test: probe hardlink staging in deployment preflight
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import importlib.util
|
||||
import sys
|
||||
import unittest
|
||||
from unittest import mock
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@@ -49,6 +50,24 @@ class DeploymentPreflightTests(unittest.TestCase):
|
||||
"/data/qb/.archive-control-routes",
|
||||
)
|
||||
|
||||
def test_runs_hardlink_probe_with_qb_and_route_roots(self):
|
||||
completed = __import__("subprocess").CompletedProcess(
|
||||
args=[], returncode=0, stdout="hard-link staging probe passed\n", stderr=""
|
||||
)
|
||||
with mock.patch.object(preflight.subprocess, "run", return_value=completed) as run:
|
||||
preflight.run_hardlink_probe("client", "/data/qb", "/data/qb/routes")
|
||||
args = run.call_args.args[0]
|
||||
self.assertEqual(args[:5], ["docker", "exec", "client", "python", "-c"])
|
||||
self.assertEqual(args[-2:], ["/data/qb", "/data/qb/routes"])
|
||||
|
||||
def test_hardlink_probe_failure_is_actionable(self):
|
||||
completed = __import__("subprocess").CompletedProcess(
|
||||
args=[], returncode=1, stdout="", stderr="[Errno 18] Invalid cross-device link"
|
||||
)
|
||||
with mock.patch.object(preflight.subprocess, "run", return_value=completed):
|
||||
with self.assertRaisesRegex(preflight.CheckFailure, "hard-link staging probe failed"):
|
||||
preflight.run_hardlink_probe("client", "/data/qb", "/data/qb/routes")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user