Publish curated Unraid-AppOps-Gateway source from 1a5159c66078983299a1c2acb8837e4b5a8a607a

This commit is contained in:
Public Source Publisher committed 2026-10-10 04:20:16 +00:00
1 parent 75269a32eb
commit 5a3941a286
8 files changed
+443 -23

No files matched your search

@@ -10,6 +10,7 @@ import stat
import subprocess
import sys
import tarfile
import threading
import types
from pathlib import Path
@@ -22,6 +23,50 @@ spec = importlib.util.spec_from_file_location(
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
REVISION = "a" * 40
@pytest.mark.skipif(os.name != "posix", reason="requires real POSIX child/lock contention")
def test_native_probe_cleanup_child_can_wait_beyond_default_command_deadline(monkeypatch, tmp_path):
import fcntl
real_run = subprocess.run
observed = []
def scaled_run(arguments, **options):
observed.append(options["timeout"])
# Keep the real deadline ratio, with a real child and kernel flock;
# the original 45-second budget expires before this owner releases.
options["timeout"] = options["timeout"] / 200
return real_run(arguments, **options)
monkeypatch.setattr(module.subprocess, "run", scaled_run)
path = tmp_path / "probe.lock"
with path.open("w") as owner:
fcntl.flock(owner.fileno(), fcntl.LOCK_EX)
release = threading.Timer(0.4, lambda: fcntl.flock(owner.fileno(), fcntl.LOCK_UN))
release.start()
try:
output = module._run([
sys.executable, "-c",
("import fcntl,sys; f=open(sys.argv[1],'a'); "
"fcntl.flock(f.fileno(),fcntl.LOCK_EX); print('released')"),
str(path),
], max_output=4096, diagnostic_action="probe_cleanup")
finally:
release.join(timeout=2)
assert output == b"released\n"
assert observed == [300]
@pytest.mark.parametrize("action", [None, "writer_copy", "compose_stop"])
def test_unrelated_promotion_commands_keep_existing_deadline(monkeypatch, action):
observed = []
def run(*_, **options):
observed.append(options["timeout"])
return subprocess.CompletedProcess([], 0, b"", b"")
monkeypatch.setattr(module.subprocess, "run", run)
module._run(["fixed-command"], diagnostic_action=action)
assert observed == [45]
OLD_REVISION = "c" * 40
IMAGE_ID = "sha256:" + "b" * 64
ORIGINAL_COMPOSE = b"name: gitea-deploy-runners\nservices:\n deploy-control:\n image: immutable-controller\n"