From e715b46938ba8978d4ebf2cced588ccc5f5a990b Mon Sep 17 00:00:00 2001 From: Mark Mandel Date: Wed, 20 Nov 2019 10:24:46 -0800 Subject: [PATCH] Flaky: TestGameServerUnhealthyAfterReadyCrash This should fix the flakiness with this test. --- test/e2e/gameserver_test.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/test/e2e/gameserver_test.go b/test/e2e/gameserver_test.go index be8364cc44..7e372c1e63 100644 --- a/test/e2e/gameserver_test.go +++ b/test/e2e/gameserver_test.go @@ -335,13 +335,23 @@ func TestGameServerUnhealthyAfterReadyCrash(t *testing.T) { defer gsClient.Delete(readyGs.ObjectMeta.Name, nil) // nolint: errcheck address := fmt.Sprintf("%s:%d", readyGs.Status.Address, readyGs.Status.Ports[0].Port) - conn, err := net.Dial("udp", address) - assert.NoError(t, err) - defer conn.Close() // nolint: errcheck - _, err = conn.Write([]byte("CRASH")) - assert.NoError(t, err) - l.WithField("address", address).Info("sent UDP packet") + // keep crashing, until we move to Unhealthy. Solves potential issues with controller Informaer cache + // race conditions in which it has yet to see a GameServer is Ready before the crash. + go func() { + for { + conn, err := net.Dial("udp", address) + assert.NoError(t, err) + defer conn.Close() // nolint: errcheck + _, err = conn.Write([]byte("CRASH")) + if err != nil { + l.WithError(err).Warn("error sending udp packet. Stopping.") + return + } + l.WithField("address", address).Info("sent UDP packet") + time.Sleep(5 * time.Second) + } + }() _, err = framework.WaitForGameServerState(readyGs, agonesv1.GameServerStateUnhealthy, 3*time.Minute) assert.NoError(t, err) }