Merge "Add plugin registry generation to sphinx build"
diff --git a/tempest/cmd/run.py b/tempest/cmd/run.py
index 26bd418..5580cf7 100644
--- a/tempest/cmd/run.py
+++ b/tempest/cmd/run.py
@@ -23,6 +23,27 @@
any tests that match on re.match() with the regex
* **--smoke**: Run all the tests tagged as smoke
+There are also the **--blacklist_file** and **--whitelist_file** options that
+let you pass a filepath to tempest run with the file format being a line
+seperated regex, with '#' used to signify the start of a comment on a line.
+For example::
+
+ # Regex file
+ ^regex1 # Match these tests
+ .*regex2 # Match those tests
+
+The blacklist file will be used to construct a negative lookahead regex and
+the whitelist file will simply OR all the regexes in the file. The whitelist
+and blacklist file options are mutually exclusive so you can't use them
+together. However, you can combine either with a normal regex or the *--smoke*
+flag. When used with a blacklist file the generated regex will be combined to
+something like::
+
+ ^((?!black_regex1|black_regex2).)*$cli_regex1
+
+When combined with a whitelist file all the regexes from the file and the CLI
+regexes will be ORed.
+
You can also use the **--list-tests** option in conjunction with selection
arguments to list which tests will be run.
@@ -47,6 +68,7 @@
import threading
from cliff import command
+from os_testr import regex_builder
from os_testr import subunit_trace
from oslo_log import log as logging
from testrepository.commands import run_argv
@@ -109,6 +131,15 @@
regex.add_argument('--regex', '-r', default='',
help='A normal testr selection regex used to '
'specify a subset of tests to run')
+ list_selector = parser.add_mutually_exclusive_group()
+ list_selector.add_argument('--whitelist_file',
+ help="Path to a whitelist file, this file "
+ "contains a seperate regex on each "
+ "newline.")
+ list_selector.add_argument('--blacklist_file',
+ help='Path to a blacklist file, this file '
+ 'contains a separate regex exclude on '
+ 'each newline')
# list only args
parser.add_argument('--list-tests', '-l', action='store_true',
help='List tests',
@@ -138,6 +169,10 @@
regex = 'smoke'
elif parsed_args.regex:
regex = parsed_args.regex
+ if parsed_args.whitelist_file or parsed_args.blacklist_file:
+ regex = regex_builder.construct_regex(parsed_args.blacklist_file,
+ parsed_args.whitelist_file,
+ regex, False)
return regex
def _build_options(self, parsed_args):
diff --git a/tempest/scenario/test_server_basic_ops.py b/tempest/scenario/test_server_basic_ops.py
index 80728dc..446c87a 100644
--- a/tempest/scenario/test_server_basic_ops.py
+++ b/tempest/scenario/test_server_basic_ops.py
@@ -14,6 +14,7 @@
# under the License.
import json
+import re
from oslo_log import log as logging
@@ -83,9 +84,9 @@
def verify_metadata_on_config_drive(self):
if self.run_ssh and CONF.compute_feature_enabled.config_drive:
# Verify metadata on config_drive
- cmd_blkid = 'blkid -t LABEL=config-2 -o device'
- dev_name = self.ssh_client.exec_command(cmd_blkid)
- dev_name = dev_name.rstrip()
+ cmd_blkid = 'blkid | grep -i config-2'
+ result = self.ssh_client.exec_command(cmd_blkid)
+ dev_name = re.match('([^:]+)', result).group()
self.ssh_client.exec_command('sudo mount %s /mnt' % dev_name)
cmd_md = 'sudo cat /mnt/openstack/latest/meta_data.json'
result = self.ssh_client.exec_command(cmd_md)
diff --git a/tempest/tests/cmd/test_run.py b/tempest/tests/cmd/test_run.py
index dcffd21..772391f 100644
--- a/tempest/tests/cmd/test_run.py
+++ b/tempest/tests/cmd/test_run.py
@@ -46,18 +46,24 @@
args = mock.Mock(spec=argparse.Namespace)
setattr(args, 'smoke', False)
setattr(args, 'regex', '')
+ setattr(args, 'whitelist_file', None)
+ setattr(args, 'blacklist_file', None)
self.assertEqual('', self.run_cmd._build_regex(args))
def test__build_regex_smoke(self):
args = mock.Mock(spec=argparse.Namespace)
setattr(args, "smoke", True)
setattr(args, 'regex', '')
+ setattr(args, 'whitelist_file', None)
+ setattr(args, 'blacklist_file', None)
self.assertEqual('smoke', self.run_cmd._build_regex(args))
def test__build_regex_regex(self):
args = mock.Mock(spec=argparse.Namespace)
setattr(args, 'smoke', False)
setattr(args, "regex", 'i_am_a_fun_little_regex')
+ setattr(args, 'whitelist_file', None)
+ setattr(args, 'blacklist_file', None)
self.assertEqual('i_am_a_fun_little_regex',
self.run_cmd._build_regex(args))