(t *testing.T)
| 571 | } |
| 572 | |
| 573 | func TestTunnel_sendAgentUpdateReconnect(t *testing.T) { |
| 574 | t.Parallel() |
| 575 | |
| 576 | ctx := testutil.Context(t, testutil.WaitShort) |
| 577 | |
| 578 | mClock := quartz.NewMock(t) |
| 579 | |
| 580 | wID1 := uuid.UUID{1} |
| 581 | aID1 := uuid.UUID{2} |
| 582 | aID2 := uuid.UUID{3} |
| 583 | |
| 584 | hsTime := time.Now().Add(-time.Minute).UTC() |
| 585 | |
| 586 | client := newFakeClient(ctx, t) |
| 587 | conn := newFakeConn(tailnet.WorkspaceUpdate{}, hsTime) |
| 588 | |
| 589 | tun, mgr := setupTunnel(t, ctx, client, mClock) |
| 590 | errCh := make(chan error, 1) |
| 591 | var resp *TunnelMessage |
| 592 | go func() { |
| 593 | r, err := mgr.unaryRPC(ctx, &ManagerMessage{ |
| 594 | Msg: &ManagerMessage_Start{ |
| 595 | Start: &StartRequest{ |
| 596 | TunnelFileDescriptor: 2, |
| 597 | CoderUrl: "https://coder.example.com", |
| 598 | ApiToken: "fakeToken", |
| 599 | }, |
| 600 | }, |
| 601 | }) |
| 602 | resp = r |
| 603 | errCh <- err |
| 604 | }() |
| 605 | testutil.RequireSend(ctx, t, client.ch, conn) |
| 606 | err := testutil.TryReceive(ctx, t, errCh) |
| 607 | require.NoError(t, err) |
| 608 | _, ok := resp.Msg.(*TunnelMessage_Start) |
| 609 | require.True(t, ok) |
| 610 | |
| 611 | // Inform the tunnel of the initial state |
| 612 | err = tun.Update(tailnet.WorkspaceUpdate{ |
| 613 | UpsertedWorkspaces: []*tailnet.Workspace{ |
| 614 | { |
| 615 | ID: wID1, Name: "w1", Status: proto.Workspace_STARTING, |
| 616 | }, |
| 617 | }, |
| 618 | UpsertedAgents: []*tailnet.Agent{ |
| 619 | { |
| 620 | ID: aID1, |
| 621 | Name: "agent1", |
| 622 | WorkspaceID: wID1, |
| 623 | Hosts: map[dnsname.FQDN][]netip.Addr{ |
| 624 | "agent1.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")}, |
| 625 | }, |
| 626 | }, |
| 627 | }, |
| 628 | }) |
| 629 | require.NoError(t, err) |
| 630 | req := testutil.TryReceive(ctx, t, mgr.requests) |
nothing calls this directly
no test coverage detected