Skip to content

Commit

Permalink
WIP - Updates to the test. I am actually going
Browse files Browse the repository at this point in the history
to have to track the containerID I think.

[skip ci]
  • Loading branch information
markmandel committed Oct 4, 2019
1 parent 0295e6a commit 08d6f54
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions test/e2e/gameserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,13 @@ func TestGameServerRestartBeforeReadyCrash(t *testing.T) {

gs := defaultGameServer(defaultNs)
// give some buffer with gameservers crashing and coming back
gs.Spec.Health.PeriodSeconds = 30
gs.Spec.Health.PeriodSeconds = 60 * 60
gs.Spec.Template.Spec.Containers[0].Env = append(gs.Spec.Template.Spec.Containers[0].Env, corev1.EnvVar{Name: "READY", Value: "FALSE"})
gsClient := framework.AgonesClient.AgonesV1().GameServers(defaultNs)
newGs, err := gsClient.Create(gs)
if !assert.NoError(t, err) {
assert.Fail(t, "could not create the gameserver")
}

defer gsClient.Delete(newGs.ObjectMeta.Name, nil) // nolint: errcheck

logger.Info("Waiting for us to have an address to send things to")
Expand Down Expand Up @@ -273,25 +272,34 @@ func TestGameServerRestartBeforeReadyCrash(t *testing.T) {
}
assert.Contains(t, err.Error(), "waiting for GameServer")

// ping READY until it doesn't fail anymore
var reply string
// ping READY until it doesn't fail anymore - since it may take a while
// for this to come back up -- or we could get a delayed CRASH, so we have to
// wait for the process to restart again to fire the SDK.Ready()
logger.Info("marking GameServer as ready")
err = wait.PollImmediate(time.Second, 3*time.Minute, func() (bool, error) {
reply, err = e2eframework.SendGameServerUDP(newGs, "READY")
err = wait.PollImmediate(3*time.Second, 3*time.Minute, func() (bool, error) {
newGs, err = gsClient.Get(newGs.ObjectMeta.Name, metav1.GetOptions{})
if err != nil {
logger.WithError(err).Warn("could not send READY udp packet")
return false, nil
logger.WithError(err).Warn("could not get gameserver")
return true, err
}

return true, nil
if newGs.Status.State == agonesv1.GameServerStateReady {
logger.Info("ready! Moving On!")
return true, nil
}

// create a connection each time, as weird stuff happens if the receiver isn't up and running.
conn, err := net.Dial("udp", address)
assert.NoError(t, err)
defer conn.Close() // nolint: errcheck
// doing this last, so that there is a short delay between the message being sent, and the check.
_, err = conn.Write([]byte("READY"))
logger.WithError(err).WithField("gs", newGs.ObjectMeta.Name).WithField("state", newGs.Status.State).Info("no ready, trying again")
return false, nil
})
if !assert.NoError(t, err) {
assert.FailNow(t, "Could not message GameServer")
assert.FailNow(t, "Could not make GameServer Ready")
}
assert.Equal(t, "ACK: READY\n", reply)
newGs, err = framework.WaitForGameServerState(newGs, agonesv1.GameServerStateReady, 3*time.Minute)
assert.NoError(t, err)

// now crash, should be unhealthy, since it's after being Ready
logger.Info("crashing again, should be unhealthy")
// retry on crash, as with the restarts, sometimes Go takes a moment to send this through.
Expand Down

0 comments on commit 08d6f54

Please sign in to comment.