Skip to content

Commit

Permalink
tests: use stable versions of COS and TLS charms (#409)
Browse files Browse the repository at this point in the history
This commit pins all charms that get deployed from Charmhub to a compatible version to the CKF 1.8 release.
Part of canonical/bundle-kubeflow#863
  • Loading branch information
DnPlas authored Apr 17, 2024
1 parent 2d4a99d commit 6619a6f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 25 deletions.
20 changes: 12 additions & 8 deletions tests/test_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
# Test dependencies
DEX_AUTH = "dex-auth"
DEX_AUTH_CHANNEL = "2.36/stable"
TRUST_DEX_AUTH = True
DEX_AUTH_TRUST = True
OIDC_GATEKEEPER = "oidc-gatekeeper"
OIDC_GATEKEEPER_CHANNEL = "ckf-1.8/stable"
TRUST_OIDC_GATEKEEPER = False
OIDC_GATEKEEPER_TRUST = False
TENSORBOARD_CONTROLLER = "tensorboard-controller"
TENSORBOARD_CONTROLLER_CHANNEL = "1.8/stable"
TRUST_TENSORBOARD_CONTROLLER = True
TENSORBOARD_CONTROLLER_TRUST = True
INGRESS_REQUIRER = "kubeflow-volumes"
INGRESS_REQUIRER_CHANNEL = "1.8/stable"
TRUST_INGRESS_REQUIRER = False
INGRESS_REQUIRER_TRUST = False

ISTIO_PILOT = "istio-pilot"
ISTIO_GATEWAY_APP_NAME = "istio-ingressgateway"
Expand Down Expand Up @@ -111,7 +111,7 @@ async def test_ingress_relation(ops_test: OpsTest):
specific charm that implements ingress's requirer interface to a generic charm
"""
await ops_test.model.deploy(
INGRESS_REQUIRER, channel=INGRESS_REQUIRER_CHANNEL, trust=TRUST_INGRESS_REQUIRER
INGRESS_REQUIRER, channel=INGRESS_REQUIRER_CHANNEL, trust=INGRESS_REQUIRER_TRUST
)

await ops_test.model.add_relation(f"{ISTIO_PILOT}:ingress", f"{INGRESS_REQUIRER}:ingress")
Expand All @@ -135,7 +135,11 @@ async def test_gateway_info_relation(ops_test: OpsTest):
TODO (https://github.com/canonical/istio-operators/issues/259): Change this from using a
specific charm that implements ingress's requirer interface to a generic charm
"""
await ops_test.model.deploy(TENSORBOARD_CONTROLLER, channel=TENSORBOARD_CONTROLLER_CHANNEL, trust=TRUST_TENSORBOARD_CONTROLLER)
await ops_test.model.deploy(
TENSORBOARD_CONTROLLER,
channel=TENSORBOARD_CONTROLLER_CHANNEL,
trust=TENSORBOARD_CONTROLLER_TRUST,
)

await ops_test.model.add_relation(
f"{ISTIO_PILOT}:gateway-info", f"{TENSORBOARD_CONTROLLER}:gateway-info"
Expand Down Expand Up @@ -247,7 +251,7 @@ async def test_enable_ingress_auth(ops_test: OpsTest):
await ops_test.model.deploy(
DEX_AUTH,
channel=DEX_AUTH_CHANNEL,
trust=TRUST_DEX_AUTH,
trust=DEX_AUTH_TRUST,
config={
"static-username": USERNAME,
"static-password": PASSWORD,
Expand All @@ -258,7 +262,7 @@ async def test_enable_ingress_auth(ops_test: OpsTest):
await ops_test.model.deploy(
OIDC_GATEKEEPER,
channel=OIDC_GATEKEEPER_CHANNEL,
trust=TRUST_OIDC_GATEKEEPER,
trust=OIDC_GATEKEEPER_TRUST,
config={"public-url": regular_ingress_gateway_ip},
)

Expand Down
9 changes: 6 additions & 3 deletions tests/test_bundle_tls_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
plural="gateways",
)

SELF_SIGNED_CERTIFICATES = "self-signed-certificates"
SELF_SIGNED_CERTIFICATES_CHANNEL = "latest/stable"


@pytest.fixture(scope="session")
def lightkube_client() -> lightkube.Client:
Expand Down Expand Up @@ -53,12 +56,12 @@ async def test_build_and_deploy_istio_charms(ops_test: OpsTest):
)

await ops_test.model.deploy(
"self-signed-certificates",
channel="edge",
SELF_SIGNED_CERTIFICATES,
channel=SELF_SIGNED_CERTIFICATES_CHANNEL,
)

await ops_test.model.add_relation(
f"{ISTIO_PILOT}:certificates", "self-signed-certificates:certificates"
f"{ISTIO_PILOT}:certificates", f"{SELF_SIGNED_CERTIFICATES}:certificates"
)

await ops_test.model.wait_for_idle(
Expand Down
42 changes: 28 additions & 14 deletions tests/test_cos_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
ISTIO_GATEWAY_APP_NAME = "istio-ingressgateway"


PROMETHEUS_K8S = "prometheus-k8s"
PROMETHEUS_K8S_CHANNEL = "1.0/stable"
PROMETHEUS_K8S_TRUST = True
PROMETHEUS_SCRAPE_K8S = "prometheus-scrape-config-k8s"
PROMETHEUS_SCRAPE_K8S_CHANNEL = "1.0/stable"
PROMETHEUS_SCRAPE_CONFIG = {"scrape_interval": "30s"}


@pytest.mark.abort_on_fail
async def test_build_and_deploy_istio_charms(ops_test: OpsTest):
# Build, deploy, and relate istio charms
Expand Down Expand Up @@ -48,23 +56,28 @@ async def test_build_and_deploy_istio_charms(ops_test: OpsTest):

async def test_prometheus_grafana_integration_istio_pilot(ops_test: OpsTest):
"""Deploy prometheus and required relations, then test the metrics."""
prometheus = "prometheus-k8s"
prometheus_scrape = "prometheus-scrape-config-k8s"
scrape_config = {"scrape_interval": "30s"}

# Deploy and relate prometheus
await ops_test.model.deploy(prometheus, channel="latest/stable", trust=True)
await ops_test.model.deploy(prometheus_scrape, channel="latest/stable", config=scrape_config)
await ops_test.model.deploy(
PROMETHEUS_K8S,
channel=PROMETHEUS_K8S_CHANNEL,
trust=PROMETHEUS_K8S_TRUST,
)
await ops_test.model.deploy(
PROMETHEUS_SCRAPE_K8S,
channel=PROMETHEUS_SCRAPE_K8S_CHANNEL,
config=PROMETHEUS_SCRAPE_CONFIG,
)

await ops_test.model.add_relation(ISTIO_PILOT, prometheus_scrape)
await ops_test.model.add_relation("istio-pilot", PROMETHEUS_SCRAPE_K8S)
await ops_test.model.add_relation(
f"{prometheus}:metrics-endpoint", f"{prometheus_scrape}:metrics-endpoint"
f"{PROMETHEUS_K8S}:metrics-endpoint",
f"{PROMETHEUS_SCRAPE_K8S}:metrics-endpoint",
)

await ops_test.model.wait_for_idle(status="active", timeout=90 * 10)

await ops_test.model.wait_for_idle(status="active", timeout=60 * 20)
status = await ops_test.model.get_status()
prometheus_unit_ip = status["applications"][prometheus]["units"][f"{prometheus}/0"]["address"]
prometheus_unit_ip = status["applications"][PROMETHEUS_K8S]["units"][f"{PROMETHEUS_K8S}/0"][
"address"
]
log.info(f"Prometheus available at http://{prometheus_unit_ip}:9090")

for attempt in retry_for_5_attempts:
Expand All @@ -89,9 +102,10 @@ async def test_prometheus_grafana_integration_istio_pilot(ops_test: OpsTest):
async def test_istio_pilot_alert_rules(ops_test: OpsTest):
"""Test alert rules availability and match with what is found in the source code."""

prometheus = "prometheus-k8s"
status = await ops_test.model.get_status()
prometheus_unit_ip = status["applications"][prometheus]["units"][f"{prometheus}/0"]["address"]
prometheus_unit_ip = status["applications"][PROMETHEUS_K8S]["units"][f"{PROMETHEUS_K8S}/0"][
"address"
]

# Get targets and assert they are available
targets_url = f"http://{prometheus_unit_ip}:9090/api/v1/targets"
Expand Down

0 comments on commit 6619a6f

Please sign in to comment.