48
48
#[ tokio:: test( flavor = "current_thread" ) ]
49
49
async fn unmeshed_http1_hello_world ( ) {
50
50
let server = hyper:: server:: conn:: http1:: Builder :: new ( ) ;
51
- #[ allow( deprecated) ] // linkerd/linkerd2#8733
52
- let mut client = hyper:: client:: conn:: Builder :: new ( ) ;
51
+ let mut client = hyper:: client:: conn:: http1:: Builder :: new ( ) ;
53
52
let _trace = trace_init ( ) ;
54
53
55
54
// Build a mock "connector" that returns the upstream "server" IO.
@@ -64,15 +63,15 @@ async fn unmeshed_http1_hello_world() {
64
63
let cfg = default_config ( ) ;
65
64
let ( rt, _shutdown) = runtime ( ) ;
66
65
let server = build_server ( cfg, rt, profiles, connect) . new_service ( Target :: UNMESHED_HTTP1 ) ;
67
- let ( client, bg) = http_util:: connect_and_accept ( & mut client, server) . await ;
66
+ let ( mut client, bg) = http_util:: connect_and_accept_http1 ( & mut client, server) . await ;
68
67
69
68
let req = Request :: builder ( )
70
69
. method ( http:: Method :: GET )
71
70
. uri ( "http://foo.svc.cluster.local:5550" )
72
71
. body ( Body :: default ( ) )
73
72
. unwrap ( ) ;
74
73
let rsp = client
75
- . oneshot ( req)
74
+ . send_request ( req)
76
75
. await
77
76
. expect ( "HTTP client request failed" ) ;
78
77
tracing:: info!( ?rsp) ;
@@ -81,6 +80,7 @@ async fn unmeshed_http1_hello_world() {
81
80
assert_eq ! ( body, "Hello world!" ) ;
82
81
83
82
// Wait for all of the background tasks to complete, panicking if any returned an error.
83
+ drop ( client) ;
84
84
bg. join_all ( )
85
85
. await
86
86
. into_iter ( )
@@ -92,9 +92,7 @@ async fn unmeshed_http1_hello_world() {
92
92
async fn downgrade_origin_form ( ) {
93
93
// Reproduces https://github.com/linkerd/linkerd2/issues/5298
94
94
let server = hyper:: server:: conn:: http1:: Builder :: new ( ) ;
95
- #[ allow( deprecated) ] // linkerd/linkerd2#8733
96
- let mut client = hyper:: client:: conn:: Builder :: new ( ) ;
97
- client. http2_only ( true ) ;
95
+ let client = hyper:: client:: conn:: http2:: Builder :: new ( TracingExecutor ) ;
98
96
let _trace = trace_init ( ) ;
99
97
100
98
// Build a mock "connector" that returns the upstream "server" IO.
@@ -109,7 +107,35 @@ async fn downgrade_origin_form() {
109
107
let cfg = default_config ( ) ;
110
108
let ( rt, _shutdown) = runtime ( ) ;
111
109
let server = build_server ( cfg, rt, profiles, connect) . new_service ( Target :: UNMESHED_H2 ) ;
112
- let ( client, bg) = http_util:: connect_and_accept ( & mut client, server) . await ;
110
+ let ( mut client, bg) = {
111
+ tracing:: info!( settings = ?client, "connecting client with" ) ;
112
+ let ( client_io, server_io) = io:: duplex ( 4096 ) ;
113
+
114
+ let ( client, conn) = client
115
+ . handshake ( client_io)
116
+ . await
117
+ . expect ( "Client must connect" ) ;
118
+
119
+ let mut bg = tokio:: task:: JoinSet :: new ( ) ;
120
+ bg. spawn (
121
+ async move {
122
+ server. oneshot ( server_io) . await ?;
123
+ tracing:: info!( "proxy serve task complete" ) ;
124
+ Ok ( ( ) )
125
+ }
126
+ . instrument ( tracing:: info_span!( "proxy" ) ) ,
127
+ ) ;
128
+ bg. spawn (
129
+ async move {
130
+ conn. await ?;
131
+ tracing:: info!( "client background complete" ) ;
132
+ Ok ( ( ) )
133
+ }
134
+ . instrument ( tracing:: info_span!( "client_bg" ) ) ,
135
+ ) ;
136
+
137
+ ( client, bg)
138
+ } ;
113
139
114
140
let req = Request :: builder ( )
115
141
. method ( http:: Method :: GET )
@@ -119,7 +145,7 @@ async fn downgrade_origin_form() {
119
145
. body ( Body :: default ( ) )
120
146
. unwrap ( ) ;
121
147
let rsp = client
122
- . oneshot ( req)
148
+ . send_request ( req)
123
149
. await
124
150
. expect ( "HTTP client request failed" ) ;
125
151
tracing:: info!( ?rsp) ;
@@ -128,6 +154,7 @@ async fn downgrade_origin_form() {
128
154
assert_eq ! ( body, "Hello world!" ) ;
129
155
130
156
// Wait for all of the background tasks to complete, panicking if any returned an error.
157
+ drop ( client) ;
131
158
bg. join_all ( )
132
159
. await
133
160
. into_iter ( )
@@ -137,10 +164,8 @@ async fn downgrade_origin_form() {
137
164
138
165
#[ tokio:: test( flavor = "current_thread" ) ]
139
166
async fn downgrade_absolute_form ( ) {
167
+ let client = hyper:: client:: conn:: http2:: Builder :: new ( TracingExecutor ) ;
140
168
let server = hyper:: server:: conn:: http1:: Builder :: new ( ) ;
141
- #[ allow( deprecated) ] // linkerd/linkerd2#8733
142
- let mut client = hyper:: client:: conn:: Builder :: new ( ) ;
143
- client. http2_only ( true ) ;
144
169
let _trace = trace_init ( ) ;
145
170
146
171
// Build a mock "connector" that returns the upstream "server" IO.
@@ -155,7 +180,36 @@ async fn downgrade_absolute_form() {
155
180
let cfg = default_config ( ) ;
156
181
let ( rt, _shutdown) = runtime ( ) ;
157
182
let server = build_server ( cfg, rt, profiles, connect) . new_service ( Target :: UNMESHED_H2 ) ;
158
- let ( client, bg) = http_util:: connect_and_accept ( & mut client, server) . await ;
183
+
184
+ let ( mut client, bg) = {
185
+ tracing:: info!( settings = ?client, "connecting client with" ) ;
186
+ let ( client_io, server_io) = io:: duplex ( 4096 ) ;
187
+
188
+ let ( client, conn) = client
189
+ . handshake ( client_io)
190
+ . await
191
+ . expect ( "Client must connect" ) ;
192
+
193
+ let mut bg = tokio:: task:: JoinSet :: new ( ) ;
194
+ bg. spawn (
195
+ async move {
196
+ server. oneshot ( server_io) . await ?;
197
+ tracing:: info!( "proxy serve task complete" ) ;
198
+ Ok ( ( ) )
199
+ }
200
+ . instrument ( tracing:: info_span!( "proxy" ) ) ,
201
+ ) ;
202
+ bg. spawn (
203
+ async move {
204
+ conn. await ?;
205
+ tracing:: info!( "client background complete" ) ;
206
+ Ok ( ( ) )
207
+ }
208
+ . instrument ( tracing:: info_span!( "client_bg" ) ) ,
209
+ ) ;
210
+
211
+ ( client, bg)
212
+ } ;
159
213
160
214
let req = Request :: builder ( )
161
215
. method ( http:: Method :: GET )
@@ -165,7 +219,7 @@ async fn downgrade_absolute_form() {
165
219
. body ( Body :: default ( ) )
166
220
. unwrap ( ) ;
167
221
let rsp = client
168
- . oneshot ( req)
222
+ . send_request ( req)
169
223
. await
170
224
. expect ( "HTTP client request failed" ) ;
171
225
tracing:: info!( ?rsp) ;
@@ -174,6 +228,7 @@ async fn downgrade_absolute_form() {
174
228
assert_eq ! ( body, "Hello world!" ) ;
175
229
176
230
// Wait for all of the background tasks to complete, panicking if any returned an error.
231
+ drop ( client) ;
177
232
bg. join_all ( )
178
233
. await
179
234
. into_iter ( )
@@ -190,16 +245,15 @@ async fn http1_bad_gateway_meshed_response_error_header() {
190
245
191
246
// Build a client using the connect that always errors so that responses
192
247
// are BAD_GATEWAY.
193
- #[ allow( deprecated) ] // linkerd/linkerd2#8733
194
- let mut client = hyper:: client:: conn:: Builder :: new ( ) ;
248
+ let mut client = hyper:: client:: conn:: http1:: Builder :: new ( ) ;
195
249
let profiles = profile:: resolver ( ) ;
196
250
let profile_tx =
197
251
profiles. profile_tx ( NameAddr :: from_str_and_port ( "foo.svc.cluster.local" , 5550 ) . unwrap ( ) ) ;
198
252
profile_tx. send ( profile:: Profile :: default ( ) ) . unwrap ( ) ;
199
253
let cfg = default_config ( ) ;
200
254
let ( rt, _shutdown) = runtime ( ) ;
201
255
let server = build_server ( cfg, rt, profiles, connect) . new_service ( Target :: meshed_http1 ( ) ) ;
202
- let ( mut client, bg) = http_util:: connect_and_accept ( & mut client, server) . await ;
256
+ let ( mut client, bg) = http_util:: connect_and_accept_http1 ( & mut client, server) . await ;
203
257
204
258
// Send a request and assert that it is a BAD_GATEWAY with the expected
205
259
// header message.
@@ -221,6 +275,7 @@ async fn http1_bad_gateway_meshed_response_error_header() {
221
275
check_error_header ( rsp. headers ( ) , "server is not listening" ) ;
222
276
223
277
// Wait for all of the background tasks to complete, panicking if any returned an error.
278
+ drop ( client) ;
224
279
bg. join_all ( )
225
280
. await
226
281
. into_iter ( )
@@ -237,16 +292,15 @@ async fn http1_bad_gateway_unmeshed_response() {
237
292
238
293
// Build a client using the connect that always errors so that responses
239
294
// are BAD_GATEWAY.
240
- #[ allow( deprecated) ] // linkerd/linkerd2#8733
241
- let mut client = hyper:: client:: conn:: Builder :: new ( ) ;
295
+ let mut client = hyper:: client:: conn:: http1:: Builder :: new ( ) ;
242
296
let profiles = profile:: resolver ( ) ;
243
297
let profile_tx =
244
298
profiles. profile_tx ( NameAddr :: from_str_and_port ( "foo.svc.cluster.local" , 5550 ) . unwrap ( ) ) ;
245
299
profile_tx. send ( profile:: Profile :: default ( ) ) . unwrap ( ) ;
246
300
let cfg = default_config ( ) ;
247
301
let ( rt, _shutdown) = runtime ( ) ;
248
302
let server = build_server ( cfg, rt, profiles, connect) . new_service ( Target :: UNMESHED_HTTP1 ) ;
249
- let ( client, bg) = http_util:: connect_and_accept ( & mut client, server) . await ;
303
+ let ( mut client, bg) = http_util:: connect_and_accept_http1 ( & mut client, server) . await ;
250
304
251
305
// Send a request and assert that it is a BAD_GATEWAY with the expected
252
306
// header message.
@@ -256,7 +310,7 @@ async fn http1_bad_gateway_unmeshed_response() {
256
310
. body ( Body :: default ( ) )
257
311
. unwrap ( ) ;
258
312
let rsp = client
259
- . oneshot ( req)
313
+ . send_request ( req)
260
314
. await
261
315
. expect ( "HTTP client request failed" ) ;
262
316
tracing:: info!( ?rsp) ;
@@ -267,6 +321,7 @@ async fn http1_bad_gateway_unmeshed_response() {
267
321
) ;
268
322
269
323
// Wait for all of the background tasks to complete, panicking if any returned an error.
324
+ drop ( client) ;
270
325
bg. join_all ( )
271
326
. await
272
327
. into_iter ( )
@@ -285,16 +340,15 @@ async fn http1_connect_timeout_meshed_response_error_header() {
285
340
286
341
// Build a client using the connect that always sleeps so that responses
287
342
// are GATEWAY_TIMEOUT.
288
- #[ allow( deprecated) ] // linkerd/linkerd2#8733
289
- let mut client = hyper:: client:: conn:: Builder :: new ( ) ;
343
+ let mut client = hyper:: client:: conn:: http1:: Builder :: new ( ) ;
290
344
let profiles = profile:: resolver ( ) ;
291
345
let profile_tx =
292
346
profiles. profile_tx ( NameAddr :: from_str_and_port ( "foo.svc.cluster.local" , 5550 ) . unwrap ( ) ) ;
293
347
profile_tx. send ( profile:: Profile :: default ( ) ) . unwrap ( ) ;
294
348
let cfg = default_config ( ) ;
295
349
let ( rt, _shutdown) = runtime ( ) ;
296
350
let server = build_server ( cfg, rt, profiles, connect) . new_service ( Target :: meshed_http1 ( ) ) ;
297
- let ( client, bg) = http_util:: connect_and_accept ( & mut client, server) . await ;
351
+ let ( mut client, bg) = http_util:: connect_and_accept_http1 ( & mut client, server) . await ;
298
352
299
353
// Send a request and assert that it is a GATEWAY_TIMEOUT with the
300
354
// expected header message.
@@ -304,7 +358,7 @@ async fn http1_connect_timeout_meshed_response_error_header() {
304
358
. body ( Body :: default ( ) )
305
359
. unwrap ( ) ;
306
360
let rsp = client
307
- . oneshot ( req)
361
+ . send_request ( req)
308
362
. await
309
363
. expect ( "HTTP client request failed" ) ;
310
364
tracing:: info!( ?rsp) ;
@@ -317,6 +371,7 @@ async fn http1_connect_timeout_meshed_response_error_header() {
317
371
check_error_header ( rsp. headers ( ) , "connect timed out after 1s" ) ;
318
372
319
373
// Wait for all of the background tasks to complete, panicking if any returned an error.
374
+ drop ( client) ;
320
375
bg. join_all ( )
321
376
. await
322
377
. into_iter ( )
@@ -335,16 +390,15 @@ async fn http1_connect_timeout_unmeshed_response_error_header() {
335
390
336
391
// Build a client using the connect that always sleeps so that responses
337
392
// are GATEWAY_TIMEOUT.
338
- #[ allow( deprecated) ] // linkerd/linkerd2#8733
339
- let mut client = hyper:: client:: conn:: Builder :: new ( ) ;
393
+ let mut client = hyper:: client:: conn:: http1:: Builder :: new ( ) ;
340
394
let profiles = profile:: resolver ( ) ;
341
395
let profile_tx =
342
396
profiles. profile_tx ( NameAddr :: from_str_and_port ( "foo.svc.cluster.local" , 5550 ) . unwrap ( ) ) ;
343
397
profile_tx. send ( profile:: Profile :: default ( ) ) . unwrap ( ) ;
344
398
let cfg = default_config ( ) ;
345
399
let ( rt, _shutdown) = runtime ( ) ;
346
400
let server = build_server ( cfg, rt, profiles, connect) . new_service ( Target :: UNMESHED_HTTP1 ) ;
347
- let ( client, bg) = http_util:: connect_and_accept ( & mut client, server) . await ;
401
+ let ( mut client, bg) = http_util:: connect_and_accept_http1 ( & mut client, server) . await ;
348
402
349
403
// Send a request and assert that it is a GATEWAY_TIMEOUT with the
350
404
// expected header message.
@@ -354,7 +408,7 @@ async fn http1_connect_timeout_unmeshed_response_error_header() {
354
408
. body ( Body :: default ( ) )
355
409
. unwrap ( ) ;
356
410
let rsp = client
357
- . oneshot ( req)
411
+ . send_request ( req)
358
412
. await
359
413
. expect ( "HTTP client request failed" ) ;
360
414
tracing:: info!( ?rsp) ;
@@ -365,6 +419,7 @@ async fn http1_connect_timeout_unmeshed_response_error_header() {
365
419
) ;
366
420
367
421
// Wait for all of the background tasks to complete, panicking if any returned an error.
422
+ drop ( client) ;
368
423
bg. join_all ( )
369
424
. await
370
425
. into_iter ( )
0 commit comments