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:
parent
03e6febc35
commit
7c96458d8c
1 changed files with 12 additions and 6 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue