(t *testing.T)
| 181 | } |
| 182 | |
| 183 | func 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 | |
| 220 | func TestPGCoordinatorSingle_AgentWithClient(t *testing.T) { |
| 221 | t.Parallel() |
nothing calls this directly
no test coverage detected