Skip to content

Commit

Permalink
Add time limit to example test curl (#424)
Browse files Browse the repository at this point in the history
Also refactor so both tests actually have to pass not just the second
one and fix gateway nodeport example

Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
  • Loading branch information
sunjayBhatia authored Aug 11, 2021
1 parent dc38ce0 commit 898379e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
10 changes: 2 additions & 8 deletions examples/gateway/gateway-nodeport.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
name: contour-gateway-sample
namespace: contour-operator
spec:
gatewayClassRef: sample-gatewayclass
gatewayControllerName: projectcontour.io/sample-controller
networkPublishing:
envoy:
type: NodePortService
Expand All @@ -25,13 +25,7 @@ apiVersion: networking.x-k8s.io/v1alpha1
metadata:
name: sample-gatewayclass
spec:
controller: projectcontour.io/contour-operator
parametersRef:
group: operator.projectcontour.io
kind: Contour
scope: Namespace
name: contour-gateway-sample
namespace: contour-operator
controller: projectcontour.io/sample-controller
---
kind: Gateway
apiVersion: networking.x-k8s.io/v1alpha1
Expand Down
20 changes: 14 additions & 6 deletions hack/test-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ waitForHttpResponse() {
while [ $attempts -le $retries ]
do
echo "Sending http request to $url (attempt #$attempts)"
resp=$(curl -w %"{http_code}" -s -o /dev/null "$url")
resp=$(curl --max-time 5 -w %"{http_code}" -s -o /dev/null "$url")
if [ "$resp" = "200" ] ; then
echo "Received http response from $url"
RESP=true
Expand All @@ -47,6 +47,14 @@ waitForHttpResponse http://local.projectcontour.io 1 100
kubectl::delete -f https://projectcontour.io/examples/kuard.yaml
kubectl::delete -f examples/contour/contour-nodeport.yaml

if [ "${RESP}" == "false" ]; then
echo "basic ingress test failed"
exit 1
fi

# Reset.
RESP=false

# Test Gateway
kubectl::apply -f examples/gateway/gateway-nodeport.yaml
kubectl::apply -f examples/gateway/kuard/kuard.yaml
Expand All @@ -61,10 +69,10 @@ kubectl::delete gatewayclasses --all-namespaces --all
kubectl::delete -f examples/gateway/gateway-nodeport.yaml
kubectl::delete -f examples/operator/operator.yaml

if ${RESP} == false ; then
echo "examples test passed"
exit 0
else
echo "examples test failed"
if [ "${RESP}" == "false" ]; then
echo "gateway test failed"
exit 1
fi

echo "all tests passed"
exit 0

0 comments on commit 898379e

Please sign in to comment.