Skip to content

Commit

Permalink
introduce kcp into testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Čáp committed Sep 22, 2022
1 parent 62d8496 commit 2e1575f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
2 changes: 2 additions & 0 deletions config/settings.local.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# kubeconfig_path: "~/.kube/config" # Optional: Kubeconfig to use, if None the default one is used
# openshift2:
# project: "kuadrant2" # Required: Secondary OpenShift project, for running tests across projects
# kcp: # Required for glbc tests
# project: "glbc-test" # Optional: namespace for glbc tests to run, if None uses current namespace
# tools:
# project: "tools" # Optional: OpenShift project, where external tools are located
# rhsso:
Expand Down
12 changes: 7 additions & 5 deletions testsuite/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def __init__(self, name, default, **kwargs) -> None:
**kwargs)


_kcp = Validator("kcp", must_exist=True)

settings = Dynaconf(
environments=True,
lowercase_read=True,
Expand All @@ -28,11 +30,11 @@ def __init__(self, name, default, **kwargs) -> None:
envvar_prefix="KUADRANT",
merge_enabled=True,
validators=[
Validator("authorino.deploy", eq=True) | Validator("authorino.url", must_exist=True),
DefaultValueValidator("rhsso.url", must_exist=True, default=fetch_route("no-ssl-sso")),
DefaultValueValidator("rhsso.password",
must_exist=True, default=fetch_secret("credential-sso", "ADMIN_PASSWORD")),
DefaultValueValidator("mockserver.url", must_exist=True, default=fetch_route("no-ssl-mockserver")),
_kcp | Validator("authorino.deploy", eq=True) | Validator("authorino.url", must_exist=True),
_kcp | DefaultValueValidator("rhsso.url", must_exist=True, default=fetch_route("no-ssl-sso")),
_kcp | DefaultValueValidator("rhsso.password", must_exist=True,
default=fetch_secret("credential-sso", "ADMIN_PASSWORD")),
_kcp | DefaultValueValidator("mockserver.url", must_exist=True, default=fetch_route("no-ssl-mockserver")),
],
loaders=["testsuite.config.openshift_loader", "dynaconf.loaders.env_loader"]
)
9 changes: 9 additions & 0 deletions testsuite/config/openshift_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ def load(obj, env=None, silent=True, key=None, filename=None):
if "openshift2" in obj and "project" in obj["openshift2"]:
openshift2 = client.change_project(obj["openshift2"]["project"])
obj["openshift2"] = openshift2

kcp = None
if "kcp" in obj and "project" in obj["kcp"]:
kcp_section = config["kcp"]
kcp = client.change_project(kcp_section["project"] % None)
# when advanced scheduling is enabled on kcp/syncer, status field is not synced back from workload cluster
# deployment, is_ready method depends on status field that is not available yet hence we have to mock it
kcp.is_ready = lambda _: True
obj["kcp"] = kcp
16 changes: 16 additions & 0 deletions testsuite/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ def openshift2(testconfig):
return client


@pytest.fixture(scope="session")
def kcp(testconfig):
"""Modified OpenShift client acting as Kcp client"""
client = testconfig["kcp"]
if client is None:
pytest.skip("Kcp required but was not configured")

# does not work for kcp yet
# internally implemented using `oc status` command that seems internally touching project kind
# that is not available on kcp
# if not client.connected:
# pytest.fail("You are not logged into Openshift or the namespace for Kcp doesn't exist")

return client


@pytest.fixture(scope="session")
def rhsso(request, testconfig, blame):
"""RHSSO OIDC Provider fixture"""
Expand Down

0 comments on commit 2e1575f

Please sign in to comment.