Merge pull request 'Legacy-Speedtest beim StreamScope-Cutover ersetzen' (#11) from fix/streamscope-legacy-replace into main
This commit is contained in:
commit
c7d7a9af8a
2 changed files with 38 additions and 1 deletions
2
app.py
2
app.py
|
|
@ -1124,7 +1124,7 @@ os.chmod(env, 0o600)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
_ssh(VPS_SSH, rollback, timeout=180)
|
_ssh(VPS_SSH, rollback, timeout=180)
|
||||||
raise RuntimeError(f"StreamScope build preflight failed: {err[-500:]}")
|
raise RuntimeError(f"StreamScope build preflight failed: {err[-500:]}")
|
||||||
deploy = "cd /app-config/github/speedtest && docker compose up -d --remove-orphans"
|
deploy = "cd /app-config/github/speedtest && (docker rm -f speedtest >/dev/null 2>&1 || true) && docker compose up -d --remove-orphans"
|
||||||
rc, out, err = _ssh(VPS_SSH, deploy, timeout=180)
|
rc, out, err = _ssh(VPS_SSH, deploy, timeout=180)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
_ssh(VPS_SSH, rollback, timeout=180)
|
_ssh(VPS_SSH, rollback, timeout=180)
|
||||||
|
|
|
||||||
37
tests/test_streamscope_deploy.py
Normal file
37
tests/test_streamscope_deploy.py
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
import app
|
||||||
|
|
||||||
|
|
||||||
|
def test_streamscope_deploy_replaces_legacy_container_before_compose(monkeypatch):
|
||||||
|
files = {path: "placeholder" for path in app.SPEEDTEST_REPO_FILES}
|
||||||
|
files["compose.yaml"] = """services:
|
||||||
|
streamscope:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- '127.0.0.1:8080:8080'
|
||||||
|
environment:
|
||||||
|
ADMIN_PASSWORD: "${ADMIN_PASSWORD:?required}"
|
||||||
|
SESSION_SECRET: "${SESSION_SECRET:?required}"
|
||||||
|
volumes:
|
||||||
|
- /app-config/speedtest/data:/data
|
||||||
|
cap_add:
|
||||||
|
- NET_RAW
|
||||||
|
"""
|
||||||
|
files["Dockerfile"] = "FROM python:3.13-slim\nRUN apt-get install -y mtr-tiny\n"
|
||||||
|
commands = []
|
||||||
|
|
||||||
|
monkeypatch.setattr(app, "_remote_python", lambda script: (0, "", ""))
|
||||||
|
|
||||||
|
def fake_ssh(host, command, timeout=600):
|
||||||
|
commands.append(command)
|
||||||
|
return 0, "ok", ""
|
||||||
|
|
||||||
|
monkeypatch.setattr(app, "_ssh", fake_ssh)
|
||||||
|
result = app._deploy_speedtest_compose(
|
||||||
|
files,
|
||||||
|
"correct-horse-battery-staple",
|
||||||
|
"streamscope-session-secret-with-entropy",
|
||||||
|
)
|
||||||
|
|
||||||
|
deploy = next(command for command in commands if "compose up -d --remove-orphans" in command)
|
||||||
|
assert "docker rm -f speedtest" in deploy
|
||||||
|
assert result["application"] == "streamscope"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue