You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem: NFR tests are a burden to run manually, taking a lot of time and effort.
Solution: Automate the longevity test to make it easier and faster for a developer to run this test. This test will be run separately from the other NFR tests, due to the fact that it is long-lived. It should not be run in the pipeline. There is still a manual step of collecting dashboard results.
Also separated out functional and nfr tests in the Makefile and README to better separate the two types of tests. These changes force NFR tests to be run in a GKE environment.
setup-gcp-and-run-tests: create-gke-router create-and-setup-vm run-tests-on-vm ## Create and setup a GKE router and GCP VM for tests and run the functional tests
57
57
58
-
.PHONY: delete-kind-cluster
59
-
delete-kind-cluster: ## Delete kind cluster
60
-
kind delete cluster
58
+
.PHONY: setup-gcp-and-run-nfr-tests
59
+
setup-gcp-and-run-nfr-tests: create-gke-router create-and-setup-vm nfr-test ## Create and setup a GKE router and GCP VM for tests and run the NFR tests
61
60
62
-
.PHONY: run-tests-on-vm
63
-
run-tests-on-vm: ## Run the tests on a GCP VM
64
-
bash scripts/run-tests-gcp-vm.sh
61
+
.PHONY: create-gke-cluster
62
+
create-gke-cluster: ## Create a GKE cluster
63
+
bash scripts/create-gke-cluster.sh$(CI)
65
64
66
65
.PHONY: create-and-setup-vm
67
66
create-and-setup-vm: ## Create and setup a GCP VM for tests
68
67
bash scripts/create-and-setup-gcp-vm.sh
69
68
70
-
.PHONY: cleanup-vm
71
-
cleanup-vm: ## Delete the test GCP VM and delete the firewall rule
72
-
bash scripts/cleanup-vm.sh
73
-
74
69
.PHONY: create-gke-router
75
70
create-gke-router: ## Create a GKE router to allow egress traffic from private nodes (allows for external image pulls)
76
71
bash scripts/create-gke-router.sh
77
72
78
-
.PHONY: cleanup-router
79
-
cleanup-router: ## Delete the GKE router
80
-
bash scripts/cleanup-router.sh
73
+
.PHONY: sync-files-to-vm
74
+
sync-files-to-vm: ## Syncs your local NGF files with the NGF repo on the VM
75
+
bash scripts/sync-files-to-vm.sh
81
76
82
-
.PHONY: setup-gcp-and-run-tests
83
-
setup-gcp-and-run-tests: create-gke-router create-and-setup-vm run-tests-on-vm ## Create and setup a GKE router and GCP VM for tests and run the tests
77
+
.PHONY: run-tests-on-vm
78
+
run-tests-on-vm: ## Run the functional tests on a GCP VM
79
+
bash scripts/run-tests-gcp-vm.sh
80
+
81
+
.PHONY: nfr-test
82
+
nfr-test: ## Run the NFR tests on a GCP VM
83
+
bash scripts/run-tests-gcp-vm.sh true
84
+
85
+
.PHONY: start-longevity-test
86
+
start-longevity-test: ## Start the longevity test to run for 4 days in GKE
87
+
START_LONGEVITY=true $(MAKE) nfr-test
88
+
89
+
.PHONY: stop-longevity-test
90
+
stop-longevity-test: ## Stops the longevity test and collects results
91
+
STOP_LONGEVITY=true $(MAKE) nfr-test
92
+
93
+
.PHONY: .vm-nfr-test
94
+
.vm-nfr-test: ## Runs the NFR tests on the GCP VM (called by `nfr-test`)
95
+
go test -v ./suite -ginkgo.label-filter "nfr"$(GINKGO_FLAGS) -ginkgo.v -args --gateway-api-version=$(GW_API_VERSION)\
load-images-with-plus Load NGF and NGINX Plus images on configured kind cluster
54
57
load-images Load NGF and NGINX images on configured kind cluster
55
-
run-tests-on-vm Run the tests on a GCP VM
56
-
setup-gcp-and-run-tests Create and setup a GKE router and GCP VM for tests and run the tests
57
-
test Run the system tests against your default k8s cluster
58
+
nfr-test Run the NFR tests on a GCP VM
59
+
run-tests-on-vm Run the functional tests on a GCP VM
60
+
setup-gcp-and-run-nfr-tests Create and setup a GKE router and GCP VM for tests and run the NFR tests
61
+
setup-gcp-and-run-tests Create and setup a GKE router and GCP VM for tests and run the functional tests
62
+
start-longevity-test Start the longevity test to run for 4 days in GKE
63
+
stop-longevity-test Stops the longevity test and collects results
64
+
sync-files-to-vm Syncs your local NGF files with the NGF repo on the VM
65
+
test Runs the functional tests on your default k8s cluster
58
66
```
59
67
60
68
**Note:** The following variables are configurable when running the below `make` commands:
@@ -78,6 +86,8 @@ test Run the system tests against your default k8s clu
78
86
79
87
This can be done in a cloud provider of choice, or locally using `kind`.
80
88
89
+
**Important**: NFR tests can only be run on a GKE cluster.
90
+
81
91
To create a local `kind` cluster:
82
92
83
93
```makefile
@@ -128,7 +138,7 @@ make build-images-with-plus load-images-with-plus TAG=$(whoami)
128
138
129
139
## Step 3 - Run the tests
130
140
131
-
### 3a - Run the tests locally
141
+
### 3a - Run the functional tests locally
132
142
133
143
```makefile
134
144
make test TAG=$(whoami)
@@ -142,9 +152,9 @@ make test TAG=$(whoami) PLUS_ENABLED=true
142
152
143
153
### 3b - Run the tests on a GKE cluster from a GCP VM
144
154
145
-
This step only applies if you would like to run the tests on a GKE cluster from a GCP based VM.
155
+
This step only applies if you are running the NFR tests, or would like to run the functional tests on a GKE cluster from a GCP based VM.
146
156
147
-
Before running the below `make`command, copy the `scripts/vars.env-example` file to `scripts/vars.env` and populate the
157
+
Before running the below `make`commands, copy the `scripts/vars.env-example` file to `scripts/vars.env` and populate the
148
158
required env vars. `GKE_SVC_ACCOUNT` needs to be the name of a service account that has Kubernetes admin permissions.
149
159
150
160
In order to run the tests in GCP, you need a few things:
@@ -153,30 +163,81 @@ In order to run the tests in GCP, you need a few things:
153
163
- this assumes that your GKE cluster is using private nodes. If using public nodes, you don't need this.
154
164
- GCP VM and firewall rule to send ingress traffic to GKE
155
165
166
+
To just set up the VM with no router (this will not run the tests):
167
+
168
+
```makefile
169
+
make create-and-setup-vm
170
+
```
171
+
172
+
Otherwise, you can set up the VM, router, and run the tests with a single command. See the options in the sections below.
173
+
174
+
By default, the tests run using the version of NGF that was `git cloned` during the setup. If you want to make
175
+
incremental changes and copy your local changes to the VM to test, you can run
176
+
177
+
```makefile
178
+
make sync-files-to-vm
179
+
```
180
+
181
+
#### Functional Tests
182
+
156
183
To set up the GCP environment with the router and VM and then run the tests, run the following command:
157
184
158
185
```makefile
159
186
make setup-gcp-and-run-tests
160
187
```
161
188
162
-
If you just need a VM and no router (this will not run the tests):
189
+
To use an existing VM to run the tests, run the following
163
190
164
191
```makefile
165
-
make create-and-setup-vm
192
+
make run-tests-on-vm
193
+
```
194
+
195
+
#### NFR tests
196
+
197
+
To set up the GCP environment with the router and VM and then run the tests, run the following command:
198
+
199
+
200
+
```makefile
201
+
make setup-gcp-and-run-nfr-tests
166
202
```
167
203
168
204
To use an existing VM to run the tests, run the following
169
205
170
206
```makefile
171
-
make run-tests-on-vm
207
+
make nfr-test
172
208
```
173
209
210
+
##### Longevity testing
211
+
212
+
This test is run on its own (and also not in a pipeline) due to its long-running nature. It will run for 4 days before
213
+
the tester must collect the results and complete the test.
214
+
215
+
To start the longevity test, set up your VM (`create-and-setup-vm`) and run
216
+
217
+
```makefile
218
+
make start-longevity-test
219
+
```
220
+
221
+
> Note: If you want to re-run the longevity test, you need to clear out the `cafe.example.com` entry from the `/etc/hosts` file on your VM.
222
+
223
+
You can verify the test is working by checking nginx logs to see traffic flow, and check that the cronjob is running and redeploying apps.
224
+
225
+
To complete the longevity test and collect results, first visit the [GCP Monitoring Dashboards](https://console.cloud.google.com/monitoring/dashboards) page and select the `NGF Longevity Test` dashboard. Take PNG screenshots of each chart for the time period in which your test ran, and save those to be added to the results file.
226
+
227
+
Next, run:
228
+
229
+
```makefile
230
+
make stop-longevity-test
231
+
```
232
+
233
+
This will tear down the test and collect results into a file, where you can add the PNGs of the dashboard.
234
+
174
235
### Common test amendments
175
236
176
-
To run all tests with the label "performance", use the GINKGO_LABEL variable:
237
+
To run all tests with the label "my-label", use the GINKGO_LABEL variable:
177
238
178
239
```makefile
179
-
make test TAG=$(whoami) GINKGO_LABEL=performance
240
+
make test TAG=$(whoami) GINKGO_LABEL=my-label
180
241
```
181
242
182
243
or to pass a specific flag, e.g. run a specific test, use the GINKGO_FLAGS variable:
@@ -185,6 +246,8 @@ or to pass a specific flag, e.g. run a specific test, use the GINKGO_FLAGS varia
185
246
make test TAG=$(whoami) GINKGO_FLAGS='-ginkgo.focus "writes the system info to a results file"'
186
247
```
187
248
249
+
> Note: if filtering on NFR tests (or functional tests on GKE), set the filter in the appropriate field in your `vars.env` file.
250
+
188
251
If you are running the tests in GCP, add your required label/ flags to `scripts/var.env`.
189
252
190
253
You can also modify the tests code for a similar outcome. To run a specific test, you can "focus" it by adding the `F`
0 commit comments