Skip to content

Commit

Permalink
Flaky: TestAllocator && e2e test suite bug
Browse files Browse the repository at this point in the history
- Fix flakiness in this e2e test
- Fix weird issue where killall returns a non zero exit code, even with -q

Make sure killall always returns true.
  • Loading branch information
markmandel committed May 23, 2019
1 parent a812340 commit 0acbdee
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 2 additions & 0 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,11 @@ test-go:
# Runs end-to-end tests on the current configured cluster
# For minikube user the minikube-test-e2e targets
test-e2e: $(ensure-build-image)
echo "Starting e2e test runner!"
$(GO_TEST) $(agones_package)/test/e2e $(ARGS) $(GO_E2E_TEST_ARGS) \
--gameserver-image=$(GS_TEST_IMAGE) \
--pullsecret=$(IMAGE_PULL_SECRET)
echo "Finishing e2e test runner!"

# Runs end-to-end stress tests on the current configured cluster
# For minikube user the minikube-stress-test-e2e targets
Expand Down
1 change: 1 addition & 0 deletions build/e2e-image/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ echo "installing current release"
DOCKER_RUN= make install
echo "starting e2e test"
DOCKER_RUN= make test-e2e ARGS=-parallel=32
echo "completed e2e test"
4 changes: 2 additions & 2 deletions build/e2e-image/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ echo "Waiting consul port-forward to launch on 8500..."
timeout 60 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' 127.0.0.1 8500
echo "consul port-forward launched. Starting e2e tests..."
consul lock -child-exit-code=true -timeout 30m -try 30m -verbose LockE2E /root/e2e.sh
killall -q kubectl

killall -q kubectl || true
echo "successfully killed kubectl proxy"
23 changes: 20 additions & 3 deletions test/e2e/allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ import (
"io/ioutil"
"net/http"
"testing"
"time"

"agones.dev/agones/pkg/apis/allocation/v1alpha1"
stablev1alpha1 "agones.dev/agones/pkg/apis/stable/v1alpha1"
e2e "agones.dev/agones/test/e2e/framework"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
)

func TestAllocator(t *testing.T) {
Expand Down Expand Up @@ -70,9 +73,23 @@ func TestAllocator(t *testing.T) {
if !assert.Nil(t, err) {
return
}
response, err := client.Post(requestURL, "application/json", bytes.NewBuffer(body))
if !assert.Nil(t, err) {
return

// wait for the allocation system to come online
var response *http.Response
err = wait.PollImmediate(2*time.Second, 5*time.Minute, func() (bool, error) {
response, err = client.Post(requestURL, "application/json", bytes.NewBuffer(body))

if err != nil {
response.Body.Close() // nolint: errcheck
logrus.WithError(err).Infof("failing http request")
return false, nil
}

return true, nil
})

if !assert.NoError(t, err) {
assert.FailNow(t, "Http test failed")
}
defer response.Body.Close() // nolint: errcheck

Expand Down

0 comments on commit 0acbdee

Please sign in to comment.