|
| 1 | +# System Testing |
| 2 | + |
| 3 | +The tests in this directory are meant to be run on a live Kubernetes environment to verify a real system. These |
| 4 | +are similar to the existing [conformance tests](../conformance/README.md), but will verify things such as: |
| 5 | + |
| 6 | +- NGF-specific functionality |
| 7 | +- Non-Functional requirements testing (such as performance, scale, etc.) |
| 8 | + |
| 9 | +When running, the tests create a port-forward from your NGF Pod to localhost using a port chosen by the |
| 10 | +test framework. Traffic is sent over this port. |
| 11 | + |
| 12 | +Directory structure is as follows: |
| 13 | + |
| 14 | +- `framework`: contains utility functions for running the tests |
| 15 | +- `suite`: contains the test files |
| 16 | + |
| 17 | +**Note**: Existing NFR tests will be migrated into this testing `suite` and results stored in a `results` directory. |
| 18 | + |
| 19 | +## Prerequisites |
| 20 | + |
| 21 | +- Kubernetes cluster. |
| 22 | +- Docker. |
| 23 | +- Golang. |
| 24 | + |
| 25 | +**Note**: all commands in steps below are executed from the `tests` directory |
| 26 | + |
| 27 | +```shell |
| 28 | +make |
| 29 | +``` |
| 30 | + |
| 31 | +```text |
| 32 | +build-images Build NGF and NGINX images |
| 33 | +create-kind-cluster Create a kind cluster |
| 34 | +delete-kind-cluster Delete kind cluster |
| 35 | +help Display this help |
| 36 | +load-images Load NGF and NGINX images on configured kind cluster |
| 37 | +test Run the system tests against your default k8s cluster |
| 38 | +``` |
| 39 | + |
| 40 | +**Note:** The following variables are configurable when running the below `make` commands: |
| 41 | + |
| 42 | +| Variable | Default | Description | |
| 43 | +|----------|---------|-------------| |
| 44 | +| TAG | edge | tag for the locally built NGF images | |
| 45 | +| PREFIX | nginx-gateway-fabric | prefix for the locally built NGF image | |
| 46 | +| NGINX_PREFIX | nginx-gateway-fabric/nginx | prefix for the locally built NGINX image | |
| 47 | +| PULL_POLICY | Never | NGF image pull policy | |
| 48 | +| GW_API_VERSION | 1.0.0 | version of Gateway API resources to install | |
| 49 | +| K8S_VERSION | latest | version of k8s that the tests are run on | |
| 50 | + |
| 51 | +## Step 1 - Create a Kubernetes cluster |
| 52 | + |
| 53 | +This can be done in a cloud provider of choice, or locally using `kind`: |
| 54 | + |
| 55 | +```makefile |
| 56 | +make create-kind-cluster |
| 57 | +``` |
| 58 | + |
| 59 | +> Note: The default kind cluster deployed is the latest available version. You can specify a different version by |
| 60 | +> defining the kind image to use through the KIND_IMAGE variable, e.g. |
| 61 | +
|
| 62 | +```makefile |
| 63 | +make create-kind-cluster KIND_IMAGE=kindest/node:v1.27.3 |
| 64 | +``` |
| 65 | + |
| 66 | +## Step 2 - Build and Load Images |
| 67 | + |
| 68 | +Loading the images only applies to a `kind` cluster. If using a cloud provider, you will need to tag and push |
| 69 | +your images to a registry that is accessible from that cloud provider. |
| 70 | + |
| 71 | +```makefile |
| 72 | +make build-images load-images TAG=$(whoami) |
| 73 | +``` |
| 74 | + |
| 75 | +## Step 3 - Run the tests |
| 76 | + |
| 77 | +```makefile |
| 78 | +make test TAG=$(whoami) |
| 79 | +``` |
| 80 | + |
| 81 | +To run a specific test, you can "focus" it by adding the `F` prefix to the name. For example: |
| 82 | + |
| 83 | +```go |
| 84 | +It("runs some test", func(){ |
| 85 | + ... |
| 86 | +}) |
| 87 | +``` |
| 88 | + |
| 89 | +becomes: |
| 90 | + |
| 91 | +```go |
| 92 | +FIt("runs some test", func(){ |
| 93 | + ... |
| 94 | +}) |
| 95 | +``` |
| 96 | + |
| 97 | +This can also be done at higher levels like `Context`. |
| 98 | + |
| 99 | +To disable a specific test, add the `X` prefix to it, similar to the previous example: |
| 100 | + |
| 101 | +```go |
| 102 | +It("runs some test", func(){ |
| 103 | + ... |
| 104 | +}) |
| 105 | +``` |
| 106 | + |
| 107 | +becomes: |
| 108 | + |
| 109 | +```go |
| 110 | +XIt("runs some test", func(){ |
| 111 | + ... |
| 112 | +}) |
| 113 | +``` |
| 114 | + |
| 115 | +## Step 4 - Delete kind cluster |
| 116 | + |
| 117 | +```makefile |
| 118 | +make delete-kind-cluster |
| 119 | +``` |
0 commit comments