Skip to content
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
1 change: 1 addition & 0 deletions test/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ set +o pipefail

wait_until_pods_running knative-serving
wait_until_pods_running istio-system
wait_until_service_has_external_ip istio-system knative-ingressgateway
abort_if_failed

# Run the tests
Expand Down
26 changes: 24 additions & 2 deletions test/library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ function delete_gcr_images() {
# Parameters: $1 - namespace.
function wait_until_pods_running() {
echo -n "Waiting until all pods in namespace $1 are up"
local ns="$1"
for i in {1..150}; do # timeout after 5 minutes
local has_pending="$(kubectl get pods -n $ns -o jsonpath='{.items[*].status.phase}' | grep Pending)"
local pods="$(kubectl get pods -n $1 2>/dev/null | grep -v NAME)"
local not_running=$(echo "${pods}" | grep -v Running | wc -l)
if [[ -n "${pods}" && ${not_running} == 0 ]]; then
if [[ -n "${pods}" && -z "${has_pending}" ]]; then
echo -e "\nAll pods are up:"
kubectl get pods -n $1
return 0
Expand All @@ -96,6 +97,27 @@ function wait_until_pods_running() {
return 1
}

# Waits until the given service has an external IP address.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You need 2 parameters in this function, I suggest documenting $1 and $2 just like line 80, for example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks!

# Parameters: $1 - namespace.
# Parameters: $2 - service name.
function wait_until_service_has_external_ip() {
local ns=$1
local svc=$2
echo -n "Waiting until service $svc in namespace $ns has an external IP"
for i in {1..150}; do # timeout after 15 minutes
local ip=$(kubectl get svc -n $ns $svc -o jsonpath="{.status.loadBalancer.ingress[0].ip}")
if [[ -n "${ip}" ]]; then
echo -e "\nService $svc.$ns has IP $ip"
return 0
fi
echo -n "."
sleep 6
done
echo -e "\n\nERROR: timeout waiting for service $svc.$ns to have external IP"
kubectl get pods -n $1
return 1
}

# Returns the name of the Knative Serving pod of the given app.
# Parameters: $1 - Knative Serving app name.
function get_knative_pod() {
Expand Down