summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Treinish <treinish@linux.vnet.ibm.com>2013-07-09 11:01:16 -0400
committerMatthew Treinish <treinish@linux.vnet.ibm.com>2013-07-09 11:01:16 -0400
commitb4814c9edef2a0d23b1bd52c775f69d9ed9ea216 (patch)
treedabf083af716e727909fd3887215a64db23d2464
parentbf920ea2002a64f23ded34bff1cd81a4bb7a4637 (diff)
downloadtestrepository-b4814c9edef2a0d23b1bd52c775f69d9ed9ea216.tar.gz
Add group_regex option to .testr.conf to leverage use of group_regex
for scheduling.
-rw-r--r--NEWS3
-rw-r--r--doc/MANUAL.txt24
-rw-r--r--testrepository/testcommand.py18
-rw-r--r--testrepository/tests/test_testcommand.py9
4 files changed, 51 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 419c19e..c38a1a4 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,9 @@ CHANGES
load command to take interactive input without it reading from the raw
subunit stream on stdin. (Robert Collins)
+* Add a new testr.conf option, group_regex, that can be used for grouping
+ test_ids with a regular expression. (Matthew Treinish)
+
0.0.15
++++++
diff --git a/doc/MANUAL.txt b/doc/MANUAL.txt
index cb76c66..d06dd3d 100644
--- a/doc/MANUAL.txt
+++ b/doc/MANUAL.txt
@@ -205,6 +205,30 @@ And then find tests with that tag::
$ testr last --subunit | subunit-filter -s --xfail --with-tag=worker-3 | subunit-ls > slave-3.list
+Test Grouping
+~~~~~~~~~~~~~
+
+In certain scenarios you may want to group tests of a certain type together
+so that they will run together. The group_regex option allows you do this by
+passing in a regex string in as an option in .testr.conf. The test scheduler
+will group the tests based on the result of matching the regex to the test id.
+Then when the scheduler is partitioning the tests these groups will be
+scheduled as a single unit. In other words each group will be run on the same
+partition.
+
+The group_regex to use can be set in .testr.conf with the group_regex option.
+If it is necessary to have the regex string for use elsewhere in .testr.conf
+then it can be accessed using the $GROUP_REGEX variable.
+
+For example, extending the python sample .testr.conf from the configuration
+section with a group regex that will group python tests cases together::
+
+ [DEFAULT]
+ test_command=foo $IDOPTION
+ test_id_option=--bar $IDFILE
+ group_regex=([^\.]*\.)*
+
+
Remote or isolated test environments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/testrepository/testcommand.py b/testrepository/testcommand.py
index 65a8f61..9fc9ad0 100644
--- a/testrepository/testcommand.py
+++ b/testrepository/testcommand.py
@@ -72,6 +72,8 @@ testrconf_help = dedent("""
be adjusted if the paths are synched with different names.
* instance_dispose -- dispose of one or more test running environments.
Accepts $INSTANCE_IDS.
+ * group_regex -- The optional variable to set a regex string to be used
+ for grouping test ids.
* $IDOPTION -- the variable to use to trigger running some specific tests.
* $IDFILE -- A file created before the test command is run and deleted
afterwards which contains a list of test ids, one per line. This can
@@ -79,6 +81,8 @@ testrconf_help = dedent("""
* $IDLIST -- A list of the test ids to run, separated by spaces. IDLIST
defaults to an empty string when no test ids are known and no explicit
default is provided. This will not handle test ids with spaces.
+ * $GROUP_REGEX -- The variable for the regex string used for grouping
+ tests.
See the testrepository manual for example .testr.conf files in different
programming languages.
@@ -185,9 +189,11 @@ class TestListingFixture(Fixture):
def setUp(self):
super(TestListingFixture, self).setUp()
- variable_regex = '\$(IDOPTION|IDFILE|IDLIST|LISTOPT)'
+ variable_regex = '\$(IDOPTION|IDFILE|IDLIST|LISTOPT|GROUP_REGEX)'
variables = {}
list_variables = {'LISTOPT': self.listopt}
+ if self.group_regex:
+ variables['GROUP_REGEX'] = self.group_regex
cmd = self.template
try:
default_idstr = self._parser.get('DEFAULT', 'test_id_list_default')
@@ -577,15 +583,21 @@ class TestCommand(Fixture):
if e.message != "No option 'test_list_option' in section: 'DEFAULT'":
raise
raise ValueError("No test_list_option option present in .testr.conf")
+ try:
+ group_regex = parser.get('DEFAULT', 'group_regex')
+ except ConfigParser.NoOptionError:
+ group_regex = None
if self.oldschool:
listpath = os.path.join(self.ui.here, 'failing.list')
result = self.run_factory(test_ids, cmd, listopt, idoption,
self.ui, self.repository, listpath=listpath, parser=parser,
- test_filters=test_filters, instance_source=self)
+ test_filters=test_filters, instance_source=self,
+ group_regex=group_regex)
else:
result = self.run_factory(test_ids, cmd, listopt, idoption,
self.ui, self.repository, parser=parser,
- test_filters=test_filters, instance_source=self)
+ test_filters=test_filters, instance_source=self,
+ group_regex=group_regex)
return result
def get_filter_tags(self):
diff --git a/testrepository/tests/test_testcommand.py b/testrepository/tests/test_testcommand.py
index bbe4ac8..ef71df0 100644
--- a/testrepository/tests/test_testcommand.py
+++ b/testrepository/tests/test_testcommand.py
@@ -221,6 +221,15 @@ class TestTestCommand(ResourcedTestCase):
expected_cmd = 'foo '
self.assertEqual(expected_cmd, fixture.cmd)
+ def test_group_regex_option(self):
+ ui, command = self.get_test_ui_and_cmd()
+ self.set_config(
+ '[DEFAULT]\ntest_command=foo $IDOPTION\n'
+ 'test_id_option=--load-list $IDFILE\n'
+ 'group_regex=test\n')
+ fixture = self.useFixture(command.get_run_command())
+ self.assertEqual('test', fixture.group_regex)
+
def test_extra_args_passed_in(self):
ui, command = self.get_test_ui_and_cmd()
self.set_config(