Commit b77ce437 authored by Samuel GAIST's avatar Samuel GAIST Committed by André Anjos

[settings] Use /dev/shm for test data(db/prefix)

This allows a nice speedup of the test database and prefix
creation.
parent b23d57a2
...@@ -15,6 +15,7 @@ sphinx/ ...@@ -15,6 +15,7 @@ sphinx/
.mr.developer.cfg .mr.developer.cfg
.coverage .coverage
*.sql3 *.sql3
*.sqlite3
.DS_Store .DS_Store
beat/web/settings/settings.py beat/web/settings/settings.py
src/ src/
......
...@@ -27,6 +27,6 @@ ...@@ -27,6 +27,6 @@
# Django settings for tests on the CI server # Django settings for tests on the CI server
from .test import * from .test import * # noqa
RUNNING_ON_CI = True RUNNING_ON_CI = True
...@@ -26,48 +26,58 @@ ...@@ -26,48 +26,58 @@
############################################################################### ###############################################################################
# Django settings for tests # Django settings for tests
import os
import platform
import sys
from .settings import * from .settings import * # noqa
TEST_CONFIGURATION = True TEST_CONFIGURATION = True
RUNNING_ON_CI = False RUNNING_ON_CI = False
DEBUG = False DEBUG = False
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG TEMPLATES[0]["OPTIONS"]["debug"] = DEBUG # noqa
ALLOWED_HOSTS = [ ALLOWED_HOSTS = ["testserver"]
'testserver',
]
DATABASES['default']['NAME'] = 'test.sql3' if platform.system() == "Linux":
DATABASES['default']['TEST'] = {'NAME': DATABASES['default']['NAME']} database_name = "/dev/shm/beatweb/test.sqlite3" # nosec
DATABASES['default']['OPTIONS']['timeout'] = 30 else:
database_name = "test.sqlite3"
DATABASES["default"]["NAME"] = database_name # noqa
DATABASES["default"]["TEST"] = {"NAME": DATABASES["default"]["NAME"]} # noqa
DATABASES["default"]["OPTIONS"]["timeout"] = 30 # noqa
DATABASES["default"]["ATOMIC_REQUESTS"] = True # noqa
import sys
if 'beat.cmdline' in sys.argv: if "beat.cmdline" in sys.argv:
# make it in-memory for cmdline app tests # make it in-memory for cmdline app tests
DATABASES['default']['NAME'] = ':memory:' DATABASES["default"]["NAME"] = ":memory:" # noqa
LOGGING['handlers']['console']['level'] = 'DEBUG' LOGGING["handlers"]["console"]["level"] = "DEBUG" # noqa
LOGGING['loggers']['beat.core']['handlers'] = ['discard'] LOGGING["loggers"]["beat.core"]["handlers"] = ["discard"] # noqa
LOGGING['loggers']['beat.web']['handlers'] = ['discard'] LOGGING["loggers"]["beat.web"]["handlers"] = ["discard"] # noqa
LOGGING['loggers']['beat.web.utils.management.commands']['handlers'] = ['discard'] LOGGING["loggers"]["beat.web.utils.management.commands"]["handlers"] = [ # noqa
"discard"
]
BASE_DIR = os.path.dirname(os.path.abspath(__name__)) BASE_DIR = os.path.dirname(os.path.abspath(__name__))
PREFIX = os.environ.get('BEAT_TEST_PREFIX', os.path.realpath('./test_prefix')) if platform.system() == "Linux":
ALGORITHMS_ROOT = os.path.join(PREFIX, 'algorithms') default_prefix = "/dev/shm/beatweb/test_prefix" # nosec
PLOTTERS_ROOT = os.path.join(PREFIX, 'plotters') else:
LIBRARIES_ROOT = os.path.join(PREFIX, 'libraries') default_prefix = os.path.realpath("./test_prefix")
DATABASES_ROOT = os.path.join(PREFIX, 'databases') PREFIX = os.environ.get("BEAT_TEST_PREFIX", default_prefix)
DATAFORMATS_ROOT = os.path.join(PREFIX, 'dataformats') ALGORITHMS_ROOT = os.path.join(PREFIX, "algorithms")
TOOLCHAINS_ROOT = os.path.join(PREFIX, 'toolchains') PLOTTERS_ROOT = os.path.join(PREFIX, "plotters")
EXPERIMENTS_ROOT = os.path.join(PREFIX, 'experiments') LIBRARIES_ROOT = os.path.join(PREFIX, "libraries")
CACHE_ROOT = os.path.join(PREFIX, 'cache') 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")
LOCAL_SCHEDULER_VERBOSITY = None LOCAL_SCHEDULER_VERBOSITY = None
LOCAL_SCHEDULER_USE_DOCKER = False LOCAL_SCHEDULER_USE_DOCKER = False
# To speed-up tests, don't put this in production # To speed-up tests, don't put this in production
PASSWORD_HASHERS = [ PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
'django.contrib.auth.hashers.MD5PasswordHasher',
]
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