Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
Add wait_for_leader_controller to our scripts and exit early and drop…
Browse files Browse the repository at this point in the history
… undefined flags. (#510)

* Add wait_for_leader_controller to our scripts and exit early.

* Drop undefined flags.
  • Loading branch information
markusthoemmes authored Jul 22, 2020
1 parent 52be02c commit 40405b3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions openshift/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,22 @@ function prepare_knative_serving_tests {
export INGRESS_CLASS=kourier.ingress.networking.knative.dev
}

function wait_for_leader_controller() {
echo -n "Waiting for a leader Controller"
for i in {1..150}; do # timeout after 5 minutes
local leader=$(kubectl get lease controller -n "${SYSTEM_NAMESPACE}" -ojsonpath='{.spec.holderIdentity}' | cut -d"_" -f1)
# Make sure the leader pod exists.
if [ -n "${leader}" ] && kubectl get pod "${leader}" -n "${SYSTEM_NAMESPACE}" >/dev/null 2>&1; then
echo -e "\nNew leader Controller has been elected"
return 0
fi
echo -n "."
sleep 2
done
echo -e "\n\nERROR: timeout waiting for leader controller"
return 1
}

function run_e2e_tests(){
header "Running tests"

Expand All @@ -201,7 +217,7 @@ function run_e2e_tests(){
kubectl -n ${SYSTEM_NAMESPACE} delete leases --all

# Wait for a new leader Controller to prevent race conditions during service reconciliation
wait_for_leader_controller || failed=1
wait_for_leader_controller || return 1

# Dump the leases post-setup.
header "Leaders"
Expand Down Expand Up @@ -254,7 +270,7 @@ function run_e2e_tests(){
# Define short -spoofinterval to ensure frequent probing while stopping pods
go_test_e2e -tags=e2e -timeout=15m -failfast -parallel=1 \
./test/ha \
-replicas="${OPENSHIFT_REPLICAS}" -buckets="${OPENSHIFT_BUCKETS}" -spoofinterval="10ms" \
-spoofinterval="10ms" \
--kubeconfig "$KUBECONFIG" \
--imagetemplate "$TEST_IMAGE_TEMPLATE" \
--resolvabledomain "$(ingress_class)"|| failed=3
Expand Down

0 comments on commit 40405b3

Please sign in to comment.