diff --git a/tests/test_bundle.py b/tests/test_bundle.py index 6ab44e91..2a5b5687 100644 --- a/tests/test_bundle.py +++ b/tests/test_bundle.py @@ -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" @@ -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") @@ -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" @@ -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, @@ -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}, ) diff --git a/tests/test_bundle_tls_provider.py b/tests/test_bundle_tls_provider.py index 1bb0254b..7bd8433b 100644 --- a/tests/test_bundle_tls_provider.py +++ b/tests/test_bundle_tls_provider.py @@ -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: @@ -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( diff --git a/tests/test_cos_integration.py b/tests/test_cos_integration.py index a0b27432..7743040a 100644 --- a/tests/test_cos_integration.py +++ b/tests/test_cos_integration.py @@ -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 @@ -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: @@ -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"