@@ -86,7 +86,7 @@ func TestPGCoordinatorSingle_AgentWithoutClients(t *testing.T) {
86
86
require .NoError (t , err )
87
87
defer coordinator .Close ()
88
88
89
- agent := newTestAgent (t , coordinator )
89
+ agent := newTestAgent (t , coordinator , "agent" )
90
90
defer agent .close ()
91
91
agent .sendNode (& agpl.Node {PreferredDERP : 10 })
92
92
require .Eventually (t , func () bool {
@@ -123,7 +123,7 @@ func TestPGCoordinatorSingle_AgentWithClient(t *testing.T) {
123
123
require .NoError (t , err )
124
124
defer coordinator .Close ()
125
125
126
- agent := newTestAgent (t , coordinator )
126
+ agent := newTestAgent (t , coordinator , "original" )
127
127
defer agent .close ()
128
128
agent .sendNode (& agpl.Node {PreferredDERP : 10 })
129
129
@@ -151,7 +151,7 @@ func TestPGCoordinatorSingle_AgentWithClient(t *testing.T) {
151
151
agent .waitForClose (ctx , t )
152
152
153
153
// Create a new agent connection. This is to simulate a reconnect!
154
- agent = newTestAgent (t , coordinator , agent .id )
154
+ agent = newTestAgent (t , coordinator , "reconnection" , agent .id )
155
155
// Ensure the existing listening connIO sends its node immediately!
156
156
clientNodes = agent .recvNodes (ctx , t )
157
157
require .Len (t , clientNodes , 1 )
@@ -200,7 +200,7 @@ func TestPGCoordinatorSingle_MissedHeartbeats(t *testing.T) {
200
200
require .NoError (t , err )
201
201
defer coordinator .Close ()
202
202
203
- agent := newTestAgent (t , coordinator )
203
+ agent := newTestAgent (t , coordinator , "agent" )
204
204
defer agent .close ()
205
205
agent .sendNode (& agpl.Node {PreferredDERP : 10 })
206
206
@@ -333,16 +333,16 @@ func TestPGCoordinatorDual_Mainline(t *testing.T) {
333
333
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitSuperLong )
334
334
defer cancel ()
335
335
logger := slogtest .Make (t , nil ).Leveled (slog .LevelDebug )
336
- coord1 , err := tailnet .NewPGCoord (ctx , logger , ps , store )
336
+ coord1 , err := tailnet .NewPGCoord (ctx , logger . Named ( "coord1" ) , ps , store )
337
337
require .NoError (t , err )
338
338
defer coord1 .Close ()
339
- coord2 , err := tailnet .NewPGCoord (ctx , logger , ps , store )
339
+ coord2 , err := tailnet .NewPGCoord (ctx , logger . Named ( "coord2" ) , ps , store )
340
340
require .NoError (t , err )
341
341
defer coord2 .Close ()
342
342
343
- agent1 := newTestAgent (t , coord1 )
343
+ agent1 := newTestAgent (t , coord1 , "agent1" )
344
344
defer agent1 .close ()
345
- agent2 := newTestAgent (t , coord2 )
345
+ agent2 := newTestAgent (t , coord2 , "agent2" )
346
346
defer agent2 .close ()
347
347
348
348
client11 := newTestClient (t , coord1 , agent1 .id )
@@ -460,19 +460,19 @@ func TestPGCoordinator_MultiAgent(t *testing.T) {
460
460
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitSuperLong )
461
461
defer cancel ()
462
462
logger := slogtest .Make (t , nil ).Leveled (slog .LevelDebug )
463
- coord1 , err := tailnet .NewPGCoord (ctx , logger , ps , store )
463
+ coord1 , err := tailnet .NewPGCoord (ctx , logger . Named ( "coord1" ) , ps , store )
464
464
require .NoError (t , err )
465
465
defer coord1 .Close ()
466
- coord2 , err := tailnet .NewPGCoord (ctx , logger , ps , store )
466
+ coord2 , err := tailnet .NewPGCoord (ctx , logger . Named ( "coord2" ) , ps , store )
467
467
require .NoError (t , err )
468
468
defer coord2 .Close ()
469
- coord3 , err := tailnet .NewPGCoord (ctx , logger , ps , store )
469
+ coord3 , err := tailnet .NewPGCoord (ctx , logger . Named ( "coord3" ) , ps , store )
470
470
require .NoError (t , err )
471
471
defer coord3 .Close ()
472
472
473
- agent1 := newTestAgent (t , coord1 )
473
+ agent1 := newTestAgent (t , coord1 , "agent1" )
474
474
defer agent1 .close ()
475
- agent2 := newTestAgent (t , coord2 , agent1 .id )
475
+ agent2 := newTestAgent (t , coord2 , "agent2" , agent1 .id )
476
476
defer agent2 .close ()
477
477
478
478
client := newTestClient (t , coord3 , agent1 .id )
@@ -552,7 +552,7 @@ func TestPGCoordinator_Unhealthy(t *testing.T) {
552
552
err := uut .Close ()
553
553
require .NoError (t , err )
554
554
}()
555
- agent1 := newTestAgent (t , uut )
555
+ agent1 := newTestAgent (t , uut , "agent1" )
556
556
defer agent1 .close ()
557
557
for i := 0 ; i < 3 ; i ++ {
558
558
select {
@@ -566,7 +566,7 @@ func TestPGCoordinator_Unhealthy(t *testing.T) {
566
566
agent1 .waitForClose (ctx , t )
567
567
568
568
// new agent should immediately disconnect
569
- agent2 := newTestAgent (t , uut )
569
+ agent2 := newTestAgent (t , uut , "agent2" )
570
570
defer agent2 .close ()
571
571
agent2 .waitForClose (ctx , t )
572
572
@@ -579,7 +579,7 @@ func TestPGCoordinator_Unhealthy(t *testing.T) {
579
579
// OK
580
580
}
581
581
}
582
- agent3 := newTestAgent (t , uut )
582
+ agent3 := newTestAgent (t , uut , "agent3" )
583
583
defer agent3 .close ()
584
584
select {
585
585
case <- agent3 .closeChan :
@@ -618,10 +618,10 @@ func newTestConn(ids []uuid.UUID) *testConn {
618
618
return a
619
619
}
620
620
621
- func newTestAgent (t * testing.T , coord agpl.Coordinator , id ... uuid.UUID ) * testConn {
621
+ func newTestAgent (t * testing.T , coord agpl.Coordinator , name string , id ... uuid.UUID ) * testConn {
622
622
a := newTestConn (id )
623
623
go func () {
624
- err := coord .ServeAgent (a .serverWS , a .id , "" )
624
+ err := coord .ServeAgent (a .serverWS , a .id , name )
625
625
assert .NoError (t , err )
626
626
close (a .closeChan )
627
627
}()
@@ -636,7 +636,7 @@ func (c *testConn) recvNodes(ctx context.Context, t *testing.T) []*agpl.Node {
636
636
t .Helper ()
637
637
select {
638
638
case <- ctx .Done ():
639
- t .Fatal ( " timeout receiving nodes" )
639
+ t .Fatalf ( "testConn id %s: timeout receiving nodes " , c . id )
640
640
return nil
641
641
case nodes := <- c .nodeChan :
642
642
return nodes
0 commit comments