Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Pin integration test dependencies #177

Merged
merged 9 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions tests/test_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
"knative-operator-webhook-image": KNATIVE_OPERATOR_WEBHOOK_IMAGE,
}

ISTIO_CHANNEL = "1.17/stable"
ISTIO_PILOT = "istio-pilot"
ISTIO_PILOT_TRUST = True
ISTIO_GATEWAY = "istio-gateway"
ISTIO_GATEWAY_APP_NAME = "istio-ingressgateway"
ISTIO_GATEWAY_TRUST = True


@pytest.mark.abort_on_fail
async def test_build_deploy_knative_charms(ops_test: OpsTest):
Expand All @@ -51,24 +58,24 @@ async def test_build_deploy_knative_charms(ops_test: OpsTest):

# Deploy istio as dependency
await ops_test.model.deploy(
"istio-pilot",
channel="latest/edge",
ISTIO_PILOT,
channel=ISTIO_CHANNEL,
config={"default-gateway": "knative-gateway"},
trust=True,
trust=ISTIO_PILOT_TRUST,
)

await ops_test.model.deploy(
"istio-gateway",
application_name="istio-ingressgateway",
channel="latest/edge",
ISTIO_GATEWAY,
application_name=ISTIO_GATEWAY_APP_NAME,
channel=ISTIO_CHANNEL,
config={"kind": "ingress"},
trust=True,
trust=ISTIO_GATEWAY_TRUST,
)

await ops_test.model.add_relation("istio-pilot", "istio-ingressgateway")
await ops_test.model.add_relation(ISTIO_PILOT, ISTIO_GATEWAY_APP_NAME)

await ops_test.model.wait_for_idle(
["istio-pilot", "istio-ingressgateway"],
[ISTIO_PILOT, ISTIO_GATEWAY_APP_NAME],
raise_on_blocked=False,
status="active",
timeout=90 * 10,
Expand Down
19 changes: 12 additions & 7 deletions tests/test_cos_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,33 +67,38 @@ async def test_build_deploy_knative_charms(ops_test: OpsTest):
# knative-operator is the charm that actually talks to prometheus
# to configure the OpenTelemetry collector to be scraped
APP_NAME = "knative-operator"
PROMETHEUS = "prometheus-k8s"
PROMETHEUS_CHANNEL = "1.0/stable"
PROMETHEUS_TRUST = True
PROMETHEUS_SCRAPE = "prometheus-scrape-config-k8s"
PROMETHEUS_SCRAPE_CHANNEL = "1.0/stable"


async def test_prometheus_grafana_integration(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, channel=PROMETHEUS_CHANNEL, trust=PROMETHEUS_TRUST)
await ops_test.model.deploy(
PROMETHEUS_SCRAPE, channel=PROMETHEUS_SCRAPE_CHANNEL, config=scrape_config
)

await ops_test.model.add_relation(APP_NAME, prometheus_scrape)
await ops_test.model.add_relation(APP_NAME, PROMETHEUS_SCRAPE)
await ops_test.model.add_relation(
f"{APP_NAME}:otel-collector", "knative-eventing:otel-collector"
)
await ops_test.model.add_relation(
f"{APP_NAME}:otel-collector", "knative-serving:otel-collector"
)
await ops_test.model.add_relation(
f"{prometheus}:metrics-endpoint", f"{prometheus_scrape}:metrics-endpoint"
f"{PROMETHEUS}:metrics-endpoint", f"{PROMETHEUS_SCRAPE}:metrics-endpoint"
)

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

status = await ops_test.model.get_status()
prometheus_unit_ip = status["applications"][prometheus]["units"][f"{prometheus}/0"]["address"]
prometheus_unit_ip = status["applications"][PROMETHEUS]["units"][f"{PROMETHEUS}/0"]["address"]
log.info(f"Prometheus available at http://{prometheus_unit_ip}:9090")

for attempt in retry_for_5_attempts:
Expand Down
Loading