MCPcopy Index your code
hub / github.com/coder/coder / TestPGCoordinator_MultiAgent

Function TestPGCoordinator_MultiAgent

enterprise/tailnet/multiagent_test.go:24–56  ·  view source on GitHub ↗

TestPGCoordinator_MultiAgent tests a single coordinator with a MultiAgent connecting to one agent. +--------+ agent1 ---> | coord1 | <--- client +--------+

(t *testing.T)

Source from the content-addressed store, hash-verified

22// agent1 ---> | coord1 | <--- client
23// +--------+
24func TestPGCoordinator_MultiAgent(t *testing.T) {
25 t.Parallel()
26
27 logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}).Leveled(slog.LevelDebug)
28 store, ps := dbtestutil.NewDB(t)
29 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
30 defer cancel()
31 coord1, err := tailnet.NewPGCoord(ctx, logger.Named("coord1"), ps, store)
32 require.NoError(t, err)
33 defer coord1.Close()
34
35 agent1 := agpltest.NewAgent(ctx, t, coord1, "agent1")
36 defer agent1.Close(ctx)
37 agent1.UpdateDERP(5)
38
39 ma1 := agpltest.NewPeer(ctx, t, coord1, "client")
40 defer ma1.Close(ctx)
41
42 ma1.AddTunnel(agent1.ID)
43 ma1.AssertEventuallyHasDERP(agent1.ID, 5)
44
45 agent1.UpdateDERP(1)
46 ma1.AssertEventuallyHasDERP(agent1.ID, 1)
47
48 ma1.UpdateDERP(3)
49 agent1.AssertEventuallyHasDERP(ma1.ID, 3)
50
51 ma1.Disconnect()
52 agent1.UngracefulDisconnect(ctx)
53
54 assertEventuallyNoClientsForAgent(ctx, t, store, agent1.ID)
55 assertEventuallyLost(ctx, t, store, agent1.ID)
56}
57
58func TestPGCoordinator_MultiAgent_CoordClose(t *testing.T) {
59 t.Parallel()

Callers

nothing calls this directly

Calls 12

CloseMethod · 0.95
UpdateDERPMethod · 0.95
CloseMethod · 0.95
AddTunnelMethod · 0.95
DisconnectMethod · 0.95
NewDBFunction · 0.92
assertEventuallyLostFunction · 0.85
NamedMethod · 0.80
UngracefulDisconnectMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected