(t *testing.T)
| 356 | } |
| 357 | |
| 358 | func TestServeControlStream(t *testing.T) { |
| 359 | http2Conn, edgeConn := newTestHTTP2Connection() |
| 360 | |
| 361 | rpcClientFactory := mockRPCClientFactory{ |
| 362 | registered: make(chan struct{}), |
| 363 | unregistered: make(chan struct{}), |
| 364 | } |
| 365 | |
| 366 | obs := NewObserver(&log, &log) |
| 367 | controlStream := NewControlStream( |
| 368 | obs, |
| 369 | mockConnectedFuse{}, |
| 370 | &TunnelProperties{}, |
| 371 | 1, |
| 372 | nil, |
| 373 | rpcClientFactory.newMockRPCClient, |
| 374 | 1*time.Second, |
| 375 | nil, |
| 376 | 1*time.Second, |
| 377 | HTTP2, |
| 378 | ) |
| 379 | http2Conn.controlStreamHandler = controlStream |
| 380 | |
| 381 | ctx, cancel := context.WithCancel(t.Context()) |
| 382 | var wg sync.WaitGroup |
| 383 | wg.Add(1) |
| 384 | go func() { |
| 385 | defer wg.Done() |
| 386 | _ = http2Conn.Serve(ctx) |
| 387 | }() |
| 388 | |
| 389 | req, err := http.NewRequestWithContext(ctx, http.MethodGet, "http://localhost:8080/", nil) |
| 390 | require.NoError(t, err) |
| 391 | req.Header.Set(InternalUpgradeHeader, ControlStreamUpgrade) |
| 392 | |
| 393 | edgeHTTP2Conn, err := testTransport.NewClientConn(edgeConn) |
| 394 | require.NoError(t, err) |
| 395 | |
| 396 | wg.Add(1) |
| 397 | go func() { |
| 398 | defer wg.Done() |
| 399 | // nolint: bodyclose |
| 400 | _, _ = edgeHTTP2Conn.RoundTrip(req) |
| 401 | }() |
| 402 | |
| 403 | <-rpcClientFactory.registered |
| 404 | cancel() |
| 405 | <-rpcClientFactory.unregistered |
| 406 | assert.False(t, http2Conn.stoppedGracefully) |
| 407 | |
| 408 | wg.Wait() |
| 409 | } |
| 410 | |
| 411 | func TestFailRegistration(t *testing.T) { |
| 412 | http2Conn, edgeConn := newTestHTTP2Connection() |
nothing calls this directly
no test coverage detected