Skip to content

Commit

Permalink
Use faas-cli ready in e2e tests instead of bash
Browse files Browse the repository at this point in the history
The faas-cli is now able determine whether the gateway and a
specific function are ready.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Apr 11, 2024
1 parent 5cb2cdd commit 02c043e
Showing 1 changed file with 3 additions and 30 deletions.
33 changes: 3 additions & 30 deletions contrib/run_function.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ fi
kubectl --context "kind-$DEVENV" port-forward deploy/gateway -n openfaas 8080:8080 &>/dev/null & \
echo -n "$!" > "of_${DEVENV}_portforward.pid"

# port-forward needs some time to start
sleep 10

# Wait for the gateway to be ready
faas-cli ready --attempts 180 --interval

echo "Using existing password for OpenFaaS gateway retrieved from Kubernetes."
PASSWORD=$(kubectl get secret -n openfaas basic-auth -o=go-template='{{index .data "basic-auth-password"}}' | base64 --decode)
Expand All @@ -47,30 +46,4 @@ fi
faas-cli deploy --image=functions/alpine:latest --fprocess=cat --name "echo"

# Call echo function
for i in {1..180};
do
Ready="$(faas-cli describe echo | awk '{ if($1 ~ /Status:/) print $2 }')"
if [[ $Ready == "Ready" ]];
then
exit 0
fi
sleep 1
done

# Apply a CRD to test the operator

if [ "${OPERATOR}" == "1" ]; then
kubectl --context "kind-$DEVENV" apply ./alpine-fn.yaml

for i in {1..180};
do
Ready="$(faas-cli describe nodeinfo | awk '{ if($1 ~ /Status:/) print $2 }')"
if [[ $Ready == "Ready" ]];
then
exit 0
fi
sleep 1
done
fi

exit 1
faas-cli ready --attempts 180 --interval 1s echo

0 comments on commit 02c043e

Please sign in to comment.