diff options
author | Matthew Treinish <treinish@linux.vnet.ibm.com> | 2013-07-08 16:18:37 -0400 |
---|---|---|
committer | Matthew Treinish <treinish@linux.vnet.ibm.com> | 2013-07-08 16:18:37 -0400 |
commit | bf920ea2002a64f23ded34bff1cd81a4bb7a4637 (patch) | |
tree | 04c5a4b17eb6726744c87fa065fff14e65437201 /testrepository/tests | |
parent | 610acebaff00b30303dc11644e0a88931d760a28 (diff) | |
download | testrepository-bf920ea2002a64f23ded34bff1cd81a4bb7a4637.tar.gz |
Add group regex scheduling hint to the test partitioner
This commit adds a new optional parameter, group_regex, to TestListingFixture.
The parameter group_regex is used to group the test_ids. By passing a regex
string with the parameter the test partitioner will match the regex to the
test ids and then group by the result. In the case a test id does not match
the regex it will be put in a default group. These groups are then used for
scheduling the partitions. Each test groups is scheduled together so that all
tests in a group are run together on the same partition. For the purposes of
scheduling the groups the sum of all test ids in a group is used to schedule
the whole group in a partition.
Diffstat (limited to 'testrepository/tests')
-rw-r--r-- | testrepository/tests/test_testcommand.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/testrepository/tests/test_testcommand.py b/testrepository/tests/test_testcommand.py index 43be8e6..bbe4ac8 100644 --- a/testrepository/tests/test_testcommand.py +++ b/testrepository/tests/test_testcommand.py @@ -362,6 +362,37 @@ class TestTestCommand(ResourcedTestCase): self.assertEqual(1, len(partitions[0])) self.assertEqual(1, len(partitions[1])) + def test_partition_tests_with_group_regex(self): + repo = memory.RepositoryFactory().initialise('memory:') + result = repo.get_inserter() + result.startTestRun() + run_timed("TestCase1.slow", 3, result) + run_timed("TestCase2.fast1", 1, result) + run_timed("TestCase2.fast2", 1, result) + result.stopTestRun() + ui, command = self.get_test_ui_and_cmd(repository=repo) + self.set_config( + '[DEFAULT]\ntest_command=foo $IDLIST $LISTOPT\n' + 'test_list_option=--list\n') + fixture = self.useFixture(command.get_run_command()) + test_ids = frozenset(['TestCase1.slow', 'TestCase1.fast', + 'TestCase1.fast2', 'TestCase2.fast1', + 'TestCase3.test1', 'TestCase3.test2', + 'TestCase2.fast2', 'TestCase4.test', + 'testdir.testfile.TestCase5.test']) + regex = 'TestCase[0-5]' + group_tags = fixture.filter_test_groups(test_ids, regex) + partitions = fixture.partition_tests(test_ids, 2, group_tags) + self.assertTrue('TestCase1.slow' in partitions[1]) + self.assertTrue('TestCase1.fast' in partitions[1]) + self.assertTrue('TestCase1.fast2' in partitions[1]) + self.assertTrue('TestCase3.test2' in partitions[1]) + self.assertTrue('TestCase3.test1' in partitions[1]) + self.assertTrue('TestCase4.test' in partitions[1]) + self.assertTrue('testdir.testfile.TestCase5.test' in partitions[0]) + self.assertTrue('TestCase2.fast1' in partitions[0]) + self.assertTrue('TestCase2.fast2' in partitions[0]) + def test_run_tests_with_instances(self): # when there are instances and no instance_execute, run_tests acts as # normal. |