diff --git a/test/e2e/gameserver_test.go b/test/e2e/gameserver_test.go index 63ad565be1..6f449f5c89 100644 --- a/test/e2e/gameserver_test.go +++ b/test/e2e/gameserver_test.go @@ -22,6 +22,7 @@ import ( "net" "os/exec" "strings" + "sync/atomic" "testing" "time" @@ -385,8 +386,16 @@ func TestGameServerUnhealthyAfterReadyCrash(t *testing.T) { // keep crashing, until we move to Unhealthy. Solves potential issues with controller Informer cache // race conditions in which it has yet to see a GameServer is Ready before the crash. + var stop int32 = 0 + defer func() { + atomic.StoreInt32(&stop, 1) + }() go func() { for { + if atomic.LoadInt32(&stop) > 0 { + l.Info("UDP Crash stop signal received. Stopping.") + return + } conn, err := net.Dial("udp", address) assert.NoError(t, err) defer conn.Close() // nolint: errcheck