Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
09dc884c
Commit
09dc884c
authored
May 04, 2016
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Isolate databases between test processes
parent
cb2ac424
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
7 deletions
+34
-7
cms/envs/test.py
+4
-0
lms/envs/test.py
+4
-2
openedx/core/djangolib/testing/utils.py
+20
-0
scripts/generic-ci-tests.sh
+6
-5
No files found.
cms/envs/test.py
View file @
09dc884c
...
...
@@ -57,6 +57,10 @@ NOSE_ARGS = [
'--xunit-file'
,
_REPORT_DIR
/
'nosetests.xml'
,
]
NOSE_PLUGINS
=
[
'openedx.core.djangolib.testing.utils.NoseDatabaseIsolation'
]
TEST_ROOT
=
path
(
'test_root'
)
# Want static files in the same dir for running on jenkins.
...
...
lms/envs/test.py
View file @
09dc884c
...
...
@@ -99,6 +99,10 @@ NOSE_ARGS = [
'--xunit-file'
,
_REPORT_DIR
/
'nosetests.xml'
,
]
NOSE_PLUGINS
=
[
'openedx.core.djangolib.testing.utils.NoseDatabaseIsolation'
]
# Local Directories
TEST_ROOT
=
path
(
"test_root"
)
# Want static files in the same dir for running on jenkins.
...
...
@@ -181,12 +185,10 @@ CONTENTSTORE = {
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
'NAME'
:
TEST_ROOT
/
'db'
/
'edx.db'
,
'ATOMIC_REQUESTS'
:
True
,
},
'student_module_history'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
'NAME'
:
TEST_ROOT
/
'db'
/
'student_module_history.db'
},
}
...
...
openedx/core/djangolib/testing/utils.py
View file @
09dc884c
...
...
@@ -10,11 +10,14 @@ Utility classes for testing django applications.
import
copy
from
django
import
db
from
django.core.cache
import
caches
from
django.test
import
TestCase
,
override_settings
from
django.conf
import
settings
from
django.contrib
import
sites
from
nose.plugins
import
Plugin
from
request_cache.middleware
import
RequestCache
...
...
@@ -138,3 +141,20 @@ class CacheIsolationTestCase(CacheIsolationMixin, TestCase):
self
.
clear_caches
()
self
.
addCleanup
(
self
.
clear_caches
)
class
NoseDatabaseIsolation
(
Plugin
):
"""
nosetest plugin that resets django databases before any tests begin.
Used to make sure that tests running in multi processes aren't sharing
a database connection.
"""
name
=
"database-isolation"
def
begin
(
self
):
"""
Before any tests start, reset all django database connections.
"""
for
db_
in
db
.
connections
.
all
():
db_
.
close
()
scripts/generic-ci-tests.sh
View file @
09dc884c
...
...
@@ -97,21 +97,22 @@ case "$TEST_SUITE" in
;;
"lms-unit"
)
LMS_ARGS
=
"--with-flaky"
case
"
$SHARD
"
in
"all"
)
paver test_system
-s
lms
--extra_args
=
"
--with-flaky"
--cov_args
=
"-p"
paver test_system
-s
lms
--extra_args
=
"
$LMS_ARGS
"
--cov_args
=
"-p"
-v
;;
"1"
)
paver test_system
-s
lms
--extra_args
=
"--attr='shard_1'
--with-flaky
"
--cov_args
=
"-p"
-v
paver test_system
-s
lms
--extra_args
=
"--attr='shard_1'
$LMS_ARGS
"
--cov_args
=
"-p"
-v
;;
"2"
)
paver test_system
-s
lms
--extra_args
=
"--attr='shard_2'
--with-flaky
"
--cov_args
=
"-p"
-v
paver test_system
-s
lms
--extra_args
=
"--attr='shard_2'
$LMS_ARGS
"
--cov_args
=
"-p"
-v
;;
"3"
)
paver test_system
-s
lms
--extra_args
=
"--attr='shard_3'
--with-flaky
"
--cov_args
=
"-p"
-v
paver test_system
-s
lms
--extra_args
=
"--attr='shard_3'
$LMS_ARGS
"
--cov_args
=
"-p"
-v
;;
"4"
)
paver test_system
-s
lms
--extra_args
=
"--attr='shard_1=False,shard_2=False,shard_3=False'
--with-flaky
"
--cov_args
=
"-p"
-v
paver test_system
-s
lms
--extra_args
=
"--attr='shard_1=False,shard_2=False,shard_3=False'
$LMS_ARGS
"
--cov_args
=
"-p"
-v
;;
*
)
# If no shard is specified, rather than running all tests, create an empty xunit file. This is a
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment