Skip to content

Commit

Permalink
Flaky: Fix test for TestGameServerUnhealthyAfterDeletingPod (#758)
Browse files Browse the repository at this point in the history
Change in behaviour on Unhealthy GameServers that are not in Fleets
(deleted vs just being marked as Unhealthy), caused this e2e test
to be flaky.

Added a TODO to review if we are still happy with this, since
release is coming up, and having stable tests is most important right
now.
  • Loading branch information
markmandel authored May 7, 2019
1 parent 93f0c3a commit 521be13
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func (f *Framework) WaitForGameServerState(gs *v1alpha1.GameServer, state v1alph
readyGs, pollErr = f.AgonesClient.StableV1alpha1().GameServers(gs.Namespace).Get(gs.Name, metav1.GetOptions{})

if pollErr != nil {
logrus.WithError(pollErr).Warn("error retrieving gameserver")
return false, nil
}

Expand Down
25 changes: 24 additions & 1 deletion test/e2e/gameserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"agones.dev/agones/pkg/apis/stable"
"agones.dev/agones/pkg/apis/stable/v1alpha1"
e2eframework "agones.dev/agones/test/e2e/framework"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -192,6 +193,8 @@ func TestGameServerUnhealthyAfterDeletingPod(t *testing.T) {
t.Fatalf("Could not get a GameServer ready: %v", err)
}

logrus.WithField("gsKey", readyGs.ObjectMeta.Name).Info("GameServer Ready")

gsClient := framework.AgonesClient.StableV1alpha1().GameServers(defaultNs)
podClient := framework.KubeClient.CoreV1().Pods(defaultNs)

Expand All @@ -205,7 +208,27 @@ func TestGameServerUnhealthyAfterDeletingPod(t *testing.T) {
err = podClient.Delete(pod.ObjectMeta.Name, nil)
assert.NoError(t, err)

_, err = framework.WaitForGameServerState(readyGs, v1alpha1.GameServerStateUnhealthy, 10*time.Second)
// TODO [[email protected]]: Should GameServers that are Unhealthy and not in a fleet be deleted?
err = wait.PollImmediate(2*time.Second, time.Minute, func() (bool, error) {
gs, err := framework.AgonesClient.StableV1alpha1().GameServers(readyGs.Namespace).Get(readyGs.ObjectMeta.Name, metav1.GetOptions{})

// just in case
if k8serrors.IsNotFound(err) {
return true, nil
}

if err != nil {
logrus.WithError(err).Warn("error retrieving gameserver")
return false, nil
}

if gs.Status.State == v1alpha1.GameServerStateUnhealthy {
return true, nil
}

return false, nil
})

assert.NoError(t, err)
}

Expand Down

0 comments on commit 521be13

Please sign in to comment.