Skip to content

Commit

Permalink
Fixes for flaky e2e tests.
Browse files Browse the repository at this point in the history
Some more fixes for the flaky e2e tests.
  • Loading branch information
markmandel committed Jan 24, 2019
1 parent 625728e commit 4f20388
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
18 changes: 14 additions & 4 deletions test/e2e/fleetautoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ package e2e

import (
"fmt"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/util/wait"
"math/rand"
"testing"
"time"
Expand Down Expand Up @@ -246,11 +248,9 @@ func TestAutoscalerWebhook(t *testing.T) {
// if we could not create the webhook pod, there is no point going further
assert.FailNow(t, "Failed creating webhook pod, aborting TestAutoscalerWebhook")
}
svc.ObjectMeta.Name = ""
svc.ObjectMeta.GenerateName = "test-service-"

// since we're using statically-named service, perform a best-effort delete of a previous service
framework.KubeClient.CoreV1().Services(defaultNs).Delete(svc.ObjectMeta.Name, waitForDeletion) // nolint:errcheck

svc, err = framework.KubeClient.CoreV1().Services(defaultNs).Create(svc)
if assert.Nil(t, err) {
defer framework.KubeClient.CoreV1().Services(defaultNs).Delete(svc.ObjectMeta.Name, nil) // nolint:errcheck
Expand Down Expand Up @@ -416,7 +416,17 @@ func TestTlsWebhook(t *testing.T) {
}

// since we're using statically-named service, perform a best-effort delete of a previous service
framework.KubeClient.CoreV1().Services(defaultNs).Delete(svc.ObjectMeta.Name, waitForDeletion) // nolint:errcheck
err = framework.KubeClient.CoreV1().Services(defaultNs).Delete(svc.ObjectMeta.Name, waitForDeletion)
if err != nil {
assert.True(t, k8serrors.IsNotFound(err))
}

// making sure the service is really gone.
err = wait.PollImmediate(2*time.Second, time.Minute, func() (bool, error) {
_, err := framework.KubeClient.CoreV1().Services(defaultNs).Get(svc.ObjectMeta.Name, metav1.GetOptions{})
return k8serrors.IsNotFound(err), nil
})
assert.Nil(t, err)

svc, err = framework.KubeClient.CoreV1().Services(defaultNs).Create(svc)
if assert.Nil(t, err) {
Expand Down
18 changes: 13 additions & 5 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,23 +189,31 @@ func (f *Framework) WaitForFleetGameServersCondition(flt *v1alpha1.Fleet, cond f
// CleanUp Delete all Agones resources in a given namespace
func (f *Framework) CleanUp(ns string) error {
logrus.Info("Done. Cleaning up now.")
err := f.AgonesClient.StableV1alpha1().Fleets(ns).DeleteCollection(&metav1.DeleteOptions{}, metav1.ListOptions{})
alpha1 := f.AgonesClient.StableV1alpha1()
do := &metav1.DeleteOptions{}
options := metav1.ListOptions{}
err := alpha1.Fleets(ns).DeleteCollection(do, options)
if err != nil {
return err
}

err = f.AgonesClient.StableV1alpha1().GameServerAllocations(ns).DeleteCollection(&metav1.DeleteOptions{}, metav1.ListOptions{})
err = alpha1.GameServerAllocations(ns).DeleteCollection(do, options)
if err != nil {
return err
}

err = f.AgonesClient.StableV1alpha1().FleetAllocations(ns).DeleteCollection(&metav1.DeleteOptions{}, metav1.ListOptions{})
err = alpha1.FleetAllocations(ns).DeleteCollection(do, options)
if err != nil {
return err
}

return f.AgonesClient.StableV1alpha1().GameServers(ns).
DeleteCollection(&metav1.DeleteOptions{}, metav1.ListOptions{})
err = alpha1.FleetAutoscalers(ns).DeleteCollection(do, options)
if err != nil {
return err
}

return alpha1.GameServers(ns).
DeleteCollection(do, options)
}

// PingGameServer pings a gameserver and returns its reply
Expand Down

0 comments on commit 4f20388

Please sign in to comment.