From 1396149366c78ec405ddc5f9b70873afdf4dcd8f Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Tue, 8 Nov 2022 09:06:22 -0800 Subject: [PATCH] Run pre-commit hooks to fix python test imports (#3221) * Run pre-commit hooks to fix python test imports * Add context.minimum_version --- internal/certmanager/cm_controller.go | 20 +++++------ internal/certmanager/helper.go | 33 ++++++++++--------- internal/certmanager/sync.go | 8 ++--- internal/configs/version1/nginx.ingress.tmpl | 2 +- .../version2/nginx.transportserver.tmpl | 2 +- perf-tests/requirements.txt | 12 +++---- pyproject.toml | 2 ++ tests/conftest.py | 4 +-- tests/kind/kind-config-template.yaml | 7 ---- tests/requirements.txt | 22 ++++++------- tests/settings.py | 1 - .../custom_resource_fixtures.py | 11 +++---- tests/suite/{ => fixtures}/fixtures.py | 8 ++--- tests/suite/{ => fixtures}/ic_fixtures.py | 7 ++-- tests/suite/test_ac_policies.py | 11 +++---- tests/suite/test_ac_policies_vsr.py | 14 +++----- tests/suite/test_annotations.py | 8 ++--- tests/suite/test_app_protect.py | 10 +++--- tests/suite/test_app_protect_grpc.py | 13 ++++---- tests/suite/test_app_protect_integration.py | 6 ++-- tests/suite/test_app_protect_waf_policies.py | 20 +++-------- .../test_app_protect_waf_policies_grpc.py | 18 +++++----- .../suite/test_app_protect_watch_namespace.py | 8 ++--- tests/suite/test_auth_basic_auth_mergeable.py | 8 ++--- tests/suite/test_auth_basic_policies.py | 21 +++--------- tests/suite/test_auth_basic_policies_vsr.py | 21 +++--------- tests/suite/test_auth_basic_secrets.py | 8 ++--- tests/suite/test_batch_reloads.py | 10 +++--- tests/suite/test_batch_startup_times.py | 10 +++--- tests/suite/test_build_info.py | 5 ++- tests/suite/test_custom_annotations.py | 6 ++-- tests/suite/test_default_server.py | 4 +-- tests/suite/test_disable_ipv6.py | 6 ++-- tests/suite/test_dos.py | 11 +++---- tests/suite/test_externalname_service.py | 6 ++-- tests/suite/test_filter_secrets.py | 3 +- tests/suite/test_healthcheck_uri.py | 2 +- tests/suite/test_hsts.py | 6 ++-- tests/suite/test_ingress_class.py | 4 +-- tests/suite/test_ingress_mtls.py | 16 ++++++--- tests/suite/test_jwt_auth_mergeable.py | 8 ++--- tests/suite/test_jwt_policies.py | 23 +++---------- tests/suite/test_jwt_policies_vsr.py | 23 +++---------- tests/suite/test_jwt_secrets.py | 8 ++--- tests/suite/test_multiple_ns_perf.py | 6 ++-- tests/suite/test_policy_ingress_class.py | 11 +++---- tests/suite/test_prometheus_metrics.py | 6 ++-- tests/suite/test_rewrites.py | 4 +-- tests/suite/test_rl_policies.py | 11 +++---- tests/suite/test_rl_policies_vsr.py | 16 +++------ tests/suite/test_smoke.py | 9 +++-- tests/suite/test_snippet_flag.py | 4 +-- tests/suite/test_tls.py | 6 ++-- tests/suite/test_transport_server.py | 4 +-- .../test_transport_server_external_name.py | 4 +-- tests/suite/test_transport_server_status.py | 4 +-- .../test_transport_server_tcp_load_balance.py | 12 ++----- .../test_transport_server_udp_load_balance.py | 10 ++---- tests/suite/test_ts_tls_passthrough.py | 12 +++---- tests/suite/test_v_s_route.py | 8 ++--- .../suite/test_v_s_route_advanced_routing.py | 8 ++--- tests/suite/test_v_s_route_api.py | 4 +-- .../suite/test_v_s_route_canned_responses.py | 6 ++-- tests/suite/test_v_s_route_error_pages.py | 6 ++-- tests/suite/test_v_s_route_externalname.py | 12 +++---- tests/suite/test_v_s_route_focused_canary.py | 8 ++--- tests/suite/test_v_s_route_grpc.py | 13 ++------ tests/suite/test_v_s_route_redirects.py | 6 ++-- tests/suite/test_v_s_route_regexp_location.py | 8 ++--- tests/suite/test_v_s_route_split_traffic.py | 4 +-- tests/suite/test_v_s_route_status.py | 7 ++-- .../suite/test_v_s_route_upstream_options.py | 8 ++--- tests/suite/test_v_s_route_upstream_tls.py | 6 ++-- tests/suite/test_virtual_server.py | 11 +++---- .../test_virtual_server_advanced_routing.py | 4 +-- tests/suite/test_virtual_server_api.py | 4 +-- .../test_virtual_server_canned_responses.py | 6 ++-- .../suite/test_virtual_server_certmanager.py | 9 +++-- .../test_virtual_server_configmap_keys.py | 6 ++-- tests/suite/test_virtual_server_dos.py | 13 ++++---- .../suite/test_virtual_server_error_pages.py | 6 ++-- .../test_virtual_server_external_name.py | 6 ++-- .../suite/test_virtual_server_externaldns.py | 10 +++--- .../test_virtual_server_focused_canary.py | 2 +- tests/suite/test_virtual_server_grpc.py | 13 ++++---- tests/suite/test_virtual_server_mixed_grpc.py | 13 +++++--- tests/suite/test_virtual_server_redirects.py | 6 ++-- .../test_virtual_server_split_traffic.py | 2 +- tests/suite/test_virtual_server_status.py | 7 ++-- tests/suite/test_virtual_server_tls.py | 6 ++-- .../suite/test_virtual_server_tls_redirect.py | 4 +-- .../test_virtual_server_upstream_options.py | 8 ++--- .../suite/test_virtual_server_upstream_tls.py | 6 ++-- tests/suite/test_virtual_server_validation.py | 7 ++-- tests/suite/test_virtual_server_wildcard.py | 8 ++--- tests/suite/test_watch_namespace.py | 4 +-- tests/suite/test_wildcard_tls_secret.py | 11 +++---- tests/suite/{ => utils}/ap_resources_utils.py | 6 ++-- tests/suite/{ => utils}/custom_assertions.py | 4 +-- .../{ => utils}/custom_resources_utils.py | 4 +-- tests/suite/{ => utils}/dos_utils.py | 2 +- tests/suite/{ => utils}/kube_config_utils.py | 0 tests/suite/{ => utils}/nginx_api_utils.py | 2 +- .../{ => utils}/policy_resources_utils.py | 6 ++-- tests/suite/{ => utils}/resources_utils.py | 0 tests/suite/{ => utils}/ssl_utils.py | 3 +- .../{ => utils}/vs_vsr_resources_utils.py | 4 +-- tests/suite/{ => utils}/yaml_utils.py | 0 108 files changed, 385 insertions(+), 497 deletions(-) delete mode 100644 tests/kind/kind-config-template.yaml rename tests/suite/{ => fixtures}/custom_resource_fixtures.py (97%) rename tests/suite/{ => fixtures}/fixtures.py (98%) rename tests/suite/{ => fixtures}/ic_fixtures.py (98%) rename tests/suite/{ => utils}/ap_resources_utils.py (97%) rename tests/suite/{ => utils}/custom_assertions.py (98%) rename tests/suite/{ => utils}/custom_resources_utils.py (98%) rename tests/suite/{ => utils}/dos_utils.py (97%) rename tests/suite/{ => utils}/kube_config_utils.py (100%) rename tests/suite/{ => utils}/nginx_api_utils.py (96%) rename tests/suite/{ => utils}/policy_resources_utils.py (89%) rename tests/suite/{ => utils}/resources_utils.py (100%) rename tests/suite/{ => utils}/ssl_utils.py (95%) rename tests/suite/{ => utils}/vs_vsr_resources_utils.py (98%) rename tests/suite/{ => utils}/yaml_utils.py (100%) diff --git a/internal/certmanager/cm_controller.go b/internal/certmanager/cm_controller.go index 5138389452..2f0f78da57 100644 --- a/internal/certmanager/cm_controller.go +++ b/internal/certmanager/cm_controller.go @@ -127,16 +127,16 @@ func (c *CmController) processItem(ctx context.Context, key string) error { // example, the following Certificate "cert-1" is controlled by the VirtualServer // "vs-1": // -// kind: Certificate -// metadata: Note that the owner -// namespace: cert-1 reference does not -// ownerReferences: have a namespace, -// - controller: true since owner refs -// apiVersion: networking.x-k8s.io/v1alpha1 only work inside -// kind: VirtualServer the same namespace. -// name: vs-1 -// blockOwnerDeletion: true -// uid: 7d3897c2-ce27-4144-883a-e1b5f89bd65a +// kind: Certificate +// metadata: Note that the owner +// namespace: cert-1 reference does not +// ownerReferences: have a namespace, +// - controller: true since owner refs +// apiVersion: networking.x-k8s.io/v1alpha1 only work inside +// kind: VirtualServer the same namespace. +// name: vs-1 +// blockOwnerDeletion: true +// uid: 7d3897c2-ce27-4144-883a-e1b5f89bd65a func certificateHandler(queue workqueue.RateLimitingInterface) func(obj interface{}) { return func(obj interface{}) { crt, ok := obj.(*cmapi.Certificate) diff --git a/internal/certmanager/helper.go b/internal/certmanager/helper.go index 3ccb3efa59..1b41ddd954 100644 --- a/internal/certmanager/helper.go +++ b/internal/certmanager/helper.go @@ -49,25 +49,26 @@ var ( // apiVersion: k8s.nginx.org/v1 // kind: VirtualServer // spec: -// <...> -// tls: -// <...> -// cert-manager: -// common-name: example.com -// duration: 2160h -// renew-before: 1440h -// usages: "digital signature,key encipherment" +// +// <...> +// tls: +// <...> +// cert-manager: +// common-name: example.com +// duration: 2160h +// renew-before: 1440h +// usages: "digital signature,key encipherment" // // is mapped to the following Certificate: // -// kind: Certificate -// spec: -// commonName: example.com -// duration: 2160h -// renewBefore: 1440h -// usages: -// - digital signature -// - key encipherment +// kind: Certificate +// spec: +// commonName: example.com +// duration: 2160h +// renewBefore: 1440h +// usages: +// - digital signature +// - key encipherment func translateVsSpec(crt *cmapi.Certificate, vsCmSpec *vsapi.CertManager) error { var errs []string if crt == nil { diff --git a/internal/certmanager/sync.go b/internal/certmanager/sync.go index 89aee7ec65..f466adcd23 100644 --- a/internal/certmanager/sync.go +++ b/internal/certmanager/sync.go @@ -274,10 +274,10 @@ func certNeedsUpdate(a, b *cmapi.Certificate) bool { // Certificate created for the given VirtualServer resource. We look up the following // VS TLS Cert-Manager fields: // -// cluster-issuer -// issuer -// issuer-kind -// issuer-group +// cluster-issuer +// issuer +// issuer-kind +// issuer-group func issuerForVirtualServer(vs *vsapi.VirtualServer) (name, kind, group string, err error) { var errs []string vsCmSpec := vs.Spec.TLS.CertManager diff --git a/internal/configs/version1/nginx.ingress.tmpl b/internal/configs/version1/nginx.ingress.tmpl index 77772c06f2..db32bfb496 100644 --- a/internal/configs/version1/nginx.ingress.tmpl +++ b/internal/configs/version1/nginx.ingress.tmpl @@ -96,7 +96,7 @@ server { {{range $location := $server.Locations}} location {{$location.Path}} { - set $service "{{$location.ServiceName}}"; + set $service "{{$location.ServiceName}}"; {{with $location.MinionIngress}} # location for minion {{$location.MinionIngress.Namespace}}/{{$location.MinionIngress.Name}} set $resource_name "{{$location.MinionIngress.Name}}"; diff --git a/internal/configs/version2/nginx.transportserver.tmpl b/internal/configs/version2/nginx.transportserver.tmpl index c725967157..8643615371 100644 --- a/internal/configs/version2/nginx.transportserver.tmpl +++ b/internal/configs/version2/nginx.transportserver.tmpl @@ -47,4 +47,4 @@ server { proxy_next_upstream_timeout {{ $s.ProxyNextUpstreamTimeout }}; proxy_next_upstream_tries {{ $s.ProxyNextUpstreamTries }}; {{ end }} -} \ No newline at end of file +} diff --git a/perf-tests/requirements.txt b/perf-tests/requirements.txt index ac301b5ac8..a8228452cf 100644 --- a/perf-tests/requirements.txt +++ b/perf-tests/requirements.txt @@ -1,10 +1,10 @@ -PyYAML==6.0 -requests==2.28.1 +certifi==2022.9.24 +cffi==1.15.1 kubernetes==25.3.0 +locust==2.13.0 pytest==7.2.0 -cffi==1.15.1 -certifi==2022.9.24 -urllib3==1.26.12 pytest-html==3.2.0 pytest-repeat==0.9.1 -locust==2.13.0 \ No newline at end of file +PyYAML==6.0 +requests==2.28.1 +urllib3==1.26.12 diff --git a/pyproject.toml b/pyproject.toml index 0008b64cff..ef12127657 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,8 @@ pythonpath = [ ".", "tests/suite", "tests/suite/grpc", + "tests/suite/fixtures", + "tests/suite/utils", ] addopts = "--tb=native -ra --disable-warnings -x -l --profile -v" log_cli = true diff --git a/tests/conftest.py b/tests/conftest.py index a8d6d69947..5a23efad51 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -16,7 +16,7 @@ NS_COUNT, NUM_REPLICAS, ) -from suite.resources_utils import get_first_pod_name +from suite.utils.resources_utils import get_first_pod_name def pytest_addoption(parser) -> None: @@ -111,7 +111,7 @@ def pytest_addoption(parser) -> None: # import fixtures into pytest global namespace -pytest_plugins = ["suite.fixtures", "suite.ic_fixtures", "suite.custom_resource_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/tests/kind/kind-config-template.yaml b/tests/kind/kind-config-template.yaml deleted file mode 100644 index 5beddb49ed..0000000000 --- a/tests/kind/kind-config-template.yaml +++ /dev/null @@ -1,7 +0,0 @@ -kind: Cluster -apiVersion: kind.x-k8s.io/v1alpha4 -networking: - ipFamily: {{.IPFamily}} - apiServerAddress: {{.APIServerAddress}} -nodes: - - role: control-plane diff --git a/tests/requirements.txt b/tests/requirements.txt index 68ed4ed8a3..328b12d225 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,16 +1,16 @@ -PyYAML==6.0 -requests==2.28.1 +certifi==2022.9.24 +cffi==1.15.1 +flaky==3.7.0 forcediphttpsadapter==1.0.2 +grpcio==1.50.0 +grpcio-tools==1.50.0 kubernetes==25.3.0 -pytest==7.2.0 -cffi==1.15.1 +mock==4.0.3 +more-itertools==9.0.0 pyOpenSSL==22.1.0 -certifi==2022.9.24 -urllib3==1.26.12 +pytest==7.2.0 pytest-html==3.2.0 pytest-profiling==1.7.0 -more-itertools==9.0.0 -mock==4.0.3 -grpcio==1.50.0 -grpcio-tools==1.50.0 -flaky==3.7.0 +PyYAML==6.0 +requests==2.28.1 +urllib3==1.26.12 diff --git a/tests/settings.py b/tests/settings.py index cc53f45673..638071364c 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """Describe project settings""" import os diff --git a/tests/suite/custom_resource_fixtures.py b/tests/suite/fixtures/custom_resource_fixtures.py similarity index 97% rename from tests/suite/custom_resource_fixtures.py rename to tests/suite/fixtures/custom_resource_fixtures.py index c6ddc96bfa..e00cd1ea29 100644 --- a/tests/suite/custom_resource_fixtures.py +++ b/tests/suite/fixtures/custom_resource_fixtures.py @@ -1,11 +1,10 @@ """Describe project shared pytest fixtures related to setup of custom resources and apps.""" import pytest -import yaml from settings import TEST_DATA -from suite.custom_resources_utils import create_gc_from_yaml, create_ts_from_yaml, delete_gc, delete_ts -from suite.fixtures import PublicEndpoint -from suite.resources_utils import ( +from suite.fixtures.fixtures import PublicEndpoint +from suite.utils.custom_resources_utils import create_gc_from_yaml, create_ts_from_yaml, delete_gc, delete_ts +from suite.utils.resources_utils import ( create_deployment_with_name, create_example_app, create_items_from_yaml, @@ -19,13 +18,13 @@ get_first_pod_name, wait_until_all_pods_are_ready, ) -from suite.vs_vsr_resources_utils import ( +from suite.utils.vs_vsr_resources_utils import ( create_v_s_route_from_yaml, create_virtual_server_from_yaml, delete_v_s_route, delete_virtual_server, ) -from suite.yaml_utils import ( +from suite.utils.yaml_utils import ( get_first_host_from_yaml, get_paths_from_vs_yaml, get_paths_from_vsr_yaml, diff --git a/tests/suite/fixtures.py b/tests/suite/fixtures/fixtures.py similarity index 98% rename from tests/suite/fixtures.py rename to tests/suite/fixtures/fixtures.py index df590dc4cc..00d5b5f480 100644 --- a/tests/suite/fixtures.py +++ b/tests/suite/fixtures/fixtures.py @@ -17,9 +17,9 @@ ) from kubernetes.client.rest import ApiException from settings import ALLOWED_DEPLOYMENT_TYPES, ALLOWED_IC_TYPES, ALLOWED_SERVICE_TYPES, DEPLOYMENTS, TEST_DATA -from suite.custom_resources_utils import create_crd_from_yaml, delete_crd -from suite.kube_config_utils import ensure_context_in_config, get_current_context_name -from suite.resources_utils import ( +from suite.utils.custom_resources_utils import create_crd_from_yaml, delete_crd +from suite.utils.kube_config_utils import ensure_context_in_config, get_current_context_name +from suite.utils.resources_utils import ( cleanup_rbac, configure_rbac, create_configmap_from_yaml, @@ -34,7 +34,7 @@ wait_before_test, wait_for_public_ip, ) -from suite.yaml_utils import get_name_from_yaml +from suite.utils.yaml_utils import get_name_from_yaml class KubeApis: diff --git a/tests/suite/ic_fixtures.py b/tests/suite/fixtures/ic_fixtures.py similarity index 98% rename from tests/suite/ic_fixtures.py rename to tests/suite/fixtures/ic_fixtures.py index 823c2a0414..c6f0e25203 100644 --- a/tests/suite/ic_fixtures.py +++ b/tests/suite/fixtures/ic_fixtures.py @@ -3,11 +3,10 @@ import time import pytest -import yaml from kubernetes.client.rest import ApiException from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_resources_utils import create_crd_from_yaml, delete_crd -from suite.resources_utils import ( +from suite.utils.custom_resources_utils import create_crd_from_yaml, delete_crd +from suite.utils.resources_utils import ( cleanup_rbac, configure_rbac_with_ap, configure_rbac_with_dos, @@ -22,7 +21,7 @@ replace_configmap_from_yaml, wait_until_all_pods_are_ready, ) -from suite.yaml_utils import get_name_from_yaml +from suite.utils.yaml_utils import get_name_from_yaml @pytest.fixture(scope="class") diff --git a/tests/suite/test_ac_policies.py b/tests/suite/test_ac_policies.py index 011025706b..5376e7e47b 100644 --- a/tests/suite/test_ac_policies.py +++ b/tests/suite/test_ac_policies.py @@ -1,19 +1,16 @@ -import json - import pytest import requests -from kubernetes.client.rest import ApiException from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_resources_utils import read_custom_resource -from suite.policy_resources_utils import create_policy_from_yaml, delete_policy, read_policy -from suite.resources_utils import ( +from suite.utils.custom_resources_utils import read_custom_resource +from suite.utils.policy_resources_utils import create_policy_from_yaml, delete_policy +from suite.utils.resources_utils import ( get_last_reload_time, get_test_file_name, replace_configmap_from_yaml, wait_before_test, write_to_json, ) -from suite.vs_vsr_resources_utils import ( +from suite.utils.vs_vsr_resources_utils import ( create_virtual_server_from_yaml, delete_virtual_server, patch_virtual_server_from_yaml, diff --git a/tests/suite/test_ac_policies_vsr.py b/tests/suite/test_ac_policies_vsr.py index e9caf39231..9e05e7b80d 100644 --- a/tests/suite/test_ac_policies_vsr.py +++ b/tests/suite/test_ac_policies_vsr.py @@ -1,16 +1,10 @@ import pytest import requests -from kubernetes.client.rest import ApiException from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_resources_utils import read_custom_resource -from suite.policy_resources_utils import create_policy_from_yaml, delete_policy, read_policy -from suite.resources_utils import replace_configmap_from_yaml, wait_before_test -from suite.vs_vsr_resources_utils import ( - create_virtual_server_from_yaml, - delete_virtual_server, - patch_v_s_route_from_yaml, - patch_virtual_server_from_yaml, -) +from suite.utils.custom_resources_utils import read_custom_resource +from suite.utils.policy_resources_utils import create_policy_from_yaml, delete_policy +from suite.utils.resources_utils import replace_configmap_from_yaml, wait_before_test +from suite.utils.vs_vsr_resources_utils import patch_v_s_route_from_yaml, patch_virtual_server_from_yaml std_cm_src = f"{DEPLOYMENTS}/common/nginx-config.yaml" test_cm_src = f"{TEST_DATA}/access-control/configmap/nginx-config.yaml" diff --git a/tests/suite/test_annotations.py b/tests/suite/test_annotations.py index 907e24f99d..14fdd4a755 100644 --- a/tests/suite/test_annotations.py +++ b/tests/suite/test_annotations.py @@ -2,9 +2,9 @@ import yaml from kubernetes.client import NetworkingV1Api from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_assertions import assert_event_count_increased -from suite.fixtures import PublicEndpoint -from suite.resources_utils import ( +from suite.fixtures.fixtures import PublicEndpoint +from suite.utils.custom_assertions import assert_event_count_increased +from suite.utils.resources_utils import ( create_example_app, create_items_from_yaml, delete_common_app, @@ -19,7 +19,7 @@ wait_before_test, wait_until_all_pods_are_ready, ) -from suite.yaml_utils import get_first_ingress_host_from_yaml, get_name_from_yaml +from suite.utils.yaml_utils import get_first_ingress_host_from_yaml, get_name_from_yaml def get_event_count(event_text, events_list) -> int: diff --git a/tests/suite/test_app_protect.py b/tests/suite/test_app_protect.py index 9021f24b49..cb7dd7eb65 100644 --- a/tests/suite/test_app_protect.py +++ b/tests/suite/test_app_protect.py @@ -1,15 +1,13 @@ -import json - import pytest import requests -from settings import DEPLOYMENTS, TEST_DATA -from suite.ap_resources_utils import ( +from settings import TEST_DATA +from suite.utils.ap_resources_utils import ( create_ap_logconf_from_yaml, create_ap_policy_from_yaml, delete_ap_logconf, delete_ap_policy, ) -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_example_app, create_ingress_with_ap_annotations, create_items_from_yaml, @@ -23,7 +21,7 @@ wait_until_all_pods_are_ready, write_to_json, ) -from suite.yaml_utils import get_first_ingress_host_from_yaml +from suite.utils.yaml_utils import get_first_ingress_host_from_yaml ap_policies_under_test = ["dataguard-alarm", "file-block", "malformed-block"] valid_resp_addr = "Server address:" diff --git a/tests/suite/test_app_protect_grpc.py b/tests/suite/test_app_protect_grpc.py index 32b2c48676..d08baaa140 100644 --- a/tests/suite/test_app_protect_grpc.py +++ b/tests/suite/test_app_protect_grpc.py @@ -1,28 +1,27 @@ import grpc import pytest from settings import DEPLOYMENTS, TEST_DATA -from suite.ap_resources_utils import ( +from suite.grpc.helloworld_pb2 import HelloRequest +from suite.grpc.helloworld_pb2_grpc import GreeterStub +from suite.utils.ap_resources_utils import ( create_ap_logconf_from_yaml, create_ap_policy_from_yaml, delete_ap_logconf, delete_ap_policy, ) -from suite.grpc.helloworld_pb2 import HelloRequest -from suite.grpc.helloworld_pb2_grpc import GreeterStub -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_example_app, create_ingress_with_ap_annotations, create_items_from_yaml, delete_common_app, delete_items_from_yaml, get_file_contents, - get_service_endpoint, replace_configmap_from_yaml, wait_before_test, wait_until_all_pods_are_ready, ) -from suite.ssl_utils import get_certificate -from suite.yaml_utils import get_first_ingress_host_from_yaml +from suite.utils.ssl_utils import get_certificate +from suite.utils.yaml_utils import get_first_ingress_host_from_yaml log_loc = f"/var/log/messages" valid_resp_txt = "Hello" diff --git a/tests/suite/test_app_protect_integration.py b/tests/suite/test_app_protect_integration.py index 2a96f86538..215dfd08b9 100644 --- a/tests/suite/test_app_protect_integration.py +++ b/tests/suite/test_app_protect_integration.py @@ -2,7 +2,7 @@ import requests import yaml from settings import DEPLOYMENTS, TEST_DATA -from suite.ap_resources_utils import ( +from suite.utils.ap_resources_utils import ( create_ap_logconf_from_yaml, create_ap_policy_from_yaml, create_ap_usersig_from_yaml, @@ -11,7 +11,7 @@ delete_ap_policy, read_ap_custom_resource, ) -from suite.resources_utils import ( +from suite.utils.resources_utils import ( clear_file_contents, create_example_app, create_ingress, @@ -33,7 +33,7 @@ wait_until_all_pods_are_ready, write_to_json, ) -from suite.yaml_utils import get_first_ingress_host_from_yaml +from suite.utils.yaml_utils import get_first_ingress_host_from_yaml src_ing_yaml = f"{TEST_DATA}/appprotect/appprotect-ingress.yaml" ap_policy = "dataguard-alarm" diff --git a/tests/suite/test_app_protect_waf_policies.py b/tests/suite/test_app_protect_waf_policies.py index 9f95b08a3c..2584461cf2 100644 --- a/tests/suite/test_app_protect_waf_policies.py +++ b/tests/suite/test_app_protect_waf_policies.py @@ -1,40 +1,30 @@ -import json -import logging - import pytest import requests -from settings import DEPLOYMENTS, TEST_DATA -from suite.ap_resources_utils import ( +from settings import TEST_DATA +from suite.utils.ap_resources_utils import ( create_ap_logconf_from_yaml, create_ap_multilog_waf_policy_from_yaml, create_ap_policy_from_yaml, create_ap_usersig_from_yaml, create_ap_waf_policy_from_yaml, - delete_and_create_ap_policy_from_yaml, delete_ap_logconf, delete_ap_policy, delete_ap_usersig, read_ap_custom_resource, ) -from suite.custom_resources_utils import create_crd_from_yaml, delete_crd -from suite.policy_resources_utils import create_policy_from_yaml, delete_policy, read_policy -from suite.resources_utils import ( +from suite.utils.policy_resources_utils import create_policy_from_yaml, delete_policy +from suite.utils.resources_utils import ( create_items_from_yaml, - delete_items_from_yaml, get_file_contents, get_pod_name_that_contains, - get_service_endpoint, wait_before_test, ) -from suite.vs_vsr_resources_utils import ( - create_v_s_route_from_yaml, +from suite.utils.vs_vsr_resources_utils import ( create_virtual_server_from_yaml, - delete_v_s_route, delete_virtual_server, patch_v_s_route_from_yaml, patch_virtual_server_from_yaml, ) -from suite.yaml_utils import get_first_ingress_host_from_yaml, get_name_from_yaml ap_pol_name = "" log_name = "" diff --git a/tests/suite/test_app_protect_waf_policies_grpc.py b/tests/suite/test_app_protect_waf_policies_grpc.py index 995a0b6dc7..c2a1d8e317 100644 --- a/tests/suite/test_app_protect_waf_policies_grpc.py +++ b/tests/suite/test_app_protect_waf_policies_grpc.py @@ -1,18 +1,18 @@ import grpc import pytest from settings import DEPLOYMENTS, TEST_DATA -from suite.ap_resources_utils import ( +from suite.fixtures.custom_resource_fixtures import VirtualServerRoute, VirtualServerRouteSetup, VirtualServerSetup +from suite.grpc.helloworld_pb2 import HelloRequest +from suite.grpc.helloworld_pb2_grpc import GreeterStub +from suite.utils.ap_resources_utils import ( create_ap_logconf_from_yaml, create_ap_policy_from_yaml, create_ap_waf_policy_from_yaml, delete_ap_logconf, delete_ap_policy, ) -from suite.custom_resource_fixtures import VirtualServerRoute, VirtualServerRouteSetup, VirtualServerSetup -from suite.grpc.helloworld_pb2 import HelloRequest -from suite.grpc.helloworld_pb2_grpc import GreeterStub -from suite.policy_resources_utils import delete_policy -from suite.resources_utils import ( +from suite.utils.policy_resources_utils import delete_policy +from suite.utils.resources_utils import ( create_example_app, create_items_from_yaml, create_namespace_with_name_from_yaml, @@ -26,13 +26,13 @@ wait_before_test, wait_until_all_pods_are_ready, ) -from suite.ssl_utils import get_certificate -from suite.vs_vsr_resources_utils import ( +from suite.utils.ssl_utils import get_certificate +from suite.utils.vs_vsr_resources_utils import ( create_v_s_route_from_yaml, create_virtual_server_from_yaml, delete_virtual_server, ) -from suite.yaml_utils import get_first_host_from_yaml, get_paths_from_vs_yaml, get_paths_from_vsr_yaml +from suite.utils.yaml_utils import get_first_host_from_yaml, get_paths_from_vs_yaml, get_paths_from_vsr_yaml log_loc = f"/var/log/messages" valid_resp_txt = "Hello" diff --git a/tests/suite/test_app_protect_watch_namespace.py b/tests/suite/test_app_protect_watch_namespace.py index 3310192769..e979cea86b 100644 --- a/tests/suite/test_app_protect_watch_namespace.py +++ b/tests/suite/test_app_protect_watch_namespace.py @@ -2,14 +2,14 @@ import pytest import requests -from settings import DEPLOYMENTS, TEST_DATA -from suite.ap_resources_utils import ( +from settings import TEST_DATA +from suite.utils.ap_resources_utils import ( create_ap_logconf_from_yaml, create_ap_policy_from_yaml, delete_ap_logconf, delete_ap_policy, ) -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_example_app, create_ingress_with_ap_annotations, create_items_from_yaml, @@ -22,7 +22,7 @@ wait_before_test, 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 # This test shows that a policy outside of the namespace test_namespace is not picked up by IC. diff --git a/tests/suite/test_auth_basic_auth_mergeable.py b/tests/suite/test_auth_basic_auth_mergeable.py index 07fcee1046..de55853ab4 100644 --- a/tests/suite/test_auth_basic_auth_mergeable.py +++ b/tests/suite/test_auth_basic_auth_mergeable.py @@ -3,8 +3,8 @@ import pytest import requests from settings import TEST_DATA -from suite.fixtures import PublicEndpoint -from suite.resources_utils import ( +from suite.fixtures.fixtures import PublicEndpoint +from suite.utils.resources_utils import ( create_example_app, create_items_from_yaml, create_secret_from_yaml, @@ -17,7 +17,7 @@ wait_before_test, 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 def to_base64(b64_string): @@ -103,7 +103,7 @@ def get_credentials_from_file(creds_type) -> str: :return: str """ with open( - f"{TEST_DATA}/auth-basic-auth-mergeable/credentials/auth-basic-auth-{creds_type}-credentials.txt", "r" + f"{TEST_DATA}/auth-basic-auth-mergeable/credentials/auth-basic-auth-{creds_type}-credentials.txt" ) as credentials_file: return credentials_file.read().replace("\n", "") diff --git a/tests/suite/test_auth_basic_policies.py b/tests/suite/test_auth_basic_policies.py index af7b3c0e76..ba3bafa97f 100644 --- a/tests/suite/test_auth_basic_policies.py +++ b/tests/suite/test_auth_basic_policies.py @@ -2,22 +2,11 @@ import pytest import requests -from kubernetes.client.rest import ApiException -from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_resources_utils import read_custom_resource -from suite.policy_resources_utils import create_policy_from_yaml, delete_policy, read_policy -from suite.resources_utils import ( - create_secret_from_yaml, - delete_secret, - replace_configmap_from_yaml, - replace_secret, - wait_before_test, -) -from suite.vs_vsr_resources_utils import ( - create_virtual_server_from_yaml, - delete_and_create_vs_from_yaml, - delete_virtual_server, -) +from settings import TEST_DATA +from suite.utils.custom_resources_utils import read_custom_resource +from suite.utils.policy_resources_utils import create_policy_from_yaml, delete_policy +from suite.utils.resources_utils import create_secret_from_yaml, delete_secret, wait_before_test +from suite.utils.vs_vsr_resources_utils import delete_and_create_vs_from_yaml std_vs_src = f"{TEST_DATA}/virtual-server/standard/virtual-server.yaml" htpasswd_sec_valid_src = f"{TEST_DATA}/auth-basic-policy/secret/htpasswd-secret-valid.yaml" diff --git a/tests/suite/test_auth_basic_policies_vsr.py b/tests/suite/test_auth_basic_policies_vsr.py index 240b2053b0..b1e3d59a36 100644 --- a/tests/suite/test_auth_basic_policies_vsr.py +++ b/tests/suite/test_auth_basic_policies_vsr.py @@ -2,22 +2,11 @@ import pytest import requests -from kubernetes.client.rest import ApiException -from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_resources_utils import read_custom_resource -from suite.policy_resources_utils import create_policy_from_yaml, delete_policy, read_policy -from suite.resources_utils import ( - create_secret_from_yaml, - delete_secret, - replace_configmap_from_yaml, - replace_secret, - wait_before_test, -) -from suite.vs_vsr_resources_utils import ( - delete_virtual_server, - patch_v_s_route_from_yaml, - patch_virtual_server_from_yaml, -) +from settings import TEST_DATA +from suite.utils.custom_resources_utils import read_custom_resource +from suite.utils.policy_resources_utils import create_policy_from_yaml, delete_policy +from suite.utils.resources_utils import create_secret_from_yaml, delete_secret, wait_before_test +from suite.utils.vs_vsr_resources_utils import patch_v_s_route_from_yaml, patch_virtual_server_from_yaml std_vs_src = f"{TEST_DATA}/virtual-server-route/standard/virtual-server.yaml" std_vsr_src = f"{TEST_DATA}/virtual-server-route/route-multiple.yaml" diff --git a/tests/suite/test_auth_basic_secrets.py b/tests/suite/test_auth_basic_secrets.py index 8edb3b8c88..5052f96cc6 100644 --- a/tests/suite/test_auth_basic_secrets.py +++ b/tests/suite/test_auth_basic_secrets.py @@ -3,8 +3,8 @@ import pytest import requests from settings import TEST_DATA -from suite.fixtures import PublicEndpoint -from suite.resources_utils import ( +from suite.fixtures.fixtures import PublicEndpoint +from suite.utils.resources_utils import ( create_example_app, create_items_from_yaml, create_secret_from_yaml, @@ -17,7 +17,7 @@ wait_before_test, 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 def to_base64(b64_string): @@ -56,7 +56,7 @@ def __init__(self, secret_name): def auth_basic_secrets_setup( request, kube_apis, ingress_controller_endpoint, ingress_controller, test_namespace ) -> AuthBasicSecretsSetup: - with open(f"{TEST_DATA}/auth-basic-secrets/credentials/credentials.txt", "r") as credentials_file: + with open(f"{TEST_DATA}/auth-basic-secrets/credentials/credentials.txt") as credentials_file: credentials = credentials_file.read().replace("\n", "") print("------------------------- Deploy Auth Basic Secrets Example -----------------------------------") create_items_from_yaml( diff --git a/tests/suite/test_batch_reloads.py b/tests/suite/test_batch_reloads.py index e08d625f7e..ac86c787fd 100644 --- a/tests/suite/test_batch_reloads.py +++ b/tests/suite/test_batch_reloads.py @@ -5,7 +5,7 @@ import requests import yaml from settings import TEST_DATA -from suite.ap_resources_utils import ( +from suite.utils.ap_resources_utils import ( create_ap_logconf_from_yaml, create_ap_policy_from_yaml, create_ap_usersig_from_yaml, @@ -14,8 +14,8 @@ delete_ap_policy, delete_ap_usersig, ) -from suite.policy_resources_utils import create_policy_from_yaml, delete_policy -from suite.resources_utils import ( +from suite.utils.policy_resources_utils import delete_policy +from suite.utils.resources_utils import ( create_example_app, create_ingress_with_ap_annotations, create_items_from_yaml, @@ -33,13 +33,13 @@ wait_before_test, wait_until_all_pods_are_ready, ) -from suite.vs_vsr_resources_utils import ( +from suite.utils.vs_vsr_resources_utils import ( create_custom_items_from_yaml, create_virtual_server, delete_virtual_server, patch_virtual_server_from_yaml, ) -from suite.yaml_utils import get_first_ingress_host_from_yaml +from suite.utils.yaml_utils import get_first_ingress_host_from_yaml class IngressSetup: diff --git a/tests/suite/test_batch_startup_times.py b/tests/suite/test_batch_startup_times.py index 2a641c5d2e..eceec15098 100644 --- a/tests/suite/test_batch_startup_times.py +++ b/tests/suite/test_batch_startup_times.py @@ -2,7 +2,7 @@ import requests import yaml from settings import TEST_DATA -from suite.ap_resources_utils import ( +from suite.utils.ap_resources_utils import ( create_ap_logconf_from_yaml, create_ap_policy_from_yaml, create_ap_usersig_from_yaml, @@ -11,8 +11,8 @@ delete_ap_policy, delete_ap_usersig, ) -from suite.policy_resources_utils import delete_policy -from suite.resources_utils import ( +from suite.utils.policy_resources_utils import delete_policy +from suite.utils.resources_utils import ( create_example_app, create_ingress, create_ingress_with_ap_annotations, @@ -33,13 +33,13 @@ wait_before_test, wait_until_all_pods_are_ready, ) -from suite.vs_vsr_resources_utils import ( +from suite.utils.vs_vsr_resources_utils import ( create_v_s_route, create_virtual_server, delete_virtual_server, patch_virtual_server_from_yaml, ) -from suite.yaml_utils import get_first_ingress_host_from_yaml +from suite.utils.yaml_utils import get_first_ingress_host_from_yaml class IngressSetup: diff --git a/tests/suite/test_build_info.py b/tests/suite/test_build_info.py index a264cb0cfe..41359e04b5 100644 --- a/tests/suite/test_build_info.py +++ b/tests/suite/test_build_info.py @@ -3,8 +3,7 @@ import time import pytest -from kubernetes.client.rest import ApiException -from suite.resources_utils import get_first_pod_name, wait_until_all_pods_are_ready +from suite.utils.resources_utils import get_first_pod_name, wait_until_all_pods_are_ready @pytest.mark.ingresses @@ -47,7 +46,7 @@ def send_build_info(self, kube_apis, ingress_controller_prerequisites) -> str: raise ex br = io.StringIO(api_response) - _log = br.readline() + _log = br.readline().strip() try: _info = _log[_log.find("Version") :].strip() logging.info(f"Version and GitCommit info: {_info}") diff --git a/tests/suite/test_custom_annotations.py b/tests/suite/test_custom_annotations.py index 8a130f2d55..c36525fa65 100644 --- a/tests/suite/test_custom_annotations.py +++ b/tests/suite/test_custom_annotations.py @@ -1,7 +1,7 @@ import pytest from settings import DEPLOYMENTS, TEST_DATA -from suite.fixtures import PublicEndpoint -from suite.resources_utils import ( +from suite.fixtures.fixtures import PublicEndpoint +from suite.utils.resources_utils import ( create_items_from_yaml, delete_items_from_yaml, get_first_pod_name, @@ -9,7 +9,7 @@ replace_configmap_from_yaml, wait_before_test, ) -from suite.yaml_utils import get_first_ingress_host_from_yaml, get_name_from_yaml +from suite.utils.yaml_utils import get_first_ingress_host_from_yaml, get_name_from_yaml class CustomAnnotationsSetup: diff --git a/tests/suite/test_default_server.py b/tests/suite/test_default_server.py index ca0b379dd7..537890b4c0 100644 --- a/tests/suite/test_default_server.py +++ b/tests/suite/test_default_server.py @@ -2,7 +2,7 @@ import pytest from settings import DEPLOYMENTS, TEST_DATA -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_secret_from_yaml, delete_secret, ensure_connection, @@ -10,7 +10,7 @@ replace_secret, wait_before_test, ) -from suite.ssl_utils import get_server_certificate_subject +from suite.utils.ssl_utils import get_server_certificate_subject def assert_cn(endpoint, cn): diff --git a/tests/suite/test_disable_ipv6.py b/tests/suite/test_disable_ipv6.py index 2102921123..6aa67e0f09 100644 --- a/tests/suite/test_disable_ipv6.py +++ b/tests/suite/test_disable_ipv6.py @@ -1,6 +1,6 @@ import pytest from settings import TEST_DATA -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_example_app, create_items_from_yaml, create_secret_from_yaml, @@ -15,8 +15,8 @@ wait_before_test, wait_until_all_pods_are_ready, ) -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf -from suite.yaml_utils import get_name_from_yaml +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf +from suite.utils.yaml_utils import get_name_from_yaml @pytest.mark.vs diff --git a/tests/suite/test_dos.py b/tests/suite/test_dos.py index 55ffd21c04..d1c176e025 100644 --- a/tests/suite/test_dos.py +++ b/tests/suite/test_dos.py @@ -4,8 +4,8 @@ import pytest import requests -from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_resources_utils import ( +from settings import TEST_DATA +from suite.utils.custom_resources_utils import ( create_dos_logconf_from_yaml, create_dos_policy_from_yaml, create_dos_protected_from_yaml, @@ -13,14 +13,13 @@ delete_dos_policy, delete_dos_protected, ) -from suite.dos_utils import ( +from suite.utils.dos_utils import ( check_learning_status_with_admd_s, clean_good_bad_clients, find_in_log, log_content_to_dic, - print_admd_log, ) -from suite.resources_utils import ( +from suite.utils.resources_utils import ( clear_file_contents, create_dos_arbitrator, create_example_app, @@ -42,7 +41,7 @@ wait_until_all_pods_are_ready, write_to_json, ) -from suite.yaml_utils import get_first_ingress_host_from_yaml +from suite.utils.yaml_utils import get_first_ingress_host_from_yaml src_ing_yaml = f"{TEST_DATA}/dos/dos-ingress.yaml" valid_resp_addr = "Server address:" diff --git a/tests/suite/test_externalname_service.py b/tests/suite/test_externalname_service.py index 8c1d8f6f44..a7fde6997f 100644 --- a/tests/suite/test_externalname_service.py +++ b/tests/suite/test_externalname_service.py @@ -1,8 +1,8 @@ import pytest import requests from settings import TEST_DATA -from suite.fixtures import PublicEndpoint -from suite.resources_utils import ( +from suite.fixtures.fixtures import PublicEndpoint +from suite.utils.resources_utils import ( create_deployment_with_name, create_ingress_from_yaml, create_namespace_with_name_from_yaml, @@ -19,7 +19,7 @@ replace_configmap_from_yaml, wait_before_test, ) -from suite.yaml_utils import get_first_ingress_host_from_yaml +from suite.utils.yaml_utils import get_first_ingress_host_from_yaml class ExternalNameSetup: diff --git a/tests/suite/test_filter_secrets.py b/tests/suite/test_filter_secrets.py index bb5a425649..cfc30cdb56 100644 --- a/tests/suite/test_filter_secrets.py +++ b/tests/suite/test_filter_secrets.py @@ -1,7 +1,6 @@ import pytest -import requests from settings import TEST_DATA -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_namespace_with_name_from_yaml, create_secret_from_yaml, delete_namespace, diff --git a/tests/suite/test_healthcheck_uri.py b/tests/suite/test_healthcheck_uri.py index dec4ccfade..0fb061f606 100644 --- a/tests/suite/test_healthcheck_uri.py +++ b/tests/suite/test_healthcheck_uri.py @@ -1,6 +1,6 @@ import pytest import requests -from suite.resources_utils import ensure_connection +from suite.utils.resources_utils import ensure_connection @pytest.mark.ingresses diff --git a/tests/suite/test_hsts.py b/tests/suite/test_hsts.py index 2cd3d1b8c6..a0303b6827 100644 --- a/tests/suite/test_hsts.py +++ b/tests/suite/test_hsts.py @@ -1,8 +1,8 @@ import pytest import requests from settings import TEST_DATA -from suite.fixtures import PublicEndpoint -from suite.resources_utils import ( +from suite.fixtures.fixtures import PublicEndpoint +from suite.utils.resources_utils import ( create_example_app, create_items_from_yaml, delete_common_app, @@ -14,7 +14,7 @@ wait_before_test, wait_until_all_pods_are_ready, ) -from suite.yaml_utils import get_first_ingress_host_from_yaml, get_name_from_yaml +from suite.utils.yaml_utils import get_first_ingress_host_from_yaml, get_name_from_yaml class HSTSSetup: diff --git a/tests/suite/test_ingress_class.py b/tests/suite/test_ingress_class.py index 9eb03db29c..eda5d4786c 100644 --- a/tests/suite/test_ingress_class.py +++ b/tests/suite/test_ingress_class.py @@ -1,7 +1,7 @@ import pytest import requests from settings import TEST_DATA -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_example_app, create_items_from_yaml, delete_common_app, @@ -11,7 +11,7 @@ wait_before_test, 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 class BackendSetup: diff --git a/tests/suite/test_ingress_mtls.py b/tests/suite/test_ingress_mtls.py index 5148bf571b..6ebe7922c4 100644 --- a/tests/suite/test_ingress_mtls.py +++ b/tests/suite/test_ingress_mtls.py @@ -1,11 +1,17 @@ -import mock +from unittest import mock + import pytest import requests from settings import TEST_DATA -from suite.policy_resources_utils import create_policy_from_yaml, delete_policy -from suite.resources_utils import create_secret_from_yaml, delete_secret, wait_before_test -from suite.ssl_utils import create_sni_session -from suite.vs_vsr_resources_utils import patch_v_s_route_from_yaml, patch_virtual_server_from_yaml, read_vs, read_vsr +from suite.utils.policy_resources_utils import create_policy_from_yaml, delete_policy +from suite.utils.resources_utils import create_secret_from_yaml, delete_secret, wait_before_test +from suite.utils.ssl_utils import create_sni_session +from suite.utils.vs_vsr_resources_utils import ( + patch_v_s_route_from_yaml, + patch_virtual_server_from_yaml, + read_vs, + read_vsr, +) std_vs_src = f"{TEST_DATA}/virtual-server/standard/virtual-server.yaml" std_vsr_src = f"{TEST_DATA}/virtual-server-route/route-multiple.yaml" diff --git a/tests/suite/test_jwt_auth_mergeable.py b/tests/suite/test_jwt_auth_mergeable.py index 9da944e62b..3ec97d9487 100644 --- a/tests/suite/test_jwt_auth_mergeable.py +++ b/tests/suite/test_jwt_auth_mergeable.py @@ -1,8 +1,8 @@ import pytest import requests from settings import TEST_DATA -from suite.fixtures import PublicEndpoint -from suite.resources_utils import ( +from suite.fixtures.fixtures import PublicEndpoint +from suite.utils.resources_utils import ( create_example_app, create_items_from_yaml, create_secret_from_yaml, @@ -15,7 +15,7 @@ wait_before_test, 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 class JWTAuthMergeableSetup: @@ -88,7 +88,7 @@ def get_token_from_file(token_type) -> str: :param token_type: 'master' or 'minion' :return: str """ - with open(f"{TEST_DATA}/jwt-auth-mergeable/tokens/jwt-auth-{token_type}-token.jwt", "r") as token_file: + with open(f"{TEST_DATA}/jwt-auth-mergeable/tokens/jwt-auth-{token_type}-token.jwt") as token_file: return token_file.read().replace("\n", "") diff --git a/tests/suite/test_jwt_policies.py b/tests/suite/test_jwt_policies.py index e15f3c2a2b..bc6b2b11c4 100644 --- a/tests/suite/test_jwt_policies.py +++ b/tests/suite/test_jwt_policies.py @@ -1,23 +1,10 @@ -import time - import pytest import requests -from kubernetes.client.rest import ApiException -from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_resources_utils import read_custom_resource -from suite.policy_resources_utils import create_policy_from_yaml, delete_policy, read_policy -from suite.resources_utils import ( - create_secret_from_yaml, - delete_secret, - replace_configmap_from_yaml, - replace_secret, - wait_before_test, -) -from suite.vs_vsr_resources_utils import ( - create_virtual_server_from_yaml, - delete_and_create_vs_from_yaml, - delete_virtual_server, -) +from settings import TEST_DATA +from suite.utils.custom_resources_utils import read_custom_resource +from suite.utils.policy_resources_utils import create_policy_from_yaml, delete_policy +from suite.utils.resources_utils import create_secret_from_yaml, delete_secret, wait_before_test +from suite.utils.vs_vsr_resources_utils import delete_and_create_vs_from_yaml std_vs_src = f"{TEST_DATA}/virtual-server/standard/virtual-server.yaml" jwk_sec_valid_src = f"{TEST_DATA}/jwt-policy/secret/jwk-secret-valid.yaml" diff --git a/tests/suite/test_jwt_policies_vsr.py b/tests/suite/test_jwt_policies_vsr.py index 5850e03b15..44c03aaf7a 100644 --- a/tests/suite/test_jwt_policies_vsr.py +++ b/tests/suite/test_jwt_policies_vsr.py @@ -1,23 +1,10 @@ -import time - import pytest import requests -from kubernetes.client.rest import ApiException -from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_resources_utils import read_custom_resource -from suite.policy_resources_utils import create_policy_from_yaml, delete_policy, read_policy -from suite.resources_utils import ( - create_secret_from_yaml, - delete_secret, - replace_configmap_from_yaml, - replace_secret, - wait_before_test, -) -from suite.vs_vsr_resources_utils import ( - delete_virtual_server, - patch_v_s_route_from_yaml, - patch_virtual_server_from_yaml, -) +from settings import TEST_DATA +from suite.utils.custom_resources_utils import read_custom_resource +from suite.utils.policy_resources_utils import create_policy_from_yaml, delete_policy +from suite.utils.resources_utils import create_secret_from_yaml, delete_secret, wait_before_test +from suite.utils.vs_vsr_resources_utils import patch_v_s_route_from_yaml, patch_virtual_server_from_yaml std_vs_src = f"{TEST_DATA}/virtual-server-route/standard/virtual-server.yaml" std_vsr_src = f"{TEST_DATA}/virtual-server-route/route-multiple.yaml" diff --git a/tests/suite/test_jwt_secrets.py b/tests/suite/test_jwt_secrets.py index 154f063587..e3ebd8f6e9 100644 --- a/tests/suite/test_jwt_secrets.py +++ b/tests/suite/test_jwt_secrets.py @@ -1,8 +1,8 @@ import pytest import requests from settings import TEST_DATA -from suite.fixtures import PublicEndpoint -from suite.resources_utils import ( +from suite.fixtures.fixtures import PublicEndpoint +from suite.utils.resources_utils import ( create_example_app, create_items_from_yaml, create_secret_from_yaml, @@ -15,7 +15,7 @@ wait_before_test, 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 class JWTSecretsSetup: @@ -50,7 +50,7 @@ def __init__(self, secret_name): def jwt_secrets_setup( request, kube_apis, ingress_controller_endpoint, ingress_controller, test_namespace ) -> JWTSecretsSetup: - with open(f"{TEST_DATA}/jwt-secrets/tokens/jwt-secrets-token.jwt", "r") as token_file: + with open(f"{TEST_DATA}/jwt-secrets/tokens/jwt-secrets-token.jwt") as token_file: token = token_file.read().replace("\n", "") print("------------------------- Deploy JWT Secrets Example -----------------------------------") create_items_from_yaml( diff --git a/tests/suite/test_multiple_ns_perf.py b/tests/suite/test_multiple_ns_perf.py index 0a672424fd..cba889c5ba 100644 --- a/tests/suite/test_multiple_ns_perf.py +++ b/tests/suite/test_multiple_ns_perf.py @@ -4,8 +4,8 @@ import pytest import yaml from settings import TEST_DATA -from suite.custom_resources_utils import get_pod_metrics -from suite.resources_utils import ( +from suite.utils.custom_resources_utils import get_pod_metrics +from suite.utils.resources_utils import ( create_example_app, create_ingress, create_ingress_controller, @@ -17,7 +17,7 @@ wait_until_all_pods_are_ready, write_to_json, ) -from suite.vs_vsr_resources_utils import create_virtual_server +from suite.utils.vs_vsr_resources_utils import create_virtual_server watched_namespaces = "" diff --git a/tests/suite/test_policy_ingress_class.py b/tests/suite/test_policy_ingress_class.py index 45f68f677a..7089a20f23 100644 --- a/tests/suite/test_policy_ingress_class.py +++ b/tests/suite/test_policy_ingress_class.py @@ -1,12 +1,9 @@ -import time - import pytest -import requests from settings import TEST_DATA -from suite.custom_resources_utils import read_custom_resource -from suite.policy_resources_utils import create_policy_from_yaml, delete_policy, read_policy -from suite.resources_utils import wait_before_test -from suite.vs_vsr_resources_utils import ( +from suite.utils.custom_resources_utils import read_custom_resource +from suite.utils.policy_resources_utils import create_policy_from_yaml, delete_policy +from suite.utils.resources_utils import wait_before_test +from suite.utils.vs_vsr_resources_utils import ( create_virtual_server_from_yaml, delete_virtual_server, patch_virtual_server_from_yaml, diff --git a/tests/suite/test_prometheus_metrics.py b/tests/suite/test_prometheus_metrics.py index f59e28fe66..92c3daac74 100644 --- a/tests/suite/test_prometheus_metrics.py +++ b/tests/suite/test_prometheus_metrics.py @@ -1,7 +1,7 @@ import pytest import requests from settings import TEST_DATA -from suite.custom_resources_utils import ( +from suite.utils.custom_resources_utils import ( create_gc_from_yaml, create_ts_from_yaml, delete_gc, @@ -9,7 +9,7 @@ patch_ts, patch_ts_from_yaml, ) -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_example_app, create_items_from_yaml, create_secret_from_yaml, @@ -22,7 +22,7 @@ wait_before_test, 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 class IngressSetup: diff --git a/tests/suite/test_rewrites.py b/tests/suite/test_rewrites.py index 879fb6cf3e..4f07913b60 100644 --- a/tests/suite/test_rewrites.py +++ b/tests/suite/test_rewrites.py @@ -1,13 +1,13 @@ import pytest import requests from settings import TEST_DATA -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_items_from_yaml, delete_items_from_yaml, wait_before_test, wait_until_all_pods_are_ready, ) -from suite.vs_vsr_resources_utils import ( +from suite.utils.vs_vsr_resources_utils import ( create_v_s_route_from_yaml, create_virtual_server_from_yaml, delete_v_s_route, diff --git a/tests/suite/test_rl_policies.py b/tests/suite/test_rl_policies.py index a2490cc16e..efed38b4f6 100644 --- a/tests/suite/test_rl_policies.py +++ b/tests/suite/test_rl_policies.py @@ -2,12 +2,11 @@ import pytest import requests -from kubernetes.client.rest import ApiException -from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_resources_utils import read_custom_resource -from suite.policy_resources_utils import create_policy_from_yaml, delete_policy, read_policy -from suite.resources_utils import replace_configmap_from_yaml, wait_before_test -from suite.vs_vsr_resources_utils import ( +from settings import TEST_DATA +from suite.utils.custom_resources_utils import read_custom_resource +from suite.utils.policy_resources_utils import create_policy_from_yaml, delete_policy +from suite.utils.resources_utils import wait_before_test +from suite.utils.vs_vsr_resources_utils import ( create_virtual_server_from_yaml, delete_virtual_server, patch_virtual_server_from_yaml, diff --git a/tests/suite/test_rl_policies_vsr.py b/tests/suite/test_rl_policies_vsr.py index 35fa724e28..c28fc43bf2 100644 --- a/tests/suite/test_rl_policies_vsr.py +++ b/tests/suite/test_rl_policies_vsr.py @@ -2,17 +2,11 @@ import pytest import requests -from kubernetes.client.rest import ApiException -from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_resources_utils import read_custom_resource -from suite.policy_resources_utils import create_policy_from_yaml, delete_policy, read_policy -from suite.resources_utils import replace_configmap_from_yaml, wait_before_test -from suite.vs_vsr_resources_utils import ( - create_virtual_server_from_yaml, - delete_virtual_server, - patch_v_s_route_from_yaml, - patch_virtual_server_from_yaml, -) +from settings import TEST_DATA +from suite.utils.custom_resources_utils import read_custom_resource +from suite.utils.policy_resources_utils import create_policy_from_yaml, delete_policy +from suite.utils.resources_utils import wait_before_test +from suite.utils.vs_vsr_resources_utils import patch_v_s_route_from_yaml, patch_virtual_server_from_yaml std_vs_src = f"{TEST_DATA}/virtual-server-route/standard/virtual-server.yaml" rl_pol_pri_src = f"{TEST_DATA}/rate-limit/policies/rate-limit-primary.yaml" diff --git a/tests/suite/test_smoke.py b/tests/suite/test_smoke.py index 75b898c1ab..b051f75554 100644 --- a/tests/suite/test_smoke.py +++ b/tests/suite/test_smoke.py @@ -2,12 +2,11 @@ import tempfile import pytest -import requests import yaml from settings import TEST_DATA -from suite.custom_assertions import wait_and_assert_status_code -from suite.fixtures import PublicEndpoint -from suite.resources_utils import ( +from suite.fixtures.fixtures import PublicEndpoint +from suite.utils.custom_assertions import wait_and_assert_status_code +from suite.utils.resources_utils import ( create_example_app, create_items_from_yaml, create_secret_from_yaml, @@ -25,7 +24,7 @@ wait_until_all_pods_are_ready, write_to_json, ) -from suite.yaml_utils import get_first_ingress_host_from_yaml +from suite.utils.yaml_utils import get_first_ingress_host_from_yaml paths = ["backend1", "backend2"] reload_times = {} diff --git a/tests/suite/test_snippet_flag.py b/tests/suite/test_snippet_flag.py index 3f54a20298..65ac53e90f 100644 --- a/tests/suite/test_snippet_flag.py +++ b/tests/suite/test_snippet_flag.py @@ -2,8 +2,8 @@ import pytest from settings import TEST_DATA -from suite.custom_assertions import assert_event -from suite.resources_utils import ( +from suite.utils.custom_assertions import assert_event +from suite.utils.resources_utils import ( create_ingress_from_yaml, delete_ingress, get_events, diff --git a/tests/suite/test_tls.py b/tests/suite/test_tls.py index e90ce9bfbb..72e17a79b0 100644 --- a/tests/suite/test_tls.py +++ b/tests/suite/test_tls.py @@ -1,7 +1,7 @@ import pytest from _ssl import SSLError from settings import TEST_DATA -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_ingress_from_yaml, create_secret_from_yaml, delete_items_from_yaml, @@ -11,8 +11,8 @@ replace_secret, wait_before_test, ) -from suite.ssl_utils import get_server_certificate_subject -from suite.yaml_utils import get_first_ingress_host_from_yaml, get_name_from_yaml +from suite.utils.ssl_utils import get_server_certificate_subject +from suite.utils.yaml_utils import get_first_ingress_host_from_yaml, get_name_from_yaml def assert_unrecognized_name_error(endpoint, host): diff --git a/tests/suite/test_transport_server.py b/tests/suite/test_transport_server.py index 5d3d70117d..fa72fbd694 100644 --- a/tests/suite/test_transport_server.py +++ b/tests/suite/test_transport_server.py @@ -1,7 +1,7 @@ import pytest from settings import TEST_DATA -from suite.custom_resources_utils import patch_ts_from_yaml -from suite.resources_utils import get_ts_nginx_template_conf, wait_before_test +from suite.utils.custom_resources_utils import patch_ts_from_yaml +from suite.utils.resources_utils import get_ts_nginx_template_conf, wait_before_test @pytest.mark.ts diff --git a/tests/suite/test_transport_server_external_name.py b/tests/suite/test_transport_server_external_name.py index 1b4a689917..5b7b12493c 100644 --- a/tests/suite/test_transport_server_external_name.py +++ b/tests/suite/test_transport_server_external_name.py @@ -1,7 +1,7 @@ import pytest from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_assertions import assert_event -from suite.resources_utils import ( +from suite.utils.custom_assertions import assert_event +from suite.utils.resources_utils import ( create_items_from_yaml, create_namespace_with_name_from_yaml, create_service_from_yaml, diff --git a/tests/suite/test_transport_server_status.py b/tests/suite/test_transport_server_status.py index e153c6f03f..d8e7c34dcd 100644 --- a/tests/suite/test_transport_server_status.py +++ b/tests/suite/test_transport_server_status.py @@ -1,7 +1,7 @@ import pytest from settings import TEST_DATA -from suite.custom_resources_utils import patch_ts_from_yaml, read_ts -from suite.resources_utils import wait_before_test +from suite.utils.custom_resources_utils import patch_ts_from_yaml, read_ts +from suite.utils.resources_utils import wait_before_test @pytest.mark.ts diff --git a/tests/suite/test_transport_server_tcp_load_balance.py b/tests/suite/test_transport_server_tcp_load_balance.py index 044e7d6a88..ec9f3ad6e6 100644 --- a/tests/suite/test_transport_server_tcp_load_balance.py +++ b/tests/suite/test_transport_server_tcp_load_balance.py @@ -1,18 +1,10 @@ import re import socket -import time import pytest from settings import TEST_DATA -from suite.custom_resources_utils import create_ts_from_yaml, delete_ts, patch_ts_from_yaml, read_ts -from suite.resources_utils import ( - get_events, - get_ts_nginx_template_conf, - scale_deployment, - wait_before_test, - wait_for_event_increment, -) -from urllib3.exceptions import NewConnectionError +from suite.utils.custom_resources_utils import create_ts_from_yaml, delete_ts, patch_ts_from_yaml, read_ts +from suite.utils.resources_utils import get_ts_nginx_template_conf, scale_deployment, wait_before_test @pytest.mark.ts diff --git a/tests/suite/test_transport_server_udp_load_balance.py b/tests/suite/test_transport_server_udp_load_balance.py index 4e25a50a41..841fc43bf9 100644 --- a/tests/suite/test_transport_server_udp_load_balance.py +++ b/tests/suite/test_transport_server_udp_load_balance.py @@ -4,14 +4,8 @@ import pytest from settings import TEST_DATA -from suite.custom_resources_utils import create_ts_from_yaml, delete_ts, patch_ts_from_yaml, read_ts -from suite.resources_utils import ( - get_events, - get_ts_nginx_template_conf, - scale_deployment, - wait_before_test, - wait_for_event_increment, -) +from suite.utils.custom_resources_utils import create_ts_from_yaml, delete_ts, patch_ts_from_yaml, read_ts +from suite.utils.resources_utils import get_ts_nginx_template_conf, scale_deployment, wait_before_test # Helper functions diff --git a/tests/suite/test_ts_tls_passthrough.py b/tests/suite/test_ts_tls_passthrough.py index 84efcbe811..59ff97dea4 100644 --- a/tests/suite/test_ts_tls_passthrough.py +++ b/tests/suite/test_ts_tls_passthrough.py @@ -2,9 +2,9 @@ import pytest from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_resources_utils import create_ts_from_yaml, delete_ts, read_ts -from suite.fixtures import PublicEndpoint -from suite.resources_utils import ( +from suite.fixtures.fixtures import PublicEndpoint +from suite.utils.custom_resources_utils import create_ts_from_yaml, delete_ts, read_ts +from suite.utils.resources_utils import ( create_items_from_yaml, delete_items_from_yaml, get_first_pod_name, @@ -13,9 +13,9 @@ wait_before_test, wait_until_all_pods_are_ready, ) -from suite.ssl_utils import create_sni_session -from suite.vs_vsr_resources_utils import create_virtual_server_from_yaml, delete_virtual_server, read_vs -from suite.yaml_utils import get_first_host_from_yaml +from suite.utils.ssl_utils import create_sni_session +from suite.utils.vs_vsr_resources_utils import create_virtual_server_from_yaml, delete_virtual_server, read_vs +from suite.utils.yaml_utils import get_first_host_from_yaml class TransportServerTlsSetup: diff --git a/tests/suite/test_v_s_route.py b/tests/suite/test_v_s_route.py index e64660005e..4e70e32c5a 100644 --- a/tests/suite/test_v_s_route.py +++ b/tests/suite/test_v_s_route.py @@ -2,12 +2,12 @@ import requests from kubernetes.client.rest import ApiException from settings import TEST_DATA -from suite.custom_assertions import ( +from suite.utils.custom_assertions import ( assert_event_and_count, assert_event_and_get_count, assert_event_with_full_equality_and_count, ) -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_service_with_name, delete_service, get_events, @@ -16,7 +16,7 @@ replace_service, wait_before_test, ) -from suite.vs_vsr_resources_utils import ( +from suite.utils.vs_vsr_resources_utils import ( create_v_s_route_from_yaml, create_virtual_server_from_yaml, delete_v_s_route, @@ -24,7 +24,7 @@ get_vs_nginx_template_conf, patch_v_s_route_from_yaml, ) -from suite.yaml_utils import get_paths_from_vsr_yaml +from suite.utils.yaml_utils import get_paths_from_vsr_yaml def assert_responses_and_server_name(resp_1, resp_2, resp_3): diff --git a/tests/suite/test_v_s_route_advanced_routing.py b/tests/suite/test_v_s_route_advanced_routing.py index fbf9e85043..b9a34c26cf 100644 --- a/tests/suite/test_v_s_route_advanced_routing.py +++ b/tests/suite/test_v_s_route_advanced_routing.py @@ -1,8 +1,8 @@ import pytest import requests from settings import TEST_DATA -from suite.custom_resource_fixtures import VirtualServerRoute -from suite.resources_utils import ( +from suite.fixtures.custom_resource_fixtures import VirtualServerRoute +from suite.utils.resources_utils import ( create_example_app, create_namespace_with_name_from_yaml, delete_namespace, @@ -10,12 +10,12 @@ wait_before_test, wait_until_all_pods_are_ready, ) -from suite.vs_vsr_resources_utils import ( +from suite.utils.vs_vsr_resources_utils import ( create_v_s_route_from_yaml, create_virtual_server_from_yaml, patch_v_s_route_from_yaml, ) -from suite.yaml_utils import get_first_host_from_yaml, get_paths_from_vsr_yaml, get_route_namespace_from_vs_yaml +from suite.utils.yaml_utils import get_first_host_from_yaml, get_paths_from_vsr_yaml, get_route_namespace_from_vs_yaml def execute_assertions(resp_1, resp_2, resp_3): diff --git a/tests/suite/test_v_s_route_api.py b/tests/suite/test_v_s_route_api.py index 72f2253a87..97703b6cc3 100644 --- a/tests/suite/test_v_s_route_api.py +++ b/tests/suite/test_v_s_route_api.py @@ -3,8 +3,8 @@ import pytest import requests from settings import NGINX_API_VERSION -from suite.nginx_api_utils import get_nginx_generation_value, wait_for_empty_array, wait_for_non_empty_array -from suite.resources_utils import scale_deployment +from suite.utils.nginx_api_utils import get_nginx_generation_value, wait_for_empty_array, wait_for_non_empty_array +from suite.utils.resources_utils import scale_deployment @pytest.mark.vsr diff --git a/tests/suite/test_v_s_route_canned_responses.py b/tests/suite/test_v_s_route_canned_responses.py index fda4ab5e05..379e5550b3 100644 --- a/tests/suite/test_v_s_route_canned_responses.py +++ b/tests/suite/test_v_s_route_canned_responses.py @@ -4,14 +4,14 @@ import requests from kubernetes.client.rest import ApiException from settings import TEST_DATA -from suite.custom_assertions import ( +from suite.utils.custom_assertions import ( assert_event_and_get_count, assert_event_count_increased, assert_event_starts_with_text_and_contains_errors, wait_and_assert_status_code, ) -from suite.resources_utils import get_events, get_first_pod_name, wait_before_test -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_v_s_route_from_yaml +from suite.utils.resources_utils import get_events, get_first_pod_name, wait_before_test +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_v_s_route_from_yaml @pytest.mark.vsr diff --git a/tests/suite/test_v_s_route_error_pages.py b/tests/suite/test_v_s_route_error_pages.py index 4c9bfa5cad..cf5d28d132 100644 --- a/tests/suite/test_v_s_route_error_pages.py +++ b/tests/suite/test_v_s_route_error_pages.py @@ -4,9 +4,9 @@ import requests from kubernetes.client.rest import ApiException from settings import TEST_DATA -from suite.custom_assertions import assert_event_starts_with_text_and_contains_errors, wait_and_assert_status_code -from suite.resources_utils import get_events, get_first_pod_name, wait_before_test -from suite.vs_vsr_resources_utils import ( +from suite.utils.custom_assertions import assert_event_starts_with_text_and_contains_errors, wait_and_assert_status_code +from suite.utils.resources_utils import get_events, get_first_pod_name, wait_before_test +from suite.utils.vs_vsr_resources_utils import ( get_vs_nginx_template_conf, patch_v_s_route_from_yaml, patch_virtual_server_from_yaml, diff --git a/tests/suite/test_v_s_route_externalname.py b/tests/suite/test_v_s_route_externalname.py index 873b4f2172..bcb3af1362 100644 --- a/tests/suite/test_v_s_route_externalname.py +++ b/tests/suite/test_v_s_route_externalname.py @@ -1,14 +1,14 @@ import pytest from settings import TEST_DATA -from suite.custom_assertions import ( +from suite.fixtures.custom_resource_fixtures import VirtualServerRoute +from suite.fixtures.fixtures import PublicEndpoint +from suite.utils.custom_assertions import ( assert_event_and_count, assert_event_and_get_count, wait_and_assert_status_code, wait_for_event_count_increases, ) -from suite.custom_resource_fixtures import VirtualServerRoute -from suite.fixtures import PublicEndpoint -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_deployment_with_name, create_namespace_with_name_from_yaml, create_service_from_yaml, @@ -23,12 +23,12 @@ replace_service, wait_before_test, ) -from suite.vs_vsr_resources_utils import ( +from suite.utils.vs_vsr_resources_utils import ( create_v_s_route_from_yaml, create_virtual_server_from_yaml, get_vs_nginx_template_conf, ) -from suite.yaml_utils import get_first_host_from_yaml, get_paths_from_vsr_yaml, get_route_namespace_from_vs_yaml +from suite.utils.yaml_utils import get_first_host_from_yaml, get_paths_from_vsr_yaml, get_route_namespace_from_vs_yaml class ReducedVirtualServerRouteSetup: diff --git a/tests/suite/test_v_s_route_focused_canary.py b/tests/suite/test_v_s_route_focused_canary.py index 6a640ff4d5..3ed3936ae5 100644 --- a/tests/suite/test_v_s_route_focused_canary.py +++ b/tests/suite/test_v_s_route_focused_canary.py @@ -2,16 +2,16 @@ import requests import yaml from settings import TEST_DATA -from suite.custom_resource_fixtures import VirtualServerRoute -from suite.resources_utils import ( +from suite.fixtures.custom_resource_fixtures import VirtualServerRoute +from suite.utils.resources_utils import ( create_example_app, create_namespace_with_name_from_yaml, delete_namespace, ensure_response_from_backend, wait_until_all_pods_are_ready, ) -from suite.vs_vsr_resources_utils import create_v_s_route_from_yaml, create_virtual_server_from_yaml -from suite.yaml_utils import get_first_host_from_yaml, get_paths_from_vsr_yaml, get_route_namespace_from_vs_yaml +from suite.utils.vs_vsr_resources_utils import create_v_s_route_from_yaml, create_virtual_server_from_yaml +from suite.utils.yaml_utils import get_first_host_from_yaml, get_paths_from_vsr_yaml, get_route_namespace_from_vs_yaml from yaml.loader import Loader diff --git a/tests/suite/test_v_s_route_grpc.py b/tests/suite/test_v_s_route_grpc.py index 55116d5d36..f6ea23a10c 100644 --- a/tests/suite/test_v_s_route_grpc.py +++ b/tests/suite/test_v_s_route_grpc.py @@ -1,29 +1,22 @@ -import grpc import pytest -from kubernetes.client.rest import ApiException from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_assertions import ( +from suite.utils.custom_assertions import ( assert_event_starts_with_text_and_contains_errors, assert_grpc_entries_exist, assert_proxy_entries_do_not_exist, assert_proxy_entries_exist, ) -from suite.custom_resources_utils import read_custom_resource -from suite.grpc.helloworld_pb2 import HelloRequest -from suite.grpc.helloworld_pb2_grpc import GreeterStub -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_example_app, create_secret_from_yaml, delete_common_app, - delete_items_from_yaml, get_events, get_first_pod_name, replace_configmap_from_yaml, wait_before_test, wait_until_all_pods_are_ready, ) -from suite.ssl_utils import get_certificate -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_v_s_route_from_yaml +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_v_s_route_from_yaml @pytest.fixture(scope="function") diff --git a/tests/suite/test_v_s_route_redirects.py b/tests/suite/test_v_s_route_redirects.py index 3c9d1f6758..40edb0bf31 100644 --- a/tests/suite/test_v_s_route_redirects.py +++ b/tests/suite/test_v_s_route_redirects.py @@ -2,14 +2,14 @@ import requests from kubernetes.client.rest import ApiException from settings import TEST_DATA -from suite.custom_assertions import ( +from suite.utils.custom_assertions import ( assert_event_and_get_count, assert_event_count_increased, assert_event_starts_with_text_and_contains_errors, wait_and_assert_status_code, ) -from suite.resources_utils import get_events, get_first_pod_name, wait_before_test -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_v_s_route_from_yaml +from suite.utils.resources_utils import get_events, get_first_pod_name, wait_before_test +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_v_s_route_from_yaml @pytest.mark.vsr diff --git a/tests/suite/test_v_s_route_regexp_location.py b/tests/suite/test_v_s_route_regexp_location.py index 6586d03e8c..f867fb12c1 100644 --- a/tests/suite/test_v_s_route_regexp_location.py +++ b/tests/suite/test_v_s_route_regexp_location.py @@ -1,8 +1,8 @@ import pytest import requests from settings import TEST_DATA -from suite.custom_assertions import assert_event, assert_vs_conf_not_exists -from suite.resources_utils import ( +from suite.utils.custom_assertions import assert_event, assert_vs_conf_not_exists +from suite.utils.resources_utils import ( create_example_app, ensure_response_from_backend, get_events, @@ -10,14 +10,14 @@ wait_before_test, wait_until_all_pods_are_ready, ) -from suite.vs_vsr_resources_utils import ( +from suite.utils.vs_vsr_resources_utils import ( create_v_s_route_from_yaml, create_virtual_server_from_yaml, get_vs_nginx_template_conf, patch_v_s_route_from_yaml, patch_virtual_server_from_yaml, ) -from suite.yaml_utils import get_first_host_from_yaml +from suite.utils.yaml_utils import get_first_host_from_yaml @pytest.mark.vsr diff --git a/tests/suite/test_v_s_route_split_traffic.py b/tests/suite/test_v_s_route_split_traffic.py index f0f39c1315..963c73c20d 100644 --- a/tests/suite/test_v_s_route_split_traffic.py +++ b/tests/suite/test_v_s_route_split_traffic.py @@ -2,8 +2,8 @@ import requests import yaml from settings import TEST_DATA -from suite.resources_utils import ensure_response_from_backend -from suite.yaml_utils import get_paths_from_vsr_yaml +from suite.utils.resources_utils import ensure_response_from_backend +from suite.utils.yaml_utils import get_paths_from_vsr_yaml from yaml.loader import Loader diff --git a/tests/suite/test_v_s_route_status.py b/tests/suite/test_v_s_route_status.py index 42deac3791..e762899368 100644 --- a/tests/suite/test_v_s_route_status.py +++ b/tests/suite/test_v_s_route_status.py @@ -1,9 +1,8 @@ import pytest -from kubernetes.client.rest import ApiException from settings import TEST_DATA -from suite.custom_resources_utils import read_custom_resource -from suite.resources_utils import wait_before_test -from suite.vs_vsr_resources_utils import ( +from suite.utils.custom_resources_utils import read_custom_resource +from suite.utils.resources_utils import wait_before_test +from suite.utils.vs_vsr_resources_utils import ( create_virtual_server_from_yaml, delete_virtual_server, patch_v_s_route_from_yaml, diff --git a/tests/suite/test_v_s_route_upstream_options.py b/tests/suite/test_v_s_route_upstream_options.py index 4882809f64..88bf20b200 100644 --- a/tests/suite/test_v_s_route_upstream_options.py +++ b/tests/suite/test_v_s_route_upstream_options.py @@ -2,7 +2,7 @@ import requests from kubernetes.client.rest import ApiException from settings import TEST_DATA -from suite.custom_assertions import ( +from suite.utils.custom_assertions import ( assert_event, assert_event_and_get_count, assert_event_count_increased, @@ -10,9 +10,9 @@ assert_response_codes, wait_for_event_count_increases, ) -from suite.custom_resources_utils import generate_item_with_upstream_options -from suite.resources_utils import get_events, get_first_pod_name, replace_configmap_from_yaml, wait_before_test -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_v_s_route, patch_v_s_route_from_yaml +from suite.utils.custom_resources_utils import generate_item_with_upstream_options +from suite.utils.resources_utils import get_events, get_first_pod_name, replace_configmap_from_yaml, wait_before_test +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_v_s_route, patch_v_s_route_from_yaml @pytest.mark.parametrize( diff --git a/tests/suite/test_v_s_route_upstream_tls.py b/tests/suite/test_v_s_route_upstream_tls.py index 25b716a8a9..90c4ca6e0b 100644 --- a/tests/suite/test_v_s_route_upstream_tls.py +++ b/tests/suite/test_v_s_route_upstream_tls.py @@ -2,14 +2,14 @@ import requests from kubernetes.client.rest import ApiException from settings import TEST_DATA -from suite.custom_assertions import ( +from suite.utils.custom_assertions import ( assert_event, assert_event_and_get_count, assert_event_count_increased, assert_no_new_events, assert_response_codes, ) -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_items_from_yaml, delete_items_from_yaml, ensure_response_from_backend, @@ -18,7 +18,7 @@ wait_before_test, wait_until_all_pods_are_ready, ) -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_v_s_route_from_yaml +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_v_s_route_from_yaml @pytest.fixture(scope="class") diff --git a/tests/suite/test_virtual_server.py b/tests/suite/test_virtual_server.py index 91642eb16a..b13c46838a 100644 --- a/tests/suite/test_virtual_server.py +++ b/tests/suite/test_virtual_server.py @@ -1,9 +1,8 @@ import pytest -import requests from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_assertions import wait_and_assert_status_code -from suite.custom_resources_utils import create_crd_from_yaml, delete_crd -from suite.resources_utils import ( +from suite.utils.custom_assertions import wait_and_assert_status_code +from suite.utils.custom_resources_utils import create_crd_from_yaml, delete_crd +from suite.utils.resources_utils import ( create_service_from_yaml, delete_service, patch_rbac, @@ -11,12 +10,12 @@ replace_service, wait_before_test, ) -from suite.vs_vsr_resources_utils import ( +from suite.utils.vs_vsr_resources_utils import ( create_virtual_server_from_yaml, delete_virtual_server, patch_virtual_server_from_yaml, ) -from suite.yaml_utils import get_first_host_from_yaml, get_name_from_yaml, get_paths_from_vs_yaml +from suite.utils.yaml_utils import get_first_host_from_yaml, get_name_from_yaml, get_paths_from_vs_yaml @pytest.mark.vs diff --git a/tests/suite/test_virtual_server_advanced_routing.py b/tests/suite/test_virtual_server_advanced_routing.py index dfcbb632a0..91dc6a939c 100644 --- a/tests/suite/test_virtual_server_advanced_routing.py +++ b/tests/suite/test_virtual_server_advanced_routing.py @@ -1,8 +1,8 @@ import pytest import requests from settings import TEST_DATA -from suite.resources_utils import ensure_response_from_backend, wait_before_test -from suite.vs_vsr_resources_utils import patch_virtual_server_from_yaml +from suite.utils.resources_utils import ensure_response_from_backend, wait_before_test +from suite.utils.vs_vsr_resources_utils import patch_virtual_server_from_yaml def execute_assertions(resp_1, resp_2, resp_3): diff --git a/tests/suite/test_virtual_server_api.py b/tests/suite/test_virtual_server_api.py index ee040301aa..de097e258f 100644 --- a/tests/suite/test_virtual_server_api.py +++ b/tests/suite/test_virtual_server_api.py @@ -3,8 +3,8 @@ import pytest import requests from settings import NGINX_API_VERSION -from suite.nginx_api_utils import get_nginx_generation_value, wait_for_empty_array, wait_for_non_empty_array -from suite.resources_utils import scale_deployment +from suite.utils.nginx_api_utils import get_nginx_generation_value, wait_for_empty_array, wait_for_non_empty_array +from suite.utils.resources_utils import scale_deployment @pytest.mark.vs diff --git a/tests/suite/test_virtual_server_canned_responses.py b/tests/suite/test_virtual_server_canned_responses.py index f4edf8d090..11d48bc339 100644 --- a/tests/suite/test_virtual_server_canned_responses.py +++ b/tests/suite/test_virtual_server_canned_responses.py @@ -4,14 +4,14 @@ import requests from kubernetes.client.rest import ApiException from settings import TEST_DATA -from suite.custom_assertions import ( +from suite.utils.custom_assertions import ( assert_event_and_get_count, assert_event_count_increased, assert_event_starts_with_text_and_contains_errors, wait_and_assert_status_code, ) -from suite.resources_utils import get_events, get_first_pod_name, wait_before_test -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_virtual_server_from_yaml +from suite.utils.resources_utils import get_events, get_first_pod_name, wait_before_test +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_virtual_server_from_yaml @pytest.mark.vs diff --git a/tests/suite/test_virtual_server_certmanager.py b/tests/suite/test_virtual_server_certmanager.py index 4e2b250f55..87a4447be0 100644 --- a/tests/suite/test_virtual_server_certmanager.py +++ b/tests/suite/test_virtual_server_certmanager.py @@ -1,10 +1,9 @@ import pytest -import requests from settings import TEST_DATA -from suite.custom_assertions import wait_and_assert_status_code -from suite.resources_utils import create_secret_from_yaml, is_secret_present, wait_before_test -from suite.vs_vsr_resources_utils import patch_virtual_server_from_yaml -from suite.yaml_utils import get_secret_name_from_vs_yaml +from suite.utils.custom_assertions import wait_and_assert_status_code +from suite.utils.resources_utils import create_secret_from_yaml, is_secret_present, wait_before_test +from suite.utils.vs_vsr_resources_utils import patch_virtual_server_from_yaml +from suite.utils.yaml_utils import get_secret_name_from_vs_yaml @pytest.mark.vs diff --git a/tests/suite/test_virtual_server_configmap_keys.py b/tests/suite/test_virtual_server_configmap_keys.py index c42eee0dce..4a77ba524f 100644 --- a/tests/suite/test_virtual_server_configmap_keys.py +++ b/tests/suite/test_virtual_server_configmap_keys.py @@ -1,6 +1,6 @@ import pytest from settings import DEPLOYMENTS, TEST_DATA -from suite.resources_utils import ( +from suite.utils.resources_utils import ( get_events, get_file_contents, get_first_pod_name, @@ -8,8 +8,8 @@ replace_configmap_from_yaml, wait_before_test, ) -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf -from suite.yaml_utils import get_configmap_fields_from_yaml +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf +from suite.utils.yaml_utils import get_configmap_fields_from_yaml def assert_update_events_emitted(virtual_server_setup, new_list, previous_list, expected_amount): diff --git a/tests/suite/test_virtual_server_dos.py b/tests/suite/test_virtual_server_dos.py index 9abfc78482..eeaba0fdd6 100644 --- a/tests/suite/test_virtual_server_dos.py +++ b/tests/suite/test_virtual_server_dos.py @@ -5,8 +5,8 @@ import pytest import requests from settings import TEST_DATA -from suite.custom_assertions import wait_and_assert_status_code -from suite.custom_resources_utils import ( +from suite.utils.custom_assertions import wait_and_assert_status_code +from suite.utils.custom_resources_utils import ( create_dos_logconf_from_yaml, create_dos_policy_from_yaml, create_dos_protected_from_yaml, @@ -14,14 +14,13 @@ delete_dos_policy, delete_dos_protected, ) -from suite.dos_utils import ( +from suite.utils.dos_utils import ( check_learning_status_with_admd_s, clean_good_bad_clients, find_in_log, log_content_to_dic, - print_admd_log, ) -from suite.resources_utils import ( +from suite.utils.resources_utils import ( clear_file_contents, create_example_app, delete_common_app, @@ -32,12 +31,12 @@ wait_before_test, wait_until_all_pods_are_ready, ) -from suite.vs_vsr_resources_utils import ( +from suite.utils.vs_vsr_resources_utils import ( create_virtual_server_from_yaml, delete_virtual_server, get_vs_nginx_template_conf, ) -from suite.yaml_utils import get_first_host_from_yaml, get_paths_from_vs_yaml +from suite.utils.yaml_utils import get_first_host_from_yaml, get_paths_from_vs_yaml valid_resp_addr = "Server address:" valid_resp_name = "Server name:" diff --git a/tests/suite/test_virtual_server_error_pages.py b/tests/suite/test_virtual_server_error_pages.py index 508a76f3b1..ddf9ad9c73 100644 --- a/tests/suite/test_virtual_server_error_pages.py +++ b/tests/suite/test_virtual_server_error_pages.py @@ -4,13 +4,13 @@ import requests from kubernetes.client.rest import ApiException from settings import TEST_DATA -from suite.custom_assertions import ( +from suite.utils.custom_assertions import ( assert_event_starts_with_text_and_contains_errors, assert_vs_conf_not_exists, wait_and_assert_status_code, ) -from suite.resources_utils import get_events, get_first_pod_name, wait_before_test -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_virtual_server_from_yaml +from suite.utils.resources_utils import get_events, get_first_pod_name, wait_before_test +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_virtual_server_from_yaml @pytest.mark.vs diff --git a/tests/suite/test_virtual_server_external_name.py b/tests/suite/test_virtual_server_external_name.py index db47055085..02d3ba3e00 100644 --- a/tests/suite/test_virtual_server_external_name.py +++ b/tests/suite/test_virtual_server_external_name.py @@ -1,13 +1,13 @@ import pytest from settings import TEST_DATA -from suite.custom_assertions import ( +from suite.utils.custom_assertions import ( assert_event_and_count, assert_event_and_get_count, assert_event_with_full_equality_and_count, wait_and_assert_status_code, wait_for_event_count_increases, ) -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_deployment_with_name, create_namespace_with_name_from_yaml, create_service_from_yaml, @@ -23,7 +23,7 @@ replace_service, wait_before_test, ) -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf class ExternalNameSetup: diff --git a/tests/suite/test_virtual_server_externaldns.py b/tests/suite/test_virtual_server_externaldns.py index ef089eeece..7830b84631 100644 --- a/tests/suite/test_virtual_server_externaldns.py +++ b/tests/suite/test_virtual_server_externaldns.py @@ -1,10 +1,10 @@ import pytest from settings import TEST_DATA -from suite.custom_assertions import assert_event -from suite.custom_resources_utils import is_dnsendpoint_present -from suite.resources_utils import get_events, wait_before_test -from suite.vs_vsr_resources_utils import patch_virtual_server_from_yaml -from suite.yaml_utils import get_name_from_yaml, get_namespace_from_yaml +from suite.utils.custom_assertions import assert_event +from suite.utils.custom_resources_utils import is_dnsendpoint_present +from suite.utils.resources_utils import get_events, wait_before_test +from suite.utils.vs_vsr_resources_utils import patch_virtual_server_from_yaml +from suite.utils.yaml_utils import get_name_from_yaml, get_namespace_from_yaml VS_YAML = f"{TEST_DATA}/virtual-server-external-dns/standard/virtual-server.yaml" diff --git a/tests/suite/test_virtual_server_focused_canary.py b/tests/suite/test_virtual_server_focused_canary.py index 4a26917c3e..261e8424c5 100644 --- a/tests/suite/test_virtual_server_focused_canary.py +++ b/tests/suite/test_virtual_server_focused_canary.py @@ -2,7 +2,7 @@ import requests import yaml from settings import TEST_DATA -from suite.resources_utils import ensure_response_from_backend +from suite.utils.resources_utils import ensure_response_from_backend def get_weights_of_splitting(file) -> []: diff --git a/tests/suite/test_virtual_server_grpc.py b/tests/suite/test_virtual_server_grpc.py index 289c2ffb16..19ea9db859 100644 --- a/tests/suite/test_virtual_server_grpc.py +++ b/tests/suite/test_virtual_server_grpc.py @@ -1,30 +1,29 @@ import grpc import pytest from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_assertions import ( +from suite.grpc.helloworld_pb2 import HelloRequest +from suite.grpc.helloworld_pb2_grpc import GreeterStub +from suite.utils.custom_assertions import ( assert_event, assert_event_starts_with_text_and_contains_errors, assert_grpc_entries_exist, assert_proxy_entries_do_not_exist, assert_vs_conf_not_exists, ) -from suite.grpc.helloworld_pb2 import HelloRequest -from suite.grpc.helloworld_pb2_grpc import GreeterStub -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_example_app, create_secret_from_yaml, delete_common_app, delete_items_from_yaml, get_events, get_first_pod_name, - get_last_log_entry, replace_configmap_from_yaml, scale_deployment, wait_before_test, wait_until_all_pods_are_ready, ) -from suite.ssl_utils import get_certificate -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_virtual_server_from_yaml +from suite.utils.ssl_utils import get_certificate +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_virtual_server_from_yaml @pytest.fixture(scope="function") diff --git a/tests/suite/test_virtual_server_mixed_grpc.py b/tests/suite/test_virtual_server_mixed_grpc.py index 316da6e2b9..9b4802b417 100644 --- a/tests/suite/test_virtual_server_mixed_grpc.py +++ b/tests/suite/test_virtual_server_mixed_grpc.py @@ -1,11 +1,14 @@ import grpc import pytest -import requests from settings import DEPLOYMENTS, TEST_DATA -from suite.custom_assertions import assert_grpc_entries_exist, assert_proxy_entries_exist, wait_and_assert_status_code from suite.grpc.helloworld_pb2 import HelloRequest from suite.grpc.helloworld_pb2_grpc import GreeterStub -from suite.resources_utils import ( +from suite.utils.custom_assertions import ( + assert_grpc_entries_exist, + assert_proxy_entries_exist, + wait_and_assert_status_code, +) +from suite.utils.resources_utils import ( create_example_app, create_secret_from_yaml, delete_common_app, @@ -14,8 +17,8 @@ replace_configmap_from_yaml, wait_until_all_pods_are_ready, ) -from suite.ssl_utils import get_certificate -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf +from suite.utils.ssl_utils import get_certificate +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf @pytest.fixture(scope="function") diff --git a/tests/suite/test_virtual_server_redirects.py b/tests/suite/test_virtual_server_redirects.py index 6ec225f50f..56759cb4fd 100644 --- a/tests/suite/test_virtual_server_redirects.py +++ b/tests/suite/test_virtual_server_redirects.py @@ -2,14 +2,14 @@ import requests from kubernetes.client.rest import ApiException from settings import TEST_DATA -from suite.custom_assertions import ( +from suite.utils.custom_assertions import ( assert_event_and_get_count, assert_event_count_increased, assert_event_starts_with_text_and_contains_errors, wait_and_assert_status_code, ) -from suite.resources_utils import get_events, get_first_pod_name, wait_before_test -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_virtual_server_from_yaml +from suite.utils.resources_utils import get_events, get_first_pod_name, wait_before_test +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_virtual_server_from_yaml @pytest.mark.vs diff --git a/tests/suite/test_virtual_server_split_traffic.py b/tests/suite/test_virtual_server_split_traffic.py index d93c78b3a6..84befef017 100644 --- a/tests/suite/test_virtual_server_split_traffic.py +++ b/tests/suite/test_virtual_server_split_traffic.py @@ -2,7 +2,7 @@ import requests import yaml from settings import TEST_DATA -from suite.resources_utils import ensure_response_from_backend +from suite.utils.resources_utils import ensure_response_from_backend def get_weights_of_splitting(file) -> []: diff --git a/tests/suite/test_virtual_server_status.py b/tests/suite/test_virtual_server_status.py index bd62069cbf..734e093b75 100644 --- a/tests/suite/test_virtual_server_status.py +++ b/tests/suite/test_virtual_server_status.py @@ -1,9 +1,8 @@ import pytest -from kubernetes.client.rest import ApiException from settings import TEST_DATA -from suite.custom_resources_utils import read_custom_resource -from suite.resources_utils import wait_before_test -from suite.vs_vsr_resources_utils import patch_virtual_server_from_yaml +from suite.utils.custom_resources_utils import read_custom_resource +from suite.utils.resources_utils import wait_before_test +from suite.utils.vs_vsr_resources_utils import patch_virtual_server_from_yaml @pytest.mark.vs diff --git a/tests/suite/test_virtual_server_tls.py b/tests/suite/test_virtual_server_tls.py index 89b5e7d139..5404ec23d8 100644 --- a/tests/suite/test_virtual_server_tls.py +++ b/tests/suite/test_virtual_server_tls.py @@ -1,15 +1,15 @@ import pytest from _ssl import SSLError from settings import TEST_DATA -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_secret_from_yaml, delete_secret, is_secret_present, replace_secret, wait_before_test, ) -from suite.ssl_utils import get_server_certificate_subject -from suite.yaml_utils import get_name_from_yaml +from suite.utils.ssl_utils import get_server_certificate_subject +from suite.utils.yaml_utils import get_name_from_yaml @pytest.fixture(scope="class") diff --git a/tests/suite/test_virtual_server_tls_redirect.py b/tests/suite/test_virtual_server_tls_redirect.py index 4d1ec60d6a..4310daf488 100644 --- a/tests/suite/test_virtual_server_tls_redirect.py +++ b/tests/suite/test_virtual_server_tls_redirect.py @@ -2,8 +2,8 @@ import requests from kubernetes.client.rest import ApiException from settings import TEST_DATA -from suite.resources_utils import get_first_pod_name, wait_before_test -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_virtual_server_from_yaml +from suite.utils.resources_utils import get_first_pod_name, wait_before_test +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_virtual_server_from_yaml @pytest.mark.vs diff --git a/tests/suite/test_virtual_server_upstream_options.py b/tests/suite/test_virtual_server_upstream_options.py index 69d211adbc..242f2ed079 100644 --- a/tests/suite/test_virtual_server_upstream_options.py +++ b/tests/suite/test_virtual_server_upstream_options.py @@ -2,7 +2,7 @@ import requests from kubernetes.client.rest import ApiException from settings import TEST_DATA -from suite.custom_assertions import ( +from suite.utils.custom_assertions import ( assert_event, assert_event_and_get_count, assert_event_count_increased, @@ -10,9 +10,9 @@ assert_response_codes, assert_vs_conf_not_exists, ) -from suite.custom_resources_utils import generate_item_with_upstream_options -from suite.resources_utils import get_events, get_first_pod_name, replace_configmap_from_yaml, wait_before_test -from suite.vs_vsr_resources_utils import ( +from suite.utils.custom_resources_utils import generate_item_with_upstream_options +from suite.utils.resources_utils import get_events, get_first_pod_name, replace_configmap_from_yaml, wait_before_test +from suite.utils.vs_vsr_resources_utils import ( get_vs_nginx_template_conf, patch_virtual_server, patch_virtual_server_from_yaml, diff --git a/tests/suite/test_virtual_server_upstream_tls.py b/tests/suite/test_virtual_server_upstream_tls.py index 843e0c7176..6edf4b4af8 100644 --- a/tests/suite/test_virtual_server_upstream_tls.py +++ b/tests/suite/test_virtual_server_upstream_tls.py @@ -2,15 +2,15 @@ import requests from kubernetes.client.rest import ApiException from settings import TEST_DATA -from suite.custom_assertions import ( +from suite.utils.custom_assertions import ( assert_event, assert_event_and_get_count, assert_event_count_increased, assert_no_new_events, assert_response_codes, ) -from suite.resources_utils import ensure_response_from_backend, get_events, get_first_pod_name, wait_before_test -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_virtual_server_from_yaml +from suite.utils.resources_utils import ensure_response_from_backend, get_events, get_first_pod_name, wait_before_test +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf, patch_virtual_server_from_yaml @pytest.mark.flaky(max_runs=3) diff --git a/tests/suite/test_virtual_server_validation.py b/tests/suite/test_virtual_server_validation.py index 0c9d313859..deb38adbf4 100644 --- a/tests/suite/test_virtual_server_validation.py +++ b/tests/suite/test_virtual_server_validation.py @@ -1,9 +1,8 @@ import pytest -import requests from settings import TEST_DATA -from suite.custom_assertions import assert_vs_conf_exists, assert_vs_conf_not_exists, wait_and_assert_status_code -from suite.resources_utils import get_events, get_first_pod_name, get_pods_amount, wait_before_test -from suite.vs_vsr_resources_utils import ( +from suite.utils.custom_assertions import assert_vs_conf_exists, assert_vs_conf_not_exists, wait_and_assert_status_code +from suite.utils.resources_utils import get_events, get_first_pod_name, get_pods_amount, wait_before_test +from suite.utils.vs_vsr_resources_utils import ( create_virtual_server_from_yaml, delete_virtual_server, patch_virtual_server_from_yaml, diff --git a/tests/suite/test_virtual_server_wildcard.py b/tests/suite/test_virtual_server_wildcard.py index 44c72f7407..98c763f3f6 100644 --- a/tests/suite/test_virtual_server_wildcard.py +++ b/tests/suite/test_virtual_server_wildcard.py @@ -2,10 +2,10 @@ import pytest from settings import TEST_DATA -from suite.custom_assertions import wait_and_assert_status_code -from suite.custom_resources_utils import read_custom_resource -from suite.resources_utils import wait_before_test -from suite.vs_vsr_resources_utils import create_virtual_server_from_yaml, delete_virtual_server +from suite.utils.custom_assertions import wait_and_assert_status_code +from suite.utils.custom_resources_utils import read_custom_resource +from suite.utils.resources_utils import wait_before_test +from suite.utils.vs_vsr_resources_utils import create_virtual_server_from_yaml, delete_virtual_server @pytest.mark.vs diff --git a/tests/suite/test_watch_namespace.py b/tests/suite/test_watch_namespace.py index edc27b978a..b74cf64bde 100644 --- a/tests/suite/test_watch_namespace.py +++ b/tests/suite/test_watch_namespace.py @@ -1,7 +1,7 @@ import pytest import requests from settings import TEST_DATA -from suite.resources_utils import ( +from suite.utils.resources_utils import ( create_example_app, create_items_from_yaml, create_namespace_with_name_from_yaml, @@ -10,7 +10,7 @@ ensure_response_from_backend, 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 class BackendSetup: diff --git a/tests/suite/test_wildcard_tls_secret.py b/tests/suite/test_wildcard_tls_secret.py index 83683e7a91..bf13820612 100644 --- a/tests/suite/test_wildcard_tls_secret.py +++ b/tests/suite/test_wildcard_tls_secret.py @@ -1,9 +1,8 @@ import pytest -import requests from settings import TEST_DATA -from suite.custom_assertions import wait_and_assert_status_code -from suite.fixtures import PublicEndpoint -from suite.resources_utils import ( +from suite.fixtures.fixtures import PublicEndpoint +from suite.utils.custom_assertions import wait_and_assert_status_code +from suite.utils.resources_utils import ( create_example_app, create_ingress_controller, create_items_from_yaml, @@ -17,8 +16,8 @@ wait_before_test, wait_until_all_pods_are_ready, ) -from suite.ssl_utils import get_server_certificate_subject -from suite.yaml_utils import get_first_ingress_host_from_yaml +from suite.utils.ssl_utils import get_server_certificate_subject +from suite.utils.yaml_utils import get_first_ingress_host_from_yaml paths = ["backend1", "backend2"] diff --git a/tests/suite/ap_resources_utils.py b/tests/suite/utils/ap_resources_utils.py similarity index 97% rename from tests/suite/ap_resources_utils.py rename to tests/suite/utils/ap_resources_utils.py index 1f2ee92d33..dde43e6c4b 100644 --- a/tests/suite/ap_resources_utils.py +++ b/tests/suite/utils/ap_resources_utils.py @@ -3,12 +3,10 @@ import logging import time -import pytest import yaml -from kubernetes import client -from kubernetes.client import ApiextensionsV1Api, CoreV1Api, CustomObjectsApi +from kubernetes.client import CustomObjectsApi from kubernetes.client.rest import ApiException -from suite.resources_utils import ensure_item_removal, get_file_contents +from suite.utils.resources_utils import ensure_item_removal def read_ap_custom_resource(custom_objects: CustomObjectsApi, namespace, plural, name) -> object: diff --git a/tests/suite/custom_assertions.py b/tests/suite/utils/custom_assertions.py similarity index 98% rename from tests/suite/custom_assertions.py rename to tests/suite/utils/custom_assertions.py index 5761969565..d8f97e6826 100644 --- a/tests/suite/custom_assertions.py +++ b/tests/suite/utils/custom_assertions.py @@ -3,8 +3,8 @@ import pytest import requests -from suite.resources_utils import get_events -from suite.vs_vsr_resources_utils import get_vs_nginx_template_conf +from suite.utils.resources_utils import get_events +from suite.utils.vs_vsr_resources_utils import get_vs_nginx_template_conf def assert_no_new_events(old_list, new_list): diff --git a/tests/suite/custom_resources_utils.py b/tests/suite/utils/custom_resources_utils.py similarity index 98% rename from tests/suite/custom_resources_utils.py rename to tests/suite/utils/custom_resources_utils.py index c8521ed84d..9fcff4bf78 100644 --- a/tests/suite/custom_resources_utils.py +++ b/tests/suite/utils/custom_resources_utils.py @@ -5,9 +5,9 @@ import pytest import yaml -from kubernetes.client import ApiextensionsV1Api, CoreV1Api, CustomObjectsApi +from kubernetes.client import ApiextensionsV1Api, CustomObjectsApi from kubernetes.client.rest import ApiException -from suite.resources_utils import ensure_item_removal, get_file_contents +from suite.utils.resources_utils import ensure_item_removal def create_crd(api_extensions_v1: ApiextensionsV1Api, body) -> None: diff --git a/tests/suite/dos_utils.py b/tests/suite/utils/dos_utils.py similarity index 97% rename from tests/suite/dos_utils.py rename to tests/suite/utils/dos_utils.py index 83e74b90b0..116ce35f2c 100644 --- a/tests/suite/dos_utils.py +++ b/tests/suite/utils/dos_utils.py @@ -3,7 +3,7 @@ from kubernetes.client import CoreV1Api from kubernetes.stream import stream -from suite.resources_utils import get_file_contents, wait_before_test +from suite.utils.resources_utils import get_file_contents, wait_before_test def log_content_to_dic(log_contents): diff --git a/tests/suite/kube_config_utils.py b/tests/suite/utils/kube_config_utils.py similarity index 100% rename from tests/suite/kube_config_utils.py rename to tests/suite/utils/kube_config_utils.py diff --git a/tests/suite/nginx_api_utils.py b/tests/suite/utils/nginx_api_utils.py similarity index 96% rename from tests/suite/nginx_api_utils.py rename to tests/suite/utils/nginx_api_utils.py index eafcf9ed08..febbd03de6 100644 --- a/tests/suite/nginx_api_utils.py +++ b/tests/suite/utils/nginx_api_utils.py @@ -4,7 +4,7 @@ import pytest import requests from settings import NGINX_API_VERSION -from suite.resources_utils import wait_before_test +from suite.utils.resources_utils import wait_before_test def get_nginx_generation_value(host) -> int: diff --git a/tests/suite/policy_resources_utils.py b/tests/suite/utils/policy_resources_utils.py similarity index 89% rename from tests/suite/policy_resources_utils.py rename to tests/suite/utils/policy_resources_utils.py index c4b69665fe..44531185d1 100644 --- a/tests/suite/policy_resources_utils.py +++ b/tests/suite/utils/policy_resources_utils.py @@ -3,10 +3,10 @@ import logging import yaml -from kubernetes.client import ApiextensionsV1Api, CoreV1Api, CustomObjectsApi +from kubernetes.client import CustomObjectsApi from kubernetes.client.rest import ApiException -from suite.custom_resources_utils import read_custom_resource -from suite.resources_utils import ensure_item_removal +from suite.utils.custom_resources_utils import read_custom_resource +from suite.utils.resources_utils import ensure_item_removal def read_policy(custom_objects: CustomObjectsApi, namespace, name) -> object: diff --git a/tests/suite/resources_utils.py b/tests/suite/utils/resources_utils.py similarity index 100% rename from tests/suite/resources_utils.py rename to tests/suite/utils/resources_utils.py diff --git a/tests/suite/ssl_utils.py b/tests/suite/utils/ssl_utils.py similarity index 95% rename from tests/suite/ssl_utils.py rename to tests/suite/utils/ssl_utils.py index 7f1475c607..e99fc640c2 100644 --- a/tests/suite/ssl_utils.py +++ b/tests/suite/utils/ssl_utils.py @@ -19,6 +19,7 @@ def get_certificate(ip_address, host, port, timeout=10) -> str: :return: str """ context = ssl.create_default_context() + context.minimum_version = ssl.TLSVersion.TLSv1_2 context.check_hostname = False context.verify_mode = ssl.CERT_NONE ip_address = ip_address.strip("[]") @@ -60,7 +61,7 @@ def send(self, request, **kwargs): # overrides the SNI to the value of the host header # See urllib3.connection.HTTPSConnection.connect self.poolmanager.connection_pool_kw["server_hostname"] = request.headers["host"] - return super(SNIAdapter, self).send(request, **kwargs) + return super().send(request, **kwargs) def create_sni_session(): diff --git a/tests/suite/vs_vsr_resources_utils.py b/tests/suite/utils/vs_vsr_resources_utils.py similarity index 98% rename from tests/suite/vs_vsr_resources_utils.py rename to tests/suite/utils/vs_vsr_resources_utils.py index 8fe698ec0e..c1fe02ef8c 100644 --- a/tests/suite/vs_vsr_resources_utils.py +++ b/tests/suite/utils/vs_vsr_resources_utils.py @@ -5,8 +5,8 @@ import yaml from kubernetes.client import CoreV1Api, CustomObjectsApi from kubernetes.client.rest import ApiException -from suite.custom_resources_utils import read_custom_resource -from suite.resources_utils import ensure_item_removal, get_file_contents +from suite.utils.custom_resources_utils import read_custom_resource +from suite.utils.resources_utils import ensure_item_removal, get_file_contents def read_vs(custom_objects: CustomObjectsApi, namespace, name) -> object: diff --git a/tests/suite/yaml_utils.py b/tests/suite/utils/yaml_utils.py similarity index 100% rename from tests/suite/yaml_utils.py rename to tests/suite/utils/yaml_utils.py