Skip to content

Commit

Permalink
Fully ensure timeseries for deleted alerts are also purged
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush-se committed Nov 21, 2024
1 parent e15f312 commit a52053d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/seer/anomaly_detection/test_cleanup_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from seer.anomaly_detection.models.external import AnomalyDetectionConfig, TimeSeriesPoint
from seer.anomaly_detection.models.timeseries import TimeSeries
from seer.anomaly_detection.tasks import cleanup_disabled_alerts, cleanup_timeseries
from seer.db import DbDynamicAlert, Session, TaskStatus
from seer.db import DbDynamicAlert, DbDynamicAlertTimeSeries, Session, TaskStatus


class TestCleanupTasks(unittest.TestCase):
Expand Down Expand Up @@ -196,6 +196,13 @@ def test_cleanup_disabled_alerts(self):
)
assert alert is None

timeseries = (
session.query(DbDynamicAlertTimeSeries)
.filter(DbDynamicAlertTimeSeries.dynamic_alert_id == alert_id)
.all()
)
assert len(timeseries) == 0

# Confirm that alert 4 and its respective timeseries are not deleted
with Session() as session:
alert = (
Expand Down

0 comments on commit a52053d

Please sign in to comment.