Update docs and screenshots
CI / backend (pull_request) Canceled after 0s
CI / shell (pull_request) Canceled after 0s
CI / frontend (pull_request) Canceled after 0s
CI / arm64-smoke (pull_request) Canceled after 0s
CI / backend (push) Canceled after 0s
CI / shell (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CI / arm64-smoke (push) Canceled after 0s
CI / backend (pull_request) Canceled after 0s
CI / shell (pull_request) Canceled after 0s
CI / frontend (pull_request) Canceled after 0s
CI / arm64-smoke (pull_request) Canceled after 0s
CI / backend (push) Canceled after 0s
CI / shell (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CI / arm64-smoke (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,156 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SCRIPTS_DIR = ROOT / "scripts"
|
||||
|
||||
|
||||
def read_script(name: str) -> str:
|
||||
return (SCRIPTS_DIR / name).read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_install_linux_script_exists_and_supports_required_flags() -> None:
|
||||
script = read_script("install-linux.sh")
|
||||
assert 'parse_common_args "$@"' in script
|
||||
assert "verify_debian_13_amd64" in script
|
||||
assert 'run_install_flow "Debian 13 amd64"' in script
|
||||
|
||||
|
||||
def test_update_linux_script_exists_and_uses_common_arg_parser() -> None:
|
||||
script = read_script("update-linux.sh")
|
||||
assert 'parse_common_args "$@"' in script
|
||||
assert "verify_debian_13_amd64" in script
|
||||
assert 'run_update_flow "Debian 13 amd64"' in script
|
||||
|
||||
|
||||
def test_common_install_library_contains_required_linux_behaviour() -> None:
|
||||
script = read_script("lib/install-common.sh")
|
||||
assert "python3-venv" in script
|
||||
assert "sqlite3" in script
|
||||
assert "sudo" in script
|
||||
assert "nodejs" in script
|
||||
assert "npm" in script
|
||||
assert "python3-ola" in script
|
||||
assert "ola-python" in script
|
||||
assert "olad" in script
|
||||
assert 'PNPM_REQUIRED_VERSION="10.28.2"' in script
|
||||
assert "--system-site-packages" in script
|
||||
assert "/opt/tuxdmx.new" in script
|
||||
assert "/opt/tuxdmx" in script
|
||||
assert "/var/lib/tuxdmx" in script
|
||||
assert "/var/log/tuxdmx" in script
|
||||
assert "/etc/tuxdmx" in script
|
||||
assert "dialout,plugdev,audio" in script
|
||||
assert "frontend/dist/index.html" in script
|
||||
assert "pip\" check" in script
|
||||
assert "apt-listchanges" in script
|
||||
assert "debconf" in script
|
||||
assert "Ignorerer kendt Debian pip check-advarsel" in script
|
||||
assert "import greenlet" in script
|
||||
assert "import sqlalchemy" in script
|
||||
assert "import ola" in script
|
||||
assert "backend/app/main.py" in script
|
||||
assert "systemctl status \"$SYSTEMD_UNIT_NAME\" --no-pager --full" in script
|
||||
assert "journalctl -u \"$SYSTEMD_UNIT_NAME\" -n 200 --no-pager" in script
|
||||
assert "update-rc.d" in script
|
||||
assert "systemctl is-enabled \"$OLA_SYSTEMD_UNIT\"" in script
|
||||
assert "service \"$OLA_SERVICE_NAME\" restart" in script
|
||||
assert "--warning=no-file-changed" in script
|
||||
assert "--exclude=\"./tuxdmx.json.log\"" in script
|
||||
assert "Kunne ikke oprette backup af datamappe." in script
|
||||
assert "http://127.0.0.1:8000/api/v1/health" in script
|
||||
assert "/etc/sudoers.d/tuxdmx-control" in script
|
||||
assert "control-system.sh restart-service" in script
|
||||
assert "control-system.sh reboot-host" in script
|
||||
assert "restore_rollbacks" in script
|
||||
|
||||
|
||||
def test_pi_and_linux_installers_share_common_library() -> None:
|
||||
for name in (
|
||||
"install-pi.sh",
|
||||
"install-linux.sh",
|
||||
"update-pi.sh",
|
||||
"update-linux.sh",
|
||||
):
|
||||
script = read_script(name)
|
||||
assert 'source "$SCRIPT_DIR/lib/install-common.sh"' in script
|
||||
|
||||
|
||||
def test_systemd_unit_contains_required_production_fields() -> None:
|
||||
unit = (ROOT / "systemd" / "tuxdmx.service").read_text(encoding="utf-8")
|
||||
assert "WorkingDirectory=/opt/tuxdmx" in unit
|
||||
assert "After=network-online.target olad.service" in unit
|
||||
assert "Wants=network-online.target olad.service" in unit
|
||||
assert "Restart=on-failure" in unit
|
||||
assert "UMask=0027" in unit
|
||||
|
||||
|
||||
def test_alembic_ini_uses_path_relative_to_config_file() -> None:
|
||||
alembic_ini = (ROOT / "backend" / "alembic.ini").read_text(encoding="utf-8")
|
||||
assert "script_location = %(here)s/alembic" in alembic_ini
|
||||
|
||||
|
||||
def test_package_manager_and_requirements_are_locked() -> None:
|
||||
package_json = json.loads((ROOT / "package.json").read_text(encoding="utf-8"))
|
||||
assert package_json["packageManager"] == "pnpm@10.28.2"
|
||||
assert package_json["engines"]["node"] == "20.x"
|
||||
assert package_json["engines"]["pnpm"] == "10.28.2"
|
||||
|
||||
requirements = (ROOT / "requirements.lock").read_text(encoding="utf-8")
|
||||
assert "greenlet==" in requirements
|
||||
assert "sqlalchemy==" in requirements
|
||||
|
||||
|
||||
def test_shell_scripts_parse_with_bash_when_available() -> None:
|
||||
bash = shutil.which("bash")
|
||||
if bash is None:
|
||||
return
|
||||
if "system32\\bash.exe" in bash.lower():
|
||||
return
|
||||
|
||||
for script_name in (
|
||||
"scripts/install-pi.sh",
|
||||
"scripts/update-pi.sh",
|
||||
"scripts/install-linux.sh",
|
||||
"scripts/update-linux.sh",
|
||||
"scripts/uninstall-linux.sh",
|
||||
"scripts/lib/install-common.sh",
|
||||
):
|
||||
subprocess.run(
|
||||
[bash, "-n", str(ROOT / script_name)],
|
||||
check=True,
|
||||
cwd=ROOT,
|
||||
)
|
||||
|
||||
|
||||
def test_shellcheck_when_available() -> None:
|
||||
shellcheck = shutil.which("shellcheck")
|
||||
if shellcheck is None:
|
||||
return
|
||||
|
||||
subprocess.run(
|
||||
[
|
||||
shellcheck,
|
||||
str(ROOT / "scripts/install-pi.sh"),
|
||||
str(ROOT / "scripts/update-pi.sh"),
|
||||
str(ROOT / "scripts/install-linux.sh"),
|
||||
str(ROOT / "scripts/update-linux.sh"),
|
||||
str(ROOT / "scripts/lib/install-common.sh"),
|
||||
],
|
||||
check=True,
|
||||
cwd=ROOT,
|
||||
)
|
||||
|
||||
|
||||
def test_pip_check_and_greenlet_import() -> None:
|
||||
subprocess.run([sys.executable, "-m", "pip", "check"], check=True, cwd=ROOT)
|
||||
subprocess.run(
|
||||
[sys.executable, "-c", "import greenlet; print(greenlet.__version__)"],
|
||||
check=True,
|
||||
cwd=ROOT,
|
||||
)
|
||||
Reference in New Issue
Block a user