Publish curated Unraid-AppOps-Gateway source from b6d6a3e1657000c6e0a482c8056a3fbebbafd711
This commit is contained in:
1 parent
2d50064a8f
commit
d825f5045d
11 files changed
+438
-43
No files matched your search
@@ -37,6 +37,7 @@ CALLER_ID = "c" * 64
|
||||
MODERN_HELPER_ID = "f" * 64
|
||||
RETIRED_HELPER_ID = bootstrap.RETIRED_FAILED_MODERN_HELPER_ID
|
||||
HOST_HOSTNAME = "Tower"
|
||||
RETIRED_MODERN_HELPER_SOURCE = (ROOT / "backend/tests/fixtures/controller_artifact_helper_spec_2_1_14.txt").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
LEGACY_HELPER_SOURCE_FIXTURE = '''
|
||||
@@ -570,6 +571,8 @@ class FakeProtectedGit:
|
||||
self.blobs_read.append((revision, path))
|
||||
if revision not in {self.revision, bootstrap.RETIRED_FAILED_MODERN_REVISION} or path != "backend/app/services/controller_artifact_helper_spec.py":
|
||||
raise bootstrap.BootstrapError("controller_promoter_source_blob_invalid")
|
||||
if revision == bootstrap.RETIRED_FAILED_MODERN_REVISION:
|
||||
return RETIRED_MODERN_HELPER_SOURCE.encode("utf-8")
|
||||
return self.helper_source.encode("utf-8")
|
||||
|
||||
def read_legacy_blob(self, revision: str, path: str) -> bytes:
|
||||
@@ -586,7 +589,7 @@ def _health(
|
||||
*,
|
||||
revision: str = REVISION,
|
||||
tree: str = TREE,
|
||||
version: str = "2.1.14",
|
||||
version: str = "2.1.17",
|
||||
artifact_sha256: str = "1" * 64,
|
||||
) -> dict[str, Any]:
|
||||
return {
|
||||
@@ -829,15 +832,16 @@ def test_controller_source_provenance_failure_precedes_health_and_side_effects()
|
||||
assert docker.started == []
|
||||
|
||||
|
||||
def _retired_failed_child(helper_source: str) -> dict[str, Any]:
|
||||
def _retired_failed_child() -> dict[str, Any]:
|
||||
spec = bootstrap.render_modern_helper_spec(
|
||||
helper_source,
|
||||
RETIRED_MODERN_HELPER_SOURCE,
|
||||
revision=bootstrap.RETIRED_FAILED_MODERN_REVISION,
|
||||
image_id=CONTROLLER_IMAGE_ID,
|
||||
current_controller_id=CONTROLLER_CONTAINER_ID,
|
||||
current_controller_revision=CONTROLLER_REVISION,
|
||||
current_controller_tree=CONTROLLER_TREE,
|
||||
current_controller_version="2.1.12",
|
||||
helper_version="2.1.14",
|
||||
)
|
||||
child = _inspect_from_spec(
|
||||
"itworx-controller-artifact-promoter-modern",
|
||||
@@ -1295,7 +1299,7 @@ def test_exact_failed_historical_child_is_removed_before_current_helper_launch()
|
||||
version="2.1.12",
|
||||
artifact_sha256=bootstrap.LEGACY_CONTROLLER_ARTIFACT_SHA256,
|
||||
)
|
||||
failed_child = _retired_failed_child(helper_source)
|
||||
failed_child = _retired_failed_child()
|
||||
docker = FakeDocker(_legacy_helper_spec(), existing_child=failed_child)
|
||||
git = FakeProtectedGit(helper_source)
|
||||
|
||||
@@ -1343,7 +1347,7 @@ def test_current_214_baseline_is_verified_and_bound_to_new_helper():
|
||||
"itworx.controller.promoter": "true",
|
||||
"itworx.source.repository": "jens/unraid-appops-gateway",
|
||||
"itworx.source.revision": REVISION,
|
||||
"itworx.controller.version": "2.1.14",
|
||||
"itworx.controller.version": "2.1.17",
|
||||
"itworx.controller.bootstrap.target.id": MODERN_CONTROLLER_CONTAINER_ID,
|
||||
"itworx.controller.bootstrap.target.image": CONTROLLER_IMAGE_ID,
|
||||
"itworx.controller.bootstrap.target.revision": MODERN_CONTROLLER_REVISION,
|
||||
@@ -1356,7 +1360,7 @@ def test_retired_failed_child_is_removed_only_after_current_214_profile_rechecks
|
||||
helper_source = (ROOT / "backend/app/services/controller_artifact_helper_spec.py").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
failed_child = _retired_failed_child(helper_source)
|
||||
failed_child = _retired_failed_child()
|
||||
docker = FakeDocker(_legacy_helper_spec(), existing_child=failed_child)
|
||||
docker.containers["gitea-deploy-control"] = _modern_controller_source_inspect(
|
||||
MODERN_CONTROLLER_REVISION
|
||||
@@ -1417,7 +1421,7 @@ def test_retired_cleanup_refuses_any_current_214_identity_or_topology_drift(muta
|
||||
helper_source = (ROOT / "backend/app/services/controller_artifact_helper_spec.py").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
failed_child = _retired_failed_child(helper_source)
|
||||
failed_child = _retired_failed_child()
|
||||
docker = FakeDocker(_legacy_helper_spec(), existing_child=failed_child)
|
||||
controller = _modern_controller_source_inspect(MODERN_CONTROLLER_REVISION)
|
||||
health = _modern_baseline_health()
|
||||
@@ -1515,7 +1519,7 @@ def test_retired_helper_cleanup_fails_closed_on_any_identity_or_state_drift(muta
|
||||
helper_source = (ROOT / "backend/app/services/controller_artifact_helper_spec.py").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
failed_child = _retired_failed_child(helper_source)
|
||||
failed_child = _retired_failed_child()
|
||||
docker = FakeDocker(_legacy_helper_spec(), existing_child=failed_child)
|
||||
git = FakeProtectedGit(helper_source)
|
||||
if mutation == "running":
|
||||
@@ -1614,7 +1618,7 @@ def test_same_failed_source_revision_is_never_retried_or_removed():
|
||||
)
|
||||
docker = FakeDocker(
|
||||
_legacy_helper_spec(bootstrap.RETIRED_FAILED_MODERN_REVISION),
|
||||
existing_child=_retired_failed_child(helper_source),
|
||||
existing_child=_retired_failed_child(),
|
||||
)
|
||||
git = FakeProtectedGit(helper_source)
|
||||
git.revision = bootstrap.RETIRED_FAILED_MODERN_REVISION
|
||||
@@ -1626,16 +1630,14 @@ def test_same_failed_source_revision_is_never_retried_or_removed():
|
||||
artifact_sha256=bootstrap.LEGACY_CONTROLLER_ARTIFACT_SHA256,
|
||||
)
|
||||
|
||||
result = _run_bootstrap(
|
||||
docker,
|
||||
git,
|
||||
health_sequence=[legacy_health],
|
||||
source_revision=git.revision,
|
||||
source_tree=git.tree,
|
||||
)
|
||||
|
||||
assert result["status"] == "failed"
|
||||
assert result["exitCode"] == 1
|
||||
with pytest.raises(bootstrap.BootstrapError, match="controller_promoter_retired_helper_retry_refused"):
|
||||
_run_bootstrap(
|
||||
docker,
|
||||
git,
|
||||
health_sequence=[legacy_health],
|
||||
source_revision=git.revision,
|
||||
source_tree=git.tree,
|
||||
)
|
||||
assert docker.removed == []
|
||||
assert docker.created == []
|
||||
|
||||
@@ -1824,7 +1826,7 @@ def test_successful_child_requires_exact_source_tree_version_and_health():
|
||||
|
||||
assert result["status"] == "promoted"
|
||||
assert result["revision"] == REVISION
|
||||
assert result["controllerVersion"] == "2.1.14"
|
||||
assert result["controllerVersion"] == "2.1.17"
|
||||
assert result["artifactSha256"] == "1" * 64
|
||||
assert docker.started == [MODERN_HELPER_ID]
|
||||
assert docker.created[0]["Image"] == CONTROLLER_IMAGE_ID
|
||||
@@ -2079,3 +2081,29 @@ def test_modern_upgrade_path_still_requires_private_archive_and_image_id(
|
||||
assert "archive is outside the helper private temporary directory" in result.stderr
|
||||
if modern_call == "missing-image":
|
||||
assert "image ID" in result.stderr
|
||||
|
||||
|
||||
def test_current_helper_version_is_distinct_from_fixed_controller_baselines():
|
||||
source = (ROOT / "backend/app/services/controller_artifact_helper_spec.py").read_bytes()
|
||||
namespace = bootstrap._safe_modern_spec_namespace(source)
|
||||
assert namespace["CONTROLLER_VERSION"] == "2.1.17"
|
||||
assert bootstrap._verified_historical_helper_version(source) == "2.1.17"
|
||||
assert [baseline.version for baseline in bootstrap.CONTROLLER_BASELINES] == ["2.1.12", "2.1.14"]
|
||||
with pytest.raises(bootstrap.BootstrapError, match="controller_promoter_modern_spec_identity_invalid"):
|
||||
bootstrap._safe_modern_spec_namespace(RETIRED_MODERN_HELPER_SOURCE.encode("utf-8"))
|
||||
assert bootstrap._verified_historical_helper_version(RETIRED_MODERN_HELPER_SOURCE.encode("utf-8")) == "2.1.14"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("version", ["2.1.16", "2.1.18", "9.9.9"])
|
||||
def test_current_and_historical_helper_reject_unreviewed_target_versions(version):
|
||||
source = (ROOT / "backend/app/services/controller_artifact_helper_spec.py").read_bytes()
|
||||
foreign = source.replace(b'CONTROLLER_VERSION = "2.1.17"', f'CONTROLLER_VERSION = "{version}"'.encode())
|
||||
with pytest.raises(bootstrap.BootstrapError, match="controller_promoter_modern_spec_identity_invalid"):
|
||||
bootstrap._safe_modern_spec_namespace(foreign)
|
||||
with pytest.raises(bootstrap.BootstrapError, match="controller_promoter_modern_spec_identity_invalid"):
|
||||
bootstrap._verified_historical_helper_version(foreign)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("version", ["2.1.14", "2.1.16", "2.1.18"])
|
||||
def test_promoted_health_cannot_substitute_a_baseline_or_unknown_version(version):
|
||||
assert not bootstrap._health_matches(_health(version=version), REVISION, TREE)
|
||||
Reference in new issue
Block a user