Restrict launches to prepared runtime images
This commit is contained in:
@@ -727,6 +727,29 @@ class AgentTests(unittest.TestCase):
|
||||
self.assertEqual(second["result"], first["result"])
|
||||
self.assertEqual(sum(call[:2] == ("container", "restart") for call in self.docker.calls), 1)
|
||||
|
||||
def test_creation_uses_cached_runtime_without_allowing_docker_to_pull(self):
|
||||
payload = self.create()
|
||||
creation = next(args for args in self.docker.calls if args[:2] == ("container", "create"))
|
||||
self.assertIn("--pull=never", creation)
|
||||
self.assertEqual(creation[-1], payload["image"])
|
||||
self.assertFalse(any(args[:2] == ("image", "pull") for args in self.docker.calls))
|
||||
|
||||
def test_image_disappearing_after_validation_cannot_be_pulled_or_started(self):
|
||||
original = self.docker.call
|
||||
|
||||
def missing_image(*args, **kwargs):
|
||||
if args[:2] == ("container", "create"):
|
||||
self.assertIn("--pull=never", args)
|
||||
raise AgentError("No such image")
|
||||
return original(*args, **kwargs)
|
||||
|
||||
payload = {"game": "t5", "libraryId": self.library_id, "image": "prepared:runtime", "port": 28960}
|
||||
with patch.object(self.docker, "call", side_effect=missing_image):
|
||||
with self.assertRaisesRegex(AgentError, "No such image"):
|
||||
self.agent.create(INSTANCE, 1, payload)
|
||||
self.assertEqual(self.docker.started, 0)
|
||||
self.assertFalse(any(args[:2] == ("image", "pull") for args in self.docker.calls))
|
||||
|
||||
def test_manifest_is_advertised_and_reconciles_as_a_read_operation(self):
|
||||
self.create()
|
||||
operation = self.operation("files.manifest", {"roots": ["configs", "scripts"], "ignoreNames": [], "paths": ["configs/server.cfg"]})
|
||||
|
||||
Reference in New Issue
Block a user