From 01b8869d60dc06d106aae4f69d6cc830274187d9 Mon Sep 17 00:00:00 2001 From: Venktesh Date: Mon, 5 Jun 2023 16:15:51 +0100 Subject: [PATCH 01/16] Run k8s gateway api conformance tests --- conformance-tests/Dockerfile | 10 +++++ conformance-tests/Makefile | 50 ++++++++++++++++++++++++ conformance-tests/README.md | 56 +++++++++++++++++++++++++++ conformance-tests/conformance_test.go | 55 ++++++++++++++++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 conformance-tests/Dockerfile create mode 100644 conformance-tests/Makefile create mode 100644 conformance-tests/README.md create mode 100644 conformance-tests/conformance_test.go diff --git a/conformance-tests/Dockerfile b/conformance-tests/Dockerfile new file mode 100644 index 0000000000..9480beacbd --- /dev/null +++ b/conformance-tests/Dockerfile @@ -0,0 +1,10 @@ +# syntax=docker/dockerfile:1.5 + +FROM golang:1.20 + +WORKDIR /go/src/github.com/nginxinc/nginx-kubernetes-gateway/conformance-tests + +COPY --link go.mod go.sum /go/src/github.com/nginxinc/nginx-kubernetes-gateway/ +RUN go mod download + +COPY --link conformance-tests /go/src/github.com/nginxinc/nginx-kubernetes-gateway/conformance-tests/ \ No newline at end of file diff --git a/conformance-tests/Makefile b/conformance-tests/Makefile new file mode 100644 index 0000000000..0ad19fef4e --- /dev/null +++ b/conformance-tests/Makefile @@ -0,0 +1,50 @@ +GATEWAY_CLASS = nginx +SUPPORTED_FEATURES = Gateway +KIND_KUBE_CONFIG_FOLDER = $${HOME}/.kube/kind +TAG = latest +PREFIX = conformance-test-runner +.DEFAULT_GOAL := help + +.PHONY: help +help: Makefile ## Display this help + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "; printf "Usage:\n\n make \033[36m\033[0m\n\nTargets:\n\n"}; {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: build-test-image +build-test-image: ## Build conformance test image + docker build -t $(PREFIX):$(TAG) -f Dockerfile .. + +.PHONY: create-kind-cluster +create-kind-cluster: ## Create a KinD cluster + kind create cluster --image kindest/node:v1.27.1 + kind export kubeconfig --kubeconfig $(KIND_KUBE_CONFIG_FOLDER)/config + +.PHONY: install-nkg +install-nkg: ## Install NKG on configured KinD cluster + kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.7.0/standard-install.yaml + kubectl apply -f ../../deploy/manifests/namespace.yaml + kubectl create configmap njs-modules --from-file=../../internal/nginx/modules/src/httpmatches.js -n nginx-gateway + kubectl apply -f ../../deploy/manifests/nginx-conf.yaml + kubectl apply -f ../../deploy/manifests/rbac.yaml && sleep 3 + kubectl apply -f ../../deploy/manifests/gatewayclass.yaml + kubectl apply -f ../../deploy/manifests/deployment.yaml + kubectl apply -f ../../deploy/manifests/service/nodeport.yaml + kubectl apply -f ../../conformance/provisioner/provisioner.yaml + +.PHONY: update-test-kind-config +update-test-kind-config: ## Update KinD config + sed -ir "s|server:.*|server: https://kind-control-plane:6443|" $(KIND_KUBE_CONFIG_FOLDER)/config + +.PHONY: run-conformance-tests +run-conformance-tests: update-test-kind-config ## Run conformance tests + docker run --network=kind --rm -v $(KIND_KUBE_CONFIG_FOLDER):/root/.kube $(PREFIX):$(TAG) \ + go test -v . -args --gateway-class=$(GATEWAY_CLASS) --supported-features=$(SUPPORTED_FEATURES) + +.PHONY: uninstall-nkg +uninstall-nkg: ## Uninstall NKG on configured KinD cluster + kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.7.0/standard-install.yaml + kubectl delete -f ../../deploy/manifests/rbac.yaml + kubectl delete -f ../../deploy/manifests/namespace.yaml + +.PHONY: delete-kind-cluster +delete-kind-cluster: ## Delete kind cluster + kind delete cluster \ No newline at end of file diff --git a/conformance-tests/README.md b/conformance-tests/README.md new file mode 100644 index 0000000000..ef5b42b32c --- /dev/null +++ b/conformance-tests/README.md @@ -0,0 +1,56 @@ +# Running [Gateway Conformance Tests](https://gateway-api.sigs.k8s.io/concepts/conformance/#3-conformance-tests) in Kind + +## Prerequisites: + +* [Kind](https://kind.sigs.k8s.io/). +* Docker. +* Golang. + +**Note**: all commands in steps below are executed from the ```conformance-tests``` directory + +List available commands: + +```bash +$ make + +build-test-image Build conformance test image +create-kind-cluster Create a KinD cluster +delete-kind-cluster Delete kind cluster +help Display this help +install-nkg Install NKG on configured KinD cluster +run-conformance-tests Run conformance tests +uninstall-nkg Uninstall NKG from configured KinD cluster +update-test-kind-config Update KinD config +``` +### Step 1 - Create a Kind Cluster + +```bash +$ make create-kind-cluster +``` + +### Step 2 - Build conformance test image +**Note**: Make sure to run `export DOCKER_BUILDKIT=1` before executing below command. + +```bash +$ make build-test-image +``` + +### Step 3 - Install Nginx Kubernetes Gateway +```bash +$ make install-nkg +``` + +### Step 4 - Run Gateway conformance tests +```bash +$ make run-conformance-tests +``` + +### Step 5 - Uninstall Nginx Kubernetes Gateway +```bash +$ make uninstall-nkg +``` + +### Step 6 - Delete KinD cluster +```bash +$ make delete-kind-cluster +``` \ No newline at end of file diff --git a/conformance-tests/conformance_test.go b/conformance-tests/conformance_test.go new file mode 100644 index 0000000000..9d572ca470 --- /dev/null +++ b/conformance-tests/conformance_test.go @@ -0,0 +1,55 @@ +/* +Copyright 2022 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package tests + +import ( + "testing" + + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/config" + "sigs.k8s.io/gateway-api/apis/v1alpha2" + "sigs.k8s.io/gateway-api/apis/v1beta1" + "sigs.k8s.io/gateway-api/conformance/tests" + "sigs.k8s.io/gateway-api/conformance/utils/flags" + "sigs.k8s.io/gateway-api/conformance/utils/suite" +) + +func TestConformance(t *testing.T) { + cfg, err := config.GetConfig() + if err != nil { + t.Fatalf("Error loading Kubernetes config: %v", err) + } + client, err := client.New(cfg, client.Options{}) + if err != nil { + t.Fatalf("Error initializing Kubernetes client: %v", err) + } + v1alpha2.AddToScheme(client.Scheme()) + v1beta1.AddToScheme(client.Scheme()) + + t.Logf("Running conformance tests with %s GatewayClass\n cleanup: %t\n debug: %t\n enable all features: %t \n supported features: [%v]\n exempt features: [%v]", + *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug, *flags.EnableAllSupportedFeatures, *flags.SupportedFeatures, *flags.ExemptFeatures) + + cSuite := suite.New(suite.Options{ + Client: client, + GatewayClassName: *flags.GatewayClassName, + Debug: *flags.ShowDebug, + CleanupBaseResources: *flags.CleanupBaseResources, + SupportedFeatures: nil, + EnableAllSupportedFeatures: *flags.EnableAllSupportedFeatures, + }) + cSuite.Setup(t) + cSuite.Run(t, tests.ConformanceTests) +} From 1e24883422ae32b398cb28db4f329f2d30cec207 Mon Sep 17 00:00:00 2001 From: Venktesh Date: Mon, 5 Jun 2023 16:55:37 +0100 Subject: [PATCH 02/16] update go files --- go.mod | 3 +++ go.sum | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/go.mod b/go.mod index 5d64243740..cedbfa9a9b 100644 --- a/go.mod +++ b/go.mod @@ -42,15 +42,18 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect + github.com/moby/spdystream v0.2.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.15.1 // indirect github.com/prometheus/client_model v0.4.0 // indirect github.com/prometheus/common v0.42.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + github.com/stretchr/testify v1.8.2 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.7.0 // indirect go.uber.org/zap v1.24.0 // indirect diff --git a/go.sum b/go.sum index 50f2427308..884da04d96 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -75,6 +76,7 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJY github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= @@ -101,6 +103,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zk github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/maxbrunsfeld/counterfeiter/v6 v6.6.1 h1:9XE5ykDiC8eNSqIPkxx0EsV3kMX1oe4kQWRZjIgytUA= github.com/maxbrunsfeld/counterfeiter/v6 v6.6.1/go.mod h1:qbKwBR+qQODzH2WD/s53mdgp/xVcXMlJb59GRFOp6Z4= +github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= +github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -145,6 +149,7 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= From 3b488fcb1e1ccde8a048d248e7367d8da2518ff1 Mon Sep 17 00:00:00 2001 From: Venktesh Date: Mon, 5 Jun 2023 17:16:13 +0100 Subject: [PATCH 03/16] Update instructions --- conformance-tests/Makefile | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/conformance-tests/Makefile b/conformance-tests/Makefile index 0ad19fef4e..41946c63b7 100644 --- a/conformance-tests/Makefile +++ b/conformance-tests/Makefile @@ -19,16 +19,15 @@ create-kind-cluster: ## Create a KinD cluster kind export kubeconfig --kubeconfig $(KIND_KUBE_CONFIG_FOLDER)/config .PHONY: install-nkg -install-nkg: ## Install NKG on configured KinD cluster - kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.7.0/standard-install.yaml - kubectl apply -f ../../deploy/manifests/namespace.yaml - kubectl create configmap njs-modules --from-file=../../internal/nginx/modules/src/httpmatches.js -n nginx-gateway - kubectl apply -f ../../deploy/manifests/nginx-conf.yaml - kubectl apply -f ../../deploy/manifests/rbac.yaml && sleep 3 - kubectl apply -f ../../deploy/manifests/gatewayclass.yaml - kubectl apply -f ../../deploy/manifests/deployment.yaml - kubectl apply -f ../../deploy/manifests/service/nodeport.yaml - kubectl apply -f ../../conformance/provisioner/provisioner.yaml +install-nkg: ## Install NKG with provisioner on configured KinD cluster + kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.7.0/standard-install.yaml && sleep 10 + kubectl apply -f ../deploy/manifests/namespace.yaml + kubectl create configmap njs-modules --from-file=../internal/nginx/modules/src/httpmatches.js -n nginx-gateway + kubectl apply -f ../deploy/manifests/nginx-conf.yaml + kubectl apply -f ../deploy/manifests/rbac.yaml + kubectl apply -f ../deploy/manifests/gatewayclass.yaml + kubectl apply -f ../deploy/manifests/service/nodeport.yaml + kubectl apply -f ../conformance/provisioner/provisioner.yaml .PHONY: update-test-kind-config update-test-kind-config: ## Update KinD config @@ -42,8 +41,8 @@ run-conformance-tests: update-test-kind-config ## Run conformance tests .PHONY: uninstall-nkg uninstall-nkg: ## Uninstall NKG on configured KinD cluster kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.7.0/standard-install.yaml - kubectl delete -f ../../deploy/manifests/rbac.yaml - kubectl delete -f ../../deploy/manifests/namespace.yaml + kubectl delete -f ../deploy/manifests/rbac.yaml + kubectl delete -f ../deploy/manifests/namespace.yaml .PHONY: delete-kind-cluster delete-kind-cluster: ## Delete kind cluster From 9b278a9632fc1a6f80e988e28b4a48f462e825b3 Mon Sep 17 00:00:00 2001 From: Venktesh Date: Tue, 6 Jun 2023 16:01:43 +0100 Subject: [PATCH 04/16] linter changes & excluted conf test from unit-test --- Makefile | 2 +- conformance-tests/conformance_test.go | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 9b893be60e..f3c3c6dfca 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ lint: ## Run golangci-lint against code .PHONY: unit-test unit-test: ## Run unit tests for the go code - go test ./... -race -coverprofile cover.out + go test ./... -race -coverprofile cover.out -skip TestConformance go tool cover -html=cover.out -o cover.html njs-unit-test: ## Run unit tests for the njs httpmatches module diff --git a/conformance-tests/conformance_test.go b/conformance-tests/conformance_test.go index 9d572ca470..90646c1a9e 100644 --- a/conformance-tests/conformance_test.go +++ b/conformance-tests/conformance_test.go @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ + package tests import ( @@ -36,11 +37,13 @@ func TestConformance(t *testing.T) { if err != nil { t.Fatalf("Error initializing Kubernetes client: %v", err) } - v1alpha2.AddToScheme(client.Scheme()) - v1beta1.AddToScheme(client.Scheme()) + _ = v1alpha2.AddToScheme(client.Scheme()) + _ = v1beta1.AddToScheme(client.Scheme()) - t.Logf("Running conformance tests with %s GatewayClass\n cleanup: %t\n debug: %t\n enable all features: %t \n supported features: [%v]\n exempt features: [%v]", - *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug, *flags.EnableAllSupportedFeatures, *flags.SupportedFeatures, *flags.ExemptFeatures) + t.Logf(`Running conformance tests with %s GatewayClass\n cleanup: %t\n`+ + `debug: %t\n enable all features: %t \n supported features: [%v]\n exempt features: [%v]`, + *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug, + *flags.EnableAllSupportedFeatures, *flags.SupportedFeatures, *flags.ExemptFeatures) cSuite := suite.New(suite.Options{ Client: client, From c9c0f5e60a68dca5a328a361bd6d2b77f36027bd Mon Sep 17 00:00:00 2001 From: Venktesh Date: Wed, 7 Jun 2023 13:16:15 +0100 Subject: [PATCH 05/16] Remove blind sleep and update readme --- conformance-tests/Makefile | 5 ++++- conformance-tests/README.md | 2 -- conformance-tests/wait_for_webhook.sh | 11 +++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100755 conformance-tests/wait_for_webhook.sh diff --git a/conformance-tests/Makefile b/conformance-tests/Makefile index 41946c63b7..cbeed33d2b 100644 --- a/conformance-tests/Makefile +++ b/conformance-tests/Makefile @@ -20,7 +20,8 @@ create-kind-cluster: ## Create a KinD cluster .PHONY: install-nkg install-nkg: ## Install NKG with provisioner on configured KinD cluster - kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.7.0/standard-install.yaml && sleep 10 + kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.7.0/standard-install.yaml + ./wait_for_webhook.sh kubectl apply -f ../deploy/manifests/namespace.yaml kubectl create configmap njs-modules --from-file=../internal/nginx/modules/src/httpmatches.js -n nginx-gateway kubectl apply -f ../deploy/manifests/nginx-conf.yaml @@ -43,6 +44,8 @@ uninstall-nkg: ## Uninstall NKG on configured KinD cluster kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.7.0/standard-install.yaml kubectl delete -f ../deploy/manifests/rbac.yaml kubectl delete -f ../deploy/manifests/namespace.yaml + kubectl delete clusterrole nginx-gateway-provisioner + kubectl delete clusterrolebinding nginx-gateway-provisioner .PHONY: delete-kind-cluster delete-kind-cluster: ## Delete kind cluster diff --git a/conformance-tests/README.md b/conformance-tests/README.md index ef5b42b32c..f3fc817548 100644 --- a/conformance-tests/README.md +++ b/conformance-tests/README.md @@ -29,8 +29,6 @@ $ make create-kind-cluster ``` ### Step 2 - Build conformance test image -**Note**: Make sure to run `export DOCKER_BUILDKIT=1` before executing below command. - ```bash $ make build-test-image ``` diff --git a/conformance-tests/wait_for_webhook.sh b/conformance-tests/wait_for_webhook.sh new file mode 100755 index 0000000000..982293863f --- /dev/null +++ b/conformance-tests/wait_for_webhook.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +export exit=1 +export count=0 +while (( exit == 1 )) && (( count < 10)); do + sleep 1 + count=$((count+1)) + echo waiting $count seconds for webhook container + kubectl get events -n gateway-system | grep "Started container webhook" + exit=`echo $?` +done \ No newline at end of file From be457430be01608ad0cf8f7e1e0ce56df1342c03 Mon Sep 17 00:00:00 2001 From: Venktesh Date: Wed, 7 Jun 2023 15:00:59 +0100 Subject: [PATCH 06/16] add chmod cmd to Makefile --- conformance-tests/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/conformance-tests/Makefile b/conformance-tests/Makefile index cbeed33d2b..1bd90df42b 100644 --- a/conformance-tests/Makefile +++ b/conformance-tests/Makefile @@ -21,6 +21,7 @@ create-kind-cluster: ## Create a KinD cluster .PHONY: install-nkg install-nkg: ## Install NKG with provisioner on configured KinD cluster kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.7.0/standard-install.yaml + chmod +x ./wait_for_webhook.sh ./wait_for_webhook.sh kubectl apply -f ../deploy/manifests/namespace.yaml kubectl create configmap njs-modules --from-file=../internal/nginx/modules/src/httpmatches.js -n nginx-gateway From cdf1ea4b0d68767c4a70d472ddd623f22d9e83e2 Mon Sep 17 00:00:00 2001 From: Venktesh Date: Wed, 7 Jun 2023 15:26:45 +0100 Subject: [PATCH 07/16] replace custom script with kubectl wait --- conformance-tests/Makefile | 3 +-- conformance-tests/wait_for_webhook.sh | 11 ----------- 2 files changed, 1 insertion(+), 13 deletions(-) delete mode 100755 conformance-tests/wait_for_webhook.sh diff --git a/conformance-tests/Makefile b/conformance-tests/Makefile index 1bd90df42b..729e64e3a4 100644 --- a/conformance-tests/Makefile +++ b/conformance-tests/Makefile @@ -21,8 +21,7 @@ create-kind-cluster: ## Create a KinD cluster .PHONY: install-nkg install-nkg: ## Install NKG with provisioner on configured KinD cluster kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.7.0/standard-install.yaml - chmod +x ./wait_for_webhook.sh - ./wait_for_webhook.sh + kubectl wait --for=condition=available deployment gateway-api-admission-server -n gateway-system kubectl apply -f ../deploy/manifests/namespace.yaml kubectl create configmap njs-modules --from-file=../internal/nginx/modules/src/httpmatches.js -n nginx-gateway kubectl apply -f ../deploy/manifests/nginx-conf.yaml diff --git a/conformance-tests/wait_for_webhook.sh b/conformance-tests/wait_for_webhook.sh deleted file mode 100755 index 982293863f..0000000000 --- a/conformance-tests/wait_for_webhook.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -export exit=1 -export count=0 -while (( exit == 1 )) && (( count < 10)); do - sleep 1 - count=$((count+1)) - echo waiting $count seconds for webhook container - kubectl get events -n gateway-system | grep "Started container webhook" - exit=`echo $?` -done \ No newline at end of file From 8a5f5343e95125baa3e01803d17b819d6ef052d1 Mon Sep 17 00:00:00 2001 From: Venktesh Date: Wed, 7 Jun 2023 15:52:01 +0100 Subject: [PATCH 08/16] add HTTPRoute to supported features --- conformance-tests/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conformance-tests/Makefile b/conformance-tests/Makefile index 729e64e3a4..f08da39f23 100644 --- a/conformance-tests/Makefile +++ b/conformance-tests/Makefile @@ -1,5 +1,5 @@ GATEWAY_CLASS = nginx -SUPPORTED_FEATURES = Gateway +SUPPORTED_FEATURES = Gateway,HTTPRoute KIND_KUBE_CONFIG_FOLDER = $${HOME}/.kube/kind TAG = latest PREFIX = conformance-test-runner @@ -21,7 +21,7 @@ create-kind-cluster: ## Create a KinD cluster .PHONY: install-nkg install-nkg: ## Install NKG with provisioner on configured KinD cluster kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.7.0/standard-install.yaml - kubectl wait --for=condition=available deployment gateway-api-admission-server -n gateway-system + kubectl wait --for=condition=available --timeout=60s deployment gateway-api-admission-server -n gateway-system kubectl apply -f ../deploy/manifests/namespace.yaml kubectl create configmap njs-modules --from-file=../internal/nginx/modules/src/httpmatches.js -n nginx-gateway kubectl apply -f ../deploy/manifests/nginx-conf.yaml From 7f2a62d6cb6592ccdeb822c7b47b42026dfcdecb Mon Sep 17 00:00:00 2001 From: Venktesh Date: Thu, 8 Jun 2023 12:21:34 +0100 Subject: [PATCH 09/16] link conformace test readme to testing doc. --- conformance-tests/Makefile | 8 ++++---- conformance-tests/README.md | 16 ++++++++-------- docs/developer/testing.md | 8 +++++++- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/conformance-tests/Makefile b/conformance-tests/Makefile index f08da39f23..701086592d 100644 --- a/conformance-tests/Makefile +++ b/conformance-tests/Makefile @@ -14,12 +14,12 @@ build-test-image: ## Build conformance test image docker build -t $(PREFIX):$(TAG) -f Dockerfile .. .PHONY: create-kind-cluster -create-kind-cluster: ## Create a KinD cluster +create-kind-cluster: ## Create a kind cluster kind create cluster --image kindest/node:v1.27.1 kind export kubeconfig --kubeconfig $(KIND_KUBE_CONFIG_FOLDER)/config .PHONY: install-nkg -install-nkg: ## Install NKG with provisioner on configured KinD cluster +install-nkg: ## Install NKG with provisioner on configured kind cluster kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.7.0/standard-install.yaml kubectl wait --for=condition=available --timeout=60s deployment gateway-api-admission-server -n gateway-system kubectl apply -f ../deploy/manifests/namespace.yaml @@ -31,7 +31,7 @@ install-nkg: ## Install NKG with provisioner on configured KinD cluster kubectl apply -f ../conformance/provisioner/provisioner.yaml .PHONY: update-test-kind-config -update-test-kind-config: ## Update KinD config +update-test-kind-config: ## Update kind config sed -ir "s|server:.*|server: https://kind-control-plane:6443|" $(KIND_KUBE_CONFIG_FOLDER)/config .PHONY: run-conformance-tests @@ -40,7 +40,7 @@ run-conformance-tests: update-test-kind-config ## Run conformance tests go test -v . -args --gateway-class=$(GATEWAY_CLASS) --supported-features=$(SUPPORTED_FEATURES) .PHONY: uninstall-nkg -uninstall-nkg: ## Uninstall NKG on configured KinD cluster +uninstall-nkg: ## Uninstall NKG on configured kind cluster kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.7.0/standard-install.yaml kubectl delete -f ../deploy/manifests/rbac.yaml kubectl delete -f ../deploy/manifests/namespace.yaml diff --git a/conformance-tests/README.md b/conformance-tests/README.md index f3fc817548..dc62bb5169 100644 --- a/conformance-tests/README.md +++ b/conformance-tests/README.md @@ -1,8 +1,8 @@ -# Running [Gateway Conformance Tests](https://gateway-api.sigs.k8s.io/concepts/conformance/#3-conformance-tests) in Kind +# Running [Gateway Conformance Tests](https://gateway-api.sigs.k8s.io/concepts/conformance/#3-conformance-tests) in kind ## Prerequisites: -* [Kind](https://kind.sigs.k8s.io/). +* [kind](https://kind.sigs.k8s.io/). * Docker. * Golang. @@ -14,15 +14,15 @@ List available commands: $ make build-test-image Build conformance test image -create-kind-cluster Create a KinD cluster +create-kind-cluster Create a kind cluster delete-kind-cluster Delete kind cluster help Display this help -install-nkg Install NKG on configured KinD cluster +install-nkg Install NKG on configured kind cluster run-conformance-tests Run conformance tests -uninstall-nkg Uninstall NKG from configured KinD cluster -update-test-kind-config Update KinD config +uninstall-nkg Uninstall NKG from configured kind cluster +update-test-kind-config Update kind config ``` -### Step 1 - Create a Kind Cluster +### Step 1 - Create a kind Cluster ```bash $ make create-kind-cluster @@ -48,7 +48,7 @@ $ make run-conformance-tests $ make uninstall-nkg ``` -### Step 6 - Delete KinD cluster +### Step 6 - Delete kind cluster ```bash $ make delete-kind-cluster ``` \ No newline at end of file diff --git a/docs/developer/testing.md b/docs/developer/testing.md index 2de781e6a4..cd2ade4aba 100644 --- a/docs/developer/testing.md +++ b/docs/developer/testing.md @@ -83,10 +83,16 @@ Follow the steps below for manual testing: - NGINX proxies traffic successfully (when applicable). - [Examples](/examples) work correctly. This will ensure that your changes have not introduced any regressions. - > **Note** > > Don't limit yourself to happy path testing. Make an effort to cover various scenarios, including edge cases and potential error conditions. By testing a wide range of scenarios, you can uncover hidden issues and ensure the robustness of your changes. Performing manual testing helps guarantee the stability, reliability, and effectiveness of your changes before submitting them for review and integration into the project. + + +## Gateway API Conformance Testing + +To run Gateway API conformance tests, please follow the instructions on [this](/conformance-tests/README.md) page. + + From 7612a3b5d164f6f28d8307aafc0b1b1c4519d95c Mon Sep 17 00:00:00 2001 From: Venktesh Date: Fri, 9 Jun 2023 12:22:55 +0100 Subject: [PATCH 10/16] add gomega --- conformance-tests/conformance_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/conformance-tests/conformance_test.go b/conformance-tests/conformance_test.go index 90646c1a9e..c5cc68ddf6 100644 --- a/conformance-tests/conformance_test.go +++ b/conformance-tests/conformance_test.go @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -19,6 +19,7 @@ package tests import ( "testing" + . "github.com/onsi/gomega" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/gateway-api/apis/v1alpha2" @@ -29,14 +30,13 @@ import ( ) func TestConformance(t *testing.T) { + g := NewGomegaWithT(t) cfg, err := config.GetConfig() - if err != nil { - t.Fatalf("Error loading Kubernetes config: %v", err) - } + g.Expect(err).To(BeNil()) + client, err := client.New(cfg, client.Options{}) - if err != nil { - t.Fatalf("Error initializing Kubernetes client: %v", err) - } + g.Expect(err).To(BeNil()) + _ = v1alpha2.AddToScheme(client.Scheme()) _ = v1beta1.AddToScheme(client.Scheme()) From f9073640b32b2671021e4352b477abb148927c9d Mon Sep 17 00:00:00 2001 From: Venktesh Date: Fri, 9 Jun 2023 17:12:36 +0100 Subject: [PATCH 11/16] PR feedback --- Makefile | 2 +- conformance-tests/Dockerfile | 10 ---- conformance-tests/README.md | 54 ------------------- {conformance-tests => conformance}/Makefile | 20 ++++--- conformance/tests/Dockerfile | 11 ++++ .../tests}/conformance_test.go | 11 ++-- docs/developer/testing.md | 4 +- 7 files changed, 34 insertions(+), 78 deletions(-) delete mode 100644 conformance-tests/Dockerfile delete mode 100644 conformance-tests/README.md rename {conformance-tests => conformance}/Makefile (79%) create mode 100644 conformance/tests/Dockerfile rename {conformance-tests => conformance/tests}/conformance_test.go (89%) diff --git a/Makefile b/Makefile index f3c3c6dfca..9b893be60e 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ lint: ## Run golangci-lint against code .PHONY: unit-test unit-test: ## Run unit tests for the go code - go test ./... -race -coverprofile cover.out -skip TestConformance + go test ./... -race -coverprofile cover.out go tool cover -html=cover.out -o cover.html njs-unit-test: ## Run unit tests for the njs httpmatches module diff --git a/conformance-tests/Dockerfile b/conformance-tests/Dockerfile deleted file mode 100644 index 9480beacbd..0000000000 --- a/conformance-tests/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -# syntax=docker/dockerfile:1.5 - -FROM golang:1.20 - -WORKDIR /go/src/github.com/nginxinc/nginx-kubernetes-gateway/conformance-tests - -COPY --link go.mod go.sum /go/src/github.com/nginxinc/nginx-kubernetes-gateway/ -RUN go mod download - -COPY --link conformance-tests /go/src/github.com/nginxinc/nginx-kubernetes-gateway/conformance-tests/ \ No newline at end of file diff --git a/conformance-tests/README.md b/conformance-tests/README.md deleted file mode 100644 index dc62bb5169..0000000000 --- a/conformance-tests/README.md +++ /dev/null @@ -1,54 +0,0 @@ -# Running [Gateway Conformance Tests](https://gateway-api.sigs.k8s.io/concepts/conformance/#3-conformance-tests) in kind - -## Prerequisites: - -* [kind](https://kind.sigs.k8s.io/). -* Docker. -* Golang. - -**Note**: all commands in steps below are executed from the ```conformance-tests``` directory - -List available commands: - -```bash -$ make - -build-test-image Build conformance test image -create-kind-cluster Create a kind cluster -delete-kind-cluster Delete kind cluster -help Display this help -install-nkg Install NKG on configured kind cluster -run-conformance-tests Run conformance tests -uninstall-nkg Uninstall NKG from configured kind cluster -update-test-kind-config Update kind config -``` -### Step 1 - Create a kind Cluster - -```bash -$ make create-kind-cluster -``` - -### Step 2 - Build conformance test image -```bash -$ make build-test-image -``` - -### Step 3 - Install Nginx Kubernetes Gateway -```bash -$ make install-nkg -``` - -### Step 4 - Run Gateway conformance tests -```bash -$ make run-conformance-tests -``` - -### Step 5 - Uninstall Nginx Kubernetes Gateway -```bash -$ make uninstall-nkg -``` - -### Step 6 - Delete kind cluster -```bash -$ make delete-kind-cluster -``` \ No newline at end of file diff --git a/conformance-tests/Makefile b/conformance/Makefile similarity index 79% rename from conformance-tests/Makefile rename to conformance/Makefile index 701086592d..ecaa1f2623 100644 --- a/conformance-tests/Makefile +++ b/conformance/Makefile @@ -1,3 +1,6 @@ + +NKG_TAG = edge +NKG_PREFIX = nginx-kubernetes-gateway GATEWAY_CLASS = nginx SUPPORTED_FEATURES = Gateway,HTTPRoute KIND_KUBE_CONFIG_FOLDER = $${HOME}/.kube/kind @@ -9,15 +12,20 @@ PREFIX = conformance-test-runner help: Makefile ## Display this help @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "; printf "Usage:\n\n make \033[36m\033[0m\n\nTargets:\n\n"}; {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}' -.PHONY: build-test-image -build-test-image: ## Build conformance test image - docker build -t $(PREFIX):$(TAG) -f Dockerfile .. +.PHONY: build-test-runner-image +build-test-runner-image: ## Build conformance test runner image + docker build -t $(PREFIX):$(TAG) -f tests/Dockerfile .. .PHONY: create-kind-cluster create-kind-cluster: ## Create a kind cluster kind create cluster --image kindest/node:v1.27.1 kind export kubeconfig --kubeconfig $(KIND_KUBE_CONFIG_FOLDER)/config +.PHONY: prepare-nkg +prepare-nkg: ## Build and load NKG container in configured + cd .. && make PREFIX=$(NKG_PREFIX) TAG=$(NKG_TAG) container + kind load docker-image $(NKG_PREFIX):$(NKG_TAG) + .PHONY: install-nkg install-nkg: ## Install NKG with provisioner on configured kind cluster kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.7.0/standard-install.yaml @@ -28,7 +36,7 @@ install-nkg: ## Install NKG with provisioner on configured kind cluster kubectl apply -f ../deploy/manifests/rbac.yaml kubectl apply -f ../deploy/manifests/gatewayclass.yaml kubectl apply -f ../deploy/manifests/service/nodeport.yaml - kubectl apply -f ../conformance/provisioner/provisioner.yaml + kubectl apply -f provisioner/provisioner.yaml .PHONY: update-test-kind-config update-test-kind-config: ## Update kind config @@ -37,7 +45,7 @@ update-test-kind-config: ## Update kind config .PHONY: run-conformance-tests run-conformance-tests: update-test-kind-config ## Run conformance tests docker run --network=kind --rm -v $(KIND_KUBE_CONFIG_FOLDER):/root/.kube $(PREFIX):$(TAG) \ - go test -v . -args --gateway-class=$(GATEWAY_CLASS) --supported-features=$(SUPPORTED_FEATURES) + go test -v . -tags conformance -args --gateway-class=$(GATEWAY_CLASS) --supported-features=$(SUPPORTED_FEATURES) .PHONY: uninstall-nkg uninstall-nkg: ## Uninstall NKG on configured kind cluster @@ -49,4 +57,4 @@ uninstall-nkg: ## Uninstall NKG on configured kind cluster .PHONY: delete-kind-cluster delete-kind-cluster: ## Delete kind cluster - kind delete cluster \ No newline at end of file + kind delete cluster diff --git a/conformance/tests/Dockerfile b/conformance/tests/Dockerfile new file mode 100644 index 0000000000..672872bbdc --- /dev/null +++ b/conformance/tests/Dockerfile @@ -0,0 +1,11 @@ +# syntax=docker/dockerfile:1.5 + +FROM golang:1.20 + +WORKDIR /go/src/github.com/nginxinc/nginx-kubernetes-gateway/conformance/tests/ + +COPY --link go.mod /go/src/github.com/nginxinc/nginx-kubernetes-gateway/ +COPY --link go.sum /go/src/github.com/nginxinc/nginx-kubernetes-gateway/ +RUN go mod download + +COPY --link conformance/tests /go/src/github.com/nginxinc/nginx-kubernetes-gateway/conformance/tests/ diff --git a/conformance-tests/conformance_test.go b/conformance/tests/conformance_test.go similarity index 89% rename from conformance-tests/conformance_test.go rename to conformance/tests/conformance_test.go index c5cc68ddf6..6f7a733ba1 100644 --- a/conformance-tests/conformance_test.go +++ b/conformance/tests/conformance_test.go @@ -1,3 +1,5 @@ +//go:build conformance + /* Copyright 2022 The Kubernetes Authors. @@ -5,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -13,7 +15,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ - package tests import ( @@ -37,8 +38,10 @@ func TestConformance(t *testing.T) { client, err := client.New(cfg, client.Options{}) g.Expect(err).To(BeNil()) - _ = v1alpha2.AddToScheme(client.Scheme()) - _ = v1beta1.AddToScheme(client.Scheme()) + err = v1alpha2.AddToScheme(client.Scheme()) + g.Expect(err).To(BeNil()) + err = v1beta1.AddToScheme(client.Scheme()) + g.Expect(err).To(BeNil()) t.Logf(`Running conformance tests with %s GatewayClass\n cleanup: %t\n`+ `debug: %t\n enable all features: %t \n supported features: [%v]\n exempt features: [%v]`, diff --git a/docs/developer/testing.md b/docs/developer/testing.md index cd2ade4aba..8fdbecc2d4 100644 --- a/docs/developer/testing.md +++ b/docs/developer/testing.md @@ -93,6 +93,4 @@ submitting them for review and integration into the project. ## Gateway API Conformance Testing -To run Gateway API conformance tests, please follow the instructions on [this](/conformance-tests/README.md) page. - - +To run Gateway API conformance tests, please follow the instructions on [this](/conformance/README.md) page. From 8a0629054b61a269ebeef500b42a9f3eafa147b2 Mon Sep 17 00:00:00 2001 From: Venktesh Date: Fri, 9 Jun 2023 17:18:40 +0100 Subject: [PATCH 12/16] PR feedback --- conformance/Makefile | 2 +- conformance/tests/conformance_test.go | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/conformance/Makefile b/conformance/Makefile index ecaa1f2623..a210db0a19 100644 --- a/conformance/Makefile +++ b/conformance/Makefile @@ -22,7 +22,7 @@ create-kind-cluster: ## Create a kind cluster kind export kubeconfig --kubeconfig $(KIND_KUBE_CONFIG_FOLDER)/config .PHONY: prepare-nkg -prepare-nkg: ## Build and load NKG container in configured +prepare-nkg: ## Build and load NKG container on configured kind cluster cd .. && make PREFIX=$(NKG_PREFIX) TAG=$(NKG_TAG) container kind load docker-image $(NKG_PREFIX):$(NKG_TAG) diff --git a/conformance/tests/conformance_test.go b/conformance/tests/conformance_test.go index 6f7a733ba1..f32053bdf5 100644 --- a/conformance/tests/conformance_test.go +++ b/conformance/tests/conformance_test.go @@ -38,10 +38,8 @@ func TestConformance(t *testing.T) { client, err := client.New(cfg, client.Options{}) g.Expect(err).To(BeNil()) - err = v1alpha2.AddToScheme(client.Scheme()) - g.Expect(err).To(BeNil()) - err = v1beta1.AddToScheme(client.Scheme()) - g.Expect(err).To(BeNil()) + g.Expect(v1alpha2.AddToScheme(client.Scheme()).ToSucceed()) + g.Expect(v1beta1.AddToScheme(client.Scheme()).ToSucceed()) t.Logf(`Running conformance tests with %s GatewayClass\n cleanup: %t\n`+ `debug: %t\n enable all features: %t \n supported features: [%v]\n exempt features: [%v]`, From 0eeae5a414662756db420b891a9fe7d381502f92 Mon Sep 17 00:00:00 2001 From: Venktesh Date: Fri, 9 Jun 2023 17:22:00 +0100 Subject: [PATCH 13/16] linting --- conformance/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/conformance/Makefile b/conformance/Makefile index a210db0a19..0a7239c355 100644 --- a/conformance/Makefile +++ b/conformance/Makefile @@ -1,4 +1,3 @@ - NKG_TAG = edge NKG_PREFIX = nginx-kubernetes-gateway GATEWAY_CLASS = nginx From b58ec4115debd24e9f1cfa82ef19791e3119aab0 Mon Sep 17 00:00:00 2001 From: Venktesh Date: Fri, 9 Jun 2023 17:35:16 +0100 Subject: [PATCH 14/16] Update README --- conformance/README.md | 75 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 conformance/README.md diff --git a/conformance/README.md b/conformance/README.md new file mode 100644 index 0000000000..fc69af55e4 --- /dev/null +++ b/conformance/README.md @@ -0,0 +1,75 @@ +# Running [Gateway Conformance Tests](https://gateway-api.sigs.k8s.io/concepts/conformance/#3-conformance-tests) in kind + +## Prerequisites: + +* [kind](https://kind.sigs.k8s.io/). +* Docker. +* Golang. + +**Note**: all commands in steps below are executed from the ```conformance``` directory + +List available commands: + +```bash +$ make + +build-test-image Build conformance test image +create-kind-cluster Create a kind cluster +delete-kind-cluster Delete kind cluster +help Display this help +install-nkg Install NKG on configured kind cluster +run-conformance-tests Run conformance tests +uninstall-nkg Uninstall NKG from configured kind cluster +update-test-kind-config Update kind config +``` +### Step 1 - Create a kind Cluster + +```bash +$ make create-kind-cluster +``` + +### Step 2 - Build and load Nginx Kubernetes Gateway container to configured kind cluster +**Note**: this step is only required when user wants to run conformance tests using locally built image of Nginx Kubernetes Gateway + +```bash +$ make NKG_PREFIX= NKG_TAG= prepare-nkg +``` + +### Step 3 - Update NKG deploymeny and provisioner manifests +**Note**: this step is only required when user wants to run conformance tests using locally built image of Nginx Kubernetes Gateway +* Navigate to `deploy/manifests` and update values in `deployment.yaml` as specified in below code-block. +* Navigate to `conformance/provisioner` and update values in `provisioner.yaml` as specified in below code-block. +``` +. +.. +containers: +- image: : + imagePullPolicy: Never +.. +. +``` + +### Step 2 - Build conformance test runner image +```bash +$ make build-test-runner-image +``` + +### Step 3 - Install Nginx Kubernetes Gateway +```bash +$ make install-nkg +``` + +### Step 4 - Run Gateway conformance tests +```bash +$ make run-conformance-tests +``` + +### Step 5 - Uninstall Nginx Kubernetes Gateway +```bash +$ make uninstall-nkg +``` + +### Step 7 - Delete kind cluster +```bash +$ make delete-kind-cluster +``` From 75cc30ab6bd32c1574924a6a2f66b62c5b77df22 Mon Sep 17 00:00:00 2001 From: Venktesh Date: Fri, 9 Jun 2023 17:36:31 +0100 Subject: [PATCH 15/16] typos --- conformance/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/conformance/README.md b/conformance/README.md index fc69af55e4..4b1ff1e187 100644 --- a/conformance/README.md +++ b/conformance/README.md @@ -35,7 +35,7 @@ $ make create-kind-cluster $ make NKG_PREFIX= NKG_TAG= prepare-nkg ``` -### Step 3 - Update NKG deploymeny and provisioner manifests +### Step 3 - Update NKG deployment and provisioner manifests **Note**: this step is only required when user wants to run conformance tests using locally built image of Nginx Kubernetes Gateway * Navigate to `deploy/manifests` and update values in `deployment.yaml` as specified in below code-block. * Navigate to `conformance/provisioner` and update values in `provisioner.yaml` as specified in below code-block. @@ -49,27 +49,27 @@ containers: . ``` -### Step 2 - Build conformance test runner image +### Step 4 - Build conformance test runner image ```bash $ make build-test-runner-image ``` -### Step 3 - Install Nginx Kubernetes Gateway +### Step 5 - Install Nginx Kubernetes Gateway ```bash $ make install-nkg ``` -### Step 4 - Run Gateway conformance tests +### Step 6 - Run Gateway conformance tests ```bash $ make run-conformance-tests ``` -### Step 5 - Uninstall Nginx Kubernetes Gateway +### Step 7 - Uninstall Nginx Kubernetes Gateway ```bash $ make uninstall-nkg ``` -### Step 7 - Delete kind cluster +### Step 8 - Delete kind cluster ```bash $ make delete-kind-cluster ``` From 0426b3328f7507596b14fd890748b81d0a75ac7d Mon Sep 17 00:00:00 2001 From: Venktesh Date: Mon, 12 Jun 2023 15:23:54 +0100 Subject: [PATCH 16/16] Update README and error assertions --- conformance/README.md | 18 ++++++++++-------- conformance/tests/conformance_test.go | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/conformance/README.md b/conformance/README.md index 4b1ff1e187..26eaac8fb2 100644 --- a/conformance/README.md +++ b/conformance/README.md @@ -28,17 +28,12 @@ update-test-kind-config Update kind config $ make create-kind-cluster ``` -### Step 2 - Build and load Nginx Kubernetes Gateway container to configured kind cluster -**Note**: this step is only required when user wants to run conformance tests using locally built image of Nginx Kubernetes Gateway - -```bash -$ make NKG_PREFIX= NKG_TAG= prepare-nkg -``` - -### Step 3 - Update NKG deployment and provisioner manifests +### Step 2 - Update NKG deployment and provisioner manifests **Note**: this step is only required when user wants to run conformance tests using locally built image of Nginx Kubernetes Gateway +* Set NKG_PREFIX= NKG_TAG= to preferred values. * Navigate to `deploy/manifests` and update values in `deployment.yaml` as specified in below code-block. * Navigate to `conformance/provisioner` and update values in `provisioner.yaml` as specified in below code-block. +* Save the changes. ``` . .. @@ -49,6 +44,13 @@ containers: . ``` +### Step 3 - Build and load Nginx Kubernetes Gateway container to configured kind cluster +**Note**: this step is only required when user wants to run conformance tests using locally built image of Nginx Kubernetes Gateway + +```bash +$ make NKG_PREFIX= NKG_TAG= prepare-nkg + +``` ### Step 4 - Build conformance test runner image ```bash $ make build-test-runner-image diff --git a/conformance/tests/conformance_test.go b/conformance/tests/conformance_test.go index f32053bdf5..b75ef2d684 100644 --- a/conformance/tests/conformance_test.go +++ b/conformance/tests/conformance_test.go @@ -38,8 +38,8 @@ func TestConformance(t *testing.T) { client, err := client.New(cfg, client.Options{}) g.Expect(err).To(BeNil()) - g.Expect(v1alpha2.AddToScheme(client.Scheme()).ToSucceed()) - g.Expect(v1beta1.AddToScheme(client.Scheme()).ToSucceed()) + g.Expect(v1alpha2.AddToScheme(client.Scheme())).To(Succeed()) + g.Expect(v1beta1.AddToScheme(client.Scheme())).To(Succeed()) t.Logf(`Running conformance tests with %s GatewayClass\n cleanup: %t\n`+ `debug: %t\n enable all features: %t \n supported features: [%v]\n exempt features: [%v]`,