Skip to content

Commit 92b1154

Browse files
authored
feat: validate CRDs on specific k8s versions (#3316)
Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>
1 parent ff517b3 commit 92b1154

3 files changed

Lines changed: 46 additions & 4 deletions

File tree

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ test:
8383
cd "conformance/echo-basic" && go test -race -cover ./...
8484
cd "gwctl" && go test -race -cover ./...
8585

86+
# Run tests for CRDs validation
87+
.PHONY: test.crds-validation
88+
test.crds-validation:
89+
./hack/test-crds-validation.sh $(VERSION)
90+
8691
# Run conformance tests against controller implementation
8792
.PHONY: conformance
8893
conformance:
Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,48 @@ cleanup() {
4141

4242
trap cleanup INT TERM EXIT
4343

44+
# TODO(mlavacca): find a good way to keep this dependency up to date.
45+
KIND_VERSION="v0.24.0"
46+
47+
# list of kind images taken from https://github.com/kubernetes-sigs/kind/releases/tag/v0.24.0.
48+
# they need to be updated when kind is updated.
49+
KIND_IMAGES=(
50+
"kindest/node:v1.27.17@sha256:3fd82731af34efe19cd54ea5c25e882985bafa2c9baefe14f8deab1737d9fabe"
51+
"kindest/node:v1.28.13@sha256:45d319897776e11167e4698f6b14938eb4d52eb381d9e3d7a9086c16c69a8110"
52+
"kindest/node:v1.29.8@sha256:d46b7aa29567e93b27f7531d258c372e829d7224b25e3fc6ffdefed12476d3aa"
53+
"kindest/node:v1.30.4@sha256:976ea815844d5fa93be213437e3ff5754cd599b040946b5cca43ca45c2047"
54+
"kindest/node:v1.31.0@sha256:53df588e04085fd41ae12de0c3fe4c72f7013bba32a20e7325357a1ac94ba865"
55+
)
56+
57+
if [ "$#" -gt 1 ]; then
58+
echo "Error: Too many arguments provided. Only 1 argument is allowed."
59+
exit 1
60+
fi
61+
62+
DEFAULT_INDEX=$((1))
63+
64+
if [ "$#" -eq 1 ]; then
65+
# Check if the argument is a valid number between 1 and 5
66+
if ! [[ "$1" =~ ^[1-5] ]]; then
67+
echo "Error: Argument is not a valid integer between 1 and 5."
68+
exit 1
69+
fi
70+
INDEX=$(($1))
71+
else
72+
INDEX=$((DEFAULT_INDEX))
73+
fi
74+
75+
K8S_IMAGE=${KIND_IMAGES[$((INDEX-1))]}
76+
4477
# For exit code
4578
res=0
4679

4780
# Install kind
48-
(cd $GOPATH && go install sigs.k8s.io/kind@v0.20.0) || res=$?
81+
(cd "${GOPATH}" && go install sigs.k8s.io/kind@${KIND_VERSION}) || res=$?
4982

5083
# Create cluster
5184
KIND_CREATE_ATTEMPTED=true
52-
kind create cluster --name "${CLUSTER_NAME}"
85+
kind create cluster --name "${CLUSTER_NAME}" --image "${K8S_IMAGE}" || res=$?
5386

5487
# Verify CEL validation
5588
for CHANNEL in experimental standard; do

hack/verify-all.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,14 @@ fi
5454

5555
EXCLUDE="verify-all.sh"
5656

57+
# TODO(mlavacca): once the prow configuration will be updated with a new target for
58+
# test-crds-validation.sh, we can remove it from the find command, otherwise it will be run twice.
59+
SCRIPTS=$(find "${SCRIPT_ROOT}"/hack -name "verify-*.sh" -o -name "test-crds-validation.sh")
60+
5761
ret=0
58-
for t in `ls $SCRIPT_ROOT/hack/verify-*.sh`
62+
for t in $SCRIPTS;
5963
do
60-
if is-excluded $t ; then
64+
if is-excluded "${t}" ; then
6165
echo "Skipping $t"
6266
continue
6367
fi

0 commit comments

Comments
 (0)