Merge "Moves an incorrectly marked negative test"
diff --git a/requirements.txt b/requirements.txt
index ddd2a6b..c0a9254 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -22,6 +22,6 @@
iso8601>=0.1.9
fixtures>=1.3.1
testscenarios>=0.4
-tempest-lib>=0.9.0
+tempest-lib>=0.10.0
PyYAML>=3.1.0
stevedore>=1.5.0 # Apache-2.0
diff --git a/tempest/api/baremetal/admin/test_ports.py b/tempest/api/baremetal/admin/test_ports.py
index 5eaf641..180b848 100644
--- a/tempest/api/baremetal/admin/test_ports.py
+++ b/tempest/api/baremetal/admin/test_ports.py
@@ -11,7 +11,6 @@
# under the License.
import six
-from tempest_lib import decorators
from tempest_lib import exceptions as lib_exc
from tempest.api.baremetal.admin import base
@@ -60,7 +59,6 @@
_, body = self.client.show_port(uuid)
self._assertExpected(port, body)
- @decorators.skip_because(bug='1398350')
@test.idempotent_id('4a02c4b0-6573-42a4-a513-2e36ad485b62')
def test_create_port_with_extra(self):
node_id = self.node['uuid']
@@ -237,7 +235,6 @@
_, body = self.client.show_port(port['uuid'])
self.assertEqual(extra, body['extra'])
- @decorators.skip_because(bug='1398350')
@test.idempotent_id('5309e897-0799-4649-a982-0179b04c3876')
def test_update_port_mixed_ops(self):
node_id = self.node['uuid']
diff --git a/tempest/api/compute/certificates/test_certificates.py b/tempest/api/compute/certificates/test_certificates.py
index 78a0a93..0096fc2 100644
--- a/tempest/api/compute/certificates/test_certificates.py
+++ b/tempest/api/compute/certificates/test_certificates.py
@@ -14,13 +14,22 @@
# under the License.
from tempest.api.compute import base
+from tempest import config
from tempest import test
+CONF = config.CONF
+
class CertificatesV2TestJSON(base.BaseComputeTest):
_api_version = 2
+ @classmethod
+ def skip_checks(cls):
+ super(CertificatesV2TestJSON, cls).skip_checks()
+ if not CONF.compute_feature_enabled.nova_cert:
+ raise cls.skipException("Nova cert is not available")
+
@test.idempotent_id('c070a441-b08e-447e-a733-905909535b1b')
def test_create_root_certificate(self):
# create certificates
diff --git a/tempest/common/credentials.py b/tempest/common/credentials.py
index 691bd34..28e95e9 100644
--- a/tempest/common/credentials.py
+++ b/tempest/common/credentials.py
@@ -13,9 +13,9 @@
import os
-from tempest.common import accounts
from tempest.common import cred_provider
from tempest.common import dynamic_creds
+from tempest.common import preprov_creds
from tempest import config
from tempest import exceptions
@@ -41,10 +41,10 @@
if (CONF.auth.test_accounts_file and
os.path.isfile(CONF.auth.test_accounts_file)):
# Most params are not relevant for pre-created accounts
- return accounts.Accounts(name=name,
- identity_version=identity_version)
+ return preprov_creds.PreProvisionedCredentialProvider(
+ name=name, identity_version=identity_version)
else:
- return accounts.NotLockingAccounts(
+ return preprov_creds.NonLockingCredentialProvider(
name=name, identity_version=identity_version)
@@ -59,7 +59,8 @@
# Check whether test accounts file has the admin specified or not
elif (CONF.auth.test_accounts_file and
os.path.isfile(CONF.auth.test_accounts_file)):
- check_accounts = accounts.Accounts(name='check_admin')
+ check_accounts = preprov_creds.PreProvisionedCredentialProvider(
+ name='check_admin')
if not check_accounts.admin_available():
is_admin = False
else:
@@ -81,9 +82,11 @@
# Check whether test accounts file has the admin specified or not
if (CONF.auth.test_accounts_file and
os.path.isfile(CONF.auth.test_accounts_file)):
- check_accounts = accounts.Accounts(name='check_alt')
+ check_accounts = preprov_creds.PreProvisionedCredentialProvider(
+ name='check_alt')
else:
- check_accounts = accounts.NotLockingAccounts(name='check_alt')
+ check_accounts = preprov_creds.NonLockingCredentialProvider(
+ name='check_alt')
try:
if not check_accounts.is_multi_user():
return False
diff --git a/tempest/common/accounts.py b/tempest/common/preprov_creds.py
similarity index 97%
rename from tempest/common/accounts.py
rename to tempest/common/preprov_creds.py
index d843fea..eac7f4e 100644
--- a/tempest/common/accounts.py
+++ b/tempest/common/preprov_creds.py
@@ -36,11 +36,11 @@
return accounts
-class Accounts(cred_provider.CredentialProvider):
+class PreProvisionedCredentialProvider(cred_provider.CredentialProvider):
def __init__(self, identity_version=None, name=None):
- super(Accounts, self).__init__(identity_version=identity_version,
- name=name)
+ super(PreProvisionedCredentialProvider, self).__init__(
+ identity_version=identity_version, name=name)
if (CONF.auth.test_accounts_file and
os.path.isfile(CONF.auth.test_accounts_file)):
accounts = read_accounts_yaml(CONF.auth.test_accounts_file)
@@ -249,7 +249,7 @@
'utf-8'), None)
# The force kwarg is used to allocate an additional set of creds with
# the same role list. The index used for the previously allocation
- # in the preprov_creds dict will be moved.
+ # in the _creds dict will be moved.
if exist_creds and not force_new:
return exist_creds
elif exist_creds and force_new:
@@ -295,7 +295,7 @@
return net_creds
-class NotLockingAccounts(Accounts):
+class NonLockingCredentialProvider(PreProvisionedCredentialProvider):
"""Credentials provider which always returns the first and second
configured accounts as primary and alt users.
This credential provider can be used in case of serial test execution
diff --git a/tempest/config.py b/tempest/config.py
index 3c25e1f..d91fb04 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -422,6 +422,9 @@
cfg.BoolOpt('ec2_api',
default=True,
help='Does the test environment have the ec2 api running?'),
+ cfg.BoolOpt('nova_cert',
+ default=True,
+ help='Does the test environment have the nova cert running?'),
# TODO(mriedem): Remove preserve_ports once juno-eol happens.
cfg.BoolOpt('preserve_ports',
default=False,
diff --git a/tempest/manager.py b/tempest/manager.py
index c39d3e5..6a003bc 100644
--- a/tempest/manager.py
+++ b/tempest/manager.py
@@ -47,8 +47,8 @@
# Check if passed or default credentials are valid
if not self.credentials.is_valid():
raise exceptions.InvalidCredentials()
- # Tenant isolation creates TestResources, but Accounts and some tests
- # creates Credentials
+ # Tenant isolation creates TestResources, but
+ # PreProvisionedCredentialProvider and some tests create Credentials
if isinstance(credentials, cred_provider.TestResources):
creds = self.credentials.credentials
else:
diff --git a/tempest/scenario/test_network_v6.py b/tempest/scenario/test_network_v6.py
index a9394cb..3df92cf 100644
--- a/tempest/scenario/test_network_v6.py
+++ b/tempest/scenario/test_network_v6.py
@@ -143,8 +143,9 @@
self._list_ports(device_id=sid,
network_id=self.network_v6.id)]
self.assertEqual(1, len(ports),
- message="Multiple IPv6 ports found on network %s"
- % self.network_v6)
+ message=("Multiple IPv6 ports found on network %s. "
+ "ports: %s")
+ % (self.network_v6, ports))
mac6 = ports[0]
ssh.turn_nic_on(ssh.get_nic_name(mac6))
diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py
index ba419a6..d4bddc0 100644
--- a/tempest/scenario/test_volume_boot_pattern.py
+++ b/tempest/scenario/test_volume_boot_pattern.py
@@ -96,14 +96,6 @@
vol_name = data_utils.rand_name('volume')
return self.create_volume(name=vol_name, snapshot_id=snap_id)
- def _stop_instances(self, instances):
- # NOTE(gfidente): two loops so we do not wait for the status twice
- for i in instances:
- self.servers_client.stop_server(i['id'])
- for i in instances:
- waiters.wait_for_server_status(self.servers_client,
- i['id'], 'SHUTOFF')
-
def _ssh_to_server(self, server, keypair):
if CONF.compute.use_floatingip_for_ssh:
ip = self.create_floating_ip(server)['ip']
@@ -172,10 +164,6 @@
ssh_client = self._ssh_to_server(instance_from_snapshot, keypair)
self._check_content_of_written_file(ssh_client, text)
- # NOTE(gfidente): ensure resources are in clean state for
- # deletion operations to succeed
- self._stop_instances([instance_2nd, instance_from_snapshot])
-
@decorators.skip_because(bug='1489581')
@test.idempotent_id('36c34c67-7b54-4b59-b188-02a2f458a63b')
@test.services('compute', 'volume', 'image')
diff --git a/tempest/services/compute/json/fixed_ips_client.py b/tempest/services/compute/json/fixed_ips_client.py
index d826655..7b374aa 100644
--- a/tempest/services/compute/json/fixed_ips_client.py
+++ b/tempest/services/compute/json/fixed_ips_client.py
@@ -33,4 +33,4 @@
url = "os-fixed-ips/%s/action" % fixed_ip
resp, body = self.post(url, json.dumps(kwargs))
self.validate_response(schema.reserve_unreserve_fixed_ip, resp, body)
- return service_client.ResponseBody(resp)
+ return service_client.ResponseBody(resp, body)
diff --git a/tempest/test_discover/plugins.py b/tempest/test_discover/plugins.py
index 640b004..58a9905 100644
--- a/tempest/test_discover/plugins.py
+++ b/tempest/test_discover/plugins.py
@@ -88,7 +88,11 @@
def register_plugin_opts(self, conf):
for plug in self.ext_plugins:
- plug.obj.register_opts(conf)
+ try:
+ plug.obj.register_opts(conf)
+ except Exception:
+ LOG.exception('Plugin %s raised an exception trying to run '
+ 'register_opts' % plug.name)
def get_plugin_options_list(self):
plugin_options = []
diff --git a/tempest/tests/common/test_admin_available.py b/tempest/tests/common/test_admin_available.py
index cd02597..8490c4d 100644
--- a/tempest/tests/common/test_admin_available.py
+++ b/tempest/tests/common/test_admin_available.py
@@ -50,7 +50,7 @@
'password': 'p',
'types': ['admin']})
self.useFixture(mockpatch.Patch(
- 'tempest.common.accounts.read_accounts_yaml',
+ 'tempest.common.preprov_creds.read_accounts_yaml',
return_value=accounts))
cfg.CONF.set_default('test_accounts_file',
use_accounts_file, group='auth')
diff --git a/tempest/tests/common/test_accounts.py b/tempest/tests/common/test_preprov_creds.py
similarity index 82%
rename from tempest/tests/common/test_accounts.py
rename to tempest/tests/common/test_preprov_creds.py
index 9bf8059..cb7240b 100644
--- a/tempest/tests/common/test_accounts.py
+++ b/tempest/tests/common/test_preprov_creds.py
@@ -24,8 +24,8 @@
from tempest_lib import auth
from tempest_lib.services.identity.v2 import token_client
-from tempest.common import accounts
from tempest.common import cred_provider
+from tempest.common import preprov_creds
from tempest import config
from tempest import exceptions
from tempest.tests import base
@@ -34,10 +34,10 @@
from tempest.tests import fake_identity
-class TestAccount(base.TestCase):
+class TestPreProvisionedCredentials(base.TestCase):
def setUp(self):
- super(TestAccount, self).setUp()
+ super(TestPreProvisionedCredentials, self).setUp()
self.useFixture(fake_config.ConfigFixture())
self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
self.fake_http = fake_http.fake_httplib2(return_type=200)
@@ -71,7 +71,7 @@
'password': 'p', 'roles': [cfg.CONF.identity.admin_role]},
]
self.accounts_mock = self.useFixture(mockpatch.Patch(
- 'tempest.common.accounts.read_accounts_yaml',
+ 'tempest.common.preprov_creds.read_accounts_yaml',
return_value=self.test_accounts))
cfg.CONF.set_default('test_accounts_file', 'fake_path', group='auth')
self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
@@ -88,7 +88,8 @@
def test_get_hash(self):
self.stubs.Set(token_client.TokenClient, 'raw_request',
fake_identity._fake_v2_response)
- test_account_class = accounts.Accounts('v2', 'test_name')
+ test_account_class = preprov_creds.PreProvisionedCredentialProvider(
+ 'v2', 'test_name')
hash_list = self._get_hash_list(self.test_accounts)
test_cred_dict = self.test_accounts[3]
test_creds = auth.get_credentials(fake_identity.FAKE_AUTH_URL,
@@ -97,7 +98,8 @@
self.assertEqual(hash_list[3], results)
def test_get_hash_dict(self):
- test_account_class = accounts.Accounts('v2', 'test_name')
+ test_account_class = preprov_creds.PreProvisionedCredentialProvider(
+ 'v2', 'test_name')
hash_dict = test_account_class.get_hash_dict(self.test_accounts)
hash_list = self._get_hash_list(self.test_accounts)
for hash in hash_list:
@@ -109,7 +111,9 @@
self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
with mock.patch('six.moves.builtins.open', mock.mock_open(),
create=True):
- test_account_class = accounts.Accounts('v2', 'test_name')
+ test_account_class = (
+ preprov_creds.PreProvisionedCredentialProvider(
+ 'v2', 'test_name'))
res = test_account_class._create_hash_file('12345')
self.assertFalse(res, "_create_hash_file should return False if the "
"pseudo-lock file already exists")
@@ -119,7 +123,9 @@
self.useFixture(mockpatch.Patch('os.path.isfile', return_value=False))
with mock.patch('six.moves.builtins.open', mock.mock_open(),
create=True):
- test_account_class = accounts.Accounts('v2', 'test_name')
+ test_account_class = (
+ preprov_creds.PreProvisionedCredentialProvider(
+ 'v2', 'test_name'))
res = test_account_class._create_hash_file('12345')
self.assertTrue(res, "_create_hash_file should return True if the "
"pseudo-lock doesn't already exist")
@@ -131,16 +137,16 @@
hash_list = self._get_hash_list(self.test_accounts)
mkdir_mock = self.useFixture(mockpatch.Patch('os.mkdir'))
self.useFixture(mockpatch.Patch('os.path.isfile', return_value=False))
- test_account_class = accounts.Accounts('v2', 'test_name')
+ test_account_class = preprov_creds.PreProvisionedCredentialProvider(
+ 'v2', 'test_name')
with mock.patch('six.moves.builtins.open', mock.mock_open(),
create=True) as open_mock:
test_account_class._get_free_hash(hash_list)
- lock_path = os.path.join(lockutils.get_lock_path(accounts.CONF),
- 'test_accounts',
- hash_list[0])
+ lock_path = os.path.join(lockutils.get_lock_path(
+ preprov_creds.CONF), 'test_accounts', hash_list[0])
open_mock.assert_called_once_with(lock_path, 'w')
- mkdir_path = os.path.join(accounts.CONF.oslo_concurrency.lock_path,
- 'test_accounts')
+ mkdir_path = os.path.join(
+ preprov_creds.CONF.oslo_concurrency.lock_path, 'test_accounts')
mkdir_mock.mock.assert_called_once_with(mkdir_path)
@mock.patch('oslo_concurrency.lockutils.lock')
@@ -150,7 +156,8 @@
self.useFixture(mockpatch.Patch('os.path.isdir', return_value=True))
# Emulate all lcoks in list are in use
self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
- test_account_class = accounts.Accounts('v2', 'test_name')
+ test_account_class = preprov_creds.PreProvisionedCredentialProvider(
+ 'v2', 'test_name')
with mock.patch('six.moves.builtins.open', mock.mock_open(),
create=True):
self.assertRaises(exceptions.InvalidConfiguration,
@@ -161,7 +168,8 @@
# Emulate no pre-existing lock
self.useFixture(mockpatch.Patch('os.path.isdir', return_value=True))
hash_list = self._get_hash_list(self.test_accounts)
- test_account_class = accounts.Accounts('v2', 'test_name')
+ test_account_class = preprov_creds.PreProvisionedCredentialProvider(
+ 'v2', 'test_name')
def _fake_is_file(path):
# Fake isfile() to return that the path exists unless a specific
@@ -174,9 +182,9 @@
with mock.patch('six.moves.builtins.open', mock.mock_open(),
create=True) as open_mock:
test_account_class._get_free_hash(hash_list)
- lock_path = os.path.join(lockutils.get_lock_path(accounts.CONF),
- 'test_accounts',
- hash_list[3])
+ lock_path = os.path.join(
+ lockutils.get_lock_path(preprov_creds.CONF),
+ 'test_accounts', hash_list[3])
open_mock.assert_has_calls([mock.call(lock_path, 'w')])
@mock.patch('oslo_concurrency.lockutils.lock')
@@ -186,14 +194,15 @@
self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
# Pretend the lock dir is empty
self.useFixture(mockpatch.Patch('os.listdir', return_value=[]))
- test_account_class = accounts.Accounts('v2', 'test_name')
+ test_account_class = preprov_creds.PreProvisionedCredentialProvider(
+ 'v2', 'test_name')
remove_mock = self.useFixture(mockpatch.Patch('os.remove'))
rmdir_mock = self.useFixture(mockpatch.Patch('os.rmdir'))
test_account_class.remove_hash(hash_list[2])
- hash_path = os.path.join(lockutils.get_lock_path(accounts.CONF),
+ hash_path = os.path.join(lockutils.get_lock_path(preprov_creds.CONF),
'test_accounts',
hash_list[2])
- lock_path = os.path.join(accounts.CONF.oslo_concurrency.lock_path,
+ lock_path = os.path.join(preprov_creds.CONF.oslo_concurrency.lock_path,
'test_accounts')
remove_mock.mock.assert_called_once_with(hash_path)
rmdir_mock.mock.assert_called_once_with(lock_path)
@@ -206,33 +215,37 @@
# Pretend the lock dir is empty
self.useFixture(mockpatch.Patch('os.listdir', return_value=[
hash_list[1], hash_list[4]]))
- test_account_class = accounts.Accounts('v2', 'test_name')
+ test_account_class = preprov_creds.PreProvisionedCredentialProvider(
+ 'v2', 'test_name')
remove_mock = self.useFixture(mockpatch.Patch('os.remove'))
rmdir_mock = self.useFixture(mockpatch.Patch('os.rmdir'))
test_account_class.remove_hash(hash_list[2])
- hash_path = os.path.join(lockutils.get_lock_path(accounts.CONF),
+ hash_path = os.path.join(lockutils.get_lock_path(preprov_creds.CONF),
'test_accounts',
hash_list[2])
remove_mock.mock.assert_called_once_with(hash_path)
rmdir_mock.mock.assert_not_called()
def test_is_multi_user(self):
- test_accounts_class = accounts.Accounts('v2', 'test_name')
+ test_accounts_class = preprov_creds.PreProvisionedCredentialProvider(
+ 'v2', 'test_name')
self.assertTrue(test_accounts_class.is_multi_user())
def test_is_not_multi_user(self):
self.test_accounts = [self.test_accounts[0]]
self.useFixture(mockpatch.Patch(
- 'tempest.common.accounts.read_accounts_yaml',
+ 'tempest.common.preprov_creds.read_accounts_yaml',
return_value=self.test_accounts))
- test_accounts_class = accounts.Accounts('v2', 'test_name')
+ test_accounts_class = preprov_creds.PreProvisionedCredentialProvider(
+ 'v2', 'test_name')
self.assertFalse(test_accounts_class.is_multi_user())
def test__get_creds_by_roles_one_role(self):
self.useFixture(mockpatch.Patch(
- 'tempest.common.accounts.read_accounts_yaml',
+ 'tempest.common.preprov_creds.read_accounts_yaml',
return_value=self.test_accounts))
- test_accounts_class = accounts.Accounts('v2', 'test_name')
+ test_accounts_class = preprov_creds.PreProvisionedCredentialProvider(
+ 'v2', 'test_name')
hashes = test_accounts_class.hash_dict['roles']['role4']
temp_hash = hashes[0]
get_free_hash_mock = self.useFixture(mockpatch.PatchObject(
@@ -247,9 +260,10 @@
def test__get_creds_by_roles_list_role(self):
self.useFixture(mockpatch.Patch(
- 'tempest.common.accounts.read_accounts_yaml',
+ 'tempest.common.preprov_creds.read_accounts_yaml',
return_value=self.test_accounts))
- test_accounts_class = accounts.Accounts('v2', 'test_name')
+ test_accounts_class = preprov_creds.PreProvisionedCredentialProvider(
+ 'v2', 'test_name')
hashes = test_accounts_class.hash_dict['roles']['role4']
hashes2 = test_accounts_class.hash_dict['roles']['role2']
hashes = list(set(hashes) & set(hashes2))
@@ -266,9 +280,10 @@
def test__get_creds_by_roles_no_admin(self):
self.useFixture(mockpatch.Patch(
- 'tempest.common.accounts.read_accounts_yaml',
+ 'tempest.common.preprov_creds.read_accounts_yaml',
return_value=self.test_accounts))
- test_accounts_class = accounts.Accounts('v2', 'test_name')
+ test_accounts_class = preprov_creds.PreProvisionedCredentialProvider(
+ 'v2', 'test_name')
hashes = list(test_accounts_class.hash_dict['creds'].keys())
admin_hashes = test_accounts_class.hash_dict['roles'][
cfg.CONF.identity.admin_role]
@@ -292,9 +307,10 @@
'password': 'p', 'roles': ['role-7', 'role-11'],
'resources': {'network': 'network-2'}}]
self.useFixture(mockpatch.Patch(
- 'tempest.common.accounts.read_accounts_yaml',
+ 'tempest.common.preprov_creds.read_accounts_yaml',
return_value=test_accounts))
- test_accounts_class = accounts.Accounts('v2', 'test_name')
+ test_accounts_class = preprov_creds.PreProvisionedCredentialProvider(
+ 'v2', 'test_name')
with mock.patch('tempest.services.compute.json.networks_client.'
'NetworksClient.list_networks',
return_value={'networks': [{'name': 'network-2',
@@ -326,13 +342,14 @@
'password': 'p'},
]
self.useFixture(mockpatch.Patch(
- 'tempest.common.accounts.read_accounts_yaml',
+ 'tempest.common.preprov_creds.read_accounts_yaml',
return_value=self.test_accounts))
cfg.CONF.set_default('test_accounts_file', '', group='auth')
self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
def test_get_creds_roles_nonlocking_invalid(self):
- test_accounts_class = accounts.NotLockingAccounts('v2', 'test_name')
+ test_accounts_class = preprov_creds.NonLockingCredentialProvider(
+ 'v2', 'test_name')
self.assertRaises(exceptions.InvalidConfiguration,
test_accounts_class.get_creds_by_roles,
['fake_role'])
diff --git a/tempest/tests/services/compute/test_fixedIPs_client.py b/tempest/tests/services/compute/test_fixedIPs_client.py
index 5acb422..b537baa 100644
--- a/tempest/tests/services/compute/test_fixedIPs_client.py
+++ b/tempest/tests/services/compute/test_fixedIPs_client.py
@@ -44,3 +44,16 @@
def test_show_fixed_ip_with_bytes_body(self):
self._test_show_fixed_ip(True)
+
+ def _test_reserve_fixed_ip(self, bytes_body=False):
+ self.check_service_client_function(
+ self.fixedIPsClient.reserve_fixed_ip,
+ 'tempest.common.service_client.ServiceClient.post',
+ {}, bytes_body,
+ status=202, fixed_ip='Identifier')
+
+ def test_reserve_fixed_ip_with_str_body(self):
+ self._test_reserve_fixed_ip()
+
+ def test_reserve_fixed_ip_with_bytes_body(self):
+ self._test_reserve_fixed_ip(True)