Skip to content

Commit 70c5495

Browse files
[DPE-3899, DPE-4173] Try to clear connection pool before relating with COS to avoid TIME_WAIT connections; stabilize exporter tests (#245)
## Issue #219 #229 We are running into a connection in `TIME_WAIT` when starting `mysql_router_exporter`. This happens in both the K8s and VM charms. The guess is that this is related to the connection pool we use in our tests. ## Solution Clear the connection pool before relating with COS, re-run exporter tests 5-10 times, observe if tests have stabilized
1 parent 46ee27a commit 70c5495

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/integration/test_exporter.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ async def test_exporter_endpoint(ops_test: OpsTest) -> None:
128128
else:
129129
assert False, "❌ can connect to metrics endpoint without relation with cos"
130130

131+
# clear connection pool before relating metrics-endpoint which starts mysql_router_exporter
132+
http.clear()
133+
131134
logger.info("Relating mysqlrouter with grafana agent")
132135
await ops_test.model.relate(
133136
f"{GRAFANA_AGENT_APP_NAME}:grafana-dashboards-consumer",
@@ -174,6 +177,8 @@ async def test_exporter_endpoint(ops_test: OpsTest) -> None:
174177
else:
175178
assert False, "❌ can connect to metrics endpoint without relation with cos"
176179

180+
http.clear()
181+
177182

178183
@pytest.mark.group(1)
179184
@pytest.mark.abort_on_fail
@@ -228,6 +233,9 @@ async def test_exporter_endpoint_with_tls(ops_test: OpsTest) -> None:
228233
else:
229234
assert False, "❌ can connect to metrics endpoint without relation with cos"
230235

236+
# clear connection pool before relating metrics-endpoint which starts mysql_router_exporter
237+
http.clear()
238+
231239
logger.info("Relating mysqlrouter with grafana agent")
232240
await ops_test.model.relate(
233241
f"{GRAFANA_AGENT_APP_NAME}:metrics-endpoint", f"{MYSQL_ROUTER_APP_NAME}:metrics-endpoint"
@@ -295,3 +303,5 @@ async def test_exporter_endpoint_with_tls(ops_test: OpsTest) -> None:
295303
assert (
296304
"Issuer: CN = MySQL_Router_Auto_Generated_CA_Certificate" in issuer
297305
), "Expected mysqlrouter autogenerated certificate"
306+
307+
http.clear()

0 commit comments

Comments
 (0)