fix(tai/tunnel): handle concurrent "open" frames in TestRegister_Ping

In CI environments where a real tai gRPC endpoint is reachable on
port 19100, the asynchronous connectTunnelNode goroutine can dial
successfully and send an "open" TunnelControl frame on the Register
stream before the test's "pong" arrives.

Loop on Recv() and skip non-pong frames so the test passes regardless
of whether connectTunnelNode fires in the background.

Made-with: Cursor
This commit is contained in:
Max 2026-03-28 09:13:21 +08:00
parent 03e6febc35
commit 7c96458d8c

View file

@ -185,12 +185,18 @@ func TestRegister_Ping(t *testing.T) {
t.Fatal(err)
}
// Loop until we receive "pong"; skip "open" frames that may arrive from
// the asynchronous connectTunnelNode goroutine if a real gRPC endpoint
// happens to be reachable in the test environment.
for {
pong, err := stream.Recv()
if err != nil {
t.Fatal(err)
}
if pong.Type != "pong" {
t.Errorf("expected pong, got %q", pong.Type)
if pong.Type == "pong" {
break
}
// skip unexpected frames (e.g. "open" from connectTunnelNode)
}
stream.CloseSend()