github.com/nginxinc/kubernetes-ingress@v1.12.5/tests/README.md (about)

     1  # Tests
     2  
     3  The project includes automated tests for testing the Ingress Controller in a Kubernetes cluster. The tests are written in Python3 and use the pytest framework.
     4  
     5  Below you will find the instructions on how to run the tests against a Minikube and kind clusters. However, you are not limited to those options and can use other types of Kubernetes clusters. See the [Configuring the Tests](#configuring-the-tests) section to find out about various configuration options.
     6  
     7  ## Running Tests in Minikube
     8  
     9  ### Prerequisites:
    10  
    11  * Minikube. 
    12  * Python3 or Docker.
    13  
    14  #### Step 1 - Create a Minikube Cluster
    15  
    16  ```bash
    17  $ minikube start
    18  ```
    19  
    20  #### Step 2 - Run the Tests
    21   
    22  **Note**: if you have the Ingress Controller deployed in the cluster, please uninstall it first, making sure to remove its namespace and RBAC resources.
    23  
    24  Run the tests:
    25  * Use local Python3 installation:
    26      ```bash
    27      $ cd tests
    28      $ pip3 install -r requirements.txt
    29      $ python3 -m pytest --node-ip=$(minikube ip)
    30      ```
    31  * Use Docker:
    32      ```bash
    33      $ cd tests
    34      $ make build
    35      $ make run-tests NODE_IP=$(minikube ip)
    36      ```
    37  The tests will use the Ingress Controller for NGINX with the default *nginx/nginx-ingress:edge* image. See the section below to learn how to configure the tests including the image and the type of NGINX -- NGINX or NGINX Plus.
    38  
    39  ## Running Tests in Kind
    40  
    41  ### Prerequisites:
    42  
    43  * [Kind](https://kind.sigs.k8s.io/).
    44  * Docker.
    45  
    46  #### Step 1 - Create a Kind Cluster
    47  
    48  ```bash
    49  $ make create-kind-cluster 
    50  ```
    51  
    52  #### Step 2 - Run the Tests
    53  
    54  **Note**: if you have the Ingress Controller deployed in the cluster, please uninstall it first, making sure to remove its namespace and RBAC resources.
    55  
    56  Run the tests in Docker:
    57  ```bash
    58  $ cd tests
    59  $ make build
    60  $ make run-tests-in-kind
    61  ```
    62  The tests will use the Ingress Controller for NGINX with the default *nginx/nginx-ingress:edge* image. See the section below to learn how to configure the tests including the image and the type of NGINX -- NGINX or NGINX Plus.
    63  
    64  ## Configuring the Tests
    65  
    66  The table below shows various configuration options for the tests. If you use Python3 to run the tests, use the command-line arguments. If you use Docker, use the [Makefile](Makefile) variables.
    67  
    68  
    69  | Command-line Argument | Makefile Variable | Description | Default |
    70  | :----------------------- | :------------ | :------------ | :----------------------- |
    71  | `--context` | `CONTEXT`, not supported by `run-tests-in-kind` target. | The context to use in the kubeconfig file. | `""` |
    72  | `--image` | `BUILD_IMAGE` | The Ingress Controller image. | `nginx/nginx-ingress:edge` |
    73  | `--image-pull-policy` | `PULL_POLICY` | The pull policy of the Ingress Controller image. | `IfNotPresent` |
    74  | `--deployment-type` | `DEPLOYMENT_TYPE` | The type of the IC deployment: deployment or daemon-set. | `deployment` |
    75  | `--ic-type` | `IC_TYPE` | The type of the Ingress Controller: nginx-ingress or nginx-ingress-plus. | `nginx-ingress` |
    76  | `--service` | `SERVICE`, not supported by `run-tests-in-kind` target.  | The type of the Ingress Controller service: nodeport or loadbalancer. | `nodeport` |
    77  | `--node-ip` | `NODE_IP`, not supported by `run-tests-in-kind` target.  | The public IP of a cluster node. Not required if you use the loadbalancer service (see --service argument). | `""` |
    78  | `--kubeconfig` | `N/A` | An absolute path to a kubeconfig file. | `~/.kube/config` or the value of the `KUBECONFIG` env variable |
    79  | `N/A` | `KUBE_CONFIG_FOLDER`, not supported by `run-tests-in-kind` target. | A path to a folder with a kubeconfig file. | `~/.kube/` |
    80  | `--show-ic-logs` | `SHOW_IC_LOGS` | A flag to control accumulating IC logs in stdout. | `no` |
    81  | `N/A` | `PYTEST_ARGS` | Any additional pytest command-line arguments (i.e `-m "smoke"`) | `""` |
    82  
    83  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 command-line arguments.
    84  
    85  Tests are marked with custom markers. The markers allow to logically split all the tests into smaller groups. The full list can be found in the [pytest.ini](pytest.ini) file or via command line:
    86  ```bash
    87  $ python3 -m pytest --markers
    88  ```