Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky: TestAllocator #789

Merged
merged 1 commit into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kuqd for interest's sake - this was the fix for the e2e tests. even with -q this was always returning a non zero status code. 🤷‍♂️

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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pooneh-m for interest's sake - this was what (seems to have) solved the flakiness issue. My theory is that there was a race condition wherein the backing pods for the service would come up after this test was run, but only sometimes (probably depending on e2e test order).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. Makes sense.

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