Phase 1, PR 5: MCP v1 (read tools, known conditions, attach tickets) behind Authelia OAuth #9
No files matched your search
@@ -105,14 +105,16 @@ def test_known_conditions_seeded_and_managed(db):
|
||||
db.migrate()
|
||||
s = Store(db)
|
||||
seeded = s.known_conditions()
|
||||
# The UPS battery entry is seeded by migration 3 and ended by migration 5 (UPS replaced).
|
||||
assert [(k['kind'], k['subject'], k['ticket_id']) for k in seeded] == [
|
||||
('reboot', 'compute-storage-02', '693930698'), ('ceph_flag', 'noout', '693930698'),
|
||||
('ups_battery', 'ups', None)]
|
||||
('reboot', 'compute-storage-02', '693930698'), ('ceph_flag', 'noout', '693930698')]
|
||||
ended = db.query("SELECT ended_by FROM known_conditions WHERE kind='ups_battery'")
|
||||
assert ended == [{'ended_by': 'operator: UPS replaced (Tinker 387982348)'}]
|
||||
new = s.add_known_condition('reboot', 'pbs', '1', 'testing', 'jared', 1795410668.0)
|
||||
assert len(s.known_conditions()) == 4
|
||||
assert len(s.known_conditions()) == 3
|
||||
assert s.end_known_condition(new, 'jared', 1795410700.0) == 1
|
||||
assert s.end_known_condition(new, 'jared', 1795410700.0) == 0
|
||||
assert len(s.known_conditions()) == 3
|
||||
assert len(s.known_conditions()) == 2
|
||||
s.save_incident({'key': 'k', 'state': 'pending', 'priority': 3, 'kind': 'x', 'subject': 's', 'mode': 'shadow',
|
||||
'first_seen': 1.0, 'last_seen': 1.0}, 2.0)
|
||||
s.delete_incident('k')
|
||||
|
||||
@@ -161,6 +161,13 @@ MIGRATIONS: List[str] = [
|
||||
KEY idx_links_incident (incident_key, removed_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
""",
|
||||
# 5: the UPS battery known condition was stale: the APC unit was replaced by a UniFi UPS 2U
|
||||
# Pro on 2026-08-08 (Tinker 387982348, closed 2026-09-25). End it, keep the history.
|
||||
"""
|
||||
UPDATE known_conditions SET ended_at=UTC_TIMESTAMP(3),
|
||||
ended_by='operator: UPS replaced (Tinker 387982348)'
|
||||
WHERE kind='ups_battery' AND ended_at IS NULL;
|
||||
""",
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user