Skip to content

Commit

Permalink
Fix race condition in e2e test script
Browse files Browse the repository at this point in the history
The build detection relied on looking up the build ID immediately
after a webhook simulation, and then repeatedly querying that build
for status. If the ID lookup beats the build record creation, the
script will time out looking for a nil build.

Look at the build list for status instead to eliminate the race.
  • Loading branch information
ironcladlou committed Nov 3, 2014
1 parent 4c54ef7 commit 843a4d1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions hack/test-end-to-end.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,12 @@ $openshift kube apply -c $CONFIG_FILE
echo "[INFO] Simulating github hook to trigger new build using curl"
curl -s -A "GitHub-Hookshot/github" -H "Content-Type:application/json" -H "X-Github-Event:push" -d @${FIXTURE_DIR}/github-webhook-example.json http://localhost:8080/osapi/v1beta1/buildConfigHooks/build100/secret101/github

echo "[INFO] Waiting for build to enter running state"
wait_for_command "$openshift kube list builds | grep -i running" $((1*TIME_MIN)) "$openshift kube list builds | grep -i -e failed -e complete -e error"

# Wait for build to complete
echo "[INFO] Waiting for build to complete"
BUILD_ID=`$openshift kube list builds --template="{{with index .Items 0}}{{.ID}}{{end}}"`
wait_for_command "$openshift kube get builds/$BUILD_ID | grep complete" $((40*TIME_MIN)) "$openshift kube get builds/$BUILD_ID | grep failed"
wait_for_command "$openshift kube list builds | grep -i complete" $((30*TIME_MIN)) "$openshift kube list builds | grep -i -e failed -e error"

echo "[INFO] Waiting for database pod to start"
wait_for_command "$openshift kube list pods | grep database | grep Running" $((30*TIME_SEC))
Expand Down

0 comments on commit 843a4d1

Please sign in to comment.