Skip to content
Snippets Groups Projects
Commit a6edb816 authored by Flavio TARSETTI's avatar Flavio TARSETTI
Browse files

Merge branch 'fix_parallel_testing_on_ci' into 'master'

Fix parallel testing on ci

See merge request !330
parents 498bb740 facb5d83
No related branches found
No related tags found
1 merge request!330Fix parallel testing on ci
Pipeline #39737 passed
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
###############################################################################
# #
# Copyright (c) 2020 Idiap Research Institute, http://www.idiap.ch/ #
# Contact: beat.support@idiap.ch #
# #
# This file is part of the beat.web module of the BEAT platform. #
# #
# Commercial License Usage #
# Licensees holding valid commercial BEAT licenses may use this file in #
# accordance with the terms contained in a written agreement between you #
# and Idiap. For further information contact tto@idiap.ch #
# #
# Alternatively, this file may be used under the terms of the GNU Affero #
# Public License version 3 as published by the Free Software and appearing #
# in the file LICENSE.AGPL included in the packaging of this file. #
# The BEAT platform is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
# or FITNESS FOR A PARTICULAR PURPOSE. #
# #
# You should have received a copy of the GNU Affero Public License along #
# with the BEAT platform. If not, see http://www.gnu.org/licenses/. #
# #
###############################################################################
import os
import platform
SHM_PATH = "/dev/shm/beatweb" # nosec
def get_test_db_path(is_on_ci):
database_name = "test.sqlite3"
database_path = os.path.realpath("./")
if not is_on_ci:
if platform.system() == "Linux":
database_path = SHM_PATH
if not os.path.exists(database_path):
os.makedirs(database_path)
return os.path.join(database_path, database_name)
def get_test_prefix_path(is_on_ci):
prefix_path = os.path.realpath("./test_prefix")
if not is_on_ci:
if platform.system() == "Linux":
prefix_path = os.path.join(SHM_PATH, "test_prefix") # nosec
return prefix_path
......@@ -26,8 +26,23 @@
###############################################################################
# Django settings for tests on the CI server
import os
from .test import * # noqa
from . import get_test_db_path
from . import get_test_prefix_path
RUNNING_ON_CI = True
DATABASES["default"]["OPTIONS"]["timeout"] = 60 # noqa
DATABASES["default"]["NAME"] = get_test_db_path(RUNNING_ON_CI) # noqa
DATABASES["default"]["TEST"] = {"NAME": DATABASES["default"]["NAME"]} # noqa
PREFIX = os.environ.get("BEAT_TEST_PREFIX", get_test_prefix_path(RUNNING_ON_CI))
ALGORITHMS_ROOT = os.path.join(PREFIX, "algorithms")
PLOTTERS_ROOT = os.path.join(PREFIX, "plotters")
LIBRARIES_ROOT = os.path.join(PREFIX, "libraries")
DATABASES_ROOT = os.path.join(PREFIX, "databases")
DATAFORMATS_ROOT = os.path.join(PREFIX, "dataformats")
TOOLCHAINS_ROOT = os.path.join(PREFIX, "toolchains")
EXPERIMENTS_ROOT = os.path.join(PREFIX, "experiments")
CACHE_ROOT = os.path.join(PREFIX, "cache")
......@@ -27,9 +27,10 @@
# Django settings for tests
import os
import platform
from .settings import * # noqa
from . import get_test_db_path
from . import get_test_prefix_path
URL_PREFIX = ""
......@@ -41,17 +42,7 @@ TEMPLATES[0]["OPTIONS"]["debug"] = DEBUG # noqa
ALLOWED_HOSTS = ["testserver"]
if platform.system() == "Linux":
shm_path = "/dev/shm/beatweb" # nosec
if not os.path.exists(shm_path):
os.makedirs(shm_path)
database_name = os.path.join(shm_path, "test.sqlite3")
else:
here = os.path.dirname(os.path.realpath(__file__))
database_name = os.path.join(here, "test.sqlite3")
DATABASES["default"]["NAME"] = database_name # noqa
DATABASES["default"]["NAME"] = get_test_db_path(RUNNING_ON_CI) # noqa
DATABASES["default"]["TEST"] = {"NAME": DATABASES["default"]["NAME"]} # noqa
DATABASES["default"]["OPTIONS"]["timeout"] = 30 # noqa
DATABASES["default"]["ATOMIC_REQUESTS"] = True # noqa
......@@ -67,11 +58,7 @@ LOGGING["loggers"]["beat.web.utils.management.commands"]["handlers"] = [ # noqa
]
BASE_DIR = os.path.dirname(os.path.abspath(__name__))
if platform.system() == "Linux":
default_prefix = os.path.join(shm_path, "test_prefix") # nosec
else:
default_prefix = os.path.realpath("./test_prefix")
PREFIX = os.environ.get("BEAT_TEST_PREFIX", default_prefix)
PREFIX = os.environ.get("BEAT_TEST_PREFIX", get_test_prefix_path(RUNNING_ON_CI))
ALGORITHMS_ROOT = os.path.join(PREFIX, "algorithms")
PLOTTERS_ROOT = os.path.join(PREFIX, "plotters")
LIBRARIES_ROOT = os.path.join(PREFIX, "libraries")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment