From 94e04babec3c3908a634f72edd9e077bd7ed9453 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Mon, 21 Aug 2023 13:41:53 +0300 Subject: [PATCH] tests: don't run commands in the server container as root I encountered an issue where the server process fails at startup due to being unable to create `/home/django/cache/events`, due to `/home/django/cache` being owned by `root`. I'm not sure how exactly that happened, but there are several commands involving Django or CVAT data that the test suite runs as root, and it had to be one of them that caused it. I don't think there's any reason to run these commands as root, so use `docker_exec_cvat` for them instead of `docker_exec`. This way, they will run as the Django user instead. --- tests/python/shared/fixtures/init.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/python/shared/fixtures/init.py b/tests/python/shared/fixtures/init.py index ae849db92031..801fa609e4f6 100644 --- a/tests/python/shared/fixtures/init.py +++ b/tests/python/shared/fixtures/init.py @@ -279,7 +279,7 @@ def docker_restore_data_volumes(): CVAT_DB_DIR / "cvat_data.tar.bz2", f"{PREFIX}_cvat_server_1:/tmp/cvat_data.tar.bz2", ) - docker_exec(Container.SERVER, "tar --strip 3 -xjf /tmp/cvat_data.tar.bz2 -C /home/django/data/") + docker_exec_cvat("tar --strip 3 -xjf /tmp/cvat_data.tar.bz2 -C /home/django/data/") def kube_restore_data_volumes(): @@ -403,7 +403,7 @@ def local_start(start, stop, dumpdb, cleanup, rebuild, cvat_root_dir, cvat_db_di docker_cp(cvat_db_dir / "data.json", f"{PREFIX}_cvat_server_1:/tmp/data.json") wait_for_services() - docker_exec(Container.SERVER, "python manage.py loaddata /tmp/data.json") + docker_exec_cvat("python manage.py loaddata /tmp/data.json") docker_exec( Container.DB, "psql -U root -d postgres -v from=cvat -v to=test_db -f /tmp/restore.sql" ) @@ -455,7 +455,7 @@ def session_finish(session): docker_exec(Container.DB, "dropdb --if-exists cvat") docker_exec(Container.DB, "createdb cvat") - docker_exec(Container.SERVER, "python manage.py migrate") + docker_exec_cvat("python manage.py migrate") def collect_code_coverage_from_containers():