Skip to content

Commit

Permalink
fix itests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldmitry committed Jan 24, 2025
1 parent ad047ae commit 109c031
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from tenacity.stop import stop_after_attempt, stop_after_delay
from tenacity.wait import wait_exponential as wexp

PARCA = "parca-k8s"
PARCA = "parca"


@mark.abort_on_fail
Expand Down Expand Up @@ -66,10 +66,11 @@ async def test_profiling_relation_is_configured(ops_test: OpsTest):
assert "zinc" in response.text


@retry(wait=wexp(multiplier=2, min=1, max=30), stop=stop_after_attempt(10), reraise=True)
async def test_self_profiling(ops_test: OpsTest):
address = await get_pubic_address(ops_test, PARCA)
response = requests.get(f"http://{address}:8080/metrics")
assert PARCA in response.text
assert f'"{PARCA}"' in response.text


@mark.abort_on_fail
Expand Down
11 changes: 8 additions & 3 deletions tests/integration/test_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@

import pytest
from helpers import get_unit_fqdn
from tenacity import retry
from tenacity.stop import stop_after_attempt
from tenacity.wait import wait_exponential as wexp

from nginx import CA_CERT_PATH, NGINX_PORT

PARCA = "parca-k8s"
PARCA = "parca"
PARCA_TESTER = "parca-tester"
SSC = "self-signed-certificates"
# Path where SSC saves the CA certificate
Expand Down Expand Up @@ -60,10 +63,11 @@ async def test_direct_url_200(ops_test):
assert exit_code == 0, f"Failed to query the parca server. {output}"


@retry(wait=wexp(multiplier=2, min=1, max=30), stop=stop_after_attempt(10), reraise=True)
async def test_self_profiling_scraping(ops_test):
exit_code, output = query_parca_server(ops_test.model_name, PARCA, url_path="/metrics")
assert exit_code == 0, f"Failed to query the parca server. {output}"
assert PARCA in output
assert f'"{PARCA}"' in output


@pytest.mark.abort_on_fail
Expand Down Expand Up @@ -93,9 +97,10 @@ async def test_profiling_scraping(ops_test):
async def test_remove_tls(ops_test):
await ops_test.juju("remove-relation", PARCA + ":certificates", SSC + ":certificates")
# we need to wait for a while until parca's nginx loses the TLS connection
await ops_test.model.wait_for_idle(apps=[PARCA], status="active", timeout=500, idle_period=60)
await ops_test.model.wait_for_idle(apps=[PARCA], status="active", timeout=500)


@retry(wait=wexp(multiplier=2, min=1, max=30), stop=stop_after_attempt(10), reraise=True)
async def test_direct_url_400(ops_test):
exit_code, _ = query_parca_server(ops_test.model_name, SSC, SSC_CA_CERT_PATH)
assert exit_code != 0
Expand Down

0 comments on commit 109c031

Please sign in to comment.