29 lines
1003 B
Python
29 lines
1003 B
Python
"""Safety tests for the legacy Atlas availability cleanup."""
|
|
|
|
import importlib.util
|
|
from pathlib import Path
|
|
|
|
|
|
def load_module():
|
|
"""Load the service-owned cleanup module without packaging it."""
|
|
path = (
|
|
Path(__file__).resolve().parents[2]
|
|
/ "services/monitoring/scripts/availability_cleanup.py"
|
|
)
|
|
spec = importlib.util.spec_from_file_location("availability_cleanup", path)
|
|
module = importlib.util.module_from_spec(spec)
|
|
assert spec.loader is not None
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
def test_cleanup_selector_cannot_match_request_v4() -> None:
|
|
"""Constrain deletion to obsolete annual Atlas definitions."""
|
|
mod = load_module()
|
|
|
|
assert '__name__="atlas:availability:ratio_365d"' in mod.LEGACY_SELECTOR
|
|
assert 'scope="atlas"' in mod.LEGACY_SELECTOR
|
|
assert 'definition!="request-v4"' in mod.LEGACY_SELECTOR
|
|
assert 'definition="request-v4"' in mod.PROTECTED_SELECTOR
|
|
assert "ratio_1h" not in mod.LEGACY_SELECTOR
|