Skip to content

Commit 3fa5d4e

Browse files
author
Nick Young
committed
Fix verify-examples-kind.sh, it was not working at all
Signed-off-by: Nick Young <[email protected]>
1 parent 284e48b commit 3fa5d4e

16 files changed

+39
-13
lines changed

hack/verify-examples-kind.sh

+39-13
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,50 @@ res=0
5151
KIND_CREATE_ATTEMPTED=true
5252
kind create cluster --name "${CLUSTER_NAME}" --kubeconfig "${KUBECONFIG}" || res=$?
5353

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

59-
# Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
60-
sleep 8
58+
# Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
59+
sleep 8
6160

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

65-
# Uninstall CRDs
66-
kubectl delete --kubeconfig "${KUBECONFIG}" -f config/crd/"${VERSION}" || res=$?
67-
done
64+
sleep 1
65+
66+
kubectl delete --kubeconfig "${KUBECONFIG}" --recursive -f examples/v1alpha1 || res=$?
67+
68+
69+
# Uninstall CRDs
70+
kubectl delete --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha1 || res=$?
6871

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

73+
##### Test v1alpha2 CRD apply and that invalid examples are invalid.
74+
# Install CRDs
75+
kubectl apply --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha2 || res=$?
76+
77+
# Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
78+
sleep 8
79+
80+
# Install all example gateway-api resources.
81+
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f examples/v1alpha2 || res=$?
82+
83+
# Install invalid gateway-api resources.
84+
# None of these examples should be successfully configured
85+
# This is very hacky, sorry.
86+
# Firstly, apply the examples, remembering that errors are on stdout
87+
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f hack/invalid-examples 2>&1 | \
88+
# First, we grep out the expected responses.
89+
# After this, if everything is as expoected, the output should be empty.
90+
grep -v 'is invalid' | \
91+
grep -v 'missing required field' | \
92+
# Then, we grep for anything else.
93+
# If anything else is found, this will return 0
94+
# which is *not* what we want.
95+
grep -e '.' && \
96+
res=2 || \
97+
echo Examples failed as expected
7298
# Clean up and exit
7399
cleanup || res=$?
74100
exit $res

0 commit comments

Comments
 (0)