diff --git a/Makefile b/Makefile index cc40acdc..c9554238 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ authorino: poetry-no-dev authorino-standalone: ## Run only test capable of running with standalone Authorino authorino-standalone: poetry-no-dev - $(PYTEST) -n4 -m 'authorino and not kuadrant_only' --dist loadfile --enforce $(flags) testsuite/tests/kuadrant/authorino + $(PYTEST) -n4 -m 'authorino and not kuadrant_only' --dist loadfile --enforce --standalone $(flags) testsuite/tests/kuadrant/authorino limitador: ## Run only Limitador related tests limitador: poetry-no-dev diff --git a/config/settings.local.yaml.tpl b/config/settings.local.yaml.tpl index 34254de2..c544ac73 100644 --- a/config/settings.local.yaml.tpl +++ b/config/settings.local.yaml.tpl @@ -1,7 +1,6 @@ #default: # skip_cleanup: false # tester: "someuser" # Optional: name of the user, who is running the tests, defaults to whoami/uid -# standalone: false # True, if Testsuite should test only individual components (e.g. Authorino/limitador operators) # cluster: # Workload cluster where tests should run, will get overriden if run on Multicluster # project: "kuadrant" # Optional: Default namespace for this cluster # api_url: "https://api.openshift.com" # Optional: OpenShift API URL, if None it will OpenShift that you are logged in diff --git a/config/settings.yaml b/config/settings.yaml index ffa98760..d53165e0 100644 --- a/config/settings.yaml +++ b/config/settings.yaml @@ -1,7 +1,6 @@ default: skip_cleanup: false dynaconf_merge: true - standalone: false cluster: {} tools: project: "tools" diff --git a/testsuite/capabilities.py b/testsuite/capabilities.py index 2802526c..499a304c 100644 --- a/testsuite/capabilities.py +++ b/testsuite/capabilities.py @@ -12,9 +12,6 @@ def has_kuadrant(): """Returns True, if Kuadrant deployment is present and should be used""" spokes = weakget(settings)["control_plane"]["spokes"] % {} - if settings.get("standalone", False): - return False, "Standalone mode is enabled" - for name, openshift in spokes.items(): # Try if Kuadrant is deployed if not openshift.connected: @@ -28,22 +25,11 @@ def has_kuadrant(): return True, None -@functools.cache -def is_standalone(): - """Return True, if the testsuite is configured to run with envoy in standalone mode, without Gateway API""" - if not settings.get("standalone", False): - return False, "Standalone mode is disabled" - return True, None - - @functools.cache def has_mgc(): """Returns True, if MGC is configured and deployed""" spokes = weakget(settings)["control_plane"]["spokes"] % {} - if settings.get("standalone", False): - return False, "Standalone mode is enabled" - if len(spokes) == 0: return False, "Spokes are not configured" diff --git a/testsuite/config/__init__.py b/testsuite/config/__init__.py index bf54f251..95841330 100644 --- a/testsuite/config/__init__.py +++ b/testsuite/config/__init__.py @@ -41,8 +41,6 @@ def __init__(self, name, default, **kwargs) -> None: DefaultValueValidator("rhsso.url", default=fetch_route("no-ssl-sso")), DefaultValueValidator("rhsso.password", default=fetch_secret("credential-sso", "ADMIN_PASSWORD")), DefaultValueValidator("mockserver.url", default=fetch_route("mockserver", force_http=True)), - Validator("standalone", must_exist=False, eq=True) - | Validator("service_protection.gateway.name", must_exist=True), ], validate_only=["authorino", "kuadrant"], loaders=["dynaconf.loaders.env_loader", "testsuite.config.openshift_loader"], diff --git a/testsuite/tests/conftest.py b/testsuite/tests/conftest.py index ceea65c9..83e06199 100644 --- a/testsuite/tests/conftest.py +++ b/testsuite/tests/conftest.py @@ -7,7 +7,7 @@ from dynaconf import ValidationError from keycloak import KeycloakAuthenticationError -from testsuite.capabilities import has_kuadrant, has_mgc, is_standalone +from testsuite.capabilities import has_kuadrant, has_mgc from testsuite.certificates import CFSSLClient from testsuite.config import settings from testsuite.mockserver import Mockserver @@ -29,7 +29,10 @@ def pytest_addoption(parser): parser.addoption( "--performance", action="store_true", default=False, help="Run also performance tests (default: False)" ) - parser.addoption("--enforce", action="store_true", default=False, help="Fails tests instead of skip") + parser.addoption( + "--enforce", action="store_true", default=False, help="Fails tests instead of skip, if capabilities are missing" + ) + parser.addoption("--standalone", action="store_true", default=False, help="Runs testsuite in standalone mode") def pytest_runtest_setup(item): @@ -43,18 +46,25 @@ def pytest_runtest_setup(item): if "performance" in marks and not item.config.getoption("--performance"): pytest.skip("Excluding performance tests") skip_or_fail = pytest.fail if item.config.getoption("--enforce") else pytest.skip - if "kuadrant_only" in marks: - kuadrant, error = has_kuadrant() - if not kuadrant: - skip_or_fail(f"Unable to locate Kuadrant installation: {error}") - if "standalone_only" in marks: - status, error = is_standalone() - if not status: - skip_or_fail(f"Unable to run Standalone tests: {error}") - if "mgc" in marks: - mgc, error = has_mgc() - if not mgc: - skip_or_fail(f"Unable to locate MGC installation: {error}") + standalone = item.config.getoption("--standalone") + if standalone: + if "mgc" in marks: + skip_or_fail("Unable to run MGC test: Standalone mode is enabled") + if "kuadrant_only" in marks: + skip_or_fail("Unable to run Kuadrant Only tests: Standalone mode is enabled") + else: + if "standalone_only" in marks: + skip_or_fail( + "Unable to run Standalone only test: Standalone mode is disabled, please use --standalone flag" + ) + if "kuadrant_only" in marks: + kuadrant, error = has_kuadrant() + if not kuadrant: + skip_or_fail(f"Unable to locate Kuadrant installation: {error}") + if "mgc" in marks: + mgc, error = has_mgc() + if not mgc: + skip_or_fail(f"Unable to locate MGC installation: {error}") @pytest.hookimpl(hookwrapper=True) @@ -241,9 +251,9 @@ def module_label(label): @pytest.fixture(scope="module") -def kuadrant(testconfig, openshift): +def kuadrant(request, testconfig, openshift): """Returns Kuadrant instance if exists, or None""" - if testconfig.get("standalone", False): + if request.config.getoption("--standalone"): return None # Try if Kuadrant is deployed