Commit e60114c7 by Calen Pennington

Add paver arguments to control concurrency and randomization

parent a45f1f03
...@@ -208,6 +208,18 @@ To run a single test format the command like this. ...@@ -208,6 +208,18 @@ To run a single test format the command like this.
paver test_system -t lms/djangoapps/courseware/tests/tests.py:ActivateLoginTest.test_activate_login paver test_system -t lms/djangoapps/courseware/tests/tests.py:ActivateLoginTest.test_activate_login
The ``lms`` suite of tests runs concurrently, and with randomized order, by default.
You can override these by using ``--no-randomize`` to disable randomization,
and ``--processes=N`` to control how many tests will run concurrently (``0`` will
disable concurrency). For example:
::
# This will run all tests in the order that they appear in their files, serially
paver test_system -s lms --no-randomize --processes=0
# This will run using only 2 processes for tests
paver test_system -s lms --processes=2
To re-run all failing django tests from lms or cms, use the To re-run all failing django tests from lms or cms, use the
``--failed``,\ ``-f`` flag (see note at end of section). ``--failed``,\ ``-f`` flag (see note at end of section).
......
...@@ -31,6 +31,9 @@ __test__ = False # do not collect ...@@ -31,6 +31,9 @@ __test__ = False # do not collect
('extra_args=', 'e', 'adds as extra args to the test command'), ('extra_args=', 'e', 'adds as extra args to the test command'),
('cov_args=', 'c', 'adds as args to coverage for the test run'), ('cov_args=', 'c', 'adds as args to coverage for the test run'),
('skip_clean', 'C', 'skip cleaning repository before running tests'), ('skip_clean', 'C', 'skip cleaning repository before running tests'),
('processes=', 'p', 'number of processes to use running tests'),
make_option('-r', '--randomize', action='store_true', dest='randomize', help='run the tests in a random order'),
make_option('--no-randomize', action='store_false', dest='randomize', help="don't run the tests in a random order"),
make_option("--verbose", action="store_const", const=2, dest="verbosity"), make_option("--verbose", action="store_const", const=2, dest="verbosity"),
make_option("-q", "--quiet", action="store_const", const=0, dest="verbosity"), make_option("-q", "--quiet", action="store_const", const=0, dest="verbosity"),
make_option("-v", "--verbosity", action="count", dest="verbosity", default=1), make_option("-v", "--verbosity", action="count", dest="verbosity", default=1),
...@@ -59,6 +62,8 @@ def test_system(options): ...@@ -59,6 +62,8 @@ def test_system(options):
'skip_clean': getattr(options, 'skip_clean', False), 'skip_clean': getattr(options, 'skip_clean', False),
'pdb': getattr(options, 'pdb', False), 'pdb': getattr(options, 'pdb', False),
'disable_migrations': getattr(options, 'disable_migrations', False), 'disable_migrations': getattr(options, 'disable_migrations', False),
'processes': getattr(options, 'processes', None),
'randomize': getattr(options, 'randomize', None),
} }
if test_id: if test_id:
......
...@@ -113,36 +113,38 @@ class SystemTestSuite(NoseTestSuite): ...@@ -113,36 +113,38 @@ class SystemTestSuite(NoseTestSuite):
self.test_id = kwargs.get('test_id', self._default_test_id) self.test_id = kwargs.get('test_id', self._default_test_id)
self.fasttest = kwargs.get('fasttest', False) self.fasttest = kwargs.get('fasttest', False)
self.processes = kwargs.get('processes', None)
self.randomize = kwargs.get('randomize', None)
def __enter__(self): def __enter__(self):
super(SystemTestSuite, self).__enter__() super(SystemTestSuite, self).__enter__()
@property @property
def cmd(self): def cmd(self):
cmd = ( if self.processes is None:
'./manage.py {system} test --verbosity={verbosity} ' # Use one process per core for LMS tests, and no multiprocessing
'{test_id} {test_opts} --settings=test {system_opts} {extra} ' # otherwise.
'--with-xunitmp --xunitmp-file={xunit_report}'.format( self.processes = -1 if self.root == 'lms' else 0
system=self.root,
verbosity=self.verbosity, if self.randomize is None:
test_id=self.test_id, self.randomize = self.root == 'lms'
test_opts=self.test_options_flags,
system_opts=self._system_options, cmd = [
extra=self.extra_args, './manage.py', self.root, 'test',
xunit_report=self.report_dir / "nosetests.xml", '--verbosity={}'.format(self.verbosity),
) self.test_id,
) self.test_options_flags,
'--settings=test',
return self._under_coverage_cmd(cmd) self.extra_args,
'--with-xunitmp',
@property '--xunitmp-file={}'.format(self.report_dir / "nosetests.xml"),
def _system_options(self): '--processes={}'.format(self.processes),
""" '--with-database-isolation',
Test arguments that are only enabled for specific systems. ]
""" if self.randomize:
if self.root == 'lms': cmd.append('--with-randomly')
return '--with-randomly --with-database-isolation --processes=-1'
return self._under_coverage_cmd(" ".join(cmd))
return ''
@property @property
def _default_test_id(self): def _default_test_id(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment