Skip to content

Commit 474ce41

Browse files
authored
update tests README
1 parent 269f924 commit 474ce41

File tree

1 file changed

+75
-52
lines changed

1 file changed

+75
-52
lines changed

tests/README.md

Lines changed: 75 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
# Tests
22

3-
The project includes automated tests for testing the Ingress Controller in a Kubernetes cluster. The tests are written
4-
in Python3 and use the pytest framework.
3+
The project includes automated tests for testing the NGINX Ingress Controller in a Kubernetes cluster. The tests are written in Python 3 and use the pytest framework with additional tools like Playwright for browser automation.
54

6-
Below you will find the instructions on how to run the tests against a Minikube and kind clusters. However, you are not
7-
limited to those options and can use other types of Kubernetes clusters. See the [Configuring the
8-
Tests](#configuring-the-tests) section to find out about various configuration options.
5+
This documentation covers how to run tests against Minikube and Kind clusters, though the tests can be run against any Kubernetes cluster. See the [Configuring the Tests](#configuring-the-tests) section for various configuration options.
96

107
## Running Tests in Minikube
118

129
### Prerequisites
1310

14-
- Minikube.
15-
- Python3 or Docker.
11+
- [Minikube](https://minikube.sigs.k8s.io/docs/)
12+
- Python 3.10+ or Docker
1613

1714
#### Step 1 - Create a Minikube Cluster
1815

@@ -22,39 +19,29 @@ minikube start
2219

2320
#### Step 2 - Run the Tests
2421

25-
**Note**: if you have the Ingress Controller deployed in the cluster, please uninstall it first, making sure to remove
26-
its namespace and RBAC resources.
22+
**Note**: If you have the Ingress Controller already deployed in the cluster, please uninstall it first, ensuring you remove its namespace and RBAC resources.
2723

28-
Run the tests:
24+
Run the tests using one of the following methods:
2925

30-
- Use local Python3 installation:
26+
- **Use Python3 virtual environment (recommended):**
3127

32-
```bash
33-
cd tests
34-
pip3 install -r requirements.txt
35-
python3 -m pytest --node-ip=$(minikube ip)
36-
```
37-
38-
- Use Python3 virtual environment:
39-
40-
Create and activate ```virtualenv```
28+
Create and activate a virtual environment:
4129

4230
```bash
43-
$ cd tests
44-
$ python3 -m venv ~/venv
45-
$ source ~/venv/bin/activate
46-
(venv) $
31+
cd tests
32+
make setup-venv
33+
pytest --node-ip=$(minikube ip)
4734
```
4835

49-
Install dependencies and run tests
36+
- **Use local Python3 installation:**
5037

5138
```bash
52-
(venv) $ cd tests
53-
(venv) $ pip3 install -r requirements.txt
54-
(venv) $ python3 -m pytest --node-ip=$(minikube ip)
39+
cd tests
40+
pip install -r requirements.txt
41+
pytest --node-ip=$(minikube ip)
5542
```
5643

57-
- Use Docker:
44+
- **Use Docker:**
5845

5946
```bash
6047
cd tests
@@ -69,24 +56,25 @@ below to learn how to configure the tests including the image and the type of NG
6956

7057
### Prerequisites
7158

72-
- [Kind](https://kind.sigs.k8s.io/).
73-
- Docker.
59+
- [Kind](https://kind.sigs.k8s.io/)
60+
- Docker
7461

75-
**Note**: all commands in steps below are executed from the ```tests``` directory
62+
**Note**: All commands in the steps below are executed from the `tests` directory.
7663

77-
List available make commands
64+
List available make commands:
7865

7966
```bash
80-
$ make
81-
82-
help Show available make targets
83-
build Run build
84-
run-tests Run tests
85-
run-tests-in-kind Run tests in Kind
86-
create-kind-cluster Create Kind cluster
87-
delete-kind-cluster Delete Kind cluster
67+
make help
8868
```
8969

70+
This will show you all available targets including:
71+
72+
- `build` - Build the test container image
73+
- `run-tests` - Run tests in Docker
74+
- `run-tests-in-kind` - Run tests in Kind cluster
75+
- `create-kind-cluster` - Create a Kind cluster
76+
- `delete-kind-cluster` - Delete a Kind cluster
77+
9078
#### Step 1 - Create a Kind Cluster
9179

9280
```bash
@@ -95,8 +83,7 @@ make create-kind-cluster
9583

9684
#### Step 2 - Run the Tests
9785

98-
**Note**: if you have the Ingress Controller deployed in the cluster, please uninstall it first, making sure to remove
99-
its namespace and RBAC resources.
86+
**Note**: If you have the Ingress Controller already deployed in the cluster, please uninstall it first, ensuring you remove its namespace and RBAC resources.
10087

10188
Run the tests in Docker:
10289

@@ -105,13 +92,27 @@ make build
10592
make run-tests-in-kind
10693
```
10794

108-
The tests will use the Ingress Controller for NGINX with the default *nginx/nginx-ingress:edge* image. See the section
109-
below to learn how to configure the tests including the image and the type of NGINX -- NGINX or NGINX Plus.
95+
The tests will use the NGINX Ingress Controller with the default `nginx/nginx-ingress:edge` image. See the [Configuring the Tests](#configuring-the-tests) section to learn how to configure different images and NGINX types (OSS vs Plus).
96+
97+
## Additional Make Targets
98+
99+
The test suite includes several additional make targets for cluster management and cleanup:
100+
101+
102+
- `make create-mini-cluster` - Create a Minikube K8S cluster
103+
- `make delete-mini-cluster` - Delete a Minikube K8S cluster
104+
- `make run-tests-in-minikube` - Run tests in Minikube
105+
- `make mini-image-load` - Load the image into the Minikube K8S cluster
106+
- `make image-load` - Load the image into the Kind K8S cluster
107+
- `make mini-image-load` - Load the image into the Minikube K8S cluster
108+
- `make setup-venv` - Create Python virtual environment with all dependencies
109+
- `make clean-venv` - Remove Python virtual environment
110+
- `make run-local-tests` - Run tests using local Python environment
111+
- `make test-lint` - Run Python linting tools (isort, black)
110112

111113
## Configuring the Tests
112114

113-
The table below shows various configuration options for the tests. If you use Python3 to run the tests, use the
114-
command-line arguments. If you use Docker, use the [Makefile](Makefile) variables.
115+
The table below shows various configuration options for the tests. If you use Python 3 to run the tests locally, use the command-line arguments. If you use Docker, use the [Makefile](Makefile) variables.
115116

116117
| Command-line Argument | Makefile Variable | Description | Default |
117118
| :----------------------- | :------------ | :------------ | :----------------------- |
@@ -126,20 +127,42 @@ command-line arguments. If you use Docker, use the [Makefile](Makefile) variable
126127
| `N/A` | `KUBE_CONFIG_FOLDER`, not supported by `run-tests-in-kind` target. | A path to a folder with a kubeconfig file. | `~/.kube/` |
127128
| `--show-ic-logs` | `SHOW_IC_LOGS` | A flag to control accumulating IC logs in stdout. | `no` |
128129
| `--skip-fixture-teardown` | `N/A` | A flag to skip test fixture teardown for debugging. | `no` |
130+
| `--plus-jwt` | `PLUS_JWT` | JWT token for NGINX Plus image authentication. | `""` |
129131
| `N/A` | `PYTEST_ARGS` | Any additional pytest command-line arguments (i.e `-m "smoke"`) | `""` |
130132

131-
If you would like to use an IDE (such as PyCharm) to run the tests, use the [pytest.ini](pytest.ini) file to set the
132-
command-line arguments.
133+
If you would like to use an IDE (such as PyCharm) to run the tests, use the [pyproject.toml](../pyproject.toml) file to view pytest configuration and markers.
133134

134-
Tests are marked with custom markers. The markers allow to logically split all the tests into smaller groups. The full
135-
list can be found in the [pytest.ini](pytest.ini) file or via command line:
135+
Tests are marked with custom markers that allow you to logically split all tests into smaller groups. The full list can be found in the [pyproject.toml](../pyproject.toml) file or via command line:
136136

137137
```bash
138-
python3 -m pytest --markers
138+
pytest --markers
139139
```
140140

141141
## Test Containers
142142

143143
The source code for the tests containers used in some tests, for example the
144144
[transport-server-tcp-load-balance](./data/transport-server-tcp-load-balance/standard/service_deployment.yaml) is
145145
located at [kic-test-containers](https://github.com/nginx/kic-test-containers).
146+
147+
## Test Structure
148+
149+
The test suite is organized as follows:
150+
151+
- `suite/` - Main test files organized by functionality
152+
- `data/` - Test data and configuration files
153+
- `ci-files/` - Continuous integration configuration
154+
- `conftest.py` - pytest configuration and fixtures
155+
- `requirements.txt` - Python dependencies with hash verification
156+
- `Makefile` - Build and test automation
157+
158+
### Test Dependencies
159+
160+
The tests require several Python packages including:
161+
162+
- `pytest` - Testing framework
163+
- `kubernetes` - Kubernetes Python client
164+
- `requests` - HTTP library
165+
- `playwright` - Browser automation for UI tests etc.
166+
167+
You can find rest of the dependencies in `requirements.txt`
168+
All dependencies are pinned with hashes.

0 commit comments

Comments
 (0)