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

[DPE-4173] Miscellaneous improvements to continue stabilizing exporter integration tests #254

Merged
merged 14 commits into from
Jun 28, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Address PR feedback
shayancanonical committed Jun 28, 2024
commit da0de8120776b2e369f6bdead54ac0d616d21756
2 changes: 1 addition & 1 deletion src/rock.py
Original file line number Diff line number Diff line change
@@ -195,7 +195,7 @@ def update_mysql_router_exporter_service(
)
self._container.add_layer(self._EXPORTER_SERVICE_NAME, layer, combine=True)
# `self._container.replan()` does not stop services that have been disabled
# Explicitly use `stop()` instead
# Use `restart()` and `stop()` instead
if enabled:
self._container.restart(self._EXPORTER_SERVICE_NAME)
else:
21 changes: 8 additions & 13 deletions tests/integration/test_exporter.py
Original file line number Diff line number Diff line change
@@ -109,8 +109,7 @@ async def test_exporter_endpoint(ops_test: OpsTest) -> None:
unit_address = await get_unit_address(ops_test, unit.name)

try:
with requests.Session() as session:
session.get(f"http://{unit_address}:49152/metrics", stream=False)
requests.get(f"http://{unit_address}:49152/metrics", stream=False)
except requests.exceptions.ConnectionError as e:
assert "[Errno 111] Connection refused" in str(e), "❌ expected connection refused error"
else:
@@ -135,15 +134,12 @@ async def test_exporter_endpoint(ops_test: OpsTest) -> None:
wait=tenacity.wait_fixed(10),
):
with attempt:
with requests.Session() as session:
response = session.get(f"http://{unit_address}:49152/metrics", stream=False)
assert (
response.status_code == 200
), "❌ cannot connect to metrics endpoint with relation with cos"
assert "mysqlrouter_route_health" in str(
response.text
), "❌ did not find expected metric in response"
response.close()
response = requests.get(f"http://{unit_address}:49152/metrics", stream=False)
response.raise_for_status()
assert (
"mysqlrouter_route_health" in response.text
), "❌ did not find expected metric in response"
response.close()

logger.info("Removing relation between mysqlrouter and grafana agent")
await mysqlrouter_app.remove_relation(
@@ -157,8 +153,7 @@ async def test_exporter_endpoint(ops_test: OpsTest) -> None:
):
with attempt:
try:
with requests.Session() as session:
response = requests.get(f"http://{unit_address}:49152/metrics", stream=False)
requests.get(f"http://{unit_address}:49152/metrics", stream=False)
except requests.exceptions.ConnectionError as e:
assert "[Errno 111] Connection refused" in str(
e
21 changes: 8 additions & 13 deletions tests/integration/test_exporter_with_tls.py
Original file line number Diff line number Diff line change
@@ -151,8 +151,7 @@ async def test_exporter_endpoint(ops_test: OpsTest) -> None:
):
with attempt:
try:
with requests.Session() as session:
response = session.get(f"http://{unit_address}:49152/metrics", stream=False)
requests.get(f"http://{unit_address}:49152/metrics", stream=False)
except requests.exceptions.ConnectionError as e:
assert "[Errno 111] Connection refused" in str(
e
@@ -178,15 +177,12 @@ async def test_exporter_endpoint(ops_test: OpsTest) -> None:
wait=tenacity.wait_fixed(10),
):
with attempt:
with requests.Session() as session:
response = session.get(f"http://{unit_address}:49152/metrics", stream=False)
assert (
response.status_code == 200
), "❌ cannot connect to metrics endpoint with relation with cos"
assert "mysqlrouter_route_health" in str(
response.text
), "❌ did not find expected metric in response"
response.close()
response = requests.get(f"http://{unit_address}:49152/metrics", stream=False)
response.raise_for_status()
assert (
"mysqlrouter_route_health" in response.text
), "❌ did not find expected metric in response"
response.close()

for attempt in tenacity.Retrying(
reraise=True,
@@ -216,8 +212,7 @@ async def test_exporter_endpoint(ops_test: OpsTest) -> None:
):
with attempt:
try:
with requests.Session() as session:
session.get(f"http://{unit_address}:49152/metrics", stream=False)
requests.get(f"http://{unit_address}:49152/metrics", stream=False)
except requests.exceptions.ConnectionError as e:
assert "[Errno 111] Connection refused" in str(
e