Skip to content

Commit

Permalink
rename method
Browse files Browse the repository at this point in the history
  • Loading branch information
sed-i committed Jan 25, 2022
1 parent c0e5377 commit 0e41df3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 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 @@ -1505,7 +1505,7 @@ def __init__(
for event_source in event_sources:
self.framework.observe(event_source, self._update_relation_data)

def reload_alert_rules(self):
def _reinitialize_alert_rules(self):
"""Reloads alert rules and updates all relations."""
self._update_relation_data(None)

Expand Down
12 changes: 6 additions & 6 deletions tests/unit/test_prometheus_rules_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_reload_when_dir_is_still_empty_changes_nothing(self):
# WHEN no rule files are present

# AND the reload method is called
self.harness.charm.rules_provider.reload_alert_rules()
self.harness.charm.rules_provider._reinitialize_alert_rules()

# THEN relation data is unchanged
relation = self.harness.charm.model.get_relation("metrics-endpoint")
Expand All @@ -82,7 +82,7 @@ def test_reload_after_dir_is_populated_updates_relation_data(self):
self.sandbox.put_file(os.path.join(self.alert_rules_path, "alert.rule"), self.ALERT)

# AND the reload method is called
self.harness.charm.rules_provider.reload_alert_rules()
self.harness.charm.rules_provider._reinitialize_alert_rules()

# THEN relation data is updated
relation = self.harness.charm.model.get_relation("metrics-endpoint")
Expand All @@ -95,13 +95,13 @@ def test_reload_after_dir_is_emptied_updates_relation_data(self):
# GIVEN alert files are present and relation data contains respective alerts
alert_filename = os.path.join(self.alert_rules_path, "alert.rule")
self.sandbox.put_file(alert_filename, self.ALERT)
self.harness.charm.rules_provider.reload_alert_rules()
self.harness.charm.rules_provider._reinitialize_alert_rules()

# WHEN all rule files are deleted from the alerts dir
self.sandbox.remove(alert_filename)

# AND the reload method is called
self.harness.charm.rules_provider.reload_alert_rules()
self.harness.charm.rules_provider._reinitialize_alert_rules()

# THEN relation data is empty again
relation = self.harness.charm.model.get_relation("metrics-endpoint")
Expand All @@ -112,14 +112,14 @@ def test_reload_after_dir_itself_removed_updates_relation_data(self):
# GIVEN alert files are present and relation data contains respective alerts
alert_filename = os.path.join(self.alert_rules_path, "alert.rule")
self.sandbox.put_file(alert_filename, self.ALERT)
self.harness.charm.rules_provider.reload_alert_rules()
self.harness.charm.rules_provider._reinitialize_alert_rules()

# WHEN the alerts dir itself is deleted
self.sandbox.remove(alert_filename)
self.sandbox.rmdir(self.alert_rules_path)

# AND the reload method is called
self.harness.charm.rules_provider.reload_alert_rules()
self.harness.charm.rules_provider._reinitialize_alert_rules()

# THEN relation data is empty again
relation = self.harness.charm.model.get_relation("metrics-endpoint")
Expand Down

0 comments on commit 0e41df3

Please sign in to comment.