1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-08 19:26:48 +00:00
webvirtcloud/webvirtcloud/tests/test_worker_install.py
catborise 837c5468ec build: systemd runs the panel on hosts instead of supervisor
The installer and the manual installation install four systemd units
(webvirt-cloud, webvirt-novncd, webvirt-socketiod, webvirt-worker) that
run as the web server's user with absolute paths and read
/etc/default/webvirtcloud. gunicorn, socketiod and the worker stop with
KillMode=mixed, so they wind down their own children. supervisor, its
installer code and the contributed systemd files go; the README gets
the update, rollback and a one-time move from supervisor, and the
installer refuses to run over a supervisor install. Docker keeps runit;
novncd's runit script is the one-line form of the others.
2026-10-17 23:18:26 +03:00

34 lines
1.6 KiB
Python

"""Every install type runs the worker as the web server's user (www-data, or
nginx where the installer and README substitute it), with its own log file
and a stop timeout above the worker's 60 s grace."""
from pathlib import Path
from django.conf import settings
from django.test import SimpleTestCase
BASE = Path(settings.BASE_DIR)
class WorkerInstallTestCase(SimpleTestCase):
def test_docker(self):
dockerfile = (BASE / "Dockerfile").read_text()
self.assertIn("conf/runit/webvirtcloud-worker.sh", dockerfile)
self.assertIn("/etc/service/webvirtcloud-worker/run", dockerfile)
script = (BASE / "conf/runit/webvirtcloud-worker.sh").read_text()
for text in ("/sbin/setuser www-data", "manage.py run_worker",
"WEBVIRTCLOUD_LOG_FILE=/srv/webvirtcloud/data/webvirtcloud-worker.log"):
self.assertIn(text, script)
self.assertIn("ENV KILL_PROCESS_TIMEOUT=80", dockerfile)
compose = (BASE / "docker-compose.yml").read_text()
self.assertRegex(compose, r"stop_grace_period:\s*9\ds")
# the worker's host identity lives in the data volume, not in a fixed hostname
self.assertIn("webvirtcloud-data:/srv/webvirtcloud/data", compose)
self.assertNotIn("hostname:", compose)
def test_systemd(self):
unit = (BASE / "conf/systemd/webvirt-worker.service").read_text()
for text in ("manage.py run_worker", "User=www-data", "webvirtcloud-worker.log", "KillMode=mixed",
"EnvironmentFile=-/etc/default/webvirtcloud", "Restart=on-failure"):
self.assertIn(text, unit)
self.assertRegex(unit, r"TimeoutStopSec=9\d")