Import CI enrollment into private NAS runtime during bootstrap
This commit is contained in:
@@ -157,7 +157,11 @@ class BootstrapTests(unittest.TestCase):
|
||||
stop.assert_called_once_with("gitea-ci", ("build-runner",))
|
||||
restore.assert_called_once_with(self.root, self.root / "backup", RUNNER.GITEA_CI_ENTRIES, "stamp")
|
||||
|
||||
def apply_in_synthetic_host(self, fail_health=False):
|
||||
def apply_in_synthetic_host(self, fail_health=False, version="v1"):
|
||||
expected_entries = RUNNER.GITEA_CI_ENTRIES
|
||||
if version == "v2":
|
||||
expected_entries = RUNNER.GITEA_CI_V2_ENTRIES
|
||||
self.artifact.write_bytes(build_artifact.bundle("gitea-ci-bootstrap-v2-test-001"))
|
||||
host = self.root / "host"
|
||||
host.mkdir()
|
||||
names = {name: host / name.lower() for name in (
|
||||
@@ -178,7 +182,7 @@ class BootstrapTests(unittest.TestCase):
|
||||
candidate.write_bytes(self.artifact.read_bytes())
|
||||
|
||||
def start_runtime(*args):
|
||||
self.assertEqual(args, ("gitea-ci", list(RUNNER.GITEA_CI_ENTRIES), ("build-runner",)))
|
||||
self.assertEqual(args, ("gitea-ci", list(expected_entries), ("build-runner",)))
|
||||
(app / "data").mkdir()
|
||||
(app / "data" / "registration-marker").write_text("preserve-on-rollback")
|
||||
|
||||
@@ -227,6 +231,19 @@ class BootstrapTests(unittest.TestCase):
|
||||
self.assertEqual((app / "data/registration-marker").read_text(), "preserve-on-rollback")
|
||||
self.assertNotIn("deploy-ok", output)
|
||||
|
||||
def test_v2_apply_records_distinct_descriptor_and_receipt(self):
|
||||
paths, app, candidate, output = self.apply_in_synthetic_host(version="v2")
|
||||
self.assertTrue((app / "deployment/bootstrap-v2.json").is_file())
|
||||
self.assertFalse((app / "deployment/bootstrap-v1.json").exists())
|
||||
self.assertEqual(json.loads(paths["STATE_FILE"].read_text())["status"], "ok")
|
||||
self.assertIn("deploy-ok patch=gitea-ci-bootstrap-v2-test-001", output)
|
||||
|
||||
def test_v2_failed_health_preserves_identity_and_rolls_back_source(self):
|
||||
paths, app, candidate, output = self.apply_in_synthetic_host(fail_health=True, version="v2")
|
||||
self.assertFalse((app / "deployment/bootstrap-v2.json").exists())
|
||||
self.assertEqual((app / "data/registration-marker").read_text(), "preserve-on-rollback")
|
||||
self.assertEqual(json.loads(paths["FAILED_STATE_FILE"].read_text())["rollback_status"], "ok:gitea-ci-bootstrap")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user