(t *testing.T)
| 409 | } |
| 410 | |
| 411 | func TestFailRegistration(t *testing.T) { |
| 412 | http2Conn, edgeConn := newTestHTTP2Connection() |
| 413 | |
| 414 | rpcClientFactory := mockRPCClientFactory{ |
| 415 | shouldFail: errDuplicationConnection, |
| 416 | registered: make(chan struct{}), |
| 417 | unregistered: make(chan struct{}), |
| 418 | } |
| 419 | |
| 420 | obs := NewObserver(&log, &log) |
| 421 | controlStream := NewControlStream( |
| 422 | obs, |
| 423 | mockConnectedFuse{}, |
| 424 | &TunnelProperties{}, |
| 425 | http2Conn.connIndex, |
| 426 | nil, |
| 427 | rpcClientFactory.newMockRPCClient, |
| 428 | 1*time.Second, |
| 429 | nil, |
| 430 | 1*time.Second, |
| 431 | HTTP2, |
| 432 | ) |
| 433 | http2Conn.controlStreamHandler = controlStream |
| 434 | |
| 435 | ctx, cancel := context.WithCancel(t.Context()) |
| 436 | var wg sync.WaitGroup |
| 437 | wg.Add(1) |
| 438 | go func() { |
| 439 | defer wg.Done() |
| 440 | _ = http2Conn.Serve(ctx) |
| 441 | }() |
| 442 | |
| 443 | req, err := http.NewRequestWithContext(ctx, http.MethodGet, "http://localhost:8080/", nil) |
| 444 | require.NoError(t, err) |
| 445 | req.Header.Set(InternalUpgradeHeader, ControlStreamUpgrade) |
| 446 | |
| 447 | edgeHTTP2Conn, err := testTransport.NewClientConn(edgeConn) |
| 448 | require.NoError(t, err) |
| 449 | resp, err := edgeHTTP2Conn.RoundTrip(req) |
| 450 | require.NoError(t, err) |
| 451 | defer resp.Body.Close() |
| 452 | require.Equal(t, http.StatusBadGateway, resp.StatusCode) |
| 453 | |
| 454 | require.Error(t, http2Conn.controlStreamErr) |
| 455 | cancel() |
| 456 | wg.Wait() |
| 457 | } |
| 458 | |
| 459 | func TestGracefulShutdownHTTP2(t *testing.T) { |
| 460 | http2Conn, edgeConn := newTestHTTP2Connection() |
nothing calls this directly
no test coverage detected