From 789b7110236f4f0677ebc04b61e2c97537f20408 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Thu, 27 Jun 2013 14:43:25 -0400 Subject: [PATCH 01/10] Acceptance tests now pull from their own unique database These databases/collections are cleared after harvest --- cms/envs/acceptance.py | 4 ++-- common/djangoapps/terrain/browser.py | 6 ++++++ lms/envs/acceptance.py | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cms/envs/acceptance.py b/cms/envs/acceptance.py index 4d1f1f2a4b..4b27c2a24f 100644 --- a/cms/envs/acceptance.py +++ b/cms/envs/acceptance.py @@ -21,7 +21,7 @@ MODULESTORE_OPTIONS = { 'default_class': 'xmodule.raw_module.RawDescriptor', 'host': 'localhost', 'db': 'test_xmodule', - 'collection': 'acceptance_modulestore', + 'collection': 'acceptance_modulestore_%s' % uuid4().hex, 'fs_root': TEST_ROOT / "data", 'render_template': 'mitxmako.shortcuts.render_to_string', } @@ -45,7 +45,7 @@ CONTENTSTORE = { 'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore', 'OPTIONS': { 'host': 'localhost', - 'db': 'acceptance_xcontent', + 'db': 'acceptance_xcontent_%s' % uuid4().hex, }, # allow for additional options that can be keyed on a name, e.g. 'trashcan' 'ADDITIONAL_OPTIONS': { diff --git a/common/djangoapps/terrain/browser.py b/common/djangoapps/terrain/browser.py index d237edc4b7..6b2114d8cc 100644 --- a/common/djangoapps/terrain/browser.py +++ b/common/djangoapps/terrain/browser.py @@ -17,6 +17,8 @@ from selenium.common.exceptions import WebDriverException # These names aren't used, but do important work on import. from lms import one_time_startup # pylint: disable=W0611 from cms import one_time_startup # pylint: disable=W0611 +from pymongo import MongoClient +import xmodule.modulestore.django # There is an import issue when using django-staticfiles with lettuce # Lettuce assumes that we are using django.contrib.staticfiles, @@ -103,3 +105,7 @@ def teardown_browser(total): Quit the browser after executing the tests. """ world.browser.quit() + mongo = MongoClient() + mongo.drop_database(settings.CONTENTSTORE['OPTIONS']['db']) + modulestore = xmodule.modulestore.django.modulestore() + modulestore.collection.drop() diff --git a/lms/envs/acceptance.py b/lms/envs/acceptance.py index 3b87bb4326..be604eea8d 100644 --- a/lms/envs/acceptance.py +++ b/lms/envs/acceptance.py @@ -16,13 +16,14 @@ DEBUG = True # Disable warnings for acceptance tests, to make the logs readable import logging logging.disable(logging.ERROR) +from uuid import uuid4 # Use the mongo store for acceptance tests modulestore_options = { 'default_class': 'xmodule.raw_module.RawDescriptor', 'host': 'localhost', 'db': 'test_xmodule', - 'collection': 'acceptance_modulestore', + 'collection': 'acceptance_modulestore_%s' % uuid4().hex, 'fs_root': TEST_ROOT / "data", 'render_template': 'mitxmako.shortcuts.render_to_string', } @@ -42,7 +43,7 @@ CONTENTSTORE = { 'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore', 'OPTIONS': { 'host': 'localhost', - 'db': 'test_xmodule', + 'db': 'acceptance_xcontent_%s' % uuid4().hex, } } From b0d70008e4dfba63a478966184c9f3a3b9522e01 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Fri, 28 Jun 2013 09:52:23 -0400 Subject: [PATCH 02/10] Changed when the databases are reset This might allow parallel features in the future --- cms/envs/acceptance.py | 1 + common/djangoapps/terrain/browser.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cms/envs/acceptance.py b/cms/envs/acceptance.py index 4b27c2a24f..40d5894378 100644 --- a/cms/envs/acceptance.py +++ b/cms/envs/acceptance.py @@ -16,6 +16,7 @@ DEBUG = True # Disable warnings for acceptance tests, to make the logs readable import logging logging.disable(logging.ERROR) +from uuid import uuid4 MODULESTORE_OPTIONS = { 'default_class': 'xmodule.raw_module.RawDescriptor', diff --git a/common/djangoapps/terrain/browser.py b/common/djangoapps/terrain/browser.py index 6b2114d8cc..94f63f6543 100644 --- a/common/djangoapps/terrain/browser.py +++ b/common/djangoapps/terrain/browser.py @@ -19,6 +19,7 @@ from lms import one_time_startup # pylint: disable=W0611 from cms import one_time_startup # pylint: disable=W0611 from pymongo import MongoClient import xmodule.modulestore.django +from xmodule.contentstore.django import _CONTENTSTORE # There is an import issue when using django-staticfiles with lettuce # Lettuce assumes that we are using django.contrib.staticfiles, @@ -89,6 +90,17 @@ def reset_data(scenario): LOGGER.debug("Flushing the test database...") call_command('flush', interactive=False) + +@after.each_scenario +def reset_databases(scenario): + mongo = MongoClient() + mongo.drop_database(settings.CONTENTSTORE['OPTIONS']['db']) + _CONTENTSTORE.clear() + modulestore = xmodule.modulestore.django.modulestore() + modulestore.collection.drop() + xmodule.modulestore.django._MODULESTORES.clear() + + # Uncomment below to trigger a screenshot on error # @after.each_scenario def screenshot_on_error(scenario): @@ -105,7 +117,3 @@ def teardown_browser(total): Quit the browser after executing the tests. """ world.browser.quit() - mongo = MongoClient() - mongo.drop_database(settings.CONTENTSTORE['OPTIONS']['db']) - modulestore = xmodule.modulestore.django.modulestore() - modulestore.collection.drop() From 28142d51f90d96424b731dda1e8761377c959bbb Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Mon, 1 Jul 2013 08:58:45 -0400 Subject: [PATCH 03/10] Added comment about how the resetting of the database works --- common/djangoapps/terrain/browser.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/djangoapps/terrain/browser.py b/common/djangoapps/terrain/browser.py index 94f63f6543..0c1303ed1a 100644 --- a/common/djangoapps/terrain/browser.py +++ b/common/djangoapps/terrain/browser.py @@ -93,6 +93,11 @@ def reset_data(scenario): @after.each_scenario def reset_databases(scenario): + ''' + After each scenario, all databases are cleared/dropped. Contentstore data are stored in unique databases + whereas modulestore data is in unique collection names. This data is created implicitly during the scenarios. + If no data is created during the test, these lines equivilently do nothing. + ''' mongo = MongoClient() mongo.drop_database(settings.CONTENTSTORE['OPTIONS']['db']) _CONTENTSTORE.clear() From 1eaa0317c49bd265d998f50b7aa7a5c915eac744 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Tue, 9 Jul 2013 08:57:05 -0400 Subject: [PATCH 04/10] 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(), } } From a2020aad038d7d120a7487ea532ace37b942f15e Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Tue, 9 Jul 2013 09:31:37 -0400 Subject: [PATCH 05/10] Changed the lms database name to be different for the acceptance tests --- cms/envs/acceptance.py | 2 +- lms/envs/acceptance.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cms/envs/acceptance.py b/cms/envs/acceptance.py index 556687af7e..fac8458ee5 100644 --- a/cms/envs/acceptance.py +++ b/cms/envs/acceptance.py @@ -25,7 +25,7 @@ def seed(): MODULESTORE_OPTIONS = { 'default_class': 'xmodule.raw_module.RawDescriptor', 'host': 'localhost', - 'db': 'test_xmodule', + 'db': 'acceptance_xmodule', 'collection': 'acceptance_modulestore_%s' % seed(), 'fs_root': TEST_ROOT / "data", 'render_template': 'mitxmako.shortcuts.render_to_string', diff --git a/lms/envs/acceptance.py b/lms/envs/acceptance.py index ddc1679c37..0811291aca 100644 --- a/lms/envs/acceptance.py +++ b/lms/envs/acceptance.py @@ -26,7 +26,7 @@ def seed(): modulestore_options = { 'default_class': 'xmodule.raw_module.RawDescriptor', 'host': 'localhost', - 'db': 'test_xmodule', + 'db': 'acceptance_xmodule', 'collection': 'acceptance_modulestore_%s' % seed(), 'fs_root': TEST_ROOT / "data", 'render_template': 'mitxmako.shortcuts.render_to_string', From a21303ba96752ca289a2107845d784fcdc7f4cc4 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Tue, 9 Jul 2013 10:49:19 -0400 Subject: [PATCH 06/10] Found some other places where the name should be unique --- cms/envs/test.py | 10 +++++++--- lms/envs/test.py | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cms/envs/test.py b/cms/envs/test.py index 86925caff6..98a8272eda 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -16,6 +16,10 @@ from .common import * import os from path import path + +def seed(): + return os.getppid() + # Nose Test Runner INSTALLED_APPS += ('django_nose',) TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' @@ -46,7 +50,7 @@ MODULESTORE_OPTIONS = { 'default_class': 'xmodule.raw_module.RawDescriptor', 'host': 'localhost', 'db': 'test_xmodule', - 'collection': 'test_modulestore', + 'collection': 'test_modulestore_%s' % seed(), 'fs_root': TEST_ROOT / "data", 'render_template': 'mitxmako.shortcuts.render_to_string', } @@ -70,7 +74,7 @@ CONTENTSTORE = { 'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore', 'OPTIONS': { 'host': 'localhost', - 'db': 'test_xcontent', + 'db': 'test_xcontent_%s' % seed(), }, # allow for additional options that can be keyed on a name, e.g. 'trashcan' 'ADDITIONAL_OPTIONS': { @@ -83,7 +87,7 @@ CONTENTSTORE = { DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': TEST_ROOT / "db" / "cms.db", + 'NAME': TEST_ROOT / "db" / "cms_%s.db" % seed(), }, } diff --git a/lms/envs/test.py b/lms/envs/test.py index f23be52a51..8fbd271daf 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -16,6 +16,9 @@ from .common import * import os from path import path +def seed(): + return os.getppid() + # can't test start dates with this True, but on the other hand, # can test everything else :) MITX_FEATURES['DISABLE_START_DATES'] = True @@ -101,7 +104,7 @@ MODULESTORE = { DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': TEST_ROOT / 'db' / 'mitx.db' + 'NAME': TEST_ROOT / 'db' / 'mitx_%s.db' % seed() }, } From 0bd1e78e03c724b597cace7a9e976ae704292de0 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Tue, 9 Jul 2013 12:18:30 -0400 Subject: [PATCH 07/10] Acceptance tests use random ports --- cms/djangoapps/contentstore/features/upload.py | 2 +- cms/envs/acceptance.py | 3 ++- lms/envs/acceptance.py | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cms/djangoapps/contentstore/features/upload.py b/cms/djangoapps/contentstore/features/upload.py index 977bad8fea..0c700956e3 100644 --- a/cms/djangoapps/contentstore/features/upload.py +++ b/cms/djangoapps/contentstore/features/upload.py @@ -9,7 +9,7 @@ import random import os TEST_ROOT = settings.COMMON_TEST_DATA_ROOT -HTTP_PREFIX = "http://localhost:8001" +HTTP_PREFIX = "http://localhost:%s" % settings.LETTUCE_SERVER_PORT @step(u'I go to the files and uploads page') diff --git a/cms/envs/acceptance.py b/cms/envs/acceptance.py index fac8458ee5..ecd22ed769 100644 --- a/cms/envs/acceptance.py +++ b/cms/envs/acceptance.py @@ -17,6 +17,7 @@ DEBUG = True import logging logging.disable(logging.ERROR) import os +import random def seed(): @@ -74,5 +75,5 @@ DATABASES = { # Include the lettuce app for acceptance testing, including the 'harvest' django-admin command INSTALLED_APPS += ('lettuce.django',) LETTUCE_APPS = ('contentstore',) -LETTUCE_SERVER_PORT = 8001 +LETTUCE_SERVER_PORT = random.randint(1024, 65535) LETTUCE_BROWSER = 'chrome' diff --git a/lms/envs/acceptance.py b/lms/envs/acceptance.py index 0811291aca..087c1ca85c 100644 --- a/lms/envs/acceptance.py +++ b/lms/envs/acceptance.py @@ -17,6 +17,7 @@ DEBUG = True import logging logging.disable(logging.ERROR) import os +import random def seed(): @@ -64,7 +65,7 @@ DATABASES = { # Set up XQueue information so that the lms will send # requests to a mock XQueue server running locally -XQUEUE_PORT = 8027 +XQUEUE_PORT = random.randint(1024, 65535) XQUEUE_INTERFACE = { "url": "http://127.0.0.1:%d" % XQUEUE_PORT, "django_auth": { @@ -81,4 +82,5 @@ MITX_FEATURES['STUB_VIDEO_FOR_TESTING'] = True # Include the lettuce app for acceptance testing, including the 'harvest' django-admin command INSTALLED_APPS += ('lettuce.django',) LETTUCE_APPS = ('courseware',) +LETTUCE_SERVER_PORT = random.randint(1024, 65535) LETTUCE_BROWSER = 'chrome' From 4685cacc7b21051492ff8147ddf867475ef5921b Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Wed, 10 Jul 2013 15:28:23 -0400 Subject: [PATCH 08/10] Databases are now cleaned properly Acceptance_static is used to prevent collect static from using a seed test.py had its seed removed due to redundancy --- cms/envs/acceptance_static.py | 75 ++++++++++++++++++++++++++++++++ cms/envs/test.py | 10 ++--- lms/envs/acceptance_static.py | 81 +++++++++++++++++++++++++++++++++++ lms/envs/test.py | 5 +-- rakelib/tests.rake | 2 +- 5 files changed, 161 insertions(+), 12 deletions(-) create mode 100644 cms/envs/acceptance_static.py create mode 100644 lms/envs/acceptance_static.py diff --git a/cms/envs/acceptance_static.py b/cms/envs/acceptance_static.py new file mode 100644 index 0000000000..cfcf35a5b5 --- /dev/null +++ b/cms/envs/acceptance_static.py @@ -0,0 +1,75 @@ +""" +This config file extends the test environment configuration +so that we can run the lettuce acceptance tests. +""" + +# We intentionally define lots of variables that aren't used, and +# want to import all variables from base settings files +# pylint: disable=W0401, W0614 + +from .test import * + +# You need to start the server in debug mode, +# otherwise the browser will not render the pages correctly +DEBUG = True + +# Disable warnings for acceptance tests, to make the logs readable +import logging +logging.disable(logging.ERROR) +import os +import random + +MODULESTORE_OPTIONS = { + 'default_class': 'xmodule.raw_module.RawDescriptor', + 'host': 'localhost', + 'db': 'acceptance_xmodule', + 'collection': 'acceptance_modulestore', + 'fs_root': TEST_ROOT / "data", + 'render_template': 'mitxmako.shortcuts.render_to_string', +} + +MODULESTORE = { + 'default': { + 'ENGINE': 'xmodule.modulestore.draft.DraftModuleStore', + 'OPTIONS': MODULESTORE_OPTIONS + }, + 'direct': { + 'ENGINE': 'xmodule.modulestore.mongo.MongoModuleStore', + 'OPTIONS': MODULESTORE_OPTIONS + }, + 'draft': { + 'ENGINE': 'xmodule.modulestore.draft.DraftModuleStore', + 'OPTIONS': MODULESTORE_OPTIONS + } +} + +CONTENTSTORE = { + 'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore', + 'OPTIONS': { + 'host': 'localhost', + 'db': 'acceptance_xcontent', + }, + # allow for additional options that can be keyed on a name, e.g. 'trashcan' + 'ADDITIONAL_OPTIONS': { + 'trashcan': { + 'bucket': 'trash_fs' + } + } +} + +# Set this up so that rake lms[acceptance] and running the +# harvest command both use the same (test) database +# which they can flush without messing up your dev db +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': TEST_ROOT / "db" / "test_mitx.db", + 'TEST_NAME': TEST_ROOT / "db" / "test_mitx.db", + } +} + +# Include the lettuce app for acceptance testing, including the 'harvest' django-admin command +INSTALLED_APPS += ('lettuce.django',) +LETTUCE_APPS = ('contentstore',) +LETTUCE_SERVER_PORT = random.randint(1024, 65535) +LETTUCE_BROWSER = 'chrome' diff --git a/cms/envs/test.py b/cms/envs/test.py index 98a8272eda..86925caff6 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -16,10 +16,6 @@ from .common import * import os from path import path - -def seed(): - return os.getppid() - # Nose Test Runner INSTALLED_APPS += ('django_nose',) TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' @@ -50,7 +46,7 @@ MODULESTORE_OPTIONS = { 'default_class': 'xmodule.raw_module.RawDescriptor', 'host': 'localhost', 'db': 'test_xmodule', - 'collection': 'test_modulestore_%s' % seed(), + 'collection': 'test_modulestore', 'fs_root': TEST_ROOT / "data", 'render_template': 'mitxmako.shortcuts.render_to_string', } @@ -74,7 +70,7 @@ CONTENTSTORE = { 'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore', 'OPTIONS': { 'host': 'localhost', - 'db': 'test_xcontent_%s' % seed(), + 'db': 'test_xcontent', }, # allow for additional options that can be keyed on a name, e.g. 'trashcan' 'ADDITIONAL_OPTIONS': { @@ -87,7 +83,7 @@ CONTENTSTORE = { DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': TEST_ROOT / "db" / "cms_%s.db" % seed(), + 'NAME': TEST_ROOT / "db" / "cms.db", }, } diff --git a/lms/envs/acceptance_static.py b/lms/envs/acceptance_static.py new file mode 100644 index 0000000000..5672ea5bf5 --- /dev/null +++ b/lms/envs/acceptance_static.py @@ -0,0 +1,81 @@ +""" +This config file extends the test environment configuration +so that we can run the lettuce acceptance tests. +""" + +# We intentionally define lots of variables that aren't used, and +# want to import all variables from base settings files +# pylint: disable=W0401, W0614 + +from .test import * + +# You need to start the server in debug mode, +# otherwise the browser will not render the pages correctly +DEBUG = True + +# Disable warnings for acceptance tests, to make the logs readable +import logging +logging.disable(logging.ERROR) +import random + +# Use the mongo store for acceptance tests +modulestore_options = { + 'default_class': 'xmodule.raw_module.RawDescriptor', + 'host': 'localhost', + 'db': 'acceptance_xmodule', + 'collection': 'acceptance_modulestore', + 'fs_root': TEST_ROOT / "data", + 'render_template': 'mitxmako.shortcuts.render_to_string', +} + +MODULESTORE = { + 'default': { + 'ENGINE': 'xmodule.modulestore.mongo.MongoModuleStore', + 'OPTIONS': modulestore_options + }, + 'direct': { + 'ENGINE': 'xmodule.modulestore.mongo.MongoModuleStore', + 'OPTIONS': modulestore_options + } +} + +CONTENTSTORE = { + 'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore', + 'OPTIONS': { + 'host': 'localhost', + 'db': 'acceptance_xcontent', + } +} + +# Set this up so that rake lms[acceptance] and running the +# harvest command both use the same (test) database +# which they can flush without messing up your dev db +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': TEST_ROOT / "db" / "test_mitx.db", + 'TEST_NAME': TEST_ROOT / "db" / "test_mitx.db", + } +} + +# Set up XQueue information so that the lms will send +# requests to a mock XQueue server running locally +XQUEUE_PORT = random.randint(1024, 65535) +XQUEUE_INTERFACE = { + "url": "http://127.0.0.1:%d" % XQUEUE_PORT, + "django_auth": { + "username": "lms", + "password": "***REMOVED***" + }, + "basic_auth": ('anant', 'agarwal'), +} + +# Do not display the YouTube videos in the browser while running the +# acceptance tests. This makes them faster and more reliable +MITX_FEATURES['STUB_VIDEO_FOR_TESTING'] = True + +# Include the lettuce app for acceptance testing, including the 'harvest' django-admin command +INSTALLED_APPS += ('lettuce.django',) +LETTUCE_APPS = ('courseware',) +LETTUCE_SERVER_PORT = random.randint(1024, 65535) +LETTUCE_BROWSER = 'chrome' diff --git a/lms/envs/test.py b/lms/envs/test.py index 8fbd271daf..f23be52a51 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -16,9 +16,6 @@ from .common import * import os from path import path -def seed(): - return os.getppid() - # can't test start dates with this True, but on the other hand, # can test everything else :) MITX_FEATURES['DISABLE_START_DATES'] = True @@ -104,7 +101,7 @@ MODULESTORE = { DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': TEST_ROOT / 'db' / 'mitx_%s.db' % seed() + 'NAME': TEST_ROOT / 'db' / 'mitx.db' }, } diff --git a/rakelib/tests.rake b/rakelib/tests.rake index ebc2b92973..70ba8970c5 100644 --- a/rakelib/tests.rake +++ b/rakelib/tests.rake @@ -80,7 +80,7 @@ TEST_TASK_DIRS = [] # Run acceptance tests desc "Run acceptance tests" - task "test_acceptance_#{system}", [:harvest_args] => [:clean_test_files, "#{system}:gather_assets:acceptance", "fasttest_acceptance_#{system}"] + task "test_acceptance_#{system}", [:harvest_args] => [:clean_test_files, "#{system}:gather_assets:acceptance_static", "fasttest_acceptance_#{system}"] desc "Run acceptance tests without collectstatic" task "fasttest_acceptance_#{system}", [:harvest_args] => [report_dir, :clean_reports_dir, :predjango] do |t, args| From a896ccfff76055945148e7a8ec8e73d4fa8136d9 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Wed, 10 Jul 2013 16:21:11 -0400 Subject: [PATCH 09/10] Added in a comment This explains why acceptance_static is used --- rakelib/tests.rake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rakelib/tests.rake b/rakelib/tests.rake index 70ba8970c5..7e3e672f39 100644 --- a/rakelib/tests.rake +++ b/rakelib/tests.rake @@ -80,6 +80,8 @@ TEST_TASK_DIRS = [] # Run acceptance tests desc "Run acceptance tests" + #gather_assets uses its own env because acceptance contains seeds to make the information unique + #acceptance_static is acceptance without the random seeding task "test_acceptance_#{system}", [:harvest_args] => [:clean_test_files, "#{system}:gather_assets:acceptance_static", "fasttest_acceptance_#{system}"] desc "Run acceptance tests without collectstatic" From a0900f09cc82b44088d2bbe6f8bfdc5bfb0f698e Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Wed, 10 Jul 2013 16:23:26 -0400 Subject: [PATCH 10/10] Commented why Acceptance_static is needed --- cms/envs/acceptance_static.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cms/envs/acceptance_static.py b/cms/envs/acceptance_static.py index cfcf35a5b5..f7d69794fb 100644 --- a/cms/envs/acceptance_static.py +++ b/cms/envs/acceptance_static.py @@ -1,6 +1,8 @@ """ This config file extends the test environment configuration so that we can run the lettuce acceptance tests. +This is used in the django-admin call as acceptance.py +contains random seeding, causing django-admin to create a random collection """ # We intentionally define lots of variables that aren't used, and