Skip acceptance test DB migrations if the DB already exists and running fasttest_acceptance
This commit is contained in:
@@ -68,8 +68,8 @@ CONTENTSTORE = {
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': TEST_ROOT / "db" / "test_mitx_%s.db" % seed(),
|
||||
'TEST_NAME': TEST_ROOT / "db" / "test_mitx_%s.db" % seed(),
|
||||
'NAME': TEST_ROOT / "db" / "test_edx.db",
|
||||
'TEST_NAME': TEST_ROOT / "db" / "test_edx.db"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
"""
|
||||
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
|
||||
# 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'
|
||||
@@ -65,8 +65,8 @@ CONTENTSTORE = {
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': TEST_ROOT / "db" / "test_mitx_%s.db" % seed(),
|
||||
'TEST_NAME': TEST_ROOT / "db" / "test_mitx_%s.db" % seed(),
|
||||
'NAME': TEST_ROOT / "db" / "test_edx.db",
|
||||
'TEST_NAME': TEST_ROOT / "db" / "test_edx.db",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
"""
|
||||
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'),
|
||||
}
|
||||
|
||||
# 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'
|
||||
@@ -4,6 +4,8 @@ CLOBBER.include(REPORT_DIR, 'test_root/*_repo', 'test_root/staticfiles')
|
||||
# Create the directory to hold coverage reports, if it doesn't already exist.
|
||||
directory REPORT_DIR
|
||||
|
||||
ACCEPTANCE_DB = 'test_root/db/test_edx.db'
|
||||
|
||||
def test_id_dir(path)
|
||||
return File.join(".testids", path.to_s)
|
||||
end
|
||||
@@ -30,7 +32,7 @@ def run_tests(system, report_dir, test_id=nil, stop_on_failure=true)
|
||||
test_sh(run_under_coverage(cmd, system))
|
||||
end
|
||||
|
||||
def run_acceptance_tests(system, report_dir, harvest_args)
|
||||
def create_acceptance_db(system)
|
||||
# HACK: Since now the CMS depends on the existence of some database tables
|
||||
# that used to be in LMS (Role/Permissions for Forums) we need to make
|
||||
# sure the acceptance tests create/migrate the database tables
|
||||
@@ -43,6 +45,22 @@ def run_acceptance_tests(system, report_dir, harvest_args)
|
||||
end
|
||||
sh(django_admin(system, 'acceptance', 'syncdb', '--noinput'))
|
||||
sh(django_admin(system, 'acceptance', 'migrate', '--noinput'))
|
||||
end
|
||||
|
||||
def setup_acceptance_db(system, fasttest=false)
|
||||
# If running under fasttest mode and the database already
|
||||
# exists, skip the migrations.
|
||||
if File.exists?(ACCEPTANCE_DB)
|
||||
if not fasttest
|
||||
File.delete(ACCEPTANCE_DB)
|
||||
create_acceptance_db(system)
|
||||
end
|
||||
else
|
||||
create_acceptance_db(system)
|
||||
end
|
||||
end
|
||||
|
||||
def run_acceptance_tests(system, report_dir, harvest_args)
|
||||
test_sh(django_admin(system, 'acceptance', 'harvest', '--debug-mode', '--tag -skip', harvest_args))
|
||||
end
|
||||
|
||||
@@ -58,7 +76,7 @@ end
|
||||
|
||||
task :clean_test_files do
|
||||
desc "Clean fixture files used by tests"
|
||||
sh("git clean -fqdx test_root")
|
||||
sh("git clean -fqdx test_root/logs test_root/data test_root/staticfiles test_root/uploads")
|
||||
end
|
||||
|
||||
task :clean_reports_dir => REPORT_DIR do
|
||||
@@ -91,13 +109,15 @@ 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}"]
|
||||
task "test_acceptance_#{system}", [:harvest_args] => [:clean_test_files, "#{system}:gather_assets:acceptance"] do |t, args|
|
||||
setup_acceptance_db(system)
|
||||
Rake::Task["fasttest_acceptance_#{system}"].invoke(*args)
|
||||
end
|
||||
|
||||
desc "Run acceptance tests without collectstatic"
|
||||
desc "Run acceptance tests without collectstatic or database migrations"
|
||||
task "fasttest_acceptance_#{system}", [:harvest_args] => [report_dir, :clean_reports_dir, :predjango] do |t, args|
|
||||
args.with_defaults(:harvest_args => '')
|
||||
setup_acceptance_db(system, fasttest=true)
|
||||
run_acceptance_tests(system, report_dir, args.harvest_args)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user