Skip to content

Commit ab25b5e

Browse files
committed
Reconfigure make commands based on feedback
1 parent ee409cc commit ab25b5e

File tree

6 files changed

+70
-63
lines changed

6 files changed

+70
-63
lines changed

conformance/Makefile

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
NKG_TAG = edge
22
NKG_PREFIX = nginx-kubernetes-gateway
3+
GATEWAY_CLASS = nginx
4+
SUPPORTED_FEATURES = HTTPRoute,HTTPRouteQueryParamMatching,HTTPRouteMethodMatching,HTTPRoutePortRedirect,HTTPRouteSchemeRedirect
5+
EXEMPT_FEATURES = ReferenceGrant
36
KIND_KUBE_CONFIG_FOLDER = $${HOME}/.kube/kind
47
TAG = latest
58
PREFIX = conformance-test-runner
6-
NGINX_IMAGE=$(shell yq '.spec.template.spec.containers[1].image as $$nginx_ver | $$nginx_ver' ../deploy/manifests/deployment.yaml)
9+
NKG_DEPLOYMENT_MANIFEST=../deploy/manifests/deployment.yaml
10+
NGINX_IMAGE=$(shell yq '.spec.template.spec.containers[1].image as $$nginx_ver | $$nginx_ver' $(NKG_DEPLOYMENT_MANIFEST))
711
.DEFAULT_GOAL := help
812

913
.PHONY: help
@@ -19,23 +23,19 @@ create-kind-cluster: ## Create a kind cluster
1923
kind create cluster --image kindest/node:v1.27.1
2024
kind export kubeconfig --kubeconfig $(KIND_KUBE_CONFIG_FOLDER)/config
2125

22-
.PHONY: prepare-nkg
23-
prepare-nkg: ## Build and load NKG and NGINX containers on configured kind cluster
24-
cd .. && make PREFIX=$(NKG_PREFIX) TAG=$(NKG_TAG) container
25-
kind load docker-image $(NKG_PREFIX):$(NKG_TAG)
26+
.PHONY: preload-nginx-container
27+
preload-nginx-container: ## Preload NGINX container on configured kind cluster
2628
docker pull $(NGINX_IMAGE)
2729
kind load docker-image $(NGINX_IMAGE)
28-
yq -i 'with(.spec.template.spec.containers[0]; .image = "$(NKG_PREFIX):$(NKG_TAG)" | .imagePullPolicy = "Never")' ../deploy/manifests/deployment.yaml
2930

30-
.PHONY: prepare-nkg-no-build
31-
prepare-nkg-no-build: ## Load NKG and NGINX containers on configured kind cluster
31+
.PHONY: build-and-load-images
32+
build-and-load-images: preload-nginx-container ## Build NKG container and load it and NGINX container on configured kind cluster
33+
yq -i 'with(.spec.template.spec.containers[0]; .image = "$(NKG_PREFIX):$(NKG_TAG)" | .imagePullPolicy = "Never")' $(NKG_DEPLOYMENT_MANIFEST)
34+
cd .. && make PREFIX=$(NKG_PREFIX) TAG=$(NKG_TAG) container
3235
kind load docker-image $(NKG_PREFIX):$(NKG_TAG)
33-
docker pull $(NGINX_IMAGE)
34-
kind load docker-image $(NGINX_IMAGE)
35-
yq -i 'with(.spec.template.spec.containers[0]; .image = "$(NKG_PREFIX):$(NKG_TAG)" | .imagePullPolicy = "Never")' ../deploy/manifests/deployment.yaml
3636

37-
.PHONY: install-nkg
38-
install-nkg: ## Install NKG with provisioner on configured kind cluster
37+
.PHONY: prepare-nkg-dependencies
38+
prepare-nkg-dependencies: ## Install NKG dependencies on configured kind cluster
3939
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.7.1/standard-install.yaml
4040
kubectl wait --for=condition=available --timeout=60s deployment gateway-api-admission-server -n gateway-system
4141
kubectl apply -f ../deploy/manifests/namespace.yaml
@@ -44,20 +44,26 @@ install-nkg: ## Install NKG with provisioner on configured kind cluster
4444
kubectl apply -f ../deploy/manifests/rbac.yaml
4545
kubectl apply -f ../deploy/manifests/gatewayclass.yaml
4646
kubectl apply -f ../deploy/manifests/service/nodeport.yaml
47+
48+
.PHONY: install-nkg-local-build
49+
install-nkg-local-build: build-and-load-images prepare-nkg-dependencies ## Install NKG from local build with provisioner on configured kind cluster
4750
yq '(select(di != 3))' provisioner/provisioner.yaml | kubectl apply -f -
4851
yq '(select(.spec.template.spec.containers[].image) | .spec.template.spec.containers[].image="$(NKG_PREFIX):$(NKG_TAG)" | .spec.template.spec.containers[].imagePullPolicy = "Never")' provisioner/provisioner.yaml | kubectl apply -f -
4952

53+
.PHONY: install-nkg-edge
54+
install-nkg-edge: preload-nginx-container prepare-nkg-dependencies ## Install NKG with provisioner from edge on configured kind cluster
55+
kubectl apply -f provisioner/provisioner.yaml
56+
5057
.PHONY: run-conformance-tests
5158
run-conformance-tests: ## Run conformance tests
5259
kind load docker-image $(PREFIX):$(TAG)
53-
yq '(select(di != 3))' tests/conformance_spec.yaml | kubectl apply -f -
54-
yq '(select(.spec.containers[].image) | .spec.containers[].image="$(PREFIX):$(TAG)")' tests/conformance_spec.yaml | kubectl apply -f -
55-
kubectl wait --for=condition=ready pod conformance
56-
kubectl logs conformance --follow
60+
kubectl apply -f tests/conformance_rbac.yaml
61+
kubectl run -i conformance --image=$(PREFIX):$(TAG) --image-pull-policy=Never --restart=Never --overrides='{ "spec": { "serviceAccountName": "conformance" } }' -- go test -v . -tags conformance -args --gateway-class=$(GATEWAY_CLASS) --debug --supported-features=$(SUPPORTED_FEATURES) --exempt-features=$(EXEMPT_FEATURES)
5762

5863
.PHONY: cleanup-conformance-tests
5964
cleanup-conformance-tests: ## Clean up conformance tests fixtures
60-
kubectl delete -f tests/conformance_spec.yaml
65+
kubectl delete pod conformance
66+
kubectl delete -f tests/conformance_rbac.yaml
6167

6268
.PHONY: uninstall-nkg
6369
uninstall-nkg: ## Uninstall NKG on configured kind cluster
@@ -69,7 +75,7 @@ uninstall-nkg: ## Uninstall NKG on configured kind cluster
6975

7076
.PHONY: undo-image-update
7177
undo-image-update: ## Undo the NKG image name and tag in deployment manifest
72-
git checkout -- ../deploy/manifests/deployment.yaml
78+
git checkout -- $(NKG_DEPLOYMENT_MANIFEST)
7379

7480
.PHONY: delete-kind-cluster
7581
delete-kind-cluster: ## Delete kind cluster

conformance/README.md

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* [kind](https://kind.sigs.k8s.io/).
66
* Docker.
77
* Golang.
8-
* [yq](https://github.com/mikefarah/yq/#macos--linux-via-homebrew)
8+
* [yq](https://github.com/mikefarah/yq/#install)
99

1010
**Note**: all commands in steps below are executed from the ```conformance``` directory
1111

@@ -14,63 +14,80 @@ List available commands:
1414
```bash
1515
$ make
1616

17+
build-and-load-images Build NKG container and load it and NGINX container on configured kind cluster
1718
build-test-runner-image Build conformance test runner image
1819
cleanup-conformance-tests Clean up conformance tests fixtures
1920
create-kind-cluster Create a kind cluster
2021
delete-kind-cluster Delete kind cluster
2122
help Display this help
22-
install-nkg Install NKG with provisioner on configured kind cluster
23-
prepare-nkg-no-build Load NKG and NGINX containers on configured kind cluster
24-
prepare-nkg Build and load NKG and NGINX containers on configured kind cluster
23+
install-nkg-edge Install NKG with provisioner from edge on configured kind cluster
24+
install-nkg-local-build Install NKG from local build with provisioner on configured kind cluster
25+
preload-nginx-container Preload NGINX container on configured kind cluster
26+
prepare-nkg-dependencies Install NKG dependencies on configured kind cluster
2527
run-conformance-tests Run conformance tests
2628
undo-image-update Undo the NKG image name and tag in deployment manifest
2729
uninstall-nkg Uninstall NKG on configured kind cluster
2830
```
31+
32+
**Note:** The following variables are configurable when running the below `make` commands:
33+
34+
| Variable | Default | Description |
35+
| ------------- | ------------- | ------------- |
36+
| TAG | latest | The tag for the conformance test image |
37+
| PREFIX | conformance-test-runner | The prefix for the conformance test image |
38+
| NKG_TAG | edge | The tag for the locally built NKG image |
39+
| NKG_PREFIX | nginx-kubernetes-gateway | The prefix for the locally built NKG image |
40+
| KIND_KUBE_CONFIG_FOLDER | ~/.kube/kind | The location of the kubeconfig folder |
41+
| GATEWAY_CLASS | nginx | The gateway class that should be used for the tests |
42+
| SUPPORTED_FEATURES | HTTPRoute,HTTPRouteQueryParamMatching,HTTPRouteMethodMatching,HTTPRoutePortRedirect,HTTPRouteSchemeRedirect | The supported features that should be tested by the conformance tests |
43+
| EXEMPT_FEATURES | ReferenceGrant | The features that should not be tested by the conformance tests |
44+
| NGINX_IMAGE | as defined in the ../deploy/manifests/deployment.yaml file | The NGINX image for the NKG deployments |
45+
| NKG_DEPLOYMENT_MANIFEST | ../deploy/manifests/deployment.yaml | The location of the NKG deployment manifest |
46+
2947
### Step 1 - Create a kind Cluster
3048

3149
```bash
3250
$ make create-kind-cluster
3351
```
52+
### Step 2 - Install Nginx Kubernetes Gateway to configured kind cluster
3453

35-
### Step 2 - Build Nginx Kubernetes Gateway container and load it and the NGINX container to configured kind cluster
54+
#### *Option 1* Build and install Nginx Kubernetes Gateway from local to configured kind cluster
3655
```bash
37-
$ make NKG_PREFIX=<repo_name> NKG_TAG=<image_tag> prepare-nkg
38-
56+
$ make install-nkg-local-build
3957
```
40-
**Optional** Instead of the above command, you can skip the build NKG image step by running
4158

42-
```bash
43-
$ make NKG_PREFIX=<repo_name> NKG_TAG=<image_tag> prepare-nkg-no-build
59+
#### *Option 2* Install Nginx Kubernetes Gateway from edge to configured kind cluster
60+
Instead of the above command, you can skip the build NKG image step and prepare the environment to instead
61+
use the `edge` image
4462

45-
```
46-
### Step 3 - Build conformance test runner image
4763
```bash
48-
$ make build-test-runner-image
64+
$ make install-nkg-edge
4965
```
5066

51-
### Step 4 - Install Nginx Kubernetes Gateway
67+
### Step 3 - Build conformance test runner image
5268
```bash
53-
$ make NKG_PREFIX=<repo_name> NKG_TAG=<image_tag> install-nkg
69+
$ make build-test-runner-image
5470
```
5571

56-
### Step 5 - Run Gateway conformance tests
72+
### Step 4 - Run Gateway conformance tests
5773
```bash
58-
$ make NKG_PREFIX=<repo_name> NKG_TAG=<image_tag> run-conformance-tests
74+
$ make run-conformance-tests
5975
```
6076

61-
### Step 6 - Cleanup the conformance test fixtures and uninstall Nginx Kubernetes Gateway
77+
### Step 5 - Cleanup the conformance test fixtures and uninstall Nginx Kubernetes Gateway
6278
```bash
6379
$ make cleanup-conformance-tests
6480
$ make uninstall-nkg
6581
```
6682

67-
### Step 7 - Revert changes to the NKG deployment manifest
83+
### Step 6 - Revert changes to the NKG deployment manifest
84+
**Optional** Not required if using `edge` image
6885
**Warning**: `make undo-image-update` will hard reset changes to the deploy/manifests/deployment.yaml file!
6986
```bash
7087
$ make undo-image-update
7188
```
7289

73-
### Step 8 - Delete kind cluster
90+
### Step 7 - Delete kind cluster
7491
```bash
7592
$ make delete-kind-cluster
7693
```

conformance/tests/Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@ COPY --link go.sum /go/src/github.com/nginxinc/nginx-kubernetes-gateway/
99
RUN go mod download
1010

1111
COPY --link conformance/tests /go/src/github.com/nginxinc/nginx-kubernetes-gateway/conformance/tests/
12-
13-
CMD go test -timeout 25m -v . -tags conformance -args --gateway-class=${GATEWAY_CLASS} --debug --supported-features=${SUPPORTED_FEATURES} --exempt-features=${EXEMPT_FEATURES}

conformance/tests/conformance_spec.yaml renamed to conformance/tests/conformance_rbac.yaml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,3 @@ roleRef:
6161
kind: ClusterRole
6262
name: conformance
6363
apiGroup: rbac.authorization.k8s.io
64-
---
65-
apiVersion: v1
66-
kind: Pod
67-
metadata:
68-
name: conformance
69-
spec:
70-
containers:
71-
- name: conformance
72-
image: conformance-test-runner:latest
73-
imagePullPolicy: Never
74-
env:
75-
- name: GATEWAY_CLASS
76-
value: nginx
77-
- name: SUPPORTED_FEATURES
78-
value: HTTPRoute,HTTPRouteQueryParamMatching,HTTPRouteMethodMatching,HTTPRoutePortRedirect,HTTPRouteSchemeRedirect
79-
- name: EXEMPT_FEATURES
80-
value: ReferenceGrant
81-
serviceAccountName: conformance
82-
restartPolicy: Never

docs/developer/quickstart.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Follow these steps to set up your development environment.
1414
- [Kind](https://kind.sigs.k8s.io/docs/user/quick-start/)
1515
- [git](https://git-scm.com/)
1616
- [GNU Make](https://www.gnu.org/software/software.html)
17+
- [yq](https://github.com/mikefarah/yq/#install)
1718
- [fieldalignment](https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/fieldalignment):
1819

1920
```shell
@@ -92,6 +93,10 @@ make unit-test
9293

9394
For more details on testing, see the [testing](/docs/developer/testing.md) documentation.
9495

96+
## Gateway API Conformance Testing
97+
98+
To run Gateway API conformance tests, please follow the instructions on [this](/conformance/README.md) page.
99+
95100
## Run the Linter
96101

97102
To lint the code, run the following make command from the project's root directory:

docs/developer/testing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Testing
22

33
This document provides guidelines for testing, including instructions on running the unit tests, accessing the code
4-
coverage report, and performing manual testing. By following these guidelines, you will gain a thorough understanding of
5-
the project's approach to unit testing, enabling you to ensure code quality, validate functionality, and maintain robust
6-
test coverage.
4+
coverage report, performing manual testing, and running the conformance tests. By following these guidelines, you will
5+
gain a thorough understanding of the project's approach to unit testing, enabling you to ensure code quality, validate
6+
functionality, and maintain robust test coverage.
77

88
## Unit Test Guidelines
99

0 commit comments

Comments
 (0)