diff --git a/perf-tests/README.md b/perf-tests/README.md index 7b5df1544f..72a70f0818 100644 --- a/perf-tests/README.md +++ b/perf-tests/README.md @@ -26,8 +26,8 @@ Run the tests: * Use local Python3 installation (advised to use pyenv/virtualenv): ```bash $ cd perf_tests - $ pip3 install -r requirements.txt - $ pytest -v -s -m ap_perf --count= --node-ip=$(minikube ip) --users= --hatch-rate= --time= + $ pip install -r ../tests/requirements.txt --no-deps + $ pytest -v -s -m ap_perf --count= --users= --hatch-rate= --time= ``` The tests will use the Ingress Controller for NGINX with the image built from `debian-image-nap-plus`. See the section below to learn how to configure the tests including the image and the type of NGINX -- NGINX or NGINX Plus. @@ -47,9 +47,7 @@ The table below shows various configuration options for the performance tests. U | `--service` | The type of the Ingress Controller service: nodeport or loadbalancer. | `nodeport` | | `--node-ip` | The public IP of a cluster node. Not required if you use the loadbalancer service (see --service argument). | `""` | | `--kubeconfig` | An absolute path to a kubeconfig file. | `~/.kube/config` or the value of the `KUBECONFIG` env variable | -| `N/A` | A path to a folder with a kubeconfig file. | `~/.kube/` | | `--show-ic-logs` | A flag to control accumulating IC logs in stdout. | `no` | -| `N/A` | Any additional pytest command-line arguments (i.e `-m "smoke"`) | `""` | | `--count` | Number of times to repeat tests | `1` | | `--users` | Total no. of users/locusts for response perf tests. | `10` | | `--hatch-rate` | No. of users hatched per second. | `5` | diff --git a/perf-tests/conftest.py b/perf-tests/conftest.py index fb9f875dba..f27202e064 100644 --- a/perf-tests/conftest.py +++ b/perf-tests/conftest.py @@ -3,12 +3,19 @@ import os import sys +sys.path.insert(0, "../tests") + import pytest from kubernetes.config.kube_config import KUBE_CONFIG_DEFAULT_LOCATION -from settings import DEFAULT_DEPLOYMENT_TYPE, DEFAULT_IC_TYPE, DEFAULT_IMAGE, DEFAULT_PULL_POLICY, DEFAULT_SERVICE -from suite.resources_utils import get_first_pod_name - -sys.path.insert(0, "../tests") +from settings import ( + DEFAULT_DEPLOYMENT_TYPE, + DEFAULT_IC_TYPE, + DEFAULT_IMAGE, + DEFAULT_PULL_POLICY, + DEFAULT_SERVICE, + NUM_REPLICAS, +) +from suite.utils.resources_utils import get_first_pod_name def pytest_addoption(parser) -> None: @@ -53,6 +60,12 @@ def pytest_addoption(parser) -> None: default=DEFAULT_SERVICE, help="The type of the Ingress Controller service: nodeport or loadbalancer.", ) + parser.addoption( + "--replicas", + action="store", + default=NUM_REPLICAS, + help="Number of replica pods for type deployment", + ) parser.addoption( "--node-ip", action="store", @@ -70,6 +83,12 @@ def pytest_addoption(parser) -> None: default="no", help="Show IC logs in stdout on test failure", ) + parser.addoption( + "--skip-fixture-teardown", + action="store", + default="no", + help="Skips teardown of test fixtures for debugging purposes", + ) parser.addoption( "--users", action="store", @@ -91,7 +110,7 @@ def pytest_addoption(parser) -> None: # import fixtures into pytest global namespace -pytest_plugins = ["suite.fixtures"] +pytest_plugins = ["suite.fixtures.fixtures", "suite.fixtures.ic_fixtures", "suite.fixtures.custom_resource_fixtures"] def pytest_collection_modifyitems(config, items) -> None: diff --git a/perf-tests/requirements.txt b/perf-tests/requirements.txt deleted file mode 100644 index 936568a552..0000000000 --- a/perf-tests/requirements.txt +++ /dev/null @@ -1,10 +0,0 @@ -certifi==2023.5.7 -cffi==1.15.1 -kubernetes==26.1.0 -locust==2.15.1 -pytest==7.4.0 -pytest-html==3.2.0 -pytest-repeat==0.9.1 -PyYAML==6.0 -requests==2.31.0 -urllib3==2.0.3 diff --git a/perf-tests/suite/test_ap_reload_perf.py b/perf-tests/suite/test_ap_reload_perf.py index 88b2ec62db..83d2d76a9b 100644 --- a/perf-tests/suite/test_ap_reload_perf.py +++ b/perf-tests/suite/test_ap_reload_perf.py @@ -10,14 +10,13 @@ import yaml from kubernetes.client import V1ContainerPort from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_resources_utils import ( +from suite.utils.ap_resources_utils import ( create_ap_logconf_from_yaml, create_ap_policy_from_yaml, delete_ap_logconf, delete_ap_policy, - read_ap_crd, ) -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_example_app, create_ingress, create_ingress_with_ap_annotations, @@ -35,7 +34,7 @@ wait_for_event_increment, wait_until_all_pods_are_ready, ) -from suite.yaml_utils import get_first_ingress_host_from_yaml +from suite.utils.yaml_utils import get_first_ingress_host_from_yaml ap_policy = "dataguard-alarm" valid_resp_addr = "Server address:"