Inclusive jargon
Following tempest's example where arguments such as --blacklist-file, --black-regex and --whitelist-file are deprecated by [1], let's do the change here as well. A few occurrences cannot be renamed atm as refstack-client uses an older tempest version which doesn't contain the change [1] yet. After we update the tempest version used in this project, the rest occurrences will be renamed as well. [1] https://review.opendev.org/c/openstack/tempest/+/768583 Change-Id: I514fb688f6895338a877cbc706ddd8d6fc5f906d
This commit is contained in:
parent
2fc66e3502
commit
1fce1e362e
@ -191,9 +191,9 @@ class TestListParser(object):
|
||||
list_file = self._write_normalized_test_list(full_capability_test_ids)
|
||||
return list_file
|
||||
|
||||
def create_whitelist(self, list_location):
|
||||
"""This takes in a test list file, get normalized, and get whitelist
|
||||
regexes using full qualified test names (one per line).
|
||||
def create_include_list(self, list_location):
|
||||
"""This takes in a test list file, get normalized, and get list of
|
||||
include regexes using full qualified test names (one per line).
|
||||
Ex:
|
||||
'tempest.test1[id-2,gate]' -> tempest.test1\[ # noqa: W605
|
||||
'tempest.test2[id-3,smoke](scenario)' -> tempest.test2\[ # noqa: W605
|
||||
|
@ -535,10 +535,14 @@ class RefstackClient:
|
||||
self.logger.info("Normalizing test list...")
|
||||
parser = TestListParser(os.path.abspath(self.tempest_dir),
|
||||
insecure=self.args.insecure)
|
||||
# get whitelist
|
||||
list_file = parser.create_whitelist(self.args.test_list)
|
||||
# get include list
|
||||
list_file = parser.create_include_list(self.args.test_list)
|
||||
if list_file:
|
||||
if os.path.getsize(list_file) > 0:
|
||||
# TODO(kopecmartin) rename the below argument when
|
||||
# refstack-client uses tempest which contains the following
|
||||
# change in its code:
|
||||
# https://review.opendev.org/c/openstack/tempest/+/768583
|
||||
cmd += ('--whitelist_file', list_file)
|
||||
else:
|
||||
self.logger.error("Test list is either empty or no valid "
|
||||
@ -922,8 +926,7 @@ def parse_cli_args(args=None):
|
||||
'specific test cases or test lists. '
|
||||
'Some examples are: -- --regex '
|
||||
'tempest.api.compute.images.'
|
||||
'test_list_image_filters OR '
|
||||
'-- --whitelist_file /tmp/testid-list.txt')
|
||||
'test_list_image_filters')
|
||||
parser_test.set_defaults(func="test")
|
||||
|
||||
# List command
|
||||
|
@ -646,10 +646,12 @@ class TestRefstackClient(unittest.TestCase):
|
||||
sign_with='rsa_key'
|
||||
)
|
||||
|
||||
@mock.patch('refstack_client.list_parser.TestListParser.create_whitelist')
|
||||
@mock.patch('refstack_client.list_parser.TestListParser.'
|
||||
'create_include_list')
|
||||
@mock.patch('refstack_client.list_parser.'
|
||||
'TestListParser.get_normalized_test_list')
|
||||
def test_run_tempest_with_test_list(self, mock_normalize, mock_whitelist):
|
||||
def test_run_tempest_with_test_list(self, mock_normalize,
|
||||
mock_include_list):
|
||||
"""Test that the Tempest script runs with a test list file."""
|
||||
argv = self.mock_argv(verbose='-vv')
|
||||
argv.extend(['--test-list', 'test-list.txt'])
|
||||
@ -666,12 +668,15 @@ class TestRefstackClient(unittest.TestCase):
|
||||
client._save_json_results = MagicMock()
|
||||
client.post_results = MagicMock()
|
||||
mock_normalize.return_value = '/tmp/some-list'
|
||||
mock_whitelist.return_value = '/tmp/some-list'
|
||||
mock_include_list.return_value = '/tmp/some-list'
|
||||
client._get_keystone_config = MagicMock(
|
||||
return_value=self.v2_config)
|
||||
client.test()
|
||||
|
||||
mock_whitelist.assert_called_with('test-list.txt')
|
||||
mock_include_list.assert_called_with('test-list.txt')
|
||||
# TODO(kopecmartin) rename the below argument when refstack-client
|
||||
# uses tempest which contains the following change in its code:
|
||||
# https://review.opendev.org/c/openstack/tempest/+/768583
|
||||
mock_popen.assert_called_with(
|
||||
['%s/tools/with_venv.sh' % self.test_path, 'tempest', 'run',
|
||||
'--serial', '--concurrency', '0', '--whitelist_file',
|
||||
@ -903,8 +908,9 @@ class TestRefstackClient(unittest.TestCase):
|
||||
self.assertEqual(os.environ.get('TEMPEST_CONFIG_DIR'), conf_dir)
|
||||
self.assertEqual(os.environ.get('TEMPEST_CONFIG'), conf_file)
|
||||
|
||||
@mock.patch('refstack_client.list_parser.TestListParser.create_whitelist')
|
||||
def test_run_tempest_with_empty_test_list(self, mock_whitelist):
|
||||
@mock.patch('refstack_client.list_parser.TestListParser.'
|
||||
'create_include_list')
|
||||
def test_run_tempest_with_empty_test_list(self, mock_include_list):
|
||||
"""Test that refstack-client can handle an empty test list file."""
|
||||
argv = self.mock_argv(verbose='-vv')
|
||||
argv.extend(['--test-list', 'foo.txt'])
|
||||
@ -918,7 +924,7 @@ class TestRefstackClient(unittest.TestCase):
|
||||
client.tempest_dir = self.test_path
|
||||
self.patch("os.path.isfile", return_value=True)
|
||||
empty_file = tempfile.NamedTemporaryFile()
|
||||
mock_whitelist.return_value = empty_file.name
|
||||
mock_include_list.return_value = empty_file.name
|
||||
self.assertRaises(SystemExit, client.test)
|
||||
|
||||
def test_run_tempest_with_non_exist_test_list_file(self):
|
||||
|
@ -171,7 +171,7 @@ class TestTestListParser(unittest.TestCase):
|
||||
self.assertEqual(test_ids, testcase_list)
|
||||
|
||||
@mock.patch.object(parser.TestListParser, "get_normalized_test_list")
|
||||
def test_create_whitelist(self, mock_get_normalized):
|
||||
def test_create_include_list(self, mock_get_normalized):
|
||||
"""Test whether a test list is properly parsed to extract test names"""
|
||||
test_list = [
|
||||
"tempest.test.one[id-11111111-2222-3333-4444-555555555555,gate]",
|
||||
@ -188,5 +188,5 @@ class TestTestListParser(unittest.TestCase):
|
||||
[f.write(item + "\n") for item in test_list]
|
||||
mock_get_normalized.return_value = tmpfile
|
||||
|
||||
result = open(self.parser.create_whitelist(tmpfile)).read()
|
||||
result = open(self.parser.create_include_list(tmpfile)).read()
|
||||
self.assertEqual(result, expected_list)
|
||||
|
Loading…
Reference in New Issue
Block a user