Add explicit HYPIR restoration profile
This commit is contained in:
1 parent
2ae61baec7
commit
118e32005e
11 files changed
+593
-32
No files matched your search
@@ -26,6 +26,11 @@ def image_item(state="exited"):
|
||||
"Labels": {controller.IMAGE_LABEL_KEY: controller.IMAGE_WORKER}}
|
||||
|
||||
|
||||
def restore_item(state="exited"):
|
||||
return {"Id": "id-restore", "State": state,
|
||||
"Labels": {controller.IMAGE_LABEL_KEY: controller.RESTORE_WORKER}}
|
||||
|
||||
|
||||
def tts_item(state="running"):
|
||||
return {"Id": "id-tts", "State": state,
|
||||
"Labels": {controller.TTS_LABEL_KEY: controller.TTS_WORKER}}
|
||||
@@ -48,7 +53,7 @@ class ProfileControllerTests(unittest.TestCase):
|
||||
return 204, b""
|
||||
|
||||
with patch.object(controller, "containers", return_value=profiles), \
|
||||
patch.object(controller, "image_container", return_value=image_item()), \
|
||||
patch.object(controller, "image_containers", return_value=[image_item()]), \
|
||||
patch.object(controller, "tts_container", return_value=tts_item()), \
|
||||
patch.object(controller, "docker_request", side_effect=request):
|
||||
result = controller.activate("medium")
|
||||
@@ -62,7 +67,7 @@ class ProfileControllerTests(unittest.TestCase):
|
||||
def test_fails_if_profile_container_is_missing(self):
|
||||
profiles = {name: item(name) for name in controller.ALLOWED[:-1]}
|
||||
with patch.object(controller, "containers", return_value=profiles), \
|
||||
patch.object(controller, "image_container", return_value=image_item()), \
|
||||
patch.object(controller, "image_containers", return_value=[image_item()]), \
|
||||
patch.object(controller, "tts_container", return_value=tts_item()):
|
||||
with self.assertRaisesRegex(RuntimeError, "missing"):
|
||||
controller.activate("fast")
|
||||
@@ -78,6 +83,8 @@ class ProfileControllerTests(unittest.TestCase):
|
||||
|
||||
with patch.object(controller, "containers", return_value=profiles), \
|
||||
patch.object(controller, "image_container", return_value=image_item()), \
|
||||
patch.object(controller, "image_containers",
|
||||
return_value=[image_item(), restore_item()]), \
|
||||
patch.object(controller, "tts_container", return_value=tts_item()), \
|
||||
patch.object(controller, "docker_request", side_effect=request):
|
||||
controller.set_image_worker(True)
|
||||
@@ -87,6 +94,27 @@ class ProfileControllerTests(unittest.TestCase):
|
||||
("POST", "/containers/id-flux/start"),
|
||||
])
|
||||
|
||||
def test_restore_start_stops_flux_and_starts_restore(self):
|
||||
profiles = {name: item(name) for name in controller.ALLOWED}
|
||||
calls = []
|
||||
|
||||
def request(method, path):
|
||||
calls.append((method, path))
|
||||
return 204, b""
|
||||
|
||||
with patch.object(controller, "containers", return_value=profiles), \
|
||||
patch.object(controller, "image_container", return_value=restore_item()), \
|
||||
patch.object(controller, "image_containers",
|
||||
return_value=[image_item("running"), restore_item()]), \
|
||||
patch.object(controller, "tts_container", return_value=tts_item()), \
|
||||
patch.object(controller, "docker_request", side_effect=request):
|
||||
controller.set_image_worker(True, controller.RESTORE_WORKER)
|
||||
self.assertEqual(calls, [
|
||||
("POST", "/containers/id-tts/stop?t=30"),
|
||||
("POST", "/containers/id-flux/stop?t=20"),
|
||||
("POST", "/containers/id-restore/start"),
|
||||
])
|
||||
|
||||
def test_profile_activation_stops_image_worker_first(self):
|
||||
profiles = {name: item(name) for name in controller.ALLOWED}
|
||||
calls = []
|
||||
@@ -96,8 +124,8 @@ class ProfileControllerTests(unittest.TestCase):
|
||||
return 204, b""
|
||||
|
||||
with patch.object(controller, "containers", return_value=profiles), \
|
||||
patch.object(controller, "image_container",
|
||||
return_value=image_item("running")), \
|
||||
patch.object(controller, "image_containers",
|
||||
return_value=[image_item("running"), restore_item()]), \
|
||||
patch.object(controller, "tts_container", return_value=tts_item()), \
|
||||
patch.object(controller, "docker_request", side_effect=request):
|
||||
controller.activate("fast")
|
||||
|
||||
Reference in new issue
Block a user