Commit 57e5b287 authored by Samuel GAIST's avatar Samuel GAIST

[test] Initialize and cleanup the test database root folder

This will avoid the docker daemon to create them
and make them belong to it and thus not properly
accessible if the daemon is root.
parent 98f0d791
......@@ -44,6 +44,8 @@ import tempfile
import pkg_resources
from beat.backend.python.test import BBP_DATABASE_ROOT_FOLDER
if sys.platform == "darwin":
tmp_prefix = tempfile.mkdtemp(
prefix=__name__, suffix=".tmpdir", dir="/tmp" # nosec
......@@ -56,6 +58,8 @@ else:
prefix_folder = tempfile.mkdtemp(prefix=__name__, suffix=".prefix")
BC_DATABASE_ROOT_FOLDER = "/tmp/beat_core_test" # nosec
prefix = os.path.join(prefix_folder, "prefix")
DOCKER_NETWORK_TEST_ENABLED = (
......@@ -93,6 +97,9 @@ def setup_package():
for path in prefixes:
sp.check_call(["rsync", "-arz", path, prefix_folder])
for path in [BBP_DATABASE_ROOT_FOLDER, BC_DATABASE_ROOT_FOLDER]:
os.makedirs(path, exist_ok=True)
if DOCKER_NETWORK_TEST_ENABLED:
import docker
......@@ -117,7 +124,8 @@ def teardown_package():
if os.path.exists(tmp_prefix):
shutil.rmtree(tmp_prefix)
shutil.rmtree(prefix_folder)
for path in [prefix_folder, BBP_DATABASE_ROOT_FOLDER, BC_DATABASE_ROOT_FOLDER]:
shutil.rmtree(path)
if DOCKER_NETWORK_TEST_ENABLED:
global network
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment