Merge "Remove checks for ipv6 utilities before use"
diff --git a/doc/source/plugin.rst b/doc/source/plugin.rst
index 72db6e9..a41038c 100644
--- a/doc/source/plugin.rst
+++ b/doc/source/plugin.rst
@@ -20,8 +20,43 @@
to tempest-lib. In that situation, file a bug, push a migration patch, etc. to
expedite providing the interface in a reliable manner.
+Plugin Cookiecutter
+-------------------
+
+In order to create the basic structure with base classes and test directories
+you can use the tempest-plugin-cookiecutter project::
+
+ > cookiecutter https://git.openstack.org/openstack/tempest-plugin-cookiecutter
+
+ Cloning into 'tempest-plugin-cookiecutter'...
+ remote: Counting objects: 17, done.
+ remote: Compressing objects: 100% (13/13), done.
+ remote: Total 17 (delta 1), reused 14 (delta 1)
+ Unpacking objects: 100% (17/17), done.
+ Checking connectivity... done.
+ project (default is "sample")? foo
+ testclass (default is "SampleTempestPlugin")? FooTempestPlugin
+
+This would create a folder called ``foo_tempest_plugin/`` with all necessary
+basic classes. You only need to move/create your test in
+``foo_tempest_plugin/tests``.
+
+Entry Point
+-----------
+
+Once you've created your plugin class you need to add an entry point to your
+project to enable tempest to find the plugin. The entry point must be added
+to the "tempest.test_plugins" namespace.
+
+If you are using pbr this is fairly straightforward, in the setup.cfg just add
+something like the following::
+
+ [entry_points]
+ tempest.test_plugins =
+ plugin_name = module.path:PluginClass
+
Plugin Class
-------------
+============
To provide tempest with all the required information it needs to be able to run
your plugin you need to create a plugin class which tempest will load and call
@@ -42,28 +77,13 @@
as the source for the abstract class will be prudent.
Abstract Plugin Class
-^^^^^^^^^^^^^^^^^^^^^
+---------------------
.. autoclass:: tempest.test_discover.plugins.TempestPlugin
:members:
-Entry Point
------------
-
-Once you've created your plugin class you need to add an entry point to your
-project to enable tempest to find the plugin. The entry point must be added
-to the "tempest.test_plugins" namespace.
-
-If you are using pbr this is fairly straightforward, in the setup.cfg just add
-something like the following::
-
- [entry_points]
- tempest.test_plugins =
- plugin_name = module.path:PluginClass
-
Plugin Structure
-----------------
-
+================
While there are no hard and fast rules for the structure a plugin, there are
basically no constraints on what the plugin looks like as long as the 2 steps
above are done. However, there are some recommended patterns to follow to make
@@ -92,7 +112,7 @@
being added in the plugin act and behave like the rest of tempest.
Dealing with configuration options
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+----------------------------------
Historically Tempest didn't provide external guarantees on its configuration
options. However, with the introduction of the plugin interface this is no
diff --git a/requirements.txt b/requirements.txt
index c0a9254..59d6856 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -13,11 +13,11 @@
testrepository>=0.0.18
pyOpenSSL>=0.14
oslo.concurrency>=2.3.0 # Apache-2.0
-oslo.config>=2.3.0 # Apache-2.0
+oslo.config>=2.6.0 # Apache-2.0
oslo.i18n>=1.5.0 # Apache-2.0
oslo.log>=1.8.0 # Apache-2.0
-oslo.serialization>=1.4.0 # Apache-2.0
-oslo.utils>=2.0.0 # Apache-2.0
+oslo.serialization>=1.10.0 # Apache-2.0
+oslo.utils!=2.6.0,>=2.4.0 # Apache-2.0
six>=1.9.0
iso8601>=0.1.9
fixtures>=1.3.1
diff --git a/tempest/api/compute/admin/test_live_migration.py b/tempest/api/compute/admin/test_live_migration.py
index 34ec78d..f186a7d 100644
--- a/tempest/api/compute/admin/test_live_migration.py
+++ b/tempest/api/compute/admin/test_live_migration.py
@@ -14,8 +14,6 @@
# under the License.
-from collections import namedtuple
-
import testtools
from tempest.api.compute import base
@@ -26,9 +24,6 @@
CONF = config.CONF
-CreatedServer = namedtuple('CreatedServer', 'server_id, volume_backed')
-
-
class LiveBlockMigrationTestJSON(base.BaseV2ComputeAdminTest):
_host_key = 'OS-EXT-SRV-ATTR:host'
@@ -39,14 +34,6 @@
cls.admin_servers_client = cls.os_adm.servers_client
cls.admin_migration_client = cls.os_adm.migrations_client
- @classmethod
- def resource_setup(cls):
- super(LiveBlockMigrationTestJSON, cls).resource_setup()
-
- # list of CreatedServer namedtuples
- # TODO(mriedem): Remove the instance variable and shared server re-use
- cls.created_servers = []
-
def _get_compute_hostnames(self):
body = self.admin_hosts_client.list_hosts()['hosts']
return [
@@ -62,18 +49,12 @@
def _get_host_for_server(self, server_id):
return self._get_server_details(server_id)[self._host_key]
- def _migrate_server_to(self, server_id, dest_host):
- # volume backed instances shouldn't be block migrated
- for id, volume_backed in self.created_servers:
- if server_id == id:
- use_block_migration = not volume_backed
- break
- else:
- raise ValueError('Server with id %s not found.' % server_id)
- bmflm = (CONF.compute_feature_enabled.
- block_migration_for_live_migration and use_block_migration)
+ def _migrate_server_to(self, server_id, dest_host, volume_backed):
+ block_migration = (CONF.compute_feature_enabled.
+ block_migration_for_live_migration and
+ not volume_backed)
body = self.admin_servers_client.live_migrate_server(
- server_id, host=dest_host, block_migration=bmflm,
+ server_id, host=dest_host, block_migration=block_migration,
disk_over_commit=False)
return body
@@ -85,19 +66,10 @@
def _get_server_status(self, server_id):
return self._get_server_details(server_id)['status']
- def _get_an_active_server(self, volume_backed=False):
- for server_id, vol_backed in self.created_servers:
- if ('ACTIVE' == self._get_server_status(server_id) and
- volume_backed == vol_backed):
- return server_id
- else:
+ def _create_server(self, volume_backed=False):
server = self.create_test_server(wait_until="ACTIVE",
volume_backed=volume_backed)
- server_id = server['id']
- new_server = CreatedServer(server_id=server_id,
- volume_backed=volume_backed)
- self.created_servers.append(new_server)
- return server_id
+ return server['id']
def _volume_clean_up(self, server_id, volume_id):
body = self.volumes_client.show_volume(volume_id)['volume']
@@ -117,11 +89,11 @@
:param volume_backed: If the instance is volume backed or not. If
volume_backed, *block* migration is not used.
"""
- # Live block migrate an instance to another host
+ # Live migrate an instance to another host
if len(self._get_compute_hostnames()) < 2:
raise self.skipTest(
"Less than 2 compute nodes, skipping migration test.")
- server_id = self._get_an_active_server(volume_backed=volume_backed)
+ server_id = self._create_server(volume_backed=volume_backed)
actual_host = self._get_host_for_server(server_id)
target_host = self._get_host_other_than(actual_host)
@@ -130,7 +102,7 @@
waiters.wait_for_server_status(self.admin_servers_client,
server_id, state)
- self._migrate_server_to(server_id, target_host)
+ self._migrate_server_to(server_id, target_host, volume_backed)
waiters.wait_for_server_status(self.servers_client, server_id, state)
migration_list = (self.admin_migration_client.list_migrations()
['migrations'])
@@ -178,11 +150,10 @@
block_migrate_cinder_iscsi,
'Block Live migration not configured for iSCSI')
def test_iscsi_volume(self):
- # Live block migrate an instance to another host
if len(self._get_compute_hostnames()) < 2:
raise self.skipTest(
"Less than 2 compute nodes, skipping migration test.")
- server_id = self._get_an_active_server()
+ server_id = self._create_server()
actual_host = self._get_host_for_server(server_id)
target_host = self._get_host_other_than(actual_host)
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 26cf180..17adfa5 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -221,7 +221,7 @@
ext_gw_info = {}
if external_network_id:
ext_gw_info['network_id'] = external_network_id
- if enable_snat:
+ if enable_snat is not None:
ext_gw_info['enable_snat'] = enable_snat
body = cls.client.create_router(
router_name, external_gateway_info=ext_gw_info,
diff --git a/tempest/api_schema/response/compute/v2_1/hypervisors.py b/tempest/api_schema/response/compute/v2_1/hypervisors.py
deleted file mode 100644
index 05901b6..0000000
--- a/tempest/api_schema/response/compute/v2_1/hypervisors.py
+++ /dev/null
@@ -1,195 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import copy
-
-from tempest.api_schema.response.compute.v2_1 import parameter_types
-
-get_hypervisor_statistics = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'hypervisor_statistics': {
- 'type': 'object',
- 'properties': {
- 'count': {'type': 'integer'},
- 'current_workload': {'type': 'integer'},
- 'disk_available_least': {'type': ['integer', 'null']},
- 'free_disk_gb': {'type': 'integer'},
- 'free_ram_mb': {'type': 'integer'},
- 'local_gb': {'type': 'integer'},
- 'local_gb_used': {'type': 'integer'},
- 'memory_mb': {'type': 'integer'},
- 'memory_mb_used': {'type': 'integer'},
- 'running_vms': {'type': 'integer'},
- 'vcpus': {'type': 'integer'},
- 'vcpus_used': {'type': 'integer'}
- },
- 'additionalProperties': False,
- 'required': ['count', 'current_workload',
- 'disk_available_least', 'free_disk_gb',
- 'free_ram_mb', 'local_gb', 'local_gb_used',
- 'memory_mb', 'memory_mb_used', 'running_vms',
- 'vcpus', 'vcpus_used']
- }
- },
- 'additionalProperties': False,
- 'required': ['hypervisor_statistics']
- }
-}
-
-
-hypervisor_detail = {
- 'type': 'object',
- 'properties': {
- 'status': {'type': 'string'},
- 'state': {'type': 'string'},
- 'cpu_info': {'type': 'string'},
- 'current_workload': {'type': 'integer'},
- 'disk_available_least': {'type': ['integer', 'null']},
- 'host_ip': parameter_types.ip_address,
- 'free_disk_gb': {'type': 'integer'},
- 'free_ram_mb': {'type': 'integer'},
- 'hypervisor_hostname': {'type': 'string'},
- 'hypervisor_type': {'type': 'string'},
- 'hypervisor_version': {'type': 'integer'},
- 'id': {'type': ['integer', 'string']},
- 'local_gb': {'type': 'integer'},
- 'local_gb_used': {'type': 'integer'},
- 'memory_mb': {'type': 'integer'},
- 'memory_mb_used': {'type': 'integer'},
- 'running_vms': {'type': 'integer'},
- 'service': {
- 'type': 'object',
- 'properties': {
- 'host': {'type': 'string'},
- 'id': {'type': ['integer', 'string']},
- 'disabled_reason': {'type': ['string', 'null']}
- },
- 'additionalProperties': False,
- 'required': ['host', 'id']
- },
- 'vcpus': {'type': 'integer'},
- 'vcpus_used': {'type': 'integer'}
- },
- 'additionalProperties': False,
- # NOTE: When loading os-hypervisor-status extension,
- # a response contains status and state. So these params
- # should not be required.
- 'required': ['cpu_info', 'current_workload',
- 'disk_available_least', 'host_ip',
- 'free_disk_gb', 'free_ram_mb',
- 'hypervisor_hostname', 'hypervisor_type',
- 'hypervisor_version', 'id', 'local_gb',
- 'local_gb_used', 'memory_mb', 'memory_mb_used',
- 'running_vms', 'service', 'vcpus', 'vcpus_used']
-}
-
-list_hypervisors_detail = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'hypervisors': {
- 'type': 'array',
- 'items': hypervisor_detail
- }
- },
- 'additionalProperties': False,
- 'required': ['hypervisors']
- }
-}
-
-get_hypervisor = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'hypervisor': hypervisor_detail
- },
- 'additionalProperties': False,
- 'required': ['hypervisor']
- }
-}
-
-list_search_hypervisors = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'hypervisors': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'status': {'type': 'string'},
- 'state': {'type': 'string'},
- 'id': {'type': ['integer', 'string']},
- 'hypervisor_hostname': {'type': 'string'}
- },
- 'additionalProperties': False,
- # NOTE: When loading os-hypervisor-status extension,
- # a response contains status and state. So these params
- # should not be required.
- 'required': ['id', 'hypervisor_hostname']
- }
- }
- },
- 'additionalProperties': False,
- 'required': ['hypervisors']
- }
-}
-
-get_hypervisor_uptime = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'hypervisor': {
- 'type': 'object',
- 'properties': {
- 'status': {'type': 'string'},
- 'state': {'type': 'string'},
- 'id': {'type': ['integer', 'string']},
- 'hypervisor_hostname': {'type': 'string'},
- 'uptime': {'type': 'string'}
- },
- 'additionalProperties': False,
- # NOTE: When loading os-hypervisor-status extension,
- # a response contains status and state. So these params
- # should not be required.
- 'required': ['id', 'hypervisor_hostname', 'uptime']
- }
- },
- 'additionalProperties': False,
- 'required': ['hypervisor']
- }
-}
-
-get_hypervisors_servers = copy.deepcopy(list_search_hypervisors)
-get_hypervisors_servers['response_body']['properties']['hypervisors']['items'][
- 'properties']['servers'] = {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'uuid': {'type': 'string'},
- 'name': {'type': 'string'}
- },
- 'additionalProperties': False,
- }
- }
-# In V2 API, if there is no servers (VM) on the Hypervisor host then 'servers'
-# attribute will not be present in response body So it is not 'required'.
diff --git a/tempest/clients.py b/tempest/clients.py
index 43dd316..84e8544 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -33,6 +33,8 @@
from tempest_lib.services.compute.floating_ips_bulk_client import \
FloatingIPsBulkClient
from tempest_lib.services.compute.hosts_client import HostsClient
+from tempest_lib.services.compute.hypervisor_client import \
+ HypervisorClient
from tempest_lib.services.identity.v2.token_client import TokenClient
from tempest_lib.services.identity.v3.token_client import V3TokenClient
@@ -46,8 +48,6 @@
from tempest.services import botoclients
from tempest.services.compute.json.floating_ips_client import \
FloatingIPsClient
-from tempest.services.compute.json.hypervisor_client import \
- HypervisorClient
from tempest.services.compute.json.images_client import ImagesClient
from tempest.services.compute.json.instance_usage_audit_log_client import \
InstanceUsagesAuditLogClient
diff --git a/tempest/cmd/main.py b/tempest/cmd/main.py
index 762e982..577df9b 100644
--- a/tempest/cmd/main.py
+++ b/tempest/cmd/main.py
@@ -16,8 +16,7 @@
from cliff import app
from cliff import commandmanager
-
-TEMPEST_CLI_VERSION = '0.1'
+from pbr import version
class Main(app.App):
@@ -27,7 +26,7 @@
def __init__(self):
super(Main, self).__init__(
description='Tempest cli application',
- version=TEMPEST_CLI_VERSION,
+ version=version.VersionInfo('tempest').version_string(),
command_manager=commandmanager.CommandManager('tempest.cm'),
)
diff --git a/tempest/common/cred_client.py b/tempest/common/cred_client.py
index 4d391d0..79a502a 100644
--- a/tempest/common/cred_client.py
+++ b/tempest/common/cred_client.py
@@ -14,14 +14,11 @@
from oslo_log import log as logging
import six
+from tempest_lib import auth
from tempest_lib import exceptions as lib_exc
-from tempest.common import cred_provider
-from tempest import config
-from tempest import exceptions
from tempest.services.identity.v2.json import identity_client as v2_identity
-CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -36,7 +33,6 @@
def __init__(self, identity_client):
# The client implies version and credentials
self.identity_client = identity_client
- self.credentials = self.identity_client.auth_provider.credentials
def create_user(self, username, password, project, email):
user = self.identity_client.create_user(
@@ -75,6 +71,13 @@
@abc.abstractmethod
def get_credentials(self, user, project, password):
+ """Produces a Credentials object from the details provided
+
+ :param user: a user dict
+ :param project: a project dict
+ :param password: the password as a string
+ :return: a Credentials object with all the available credential details
+ """
pass
def delete_user(self, user_id):
@@ -93,7 +96,11 @@
return tenant
def get_credentials(self, user, project, password):
- return cred_provider.get_credentials(
+ # User and project already include both ID and name here,
+ # so there's no need to use the fill_in mode
+ return auth.get_credentials(
+ auth_url=None,
+ fill_in=False,
identity_version='v2',
username=user['name'], user_id=user['id'],
tenant_name=project['name'], tenant_id=project['id'],
@@ -114,8 +121,8 @@
params={'name': domain_name})['domains'][0]
except lib_exc.NotFound:
# TODO(andrea) we could probably create the domain on the fly
- msg = "Configured domain %s could not be found" % domain_name
- raise exceptions.InvalidConfiguration(msg)
+ msg = "Requested domain %s could not be found" % domain_name
+ raise lib_exc.InvalidCredentials(msg)
def create_project(self, name, description):
project = self.identity_client.create_project(
@@ -124,11 +131,16 @@
return project
def get_credentials(self, user, project, password):
- return cred_provider.get_credentials(
+ # User, project and domain already include both ID and name here,
+ # so there's no need to use the fill_in mode.
+ return auth.get_credentials(
+ auth_url=None,
+ fill_in=False,
identity_version='v3',
username=user['name'], user_id=user['id'],
project_name=project['name'], project_id=project['id'],
password=password,
+ project_domain_id=self.creds_domain['id'],
project_domain_name=self.creds_domain['name'])
def delete_project(self, project_id):
diff --git a/tempest/common/cred_provider.py b/tempest/common/cred_provider.py
index eb4c4a8..3575998 100644
--- a/tempest/common/cred_provider.py
+++ b/tempest/common/cred_provider.py
@@ -98,17 +98,22 @@
@six.add_metaclass(abc.ABCMeta)
class CredentialProvider(object):
- def __init__(self, identity_version, name=None,
- network_resources=None):
+ def __init__(self, identity_version, name=None, network_resources=None,
+ credentials_domain=None, admin_role=None):
"""A CredentialProvider supplies credentials to test classes.
:param identity_version: Identity version of the credentials provided
:param name: Name of the calling test. Included in provisioned
credentials when credentials are provisioned on the fly
:param network_resources: Network resources required for the
credentials
+ :param credentials_domain: Domain credentials belong to
+ :param admin_role: Name of the role of the admin account
"""
- self.name = name or "test_creds"
self.identity_version = identity_version
+ self.name = name or "test_creds"
+ self.network_resources = network_resources
+ self.credentials_domain = credentials_domain or 'Default'
+ self.admin_role = admin_role
if not auth.is_identity_version_supported(self.identity_version):
raise exceptions.InvalidIdentityVersion(
identity_version=self.identity_version)
diff --git a/tempest/common/credentials.py b/tempest/common/credentials.py
index 1b2eca7..76f8afe 100644
--- a/tempest/common/credentials.py
+++ b/tempest/common/credentials.py
@@ -37,16 +37,21 @@
return dynamic_creds.DynamicCredentialProvider(
name=name,
network_resources=network_resources,
- identity_version=identity_version)
+ identity_version=identity_version,
+ credentials_domain=CONF.auth.default_credentials_domain_name,
+ admin_role=CONF.identity.admin_role)
else:
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 preprov_creds.PreProvisionedCredentialProvider(
- name=name, identity_version=identity_version)
+ name=name, identity_version=identity_version,
+ credentials_domain=CONF.auth.default_credentials_domain_name,
+ admin_role=CONF.identity.admin_role)
else:
return preprov_creds.NonLockingCredentialProvider(
- name=name, identity_version=identity_version)
+ name=name, identity_version=identity_version,
+ admin_role=CONF.identity.admin_role)
# We want a helper function here to check and see if admin credentials
@@ -63,7 +68,8 @@
elif (CONF.auth.test_accounts_file and
os.path.isfile(CONF.auth.test_accounts_file)):
check_accounts = preprov_creds.PreProvisionedCredentialProvider(
- identity_version=identity_version, name='check_admin')
+ identity_version=identity_version, name='check_admin',
+ admin_role=CONF.identity.admin_role)
if not check_accounts.admin_available():
is_admin = False
else:
@@ -89,10 +95,12 @@
if (CONF.auth.test_accounts_file and
os.path.isfile(CONF.auth.test_accounts_file)):
check_accounts = preprov_creds.PreProvisionedCredentialProvider(
- identity_version=identity_version, name='check_alt')
+ identity_version=identity_version, name='check_alt',
+ admin_role=CONF.identity.admin_role)
else:
check_accounts = preprov_creds.NonLockingCredentialProvider(
- identity_version=identity_version, name='check_alt')
+ identity_version=identity_version, name='check_alt',
+ admin_role=CONF.identity.admin_role)
try:
if not check_accounts.is_multi_user():
return False
diff --git a/tempest/common/dynamic_creds.py b/tempest/common/dynamic_creds.py
index d9cfac8..e2df560 100644
--- a/tempest/common/dynamic_creds.py
+++ b/tempest/common/dynamic_creds.py
@@ -30,11 +30,12 @@
class DynamicCredentialProvider(cred_provider.CredentialProvider):
- def __init__(self, identity_version, name=None,
- network_resources=None):
+ def __init__(self, identity_version, name=None, network_resources=None,
+ credentials_domain=None, admin_role=None):
super(DynamicCredentialProvider, self).__init__(
- identity_version, name, network_resources)
- self.network_resources = network_resources
+ identity_version=identity_version, name=name,
+ network_resources=network_resources,
+ credentials_domain=credentials_domain, admin_role=admin_role)
self._creds = {}
self.ports = []
self.default_admin_creds = cred_provider.get_configured_credentials(
@@ -49,7 +50,7 @@
if self.identity_version == 'v3':
self.creds_domain_name = (
self.default_admin_creds.project_domain_name or
- CONF.auth.default_credentials_domain_name)
+ self.credentials_domain)
self.creds_client = cred_client.get_creds_client(
self.identity_admin_client, self.creds_domain_name)
@@ -98,7 +99,7 @@
role_assigned = False
if admin:
self.creds_client.assign_user_role(user, project,
- CONF.identity.admin_role)
+ self.admin_role)
role_assigned = True
# Add roles specified in config file
for conf_role in CONF.auth.tempest_roles:
diff --git a/tempest/common/preprov_creds.py b/tempest/common/preprov_creds.py
index 48eae25..dd27f08 100644
--- a/tempest/common/preprov_creds.py
+++ b/tempest/common/preprov_creds.py
@@ -39,9 +39,11 @@
class PreProvisionedCredentialProvider(cred_provider.CredentialProvider):
- def __init__(self, identity_version, name=None):
+ def __init__(self, identity_version, name=None, credentials_domain=None,
+ admin_role=None):
super(PreProvisionedCredentialProvider, self).__init__(
- identity_version=identity_version, name=name)
+ identity_version=identity_version, name=name,
+ credentials_domain=credentials_domain, admin_role=admin_role)
if (CONF.auth.test_accounts_file and
os.path.isfile(CONF.auth.test_accounts_file)):
accounts = read_accounts_yaml(CONF.auth.test_accounts_file)
@@ -49,7 +51,7 @@
else:
accounts = {}
self.use_default_creds = True
- self.hash_dict = self.get_hash_dict(accounts)
+ self.hash_dict = self.get_hash_dict(accounts, admin_role)
self.accounts_dir = os.path.join(lockutils.get_lock_path(CONF),
'test_accounts')
self._creds = {}
@@ -63,7 +65,7 @@
return hash_dict
@classmethod
- def get_hash_dict(cls, accounts):
+ def get_hash_dict(cls, accounts, admin_role):
hash_dict = {'roles': {}, 'creds': {}, 'networks': {}}
# Loop over the accounts read from the yaml file
for account in accounts:
@@ -87,8 +89,8 @@
# subdict with the hash
for type in types:
if type == 'admin':
- hash_dict = cls._append_role(CONF.identity.admin_role,
- temp_hash_key, hash_dict)
+ hash_dict = cls._append_role(admin_role, temp_hash_key,
+ hash_dict)
elif type == 'operator':
hash_dict = cls._append_role(
CONF.object_storage.operator_role, temp_hash_key,
@@ -173,9 +175,9 @@
# privlege set which could potentially cause issues on tests where that
# is not expected. So unless the admin role isn't specified do not
# allocate admin.
- admin_hashes = self.hash_dict['roles'].get(CONF.identity.admin_role,
+ admin_hashes = self.hash_dict['roles'].get(self.admin_role,
None)
- if ((not roles or CONF.identity.admin_role not in roles) and
+ if ((not roles or self.admin_role not in roles) and
admin_hashes):
useable_hashes = [x for x in hashes if x not in admin_hashes]
else:
@@ -217,7 +219,7 @@
if ('user_domain_name' in init_attributes and 'user_domain_name'
not in hash_attributes):
# Allow for the case of domain_name populated from config
- domain_name = CONF.auth.default_credentials_domain_name
+ domain_name = self.credentials_domain
hash_attributes['user_domain_name'] = domain_name
if all([getattr(creds, k) == hash_attributes[k] for
k in init_attributes]):
@@ -266,7 +268,7 @@
self.remove_credentials(creds)
def get_admin_creds(self):
- return self.get_creds_by_roles([CONF.identity.admin_role])
+ return self.get_creds_by_roles([self.admin_role])
def is_role_available(self, role):
if self.use_default_creds:
@@ -277,7 +279,7 @@
return False
def admin_available(self):
- return self.is_role_available(CONF.identity.admin_role)
+ return self.is_role_available(self.admin_role)
def _wrap_creds_with_network(self, hash):
creds_dict = self.hash_dict['creds'][hash]
@@ -306,8 +308,7 @@
if self.identity_version == 'v3':
user_domain_fields = set(['user_domain_name', 'user_domain_id'])
if not user_domain_fields.intersection(set(creds_dict.keys())):
- _domain = CONF.auth.default_credentials_domain_name
- creds_dict['user_domain_name'] = _domain
+ creds_dict['user_domain_name'] = self.credentials_domain
return creds_dict
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 036914e..a10dc83 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -450,21 +450,21 @@
image_name, server['name'])
return snapshot_image
- def nova_volume_attach(self):
+ def nova_volume_attach(self, server, volume_to_attach):
volume = self.servers_client.attach_volume(
- self.server['id'], volumeId=self.volume['id'], device='/dev/%s'
+ server['id'], volumeId=volume_to_attach['id'], device='/dev/%s'
% CONF.compute.volume_device_name)['volumeAttachment']
- self.assertEqual(self.volume['id'], volume['id'])
+ self.assertEqual(volume_to_attach['id'], volume['id'])
self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
- # Refresh the volume after the attachment
- self.volume = self.volumes_client.show_volume(volume['id'])['volume']
- def nova_volume_detach(self):
- self.servers_client.detach_volume(self.server['id'], self.volume['id'])
- self.volumes_client.wait_for_volume_status(self.volume['id'],
- 'available')
+ # Return the updated volume after the attachment
+ return self.volumes_client.show_volume(volume['id'])['volume']
- volume = self.volumes_client.show_volume(self.volume['id'])['volume']
+ def nova_volume_detach(self, server, volume):
+ self.servers_client.detach_volume(server['id'], volume['id'])
+ self.volumes_client.wait_for_volume_status(volume['id'], 'available')
+
+ volume = self.volumes_client.show_volume(volume['id'])['volume']
self.assertEqual('available', volume['status'])
def rebuild_server(self, server_id, image=None,
@@ -573,8 +573,10 @@
floating_ip['ip'], thing['id'])
return floating_ip
- def create_timestamp(self, server_or_ip, dev_name=None, mount_path='/mnt'):
- ssh_client = self.get_remote_client(server_or_ip)
+ def create_timestamp(self, server_or_ip, dev_name=None, mount_path='/mnt',
+ private_key=None):
+ ssh_client = self.get_remote_client(server_or_ip,
+ private_key=private_key)
if dev_name is not None:
ssh_client.make_fs(dev_name)
ssh_client.mount(dev_name, mount_path)
@@ -586,8 +588,10 @@
ssh_client.umount(mount_path)
return timestamp
- def get_timestamp(self, server_or_ip, dev_name=None, mount_path='/mnt'):
- ssh_client = self.get_remote_client(server_or_ip)
+ def get_timestamp(self, server_or_ip, dev_name=None, mount_path='/mnt',
+ private_key=None):
+ ssh_client = self.get_remote_client(server_or_ip,
+ private_key=private_key)
if dev_name is not None:
ssh_client.mount(dev_name, mount_path)
timestamp = ssh_client.exec_command('sudo cat %s/timestamp'
diff --git a/tempest/scenario/test_encrypted_cinder_volumes.py b/tempest/scenario/test_encrypted_cinder_volumes.py
index b66eb59..3f0123d 100644
--- a/tempest/scenario/test_encrypted_cinder_volumes.py
+++ b/tempest/scenario/test_encrypted_cinder_volumes.py
@@ -54,8 +54,8 @@
self.volume = self.create_volume(volume_type=volume_type['name'])
def attach_detach_volume(self):
- self.nova_volume_attach()
- self.nova_volume_detach()
+ self.volume = self.nova_volume_attach(self.server, self.volume)
+ self.nova_volume_detach(self.server, self.volume)
@test.idempotent_id('79165fb4-5534-4b9d-8429-97ccffb8f86e')
@test.services('compute', 'volume', 'image')
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index eac8311..22aa06c 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -40,66 +40,61 @@
"""
- def _wait_for_server_status(self, status):
- server_id = self.server['id']
+ def _wait_for_server_status(self, server, status):
+ server_id = server['id']
# Raise on error defaults to True, which is consistent with the
# original function from scenario tests here
waiters.wait_for_server_status(self.servers_client,
server_id, status)
- def nova_keypair_add(self):
- self.keypair = self.create_keypair()
-
- def nova_boot(self):
- create_kwargs = {'key_name': self.keypair['name']}
- self.server = self.create_server(image=self.image,
- create_kwargs=create_kwargs)
+ def nova_boot(self, keypair):
+ create_kwargs = {'key_name': keypair['name']}
+ return self.create_server(image=self.image,
+ create_kwargs=create_kwargs)
def nova_list(self):
servers = self.servers_client.list_servers()
# The list servers in the compute client is inconsistent...
- servers = servers['servers']
- self.assertIn(self.server['id'], [x['id'] for x in servers])
+ return servers['servers']
- def nova_show(self):
- got_server = (self.servers_client.show_server(self.server['id'])
+ def nova_show(self, server):
+ got_server = (self.servers_client.show_server(server['id'])
['server'])
excluded_keys = ['OS-EXT-AZ:availability_zone']
# Exclude these keys because of LP:#1486475
excluded_keys.extend(['OS-EXT-STS:power_state', 'updated'])
self.assertThat(
- self.server, custom_matchers.MatchesDictExceptForKeys(
+ server, custom_matchers.MatchesDictExceptForKeys(
got_server, excluded_keys=excluded_keys))
def cinder_create(self):
- self.volume = self.create_volume()
+ return self.create_volume()
def cinder_list(self):
- volumes = self.volumes_client.list_volumes()['volumes']
- self.assertIn(self.volume['id'], [x['id'] for x in volumes])
+ return self.volumes_client.list_volumes()['volumes']
- def cinder_show(self):
- volume = self.volumes_client.show_volume(self.volume['id'])['volume']
- self.assertEqual(self.volume, volume)
+ def cinder_show(self, volume):
+ got_volume = self.volumes_client.show_volume(volume['id'])['volume']
+ self.assertEqual(volume, got_volume)
- def nova_reboot(self):
- self.servers_client.reboot_server(self.server['id'], 'SOFT')
- self._wait_for_server_status('ACTIVE')
+ def nova_reboot(self, server):
+ self.servers_client.reboot_server(server['id'], 'SOFT')
+ self._wait_for_server_status(server, 'ACTIVE')
def check_partitions(self):
# NOTE(andreaf) The device name may be different on different guest OS
partitions = self.linux_client.get_partitions()
self.assertEqual(1, partitions.count(CONF.compute.volume_device_name))
- def create_and_add_security_group(self):
+ def create_and_add_security_group_to_server(self, server):
secgroup = self._create_security_group()
- self.servers_client.add_security_group(self.server['id'],
+ self.servers_client.add_security_group(server['id'],
secgroup['name'])
self.addCleanup(self.servers_client.remove_security_group,
- self.server['id'], secgroup['name'])
+ server['id'], secgroup['name'])
def wait_for_secgroup_add():
- body = (self.servers_client.show_server(self.server['id'])
+ body = (self.servers_client.show_server(server['id'])
['server'])
return {'name': secgroup['name']} in body['security_groups']
@@ -107,29 +102,39 @@
CONF.compute.build_timeout,
CONF.compute.build_interval):
msg = ('Timed out waiting for adding security group %s to server '
- '%s' % (secgroup['id'], self.server['id']))
+ '%s' % (secgroup['id'], server['id']))
raise exceptions.TimeoutException(msg)
@test.idempotent_id('bdbb5441-9204-419d-a225-b4fdbfb1a1a8')
@test.services('compute', 'volume', 'image', 'network')
def test_minimum_basic_scenario(self):
self.glance_image_create()
- self.nova_keypair_add()
- self.nova_boot()
- self.nova_list()
- self.nova_show()
- self.cinder_create()
- self.cinder_list()
- self.cinder_show()
- self.nova_volume_attach()
- self.addCleanup(self.nova_volume_detach)
- self.cinder_show()
- self.floating_ip = self.create_floating_ip(self.server)
- self.create_and_add_security_group()
+ keypair = self.create_keypair()
- self.linux_client = self.get_remote_client(self.floating_ip['ip'])
- self.nova_reboot()
+ server = self.nova_boot(keypair)
+ servers = self.nova_list()
+ self.assertIn(server['id'], [x['id'] for x in servers])
- self.linux_client = self.get_remote_client(self.floating_ip['ip'])
+ self.nova_show(server)
+
+ volume = self.cinder_create()
+ volumes = self.cinder_list()
+ self.assertIn(volume['id'], [x['id'] for x in volumes])
+
+ self.cinder_show(volume)
+
+ volume = self.nova_volume_attach(server, volume)
+ self.addCleanup(self.nova_volume_detach, server, volume)
+ self.cinder_show(volume)
+
+ floating_ip = self.create_floating_ip(server)
+ self.create_and_add_security_group_to_server(server)
+
+ self.linux_client = self.get_remote_client(
+ floating_ip['ip'], private_key=keypair['private_key'])
+ self.nova_reboot(server)
+
+ self.linux_client = self.get_remote_client(
+ floating_ip['ip'], private_key=keypair['private_key'])
self.check_partitions()
diff --git a/tempest/scenario/test_network_advanced_server_ops.py b/tempest/scenario/test_network_advanced_server_ops.py
index 62b2976..704342f 100644
--- a/tempest/scenario/test_network_advanced_server_ops.py
+++ b/tempest/scenario/test_network_advanced_server_ops.py
@@ -56,7 +56,7 @@
super(TestNetworkAdvancedServerOps, cls).setup_credentials()
def _setup_network_and_servers(self):
- self.keypair = self.create_keypair()
+ keypair = self.create_keypair()
security_group = self._create_security_group()
network, subnet, router = self.create_networks()
public_network_id = CONF.network.public_network_id
@@ -64,91 +64,103 @@
'networks': [
{'uuid': network.id},
],
- 'key_name': self.keypair['name'],
+ 'key_name': keypair['name'],
'security_groups': [{'name': security_group['name']}],
}
server_name = data_utils.rand_name('server-smoke')
- self.server = self.create_server(name=server_name,
- create_kwargs=create_kwargs)
- self.floating_ip = self.create_floating_ip(self.server,
- public_network_id)
+ server = self.create_server(name=server_name,
+ create_kwargs=create_kwargs)
+ floating_ip = self.create_floating_ip(server, public_network_id)
# Verify that we can indeed connect to the server before we mess with
# it's state
- self._wait_server_status_and_check_network_connectivity()
+ self._wait_server_status_and_check_network_connectivity(
+ server, keypair, floating_ip)
- def _check_network_connectivity(self, should_connect=True):
+ return server, keypair, floating_ip
+
+ def _check_network_connectivity(self, server, keypair, floating_ip,
+ should_connect=True):
username = CONF.compute.image_ssh_user
- private_key = self.keypair['private_key']
+ private_key = keypair['private_key']
self._check_tenant_network_connectivity(
- self.server, username, private_key,
+ server, username, private_key,
should_connect=should_connect,
- servers_for_debug=[self.server])
- floating_ip = self.floating_ip.floating_ip_address
+ servers_for_debug=[server])
+ floating_ip_addr = floating_ip.floating_ip_address
# Check FloatingIP status before checking the connectivity
- self.check_floating_ip_status(self.floating_ip, 'ACTIVE')
- self.check_public_network_connectivity(floating_ip, username,
+ self.check_floating_ip_status(floating_ip, 'ACTIVE')
+ self.check_public_network_connectivity(floating_ip_addr, username,
private_key, should_connect,
- servers=[self.server])
+ servers=[server])
- def _wait_server_status_and_check_network_connectivity(self):
- waiters.wait_for_server_status(self.servers_client,
- self.server['id'], 'ACTIVE')
- self._check_network_connectivity()
+ def _wait_server_status_and_check_network_connectivity(self, server,
+ keypair,
+ floating_ip):
+ waiters.wait_for_server_status(self.servers_client, server['id'],
+ 'ACTIVE')
+ self._check_network_connectivity(server, keypair, floating_ip)
@test.idempotent_id('61f1aa9a-1573-410e-9054-afa557cab021')
@test.stresstest(class_setup_per='process')
@test.services('compute', 'network')
def test_server_connectivity_stop_start(self):
- self._setup_network_and_servers()
- self.servers_client.stop_server(self.server['id'])
- waiters.wait_for_server_status(self.servers_client,
- self.server['id'], 'SHUTOFF')
- self._check_network_connectivity(should_connect=False)
- self.servers_client.start_server(self.server['id'])
- self._wait_server_status_and_check_network_connectivity()
+ server, keypair, floating_ip = self._setup_network_and_servers()
+ self.servers_client.stop_server(server['id'])
+ waiters.wait_for_server_status(self.servers_client, server['id'],
+ 'SHUTOFF')
+ self._check_network_connectivity(server, keypair, floating_ip,
+ should_connect=False)
+ self.servers_client.start_server(server['id'])
+ self._wait_server_status_and_check_network_connectivity(
+ server, keypair, floating_ip)
@test.idempotent_id('7b6860c2-afa3-4846-9522-adeb38dfbe08')
@test.services('compute', 'network')
def test_server_connectivity_reboot(self):
- self._setup_network_and_servers()
- self.servers_client.reboot_server(self.server['id'],
- reboot_type='SOFT')
- self._wait_server_status_and_check_network_connectivity()
+ server, keypair, floating_ip = self._setup_network_and_servers()
+ self.servers_client.reboot_server(server['id'], reboot_type='SOFT')
+ self._wait_server_status_and_check_network_connectivity(
+ server, keypair, floating_ip)
@test.idempotent_id('88a529c2-1daa-4c85-9aec-d541ba3eb699')
@test.services('compute', 'network')
def test_server_connectivity_rebuild(self):
- self._setup_network_and_servers()
+ server, keypair, floating_ip = self._setup_network_and_servers()
image_ref_alt = CONF.compute.image_ref_alt
- self.servers_client.rebuild_server(self.server['id'],
+ self.servers_client.rebuild_server(server['id'],
image_ref=image_ref_alt)
- self._wait_server_status_and_check_network_connectivity()
+ self._wait_server_status_and_check_network_connectivity(
+ server, keypair, floating_ip)
@test.idempotent_id('2b2642db-6568-4b35-b812-eceed3fa20ce')
@testtools.skipUnless(CONF.compute_feature_enabled.pause,
'Pause is not available.')
@test.services('compute', 'network')
def test_server_connectivity_pause_unpause(self):
- self._setup_network_and_servers()
- self.servers_client.pause_server(self.server['id'])
- waiters.wait_for_server_status(self.servers_client,
- self.server['id'], 'PAUSED')
- self._check_network_connectivity(should_connect=False)
- self.servers_client.unpause_server(self.server['id'])
- self._wait_server_status_and_check_network_connectivity()
+ server, keypair, floating_ip = self._setup_network_and_servers()
+ self.servers_client.pause_server(server['id'])
+ waiters.wait_for_server_status(self.servers_client, server['id'],
+ 'PAUSED')
+ self._check_network_connectivity(server, keypair, floating_ip,
+ should_connect=False)
+ self.servers_client.unpause_server(server['id'])
+ self._wait_server_status_and_check_network_connectivity(
+ server, keypair, floating_ip)
@test.idempotent_id('5cdf9499-541d-4923-804e-b9a60620a7f0')
@testtools.skipUnless(CONF.compute_feature_enabled.suspend,
'Suspend is not available.')
@test.services('compute', 'network')
def test_server_connectivity_suspend_resume(self):
- self._setup_network_and_servers()
- self.servers_client.suspend_server(self.server['id'])
- waiters.wait_for_server_status(self.servers_client, self.server['id'],
+ server, keypair, floating_ip = self._setup_network_and_servers()
+ self.servers_client.suspend_server(server['id'])
+ waiters.wait_for_server_status(self.servers_client, server['id'],
'SUSPENDED')
- self._check_network_connectivity(should_connect=False)
- self.servers_client.resume_server(self.server['id'])
- self._wait_server_status_and_check_network_connectivity()
+ self._check_network_connectivity(server, keypair, floating_ip,
+ should_connect=False)
+ self.servers_client.resume_server(server['id'])
+ self._wait_server_status_and_check_network_connectivity(
+ server, keypair, floating_ip)
@test.idempotent_id('719eb59d-2f42-4b66-b8b1-bb1254473967')
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
@@ -159,10 +171,11 @@
if resize_flavor == CONF.compute.flavor_ref:
msg = "Skipping test - flavor_ref and flavor_ref_alt are identical"
raise self.skipException(msg)
- self._setup_network_and_servers()
- self.servers_client.resize_server(self.server['id'],
+ server, keypair, floating_ip = self._setup_network_and_servers()
+ self.servers_client.resize_server(server['id'],
flavor_ref=resize_flavor)
- waiters.wait_for_server_status(self.servers_client, self.server['id'],
+ waiters.wait_for_server_status(self.servers_client, server['id'],
'VERIFY_RESIZE')
- self.servers_client.confirm_resize_server(self.server['id'])
- self._wait_server_status_and_check_network_connectivity()
+ self.servers_client.confirm_resize_server(server['id'])
+ self._wait_server_status_and_check_network_connectivity(
+ server, keypair, floating_ip)
diff --git a/tempest/scenario/test_shelve_instance.py b/tempest/scenario/test_shelve_instance.py
index dbc9bbb..bc80412 100644
--- a/tempest/scenario/test_shelve_instance.py
+++ b/tempest/scenario/test_shelve_instance.py
@@ -55,12 +55,12 @@
'ACTIVE')
def _create_server_then_shelve_and_unshelve(self, boot_from_volume=False):
- self.keypair = self.create_keypair()
+ keypair = self.create_keypair()
- self.security_group = self._create_security_group()
- security_groups = [{'name': self.security_group['name']}]
+ security_group = self._create_security_group()
+ security_groups = [{'name': security_group['name']}]
create_kwargs = {
- 'key_name': self.keypair['name'],
+ 'key_name': keypair['name'],
'security_groups': security_groups
}
@@ -86,18 +86,22 @@
floating_ip['id'])
self.floating_ips_client.associate_floating_ip_to_server(
floating_ip['ip'], server['id'])
- timestamp = self.create_timestamp(floating_ip['ip'])
+ timestamp = self.create_timestamp(
+ floating_ip['ip'], private_key=keypair['private_key'])
else:
- timestamp = self.create_timestamp(server)
+ timestamp = self.create_timestamp(
+ server, private_key=keypair['private_key'])
# Prevent bug #1257594 from coming back
# Unshelve used to boot the instance with the original image, not
# with the instance snapshot
self._shelve_then_unshelve_server(server)
if CONF.compute.use_floatingip_for_ssh:
- timestamp2 = self.get_timestamp(floating_ip['ip'])
+ timestamp2 = self.get_timestamp(floating_ip['ip'],
+ private_key=keypair['private_key'])
else:
- timestamp2 = self.get_timestamp(server)
+ timestamp2 = self.get_timestamp(server,
+ private_key=keypair['private_key'])
self.assertEqual(timestamp, timestamp2)
@test.idempotent_id('1164e700-0af0-4a4c-8792-35909a88743c')
diff --git a/tempest/scenario/test_snapshot_pattern.py b/tempest/scenario/test_snapshot_pattern.py
index 79b809f..5ac3a7e 100644
--- a/tempest/scenario/test_snapshot_pattern.py
+++ b/tempest/scenario/test_snapshot_pattern.py
@@ -36,44 +36,47 @@
"""
- def _boot_image(self, image_id):
- security_groups = [{'name': self.security_group['name']}]
+ def _boot_image(self, image_id, keypair, security_group):
+ security_groups = [{'name': security_group['name']}]
create_kwargs = {
- 'key_name': self.keypair['name'],
+ 'key_name': keypair['name'],
'security_groups': security_groups
}
return self.create_server(image=image_id, create_kwargs=create_kwargs)
- def _add_keypair(self):
- self.keypair = self.create_keypair()
-
@test.idempotent_id('608e604b-1d63-4a82-8e3e-91bc665c90b4')
@testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
'Snapshotting is not available.')
@test.services('compute', 'network', 'image')
def test_snapshot_pattern(self):
# prepare for booting an instance
- self._add_keypair()
- self.security_group = self._create_security_group()
+ keypair = self.create_keypair()
+ security_group = self._create_security_group()
# boot an instance and create a timestamp file in it
- server = self._boot_image(CONF.compute.image_ref)
+ server = self._boot_image(CONF.compute.image_ref, keypair,
+ security_group)
if CONF.compute.use_floatingip_for_ssh:
fip_for_server = self.create_floating_ip(server)
- timestamp = self.create_timestamp(fip_for_server['ip'])
+ timestamp = self.create_timestamp(
+ fip_for_server['ip'], private_key=keypair['private_key'])
else:
- timestamp = self.create_timestamp(server)
+ timestamp = self.create_timestamp(
+ server, private_key=keypair['private_key'])
# snapshot the instance
snapshot_image = self.create_server_snapshot(server=server)
# boot a second instance from the snapshot
- server_from_snapshot = self._boot_image(snapshot_image['id'])
+ server_from_snapshot = self._boot_image(snapshot_image['id'],
+ keypair, security_group)
# check the existence of the timestamp file in the second instance
if CONF.compute.use_floatingip_for_ssh:
fip_for_snapshot = self.create_floating_ip(server_from_snapshot)
- timestamp2 = self.get_timestamp(fip_for_snapshot['ip'])
+ timestamp2 = self.get_timestamp(fip_for_snapshot['ip'],
+ private_key=keypair['private_key'])
else:
- timestamp2 = self.get_timestamp(server_from_snapshot)
+ timestamp2 = self.get_timestamp(server_from_snapshot,
+ private_key=keypair['private_key'])
self.assertEqual(timestamp, timestamp2)
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index a4f9896..6eceeb2 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -63,20 +63,17 @@
self.snapshots_client.wait_for_snapshot_status(volume_snapshot['id'],
status)
- def _boot_image(self, image_id):
- security_groups = [{'name': self.security_group['name']}]
+ def _boot_image(self, image_id, keypair, security_group):
+ security_groups = [{'name': security_group['name']}]
create_kwargs = {
- 'key_name': self.keypair['name'],
+ 'key_name': keypair['name'],
'security_groups': security_groups
}
return self.create_server(image=image_id, create_kwargs=create_kwargs)
- def _add_keypair(self):
- self.keypair = self.create_keypair()
-
def _create_volume_snapshot(self, volume):
snapshot_name = data_utils.rand_name('scenario-snapshot')
- _, snapshot = self.snapshots_client.create_snapshot(
+ snapshot = self.snapshots_client.create_snapshot(
volume['id'], display_name=snapshot_name)['snapshot']
def cleaner():
@@ -111,8 +108,9 @@
self.servers_client.detach_volume(server['id'], volume['id'])
self._wait_for_volume_status(volume, 'available')
- def _wait_for_volume_available_on_the_system(self, server_or_ip):
- ssh = self.get_remote_client(server_or_ip)
+ def _wait_for_volume_available_on_the_system(self, server_or_ip,
+ private_key):
+ ssh = self.get_remote_client(server_or_ip, private_key=private_key)
def _func():
part = ssh.get_partitions()
@@ -131,12 +129,13 @@
@tempest.test.services('compute', 'network', 'volume', 'image')
def test_stamp_pattern(self):
# prepare for booting an instance
- self._add_keypair()
- self.security_group = self._create_security_group()
+ keypair = self.create_keypair()
+ security_group = self._create_security_group()
# boot an instance and create a timestamp file in it
volume = self._create_volume()
- server = self._boot_image(CONF.compute.image_ref)
+ server = self._boot_image(CONF.compute.image_ref, keypair,
+ security_group)
# create and add floating IP to server1
if CONF.compute.use_floatingip_for_ssh:
@@ -146,9 +145,11 @@
ip_for_server = server
self._attach_volume(server, volume)
- self._wait_for_volume_available_on_the_system(ip_for_server)
+ self._wait_for_volume_available_on_the_system(ip_for_server,
+ keypair['private_key'])
timestamp = self.create_timestamp(ip_for_server,
- CONF.compute.volume_device_name)
+ CONF.compute.volume_device_name,
+ private_key=keypair['private_key'])
self._detach_volume(server, volume)
# snapshot the volume
@@ -162,7 +163,8 @@
snapshot_id=volume_snapshot['id'])
# boot second instance from the snapshot(instance2)
- server_from_snapshot = self._boot_image(snapshot_image['id'])
+ server_from_snapshot = self._boot_image(snapshot_image['id'],
+ keypair, security_group)
# create and add floating IP to server_from_snapshot
if CONF.compute.use_floatingip_for_ssh:
@@ -174,9 +176,11 @@
# attach volume2 to instance2
self._attach_volume(server_from_snapshot, volume_from_snapshot)
- self._wait_for_volume_available_on_the_system(ip_for_snapshot)
+ self._wait_for_volume_available_on_the_system(ip_for_snapshot,
+ keypair['private_key'])
# check the existence of the timestamp file in the volume2
timestamp2 = self.get_timestamp(ip_for_snapshot,
- CONF.compute.volume_device_name)
+ CONF.compute.volume_device_name,
+ private_key=keypair['private_key'])
self.assertEqual(timestamp, timestamp2)
diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py
index d4bddc0..678fcfc 100644
--- a/tempest/scenario/test_volume_boot_pattern.py
+++ b/tempest/scenario/test_volume_boot_pattern.py
@@ -11,7 +11,6 @@
# under the License.
from oslo_log import log
-from tempest_lib import decorators
from tempest.common.utils import data_utils
from tempest.common import waiters
@@ -164,7 +163,6 @@
ssh_client = self._ssh_to_server(instance_from_snapshot, keypair)
self._check_content_of_written_file(ssh_client, text)
- @decorators.skip_because(bug='1489581')
@test.idempotent_id('36c34c67-7b54-4b59-b188-02a2f458a63b')
@test.services('compute', 'volume', 'image')
def test_create_ebs_image_and_check_boot(self):
diff --git a/tempest/services/compute/json/hypervisor_client.py b/tempest/services/compute/json/hypervisor_client.py
deleted file mode 100644
index ba06f23..0000000
--- a/tempest/services/compute/json/hypervisor_client.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright 2013 IBM Corporation.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from oslo_serialization import jsonutils as json
-
-from tempest.api_schema.response.compute.v2_1 import hypervisors as schema
-from tempest.common import service_client
-
-
-class HypervisorClient(service_client.ServiceClient):
-
- def list_hypervisors(self, detail=False):
- """List hypervisors information."""
- url = 'os-hypervisors'
- _schema = schema.list_search_hypervisors
- if detail:
- url += '/detail'
- _schema = schema.list_hypervisors_detail
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(_schema, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def show_hypervisor(self, hypervisor_id):
- """Display the details of the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s' % hypervisor_id)
- body = json.loads(body)
- self.validate_response(schema.get_hypervisor, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def list_servers_on_hypervisor(self, hypervisor_name):
- """List instances belonging to the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/servers' % hypervisor_name)
- body = json.loads(body)
- self.validate_response(schema.get_hypervisors_servers, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def show_hypervisor_statistics(self):
- """Get hypervisor statistics over all compute nodes."""
- resp, body = self.get('os-hypervisors/statistics')
- body = json.loads(body)
- self.validate_response(schema.get_hypervisor_statistics, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def show_hypervisor_uptime(self, hypervisor_id):
- """Display the uptime of the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/uptime' % hypervisor_id)
- body = json.loads(body)
- self.validate_response(schema.get_hypervisor_uptime, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def search_hypervisor(self, hypervisor_name):
- """Search specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/search' % hypervisor_name)
- body = json.loads(body)
- self.validate_response(schema.list_search_hypervisors, resp, body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/tests/common/test_admin_available.py b/tempest/tests/common/test_admin_available.py
index 709ca6f..a53ed5f 100644
--- a/tempest/tests/common/test_admin_available.py
+++ b/tempest/tests/common/test_admin_available.py
@@ -30,10 +30,10 @@
self.useFixture(fake_config.ConfigFixture())
self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
- def run_test(self, tenant_isolation, use_accounts_file, admin_creds):
+ def run_test(self, dynamic_creds, use_accounts_file, admin_creds):
cfg.CONF.set_default('use_dynamic_credentials',
- tenant_isolation, group='auth')
+ dynamic_creds, group='auth')
if use_accounts_file:
accounts = [{'username': 'u1',
'tenant_name': 't1',
@@ -62,48 +62,54 @@
self.useFixture(mockpatch.Patch('os.path.isfile',
return_value=False))
if admin_creds:
- (u, t, p, d) = ('u', 't', 'p', 'd')
+ username = 'u'
+ tenant = 't'
+ password = 'p'
+ domain = 'd'
else:
- (u, t, p, d) = (None, None, None, None)
+ username = None
+ tenant = None
+ password = None
+ domain = None
- cfg.CONF.set_default('admin_username', u, group='auth')
- cfg.CONF.set_default('admin_tenant_name', t, group='auth')
- cfg.CONF.set_default('admin_password', p, group='auth')
- cfg.CONF.set_default('admin_domain_name', d, group='auth')
+ cfg.CONF.set_default('admin_username', username, group='auth')
+ cfg.CONF.set_default('admin_tenant_name', tenant, group='auth')
+ cfg.CONF.set_default('admin_password', password, group='auth')
+ cfg.CONF.set_default('admin_domain_name', domain, group='auth')
- expected = admin_creds is not None or tenant_isolation
+ expected = admin_creds is not None or dynamic_creds
observed = credentials.is_admin_available(
identity_version=self.identity_version)
self.assertEqual(expected, observed)
- # Tenant isolation implies admin so only one test case for True
- def test__tenant_isolation__accounts_file__no_admin(self):
- self.run_test(tenant_isolation=True,
+ # Dynamic credentials implies admin so only one test case for True
+ def test__dynamic_creds__accounts_file__no_admin(self):
+ self.run_test(dynamic_creds=True,
use_accounts_file=True,
admin_creds=None)
- def test__no_tenant_isolation__accounts_file__no_admin(self):
- self.run_test(tenant_isolation=False,
+ def test__no_dynamic_creds__accounts_file__no_admin(self):
+ self.run_test(dynamic_creds=False,
use_accounts_file=True,
admin_creds=None)
- def test__no_tenant_isolation__accounts_file__admin_role(self):
- self.run_test(tenant_isolation=False,
+ def test__no_dynamic_creds__accounts_file__admin_role(self):
+ self.run_test(dynamic_creds=False,
use_accounts_file=True,
admin_creds='role')
- def test__no_tenant_isolation__accounts_file__admin_type(self):
- self.run_test(tenant_isolation=False,
+ def test__no_dynamic_creds__accounts_file__admin_type(self):
+ self.run_test(dynamic_creds=False,
use_accounts_file=True,
admin_creds='type')
- def test__no_tenant_isolation__no_accounts_file__no_admin(self):
- self.run_test(tenant_isolation=False,
+ def test__no_dynamic_creds__no_accounts_file__no_admin(self):
+ self.run_test(dynamic_creds=False,
use_accounts_file=False,
admin_creds=None)
- def test__no_tenant_isolation__no_accounts_file__admin(self):
- self.run_test(tenant_isolation=False,
+ def test__no_dynamic_creds__no_accounts_file__admin(self):
+ self.run_test(dynamic_creds=False,
use_accounts_file=False,
admin_creds='role')
diff --git a/tempest/tests/common/test_alt_available.py b/tempest/tests/common/test_alt_available.py
new file mode 100644
index 0000000..6a86f73
--- /dev/null
+++ b/tempest/tests/common/test_alt_available.py
@@ -0,0 +1,117 @@
+# Copyright 2015 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from oslo_config import cfg
+from oslotest import mockpatch
+
+from tempest.common import credentials
+from tempest import config
+from tempest.tests import base
+from tempest.tests import fake_config
+
+
+class TestAltAvailable(base.TestCase):
+
+ identity_version = 'v2'
+
+ def setUp(self):
+ super(TestAltAvailable, self).setUp()
+ self.useFixture(fake_config.ConfigFixture())
+ self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
+
+ def run_test(self, dynamic_creds, use_accounts_file, creds):
+
+ cfg.CONF.set_default('use_dynamic_credentials',
+ dynamic_creds, group='auth')
+ if use_accounts_file:
+ accounts = [dict(username="u%s" % ii,
+ tenant_name="t%s" % ii,
+ password="p") for ii in creds]
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.preprov_creds.read_accounts_yaml',
+ return_value=accounts))
+ cfg.CONF.set_default('test_accounts_file',
+ use_accounts_file, group='auth')
+ self.useFixture(mockpatch.Patch('os.path.isfile',
+ return_value=True))
+ else:
+ self.useFixture(mockpatch.Patch('os.path.isfile',
+ return_value=False))
+ cred_prefix = ['', 'alt_']
+ for ii in range(0, 2):
+ if len(creds) > ii:
+ username = 'u%s' % creds[ii]
+ tenant = 't%s' % creds[ii]
+ password = 'p'
+ domain = 'd'
+ else:
+ username = None
+ tenant = None
+ password = None
+ domain = None
+
+ cfg.CONF.set_default('%susername' % cred_prefix[ii], username,
+ group='identity')
+ cfg.CONF.set_default('%stenant_name' % cred_prefix[ii], tenant,
+ group='identity')
+ cfg.CONF.set_default('%spassword' % cred_prefix[ii], password,
+ group='identity')
+ cfg.CONF.set_default('%sdomain_name' % cred_prefix[ii], domain,
+ group='identity')
+
+ expected = len(set(creds)) > 1 or dynamic_creds
+ observed = credentials.is_alt_available(
+ identity_version=self.identity_version)
+ self.assertEqual(expected, observed)
+
+ # Dynamic credentials implies alt so only one test case for True
+ def test__dynamic_creds__accounts_file__one_user(self):
+ self.run_test(dynamic_creds=True,
+ use_accounts_file=False,
+ creds=['1', '2'])
+
+ def test__no_dynamic_creds__accounts_file__one_user(self):
+ self.run_test(dynamic_creds=False,
+ use_accounts_file=True,
+ creds=['1'])
+
+ def test__no_dynamic_creds__accounts_file__two_users(self):
+ self.run_test(dynamic_creds=False,
+ use_accounts_file=True,
+ creds=['1', '2'])
+
+ def test__no_dynamic_creds__accounts_file__two_users_identical(self):
+ self.run_test(dynamic_creds=False,
+ use_accounts_file=True,
+ creds=['1', '1'])
+
+ def test__no_dynamic_creds__no_accounts_file__one_user(self):
+ self.run_test(dynamic_creds=False,
+ use_accounts_file=False,
+ creds=['1'])
+
+ def test__no_dynamic_creds__no_accounts_file__two_users(self):
+ self.run_test(dynamic_creds=False,
+ use_accounts_file=False,
+ creds=['1', '2'])
+
+ def test__no_dynamic_creds__no_accounts_file__two_users_identical(self):
+ self.run_test(dynamic_creds=False,
+ use_accounts_file=False,
+ creds=['1', '1'])
+
+
+class TestAltAvailableV3(TestAltAvailable):
+
+ identity_version = 'v3'
diff --git a/tempest/tests/test_dynamic_creds.py b/tempest/tests/common/test_dynamic_creds.py
similarity index 99%
rename from tempest/tests/test_dynamic_creds.py
rename to tempest/tests/common/test_dynamic_creds.py
index 08b2ab6..59a5523 100644
--- a/tempest/tests/test_dynamic_creds.py
+++ b/tempest/tests/common/test_dynamic_creds.py
@@ -33,7 +33,8 @@
class TestDynamicCredentialProvider(base.TestCase):
fixed_params = {'name': 'test class',
- 'identity_version': 'v2'}
+ 'identity_version': 'v2',
+ 'admin_role': 'admin'}
def setUp(self):
super(TestDynamicCredentialProvider, self).setUp()
diff --git a/tempest/tests/common/test_preprov_creds.py b/tempest/tests/common/test_preprov_creds.py
index e813b2e..8a014af 100644
--- a/tempest/tests/common/test_preprov_creds.py
+++ b/tempest/tests/common/test_preprov_creds.py
@@ -37,7 +37,8 @@
class TestPreProvisionedCredentials(base.TestCase):
fixed_params = {'name': 'test class',
- 'identity_version': 'v2'}
+ 'identity_version': 'v2',
+ 'admin_role': 'admin'}
def setUp(self):
super(TestPreProvisionedCredentials, self).setUp()
@@ -103,7 +104,8 @@
def test_get_hash_dict(self):
test_account_class = preprov_creds.PreProvisionedCredentialProvider(
**self.fixed_params)
- hash_dict = test_account_class.get_hash_dict(self.test_accounts)
+ hash_dict = test_account_class.get_hash_dict(
+ self.test_accounts, self.fixed_params['admin_role'])
hash_list = self._get_hash_list(self.test_accounts)
for hash in hash_list:
self.assertIn(hash, hash_dict['creds'].keys())
@@ -332,7 +334,8 @@
class TestNotLockingAccount(base.TestCase):
fixed_params = {'name': 'test class',
- 'identity_version': 'v2'}
+ 'identity_version': 'v2',
+ 'admin_role': 'admin'}
def setUp(self):
super(TestNotLockingAccount, self).setUp()
diff --git a/tempest/tests/services/compute/test_hypervisor_client.py b/tempest/tests/services/compute/test_hypervisor_client.py
deleted file mode 100644
index 441e7e6..0000000
--- a/tempest/tests/services/compute/test_hypervisor_client.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# Copyright 2015 IBM Corp.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.services.compute.json import hypervisor_client
-from tempest.tests import fake_auth_provider
-from tempest.tests.services.compute import base
-
-
-class TestHypervisorClient(base.BaseComputeServiceTest):
-
- hypervisor_id = "1"
- hypervisor_name = "hyper.hostname.com"
-
- def setUp(self):
- super(TestHypervisorClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = hypervisor_client.HypervisorClient(
- fake_auth, 'compute', 'regionOne')
-
- def test_list_hypervisor_str_body(self):
- self._test_list_hypervisor(bytes_body=False)
-
- def test_list_hypervisor_byte_body(self):
- self._test_list_hypervisor(bytes_body=True)
-
- def _test_list_hypervisor(self, bytes_body=False):
- expected = {"hypervisors": [{
- "id": 1,
- "hypervisor_hostname": "hypervisor1.hostname.com"},
- {
- "id": 2,
- "hypervisor_hostname": "hypervisor2.hostname.com"}]}
- self.check_service_client_function(
- self.client.list_hypervisors,
- 'tempest.common.service_client.ServiceClient.get',
- expected, bytes_body)
-
- def test_show_hypervisor_str_body(self):
- self._test_show_hypervisor(bytes_body=False)
-
- def test_show_hypervisor_byte_body(self):
- self._test_show_hypervisor(bytes_body=True)
-
- def _test_show_hypervisor(self, bytes_body=False):
- expected = {"hypervisor": {
- "cpu_info": "?",
- "current_workload": 0,
- "disk_available_least": 1,
- "host_ip": "10.10.10.10",
- "free_disk_gb": 1028,
- "free_ram_mb": 7680,
- "hypervisor_hostname": "fake-mini",
- "hypervisor_type": "fake",
- "hypervisor_version": 1,
- "id": 1,
- "local_gb": 1028,
- "local_gb_used": 0,
- "memory_mb": 8192,
- "memory_mb_used": 512,
- "running_vms": 0,
- "service": {
- "host": "fake_host",
- "id": 2},
- "vcpus": 1,
- "vcpus_used": 0}}
- self.check_service_client_function(
- self.client.show_hypervisor,
- 'tempest.common.service_client.ServiceClient.get',
- expected, bytes_body,
- hypervisor_id=self.hypervisor_id)
-
- def test_list_servers_on_hypervisor_str_body(self):
- self._test_list_servers_on_hypervisor(bytes_body=False)
-
- def test_list_servers_on_hypervisor_byte_body(self):
- self._test_list_servers_on_hypervisor(bytes_body=True)
-
- def _test_list_servers_on_hypervisor(self, bytes_body=False):
- expected = {"hypervisors": [{
- "id": 1,
- "hypervisor_hostname": "hyper.hostname.com",
- "servers": [{
- "uuid": "e1ae8fc4-b72d-4c2f-a427-30dd420b6277",
- "name": "instance-00000001"},
- {
- "uuid": "e1ae8fc4-b72d-4c2f-a427-30dd42066666",
- "name": "instance-00000002"}
- ]}
- ]}
- self.check_service_client_function(
- self.client.list_servers_on_hypervisor,
- 'tempest.common.service_client.ServiceClient.get',
- expected, bytes_body,
- hypervisor_name=self.hypervisor_name)
-
- def test_show_hypervisor_statistics_str_body(self):
- self._test_show_hypervisor_statistics(bytes_body=False)
-
- def test_show_hypervisor_statistics_byte_body(self):
- self._test_show_hypervisor_statistics(bytes_body=True)
-
- def _test_show_hypervisor_statistics(self, bytes_body=False):
- expected = {
- "hypervisor_statistics": {
- "count": 1,
- "current_workload": 0,
- "disk_available_least": 0,
- "free_disk_gb": 1028,
- "free_ram_mb": 7680,
- "local_gb": 1028,
- "local_gb_used": 0,
- "memory_mb": 8192,
- "memory_mb_used": 512,
- "running_vms": 0,
- "vcpus": 1,
- "vcpus_used": 0}}
- self.check_service_client_function(
- self.client.show_hypervisor_statistics,
- 'tempest.common.service_client.ServiceClient.get',
- expected, bytes_body)
-
- def test_show_hypervisor_uptime_str_body(self):
- self._test_show_hypervisor_uptime(bytes_body=False)
-
- def test_show_hypervisor_uptime_byte_body(self):
- self._test_show_hypervisor_uptime(bytes_body=True)
-
- def _test_show_hypervisor_uptime(self, bytes_body=False):
- expected = {
- "hypervisor": {
- "hypervisor_hostname": "fake-mini",
- "id": 1,
- "uptime": (" 08:32:11 up 93 days, 18:25, 12 users, "
- " load average: 0.20, 0.12, 0.14")
- }}
- self.check_service_client_function(
- self.client.show_hypervisor_uptime,
- 'tempest.common.service_client.ServiceClient.get',
- expected, bytes_body,
- hypervisor_id=self.hypervisor_id)
-
- def test_search_hypervisor_str_body(self):
- self._test_search_hypervisor(bytes_body=False)
-
- def test_search_hypervisor_byte_body(self):
- self._test_search_hypervisor(bytes_body=True)
-
- def _test_search_hypervisor(self, bytes_body=False):
- expected = {"hypervisors": [{
- "id": 2,
- "hypervisor_hostname": "hyper.hostname.com"}]}
- self.check_service_client_function(
- self.client.search_hypervisor,
- 'tempest.common.service_client.ServiceClient.get',
- expected, bytes_body,
- hypervisor_name=self.hypervisor_name)