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:
Martin Kopec 2020-12-24 20:43:14 +00:00
parent 2fc66e3502
commit 1fce1e362e
4 changed files with 25 additions and 16 deletions

@ -191,9 +191,9 @@ class TestListParser(object):
list_file = self._write_normalized_test_list(full_capability_test_ids) list_file = self._write_normalized_test_list(full_capability_test_ids)
return list_file return list_file
def create_whitelist(self, list_location): def create_include_list(self, list_location):
"""This takes in a test list file, get normalized, and get whitelist """This takes in a test list file, get normalized, and get list of
regexes using full qualified test names (one per line). include regexes using full qualified test names (one per line).
Ex: Ex:
'tempest.test1[id-2,gate]' -> tempest.test1\[ # noqa: W605 'tempest.test1[id-2,gate]' -> tempest.test1\[ # noqa: W605
'tempest.test2[id-3,smoke](scenario)' -> tempest.test2\[ # noqa: W605 'tempest.test2[id-3,smoke](scenario)' -> tempest.test2\[ # noqa: W605

@ -535,10 +535,14 @@ class RefstackClient:
self.logger.info("Normalizing test list...") self.logger.info("Normalizing test list...")
parser = TestListParser(os.path.abspath(self.tempest_dir), parser = TestListParser(os.path.abspath(self.tempest_dir),
insecure=self.args.insecure) insecure=self.args.insecure)
# get whitelist # get include list
list_file = parser.create_whitelist(self.args.test_list) list_file = parser.create_include_list(self.args.test_list)
if list_file: if list_file:
if os.path.getsize(list_file) > 0: 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) cmd += ('--whitelist_file', list_file)
else: else:
self.logger.error("Test list is either empty or no valid " 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. ' 'specific test cases or test lists. '
'Some examples are: -- --regex ' 'Some examples are: -- --regex '
'tempest.api.compute.images.' 'tempest.api.compute.images.'
'test_list_image_filters OR ' 'test_list_image_filters')
'-- --whitelist_file /tmp/testid-list.txt')
parser_test.set_defaults(func="test") parser_test.set_defaults(func="test")
# List command # List command

@ -646,10 +646,12 @@ class TestRefstackClient(unittest.TestCase):
sign_with='rsa_key' 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.' @mock.patch('refstack_client.list_parser.'
'TestListParser.get_normalized_test_list') '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.""" """Test that the Tempest script runs with a test list file."""
argv = self.mock_argv(verbose='-vv') argv = self.mock_argv(verbose='-vv')
argv.extend(['--test-list', 'test-list.txt']) argv.extend(['--test-list', 'test-list.txt'])
@ -666,12 +668,15 @@ class TestRefstackClient(unittest.TestCase):
client._save_json_results = MagicMock() client._save_json_results = MagicMock()
client.post_results = MagicMock() client.post_results = MagicMock()
mock_normalize.return_value = '/tmp/some-list' 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( client._get_keystone_config = MagicMock(
return_value=self.v2_config) return_value=self.v2_config)
client.test() 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( mock_popen.assert_called_with(
['%s/tools/with_venv.sh' % self.test_path, 'tempest', 'run', ['%s/tools/with_venv.sh' % self.test_path, 'tempest', 'run',
'--serial', '--concurrency', '0', '--whitelist_file', '--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_DIR'), conf_dir)
self.assertEqual(os.environ.get('TEMPEST_CONFIG'), conf_file) self.assertEqual(os.environ.get('TEMPEST_CONFIG'), conf_file)
@mock.patch('refstack_client.list_parser.TestListParser.create_whitelist') @mock.patch('refstack_client.list_parser.TestListParser.'
def test_run_tempest_with_empty_test_list(self, mock_whitelist): '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.""" """Test that refstack-client can handle an empty test list file."""
argv = self.mock_argv(verbose='-vv') argv = self.mock_argv(verbose='-vv')
argv.extend(['--test-list', 'foo.txt']) argv.extend(['--test-list', 'foo.txt'])
@ -918,7 +924,7 @@ class TestRefstackClient(unittest.TestCase):
client.tempest_dir = self.test_path client.tempest_dir = self.test_path
self.patch("os.path.isfile", return_value=True) self.patch("os.path.isfile", return_value=True)
empty_file = tempfile.NamedTemporaryFile() empty_file = tempfile.NamedTemporaryFile()
mock_whitelist.return_value = empty_file.name mock_include_list.return_value = empty_file.name
self.assertRaises(SystemExit, client.test) self.assertRaises(SystemExit, client.test)
def test_run_tempest_with_non_exist_test_list_file(self): 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) self.assertEqual(test_ids, testcase_list)
@mock.patch.object(parser.TestListParser, "get_normalized_test_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 whether a test list is properly parsed to extract test names"""
test_list = [ test_list = [
"tempest.test.one[id-11111111-2222-3333-4444-555555555555,gate]", "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] [f.write(item + "\n") for item in test_list]
mock_get_normalized.return_value = tmpfile 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) self.assertEqual(result, expected_list)