feat(reliability): supervisor continuously enforces known-good UCI set
This commit is contained in:
+55
-5
@@ -155,20 +155,70 @@ class SupervisorExtrasTest(unittest.TestCase):
|
||||
server._health['ticks'] = server.HEALTH_STA_PARK_INTERVAL - 1
|
||||
with mock.patch.object(
|
||||
server, '_sta_uplink_enabled', return_value=True), \
|
||||
__import__('unittest').mock.patch.object(
|
||||
server, '_park_dummy_sta') as park:
|
||||
mock.patch.object(
|
||||
server, '_park_dummy_sta') as park, \
|
||||
mock.patch.object(
|
||||
server, '_raise_monitors', return_value=[]), \
|
||||
mock.patch('mk8_guard.reconcile',
|
||||
return_value={'changed': [], 'pool_cleared': False,
|
||||
'monitors_raised': []}) as rec:
|
||||
h = server.health_check()
|
||||
park.assert_called_once()
|
||||
rec.assert_called_once()
|
||||
self.assertEqual(server._health['ticks'],
|
||||
server.HEALTH_STA_PARK_INTERVAL)
|
||||
# not on interval ticks: no re-park
|
||||
# not on interval ticks: no re-park, no reconcile
|
||||
server._health['ticks'] = 1
|
||||
with mock.patch.object(
|
||||
server, '_sta_uplink_enabled', return_value=True), \
|
||||
__import__('unittest').mock.patch.object(
|
||||
server, '_park_dummy_sta') as park:
|
||||
mock.patch.object(
|
||||
server, '_park_dummy_sta') as park, \
|
||||
mock.patch('mk8_guard.reconcile') as rec:
|
||||
server.health_check()
|
||||
park.assert_not_called()
|
||||
rec.assert_not_called()
|
||||
|
||||
def test_health_reconcile_journals_changed_keys(self):
|
||||
import mk8_events
|
||||
events = []
|
||||
old_log = mk8_events.log_event
|
||||
old_run = server.device_run
|
||||
old_iface = server._iface_up
|
||||
|
||||
def fake_run(args, timeout=20, input_data=None):
|
||||
a = list(args)
|
||||
if a[:2] == ['pidof', 'pineapd']:
|
||||
return (0, '12345\n', '')
|
||||
if a[:2] == ['ip', 'link', 'show']:
|
||||
return (0, '4: wlan0mon: <UP> state unknown', '')
|
||||
return (0, '', '')
|
||||
|
||||
mk8_events.log_event = lambda kind, **kw: events.append((kind, kw))
|
||||
server.device_run = fake_run
|
||||
server._iface_up = lambda name: True
|
||||
old_ticks = server._health.get('ticks')
|
||||
try:
|
||||
server._health['ticks'] = server.HEALTH_STA_PARK_INTERVAL - 1
|
||||
with mock.patch.object(server, '_sta_uplink_enabled',
|
||||
return_value=False), \
|
||||
mock.patch.object(server, '_raise_monitors',
|
||||
return_value=[]), \
|
||||
mock.patch('mk8_guard.reconcile',
|
||||
return_value={'changed':
|
||||
['pineapd.@pineapd[0].autossidpool'],
|
||||
'pool_cleared': False,
|
||||
'monitors_raised': []}):
|
||||
server.health_check()
|
||||
self.assertTrue(any(k == 'guard_fix' and 'autossidpool' in kw.get('msg', '')
|
||||
for k, kw in events))
|
||||
finally:
|
||||
mk8_events.log_event = old_log
|
||||
server.device_run = old_run
|
||||
server._iface_up = old_iface
|
||||
if old_ticks is None:
|
||||
server._health.pop('ticks', None)
|
||||
else:
|
||||
server._health['ticks'] = old_ticks
|
||||
|
||||
def test_health_reports_events_and_counters(self):
|
||||
import mk8_events
|
||||
|
||||
Reference in New Issue
Block a user