From 4685cacc7b21051492ff8147ddf867475ef5921b Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Wed, 10 Jul 2013 15:28:23 -0400 Subject: [PATCH] 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|