Skip to content

Commit

Permalink
Fix verify-examples-kind.sh, it was not working at all
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Young <ynick@vmware.com>
  • Loading branch information
Nick Young committed Aug 26, 2021
1 parent 284e48b commit 3fa5d4e
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 13 deletions.
52 changes: 39 additions & 13 deletions hack/verify-examples-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,50 @@ res=0
KIND_CREATE_ATTEMPTED=true
kind create cluster --name "${CLUSTER_NAME}" --kubeconfig "${KUBECONFIG}" || res=$?

for VERSION in v1alpha1 v1alpha2
do
# Install CRDs
kubectl apply --kubeconfig "${KUBECONFIG}" -f config/crd/"${VERSION}" || res=$?
##### Test v1alpha1 CRD apply
# Install CRDs
kubectl apply --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha1 || res=$?

# Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
sleep 8
# Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
sleep 8

# Install all example gateway-api resources.
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f examples/"${VERSION}" || res=$?
# Install all example gateway-api resources.
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f examples/v1alpha1 || res=$?

# Uninstall CRDs
kubectl delete --kubeconfig "${KUBECONFIG}" -f config/crd/"${VERSION}" || res=$?
done
sleep 1

kubectl delete --kubeconfig "${KUBECONFIG}" --recursive -f examples/v1alpha1 || res=$?


# Uninstall CRDs
kubectl delete --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha1 || res=$?

# None of these examples should be successfully configured
kubectl apply --recursive -f hack/invalid-examples | grep configured && res=2

##### Test v1alpha2 CRD apply and that invalid examples are invalid.
# Install CRDs
kubectl apply --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha2 || res=$?

# Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
sleep 8

# Install all example gateway-api resources.
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f examples/v1alpha2 || res=$?

# Install invalid gateway-api resources.
# None of these examples should be successfully configured
# This is very hacky, sorry.
# Firstly, apply the examples, remembering that errors are on stdout
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f hack/invalid-examples 2>&1 | \
# First, we grep out the expected responses.
# After this, if everything is as expoected, the output should be empty.
grep -v 'is invalid' | \
grep -v 'missing required field' | \
# Then, we grep for anything else.
# If anything else is found, this will return 0
# which is *not* what we want.
grep -e '.' && \
res=2 || \
echo Examples failed as expected
# Clean up and exit
cleanup || res=$?
exit $res

0 comments on commit 3fa5d4e

Please sign in to comment.