TestPGCoordinator_MultiAgent tests a single coordinator with a MultiAgent connecting to one agent. +--------+ agent1 ---> | coord1 | <--- client +--------+
(t *testing.T)
| 22 | // agent1 ---> | coord1 | <--- client |
| 23 | // +--------+ |
| 24 | func 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 | |
| 58 | func TestPGCoordinator_MultiAgent_CoordClose(t *testing.T) { |
| 59 | t.Parallel() |
nothing calls this directly
no test coverage detected