fix(storage): preserve preexisting Matrix health failures during restart
This commit is contained in:
@@ -159,6 +159,43 @@ class HostSafetyTests(unittest.TestCase):
|
||||
value = {"environment": {"KEY": "literal-$-$$-${NOT_AN_ENV_VAR}"}, "command": ["echo $VALUE"]}
|
||||
self.assertEqual(m.resolved(m.literal(value)), value)
|
||||
|
||||
def restart_fixture(self):
|
||||
migration = m.Migration(self.root)
|
||||
(self.root / "docker-compose.yml").write_text('{}')
|
||||
(migration.home / "target.json").write_text('{}')
|
||||
migration.state = {"writesReleased": True, "phase": "released", "containers": {
|
||||
"backend": {"running": True, "health": "unhealthy"},
|
||||
"db": {"running": True, "health": "healthy"},
|
||||
"matrix-synapse": {"running": True, "health": "healthy"},
|
||||
"matrix-element": {"running": True, "health": "unhealthy"},
|
||||
"matrix-redis": {"running": False, "health": None},
|
||||
}}
|
||||
migration.compose = Mock(return_value="matrix-element-id")
|
||||
migration.inspect = Mock(return_value={"State": {"Running": True}})
|
||||
return migration
|
||||
|
||||
def test_restart_preserves_existing_matrix_health_failure_but_waits_for_core(self):
|
||||
migration = self.restart_fixture()
|
||||
migration.start_application()
|
||||
calls = [call.args for call in migration.compose.call_args_list]
|
||||
start = next(args for args in calls if "up" in args and "--no-deps" not in args)
|
||||
self.assertIn("matrix-element", start)
|
||||
self.assertNotIn("matrix-redis", start)
|
||||
wait = next(args for args in calls if "--wait" in args)
|
||||
for name in ("backend", "db", "matrix-synapse"):
|
||||
self.assertIn(name, wait)
|
||||
self.assertNotIn("matrix-element", wait)
|
||||
self.assertEqual(migration.state["preexistingUnhealthyServices"], ["matrix-element"])
|
||||
self.assertEqual(migration.state["phase"], "complete")
|
||||
|
||||
def test_preexisting_unhealthy_matrix_must_still_restart(self):
|
||||
migration = self.restart_fixture()
|
||||
migration.inspect.return_value = {"State": {"Running": False}}
|
||||
with self.assertRaisesRegex(m.Error, "nicht wieder gestartet"):
|
||||
migration.start_application()
|
||||
self.assertEqual(migration.state["phase"], "released")
|
||||
self.assertFalse(any("traefik" in call.args for call in migration.compose.call_args_list))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user