MCPcopy Create free account
hub / github.com/coder/coder / TestPGCoordinatorSingle_AgentValidIP

Function TestPGCoordinatorSingle_AgentValidIP

enterprise/tailnet/pgcoord_test.go:183–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

181}
182
183func TestPGCoordinatorSingle_AgentValidIP(t *testing.T) {
184 t.Parallel()
185
186 store, ps := dbtestutil.NewDB(t)
187 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
188 defer cancel()
189 logger := testutil.Logger(t)
190 coordinator, err := tailnet.NewPGCoord(ctx, logger, ps, store)
191 require.NoError(t, err)
192 defer coordinator.Close()
193
194 agent := agpltest.NewAgent(ctx, t, coordinator, "agent")
195 defer agent.Close(ctx)
196 agent.UpdateNode(&proto.Node{
197 Addresses: []string{
198 agpl.TailscaleServicePrefix.PrefixFromUUID(agent.ID).String(),
199 },
200 PreferredDerp: 10,
201 })
202 require.Eventually(t, func() bool {
203 agents, err := store.GetTailnetPeers(ctx, agent.ID)
204 if err != nil && !xerrors.Is(err, sql.ErrNoRows) {
205 t.Fatalf("database error: %v", err)
206 }
207 if len(agents) == 0 {
208 return false
209 }
210 node := new(proto.Node)
211 err = gProto.Unmarshal(agents[0].Node, node)
212 assert.NoError(t, err)
213 assert.EqualValues(t, 10, node.PreferredDerp)
214 return true
215 }, testutil.WaitShort, testutil.IntervalFast)
216 agent.UngracefulDisconnect(ctx)
217 assertEventuallyLost(ctx, t, store, agent.ID)
218}
219
220func TestPGCoordinatorSingle_AgentWithClient(t *testing.T) {
221 t.Parallel()

Callers

nothing calls this directly

Calls 13

CloseMethod · 0.95
NewDBFunction · 0.92
LoggerFunction · 0.92
assertEventuallyLostFunction · 0.85
UpdateNodeMethod · 0.80
PrefixFromUUIDMethod · 0.80
UngracefulDisconnectMethod · 0.80
CloseMethod · 0.65
GetTailnetPeersMethod · 0.65
StringMethod · 0.45
IsMethod · 0.45
FatalfMethod · 0.45

Tested by

no test coverage detected