Skip to content

Commit

Permalink
tests: don't run commands in the server container as root (cvat-ai#6717)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SpecLad authored and jonybekov committed Sep 6, 2023
1 parent 0402397 commit f17b20a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/python/shared/fixtures/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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"
)
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit f17b20a

Please sign in to comment.