Skip to content

Commit 1ff9131

Browse files
committed
fix: ignore spurious node updates while waiting for errors
1 parent 7e6b549 commit 1ff9131

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

enterprise/tailnet/pgcoord_test.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -645,12 +645,20 @@ func (c *testConn) recvNodes(ctx context.Context, t *testing.T) []*agpl.Node {
645645

646646
func (c *testConn) recvErr(ctx context.Context, t *testing.T) error {
647647
t.Helper()
648-
select {
649-
case <-ctx.Done():
650-
t.Fatal("timeout receiving error")
651-
return ctx.Err()
652-
case err := <-c.errChan:
653-
return err
648+
// pgCoord works on eventual consistency, so it sometimes sends extra node
649+
// updates, and these block errors if not read from the nodes channel.
650+
for {
651+
select {
652+
case nodes := <-c.nodeChan:
653+
t.Logf("ignoring nodes update while waiting for error; id=%s, nodes=%+v",
654+
c.id.String(), nodes)
655+
continue
656+
case <-ctx.Done():
657+
t.Fatal("timeout receiving error")
658+
return ctx.Err()
659+
case err := <-c.errChan:
660+
return err
661+
}
654662
}
655663
}
656664

0 commit comments

Comments
 (0)