91 lines
3.2 KiB
Python
91 lines
3.2 KiB
Python
"""Regressietests voor de infrastructuur- en beheerapps uit v0.8.17."""
|
|
import json
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
|
|
WORTEL = Path(__file__).resolve().parent.parent
|
|
APPS = WORTEL / "apps"
|
|
|
|
NIEUWE_APPS = {
|
|
"activepieces",
|
|
"consul",
|
|
"guacamole",
|
|
"lldap",
|
|
"meshcentral",
|
|
"nomad-server",
|
|
"openobserve",
|
|
"pairdrop",
|
|
"rustdesk-server",
|
|
"victoriametrics",
|
|
"windmill",
|
|
}
|
|
|
|
|
|
def _template(app: str) -> dict:
|
|
return json.loads((APPS / app / "template.json").read_text(encoding="utf-8"))
|
|
|
|
|
|
def test_alle_geselecteerde_apps_staan_in_de_catalogus():
|
|
aanwezig = {pad.name for pad in APPS.iterdir() if pad.is_dir()}
|
|
assert NIEUWE_APPS <= aanwezig
|
|
|
|
|
|
@pytest.mark.parametrize("app", sorted(NIEUWE_APPS))
|
|
def test_nieuwe_apps_ondersteunen_pi_en_x86(app):
|
|
architecturen = set(_template(app)["metadata"]["architectures"])
|
|
assert {"amd64", "arm64"} <= architecturen
|
|
|
|
|
|
def test_nomad_container_is_alleen_control_plane():
|
|
compose = (APPS / "nomad-server" / "files" / "compose.yaml").read_text()
|
|
config = (APPS / "nomad-server" / "files" / "server.hcl").read_text()
|
|
assert "-config=/nomad/config/server.hcl" in compose
|
|
assert "enabled = false" in config
|
|
assert "enabled = true" in config
|
|
regels = {" ".join(regel.split()) for regel in config.splitlines()}
|
|
for adres in ("http", "rpc", "serf"):
|
|
assert any(regel.startswith(f'{adres} = "<< advertise_ip >>:') for regel in regels)
|
|
assert "/var/run/docker.sock" not in compose
|
|
assert "privileged:" not in compose
|
|
|
|
|
|
def test_clusterapps_adverteren_het_bereikbare_hostadres():
|
|
for app in ("nomad-server", "consul"):
|
|
velden = {
|
|
item["name"]: item
|
|
for groep in _template(app)["variables"]
|
|
for item in groep["items"]
|
|
}
|
|
assert velden["advertise_ip"]["required"] is True
|
|
assert velden["advertise_ip"]["default"] == ""
|
|
if app == "nomad-server":
|
|
bron = (APPS / app / "files" / "server.hcl").read_text()
|
|
else:
|
|
bron = (APPS / app / "files" / "compose.yaml").read_text()
|
|
assert "<< advertise_ip >>" in bron
|
|
|
|
|
|
def test_interne_databasewachtwoorden_worden_automatisch_gemaakt():
|
|
for app in ("guacamole", "windmill"):
|
|
velden = [item for groep in _template(app)["variables"] for item in groep["items"]]
|
|
assert next(item for item in velden if item["name"] == "db_password")["generate"] == "auto"
|
|
|
|
|
|
def test_guacamole_initialiseert_database_voor_de_webapp_start():
|
|
compose = (APPS / "guacamole" / "files" / "compose.yaml").read_text()
|
|
assert "initdb.sh --postgresql" in compose
|
|
assert "condition: service_completed_successfully" in compose
|
|
assert "condition: service_healthy" in compose
|
|
|
|
|
|
def test_meshcentral_krijgt_een_bereikbare_https_configuratie():
|
|
config = (APPS / "meshcentral" / "files" / "config.json").read_text()
|
|
config = json.loads(config.replace("<< hostname >>", "mesh.example.nl"))
|
|
assert config["settings"]["cert"] == "mesh.example.nl"
|
|
assert config["settings"]["port"] == 443
|
|
assert config["domains"][""]["newAccounts"] is True
|
|
|
|
compose = (APPS / "meshcentral" / "files" / "compose.yaml").read_text()
|
|
assert '"<< port >>:443"' in compose
|