"""Replays for the other incidents in the plan on thor#1 (Area 7). * T2, 2026-11-25: planned rack maintenance. Zero tickets. * T3, 2026-10-27: compute-storage-01 lost its only corosync link, was fenced, down 3.5 hours. One ticket. * T4, 2026-11-04: corosync partition, three nodes fenced. One ticket. * DIMM, 2026-11-21: compute-storage-02's known failing DIMM. No ticket, one note on 693930698. """ from datetime import datetime, timezone import pytest from .replay import Replay def hm(ts: float) -> str: return datetime.fromtimestamp(ts, tz=timezone.utc).strftime('%H:%M') @pytest.fixture(scope='module') def t2(): return Replay('t2').run() @pytest.fixture(scope='module') def t3(): return Replay('t3').run() @pytest.fixture(scope='module') def t4(): return Replay('t4').run() @pytest.fixture(scope='module') def dimm(): return Replay('dimm').run() # -- T2: planned maintenance ------------------------------------------------ def test_t2_planned_maintenance_opens_no_ticket(t2): assert t2.actions() == [] def test_t2_everything_lands_on_the_maintenance_timeline(t2): inc = t2.store.incidents['maintenance:gandalf:2'] assert inc['ticket'] is False and inc['state'] == 'cleared' assert inc['summary'] == 'Planned maintenance (switch update, by jared)' rebooted = {s['subject'] for s in inc['symptoms'].values() if s['kind'] in ('reboot', 'reboot_planned')} # Every rack host and compute-storage-02 came back with a new boot time. assert rebooted >= {'compute-storage-01', 'compute-storage-02', 'compute-storage-gpu-01', 'storage-01', 'monitor-01', 'monitor-02'} assert set(t2.store.incidents) == {'maintenance:gandalf:2'} def test_t2_thor_was_dark_and_caught_up(t2): caught_up = [r for r in t2.results if r.catching_up] assert caught_up, 'the first cycle after the outage reviews the whole gap' assert caught_up[0].window[1] - caught_up[0].window[0] > 20 * 60 # -- T3: one host fenced ------------------------------------------------------ def test_t3_one_ticket_for_the_fenced_host(t3): opened = t3.opened() assert len(opened) == 1 p = opened[0]['payload'] assert opened[0]['incident_key'] == 'host:compute-storage-01:fenced' assert p['priority'] == 2 assert p['title'] == ('[compute-storage-01][auto][thor][software] compute-storage-01 lost its cluster link and ' 'was fenced [single-node][production][issue]') assert '15:55' <= hm(opened[0]['created']) <= '15:59' def test_t3_ceph_fallout_and_the_late_reboot_attach_to_it(t3): inc = t3.store.incidents['host:compute-storage-01:fenced'] kinds = {(s['kind'], s['subject']) for s in inc['symptoms'].values()} assert ('ceph_alert', 'cluster') in kinds assert ('scrape', 'compute-storage-01') in kinds names = {k.split(':')[-1] for k in inc['symptoms'] if k.startswith('cluster:ceph_alert:')} assert {'MON_DOWN', 'OSD_HOST_DOWN', 'OSD_DOWN'} <= names # The host stayed down until 19:20; the incident stays open while it is down, then clears. assert inc['state'] == 'cleared' assert set(t3.store.incidents) == {'host:compute-storage-01:fenced'} # -- T4: partition -------------------------------------------------------------- def test_t4_one_ticket_for_the_partition(t4): opened = t4.opened() assert len(opened) == 1 assert opened[0]['incident_key'] == 'cluster:corosync:partition' assert opened[0]['payload']['priority'] == 1 assert opened[0]['payload']['title'].startswith('[proxmox-cluster][auto][thor][software] Cluster partition: ') assert '20:52' <= hm(opened[0]['created']) <= '20:56' assert {a['incident_key'] for a in t4.actions()} == {'cluster:corosync:partition'} def test_t4_late_fence_and_reboots_fold_into_the_partition(t4): inc = t4.store.incidents['cluster:corosync:partition'] assert 'storage-01' in inc['summary'] # fenced at 20:54, seen later on its own assert 'host:storage-01:fenced' in inc['symptoms'] assert {'host:compute-storage-01:reboot', 'host:compute-storage-gpu-01:reboot'} <= set(inc['symptoms']) assert inc['state'] == 'cleared' # -- DIMM: known condition ------------------------------------------------------ def test_dimm_reboot_is_a_note_on_its_known_ticket_not_a_new_ticket(dimm): assert dimm.opened() == [] notes = dimm.actions('known_note') assert len(notes) == 1 assert notes[0]['payload']['ticket_id'] == '693930698' assert 'compute-storage-02' in notes[0]['payload']['comment'] assert dimm.store.incidents['host:compute-storage-02:reboot']['state'] == 'cleared'