From 1eaa0317c49bd265d998f50b7aa7a5c915eac744 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Tue, 9 Jul 2013 08:57:05 -0400 Subject: [PATCH] Using parent process id for random number This is to allow acceptance tests to properly link and know the names of its other parts --- cms/envs/acceptance.py | 14 +++++++++----- lms/envs/acceptance.py | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/cms/envs/acceptance.py b/cms/envs/acceptance.py index 40d5894378..556687af7e 100644 --- a/cms/envs/acceptance.py +++ b/cms/envs/acceptance.py @@ -16,13 +16,17 @@ DEBUG = True # Disable warnings for acceptance tests, to make the logs readable import logging logging.disable(logging.ERROR) -from uuid import uuid4 +import os + + +def seed(): + return os.getppid() MODULESTORE_OPTIONS = { 'default_class': 'xmodule.raw_module.RawDescriptor', 'host': 'localhost', 'db': 'test_xmodule', - 'collection': 'acceptance_modulestore_%s' % uuid4().hex, + 'collection': 'acceptance_modulestore_%s' % seed(), 'fs_root': TEST_ROOT / "data", 'render_template': 'mitxmako.shortcuts.render_to_string', } @@ -46,7 +50,7 @@ CONTENTSTORE = { 'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore', 'OPTIONS': { 'host': 'localhost', - 'db': 'acceptance_xcontent_%s' % uuid4().hex, + 'db': 'acceptance_xcontent_%s' % seed(), }, # allow for additional options that can be keyed on a name, e.g. 'trashcan' 'ADDITIONAL_OPTIONS': { @@ -62,8 +66,8 @@ CONTENTSTORE = { DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': TEST_ROOT / "db" / "test_mitx.db", - 'TEST_NAME': TEST_ROOT / "db" / "test_mitx.db", + 'NAME': TEST_ROOT / "db" / "test_mitx_%s.db" % seed(), + 'TEST_NAME': TEST_ROOT / "db" / "test_mitx_%s.db" % seed(), } } diff --git a/lms/envs/acceptance.py b/lms/envs/acceptance.py index be604eea8d..ddc1679c37 100644 --- a/lms/envs/acceptance.py +++ b/lms/envs/acceptance.py @@ -16,14 +16,18 @@ DEBUG = True # Disable warnings for acceptance tests, to make the logs readable import logging logging.disable(logging.ERROR) -from uuid import uuid4 +import os + + +def seed(): + return os.getppid() # Use the mongo store for acceptance tests modulestore_options = { 'default_class': 'xmodule.raw_module.RawDescriptor', 'host': 'localhost', 'db': 'test_xmodule', - 'collection': 'acceptance_modulestore_%s' % uuid4().hex, + 'collection': 'acceptance_modulestore_%s' % seed(), 'fs_root': TEST_ROOT / "data", 'render_template': 'mitxmako.shortcuts.render_to_string', } @@ -43,7 +47,7 @@ CONTENTSTORE = { 'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore', 'OPTIONS': { 'host': 'localhost', - 'db': 'acceptance_xcontent_%s' % uuid4().hex, + 'db': 'acceptance_xcontent_%s' % seed(), } } @@ -53,8 +57,8 @@ CONTENTSTORE = { DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': TEST_ROOT / "db" / "test_mitx.db", - 'TEST_NAME': TEST_ROOT / "db" / "test_mitx.db", + 'NAME': TEST_ROOT / "db" / "test_mitx_%s.db" % seed(), + 'TEST_NAME': TEST_ROOT / "db" / "test_mitx_%s.db" % seed(), } }