test(alerts): seed metrics the way ingest does, through record_metrics (#5473)
#5473 "Opening an alert rule takes up to 15 s". With the rule pickers now reading plugin_metric_latest, nine integration tests failed on rule_fields: "host_agent has no resource 'box-…'". They seeded a resource by adding a raw PluginMetric row, which no production path does: host-agent ingest and record_metric both go through record_metrics, which keeps the latest-value table. The seeds now go through record_metrics too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -45,9 +45,9 @@ def test_silence_is_marked_once_and_cleared_by_data(app):
|
||||
user = User(username=f"nd-{tag}", email=f"nd-{tag}@test", password_hash="x",
|
||||
role=UserRole.admin)
|
||||
s.add(user)
|
||||
s.add(PluginMetric(source_module="host_agent", resource_name=res,
|
||||
metric_name="cpu_pct", value=1.0,
|
||||
recorded_at=now - timedelta(hours=1)))
|
||||
await alerts.record_metrics(s, [PluginMetric(
|
||||
source_module="host_agent", resource_name=res, metric_name="cpu_pct",
|
||||
value=1.0, recorded_at=now - timedelta(hours=1))])
|
||||
await s.flush()
|
||||
ids = {}
|
||||
for key, notify in (("loud", True), ("hushed", False)):
|
||||
@@ -156,9 +156,9 @@ def test_a_series_quiet_only_while_steward_was_down_is_not_silent(app):
|
||||
user = User(username=f"bk-{tag}", email=f"bk-{tag}@test", password_hash="x",
|
||||
role=UserRole.admin)
|
||||
s.add(user)
|
||||
s.add(PluginMetric(source_module="host_agent", resource_name=res,
|
||||
metric_name="cpu_pct", value=1.0,
|
||||
recorded_at=now - timedelta(minutes=18)))
|
||||
await alerts.record_metrics(s, [PluginMetric(
|
||||
source_module="host_agent", resource_name=res, metric_name="cpu_pct",
|
||||
value=1.0, recorded_at=now - timedelta(minutes=18))])
|
||||
await s.flush()
|
||||
fields = await alert_svc.rule_fields(
|
||||
s, name=f"back {tag}", source_module="host_agent", resource_name=res,
|
||||
|
||||
Reference in New Issue
Block a user