Skip to content

Commit

Permalink
test: update cosl dep to the branch for testing CI
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelThamm committed Dec 20, 2024
1 parent 4ba4abe commit 082a34c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/charms/prometheus_k8s/v0/prometheus_scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def expand_wildcard_targets_into_individual_jobs(
job_name = modified_job.get("job_name", "unnamed-job") + "-" + unit_num
modified_job["job_name"] = job_name
modified_job["metrics_path"] = unit_path + (
job.get("metrics_path") or "/metrics"
job.get("metrics_path") or "/metrics"
)

if topology:
Expand Down
1 change: 1 addition & 0 deletions lib/charms/prometheus_k8s/v1/prometheus_remote_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
)
)


class RelationNotFoundError(Exception):
"""Raised if there is no relation with the given name."""

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cosl>=0.0.46
git+https://github.com/canonical/cos-lib.git@feature/generic-alerts#egg=cosl
cryptography
jsonschema
ops
Expand Down
11 changes: 7 additions & 4 deletions tests/unit/test_endpoint_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def test_each_alert_rule_is_topology_labeled(self):
self.assertIn("alert_rules", data)
alerts = json.loads(data["alert_rules"])
self.assertIn("groups", alerts)
self.assertEqual(len(alerts["groups"]), 6)
self.assertEqual(len(alerts["groups"]), 7)
for group in alerts["groups"]:
for rule in group["rules"]:
if "and_unit" not in group["name"]:
Expand Down Expand Up @@ -360,7 +360,7 @@ def test_each_alert_expression_is_topology_labeled(self):
self.assertIn("alert_rules", data)
alerts = json.loads(data["alert_rules"])
self.assertIn("groups", alerts)
self.assertEqual(len(alerts["groups"]), 6)
self.assertEqual(len(alerts["groups"]), 7)
group = alerts["groups"][0]
for rule in group["rules"]:
self.assertIn("expr", rule)
Expand Down Expand Up @@ -753,10 +753,13 @@ def test_unit_label_is_retained_if_hard_coded(self):
# check unit topology is present in labels and in alert rule expression
relation = self.harness.charm.model.get_relation("metrics-endpoint")
alert_rules = json.loads(relation.data[self.harness.charm.app].get("alert_rules"))
from pprint import pprint
pprint(alert_rules)
for group in alert_rules["groups"]:
for rule in group["rules"]:
self.assertIn("juju_unit", rule["labels"])
self.assertIn("juju_unit=", rule["expr"])
if "_HostHealth_alerts" not in group["name"]: # _HostHealth_alerts are injected alerts without juju_unit labels
self.assertIn("juju_unit", rule["labels"])
self.assertIn("juju_unit=", rule["expr"])


class TestNoLeader(unittest.TestCase):
Expand Down

0 comments on commit 082a34c

Please sign in to comment.