Merge "Bring back Python 2.6 compat (don"t use dict comprehension)"
diff --git a/HACKING.rst b/HACKING.rst
index e15e213..9f7487d 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -17,6 +17,7 @@
- [T108] Check no hyphen at the end of rand_name() argument
- [T109] Cannot use testtools.skip decorator; instead use
decorators.skip_because from tempest-lib
+- [T110] Check that service client names of GET should be consistent
- [N322] Method's default argument shouldn't be mutable
Test Data/Configuration
@@ -136,7 +137,7 @@
Tear-down is also split in a series of steps (teardown stages), which are
stacked for execution only if the corresponding setup stage had been
reached during the setup phase. Tear-down stages are:
-- `clear_isolated_creds` (defined in the base test class)
+- `clear_credentials` (defined in the base test class)
- `resource_cleanup`
Skipping Tests
@@ -206,9 +207,10 @@
-----------------------
Tempest by default runs its tests in parallel this creates the possibility for
interesting interactions between tests which can cause unexpected failures.
-Tenant isolation provides protection from most of the potential race conditions
-between tests outside the same class. But there are still a few of things to
-watch out for to try to avoid issues when running your tests in parallel.
+Dynamic credentials provides protection from most of the potential race
+conditions between tests outside the same class. But there are still a few of
+things to watch out for to try to avoid issues when running your tests in
+parallel.
- Resources outside of a tenant scope still have the potential to conflict. This
is a larger concern for the admin tests since most resources and actions that
diff --git a/README.rst b/README.rst
index 7108eaf..45cb4c0 100644
--- a/README.rst
+++ b/README.rst
@@ -22,8 +22,8 @@
- Tempest should not touch private or implementation specific
interfaces. This means not directly going to the database, not
directly hitting the hypervisors, not testing extensions not
- included in the OpenStack base. If there is some feature of
- OpenStack that is not verifiable through standard interfaces, this
+ included in the OpenStack base. If there are some features of
+ OpenStack that are not verifiable through standard interfaces, this
should be considered a possible enhancement.
- Tempest strives for complete coverage of the OpenStack API and
common scenarios that demonstrate a working cloud.
@@ -47,10 +47,11 @@
assumptions related to that. For this section we'll only cover the newer method
as it is simpler, and quicker to work with.
-#. You first need to install Tempest this is done with pip, after you check out
- the Tempest repo you simply run something like::
+#. You first need to install Tempest. This is done with pip after you check out
+ the Tempest repo::
- $ pip install tempest
+ $ git clone https://github.com/openstack/tempest/
+ $ pip install tempest/
This can be done within a venv, but the assumption for this guide is that
the Tempest cli entry point will be in your shell's PATH.
@@ -168,7 +169,7 @@
$> cd $TEMPEST_ROOT_DIR
$> oslo-config-generator --config-file \
- tools/config/config-generator.tempest.conf \
+ etc/config-generator.tempest.conf \
--output-file etc/tempest.conf
After that, open up the ``etc/tempest.conf`` file and edit the
diff --git a/doc/source/conf.py b/doc/source/conf.py
index f85899b..12d1d40 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -34,7 +34,7 @@
'oslo_config.sphinxconfiggen',
]
-config_generator_config_file = '../../tools/config/config-generator.tempest.conf'
+config_generator_config_file = '../../etc/config-generator.tempest.conf'
sample_config_basename = '_static/tempest'
todo_include_todos = True
diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst
index ec430b7..1b2b6d2 100644
--- a/doc/source/configuration.rst
+++ b/doc/source/configuration.rst
@@ -63,38 +63,41 @@
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Tempest currently also has 3 different internal methods for providing
-authentication to tests. Tenant isolation, locking test accounts, and
+authentication to tests. Dynamic credentials, locking test accounts, and
non-locking test accounts. Depending on which one is in use the configuration
of tempest is slightly different.
-Tenant Isolation
-""""""""""""""""
-Tenant isolation was originally create to enable running tempest in parallel.
+Dynamic Credentials
+"""""""""""""""""""
+Dynamic Credentials (formerly known as Tenant isolation) was originally created
+to enable running tempest in parallel.
For each test class it creates a unique set of user credentials to use for the
tests in the class. It can create up to 3 sets of username, password, and
tenant/project names for a primary user, an admin user, and an alternate user.
-To enable and use tenant isolation you only need to configure 2 things:
+To enable and use dynamic credentials you only need to configure 2 things:
#. A set of admin credentials with permissions to create users and
- tenants/projects. This is specified in the identity section with the
- admin_username, admin_tenant_name, and admin_password options
- #. To enable tenant_isolation in the auth section with the
- allow_tenant_isolation option.
+ tenants/projects. This is specified in the auth section with the
+ admin_username, admin_tenant_name, admin_domain_name and admin_password
+ options
+ #. To enable dynamic_creds in the auth section with the
+ use_dynamic_credentials option.
This is also the currently the default credential provider enabled by tempest,
due to it's common use and ease of configuration.
It is worth pointing out that depending on your cloud configuration you might
-need to assign a role to each of the users created Tempest's tenant isolation.
+need to assign a role to each of the users created by Tempest's dynamic
+credentials.
This can be set using the *tempest_roles* option. It takes in a list of role
-names each of which will be assigned to each of the users created by tenant
-isolation. This option will not have any effect when set and tempest is not
-configured to use tenant isolation.
+names each of which will be assigned to each of the users created by dynamic
+credentials. This option will not have any effect when set and tempest is not
+configured to use dynamic credentials.
Locking Test Accounts (aka accounts.yaml or accounts file)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-For a long time using tenant isolation was the only method available if you
+For a long time using dynamic credentials was the only method available if you
wanted to enable parallel execution of tempest tests. However this was
insufficient for certain use cases because of the admin credentials requirement
to create the credential sets on demand. To get around that the accounts.yaml
@@ -102,7 +105,7 @@
using the list of credentials instead of creating them on demand. With locking
test accounts each test class will reserve a set of credentials from the
accounts.yaml before executing any of its tests so that each class is isolated
-like in tenant isolation.
+like with dynamic credentials.
To enable and use locking test accounts you need do a few things:
@@ -116,7 +119,7 @@
#. Provide tempest with the location of your accounts.yaml file with the
test_accounts_file option in the auth section
- #. Set allow_tenant_isolation = False in the auth group
+ #. Set use_dynamic_credentials = False in the auth group
It is worth pointing out that each set of credentials in the accounts.yaml
should have a unique tenant. This is required to provide proper isolation
@@ -124,13 +127,16 @@
unexpected failures in some tests.
-Non-locking test accounts (aka credentials config options)
-""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+Legacy test accounts (aka credentials config options)
+"""""""""""""""""""""""""""""""""""""""""""""""""""""
+**Starting in the Liberty release this mechanism was deprecated and will be
+removed in a future release**
+
When Tempest was refactored to allow for locking test accounts, the original
non-tenant isolated case was converted to internally work similarly to the
-accounts.yaml file. This mechanism was then called the non-locking test accounts
-provider. To use the non-locking test accounts provider you can specify the sets
-of credentials in the configuration file like detailed above with following 9
+accounts.yaml file. This mechanism was then called the legacy test accounts
+provider. To use the legacy test accounts provider you can specify the sets of
+credentials in the configuration file like detailed above with following 9
options in the identity section:
#. username
@@ -145,7 +151,7 @@
And in the auth section:
- #. allow_tenant_isolation = False
+ #. use_dynamic_credentials = False
#. comment out 'test_accounts_file' or keep it as empty
It only makes sense to use it if parallel execution isn't needed, since tempest
@@ -291,28 +297,28 @@
misconfiguration or a missing network in the accounts file.
-With Tenant Isolation
-"""""""""""""""""""""
-With tenant isolation enabled and using nova-network then nothing changes. Your
-only option for configuration is to either set a fixed network name or not.
+With Dynamic Credentials
+""""""""""""""""""""""""
+With dynamic credentials enabled and using nova-network then nothing changes.
+Your only option for configuration is to either set a fixed network name or not.
However, in most cases it shouldn't matter because nova-network should have no
problem booting a server with multiple networks. If this is not the case for
your cloud then using an accounts file is recommended because it provides the
-necessary flexibility to describe your configuration. Tenant isolation is not
+necessary flexibility to describe your configuration. Dynamic credentials is not
able to dynamically allocate things as necessary if neutron is not enabled.
-With neutron and tenant isolation enabled there should not be any additional
+With neutron and dynamic credentials enabled there should not be any additional
configuration necessary to enable Tempest to create servers with working
networking, assuming you have properly configured the network section to work
for your cloud. Tempest will dynamically create the neutron resources necessary
to enable using servers with that network. Also, just as with the accounts
-file, if you specify a fixed network name while using neutron and tenant
-isolation it will enable running tests which require a static network and it
+file, if you specify a fixed network name while using neutron and dynamic
+credentials it will enable running tests which require a static network and it
will additionally be used as a fallback for server creation. However, unlike
accounts.yaml this should never be triggered.
-However, there is an option *create_isolated_networks* to disable tenant
-isolation's automatic provisioning of network resources. If this option is
+However, there is an option *create_isolated_networks* to disable dynamic
+credentials's automatic provisioning of network resources. If this option is
used you will have to either rely on there only being a single/default network
available for the server creation, or use *fixed_network_name* to inform
Tempest which network to use.
@@ -357,6 +363,17 @@
the same *catalog_type* as devstack or you want Tempest to talk to a different
endpoint type instead of publicURL for a service that these need to be changed.
+.. note::
+
+ Tempest does not serve all kind of fancy URLs in the service catalog.
+ Service catalog should be in a standard format (which is going to be
+ standardized at keystone level).
+ Tempest expects URLs in the Service catalog in below format:
+ * http://example.com:1234/<version-info>
+ Examples:
+ * Good - http://example.com:1234/v2.0
+ * Wouldn’t work - http://example.com:1234/xyz/v2.0/
+ (adding prefix/suffix around version etc)
Service feature configuration
-----------------------------
diff --git a/doc/source/plugin.rst b/doc/source/plugin.rst
index f92f63e..29653a6 100644
--- a/doc/source/plugin.rst
+++ b/doc/source/plugin.rst
@@ -20,32 +20,26 @@
to tempest-lib. In that situation, file a bug, push a migration patch, etc. to
expedite providing the interface in a reliable manner.
-Plugin Class
-------------
+Plugin Cookiecutter
+-------------------
-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
-to get information when it needs. To simplify creating this tempest provides an
-abstract class that should be used as the parent for your plugin. To use this
-you would do something like the following::
+In order to create the basic structure with base classes and test directories
+you can use the tempest-plugin-cookiecutter project::
- from tempest.test_discover import plugin
+ > pip install -U cookiecutter && cookiecutter https://git.openstack.org/openstack/tempest-plugin-cookiecutter
- class MyPlugin(plugin.TempestPlugin):
+ 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
-Then you need to ensure you locally define all of the methods in the abstract
-class, you can refer to the api doc below for a reference of what that entails.
-
-Also, note eventually this abstract class will likely live in tempest-lib, when
-that migration occurs a deprecation shim will be added to tempest so as to not
-break any existing plugins. But, when that occurs migrating to using tempest-lib
-as the source for the abstract class will be prudent.
-
-Abstract Plugin Class
-^^^^^^^^^^^^^^^^^^^^^
-
-.. autoclass:: tempest.test_discover.plugins.TempestPlugin
- :members:
+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
-----------
@@ -61,9 +55,35 @@
tempest.test_plugins =
plugin_name = module.path:PluginClass
-Plugin Structure
-----------------
+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
+to get information when it needs. To simplify creating this tempest provides an
+abstract class that should be used as the parent for your plugin. To use this
+you would do something like the following::
+
+ from tempest.test_discover import plugins
+
+ class MyPlugin(plugins.TempestPlugin):
+
+Then you need to ensure you locally define all of the methods in the abstract
+class, you can refer to the api doc below for a reference of what that entails.
+
+Also, note eventually this abstract class will likely live in tempest-lib, when
+that migration occurs a deprecation shim will be added to tempest so as to not
+break any existing plugins. But, when that occurs migrating to using tempest-lib
+as the source for the abstract class will be prudent.
+
+Abstract Plugin Class
+---------------------
+
+.. autoclass:: tempest.test_discover.plugins.TempestPlugin
+ :members:
+
+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/tools/config/config-generator.tempest.conf b/etc/config-generator.tempest.conf
similarity index 100%
rename from tools/config/config-generator.tempest.conf
rename to etc/config-generator.tempest.conf
diff --git a/requirements.txt b/requirements.txt
index b25b9d3..ffe6f26 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
-pbr<2.0,>=1.6
+pbr>=1.6
cliff>=1.14.0 # Apache-2.0
anyjson>=0.3.3
httplib2>=0.7.5
@@ -13,15 +13,15 @@
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.7.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.log>=1.12.0 # Apache-2.0
+oslo.serialization>=1.10.0 # Apache-2.0
+oslo.utils>=2.8.0 # Apache-2.0
six>=1.9.0
iso8601>=0.1.9
fixtures>=1.3.1
testscenarios>=0.4
-tempest-lib>=0.6.1
+tempest-lib>=0.10.0
PyYAML>=3.1.0
stevedore>=1.5.0 # Apache-2.0
diff --git a/setup.cfg b/setup.cfg
index 46e21f1..ee61788 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -34,6 +34,7 @@
tempest = tempest.cmd.main:main
tempest.cm =
init = tempest.cmd.init:TempestInit
+ cleanup = tempest.cmd.cleanup:TempestCleanup
oslo.config.opts =
tempest.config = tempest.config:list_opts
diff --git a/setup.py b/setup.py
index d8080d0..782bb21 100644
--- a/setup.py
+++ b/setup.py
@@ -25,5 +25,5 @@
pass
setuptools.setup(
- setup_requires=['pbr>=1.3'],
+ setup_requires=['pbr>=1.8'],
pbr=True)
diff --git a/tempest/api/baremetal/admin/base.py b/tempest/api/baremetal/admin/base.py
index d7d2efe..80b69b9 100644
--- a/tempest/api/baremetal/admin/base.py
+++ b/tempest/api/baremetal/admin/base.py
@@ -98,8 +98,7 @@
@classmethod
@creates('chassis')
def create_chassis(cls, description=None, expect_errors=False):
- """
- Wrapper utility for creating test chassis.
+ """Wrapper utility for creating test chassis.
:param description: A description of the chassis. if not supplied,
a random value will be generated.
@@ -114,8 +113,7 @@
@creates('node')
def create_node(cls, chassis_id, cpu_arch='x86', cpus=8, local_gb=10,
memory_mb=4096):
- """
- Wrapper utility for creating test baremetal nodes.
+ """Wrapper utility for creating test baremetal nodes.
:param cpu_arch: CPU architecture of the node. Default: x86.
:param cpus: Number of CPUs. Default: 8.
@@ -134,8 +132,7 @@
@classmethod
@creates('port')
def create_port(cls, node_id, address, extra=None, uuid=None):
- """
- Wrapper utility for creating test ports.
+ """Wrapper utility for creating test ports.
:param address: MAC address of the port.
:param extra: Meta data of the port. If not supplied, an empty
@@ -152,8 +149,7 @@
@classmethod
def delete_chassis(cls, chassis_id):
- """
- Deletes a chassis having the specified UUID.
+ """Deletes a chassis having the specified UUID.
:param uuid: The unique identifier of the chassis.
:return: Server response.
@@ -169,8 +165,7 @@
@classmethod
def delete_node(cls, node_id):
- """
- Deletes a node having the specified UUID.
+ """Deletes a node having the specified UUID.
:param uuid: The unique identifier of the node.
:return: Server response.
@@ -186,8 +181,7 @@
@classmethod
def delete_port(cls, port_id):
- """
- Deletes a port having the specified UUID.
+ """Deletes a port having the specified UUID.
:param uuid: The unique identifier of the port.
:return: Server response.
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/admin/test_agents.py b/tempest/api/compute/admin/test_agents.py
index 38f5fb7..d2b3a81 100644
--- a/tempest/api/compute/admin/test_agents.py
+++ b/tempest/api/compute/admin/test_agents.py
@@ -23,9 +23,7 @@
class AgentsAdminTestJSON(base.BaseV2ComputeAdminTest):
- """
- Tests Agents API
- """
+ """Tests Agents API"""
@classmethod
def setup_clients(cls):
diff --git a/tempest/api/compute/admin/test_aggregates.py b/tempest/api/compute/admin/test_aggregates.py
index 4d05ff7..ddd9aa0 100644
--- a/tempest/api/compute/admin/test_aggregates.py
+++ b/tempest/api/compute/admin/test_aggregates.py
@@ -22,10 +22,7 @@
class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
-
- """
- Tests Aggregates API that require admin privileges
- """
+ """Tests Aggregates API that require admin privileges"""
_host_key = 'OS-EXT-SRV-ATTR:host'
diff --git a/tempest/api/compute/admin/test_aggregates_negative.py b/tempest/api/compute/admin/test_aggregates_negative.py
index bc1a854..181533b 100644
--- a/tempest/api/compute/admin/test_aggregates_negative.py
+++ b/tempest/api/compute/admin/test_aggregates_negative.py
@@ -22,10 +22,7 @@
class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
-
- """
- Tests Aggregates API that require admin privileges
- """
+ """Tests Aggregates API that require admin privileges"""
@classmethod
def setup_clients(cls):
diff --git a/tempest/api/compute/admin/test_availability_zone.py b/tempest/api/compute/admin/test_availability_zone.py
index 1b36ff2..5befa53 100644
--- a/tempest/api/compute/admin/test_availability_zone.py
+++ b/tempest/api/compute/admin/test_availability_zone.py
@@ -17,11 +17,8 @@
from tempest import test
-class AZAdminV2TestJSON(base.BaseComputeAdminTest):
- """
- Tests Availability Zone API List
- """
- _api_version = 2
+class AZAdminV2TestJSON(base.BaseV2ComputeAdminTest):
+ """Tests Availability Zone API List"""
@classmethod
def setup_clients(cls):
diff --git a/tempest/api/compute/admin/test_availability_zone_negative.py b/tempest/api/compute/admin/test_availability_zone_negative.py
index be1c289..fe979d4 100644
--- a/tempest/api/compute/admin/test_availability_zone_negative.py
+++ b/tempest/api/compute/admin/test_availability_zone_negative.py
@@ -19,10 +19,7 @@
class AZAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
-
- """
- Tests Availability Zone API List
- """
+ """Tests Availability Zone API List"""
@classmethod
def setup_clients(cls):
diff --git a/tempest/api/compute/admin/test_baremetal_nodes.py b/tempest/api/compute/admin/test_baremetal_nodes.py
index 2599d86..b764483 100644
--- a/tempest/api/compute/admin/test_baremetal_nodes.py
+++ b/tempest/api/compute/admin/test_baremetal_nodes.py
@@ -20,9 +20,7 @@
class BaremetalNodesAdminTestJSON(base.BaseV2ComputeAdminTest):
- """
- Tests Baremetal API
- """
+ """Tests Baremetal API"""
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/compute/admin/test_flavors.py b/tempest/api/compute/admin/test_flavors.py
index 085916e..1ef8f67 100644
--- a/tempest/api/compute/admin/test_flavors.py
+++ b/tempest/api/compute/admin/test_flavors.py
@@ -23,10 +23,7 @@
class FlavorsAdminTestJSON(base.BaseV2ComputeAdminTest):
-
- """
- Tests Flavors API Create and Delete that require admin privileges
- """
+ """Tests Flavors API Create and Delete that require admin privileges"""
@classmethod
def skip_checks(cls):
diff --git a/tempest/api/compute/admin/test_flavors_access.py b/tempest/api/compute/admin/test_flavors_access.py
index 0a11d52..2063267 100644
--- a/tempest/api/compute/admin/test_flavors_access.py
+++ b/tempest/api/compute/admin/test_flavors_access.py
@@ -19,9 +19,8 @@
class FlavorsAccessTestJSON(base.BaseV2ComputeAdminTest):
+ """Tests Flavor Access API extension.
- """
- Tests Flavor Access API extension.
Add and remove Flavor Access require admin privileges.
"""
diff --git a/tempest/api/compute/admin/test_flavors_access_negative.py b/tempest/api/compute/admin/test_flavors_access_negative.py
index 89ae1b5..5070fd7 100644
--- a/tempest/api/compute/admin/test_flavors_access_negative.py
+++ b/tempest/api/compute/admin/test_flavors_access_negative.py
@@ -23,9 +23,8 @@
class FlavorsAccessNegativeTestJSON(base.BaseV2ComputeAdminTest):
+ """Tests Flavor Access API extension.
- """
- Tests Flavor Access API extension.
Add and remove Flavor Access require admin privileges.
"""
diff --git a/tempest/api/compute/admin/test_flavors_extra_specs.py b/tempest/api/compute/admin/test_flavors_extra_specs.py
index 25dce6a..661cd18 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs.py
@@ -19,9 +19,8 @@
class FlavorsExtraSpecsTestJSON(base.BaseV2ComputeAdminTest):
+ """Tests Flavor Extra Spec API extension.
- """
- Tests Flavor Extra Spec API extension.
SET, UNSET, UPDATE Flavor Extra specs require admin privileges.
GET Flavor Extra specs can be performed even by without admin privileges.
"""
diff --git a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
index aa95454..14646e8 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
@@ -22,9 +22,8 @@
class FlavorsExtraSpecsNegativeTestJSON(base.BaseV2ComputeAdminTest):
+ """Negative Tests Flavor Extra Spec API extension.
- """
- Negative Tests Flavor Extra Spec API extension.
SET, UNSET, UPDATE Flavor Extra specs require admin privileges.
"""
diff --git a/tempest/api/compute/admin/test_floating_ips_bulk.py b/tempest/api/compute/admin/test_floating_ips_bulk.py
index e979616..fe05ddb 100644
--- a/tempest/api/compute/admin/test_floating_ips_bulk.py
+++ b/tempest/api/compute/admin/test_floating_ips_bulk.py
@@ -24,9 +24,8 @@
class FloatingIPsBulkAdminTestJSON(base.BaseV2ComputeAdminTest):
- """
- Tests Floating IPs Bulk APIs Create, List and Delete that
- require admin privileges.
+ """Tests Floating IPs Bulk APIs that require admin privileges.
+
API documentation - http://docs.openstack.org/api/openstack-compute/2/
content/ext-os-floating-ips-bulk.html
"""
diff --git a/tempest/api/compute/admin/test_hosts.py b/tempest/api/compute/admin/test_hosts.py
index 6d8788f..f6ea3a4 100644
--- a/tempest/api/compute/admin/test_hosts.py
+++ b/tempest/api/compute/admin/test_hosts.py
@@ -18,10 +18,7 @@
class HostsAdminTestJSON(base.BaseV2ComputeAdminTest):
-
- """
- Tests hosts API using admin privileges.
- """
+ """Tests hosts API using admin privileges."""
@classmethod
def setup_clients(cls):
diff --git a/tempest/api/compute/admin/test_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py
index 4c8d8a2..65ada4d 100644
--- a/tempest/api/compute/admin/test_hosts_negative.py
+++ b/tempest/api/compute/admin/test_hosts_negative.py
@@ -20,10 +20,7 @@
class HostsAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
-
- """
- Tests hosts API using admin privileges.
- """
+ """Tests hosts API using admin privileges."""
@classmethod
def setup_clients(cls):
diff --git a/tempest/api/compute/admin/test_hypervisor.py b/tempest/api/compute/admin/test_hypervisor.py
index 186867e..113ec40 100644
--- a/tempest/api/compute/admin/test_hypervisor.py
+++ b/tempest/api/compute/admin/test_hypervisor.py
@@ -18,10 +18,7 @@
class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
-
- """
- Tests Hypervisors API that require admin privileges
- """
+ """Tests Hypervisors API that require admin privileges"""
@classmethod
def setup_clients(cls):
diff --git a/tempest/api/compute/admin/test_hypervisor_negative.py b/tempest/api/compute/admin/test_hypervisor_negative.py
index ca4a691..0e8012a 100644
--- a/tempest/api/compute/admin/test_hypervisor_negative.py
+++ b/tempest/api/compute/admin/test_hypervisor_negative.py
@@ -23,10 +23,7 @@
class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
-
- """
- Tests Hypervisors API that require admin privileges
- """
+ """Tests Hypervisors API that require admin privileges"""
@classmethod
def setup_clients(cls):
diff --git a/tempest/api/compute/admin/test_live_migration.py b/tempest/api/compute/admin/test_live_migration.py
index 9d49124..7c4c30c 100644
--- a/tempest/api/compute/admin/test_live_migration.py
+++ b/tempest/api/compute/admin/test_live_migration.py
@@ -28,6 +28,18 @@
_host_key = 'OS-EXT-SRV-ATTR:host'
@classmethod
+ def skip_checks(cls):
+ super(LiveBlockMigrationTestJSON, cls).skip_checks()
+
+ if not CONF.compute_feature_enabled.live_migration:
+ skip_msg = ("%s skipped as live-migration is "
+ "not available" % cls.__name__)
+ raise cls.skipException(skip_msg)
+ if CONF.compute.min_compute_nodes < 2:
+ raise cls.skipException(
+ "Less than 2 compute nodes, skipping migration test.")
+
+ @classmethod
def setup_clients(cls):
super(LiveBlockMigrationTestJSON, cls).setup_clients()
cls.admin_hosts_client = cls.os_adm.hosts_client
@@ -35,13 +47,8 @@
cls.admin_migration_client = cls.os_adm.migrations_client
@classmethod
- def resource_setup(cls):
- super(LiveBlockMigrationTestJSON, cls).resource_setup()
-
- cls.created_server_ids = []
-
- def _get_compute_hostnames(self):
- body = self.admin_hosts_client.list_hosts()['hosts']
+ def _get_compute_hostnames(cls):
+ body = cls.admin_hosts_client.list_hosts()['hosts']
return [
host_record['host_name']
for host_record in body
@@ -55,10 +62,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):
- bmflm = CONF.compute_feature_enabled.block_migration_for_live_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
@@ -70,15 +79,10 @@
def _get_server_status(self, server_id):
return self._get_server_details(server_id)['status']
- def _get_an_active_server(self):
- for server_id in self.created_server_ids:
- if 'ACTIVE' == self._get_server_status(server_id):
- return server_id
- else:
- server = self.create_test_server(wait_until="ACTIVE")
- server_id = server['id']
- self.created_server_ids.append(server_id)
- return server_id
+ def _create_server(self, volume_backed=False):
+ server = self.create_test_server(wait_until="ACTIVE",
+ volume_backed=volume_backed)
+ return server['id']
def _volume_clean_up(self, server_id, volume_id):
body = self.volumes_client.show_volume(volume_id)['volume']
@@ -87,20 +91,19 @@
self.volumes_client.wait_for_volume_status(volume_id, 'available')
self.volumes_client.delete_volume(volume_id)
- def _test_live_block_migration(self, state='ACTIVE'):
- """Tests live block migration between two hosts.
+ def _test_live_migration(self, state='ACTIVE', volume_backed=False):
+ """Tests live migration between two hosts.
Requires CONF.compute_feature_enabled.live_migration to be True.
:param state: The vm_state the migrated server should be in before and
after the live migration. Supported values are 'ACTIVE'
and 'PAUSED'.
+ :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
- 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()
+ # Live migrate an instance to another host
+ 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)
@@ -109,7 +112,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'])
@@ -124,14 +127,10 @@
msg)
@test.idempotent_id('1dce86b8-eb04-4c03-a9d8-9c1dc3ee0c7b')
- @testtools.skipUnless(CONF.compute_feature_enabled.live_migration,
- 'Live migration not available')
def test_live_block_migration(self):
- self._test_live_block_migration()
+ self._test_live_migration()
@test.idempotent_id('1e107f21-61b2-4988-8f22-b196e938ab88')
- @testtools.skipUnless(CONF.compute_feature_enabled.live_migration,
- 'Live migration not available')
@testtools.skipUnless(CONF.compute_feature_enabled.pause,
'Pause is not available.')
@testtools.skipUnless(CONF.compute_feature_enabled
@@ -139,22 +138,22 @@
'Live migration of paused instances is not '
'available.')
def test_live_block_migration_paused(self):
- self._test_live_block_migration(state='PAUSED')
+ self._test_live_migration(state='PAUSED')
+
+ @test.idempotent_id('5071cf17-3004-4257-ae61-73a84e28badd')
+ @test.services('volume')
+ def test_volume_backed_live_migration(self):
+ self._test_live_migration(volume_backed=True)
@test.idempotent_id('e19c0cc6-6720-4ed8-be83-b6603ed5c812')
- @testtools.skipIf(not CONF.compute_feature_enabled.live_migration or not
- CONF.compute_feature_enabled.
+ @testtools.skipIf(not CONF.compute_feature_enabled.
block_migration_for_live_migration,
'Block Live migration not available')
@testtools.skipIf(not CONF.compute_feature_enabled.
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/compute/admin/test_networks.py b/tempest/api/compute/admin/test_networks.py
index 1da3f6e..e5c8790 100644
--- a/tempest/api/compute/admin/test_networks.py
+++ b/tempest/api/compute/admin/test_networks.py
@@ -20,11 +20,9 @@
CONF = config.CONF
-class NetworksTest(base.BaseComputeAdminTest):
- _api_version = 2
+class NetworksTest(base.BaseV2ComputeAdminTest):
+ """Tests Nova Networks API that usually requires admin privileges.
- """
- Tests Nova Networks API that usually requires admin privileges.
API docs:
http://developer.openstack.org/api-ref-compute-v2-ext.html#ext-os-networks
"""
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index dbca6bb..fa1c666 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -151,8 +151,7 @@
class QuotaClassesAdminTestJSON(base.BaseV2ComputeAdminTest):
- """Tests the os-quota-class-sets API to update default quotas.
- """
+ """Tests the os-quota-class-sets API to update default quotas."""
def setUp(self):
# All test cases in this class need to externally lock on doing
diff --git a/tempest/api/compute/admin/test_servers.py b/tempest/api/compute/admin/test_servers.py
index dfaa5d5..b038c6b 100644
--- a/tempest/api/compute/admin/test_servers.py
+++ b/tempest/api/compute/admin/test_servers.py
@@ -22,10 +22,7 @@
class ServersAdminTestJSON(base.BaseV2ComputeAdminTest):
-
- """
- Tests Servers API using admin privileges
- """
+ """Tests Servers API using admin privileges"""
_host_key = 'OS-EXT-SRV-ATTR:host'
@@ -150,7 +147,7 @@
@test.idempotent_id('31ff3486-b8a0-4f56-a6c0-aab460531db3')
def test_get_server_diagnostics_by_admin(self):
# Retrieve server diagnostics by admin user
- diagnostic = self.client.get_server_diagnostics(self.s1_id)
+ diagnostic = self.client.show_server_diagnostics(self.s1_id)
basic_attrs = ['rx_packets', 'rx_errors', 'rx_drop',
'tx_packets', 'tx_errors', 'tx_drop',
'read_req', 'write_req', 'cpu', 'memory']
diff --git a/tempest/api/compute/admin/test_servers_negative.py b/tempest/api/compute/admin/test_servers_negative.py
index c2dc94c..7c5e8d0 100644
--- a/tempest/api/compute/admin/test_servers_negative.py
+++ b/tempest/api/compute/admin/test_servers_negative.py
@@ -28,10 +28,7 @@
class ServersAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
-
- """
- Tests Servers API using admin privileges
- """
+ """Tests Servers API using admin privileges"""
@classmethod
def setup_clients(cls):
@@ -133,7 +130,7 @@
def test_get_server_diagnostics_by_non_admin(self):
# Non-admin user can not view server diagnostics according to policy
self.assertRaises(lib_exc.Forbidden,
- self.non_adm_client.get_server_diagnostics,
+ self.non_adm_client.show_server_diagnostics,
self.s1_id)
@test.attr(type=['negative'])
diff --git a/tempest/api/compute/admin/test_services.py b/tempest/api/compute/admin/test_services.py
index 4d7dea5..8648b9f 100644
--- a/tempest/api/compute/admin/test_services.py
+++ b/tempest/api/compute/admin/test_services.py
@@ -19,10 +19,7 @@
class ServicesAdminTestJSON(base.BaseV2ComputeAdminTest):
-
- """
- Tests Services API. List and Enable/Disable require admin privileges.
- """
+ """Tests Services API. List and Enable/Disable require admin privileges."""
@classmethod
def setup_clients(cls):
diff --git a/tempest/api/compute/admin/test_services_negative.py b/tempest/api/compute/admin/test_services_negative.py
index 0c81ccb..e57401a 100644
--- a/tempest/api/compute/admin/test_services_negative.py
+++ b/tempest/api/compute/admin/test_services_negative.py
@@ -19,10 +19,7 @@
class ServicesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
-
- """
- Tests Services API. List and Enable/Disable require admin privileges.
- """
+ """Tests Services API. List and Enable/Disable require admin privileges."""
@classmethod
def setup_clients(cls):
diff --git a/tempest/api/compute/admin/test_simple_tenant_usage.py b/tempest/api/compute/admin/test_simple_tenant_usage.py
index 7333acb..e5c17ca 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage.py
@@ -14,10 +14,14 @@
# under the License.
import datetime
-import time
from tempest.api.compute import base
from tempest import test
+from tempest_lib import exceptions as e
+
+# Time that waits for until returning valid response
+# TODO(takmatsu): Ideally this value would come from configuration.
+VALID_WAIT = 30
class TenantUsagesTestJSON(base.BaseV2ComputeAdminTest):
@@ -35,7 +39,6 @@
# Create a server in the demo tenant
cls.create_test_server(wait_until='ACTIVE')
- time.sleep(2)
now = datetime.datetime.now()
cls.start = cls._parse_strtime(now - datetime.timedelta(days=1))
@@ -46,17 +49,32 @@
# Returns formatted datetime
return at.strftime('%Y-%m-%dT%H:%M:%S.%f')
+ def call_until_valid(self, func, duration, *args, **kwargs):
+ # Call until get valid response for "duration"
+ # because tenant usage doesn't become available immediately
+ # after create VM.
+ def is_valid():
+ try:
+ self.resp = func(*args, **kwargs)
+ return True
+ except e.InvalidHTTPResponseBody:
+ return False
+ test.call_until_true(is_valid, duration, 1)
+ return self.resp
+
@test.idempotent_id('062c8ae9-9912-4249-8b51-e38d664e926e')
def test_list_usage_all_tenants(self):
# Get usage for all tenants
- tenant_usage = self.adm_client.list_tenant_usages(
+ tenant_usage = self.call_until_valid(
+ self.adm_client.list_tenant_usages, VALID_WAIT,
start=self.start, end=self.end, detailed="1")['tenant_usages'][0]
self.assertEqual(len(tenant_usage), 8)
@test.idempotent_id('94135049-a4c5-4934-ad39-08fa7da4f22e')
def test_get_usage_tenant(self):
# Get usage for a specific tenant
- tenant_usage = self.adm_client.show_tenant_usage(
+ tenant_usage = self.call_until_valid(
+ self.adm_client.show_tenant_usage, VALID_WAIT,
self.tenant_id, start=self.start, end=self.end)['tenant_usage']
self.assertEqual(len(tenant_usage), 8)
@@ -64,7 +82,7 @@
@test.idempotent_id('9d00a412-b40e-4fd9-8eba-97b496316116')
def test_get_usage_tenant_with_non_admin_user(self):
# Get usage for a specific tenant with non admin user
- tenant_usage = self.client.show_tenant_usage(
+ tenant_usage = self.call_until_valid(
+ self.client.show_tenant_usage, VALID_WAIT,
self.tenant_id, start=self.start, end=self.end)['tenant_usage']
-
self.assertEqual(len(tenant_usage), 8)
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 3952439..a5c0600 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -22,7 +22,6 @@
from tempest.common.utils import data_utils
from tempest.common import waiters
from tempest import config
-from tempest import exceptions
import tempest.test
CONF = config.CONF
@@ -30,10 +29,9 @@
LOG = logging.getLogger(__name__)
-class BaseComputeTest(tempest.test.BaseTestCase):
+class BaseV2ComputeTest(tempest.test.BaseTestCase):
"""Base test case class for all Compute API tests."""
- _api_version = 2
force_tenant_isolation = False
# TODO(andreaf) We should care also for the alt_manager here
@@ -42,29 +40,25 @@
@classmethod
def skip_checks(cls):
- super(BaseComputeTest, cls).skip_checks()
+ super(BaseV2ComputeTest, cls).skip_checks()
if not CONF.service_available.nova:
raise cls.skipException("Nova is not available")
- if cls._api_version != 2:
- msg = ("Unexpected API version is specified (%s)" %
- cls._api_version)
- raise exceptions.InvalidConfiguration(message=msg)
@classmethod
def setup_credentials(cls):
cls.set_network_resources()
- super(BaseComputeTest, cls).setup_credentials()
+ super(BaseV2ComputeTest, cls).setup_credentials()
@classmethod
def setup_clients(cls):
- super(BaseComputeTest, cls).setup_clients()
+ super(BaseV2ComputeTest, cls).setup_clients()
cls.servers_client = cls.os.servers_client
cls.server_groups_client = cls.os.server_groups_client
cls.flavors_client = cls.os.flavors_client
cls.images_client = cls.os.images_client
cls.extensions_client = cls.os.extensions_client
cls.floating_ip_pools_client = cls.os.floating_ip_pools_client
- cls.floating_ips_client = cls.os.floating_ips_client
+ cls.floating_ips_client = cls.os.compute_floating_ips_client
cls.keypairs_client = cls.os.keypairs_client
cls.security_group_rules_client = cls.os.security_group_rules_client
cls.security_groups_client = cls.os.security_groups_client
@@ -96,7 +90,7 @@
@classmethod
def resource_setup(cls):
- super(BaseComputeTest, cls).resource_setup()
+ super(BaseV2ComputeTest, cls).resource_setup()
cls.build_interval = CONF.compute.build_interval
cls.build_timeout = CONF.compute.build_timeout
cls.ssh_user = CONF.compute.ssh_user
@@ -117,7 +111,7 @@
cls.clear_servers()
cls.clear_security_groups()
cls.clear_server_groups()
- super(BaseComputeTest, cls).resource_cleanup()
+ super(BaseV2ComputeTest, cls).resource_cleanup()
@classmethod
def clear_servers(cls):
@@ -144,10 +138,11 @@
@classmethod
def server_check_teardown(cls):
"""Checks is the shared server clean enough for subsequent test.
+
Method will delete the server when it's dirty.
The setUp method is responsible for creating a new server.
Exceptions raised in tearDown class are fails the test case,
- This method supposed to use only by tierDown methods, when
+ This method supposed to use only by tearDown methods, when
the shared server_id is stored in the server_id of the class.
"""
if getattr(cls, 'server_id', None) is not None:
@@ -203,13 +198,17 @@
server_group_id)
@classmethod
- def create_test_server(cls, validatable=False, **kwargs):
+ def create_test_server(cls, validatable=False, volume_backed=False,
+ **kwargs):
"""Wrapper utility that returns a test server.
This wrapper utility calls the common create test server and
returns a test server. The purpose of this wrapper is to minimize
the impact on the code of the tests already using this
function.
+
+ :param validatable: Whether the server will be pingable or sshable.
+ :param volume_backed: Whether the instance is volume backed or not.
"""
tenant_network = cls.get_tenant_network()
body, servers = compute.create_test_server(
@@ -217,6 +216,7 @@
validatable,
validation_resources=cls.validation_resources,
tenant_network=tenant_network,
+ volume_backed=volume_backed,
**kwargs)
cls.servers.extend(servers)
@@ -241,8 +241,8 @@
name = data_utils.rand_name(cls.__name__ + "-Server-Group")
if policy is None:
policy = ['affinity']
- body = (cls.server_groups_client.create_server_group(name, policy)
- ['server_group'])
+ body = cls.server_groups_client.create_server_group(
+ name=name, policies=policy)['server_group']
cls.server_groups.append(body['id'])
return body
@@ -351,22 +351,13 @@
return ip_or_server
-class BaseV2ComputeTest(BaseComputeTest):
- _api_version = 2
-
-
-class BaseComputeAdminTest(BaseComputeTest):
+class BaseV2ComputeAdminTest(BaseV2ComputeTest):
"""Base test case class for Compute Admin API tests."""
credentials = ['primary', 'admin']
@classmethod
def setup_clients(cls):
- super(BaseComputeAdminTest, cls).setup_clients()
+ super(BaseV2ComputeAdminTest, cls).setup_clients()
cls.availability_zone_admin_client = (
cls.os_adm.availability_zone_client)
-
-
-class BaseV2ComputeAdminTest(BaseComputeAdminTest):
- """Base test case class for Compute Admin V2 API tests."""
- _api_version = 2
diff --git a/tempest/api/compute/certificates/test_certificates.py b/tempest/api/compute/certificates/test_certificates.py
index 78a0a93..d5c7302 100644
--- a/tempest/api/compute/certificates/test_certificates.py
+++ b/tempest/api/compute/certificates/test_certificates.py
@@ -14,12 +14,19 @@
# 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
+class CertificatesV2TestJSON(base.BaseV2ComputeTest):
+
+ @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):
diff --git a/tempest/api/compute/flavors/test_flavors.py b/tempest/api/compute/flavors/test_flavors.py
index e114c80..7e01296 100644
--- a/tempest/api/compute/flavors/test_flavors.py
+++ b/tempest/api/compute/flavors/test_flavors.py
@@ -17,9 +17,7 @@
from tempest import test
-class FlavorsV2TestJSON(base.BaseComputeTest):
-
- _api_version = 2
+class FlavorsV2TestJSON(base.BaseV2ComputeTest):
_min_disk = 'minDisk'
_min_ram = 'minRam'
diff --git a/tempest/api/compute/images/test_images.py b/tempest/api/compute/images/test_images.py
index 0324df2..dc62620 100644
--- a/tempest/api/compute/images/test_images.py
+++ b/tempest/api/compute/images/test_images.py
@@ -14,6 +14,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import config
from tempest import test
@@ -48,3 +49,18 @@
name=snapshot_name,
wait_until='SAVING')
self.client.delete_image(image['id'])
+
+ @test.idempotent_id('aaacd1d0-55a2-4ce8-818a-b5439df8adc9')
+ def test_create_image_from_stopped_server(self):
+ server = self.create_test_server(wait_until='ACTIVE')
+ self.servers_client.stop_server(server['id'])
+ waiters.wait_for_server_status(self.servers_client,
+ server['id'], 'SHUTOFF')
+ self.addCleanup(self.servers_client.delete_server, server['id'])
+ snapshot_name = data_utils.rand_name('test-snap')
+ image = self.create_image_from_server(server['id'],
+ name=snapshot_name,
+ wait_until='ACTIVE',
+ wait_for_server=False)
+ self.addCleanup(self.client.delete_image, image['id'])
+ self.assertEqual(snapshot_name, image['name'])
diff --git a/tempest/api/compute/images/test_images_negative.py b/tempest/api/compute/images/test_images_negative.py
index 126d092..9197adf 100644
--- a/tempest/api/compute/images/test_images_negative.py
+++ b/tempest/api/compute/images/test_images_negative.py
@@ -71,22 +71,6 @@
'!@#$%^&*()', name=name, meta=meta)
@test.attr(type=['negative'])
- @test.idempotent_id('aaacd1d0-55a2-4ce8-818a-b5439df8adc9')
- def test_create_image_from_stopped_server(self):
- server = self.create_test_server(wait_until='ACTIVE')
- self.servers_client.stop_server(server['id'])
- waiters.wait_for_server_status(self.servers_client,
- server['id'], 'SHUTOFF')
- self.addCleanup(self.servers_client.delete_server, server['id'])
- snapshot_name = data_utils.rand_name('test-snap')
- image = self.create_image_from_server(server['id'],
- name=snapshot_name,
- wait_until='ACTIVE',
- wait_for_server=False)
- self.addCleanup(self.client.delete_image, image['id'])
- self.assertEqual(snapshot_name, image['name'])
-
- @test.attr(type=['negative'])
@test.idempotent_id('ec176029-73dc-4037-8d72-2e4ff60cf538')
def test_create_image_specify_uuid_35_characters_or_less(self):
# Return an error if Image ID passed is 35 characters or less
diff --git a/tempest/api/compute/keypairs/base.py b/tempest/api/compute/keypairs/base.py
index 76e5573..15f231b 100644
--- a/tempest/api/compute/keypairs/base.py
+++ b/tempest/api/compute/keypairs/base.py
@@ -16,11 +16,9 @@
from tempest.api.compute import base
-class BaseKeypairTest(base.BaseComputeTest):
+class BaseKeypairTest(base.BaseV2ComputeTest):
"""Base test case class for all keypair API tests."""
- _api_version = 2
-
@classmethod
def setup_clients(cls):
super(BaseKeypairTest, cls).setup_clients()
diff --git a/tempest/api/compute/servers/test_availability_zone.py b/tempest/api/compute/servers/test_availability_zone.py
index 080441a..76da317 100644
--- a/tempest/api/compute/servers/test_availability_zone.py
+++ b/tempest/api/compute/servers/test_availability_zone.py
@@ -17,11 +17,8 @@
from tempest import test
-class AZV2TestJSON(base.BaseComputeTest):
- """
- Tests Availability Zone API List
- """
- _api_version = 2
+class AZV2TestJSON(base.BaseV2ComputeTest):
+ """Tests Availability Zone API List"""
@classmethod
def setup_clients(cls):
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index 68af81c..f51c2db 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import base64
-
import netaddr
import testtools
@@ -41,6 +39,8 @@
super(ServersTestJSON, cls).setup_clients()
cls.client = cls.servers_client
cls.network_client = cls.os.network_client
+ cls.networks_client = cls.os.networks_client
+ cls.subnets_client = cls.os.subnets_client
@classmethod
def resource_setup(cls):
@@ -50,9 +50,6 @@
cls.accessIPv4 = '1.1.1.1'
cls.accessIPv6 = '0000:0000:0000:0000:0000:babe:220.12.22.2'
cls.name = data_utils.rand_name('server')
- file_contents = 'This is a test file.'
- personality = [{'path': '/test.txt',
- 'contents': base64.b64encode(file_contents)}]
disk_config = cls.disk_config
cls.server_initial = cls.create_test_server(
validatable=True,
@@ -61,7 +58,6 @@
metadata=cls.meta,
accessIPv4=cls.accessIPv4,
accessIPv6=cls.accessIPv6,
- personality=personality,
disk_config=disk_config)
cls.password = cls.server_initial['adminPass']
cls.server = (cls.client.show_server(cls.server_initial['id'])
@@ -69,15 +65,15 @@
def _create_net_subnet_ret_net_from_cidr(self, cidr):
name_net = data_utils.rand_name(self.__class__.__name__)
- net = self.network_client.create_network(name=name_net)
- self.addCleanup(self.network_client.delete_network,
+ net = self.networks_client.create_network(name=name_net)
+ self.addCleanup(self.networks_client.delete_network,
net['network']['id'])
- subnet = self.network_client.create_subnet(
+ subnet = self.subnets_client.create_subnet(
network_id=net['network']['id'],
cidr=cidr,
ip_version=4)
- self.addCleanup(self.network_client.delete_subnet,
+ self.addCleanup(self.subnets_client.delete_subnet,
subnet['subnet']['id'])
return net
@@ -154,7 +150,7 @@
wait_until='ACTIVE')
# Check a server is in the group
- server_group = (self.server_groups_client.get_server_group(group_id)
+ server_group = (self.server_groups_client.show_server_group(group_id)
['server_group'])
self.assertIn(server['id'], server_group['members'])
diff --git a/tempest/api/compute/servers/test_instance_actions.py b/tempest/api/compute/servers/test_instance_actions.py
index 97d47fd..814aec7 100644
--- a/tempest/api/compute/servers/test_instance_actions.py
+++ b/tempest/api/compute/servers/test_instance_actions.py
@@ -47,7 +47,7 @@
@test.idempotent_id('aacc71ca-1d70-4aa5-bbf6-0ff71470e43c')
def test_get_instance_action(self):
# Get the action details of the provided server
- body = self.client.get_instance_action(
+ body = self.client.show_instance_action(
self.server_id, self.request_id)['instanceAction']
self.assertEqual(self.server_id, body['instance_uuid'])
self.assertEqual('create', body['action'])
diff --git a/tempest/api/compute/servers/test_instance_actions_negative.py b/tempest/api/compute/servers/test_instance_actions_negative.py
index 6567da1..ac66d05 100644
--- a/tempest/api/compute/servers/test_instance_actions_negative.py
+++ b/tempest/api/compute/servers/test_instance_actions_negative.py
@@ -46,5 +46,5 @@
@test.idempotent_id('0269f40a-6f18-456c-b336-c03623c897f1')
def test_get_instance_action_invalid_request(self):
# Get the action details of the provided server with invalid request
- self.assertRaises(lib_exc.NotFound, self.client.get_instance_action,
+ self.assertRaises(lib_exc.NotFound, self.client.show_instance_action,
self.server_id, '999')
diff --git a/tempest/api/compute/servers/test_multiple_create.py b/tempest/api/compute/servers/test_multiple_create.py
index a945411..eb1beb1 100644
--- a/tempest/api/compute/servers/test_multiple_create.py
+++ b/tempest/api/compute/servers/test_multiple_create.py
@@ -25,10 +25,9 @@
return data_utils.rand_name(self._name)
def _create_multiple_servers(self, name=None, wait_until=None, **kwargs):
- """
- This is the right way to create_multiple servers and manage to get the
- created servers into the servers list to be cleaned up after all.
- """
+ # NOTE: This is the right way to create_multiple servers and manage to
+ # get the created servers into the servers list to be cleaned up after
+ # all.
kwargs['name'] = name if name else self._generate_name()
if wait_until:
kwargs['wait_until'] = wait_until
diff --git a/tempest/api/compute/servers/test_multiple_create_negative.py b/tempest/api/compute/servers/test_multiple_create_negative.py
index 8135768..3d8a732 100644
--- a/tempest/api/compute/servers/test_multiple_create_negative.py
+++ b/tempest/api/compute/servers/test_multiple_create_negative.py
@@ -27,10 +27,8 @@
return data_utils.rand_name(self._name)
def _create_multiple_servers(self, name=None, wait_until=None, **kwargs):
- """
- This is the right way to create_multiple servers and manage to get the
- created servers into the servers list to be cleaned up after all.
- """
+ # This is the right way to create_multiple servers and manage to get
+ # the created servers into the servers list to be cleaned up after all.
kwargs['name'] = kwargs.get('name', self._generate_name())
body = self.create_test_server(**kwargs)
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index f0cd2a1..0754d27 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import base64
import logging
from six.moves.urllib import parse as urlparse
@@ -53,7 +52,7 @@
except Exception:
# Rebuild server if something happened to it during a test
self.__class__.server_id = self.rebuild_server(
- self.server_id, validatable=True)['server']
+ self.server_id, validatable=True)
def tearDown(self):
self.server_check_teardown()
@@ -145,16 +144,12 @@
# The server should be rebuilt using the provided image and data
meta = {'rebuild': 'server'}
new_name = data_utils.rand_name('server')
- file_contents = 'Test server rebuild.'
- personality = [{'path': 'rebuild.txt',
- 'contents': base64.b64encode(file_contents)}]
password = 'rebuildPassw0rd'
rebuilt_server = self.client.rebuild_server(
self.server_id,
self.image_ref_alt,
name=new_name,
metadata=meta,
- personality=personality,
adminPass=password)['server']
# If the server was rebuilt on a different image, restore it to the
diff --git a/tempest/api/compute/servers/test_server_group.py b/tempest/api/compute/servers/test_server_group.py
index 0da7912..c23b365 100644
--- a/tempest/api/compute/servers/test_server_group.py
+++ b/tempest/api/compute/servers/test_server_group.py
@@ -21,8 +21,8 @@
class ServerGroupTestJSON(base.BaseV2ComputeTest):
- """
- These tests check for the server-group APIs
+ """These tests check for the server-group APIs
+
They create/delete server-groups with different policies.
policies = affinity/anti-affinity
It also adds the tests for list and get details of server-groups
@@ -104,9 +104,9 @@
self._delete_server_group(server_groups[i])
@test.idempotent_id('b3545034-dd78-48f0-bdc2-a4adfa6d0ead')
- def test_get_server_group(self):
+ def test_show_server_group(self):
# Get the server-group
- body = self.client.get_server_group(
+ body = self.client.show_server_group(
self.created_server_group['id'])['server_group']
self.assertEqual(self.created_server_group, body)
diff --git a/tempest/api/compute/servers/test_server_metadata.py b/tempest/api/compute/servers/test_server_metadata.py
index 77ddb3b..9c07677 100644
--- a/tempest/api/compute/servers/test_server_metadata.py
+++ b/tempest/api/compute/servers/test_server_metadata.py
@@ -87,8 +87,8 @@
@test.idempotent_id('3043c57d-7e0e-49a6-9a96-ad569c265e6a')
def test_get_server_metadata_item(self):
# The value for a specific metadata key should be returned
- meta = self.client.get_server_metadata_item(self.server_id,
- 'key2')['meta']
+ meta = self.client.show_server_metadata_item(self.server_id,
+ 'key2')['meta']
self.assertEqual('value2', meta['key2'])
@test.idempotent_id('58c02d4f-5c67-40be-8744-d3fa5982eb1c')
diff --git a/tempest/api/compute/servers/test_server_metadata_negative.py b/tempest/api/compute/servers/test_server_metadata_negative.py
index cee60fb..18d80be 100644
--- a/tempest/api/compute/servers/test_server_metadata_negative.py
+++ b/tempest/api/compute/servers/test_server_metadata_negative.py
@@ -67,7 +67,7 @@
# GET on a non-existent server should not succeed
non_existent_server_id = data_utils.rand_uuid()
self.assertRaises(lib_exc.NotFound,
- self.client.get_server_metadata_item,
+ self.client.show_server_metadata_item,
non_existent_server_id,
'test2')
diff --git a/tempest/api/compute/servers/test_server_password.py b/tempest/api/compute/servers/test_server_password.py
index 35c2cfd..9b41708 100644
--- a/tempest/api/compute/servers/test_server_password.py
+++ b/tempest/api/compute/servers/test_server_password.py
@@ -32,7 +32,7 @@
@test.idempotent_id('f83b582f-62a8-4f22-85b0-0dee50ff783a')
def test_get_server_password(self):
- self.client.get_password(self.server['id'])
+ self.client.show_password(self.server['id'])
@test.idempotent_id('f8229e8b-b625-4493-800a-bde86ac611ea')
def test_delete_server_password(self):
diff --git a/tempest/api/compute/servers/test_server_personality.py b/tempest/api/compute/servers/test_server_personality.py
index a7fc235..77af509 100644
--- a/tempest/api/compute/servers/test_server_personality.py
+++ b/tempest/api/compute/servers/test_server_personality.py
@@ -17,17 +17,42 @@
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest import config
from tempest import test
+CONF = config.CONF
+
class ServerPersonalityTestJSON(base.BaseV2ComputeTest):
@classmethod
+ def skip_checks(cls):
+ super(ServerPersonalityTestJSON, cls).skip_checks()
+ if not CONF.compute_feature_enabled.personality:
+ raise cls.skipException("Nova personality feature disabled")
+
+ @classmethod
def setup_clients(cls):
super(ServerPersonalityTestJSON, cls).setup_clients()
cls.client = cls.servers_client
cls.user_client = cls.limits_client
+ @test.idempotent_id('3cfe87fd-115b-4a02-b942-7dc36a337fdf')
+ def test_create_server_with_personality(self):
+ file_contents = 'This is a test file.'
+ personality = [{'path': '/test.txt',
+ 'contents': base64.b64encode(file_contents)}]
+ self.create_test_server(personality=personality)
+
+ @test.idempotent_id('128966d8-71fc-443c-8cab-08e24114ecc9')
+ def test_rebuild_server_with_personality(self):
+ server_id = self.rebuild_server(None)
+ file_contents = 'Test server rebuild.'
+ personality = [{'path': 'rebuild.txt',
+ 'contents': base64.b64encode(file_contents)}]
+ self.client.rebuild_server(server_id, self.image_ref_alt,
+ personality=personality)
+
@test.idempotent_id('176cd8c9-b9e8-48ee-a480-180beab292bf')
def test_personality_files_exceed_limit(self):
# Server creation should fail if greater than the maximum allowed
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index 6946be4..98b292a 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -66,6 +66,8 @@
@test.attr(type=['negative'])
@test.idempotent_id('b8a7235e-5246-4a8f-a08e-b34877c6586f')
+ @testtools.skipUnless(CONF.compute_feature_enabled.personality,
+ 'Nova personality feature disabled')
def test_personality_file_contents_not_encoded(self):
# Use an unencoded file when creating a server with personality
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index 484c156..436ed2f 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -186,6 +186,14 @@
@test.idempotent_id('acf8724b-142b-4044-82c3-78d31a533f24')
def test_create_server_fails_when_tenant_incorrect(self):
+ # BUG(sdague): this test should fail because of bad auth url,
+ # which means that when we run with a service catalog without
+ # project_id in the urls, it should fail to fail, and thus
+ # fail the test. It does not.
+ #
+ # The 400 BadRequest is clearly ambiguous, and something else
+ # is wrong about this request. This should be fixed.
+ #
# A create server request should fail if the tenant id does not match
# the current user
# Change the base URL to impersonate another user
@@ -199,9 +207,22 @@
@test.idempotent_id('f03d1ded-7fd4-4d29-bc13-e2391f29c625')
def test_create_keypair_in_analt_user_tenant(self):
- # A create keypair request should fail if the tenant id does not match
- # the current user
- # POST keypair with other user tenant
+ """create keypair should not function for alternate tenant
+
+ POST {alt_service_url}/os-keypairs
+
+ Attempt to create a keypair against an alternate tenant by
+ changing using a different tenant's service url. This should
+ return a BadRequest. This tests basic tenant isolation protections.
+
+ NOTE(sdague): if the environment does not use project_id in
+ the service urls, this test is not valid. Skip under these
+ conditions.
+
+ """
+ if self.alt_keypairs_client.base_url == self.keypairs_client.base_url:
+ raise self.skipException("Service urls don't include project_id")
+
k_name = data_utils.rand_name('keypair')
try:
# Change the base URL to impersonate another user
@@ -250,9 +271,23 @@
@test.idempotent_id('752c917e-83be-499d-a422-3559127f7d3c')
def test_create_security_group_in_analt_user_tenant(self):
- # A create security group request should fail if the tenant id does not
- # match the current user
- # POST security group with other user tenant
+ """create security group should not function for alternate tenant
+
+ POST {alt_service_url}/os-security-groups
+
+ Attempt to create a security group against an alternate tenant
+ by changing using a different tenant's service url. This
+ should return a BadRequest. This tests basic tenant isolation
+ protections.
+
+ NOTE(sdague): if the environment does not use project_id in
+ the service urls, this test is not valid. Skip under these
+ conditions.
+
+ """
+ if self.alt_security_client.base_url == self.security_client.base_url:
+ raise self.skipException("Service urls don't include project_id")
+
s_name = data_utils.rand_name('security')
s_description = data_utils.rand_name('security')
try:
@@ -289,9 +324,23 @@
@test.idempotent_id('b2b76de0-210a-4089-b921-591c9ec552f6')
def test_create_security_group_rule_in_analt_user_tenant(self):
- # A create security group rule request should fail if the tenant id
- # does not match the current user
- # POST security group rule with other user tenant
+ """create security group rule should not function for alternate tenant
+
+ POST {alt_service_url}/os-security-group-rules
+
+ Attempt to create a security group rule against an alternate
+ tenant by changing using a different tenant's service
+ url. This should return a BadRequest. This tests basic tenant
+ isolation protections.
+
+ NOTE(sdague): if the environment does not use project_id in
+ the service urls, this test is not valid. Skip under these
+ conditions.
+
+ """
+ if self.alt_security_client.base_url == self.security_client.base_url:
+ raise self.skipException("Service urls don't include project_id")
+
parent_group_id = self.security_group['id']
ip_protocol = 'icmp'
from_port = -1
@@ -351,7 +400,7 @@
self.addCleanup(self.client.delete_server_metadata_item,
self.server['id'], 'meta1')
self.assertRaises(lib_exc.NotFound,
- self.alt_client.get_server_metadata_item,
+ self.alt_client.show_server_metadata_item,
self.server['id'], 'meta1')
@test.idempotent_id('16b2d724-0d3b-4216-a9fa-97bd4d9cf670')
diff --git a/tempest/api/compute/test_versions.py b/tempest/api/compute/test_versions.py
index f94cee6..8b84a21 100644
--- a/tempest/api/compute/test_versions.py
+++ b/tempest/api/compute/test_versions.py
@@ -16,7 +16,7 @@
from tempest import test
-class TestVersions(base.BaseComputeTest):
+class TestVersions(base.BaseV2ComputeTest):
@test.idempotent_id('6c0a0990-43b6-4529-9b61-5fd8daf7c55c')
def test_list_api_versions(self):
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index ab4ddf7..b4837f7 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -144,7 +144,7 @@
self.assertIn(self.attachment, body)
# Get Volume attachment of the server
- body = self.servers_client.get_volume_attachment(
+ body = self.servers_client.show_volume_attachment(
self.server['id'],
self.attachment['id'])['volumeAttachment']
self.assertEqual(self.server['id'], body['serverId'])
diff --git a/tempest/api/compute/volumes/test_volumes_list.py b/tempest/api/compute/volumes/test_volumes_list.py
index f0ed141..990e429 100644
--- a/tempest/api/compute/volumes/test_volumes_list.py
+++ b/tempest/api/compute/volumes/test_volumes_list.py
@@ -23,14 +23,11 @@
class VolumesTestJSON(base.BaseV2ComputeTest):
-
- """
- This test creates a number of 1G volumes. To run successfully,
- ensure that the backing file for the volume group that Nova uses
- has space for at least 3 1G volumes!
- If you are running a Devstack environment, ensure that the
- VOLUME_BACKING_FILE_SIZE is atleast 4G in your localrc
- """
+ # NOTE: This test creates a number of 1G volumes. To run successfully,
+ # ensure that the backing file for the volume group that Nova uses
+ # has space for at least 3 1G volumes!
+ # If you are running a Devstack environment, ensure that the
+ # VOLUME_BACKING_FILE_SIZE is atleast 4G in your localrc
@classmethod
def skip_checks(cls):
diff --git a/tempest/api/data_processing/base.py b/tempest/api/data_processing/base.py
index 5d78539..4e88f65 100644
--- a/tempest/api/data_processing/base.py
+++ b/tempest/api/data_processing/base.py
@@ -399,6 +399,7 @@
@classmethod
def _get_default_version(cls):
"""Returns the default plugin version used for testing.
+
This is gathered separately from the plugin to allow
the usage of plugin name in skip_checks. This method is
rather invoked into resource_setup, which allows API calls
@@ -439,6 +440,7 @@
@classmethod
def get_cluster_template(cls, node_group_template_ids=None):
"""Returns a cluster template for the default plugin.
+
node_group_template_defined contains the type and ID of pre-defined
node group templates that have to be used in the cluster template
(instead of dynamically defining them with 'node_processes').
diff --git a/tempest/api/data_processing/test_cluster_templates.py b/tempest/api/data_processing/test_cluster_templates.py
index 42cbd14..dfd8e27 100644
--- a/tempest/api/data_processing/test_cluster_templates.py
+++ b/tempest/api/data_processing/test_cluster_templates.py
@@ -19,9 +19,9 @@
class ClusterTemplateTest(dp_base.BaseDataProcessingTest):
- """Link to the API documentation is http://docs.openstack.org/developer/
- sahara/restapi/rest_api_v1.0.html#cluster-templates
- """
+ # Link to the API documentation is http://docs.openstack.org/developer/
+ # sahara/restapi/rest_api_v1.0.html#cluster-templates
+
@classmethod
def skip_checks(cls):
super(ClusterTemplateTest, cls).skip_checks()
diff --git a/tempest/api/data_processing/test_job_binaries.py b/tempest/api/data_processing/test_job_binaries.py
index 98b7e24..a47ddbc 100644
--- a/tempest/api/data_processing/test_job_binaries.py
+++ b/tempest/api/data_processing/test_job_binaries.py
@@ -18,9 +18,9 @@
class JobBinaryTest(dp_base.BaseDataProcessingTest):
- """Link to the API documentation is http://docs.openstack.org/developer/
- sahara/restapi/rest_api_v1.1_EDP.html#job-binaries
- """
+ # Link to the API documentation is http://docs.openstack.org/developer/
+ # sahara/restapi/rest_api_v1.1_EDP.html#job-binaries
+
@classmethod
def resource_setup(cls):
super(JobBinaryTest, cls).resource_setup()
diff --git a/tempest/api/data_processing/test_job_binary_internals.py b/tempest/api/data_processing/test_job_binary_internals.py
index 6919fa5..b4f0769 100644
--- a/tempest/api/data_processing/test_job_binary_internals.py
+++ b/tempest/api/data_processing/test_job_binary_internals.py
@@ -18,9 +18,9 @@
class JobBinaryInternalTest(dp_base.BaseDataProcessingTest):
- """Link to the API documentation is http://docs.openstack.org/developer/
- sahara/restapi/rest_api_v1.1_EDP.html#job-binary-internals
- """
+ # Link to the API documentation is http://docs.openstack.org/developer/
+ # sahara/restapi/rest_api_v1.1_EDP.html#job-binary-internals
+
@classmethod
def resource_setup(cls):
super(JobBinaryInternalTest, cls).resource_setup()
diff --git a/tempest/api/data_processing/test_jobs.py b/tempest/api/data_processing/test_jobs.py
index 7798056..8503320 100644
--- a/tempest/api/data_processing/test_jobs.py
+++ b/tempest/api/data_processing/test_jobs.py
@@ -18,9 +18,9 @@
class JobTest(dp_base.BaseDataProcessingTest):
- """Link to the API documentation is http://docs.openstack.org/developer/
- sahara/restapi/rest_api_v1.1_EDP.html#jobs
- """
+ # NOTE: Link to the API documentation: http://docs.openstack.org/developer/
+ # sahara/restapi/rest_api_v1.1_EDP.html#jobs
+
@classmethod
def resource_setup(cls):
super(JobTest, cls).resource_setup()
diff --git a/tempest/api/identity/admin/v2/test_endpoints.py b/tempest/api/identity/admin/v2/test_endpoints.py
index 3af2e90..bff4f91 100644
--- a/tempest/api/identity/admin/v2/test_endpoints.py
+++ b/tempest/api/identity/admin/v2/test_endpoints.py
@@ -27,9 +27,8 @@
s_name = data_utils.rand_name('service')
s_type = data_utils.rand_name('type')
s_description = data_utils.rand_name('description')
- cls.service_data =\
- cls.client.create_service(s_name, s_type,
- description=s_description)
+ cls.service_data = cls.client.create_service(
+ s_name, s_type, description=s_description)['OS-KSADM:service']
cls.service_id = cls.service_data['id']
cls.service_ids.append(cls.service_id)
# Create endpoints so as to use for LIST and GET test cases
@@ -41,7 +40,7 @@
region,
publicurl=url,
adminurl=url,
- internalurl=url)
+ internalurl=url)['endpoint']
# list_endpoints() will return 'enabled' field
endpoint['enabled'] = True
cls.setup_endpoints.append(endpoint)
@@ -57,7 +56,7 @@
@test.idempotent_id('11f590eb-59d8-4067-8b2b-980c7f387f51')
def test_list_endpoints(self):
# Get a list of endpoints
- fetched_endpoints = self.client.list_endpoints()
+ fetched_endpoints = self.client.list_endpoints()['endpoints']
# Asserting LIST endpoints
missing_endpoints =\
[e for e in self.setup_endpoints if e not in fetched_endpoints]
@@ -73,18 +72,18 @@
region,
publicurl=url,
adminurl=url,
- internalurl=url)
+ internalurl=url)['endpoint']
# Asserting Create Endpoint response body
self.assertIn('id', endpoint)
self.assertEqual(region, endpoint['region'])
self.assertEqual(url, endpoint['publicurl'])
# Checking if created endpoint is present in the list of endpoints
- fetched_endpoints = self.client.list_endpoints()
+ fetched_endpoints = self.client.list_endpoints()['endpoints']
fetched_endpoints_id = [e['id'] for e in fetched_endpoints]
self.assertIn(endpoint['id'], fetched_endpoints_id)
# Deleting the endpoint created in this method
self.client.delete_endpoint(endpoint['id'])
# Checking whether endpoint is deleted successfully
- fetched_endpoints = self.client.list_endpoints()
+ fetched_endpoints = self.client.list_endpoints()['endpoints']
fetched_endpoints_id = [e['id'] for e in fetched_endpoints]
self.assertNotIn(endpoint['id'], fetched_endpoints_id)
diff --git a/tempest/api/identity/admin/v2/test_roles.py b/tempest/api/identity/admin/v2/test_roles.py
index 0b28a07..8702db7 100644
--- a/tempest/api/identity/admin/v2/test_roles.py
+++ b/tempest/api/identity/admin/v2/test_roles.py
@@ -27,7 +27,7 @@
super(RolesTestJSON, cls).resource_setup()
for _ in moves.xrange(5):
role_name = data_utils.rand_name(name='role')
- role = cls.client.create_role(role_name)
+ role = cls.client.create_role(role_name)['role']
cls.data.roles.append(role)
def _get_role_params(self):
@@ -48,7 +48,7 @@
@test.idempotent_id('75d9593f-50b7-4fcf-bd64-e3fb4a278e23')
def test_list_roles(self):
"""Return a list of all roles."""
- body = self.client.list_roles()
+ body = self.client.list_roles()['roles']
found = [role for role in body if role in self.data.roles]
self.assertTrue(any(found))
self.assertEqual(len(found), len(self.data.roles))
@@ -57,16 +57,16 @@
def test_role_create_delete(self):
"""Role should be created, verified, and deleted."""
role_name = data_utils.rand_name(name='role-test')
- body = self.client.create_role(role_name)
+ body = self.client.create_role(role_name)['role']
self.assertEqual(role_name, body['name'])
- body = self.client.list_roles()
+ body = self.client.list_roles()['roles']
found = [role for role in body if role['name'] == role_name]
self.assertTrue(any(found))
body = self.client.delete_role(found[0]['id'])
- body = self.client.list_roles()
+ body = self.client.list_roles()['roles']
found = [role for role in body if role['name'] == role_name]
self.assertFalse(any(found))
@@ -76,7 +76,7 @@
self.data.setup_test_role()
role_id = self.data.role['id']
role_name = self.data.role['name']
- body = self.client.get_role(role_id)['role']
+ body = self.client.show_role(role_id)['role']
self.assertEqual(role_id, body['id'])
self.assertEqual(role_name, body['name'])
@@ -85,7 +85,7 @@
"""Assign a role to a user on a tenant."""
(user, tenant, role) = self._get_role_params()
self.client.assign_user_role(tenant['id'], user['id'], role['id'])
- roles = self.client.list_user_roles(tenant['id'], user['id'])
+ roles = self.client.list_user_roles(tenant['id'], user['id'])['roles']
self.assert_role_in_role_list(role, roles)
@test.idempotent_id('f0b9292c-d3ba-4082-aa6c-440489beef69')
@@ -93,8 +93,9 @@
"""Remove a role assigned to a user on a tenant."""
(user, tenant, role) = self._get_role_params()
user_role = self.client.assign_user_role(tenant['id'],
- user['id'], role['id'])
- self.client.remove_user_role(tenant['id'], user['id'],
+ user['id'],
+ role['id'])['role']
+ self.client.delete_user_role(tenant['id'], user['id'],
user_role['id'])
@test.idempotent_id('262e1e3e-ed71-4edd-a0e5-d64e83d66d05')
@@ -102,5 +103,5 @@
"""List roles assigned to a user on tenant."""
(user, tenant, role) = self._get_role_params()
self.client.assign_user_role(tenant['id'], user['id'], role['id'])
- roles = self.client.list_user_roles(tenant['id'], user['id'])
+ roles = self.client.list_user_roles(tenant['id'], user['id'])['roles']
self.assert_role_in_role_list(role, roles)
diff --git a/tempest/api/identity/admin/v2/test_roles_negative.py b/tempest/api/identity/admin/v2/test_roles_negative.py
index b38b7dd..45c95df 100644
--- a/tempest/api/identity/admin/v2/test_roles_negative.py
+++ b/tempest/api/identity/admin/v2/test_roles_negative.py
@@ -78,7 +78,7 @@
def test_role_create_duplicate(self):
# Role names should be unique
role_name = data_utils.rand_name(name='role-dup')
- body = self.client.create_role(role_name)
+ body = self.client.create_role(role_name)['role']
role1_id = body.get('id')
self.addCleanup(self.client.delete_role, role1_id)
self.assertRaises(lib_exc.Conflict, self.client.create_role,
@@ -89,7 +89,7 @@
def test_delete_role_by_unauthorized_user(self):
# Non-administrator user should not be able to delete role
role_name = data_utils.rand_name(name='role')
- body = self.client.create_role(role_name)
+ body = self.client.create_role(role_name)['role']
self.data.roles.append(body)
role_id = body.get('id')
self.assertRaises(lib_exc.Forbidden,
@@ -100,7 +100,7 @@
def test_delete_role_request_without_token(self):
# Request to delete role without a valid token should fail
role_name = data_utils.rand_name(name='role')
- body = self.client.create_role(role_name)
+ body = self.client.create_role(role_name)['role']
self.data.roles.append(body)
role_id = body.get('id')
token = self.client.auth_provider.get_token()
@@ -177,7 +177,7 @@
user['id'],
role['id'])
self.assertRaises(lib_exc.Forbidden,
- self.non_admin_client.remove_user_role,
+ self.non_admin_client.delete_user_role,
tenant['id'], user['id'], role['id'])
@test.attr(type=['negative'])
@@ -191,7 +191,7 @@
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
self.assertRaises(lib_exc.Unauthorized,
- self.client.remove_user_role, tenant['id'],
+ self.client.delete_user_role, tenant['id'],
user['id'], role['id'])
self.client.auth_provider.clear_auth()
@@ -204,7 +204,7 @@
user['id'],
role['id'])
non_existent_role = str(uuid.uuid4().hex)
- self.assertRaises(lib_exc.NotFound, self.client.remove_user_role,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_user_role,
tenant['id'], user['id'], non_existent_role)
@test.attr(type=['negative'])
@@ -216,7 +216,7 @@
user['id'],
role['id'])
non_existent_tenant = str(uuid.uuid4().hex)
- self.assertRaises(lib_exc.NotFound, self.client.remove_user_role,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_user_role,
non_existent_tenant, user['id'], role['id'])
@test.attr(type=['negative'])
diff --git a/tempest/api/identity/admin/v2/test_services.py b/tempest/api/identity/admin/v2/test_services.py
index ef93981..04e15d2 100644
--- a/tempest/api/identity/admin/v2/test_services.py
+++ b/tempest/api/identity/admin/v2/test_services.py
@@ -27,7 +27,7 @@
# Deleting the service created in this method
self.client.delete_service(service_id)
# Checking whether service is deleted successfully
- self.assertRaises(lib_exc.NotFound, self.client.get_service,
+ self.assertRaises(lib_exc.NotFound, self.client.show_service,
service_id)
@test.idempotent_id('84521085-c6e6-491c-9a08-ec9f70f90110')
@@ -38,7 +38,7 @@
type = data_utils.rand_name('type')
description = data_utils.rand_name('description')
service_data = self.client.create_service(
- name, type, description=description)
+ name, type, description=description)['OS-KSADM:service']
self.assertFalse(service_data['id'] is None)
self.addCleanup(self._del_service, service_data['id'])
# Verifying response body of create service
@@ -50,7 +50,8 @@
self.assertIn('description', service_data)
self.assertEqual(description, service_data['description'])
# Get service
- fetched_service = self.client.get_service(service_data['id'])
+ fetched_service = (self.client.show_service(service_data['id'])
+ ['OS-KSADM:service'])
# verifying the existence of service created
self.assertIn('id', fetched_service)
self.assertEqual(fetched_service['id'], service_data['id'])
@@ -67,7 +68,7 @@
# Create a service only with name and type
name = data_utils.rand_name('service')
type = data_utils.rand_name('type')
- service = self.client.create_service(name, type)
+ service = self.client.create_service(name, type)['OS-KSADM:service']
self.assertIn('id', service)
self.addCleanup(self._del_service, service['id'])
self.assertIn('name', service)
@@ -85,7 +86,7 @@
type = data_utils.rand_name('type')
description = data_utils.rand_name('description')
service = self.client.create_service(
- name, type, description=description)
+ name, type, description=description)['OS-KSADM:service']
services.append(service)
service_ids = map(lambda x: x['id'], services)
@@ -95,6 +96,6 @@
self.addCleanup(delete_services)
# List and Verify Services
- body = self.client.list_services()
+ body = self.client.list_services()['OS-KSADM:services']
found = [serv for serv in body if serv['id'] in service_ids]
self.assertEqual(len(found), len(services), 'Services not found')
diff --git a/tempest/api/identity/admin/v2/test_tenant_negative.py b/tempest/api/identity/admin/v2/test_tenant_negative.py
index bccb5ca..74558d1 100644
--- a/tempest/api/identity/admin/v2/test_tenant_negative.py
+++ b/tempest/api/identity/admin/v2/test_tenant_negative.py
@@ -45,7 +45,7 @@
def test_tenant_delete_by_unauthorized_user(self):
# Non-administrator user should not be able to delete a tenant
tenant_name = data_utils.rand_name(name='tenant')
- tenant = self.client.create_tenant(tenant_name)
+ tenant = self.client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
self.assertRaises(lib_exc.Forbidden,
self.non_admin_client.delete_tenant, tenant['id'])
@@ -55,7 +55,7 @@
def test_tenant_delete_request_without_token(self):
# Request to delete a tenant without a valid token should fail
tenant_name = data_utils.rand_name(name='tenant')
- tenant = self.client.create_tenant(tenant_name)
+ tenant = self.client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
@@ -75,7 +75,7 @@
def test_tenant_create_duplicate(self):
# Tenant names should be unique
tenant_name = data_utils.rand_name(name='tenant')
- body = self.client.create_tenant(tenant_name)
+ body = self.client.create_tenant(tenant_name)['tenant']
tenant = body
self.data.tenants.append(tenant)
tenant1_id = body.get('id')
@@ -131,7 +131,7 @@
def test_tenant_update_by_unauthorized_user(self):
# Non-administrator user should not be able to update a tenant
tenant_name = data_utils.rand_name(name='tenant')
- tenant = self.client.create_tenant(tenant_name)
+ tenant = self.client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
self.assertRaises(lib_exc.Forbidden,
self.non_admin_client.update_tenant, tenant['id'])
@@ -141,7 +141,7 @@
def test_tenant_update_request_without_token(self):
# Request to update a tenant without a valid token should fail
tenant_name = data_utils.rand_name(name='tenant')
- tenant = self.client.create_tenant(tenant_name)
+ tenant = self.client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
diff --git a/tempest/api/identity/admin/v2/test_tenants.py b/tempest/api/identity/admin/v2/test_tenants.py
index 9fff5f3..4632b1e 100644
--- a/tempest/api/identity/admin/v2/test_tenants.py
+++ b/tempest/api/identity/admin/v2/test_tenants.py
@@ -28,7 +28,7 @@
tenants = []
for _ in moves.xrange(3):
tenant_name = data_utils.rand_name(name='tenant-new')
- tenant = self.client.create_tenant(tenant_name)
+ tenant = self.client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
tenants.append(tenant)
tenant_ids = map(lambda x: x['id'], tenants)
@@ -50,14 +50,14 @@
tenant_name = data_utils.rand_name(name='tenant')
tenant_desc = data_utils.rand_name(name='desc')
body = self.client.create_tenant(tenant_name,
- description=tenant_desc)
+ description=tenant_desc)['tenant']
tenant = body
self.data.tenants.append(tenant)
tenant_id = body['id']
desc1 = body['description']
self.assertEqual(desc1, tenant_desc, 'Description should have '
'been sent in response for create')
- body = self.client.get_tenant(tenant_id)
+ body = self.client.show_tenant(tenant_id)['tenant']
desc2 = body['description']
self.assertEqual(desc2, tenant_desc, 'Description does not appear'
'to be set')
@@ -68,13 +68,13 @@
def test_tenant_create_enabled(self):
# Create a tenant that is enabled
tenant_name = data_utils.rand_name(name='tenant')
- body = self.client.create_tenant(tenant_name, enabled=True)
+ body = self.client.create_tenant(tenant_name, enabled=True)['tenant']
tenant = body
self.data.tenants.append(tenant)
tenant_id = body['id']
en1 = body['enabled']
self.assertTrue(en1, 'Enable should be True in response')
- body = self.client.get_tenant(tenant_id)
+ body = self.client.show_tenant(tenant_id)['tenant']
en2 = body['enabled']
self.assertTrue(en2, 'Enable should be True in lookup')
self.client.delete_tenant(tenant_id)
@@ -84,14 +84,14 @@
def test_tenant_create_not_enabled(self):
# Create a tenant that is not enabled
tenant_name = data_utils.rand_name(name='tenant')
- body = self.client.create_tenant(tenant_name, enabled=False)
+ body = self.client.create_tenant(tenant_name, enabled=False)['tenant']
tenant = body
self.data.tenants.append(tenant)
tenant_id = body['id']
en1 = body['enabled']
self.assertEqual('false', str(en1).lower(),
'Enable should be False in response')
- body = self.client.get_tenant(tenant_id)
+ body = self.client.show_tenant(tenant_id)['tenant']
en2 = body['enabled']
self.assertEqual('false', str(en2).lower(),
'Enable should be False in lookup')
@@ -102,7 +102,7 @@
def test_tenant_update_name(self):
# Update name attribute of a tenant
t_name1 = data_utils.rand_name(name='tenant')
- body = self.client.create_tenant(t_name1)
+ body = self.client.create_tenant(t_name1)['tenant']
tenant = body
self.data.tenants.append(tenant)
@@ -110,11 +110,11 @@
resp1_name = body['name']
t_name2 = data_utils.rand_name(name='tenant2')
- body = self.client.update_tenant(t_id, name=t_name2)
+ body = self.client.update_tenant(t_id, name=t_name2)['tenant']
resp2_name = body['name']
self.assertNotEqual(resp1_name, resp2_name)
- body = self.client.get_tenant(t_id)
+ body = self.client.show_tenant(t_id)['tenant']
resp3_name = body['name']
self.assertNotEqual(resp1_name, resp3_name)
@@ -129,7 +129,7 @@
# Update description attribute of a tenant
t_name = data_utils.rand_name(name='tenant')
t_desc = data_utils.rand_name(name='desc')
- body = self.client.create_tenant(t_name, description=t_desc)
+ body = self.client.create_tenant(t_name, description=t_desc)['tenant']
tenant = body
self.data.tenants.append(tenant)
@@ -137,11 +137,11 @@
resp1_desc = body['description']
t_desc2 = data_utils.rand_name(name='desc2')
- body = self.client.update_tenant(t_id, description=t_desc2)
+ body = self.client.update_tenant(t_id, description=t_desc2)['tenant']
resp2_desc = body['description']
self.assertNotEqual(resp1_desc, resp2_desc)
- body = self.client.get_tenant(t_id)
+ body = self.client.show_tenant(t_id)['tenant']
resp3_desc = body['description']
self.assertNotEqual(resp1_desc, resp3_desc)
@@ -156,7 +156,7 @@
# Update the enabled attribute of a tenant
t_name = data_utils.rand_name(name='tenant')
t_en = False
- body = self.client.create_tenant(t_name, enabled=t_en)
+ body = self.client.create_tenant(t_name, enabled=t_en)['tenant']
tenant = body
self.data.tenants.append(tenant)
@@ -164,11 +164,11 @@
resp1_en = body['enabled']
t_en2 = True
- body = self.client.update_tenant(t_id, enabled=t_en2)
+ body = self.client.update_tenant(t_id, enabled=t_en2)['tenant']
resp2_en = body['enabled']
self.assertNotEqual(resp1_en, resp2_en)
- body = self.client.get_tenant(t_id)
+ body = self.client.show_tenant(t_id)['tenant']
resp3_en = body['enabled']
self.assertNotEqual(resp1_en, resp3_en)
diff --git a/tempest/api/identity/admin/v2/test_tokens.py b/tempest/api/identity/admin/v2/test_tokens.py
index 66d00d1..0e7a480 100644
--- a/tempest/api/identity/admin/v2/test_tokens.py
+++ b/tempest/api/identity/admin/v2/test_tokens.py
@@ -27,11 +27,11 @@
user_password = data_utils.rand_name(name='pass')
# first:create a tenant
tenant_name = data_utils.rand_name(name='tenant')
- tenant = self.client.create_tenant(tenant_name)
+ tenant = self.client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
# second:create a user
user = self.client.create_user(user_name, user_password,
- tenant['id'], '')
+ tenant['id'], '')['user']
self.data.users.append(user)
# then get a token for the user
body = self.token_client.auth(user_name,
@@ -41,7 +41,7 @@
tenant['name'])
# Perform GET Token
token_id = body['token']['id']
- token_details = self.client.get_token(token_id)
+ token_details = self.client.show_token(token_id)['access']
self.assertEqual(token_id, token_details['token']['id'])
self.assertEqual(user['id'], token_details['user']['id'])
self.assertEqual(user_name, token_details['user']['name'])
@@ -52,8 +52,9 @@
@test.idempotent_id('25ba82ee-8a32-4ceb-8f50-8b8c71e8765e')
def test_rescope_token(self):
- """An unscoped token can be requested, that token can be used to
- request a scoped token.
+ """An unscoped token can be requested
+
+ That token can be used to request a scoped token.
"""
# Create a user.
@@ -62,21 +63,21 @@
tenant_id = None # No default tenant so will get unscoped token.
email = ''
user = self.client.create_user(user_name, user_password,
- tenant_id, email)
+ tenant_id, email)['user']
self.data.users.append(user)
# Create a couple tenants.
tenant1_name = data_utils.rand_name(name='tenant')
- tenant1 = self.client.create_tenant(tenant1_name)
+ tenant1 = self.client.create_tenant(tenant1_name)['tenant']
self.data.tenants.append(tenant1)
tenant2_name = data_utils.rand_name(name='tenant')
- tenant2 = self.client.create_tenant(tenant2_name)
+ tenant2 = self.client.create_tenant(tenant2_name)['tenant']
self.data.tenants.append(tenant2)
# Create a role
role_name = data_utils.rand_name(name='role')
- role = self.client.create_role(role_name)
+ role = self.client.create_role(role_name)['role']
self.data.roles.append(role)
# Grant the user the role on the tenants.
diff --git a/tempest/api/identity/admin/v2/test_users.py b/tempest/api/identity/admin/v2/test_users.py
index bfbcfe7..6341106 100644
--- a/tempest/api/identity/admin/v2/test_users.py
+++ b/tempest/api/identity/admin/v2/test_users.py
@@ -36,7 +36,7 @@
self.data.setup_test_tenant()
user = self.client.create_user(self.alt_user, self.alt_password,
self.data.tenant['id'],
- self.alt_email)
+ self.alt_email)['user']
self.data.users.append(user)
self.assertEqual(self.alt_user, user['name'])
@@ -47,7 +47,7 @@
name = data_utils.rand_name('test_user')
user = self.client.create_user(name, self.alt_password,
self.data.tenant['id'],
- self.alt_email, enabled=False)
+ self.alt_email, enabled=False)['user']
self.data.users.append(user)
self.assertEqual(name, user['name'])
self.assertEqual(False, user['enabled'])
@@ -60,7 +60,7 @@
self.data.setup_test_tenant()
user = self.client.create_user(test_user, self.alt_password,
self.data.tenant['id'],
- self.alt_email)
+ self.alt_email)['user']
# Delete the User at the end of this method
self.addCleanup(self.client.delete_user, user['id'])
# Updating user details with new values
@@ -68,12 +68,12 @@
u_email2 = u_name2 + '@testmail.tm'
update_user = self.client.update_user(user['id'], name=u_name2,
email=u_email2,
- enabled=False)
+ enabled=False)['user']
self.assertEqual(u_name2, update_user['name'])
self.assertEqual(u_email2, update_user['email'])
self.assertEqual(False, update_user['enabled'])
# GET by id after updating
- updated_user = self.client.get_user(user['id'])
+ updated_user = self.client.show_user(user['id'])['user']
# Assert response body of GET after updating
self.assertEqual(u_name2, updated_user['name'])
self.assertEqual(u_email2, updated_user['email'])
@@ -86,7 +86,7 @@
self.data.setup_test_tenant()
user = self.client.create_user(test_user, self.alt_password,
self.data.tenant['id'],
- self.alt_email)
+ self.alt_email)['user']
self.client.delete_user(user['id'])
@test.idempotent_id('aca696c3-d645-4f45-b728-63646045beb1')
@@ -121,7 +121,7 @@
def test_get_users(self):
# Get a list of users and find the test user
self.data.setup_test_user()
- users = self.client.get_users()
+ users = self.client.list_users()['users']
self.assertThat([u['name'] for u in users],
matchers.Contains(self.data.test_user),
"Could not find %s" % self.data.test_user)
@@ -135,18 +135,19 @@
alt_tenant_user1 = data_utils.rand_name('tenant_user1')
user1 = self.client.create_user(alt_tenant_user1, 'password1',
self.data.tenant['id'],
- 'user1@123')
+ 'user1@123')['user']
user_ids.append(user1['id'])
self.data.users.append(user1)
alt_tenant_user2 = data_utils.rand_name('tenant_user2')
user2 = self.client.create_user(alt_tenant_user2, 'password2',
self.data.tenant['id'],
- 'user2@123')
+ 'user2@123')['user']
user_ids.append(user2['id'])
self.data.users.append(user2)
# List of users for the respective tenant ID
- body = self.client.list_users_for_tenant(self.data.tenant['id'])
+ body = (self.client.list_tenant_users(self.data.tenant['id'])
+ ['users'])
for i in body:
fetched_user_ids.append(i['id'])
# verifying the user Id in the list
@@ -169,19 +170,20 @@
fetched_user_ids = list()
user_ids.append(user['id'])
role = self.client.assign_user_role(tenant['id'], user['id'],
- role['id'])
+ role['id'])['role']
alt_user2 = data_utils.rand_name('second_user')
second_user = self.client.create_user(alt_user2, 'password1',
self.data.tenant['id'],
- 'user2@123')
+ 'user2@123')['user']
user_ids.append(second_user['id'])
self.data.users.append(second_user)
role = self.client.assign_user_role(tenant['id'],
second_user['id'],
- role['id'])
+ role['id'])['role']
# List of users with roles for the respective tenant ID
- body = self.client.list_users_for_tenant(self.data.tenant['id'])
+ body = (self.client.list_tenant_users(self.data.tenant['id'])
+ ['users'])
for i in body:
fetched_user_ids.append(i['id'])
# verifying the user Id in the list
@@ -198,7 +200,7 @@
# Updating the user with new password
new_pass = data_utils.rand_name('pass')
update_user = self.client.update_user_password(
- self.data.user['id'], new_pass)
+ self.data.user['id'], new_pass)['user']
self.assertEqual(update_user['id'], self.data.user['id'])
# Validate the updated password
diff --git a/tempest/api/identity/admin/v2/test_users_negative.py b/tempest/api/identity/admin/v2/test_users_negative.py
index 85f7411..a88053d 100644
--- a/tempest/api/identity/admin/v2/test_users_negative.py
+++ b/tempest/api/identity/admin/v2/test_users_negative.py
@@ -222,7 +222,7 @@
# Non-administrator user should not be authorized to get user list
self.data.setup_test_user()
self.assertRaises(lib_exc.Forbidden,
- self.non_admin_client.get_users)
+ self.non_admin_client.list_users)
@test.attr(type=['negative'])
@test.idempotent_id('a73591ec-1903-4ffe-be42-282b39fefc9d')
@@ -230,7 +230,7 @@
# Request to get list of users without a valid token should fail
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
- self.assertRaises(lib_exc.Unauthorized, self.client.get_users)
+ self.assertRaises(lib_exc.Unauthorized, self.client.list_users)
self.client.auth_provider.clear_auth()
@test.attr(type=['negative'])
@@ -247,4 +247,4 @@
# List the users with invalid tenant id
for invalid in invalid_id:
self.assertRaises(lib_exc.NotFound,
- self.client.list_users_for_tenant, invalid)
+ self.client.list_tenant_users, invalid)
diff --git a/tempest/api/identity/admin/v3/test_credentials.py b/tempest/api/identity/admin/v3/test_credentials.py
index d22b27f..048c53a 100644
--- a/tempest/api/identity/admin/v3/test_credentials.py
+++ b/tempest/api/identity/admin/v3/test_credentials.py
@@ -53,11 +53,11 @@
@test.attr(type='smoke')
@test.idempotent_id('7cd59bf9-bda4-4c72-9467-d21cab278355')
def test_credentials_create_get_update_delete(self):
- keys = [data_utils.rand_name('Access'),
- data_utils.rand_name('Secret')]
+ blob = '{"access": "%s", "secret": "%s"}' % (
+ data_utils.rand_name('Access'), data_utils.rand_name('Secret'))
cred = self.creds_client.create_credential(
- keys[0], keys[1], self.user_body['id'],
- self.projects[0])['credential']
+ user_id=self.user_body['id'], project_id=self.projects[0],
+ blob=blob, type='ec2')['credential']
self.addCleanup(self._delete_credential, cred['id'])
for value1 in self.creds_list[0]:
self.assertIn(value1, cred)
@@ -66,9 +66,10 @@
new_keys = [data_utils.rand_name('NewAccess'),
data_utils.rand_name('NewSecret')]
+ blob = '{"access": "%s", "secret": "%s"}' % (new_keys[0], new_keys[1])
update_body = self.creds_client.update_credential(
- cred['id'], access_key=new_keys[0], secret_key=new_keys[1],
- project_id=self.projects[1])['credential']
+ cred['id'], blob=blob, project_id=self.projects[1],
+ type='ec2')['credential']
self.assertEqual(cred['id'], update_body['id'])
self.assertEqual(self.projects[1], update_body['project_id'])
self.assertEqual(self.user_body['id'], update_body['user_id'])
@@ -89,10 +90,11 @@
fetched_cred_ids = list()
for i in range(2):
+ blob = '{"access": "%s", "secret": "%s"}' % (
+ data_utils.rand_name('Access'), data_utils.rand_name('Secret'))
cred = self.creds_client.create_credential(
- data_utils.rand_name('Access'),
- data_utils.rand_name('Secret'),
- self.user_body['id'], self.projects[0])['credential']
+ user_id=self.user_body['id'], project_id=self.projects[0],
+ blob=blob, type='ec2')['credential']
created_cred_ids.append(cred['id'])
self.addCleanup(self._delete_credential, cred['id'])
diff --git a/tempest/api/identity/admin/v3/test_default_project_id.py b/tempest/api/identity/admin/v3/test_default_project_id.py
index 4c69758..53861ca 100644
--- a/tempest/api/identity/admin/v3/test_default_project_id.py
+++ b/tempest/api/identity/admin/v3/test_default_project_id.py
@@ -83,6 +83,6 @@
# verify the user's token and see that it is scoped to the project
token, auth_data = admin_client.auth_provider.get_auth()
- result = admin_client.identity_v3_client.get_token(token)['token']
+ result = admin_client.identity_v3_client.show_token(token)['token']
self.assertEqual(result['project']['domain']['id'], dom_id)
self.assertEqual(result['project']['id'], proj_id)
diff --git a/tempest/api/identity/admin/v3/test_domains.py b/tempest/api/identity/admin/v3/test_domains.py
index 742d737..15bea28 100644
--- a/tempest/api/identity/admin/v3/test_domains.py
+++ b/tempest/api/identity/admin/v3/test_domains.py
@@ -28,6 +28,11 @@
# or else it would result in unauthorized error
self.client.update_domain(domain_id, enabled=False)
self.client.delete_domain(domain_id)
+ # Asserting that the domain is not found in the list
+ # after deletion
+ body = self.client.list_domains()['domains']
+ domains_list = [d['id'] for d in body]
+ self.assertNotIn(domain_id, domains_list)
@test.idempotent_id('8cf516ef-2114-48f1-907b-d32726c734d4')
def test_list_domains(self):
diff --git a/tempest/api/identity/admin/v3/test_domains_negative.py b/tempest/api/identity/admin/v3/test_domains_negative.py
index 156179c..9eb3149 100644
--- a/tempest/api/identity/admin/v3/test_domains_negative.py
+++ b/tempest/api/identity/admin/v3/test_domains_negative.py
@@ -37,3 +37,36 @@
# domain need to be disabled before deleting
self.assertRaises(lib_exc.Forbidden, self.client.delete_domain,
domain_id)
+
+ @test.attr(type=['negative'])
+ @test.idempotent_id('9018461d-7d24-408d-b3fe-ae37e8cd5c9e')
+ def test_create_domain_with_empty_name(self):
+ # Domain name should not be empty
+ self.assertRaises(lib_exc.BadRequest, self.client.create_domain,
+ name='')
+
+ @test.attr(type=['negative'])
+ @test.idempotent_id('37b1bbf2-d664-4785-9a11-333438586eae')
+ def test_create_domain_with_name_length_over_64(self):
+ # Domain name length should not ne greater than 64 characters
+ d_name = 'a' * 65
+ self.assertRaises(lib_exc.BadRequest, self.client.create_domain,
+ d_name)
+
+ @test.attr(type=['negative'])
+ @test.idempotent_id('43781c07-764f-4cf2-a405-953c1916f605')
+ def test_delete_non_existent_domain(self):
+ # Attempt to delete a non existent domain should fail
+ self.assertRaises(lib_exc.NotFound, self.client.delete_domain,
+ data_utils.rand_uuid_hex())
+
+ @test.attr(type=['negative'])
+ @test.idempotent_id('e6f9e4a2-4f36-4be8-bdbc-4e199ae29427')
+ def test_domain_create_duplicate(self):
+ domain_name = data_utils.rand_name('domain-dup')
+ domain = self.client.create_domain(domain_name)['domain']
+ domain_id = domain['id']
+ self.addCleanup(self.delete_domain, domain_id)
+ # Domain name should be unique
+ self.assertRaises(
+ lib_exc.Conflict, self.client.create_domain, domain_name)
diff --git a/tempest/api/identity/admin/v3/test_endpoints.py b/tempest/api/identity/admin/v3/test_endpoints.py
index e44a96b..429e2e3 100644
--- a/tempest/api/identity/admin/v3/test_endpoints.py
+++ b/tempest/api/identity/admin/v3/test_endpoints.py
@@ -33,9 +33,9 @@
s_name = data_utils.rand_name('service')
s_type = data_utils.rand_name('type')
s_description = data_utils.rand_name('description')
- cls.service_data =\
- cls.service_client.create_service(s_name, s_type,
- description=s_description)
+ cls.service_data = (
+ cls.service_client.create_service(name=s_name, type=s_type,
+ description=s_description))
cls.service_data = cls.service_data['service']
cls.service_id = cls.service_data['id']
cls.service_ids.append(cls.service_id)
@@ -45,8 +45,10 @@
region = data_utils.rand_name('region')
url = data_utils.rand_url()
interface = 'public'
- endpoint = (cls.client.create_endpoint(cls.service_id, interface,
- url, region=region, enabled=True))['endpoint']
+ endpoint = cls.client.create_endpoint(service_id=cls.service_id,
+ interface=interface,
+ url=url, region=region,
+ enabled=True)['endpoint']
cls.setup_endpoints.append(endpoint)
@classmethod
@@ -73,8 +75,10 @@
region = data_utils.rand_name('region')
url = data_utils.rand_url()
interface = 'public'
- endpoint = (self.client.create_endpoint(self.service_id, interface,
- url, region=region, enabled=True)['endpoint'])
+ endpoint = self.client.create_endpoint(service_id=self.service_id,
+ interface=interface,
+ url=url, region=region,
+ enabled=True)['endpoint']
# Asserting Create Endpoint response body
self.assertIn('id', endpoint)
self.assertEqual(region, endpoint['region'])
@@ -98,30 +102,30 @@
region1 = data_utils.rand_name('region')
url1 = data_utils.rand_url()
interface1 = 'public'
- endpoint_for_update =\
- self.client.create_endpoint(self.service_id, interface1,
- url1, region=region1,
- enabled=True)['endpoint']
+ endpoint_for_update = (
+ self.client.create_endpoint(service_id=self.service_id,
+ interface=interface1,
+ url=url1, region=region1,
+ enabled=True)['endpoint'])
self.addCleanup(self.client.delete_endpoint, endpoint_for_update['id'])
# Creating service so as update endpoint with new service ID
s_name = data_utils.rand_name('service')
s_type = data_utils.rand_name('type')
s_description = data_utils.rand_name('description')
- service2 =\
- self.service_client.create_service(s_name, s_type,
- description=s_description)
+ service2 = (
+ self.service_client.create_service(name=s_name, type=s_type,
+ description=s_description))
service2 = service2['service']
self.service_ids.append(service2['id'])
# Updating endpoint with new values
region2 = data_utils.rand_name('region')
url2 = data_utils.rand_url()
interface2 = 'internal'
- endpoint = \
- self.client.update_endpoint(endpoint_for_update['id'],
- service_id=service2['id'],
- interface=interface2, url=url2,
- region=region2,
- enabled=False)['endpoint']
+ endpoint = self.client.update_endpoint(endpoint_for_update['id'],
+ service_id=service2['id'],
+ interface=interface2,
+ url=url2, region=region2,
+ enabled=False)['endpoint']
# Asserting if the attributes of endpoint are updated
self.assertEqual(service2['id'], endpoint['service_id'])
self.assertEqual(interface2, endpoint['interface'])
diff --git a/tempest/api/identity/admin/v3/test_endpoints_negative.py b/tempest/api/identity/admin/v3/test_endpoints_negative.py
index 8cf853b..8f9bf2a 100644
--- a/tempest/api/identity/admin/v3/test_endpoints_negative.py
+++ b/tempest/api/identity/admin/v3/test_endpoints_negative.py
@@ -37,7 +37,7 @@
s_type = data_utils.rand_name('type')
s_description = data_utils.rand_name('description')
cls.service_data = (
- cls.service_client.create_service(s_name, s_type,
+ cls.service_client.create_service(name=s_name, type=s_type,
description=s_description)
['service'])
cls.service_id = cls.service_data['id']
@@ -57,8 +57,8 @@
url = data_utils.rand_url()
region = data_utils.rand_name('region')
self.assertRaises(lib_exc.BadRequest, self.client.create_endpoint,
- self.service_id, interface, url, region=region,
- force_enabled='False')
+ service_id=self.service_id, interface=interface,
+ url=url, region=region, enabled='False')
@test.attr(type=['negative'])
@test.idempotent_id('9c43181e-0627-484a-8c79-923e8a59598b')
@@ -68,8 +68,8 @@
url = data_utils.rand_url()
region = data_utils.rand_name('region')
self.assertRaises(lib_exc.BadRequest, self.client.create_endpoint,
- self.service_id, interface, url, region=region,
- force_enabled='True')
+ service_id=self.service_id, interface=interface,
+ url=url, region=region, enabled='True')
def _assert_update_raises_bad_request(self, enabled):
@@ -78,13 +78,14 @@
url1 = data_utils.rand_url()
interface1 = 'public'
endpoint_for_update = (
- self.client.create_endpoint(self.service_id, interface1,
- url1, region=region1,
- enabled=True))['endpoint']
+ self.client.create_endpoint(service_id=self.service_id,
+ interface=interface1,
+ url=url1, region=region1,
+ enabled=True)['endpoint'])
self.addCleanup(self.client.delete_endpoint, endpoint_for_update['id'])
self.assertRaises(lib_exc.BadRequest, self.client.update_endpoint,
- endpoint_for_update['id'], force_enabled=enabled)
+ endpoint_for_update['id'], enabled=enabled)
@test.attr(type=['negative'])
@test.idempotent_id('65e41f32-5eb7-498f-a92a-a6ccacf7439a')
diff --git a/tempest/api/identity/admin/v3/test_groups.py b/tempest/api/identity/admin/v3/test_groups.py
index 5ce6354..d5af4b4 100644
--- a/tempest/api/identity/admin/v3/test_groups.py
+++ b/tempest/api/identity/admin/v3/test_groups.py
@@ -24,21 +24,20 @@
def test_group_create_update_get(self):
name = data_utils.rand_name('Group')
description = data_utils.rand_name('Description')
- group = self.client.create_group(name,
- description=description)['group']
- self.addCleanup(self.client.delete_group, group['id'])
+ group = self.groups_client.create_group(
+ name, description=description)['group']
+ self.addCleanup(self.groups_client.delete_group, group['id'])
self.assertEqual(group['name'], name)
self.assertEqual(group['description'], description)
new_name = data_utils.rand_name('UpdateGroup')
new_desc = data_utils.rand_name('UpdateDescription')
- updated_group = self.client.update_group(group['id'],
- name=new_name,
- description=new_desc)['group']
+ updated_group = self.groups_client.update_group(
+ group['id'], name=new_name, description=new_desc)['group']
self.assertEqual(updated_group['name'], new_name)
self.assertEqual(updated_group['description'], new_desc)
- new_group = self.client.get_group(group['id'])['group']
+ new_group = self.groups_client.get_group(group['id'])['group']
self.assertEqual(group['id'], new_group['id'])
self.assertEqual(new_name, new_group['name'])
self.assertEqual(new_desc, new_group['description'])
@@ -47,8 +46,8 @@
@test.idempotent_id('1598521a-2f36-4606-8df9-30772bd51339')
def test_group_users_add_list_delete(self):
name = data_utils.rand_name('Group')
- group = self.client.create_group(name)['group']
- self.addCleanup(self.client.delete_group, group['id'])
+ group = self.groups_client.create_group(name)['group']
+ self.addCleanup(self.groups_client.delete_group, group['id'])
# add user into group
users = []
for i in range(3):
@@ -56,16 +55,15 @@
user = self.client.create_user(name)['user']
users.append(user)
self.addCleanup(self.client.delete_user, user['id'])
- self.client.add_group_user(group['id'], user['id'])
+ self.groups_client.add_group_user(group['id'], user['id'])
# list users in group
- group_users = self.client.list_group_users(group['id'])['users']
+ group_users = self.groups_client.list_group_users(group['id'])['users']
self.assertEqual(sorted(users), sorted(group_users))
# delete user in group
for user in users:
- self.client.delete_group_user(group['id'],
- user['id'])
- group_users = self.client.list_group_users(group['id'])['users']
+ self.groups_client.delete_group_user(group['id'], user['id'])
+ group_users = self.groups_client.list_group_users(group['id'])['users']
self.assertEqual(len(group_users), 0)
@test.idempotent_id('64573281-d26a-4a52-b899-503cb0f4e4ec')
@@ -79,10 +77,10 @@
groups = []
for i in range(2):
name = data_utils.rand_name('Group')
- group = self.client.create_group(name)['group']
+ group = self.groups_client.create_group(name)['group']
groups.append(group)
- self.addCleanup(self.client.delete_group, group['id'])
- self.client.add_group_user(group['id'], user['id'])
+ self.addCleanup(self.groups_client.delete_group, group['id'])
+ self.groups_client.add_group_user(group['id'], user['id'])
# list groups which user belongs to
user_groups = self.client.list_user_groups(user['id'])['groups']
self.assertEqual(sorted(groups), sorted(user_groups))
@@ -96,12 +94,12 @@
for _ in range(3):
name = data_utils.rand_name('Group')
description = data_utils.rand_name('Description')
- group = self.client.create_group(name,
- description=description)['group']
- self.addCleanup(self.client.delete_group, group['id'])
+ group = self.groups_client.create_group(
+ name, description=description)['group']
+ self.addCleanup(self.groups_client.delete_group, group['id'])
group_ids.append(group['id'])
# List and Verify Groups
- body = self.client.list_groups()['groups']
+ body = self.groups_client.list_groups()['groups']
for g in body:
fetched_ids.append(g['id'])
missing_groups = [g for g in group_ids if g not in fetched_ids]
diff --git a/tempest/api/identity/admin/v3/test_list_users.py b/tempest/api/identity/admin/v3/test_list_users.py
index 320b479..b7f37d4 100644
--- a/tempest/api/identity/admin/v3/test_list_users.py
+++ b/tempest/api/identity/admin/v3/test_list_users.py
@@ -25,7 +25,7 @@
# assert the response based on expected and not_expected
# expected: user expected in the list response
# not_expected: user, which should not be present in list response
- body = self.client.get_users(params)['users']
+ body = self.client.list_users(params)['users']
self.assertIn(expected[key], map(lambda x: x[key], body))
self.assertNotIn(not_expected[key],
map(lambda x: x[key], body))
@@ -77,7 +77,7 @@
@test.idempotent_id('b30d4651-a2ea-4666-8551-0c0e49692635')
def test_list_users(self):
# List users
- body = self.client.get_users()['users']
+ body = self.client.list_users()['users']
fetched_ids = [u['id'] for u in body]
missing_users = [u['id'] for u in self.data.v3_users
if u['id'] not in fetched_ids]
@@ -88,7 +88,7 @@
@test.idempotent_id('b4baa3ae-ac00-4b4e-9e27-80deaad7771f')
def test_get_user(self):
# Get a user detail
- user = self.client.get_user(self.data.v3_users[0]['id'])['user']
+ user = self.client.show_user(self.data.v3_users[0]['id'])['user']
self.assertEqual(self.data.v3_users[0]['id'], user['id'])
self.assertEqual(self.data.v3_users[0]['name'], user['name'])
self.assertEqual(self.alt_email, user['email'])
diff --git a/tempest/api/identity/admin/v3/test_policies.py b/tempest/api/identity/admin/v3/test_policies.py
index d079fec..44e5c7b 100644
--- a/tempest/api/identity/admin/v3/test_policies.py
+++ b/tempest/api/identity/admin/v3/test_policies.py
@@ -31,8 +31,8 @@
for _ in range(3):
blob = data_utils.rand_name('BlobName')
policy_type = data_utils.rand_name('PolicyType')
- policy = self.policy_client.create_policy(blob,
- policy_type)['policy']
+ policy = self.policy_client.create_policy(
+ blob=blob, type=policy_type)['policy']
# Delete the Policy at the end of this method
self.addCleanup(self._delete_policy, policy['id'])
policy_ids.append(policy['id'])
@@ -49,7 +49,8 @@
# Test to update policy
blob = data_utils.rand_name('BlobName')
policy_type = data_utils.rand_name('PolicyType')
- policy = self.policy_client.create_policy(blob, policy_type)['policy']
+ policy = self.policy_client.create_policy(blob=blob,
+ type=policy_type)['policy']
self.addCleanup(self._delete_policy, policy['id'])
self.assertIn('id', policy)
self.assertIn('type', policy)
diff --git a/tempest/api/identity/admin/v3/test_projects.py b/tempest/api/identity/admin/v3/test_projects.py
index f014307..d39fd5f 100644
--- a/tempest/api/identity/admin/v3/test_projects.py
+++ b/tempest/api/identity/admin/v3/test_projects.py
@@ -169,7 +169,7 @@
self.addCleanup(self.client.delete_user, user['id'])
# Get User To validate the user details
- new_user_get = self.client.get_user(user['id'])['user']
+ new_user_get = self.client.show_user(user['id'])['user']
# Assert response body of GET
self.assertEqual(u_name, new_user_get['name'])
self.assertEqual(u_desc, new_user_get['description'])
diff --git a/tempest/api/identity/admin/v3/test_regions.py b/tempest/api/identity/admin/v3/test_regions.py
index e96e0f5..0dbbae0 100644
--- a/tempest/api/identity/admin/v3/test_regions.py
+++ b/tempest/api/identity/admin/v3/test_regions.py
@@ -33,7 +33,8 @@
cls.setup_regions = list()
for i in range(2):
r_description = data_utils.rand_name('description')
- region = cls.client.create_region(r_description)['region']
+ region = cls.client.create_region(
+ description=r_description)['region']
cls.setup_regions.append(region)
@classmethod
@@ -51,7 +52,7 @@
def test_create_update_get_delete_region(self):
r_description = data_utils.rand_name('description')
region = self.client.create_region(
- r_description,
+ description=r_description,
parent_region_id=self.setup_regions[0]['id'])['region']
self.addCleanup(self._delete_region, region['id'])
self.assertEqual(r_description, region['description'])
@@ -79,7 +80,7 @@
r_region_id = data_utils.rand_uuid()
r_description = data_utils.rand_name('description')
region = self.client.create_region(
- r_description, unique_region_id=r_region_id)['region']
+ region_id=r_region_id, description=r_description)['region']
self.addCleanup(self._delete_region, region['id'])
# Asserting Create Region with specific id response body
self.assertEqual(r_region_id, region['id'])
diff --git a/tempest/api/identity/admin/v3/test_roles.py b/tempest/api/identity/admin/v3/test_roles.py
index ffc991a..d5350a1 100644
--- a/tempest/api/identity/admin/v3/test_roles.py
+++ b/tempest/api/identity/admin/v3/test_roles.py
@@ -39,7 +39,7 @@
data_utils.rand_name('project'),
description=data_utils.rand_name('project-desc'),
domain_id=cls.domain['id'])['project']
- cls.group_body = cls.client.create_group(
+ cls.group_body = cls.groups_client.create_group(
data_utils.rand_name('Group'), project_id=cls.project['id'],
domain_id=cls.domain['id'])['group']
cls.user_body = cls.client.create_user(
@@ -52,7 +52,7 @@
@classmethod
def resource_cleanup(cls):
cls.client.delete_role(cls.role['id'])
- cls.client.delete_group(cls.group_body['id'])
+ cls.groups_client.delete_group(cls.group_body['id'])
cls.client.delete_user(cls.user_body['id'])
cls.client.delete_project(cls.project['id'])
# NOTE(harika-vakadi): It is necessary to disable the domain
@@ -81,7 +81,7 @@
self.assertIn('links', updated_role)
self.assertNotEqual(r_name, updated_role['name'])
- new_role = self.client.get_role(role['id'])['role']
+ new_role = self.client.show_role(role['id'])['role']
self.assertEqual(new_name, new_role['name'])
self.assertEqual(updated_role['id'], new_role['id'])
@@ -102,7 +102,7 @@
self._list_assertions(roles, self.fetched_role_ids,
self.role['id'])
- self.client.revoke_role_from_user_on_project(
+ self.client.delete_role_from_user_on_project(
self.project['id'], self.user_body['id'], self.role['id'])
@test.idempotent_id('6c9a2940-3625-43a3-ac02-5dcec62ef3bd')
@@ -119,7 +119,7 @@
self._list_assertions(roles, self.fetched_role_ids,
self.role['id'])
- self.client.revoke_role_from_user_on_domain(
+ self.client.delete_role_from_user_on_domain(
self.domain['id'], self.user_body['id'], self.role['id'])
@test.idempotent_id('cbf11737-1904-4690-9613-97bcbb3df1c4')
@@ -137,8 +137,9 @@
self._list_assertions(roles, self.fetched_role_ids,
self.role['id'])
# Add user to group, and insure user has role on project
- self.client.add_group_user(self.group_body['id'], self.user_body['id'])
- self.addCleanup(self.client.delete_group_user,
+ self.groups_client.add_group_user(self.group_body['id'],
+ self.user_body['id'])
+ self.addCleanup(self.groups_client.delete_group_user,
self.group_body['id'], self.user_body['id'])
body = self.token.auth(user_id=self.user_body['id'],
password=self.u_password,
@@ -149,7 +150,7 @@
self.assertEqual(len(roles), 1)
self.assertEqual(roles[0]['id'], self.role['id'])
# Revoke role to group on project
- self.client.revoke_role_from_group_on_project(
+ self.client.delete_role_from_group_on_project(
self.project['id'], self.group_body['id'], self.role['id'])
@test.idempotent_id('4bf8a70b-e785-413a-ad53-9f91ce02faa7')
@@ -166,7 +167,7 @@
self._list_assertions(roles, self.fetched_role_ids,
self.role['id'])
- self.client.revoke_role_from_group_on_domain(
+ self.client.delete_role_from_group_on_domain(
self.domain['id'], self.group_body['id'], self.role['id'])
@test.idempotent_id('f5654bcc-08c4-4f71-88fe-05d64e06de94')
diff --git a/tempest/api/identity/admin/v3/test_services.py b/tempest/api/identity/admin/v3/test_services.py
index d920f64..d1595dd 100644
--- a/tempest/api/identity/admin/v3/test_services.py
+++ b/tempest/api/identity/admin/v3/test_services.py
@@ -26,7 +26,7 @@
# Used for deleting the services created in this class
self.service_client.delete_service(service_id)
# Checking whether service is deleted successfully
- self.assertRaises(lib_exc.NotFound, self.service_client.get_service,
+ self.assertRaises(lib_exc.NotFound, self.service_client.show_service,
service_id)
@test.attr(type='smoke')
@@ -37,7 +37,7 @@
serv_type = data_utils.rand_name('type')
desc = data_utils.rand_name('description')
create_service = self.service_client.create_service(
- serv_type, name=name, description=desc)['service']
+ type=serv_type, name=name, description=desc)['service']
self.addCleanup(self._del_service, create_service['id'])
self.assertIsNotNone(create_service['id'])
@@ -56,7 +56,7 @@
self.assertNotEqual(resp1_desc, resp2_desc)
# Get service
- fetched_service = self.service_client.get_service(s_id)['service']
+ fetched_service = self.service_client.show_service(s_id)['service']
resp3_desc = fetched_service['description']
self.assertEqual(resp2_desc, resp3_desc)
@@ -68,7 +68,7 @@
name = data_utils.rand_name('service')
serv_type = data_utils.rand_name('type')
service = self.service_client.create_service(
- serv_type, name=name)['service']
+ type=serv_type, name=name)['service']
self.addCleanup(self.service_client.delete_service, service['id'])
self.assertIn('id', service)
expected_data = {'name': name, 'type': serv_type}
@@ -82,7 +82,7 @@
name = data_utils.rand_name('service')
serv_type = data_utils.rand_name('type')
create_service = self.service_client.create_service(
- serv_type, name=name)['service']
+ type=serv_type, name=name)['service']
self.addCleanup(self.service_client.delete_service,
create_service['id'])
service_ids.append(create_service['id'])
diff --git a/tempest/api/identity/admin/v3/test_tokens.py b/tempest/api/identity/admin/v3/test_tokens.py
index b5f86da..7d33d4a 100644
--- a/tempest/api/identity/admin/v3/test_tokens.py
+++ b/tempest/api/identity/admin/v3/test_tokens.py
@@ -39,13 +39,13 @@
password=u_password).response
subject_token = resp['x-subject-token']
# Perform GET Token
- token_details = self.client.get_token(subject_token)['token']
+ token_details = self.client.show_token(subject_token)['token']
self.assertEqual(resp['x-subject-token'], subject_token)
self.assertEqual(token_details['user']['id'], user['id'])
self.assertEqual(token_details['user']['name'], u_name)
# Perform Delete Token
self.client.delete_token(subject_token)
- self.assertRaises(lib_exc.NotFound, self.client.get_token,
+ self.assertRaises(lib_exc.NotFound, self.client.show_token,
subject_token)
@test.idempotent_id('565fa210-1da1-4563-999b-f7b5b67cf112')
diff --git a/tempest/api/identity/admin/v3/test_trusts.py b/tempest/api/identity/admin/v3/test_trusts.py
index fac8826..a8b0af9 100644
--- a/tempest/api/identity/admin/v3/test_trusts.py
+++ b/tempest/api/identity/admin/v3/test_trusts.py
@@ -18,7 +18,7 @@
from tempest.api.identity import base
from tempest import clients
-from tempest.common import cred_provider
+from tempest.common import credentials_factory as common_creds
from tempest.common.utils import data_utils
from tempest import config
from tempest import test
@@ -89,7 +89,7 @@
self.assertIsNotNone(self.trustee_user_id)
# Initialize a new client with the trustor credentials
- creds = cred_provider.get_credentials(
+ creds = common_creds.get_credentials(
identity_version='v3',
username=self.trustor_username,
password=self.trustor_password,
diff --git a/tempest/api/identity/admin/v3/test_users.py b/tempest/api/identity/admin/v3/test_users.py
index 8fac0b3..b56c9e6 100644
--- a/tempest/api/identity/admin/v3/test_users.py
+++ b/tempest/api/identity/admin/v3/test_users.py
@@ -54,7 +54,7 @@
self.assertEqual(u_email2, update_user['email'])
self.assertEqual(False, update_user['enabled'])
# GET by id after updation
- new_user_get = self.client.get_user(user['id'])['user']
+ new_user_get = self.client.show_user(user['id'])['user']
# Assert response body of GET after updation
self.assertEqual(u_name2, new_user_get['name'])
self.assertEqual(u_description2, new_user_get['description'])
@@ -80,7 +80,7 @@
password=new_password).response
subject_token = resp['x-subject-token']
# Perform GET Token to verify and confirm password is updated
- token_details = self.client.get_token(subject_token)['token']
+ token_details = self.client.show_token(subject_token)['token']
self.assertEqual(resp['x-subject-token'], subject_token)
self.assertEqual(token_details['user']['id'], user['id'])
self.assertEqual(token_details['user']['name'], u_name)
@@ -111,8 +111,8 @@
# Delete the Role at the end of this method
self.addCleanup(self.client.delete_role, role_body['id'])
- user = self.client.get_user(user_body['id'])['user']
- role = self.client.get_role(role_body['id'])['role']
+ user = self.client.show_user(user_body['id'])['user']
+ role = self.client.show_role(role_body['id'])['role']
for i in range(2):
# Creating project so as to assign role
project_body = self.client.create_project(
@@ -142,5 +142,5 @@
def test_get_user(self):
# Get a user detail
self.data.setup_test_v3_user()
- user = self.client.get_user(self.data.v3_user['id'])['user']
+ user = self.client.show_user(self.data.v3_user['id'])['user']
self.assertEqual(self.data.v3_user['id'], user['id'])
diff --git a/tempest/api/identity/admin/v3/test_users_negative.py b/tempest/api/identity/admin/v3/test_users_negative.py
new file mode 100644
index 0000000..ca2aaa4
--- /dev/null
+++ b/tempest/api/identity/admin/v3/test_users_negative.py
@@ -0,0 +1,35 @@
+# Copyright 2015 OpenStack Foundation
+# 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 tempest_lib import exceptions as lib_exc
+
+from tempest.api.identity import base
+from tempest.common.utils import data_utils
+from tempest import test
+
+
+class UsersNegativeTest(base.BaseIdentityV3AdminTest):
+
+ @test.attr(type=['negative'])
+ @test.idempotent_id('e75f006c-89cc-477b-874d-588e4eab4b17')
+ def test_create_user_for_non_existent_domain(self):
+ # Attempt to create a user in a non-existent domain should fail
+ u_name = data_utils.rand_name('user')
+ u_email = u_name + '@testmail.tm'
+ u_password = data_utils.rand_name('pass')
+ self.assertRaises(lib_exc.NotFound, self.client.create_user,
+ u_name, u_password,
+ email=u_email,
+ domain_id=data_utils.rand_uuid_hex())
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index ada292f..c56f4fb 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -16,7 +16,7 @@
from oslo_log import log as logging
from tempest_lib import exceptions as lib_exc
-from tempest.common import cred_provider
+from tempest.common import credentials_factory as common_creds
from tempest.common.utils import data_utils
from tempest import config
import tempest.test
@@ -39,7 +39,7 @@
@classmethod
def get_user_by_name(cls, name):
- users = cls.client.get_users()
+ users = cls.client.list_users()['users']
user = [u for u in users if u['name'] == name]
if len(user) > 0:
return user[0]
@@ -47,11 +47,7 @@
@classmethod
def get_tenant_by_name(cls, name):
try:
- tenants = cls.client.list_tenants()
- # TODO(jswarren): always retrieve 'tenants' value
- # once both clients return full response objects
- if 'tenants' in tenants:
- tenants = tenants['tenants']
+ tenants = cls.client.list_tenants()['tenants']
except AttributeError:
tenants = cls.client.list_projects()['projects']
tenant = [t for t in tenants if t['name'] == name]
@@ -60,7 +56,7 @@
@classmethod
def get_role_by_name(cls, name):
- roles = cls.client.list_roles()
+ roles = cls.client.list_roles()['roles']
role = [r for r in roles if r['name'] == name]
if len(role) > 0:
return role[0]
@@ -124,11 +120,6 @@
super(BaseIdentityV3Test, cls).setup_clients()
cls.non_admin_client = cls.os.identity_v3_client
cls.non_admin_token = cls.os.token_v3_client
- cls.non_admin_endpoints_client = cls.os.endpoints_client
- cls.non_admin_region_client = cls.os.region_client
- cls.non_admin_service_client = cls.os.service_client
- cls.non_admin_policy_client = cls.os.policy_client
- cls.non_admin_creds_client = cls.os.credentials_client
@classmethod
def resource_cleanup(cls):
@@ -146,10 +137,12 @@
cls.token = cls.os_adm.token_v3_client
cls.endpoints_client = cls.os_adm.endpoints_client
cls.region_client = cls.os_adm.region_client
- cls.data = DataGenerator(cls.client)
cls.service_client = cls.os_adm.service_client
cls.policy_client = cls.os_adm.policy_client
cls.creds_client = cls.os_adm.credentials_client
+ cls.groups_client = cls.os_adm.groups_client
+
+ cls.data = DataGenerator(cls.client)
@classmethod
def resource_cleanup(cls):
@@ -158,7 +151,7 @@
@classmethod
def get_user_by_name(cls, name):
- users = cls.client.get_users()['users']
+ users = cls.client.list_users()['users']
user = [u for u in users if u['name'] == name]
if len(user) > 0:
return user[0]
@@ -199,11 +192,11 @@
@property
def test_credentials(self):
- return cred_provider.get_credentials(username=self.test_user,
- user_id=self.user['id'],
- password=self.test_password,
- tenant_name=self.test_tenant,
- tenant_id=self.tenant['id'])
+ return common_creds.get_credentials(username=self.test_user,
+ user_id=self.user['id'],
+ password=self.test_password,
+ tenant_name=self.test_tenant,
+ tenant_id=self.tenant['id'])
def setup_test_user(self):
"""Set up a test user."""
@@ -214,7 +207,7 @@
self.user = self.client.create_user(self.test_user,
self.test_password,
self.tenant['id'],
- self.test_email)
+ self.test_email)['user']
self.users.append(self.user)
def setup_test_tenant(self):
@@ -223,13 +216,13 @@
self.test_description = data_utils.rand_name('desc')
self.tenant = self.client.create_tenant(
name=self.test_tenant,
- description=self.test_description)
+ description=self.test_description)['tenant']
self.tenants.append(self.tenant)
def setup_test_role(self):
"""Set up a test role."""
self.test_role = data_utils.rand_name('role')
- self.role = self.client.create_role(self.test_role)
+ self.role = self.client.create_role(self.test_role)['role']
self.roles.append(self.role)
def setup_test_v3_user(self):
diff --git a/tempest/api/identity/test_extension.py b/tempest/api/identity/test_extension.py
index b1d65b4..01e5661 100644
--- a/tempest/api/identity/test_extension.py
+++ b/tempest/api/identity/test_extension.py
@@ -22,7 +22,7 @@
@test.idempotent_id('85f3f661-f54c-4d48-b563-72ae952b9383')
def test_list_extensions(self):
# List all the extensions
- body = self.non_admin_client.list_extensions()
+ body = self.non_admin_client.list_extensions()['extensions']['values']
self.assertNotEmpty(body)
keys = ['name', 'updated', 'alias', 'links',
'namespace', 'description']
diff --git a/tempest/api/identity/v2/test_api_discovery.py b/tempest/api/identity/v2/test_api_discovery.py
index 8132ee1..ca807a4 100644
--- a/tempest/api/identity/v2/test_api_discovery.py
+++ b/tempest/api/identity/v2/test_api_discovery.py
@@ -23,7 +23,7 @@
@test.attr(type='smoke')
@test.idempotent_id('ea889a68-a15f-4166-bfb1-c12456eae853')
def test_api_version_resources(self):
- descr = self.non_admin_client.get_api_description()
+ descr = self.non_admin_client.show_api_description()['version']
expected_resources = ('id', 'links', 'media-types', 'status',
'updated')
@@ -34,7 +34,7 @@
@test.attr(type='smoke')
@test.idempotent_id('007a0be0-78fe-4fdb-bbee-e9216cc17bb2')
def test_api_media_types(self):
- descr = self.non_admin_client.get_api_description()
+ descr = self.non_admin_client.show_api_description()['version']
# Get MIME type bases and descriptions
media_types = [(media_type['base'], media_type['type']) for
media_type in descr['media-types']]
@@ -49,7 +49,7 @@
@test.attr(type='smoke')
@test.idempotent_id('77fd6be0-8801-48e6-b9bf-38cdd2f253ec')
def test_api_version_statuses(self):
- descr = self.non_admin_client.get_api_description()
+ descr = self.non_admin_client.show_api_description()['version']
status = descr['status'].lower()
supported_statuses = ['current', 'stable', 'experimental',
'supported', 'deprecated']
diff --git a/tempest/api/identity/v2/test_ec2_credentials.py b/tempest/api/identity/v2/test_ec2_credentials.py
index dbb50be..763d8de 100644
--- a/tempest/api/identity/v2/test_ec2_credentials.py
+++ b/tempest/api/identity/v2/test_ec2_credentials.py
@@ -38,7 +38,7 @@
"""Create user ec2 credentials."""
resp = self.non_admin_client.create_user_ec2_credentials(
self.creds.credentials.user_id,
- self.creds.credentials.tenant_id)
+ self.creds.credentials.tenant_id)["credential"]
access = resp['access']
self.addCleanup(
self.non_admin_client.delete_user_ec2_credentials,
@@ -55,11 +55,13 @@
fetched_creds = []
# create first ec2 credentials
creds1 = self.non_admin_client.create_user_ec2_credentials(
- self.creds.credentials.user_id, self.creds.credentials.tenant_id)
+ self.creds.credentials.user_id,
+ self.creds.credentials.tenant_id)["credential"]
created_creds.append(creds1['access'])
# create second ec2 credentials
creds2 = self.non_admin_client.create_user_ec2_credentials(
- self.creds.credentials.user_id, self.creds.credentials.tenant_id)
+ self.creds.credentials.user_id,
+ self.creds.credentials.tenant_id)["credential"]
created_creds.append(creds2['access'])
# add credentials to be cleaned up
self.addCleanup(
@@ -70,7 +72,7 @@
self.creds.credentials.user_id, creds2['access'])
# get the list of user ec2 credentials
resp = self.non_admin_client.list_user_ec2_credentials(
- self.creds.credentials.user_id)
+ self.creds.credentials.user_id)["credentials"]
fetched_creds = [cred['access'] for cred in resp]
# created credentials should be in a fetched list
missing = [cred for cred in created_creds
@@ -84,14 +86,14 @@
"""Get the definite user ec2 credentials."""
resp = self.non_admin_client.create_user_ec2_credentials(
self.creds.credentials.user_id,
- self.creds.credentials.tenant_id)
+ self.creds.credentials.tenant_id)["credential"]
self.addCleanup(
self.non_admin_client.delete_user_ec2_credentials,
self.creds.credentials.user_id, resp['access'])
ec2_creds = self.non_admin_client.show_user_ec2_credentials(
self.creds.credentials.user_id, resp['access']
- )
+ )["credential"]
for key in ['access', 'secret', 'user_id', 'tenant_id']:
self.assertEqual(ec2_creds[key], resp[key])
@@ -100,7 +102,7 @@
"""Delete user ec2 credentials."""
resp = self.non_admin_client.create_user_ec2_credentials(
self.creds.credentials.user_id,
- self.creds.credentials.tenant_id)
+ self.creds.credentials.tenant_id)["credential"]
access = resp['access']
self.non_admin_client.delete_user_ec2_credentials(
self.creds.credentials.user_id, access)
diff --git a/tempest/api/identity/v2/test_users.py b/tempest/api/identity/v2/test_users.py
index 4e5b41d..03c6621 100644
--- a/tempest/api/identity/v2/test_users.py
+++ b/tempest/api/identity/v2/test_users.py
@@ -14,6 +14,7 @@
# under the License.
import copy
+import time
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions
@@ -56,7 +57,16 @@
# user updates own password
resp = self.non_admin_client.update_user_own_password(
- user_id=user_id, new_pass=new_pass, old_pass=old_pass)
+ user_id=user_id, new_pass=new_pass, old_pass=old_pass)['access']
+
+ # TODO(lbragstad): Sleeping after the response status has been checked
+ # and the body loaded as JSON allows requests to fail-fast. The sleep
+ # is necessary because keystone will err on the side of security and
+ # invalidate tokens within a small margin of error (within the same
+ # wall clock second) after a revocation event is issued (such as a
+ # password change). Remove this once keystone and Fernet support
+ # sub-second precision.
+ time.sleep(1)
# check authorization with new token
self.non_admin_token_client.auth_token(resp['token']['id'])
diff --git a/tempest/api/identity/v3/test_api_discovery.py b/tempest/api/identity/v3/test_api_discovery.py
index e0207a9..74e9ec1 100644
--- a/tempest/api/identity/v3/test_api_discovery.py
+++ b/tempest/api/identity/v3/test_api_discovery.py
@@ -23,7 +23,7 @@
@test.attr(type='smoke')
@test.idempotent_id('b9232f5e-d9e5-4d97-b96c-28d3db4de1bd')
def test_api_version_resources(self):
- descr = self.non_admin_client.get_api_description()['version']
+ descr = self.non_admin_client.show_api_description()['version']
expected_resources = ('id', 'links', 'media-types', 'status',
'updated')
@@ -34,7 +34,7 @@
@test.attr(type='smoke')
@test.idempotent_id('657c1970-4722-4189-8831-7325f3bc4265')
def test_api_media_types(self):
- descr = self.non_admin_client.get_api_description()['version']
+ descr = self.non_admin_client.show_api_description()['version']
# Get MIME type bases and descriptions
media_types = [(media_type['base'], media_type['type']) for
media_type in descr['media-types']]
@@ -49,7 +49,7 @@
@test.attr(type='smoke')
@test.idempotent_id('8879a470-abfb-47bb-bb8d-5a7fd279ad1e')
def test_api_version_statuses(self):
- descr = self.non_admin_client.get_api_description()['version']
+ descr = self.non_admin_client.show_api_description()['version']
status = descr['status'].lower()
supported_statuses = ['current', 'stable', 'experimental',
'supported', 'deprecated']
diff --git a/tempest/api/identity/v3/test_users.py b/tempest/api/identity/v3/test_users.py
index a1f664f..2bab5d1 100644
--- a/tempest/api/identity/v3/test_users.py
+++ b/tempest/api/identity/v3/test_users.py
@@ -14,6 +14,7 @@
# under the License.
import copy
+import time
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions
@@ -57,6 +58,15 @@
self.non_admin_client.update_user_password(
user_id=user_id, password=new_pass, original_password=old_pass)
+ # TODO(lbragstad): Sleeping after the response status has been checked
+ # and the body loaded as JSON allows requests to fail-fast. The sleep
+ # is necessary because keystone will err on the side of security and
+ # invalidate tokens within a small margin of error (within the same
+ # wall clock second) after a revocation event is issued (such as a
+ # password change). Remove this once keystone and Fernet support
+ # sub-second precision.
+ time.sleep(1)
+
# check authorization with new password
self.non_admin_token.auth(user_id=self.user_id, password=new_pass)
diff --git a/tempest/api/image/admin/v2/test_images.py b/tempest/api/image/admin/v2/test_images.py
index 09877ba..01838b6 100644
--- a/tempest/api/image/admin/v2/test_images.py
+++ b/tempest/api/image/admin/v2/test_images.py
@@ -26,10 +26,8 @@
class BasicAdminOperationsImagesTest(base.BaseV2ImageAdminTest):
+ """Here we test admin operations of images"""
- """
- Here we test admin operations of images
- """
@testtools.skipUnless(CONF.image_feature_enabled.deactivate_image,
'deactivate-image is not available.')
@test.idempotent_id('951ebe01-969f-4ea9-9898-8a3f1f442ab0')
diff --git a/tempest/api/image/v1/test_images.py b/tempest/api/image/v1/test_images.py
index d4dbfcd..64f3174 100644
--- a/tempest/api/image/v1/test_images.py
+++ b/tempest/api/image/v1/test_images.py
@@ -100,10 +100,7 @@
class ListImagesTest(base.BaseV1ImageTest):
-
- """
- Here we test the listing of image information
- """
+ """Here we test the listing of image information"""
@classmethod
def resource_setup(cls):
@@ -131,10 +128,8 @@
@classmethod
def _create_remote_image(cls, name, container_format, disk_format):
- """
- Create a new remote image and return the ID of the newly-registered
- image
- """
+ """Create a new remote image and return newly-registered image-id"""
+
name = 'New Remote Image %s' % name
location = CONF.image.http_image
image = cls.create_image(name=name,
@@ -148,9 +143,9 @@
@classmethod
def _create_standard_image(cls, name, container_format,
disk_format, size):
- """
- Create a new standard image and return the ID of the newly-registered
- image. Note that the size of the new image is a random number between
+ """Create a new standard image and return newly-registered image-id
+
+ Note that the size of the new image is a random number between
1024 and 4096
"""
image_file = moves.cStringIO(data_utils.random_bytes(size))
@@ -241,10 +236,8 @@
@classmethod
def _create_standard_image(cls, name, container_format,
disk_format, size):
- """
- Create a new standard image and return the ID of the newly-registered
- image.
- """
+ """Create a new standard image and return newly-registered image-id"""
+
image_file = moves.cStringIO(data_utils.random_bytes(size))
name = 'New Standard Image %s' % name
image = cls.create_image(name=name,
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index a336507..936eadf 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -18,30 +18,35 @@
from six import moves
+from oslo_log import log as logging
from tempest.api.image import base
from tempest.common.utils import data_utils
+from tempest import config
from tempest import test
+CONF = config.CONF
+LOG = logging.getLogger(__name__)
+
class BasicOperationsImagesTest(base.BaseV2ImageTest):
- """
- Here we test the basic operations of images
- """
+ """Here we test the basic operations of images"""
@test.attr(type='smoke')
@test.idempotent_id('139b765e-7f3d-4b3d-8b37-3ca3876ee318')
def test_register_upload_get_image_file(self):
+ """Here we test these functionalities
- """
- Here we test these functionalities - Register image,
- upload the image file, get image and get image file api's
+ Register image, upload the image file, get image and get image
+ file api's
"""
uuid = '00000000-1111-2222-3333-444455556666'
image_name = data_utils.rand_name('image')
+ container_format = CONF.image.container_formats[0]
+ disk_format = CONF.image.disk_formats[0]
body = self.create_image(name=image_name,
- container_format='bare',
- disk_format='raw',
+ container_format=container_format,
+ disk_format=disk_format,
visibility='private',
ramdisk_id=uuid)
self.assertIn('id', body)
@@ -77,9 +82,11 @@
# Create image
image_name = data_utils.rand_name('image')
+ container_format = CONF.image.container_formats[0]
+ disk_format = CONF.image.disk_formats[0]
body = self.client.create_image(name=image_name,
- container_format='bare',
- disk_format='raw',
+ container_format=container_format,
+ disk_format=disk_format,
visibility='private')
image_id = body['id']
@@ -99,9 +106,11 @@
# Create image
image_name = data_utils.rand_name('image')
+ container_format = CONF.image.container_formats[0]
+ disk_format = CONF.image.disk_formats[0]
body = self.client.create_image(name=image_name,
- container_format='bare',
- disk_format='iso',
+ container_format=container_format,
+ disk_format=disk_format,
visibility='private')
self.addCleanup(self.client.delete_image, body['id'])
self.assertEqual('queued', body['status'])
@@ -124,28 +133,30 @@
class ListImagesTest(base.BaseV2ImageTest):
- """
- Here we test the listing of image information
- """
+ """Here we test the listing of image information"""
@classmethod
def resource_setup(cls):
super(ListImagesTest, cls).resource_setup()
# We add a few images here to test the listing functionality of
# the images API
- cls._create_standard_image('bare', 'raw')
- cls._create_standard_image('bare', 'raw')
- cls._create_standard_image('ami', 'raw')
- # Add some more for listing
- cls._create_standard_image('ami', 'ami')
- cls._create_standard_image('ari', 'ari')
- cls._create_standard_image('aki', 'aki')
+ container_fmts = CONF.image.container_formats
+ disk_fmts = CONF.image.disk_formats
+ all_pairs = [(container_fmt, disk_fmt)
+ for container_fmt in container_fmts
+ for disk_fmt in disk_fmts]
+
+ for (container_fmt, disk_fmt) in all_pairs[:6]:
+ LOG.debug("Creating a image"
+ "(Container format: %s, Disk format: %s).",
+ container_fmt, disk_fmt)
+ cls._create_standard_image(container_fmt, disk_fmt)
@classmethod
def _create_standard_image(cls, container_format, disk_format):
- """
- Create a new standard image and return the ID of the newly-registered
- image. Note that the size of the new image is a random number between
+ """Create a new standard image and return the newly-registered image-id
+
+ Note that the size of the new image is a random number between
1024 and 4096
"""
size = random.randint(1024, 4096)
@@ -161,9 +172,8 @@
return image_id
def _list_by_param_value_and_assert(self, params):
- """
- Perform list action with given params and validates result.
- """
+ """Perform list action with given params and validates result."""
+
images_list = self.client.list_images(params=params)['images']
# Validating params of fetched images
for image in images_list:
@@ -201,7 +211,7 @@
@test.idempotent_id('cf1b9a48-8340-480e-af7b-fe7e17690876')
def test_list_images_param_size(self):
# Test to get all images by size
- image_id = self.created_images[1]
+ image_id = self.created_images[0]
# Get image metadata
image = self.client.show_image(image_id)
@@ -211,7 +221,7 @@
@test.idempotent_id('4ad8c157-971a-4ba8-aa84-ed61154b1e7f')
def test_list_images_param_min_max_size(self):
# Test to get all images with size between 2000 to 3000
- image_id = self.created_images[1]
+ image_id = self.created_images[0]
# Get image metadata
image = self.client.show_image(image_id)
@@ -234,7 +244,7 @@
@test.idempotent_id('e914a891-3cc8-4b40-ad32-e0a39ffbddbb')
def test_list_images_param_limit(self):
# Test to get images by limit
- params = {"limit": 2}
+ params = {"limit": 1}
images_list = self.client.list_images(params=params)['images']
self.assertEqual(len(images_list), params['limit'],
diff --git a/tempest/api/image/v2/test_images_member.py b/tempest/api/image/v2/test_images_member.py
index d89803d..d68ceff 100644
--- a/tempest/api/image/v2/test_images_member.py
+++ b/tempest/api/image/v2/test_images_member.py
@@ -77,7 +77,7 @@
{'status': 'accepted'})
self.assertIn(image_id, self._list_image_ids_as_alt())
- self.os_img_client.remove_image_member(image_id, self.alt_tenant_id)
+ self.os_img_client.delete_image_member(image_id, self.alt_tenant_id)
self.assertNotIn(image_id, self._list_image_ids_as_alt())
@test.idempotent_id('634dcc3f-f6e2-4409-b8fd-354a0bb25d83')
@@ -103,5 +103,5 @@
self.alt_tenant_id,
{'status': 'accepted'})
self.assertIn(image_id, self._list_image_ids_as_alt())
- self.os_img_client.remove_image_member(image_id, self.alt_tenant_id)
+ self.os_img_client.delete_image_member(image_id, self.alt_tenant_id)
self.assertNotIn(image_id, self._list_image_ids_as_alt())
diff --git a/tempest/api/image/v2/test_images_metadefs_namespaces.py b/tempest/api/image/v2/test_images_metadefs_namespaces.py
new file mode 100644
index 0000000..d089c84
--- /dev/null
+++ b/tempest/api/image/v2/test_images_metadefs_namespaces.py
@@ -0,0 +1,70 @@
+# Copyright 2015 Red Hat, Inc.
+# 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 tempest.api.image import base
+from tempest.common.utils import data_utils
+from tempest import test
+from tempest_lib import exceptions as lib_exc
+
+
+class MetadataNamespacesTest(base.BaseV2ImageTest):
+ """Test the Metadata definition Namespaces basic functionality"""
+
+ @test.idempotent_id('319b765e-7f3d-4b3d-8b37-3ca3876ee768')
+ def test_basic_metadata_definition_namespaces(self):
+ # get the available resource types and use one resource_type
+ body = self.client.list_resource_types()
+ resource_name = body['resource_types'][0]['name']
+ name = [{'name': resource_name}]
+ namespace_name = data_utils.rand_name('namespace')
+ # create the metadef namespaces
+ body = self.client.create_namespaces(namespace=namespace_name,
+ visibility='public',
+ description='Tempest',
+ display_name=namespace_name,
+ resource_type_associations=name,
+ protected=True)
+ self.addCleanup(self._cleanup_namespace, namespace_name)
+ # get namespaces details
+ body = self.client.show_namespaces(namespace_name)
+ self.assertEqual(namespace_name, body['namespace'])
+ self.assertEqual('public', body['visibility'])
+ # unable to delete protected namespace
+ self.assertRaises(lib_exc.Forbidden, self.client.delete_namespaces,
+ namespace_name)
+ # update the visibility to private and protected to False
+ body = self.client.update_namespaces(namespace=namespace_name,
+ description='Tempest',
+ visibility='private',
+ display_name=namespace_name,
+ protected=False)
+ self.assertEqual('private', body['visibility'])
+ self.assertEqual(False, body['protected'])
+ # now able to delete the non-protected namespace
+ self.client.delete_namespaces(namespace_name)
+
+ def _cleanup_namespace(self, namespace_name):
+ # this is used to cleanup the resources
+ try:
+ body = self.client.show_namespaces(namespace_name)
+ self.assertEqual(namespace_name, body['namespace'])
+ body = self.client.update_namespaces(namespace=namespace_name,
+ description='Tempest',
+ visibility='private',
+ display_name=namespace_name,
+ protected=False)
+ self.client.delete_namespaces(namespace_name)
+ except lib_exc.NotFound:
+ pass
diff --git a/tempest/api/image/v2/test_images_negative.py b/tempest/api/image/v2/test_images_negative.py
index c5c5e8b..71c8c7a 100644
--- a/tempest/api/image/v2/test_images_negative.py
+++ b/tempest/api/image/v2/test_images_negative.py
@@ -24,8 +24,7 @@
class ImagesNegativeTest(base.BaseV2ImageTest):
- """
- here we have -ve tests for show_image and delete_image api
+ """here we have -ve tests for show_image and delete_image api
Tests
** get non-existent image
diff --git a/tempest/api/messaging/base.py b/tempest/api/messaging/base.py
index 64a7fd5..528fbea 100644
--- a/tempest/api/messaging/base.py
+++ b/tempest/api/messaging/base.py
@@ -26,8 +26,7 @@
class BaseMessagingTest(test.BaseTestCase):
- """
- Base class for the Messaging tests that use the Tempest Zaqar REST client
+ """Base class for the Messaging (Zaqar) tests
It is assumed that the following option is defined in the
[service_available] section of etc/tempest.conf
@@ -147,7 +146,7 @@
@classmethod
def release_claim(cls, claim_uri):
"""Wrapper utility that deletes a claim."""
- resp, body = cls.client.release_claim(claim_uri)
+ resp, body = cls.client.delete_claim(claim_uri)
return resp, body
diff --git a/tempest/api/messaging/test_claims.py b/tempest/api/messaging/test_claims.py
index e54bed1..57b8c7f 100644
--- a/tempest/api/messaging/test_claims.py
+++ b/tempest/api/messaging/test_claims.py
@@ -115,7 +115,7 @@
claim_uri = resp['location']
# Release Claim
- self.client.release_claim(claim_uri)
+ self.client.delete_claim(claim_uri)
# Delete Claimed message
# This will implicitly verify that the claim is deleted.
diff --git a/tempest/api/network/admin/test_agent_management.py b/tempest/api/network/admin/test_agent_management.py
index 128398b..c5d0d57 100644
--- a/tempest/api/network/admin/test_agent_management.py
+++ b/tempest/api/network/admin/test_agent_management.py
@@ -79,9 +79,8 @@
self.assertEqual(updated_description, description)
def _restore_agent(self):
- """
- Restore the agent description after update test.
- """
+ """Restore the agent description after update test"""
+
description = self.agent['description'] or ''
origin_agent = {'description': description}
self.admin_client.update_agent(agent_id=self.agent['id'],
diff --git a/tempest/api/network/admin/test_dhcp_agent_scheduler.py b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
index 86b4973..7692b56 100644
--- a/tempest/api/network/admin/test_dhcp_agent_scheduler.py
+++ b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
@@ -61,7 +61,7 @@
@test.idempotent_id('a0856713-6549-470c-a656-e97c8df9a14d')
def test_add_remove_network_from_dhcp_agent(self):
# The agent is now bound to the network, we can free the port
- self.client.delete_port(self.port['id'])
+ self.ports_client.delete_port(self.port['id'])
self.ports.remove(self.port)
agent = dict()
agent['agent_type'] = None
diff --git a/tempest/api/network/admin/test_external_network_extension.py b/tempest/api/network/admin/test_external_network_extension.py
index d942641..a32bfbc 100644
--- a/tempest/api/network/admin/test_external_network_extension.py
+++ b/tempest/api/network/admin/test_external_network_extension.py
@@ -26,9 +26,10 @@
post_body = {'name': data_utils.rand_name('network-')}
if external:
post_body['router:external'] = external
- body = self.admin_client.create_network(**post_body)
+ body = self.admin_networks_client.create_network(**post_body)
network = body['network']
- self.addCleanup(self.admin_client.delete_network, network['id'])
+ self.addCleanup(
+ self.admin_networks_client.delete_network, network['id'])
return network
@test.idempotent_id('462be770-b310-4df9-9c42-773217e4c8b1')
@@ -47,8 +48,8 @@
network = self._create_network(external=False)
self.assertFalse(network.get('router:external', False))
update_body = {'router:external': True}
- body = self.admin_client.update_network(network['id'],
- **update_body)
+ body = self.admin_networks_client.update_network(network['id'],
+ **update_body)
updated_network = body['network']
# Verify that router:external parameter was updated
self.assertTrue(updated_network['router:external'])
@@ -60,7 +61,7 @@
# List networks as a normal user and confirm the external
# network extension attribute is returned for those networks
# that were created as external
- body = self.client.list_networks()
+ body = self.networks_client.list_networks()
networks_list = [net['id'] for net in body['networks']]
self.assertIn(external_network['id'], networks_list)
self.assertIn(self.network['id'], networks_list)
@@ -76,12 +77,12 @@
external_network = self._create_network()
# Show an external network as a normal user and confirm the
# external network extension attribute is returned.
- body = self.client.show_network(external_network['id'])
+ body = self.networks_client.show_network(external_network['id'])
show_ext_net = body['network']
self.assertEqual(external_network['name'], show_ext_net['name'])
self.assertEqual(external_network['id'], show_ext_net['id'])
self.assertTrue(show_ext_net['router:external'])
- body = self.client.show_network(self.network['id'])
+ body = self.networks_client.show_network(self.network['id'])
show_net = body['network']
# Verify with show that router:external is False for network
self.assertEqual(self.network['name'], show_net['name'])
@@ -90,36 +91,35 @@
@test.idempotent_id('82068503-2cf2-4ed4-b3be-ecb89432e4bb')
def test_delete_external_networks_with_floating_ip(self):
- """Verifies external network can be deleted while still holding
- (unassociated) floating IPs
+ # Verifies external network can be deleted while still holding
+ # (unassociated) floating IPs
- """
- # Set cls.client to admin to use base.create_subnet()
- client = self.admin_client
- body = client.create_network(**{'router:external': True})
+ body = self.admin_networks_client.create_network(
+ **{'router:external': True})
external_network = body['network']
self.addCleanup(self._try_delete_resource,
- client.delete_network,
+ self.admin_networks_client.delete_network,
external_network['id'])
- subnet = self.create_subnet(external_network, client=client,
- enable_dhcp=False)
- body = client.create_floatingip(
+ subnet = self.create_subnet(
+ external_network, client=self.admin_subnets_client,
+ enable_dhcp=False)
+ body = self.admin_floating_ips_client.create_floatingip(
floating_network_id=external_network['id'])
created_floating_ip = body['floatingip']
self.addCleanup(self._try_delete_resource,
- client.delete_floatingip,
+ self.admin_floating_ips_client.delete_floatingip,
created_floating_ip['id'])
- floatingip_list = client.list_floatingips(
+ floatingip_list = self.admin_floating_ips_client.list_floatingips(
network=external_network['id'])
self.assertIn(created_floating_ip['id'],
(f['id'] for f in floatingip_list['floatingips']))
- client.delete_network(external_network['id'])
+ self.admin_networks_client.delete_network(external_network['id'])
# Verifies floating ip is deleted
- floatingip_list = client.list_floatingips()
+ floatingip_list = self.admin_floating_ips_client.list_floatingips()
self.assertNotIn(created_floating_ip['id'],
(f['id'] for f in floatingip_list['floatingips']))
# Verifies subnet is deleted
- subnet_list = client.list_subnets()
+ subnet_list = self.admin_subnets_client.list_subnets()
self.assertNotIn(subnet['id'],
(s['id'] for s in subnet_list))
# Removes subnet from the cleanup list
diff --git a/tempest/api/network/admin/test_external_networks_negative.py b/tempest/api/network/admin/test_external_networks_negative.py
index c2fa0dd..d031108 100644
--- a/tempest/api/network/admin/test_external_networks_negative.py
+++ b/tempest/api/network/admin/test_external_networks_negative.py
@@ -27,19 +27,16 @@
@test.attr(type=['negative'])
@test.idempotent_id('d402ae6c-0be0-4d8e-833b-a738895d98d0')
def test_create_port_with_precreated_floatingip_as_fixed_ip(self):
- """
- External networks can be used to create both floating-ip as well
- as instance-ip. So, creating an instance-ip with a value of a
- pre-created floating-ip should be denied.
- """
+ # NOTE: External networks can be used to create both floating-ip as
+ # well as instance-ip. So, creating an instance-ip with a value of a
+ # pre-created floating-ip should be denied.
# create a floating ip
- client = self.admin_client
- body = client.create_floatingip(
+ body = self.admin_floating_ips_client.create_floatingip(
floating_network_id=CONF.network.public_network_id)
created_floating_ip = body['floatingip']
self.addCleanup(self._try_delete_resource,
- client.delete_floatingip,
+ self.admin_floating_ips_client.delete_floatingip,
created_floating_ip['id'])
floating_ip_address = created_floating_ip['floating_ip_address']
self.assertIsNotNone(floating_ip_address)
@@ -49,6 +46,6 @@
# create a port which will internally create an instance-ip
self.assertRaises(lib_exc.Conflict,
- client.create_port,
+ self.admin_ports_client.create_port,
network_id=CONF.network.public_network_id,
fixed_ips=fixed_ips)
diff --git a/tempest/api/network/admin/test_floating_ips_admin_actions.py b/tempest/api/network/admin/test_floating_ips_admin_actions.py
index dfe7307..6ad374b 100644
--- a/tempest/api/network/admin/test_floating_ips_admin_actions.py
+++ b/tempest/api/network/admin/test_floating_ips_admin_actions.py
@@ -29,6 +29,7 @@
def setup_clients(cls):
super(FloatingIPAdminTestJSON, cls).setup_clients()
cls.alt_client = cls.alt_manager.network_client
+ cls.alt_floating_ips_client = cls.alt_manager.floating_ips_client
@classmethod
def resource_setup(cls):
@@ -45,18 +46,18 @@
@test.idempotent_id('64f2100b-5471-4ded-b46c-ddeeeb4f231b')
def test_list_floating_ips_from_admin_and_nonadmin(self):
# Create floating ip from admin user
- floating_ip_admin = self.admin_client.create_floatingip(
+ floating_ip_admin = self.admin_floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id)
- self.addCleanup(self.admin_client.delete_floatingip,
+ self.addCleanup(self.admin_floating_ips_client.delete_floatingip,
floating_ip_admin['floatingip']['id'])
# Create floating ip from alt user
- body = self.alt_client.create_floatingip(
+ body = self.alt_floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id)
floating_ip_alt = body['floatingip']
- self.addCleanup(self.alt_client.delete_floatingip,
+ self.addCleanup(self.alt_floating_ips_client.delete_floatingip,
floating_ip_alt['id'])
# List floating ips from admin
- body = self.admin_client.list_floatingips()
+ body = self.admin_floating_ips_client.list_floatingips()
floating_ip_ids_admin = [f['id'] for f in body['floatingips']]
# Check that admin sees all floating ips
self.assertIn(self.floating_ip['id'], floating_ip_ids_admin)
@@ -64,7 +65,7 @@
floating_ip_ids_admin)
self.assertIn(floating_ip_alt['id'], floating_ip_ids_admin)
# List floating ips from nonadmin
- body = self.client.list_floatingips()
+ body = self.floating_ips_client.list_floatingips()
floating_ip_ids = [f['id'] for f in body['floatingips']]
# Check that nonadmin user doesn't see floating ip created from admin
# and floating ip that is created in another tenant (alt user)
@@ -76,12 +77,12 @@
@test.idempotent_id('32727cc3-abe2-4485-a16e-48f2d54c14f2')
def test_create_list_show_floating_ip_with_tenant_id_by_admin(self):
# Creates a floating IP
- body = self.admin_client.create_floatingip(
+ body = self.admin_floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id,
tenant_id=self.network['tenant_id'],
port_id=self.port['id'])
created_floating_ip = body['floatingip']
- self.addCleanup(self.client.delete_floatingip,
+ self.addCleanup(self.floating_ips_client.delete_floatingip,
created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['tenant_id'])
@@ -93,7 +94,7 @@
self.assertEqual(created_floating_ip['fixed_ip_address'],
port[0]['ip_address'])
# Verifies the details of a floating_ip
- floating_ip = self.admin_client.show_floatingip(
+ floating_ip = self.admin_floating_ips_client.show_floatingip(
created_floating_ip['id'])
shown_floating_ip = floating_ip['floatingip']
self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
@@ -105,6 +106,6 @@
created_floating_ip['floating_ip_address'])
self.assertEqual(shown_floating_ip['port_id'], self.port['id'])
# Verify the floating ip exists in the list of all floating_ips
- floating_ips = self.admin_client.list_floatingips()
+ floating_ips = self.admin_floating_ips_client.list_floatingips()
floatingip_id_list = [f['id'] for f in floating_ips['floatingips']]
self.assertIn(created_floating_ip['id'], floatingip_id_list)
diff --git a/tempest/api/network/admin/test_quotas.py b/tempest/api/network/admin/test_quotas.py
index f5c5784..4a25206 100644
--- a/tempest/api/network/admin/test_quotas.py
+++ b/tempest/api/network/admin/test_quotas.py
@@ -21,9 +21,7 @@
class QuotasTest(base.BaseAdminNetworkTest):
- """
- Tests the following operations in the Neutron API using the REST client for
- Neutron:
+ """Tests the following operations in the Neutron API:
list quotas for tenants who have non-default quota values
show quotas for a specified tenant
diff --git a/tempest/api/network/admin/test_routers_dvr.py b/tempest/api/network/admin/test_routers_dvr.py
index 365698d..3e787af 100644
--- a/tempest/api/network/admin/test_routers_dvr.py
+++ b/tempest/api/network/admin/test_routers_dvr.py
@@ -42,7 +42,8 @@
@test.idempotent_id('08a2a0a8-f1e4-4b34-8e30-e522e836c44e')
def test_distributed_router_creation(self):
- """
+ """Test distributed router creation
+
Test uses administrative credentials to creates a
DVR (Distributed Virtual Routing) router using the
distributed=True.
@@ -59,7 +60,8 @@
@test.idempotent_id('8a0a72b4-7290-4677-afeb-b4ffe37bc352')
def test_centralized_router_creation(self):
- """
+ """Test centralized router creation
+
Test uses administrative credentials to creates a
CVR (Centralized Virtual Routing) router using the
distributed=False.
@@ -77,10 +79,11 @@
@test.idempotent_id('acd43596-c1fb-439d-ada8-31ad48ae3c2e')
def test_centralized_router_update_to_dvr(self):
- """
+ """Test centralized router update
+
Test uses administrative credentials to creates a
CVR (Centralized Virtual Routing) router using the
- distributed=False.Then it will "update" the router
+ distributed=False. Then it will "update" the router
distributed attribute to True
Acceptance
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index fa6fa33..b798cb2 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -28,9 +28,7 @@
class BaseNetworkTest(tempest.test.BaseTestCase):
-
- """
- Base class for the Neutron tests that use the Tempest Neutron REST client
+ """Base class for the Neutron tests
Per the Neutron API Guide, API v1.x was removed from the source code tree
(docs.openstack.org/api/openstack-network/2.0/content/Overview-d1e71.html)
@@ -73,6 +71,10 @@
def setup_clients(cls):
super(BaseNetworkTest, cls).setup_clients()
cls.client = cls.os.network_client
+ cls.networks_client = cls.os.networks_client
+ cls.subnets_client = cls.os.subnets_client
+ cls.ports_client = cls.os.ports_client
+ cls.floating_ips_client = cls.os.floating_ips_client
@classmethod
def resource_setup(cls):
@@ -91,8 +93,9 @@
if CONF.service_available.neutron:
# Clean up floating IPs
for floating_ip in cls.floating_ips:
- cls._try_delete_resource(cls.client.delete_floatingip,
- floating_ip['id'])
+ cls._try_delete_resource(
+ cls.floating_ips_client.delete_floatingip,
+ floating_ip['id'])
# Clean up metering label rules
for metering_label_rule in cls.metering_label_rules:
@@ -106,7 +109,7 @@
metering_label['id'])
# Clean up ports
for port in cls.ports:
- cls._try_delete_resource(cls.client.delete_port,
+ cls._try_delete_resource(cls.ports_client.delete_port,
port['id'])
# Clean up routers
for router in cls.routers:
@@ -114,11 +117,11 @@
router)
# Clean up subnets
for subnet in cls.subnets:
- cls._try_delete_resource(cls.client.delete_subnet,
+ cls._try_delete_resource(cls.subnets_client.delete_subnet,
subnet['id'])
# Clean up networks
for network in cls.networks:
- cls._try_delete_resource(cls.client.delete_network,
+ cls._try_delete_resource(cls.networks_client.delete_network,
network['id'])
super(BaseNetworkTest, cls).resource_cleanup()
@@ -147,7 +150,7 @@
"""Wrapper utility that returns a test network."""
network_name = network_name or data_utils.rand_name('test-network-')
- body = cls.client.create_network(name=network_name)
+ body = cls.networks_client.create_network(name=network_name)
network = body['network']
cls.networks.append(network)
return network
@@ -159,7 +162,7 @@
# allow tests to use admin client
if not client:
- client = cls.client
+ client = cls.subnets_client
# The cidr and mask_bits depend on the ip version.
ip_version = ip_version if ip_version is not None else cls._ip_version
@@ -199,8 +202,8 @@
@classmethod
def create_port(cls, network, **kwargs):
"""Wrapper utility that returns a test port."""
- body = cls.client.create_port(network_id=network['id'],
- **kwargs)
+ body = cls.ports_client.create_port(network_id=network['id'],
+ **kwargs)
port = body['port']
cls.ports.append(port)
return port
@@ -208,8 +211,8 @@
@classmethod
def update_port(cls, port, **kwargs):
"""Wrapper utility that updates a test port."""
- body = cls.client.update_port(port['id'],
- **kwargs)
+ body = cls.ports_client.update_port(port['id'],
+ **kwargs)
return body['port']
@classmethod
@@ -219,7 +222,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,
@@ -231,7 +234,7 @@
@classmethod
def create_floatingip(cls, external_network_id):
"""Wrapper utility that returns a test floating IP."""
- body = cls.client.create_floatingip(
+ body = cls.floating_ips_client.create_floatingip(
floating_network_id=external_network_id)
fip = body['floatingip']
cls.floating_ips.append(fip)
@@ -265,6 +268,10 @@
def setup_clients(cls):
super(BaseAdminNetworkTest, cls).setup_clients()
cls.admin_client = cls.os_adm.network_client
+ cls.admin_networks_client = cls.os_adm.networks_client
+ cls.admin_subnets_client = cls.os_adm.subnets_client
+ cls.admin_ports_client = cls.os_adm.ports_client
+ cls.admin_floating_ips_client = cls.os_adm.floating_ips_client
@classmethod
def create_metering_label(cls, name, description):
diff --git a/tempest/api/network/test_allowed_address_pair.py b/tempest/api/network/test_allowed_address_pair.py
index 5d7f00e..394aec1 100644
--- a/tempest/api/network/test_allowed_address_pair.py
+++ b/tempest/api/network/test_allowed_address_pair.py
@@ -23,9 +23,9 @@
class AllowedAddressPairTestJSON(base.BaseNetworkTest):
- """
- Tests the Neutron Allowed Address Pair API extension using the Tempest
- ReST client. The following API operations are tested with this extension:
+ """Tests the Neutron Allowed Address Pair API extension
+
+ The following API operations are tested with this extension:
create port
list ports
@@ -60,14 +60,14 @@
# Create port with allowed address pair attribute
allowed_address_pairs = [{'ip_address': self.ip_address,
'mac_address': self.mac_address}]
- body = self.client.create_port(
+ body = self.ports_client.create_port(
network_id=self.network['id'],
allowed_address_pairs=allowed_address_pairs)
port_id = body['port']['id']
- self.addCleanup(self.client.delete_port, port_id)
+ self.addCleanup(self.ports_client.delete_port, port_id)
# Confirm port was created with allowed address pair attribute
- body = self.client.list_ports()
+ body = self.ports_client.list_ports()
ports = body['ports']
port = [p for p in ports if p['id'] == port_id]
msg = 'Created port not found in list of ports returned by Neutron'
@@ -76,9 +76,9 @@
def _update_port_with_address(self, address, mac_address=None, **kwargs):
# Create a port without allowed address pair
- body = self.client.create_port(network_id=self.network['id'])
+ body = self.ports_client.create_port(network_id=self.network['id'])
port_id = body['port']['id']
- self.addCleanup(self.client.delete_port, port_id)
+ self.addCleanup(self.ports_client.delete_port, port_id)
if mac_address is None:
mac_address = self.mac_address
@@ -87,7 +87,7 @@
'mac_address': mac_address}]
if kwargs:
allowed_address_pairs.append(kwargs['allowed_address_pairs'])
- body = self.client.update_port(
+ body = self.ports_client.update_port(
port_id, allowed_address_pairs=allowed_address_pairs)
allowed_address_pair = body['port']['allowed_address_pairs']
self.assertEqual(allowed_address_pair, allowed_address_pairs)
@@ -106,9 +106,9 @@
@test.idempotent_id('b3f20091-6cd5-472b-8487-3516137df933')
def test_update_port_with_multiple_ip_mac_address_pair(self):
# Create an ip _address and mac_address through port create
- resp = self.client.create_port(network_id=self.network['id'])
+ resp = self.ports_client.create_port(network_id=self.network['id'])
newportid = resp['port']['id']
- self.addCleanup(self.client.delete_port, newportid)
+ self.addCleanup(self.ports_client.delete_port, newportid)
ipaddress = resp['port']['fixed_ips'][0]['ip_address']
macaddress = resp['port']['mac_address']
diff --git a/tempest/api/network/test_dhcp_ipv6.py b/tempest/api/network/test_dhcp_ipv6.py
index f8c64ed..74c1d51 100644
--- a/tempest/api/network/test_dhcp_ipv6.py
+++ b/tempest/api/network/test_dhcp_ipv6.py
@@ -63,7 +63,7 @@
del things_list[index]
def _clean_network(self):
- body = self.client.list_ports()
+ body = self.ports_client.list_ports()
ports = body['ports']
for port in ports:
if (port['device_owner'].startswith('network:router_interface')
@@ -73,13 +73,13 @@
)
else:
if port['id'] in [p['id'] for p in self.ports]:
- self.client.delete_port(port['id'])
+ self.ports_client.delete_port(port['id'])
self._remove_from_list_by_index(self.ports, port)
- body = self.client.list_subnets()
+ body = self.subnets_client.list_subnets()
subnets = body['subnets']
for subnet in subnets:
if subnet['id'] in [s['id'] for s in self.subnets]:
- self.client.delete_subnet(subnet['id'])
+ self.subnets_client.delete_subnet(subnet['id'])
self._remove_from_list_by_index(self.subnets, subnet)
body = self.client.list_routers()
routers = body['routers']
@@ -99,10 +99,9 @@
@test.idempotent_id('e5517e62-6f16-430d-a672-f80875493d4c')
def test_dhcpv6_stateless_eui64(self):
- """When subnets configured with RAs SLAAC (AOM=100) and DHCP stateless
- (AOM=110) both for radvd and dnsmasq, port shall receive IP address
- calculated from its MAC.
- """
+ # NOTE: When subnets configured with RAs SLAAC (AOM=100) and DHCP
+ # stateless (AOM=110) both for radvd and dnsmasq, port shall receive
+ # IP address calculated from its MAC.
for ra_mode, add_mode in (
('slaac', 'slaac'),
('dhcpv6-stateless', 'dhcpv6-stateless'),
@@ -118,10 +117,9 @@
@test.idempotent_id('ae2f4a5d-03ff-4c42-a3b0-ce2fcb7ea832')
def test_dhcpv6_stateless_no_ra(self):
- """When subnets configured with dnsmasq SLAAC and DHCP stateless
- and there is no radvd, port shall receive IP address calculated
- from its MAC and mask of subnet.
- """
+ # NOTE: When subnets configured with dnsmasq SLAAC and DHCP stateless
+ # and there is no radvd, port shall receive IP address calculated
+ # from its MAC and mask of subnet.
for ra_mode, add_mode in (
(None, 'slaac'),
(None, 'dhcpv6-stateless'),
@@ -158,9 +156,8 @@
@test.idempotent_id('21635b6f-165a-4d42-bf49-7d195e47342f')
def test_dhcpv6_stateless_no_ra_no_dhcp(self):
- """If no radvd option and no dnsmasq option is configured
- port shall receive IP from fixed IPs list of subnet.
- """
+ # NOTE: If no radvd option and no dnsmasq option is configured
+ # port shall receive IP from fixed IPs list of subnet.
real_ip, eui_ip = self._get_ips_from_subnet()
self._clean_network()
self.assertNotEqual(eui_ip, real_ip,
@@ -171,11 +168,10 @@
@test.idempotent_id('4544adf7-bb5f-4bdc-b769-b3e77026cef2')
def test_dhcpv6_two_subnets(self):
- """When one IPv6 subnet configured with dnsmasq SLAAC or DHCP stateless
- and other IPv6 is with DHCP stateful, port shall receive EUI-64 IP
- addresses from first subnet and DHCP address from second one.
- Order of subnet creating should be unimportant.
- """
+ # NOTE: When one IPv6 subnet configured with dnsmasq SLAAC or DHCP
+ # stateless and other IPv6 is with DHCP stateful, port shall receive
+ # EUI-64 IP addresses from first subnet and DHCP address from second
+ # one. Order of subnet creating should be unimportant.
for order in ("slaac_first", "dhcp_first"):
for ra_mode, add_mode in (
('slaac', 'slaac'),
@@ -203,9 +199,9 @@
real_dhcp_ip, real_eui_ip = [real_ips[sub['id']]
for sub in [subnet_dhcp,
subnet_slaac]]
- self.client.delete_port(port['id'])
+ self.ports_client.delete_port(port['id'])
self.ports.pop()
- body = self.client.list_ports()
+ body = self.ports_client.list_ports()
ports_id_list = [i['id'] for i in body['ports']]
self.assertNotIn(port['id'], ports_id_list)
self._clean_network()
@@ -221,11 +217,10 @@
@test.idempotent_id('4256c61d-c538-41ea-9147-3c450c36669e')
def test_dhcpv6_64_subnets(self):
- """When one IPv6 subnet configured with dnsmasq SLAAC or DHCP stateless
- and other IPv4 is with DHCP of IPv4, port shall receive EUI-64 IP
- addresses from first subnet and IPv4 DHCP address from second one.
- Order of subnet creating should be unimportant.
- """
+ # NOTE: When one IPv6 subnet configured with dnsmasq SLAAC or DHCP
+ # stateless and other IPv4 is with DHCP of IPv4, port shall receive
+ # EUI-64 IP addresses from first subnet and IPv4 DHCP address from
+ # second one. Order of subnet creating should be unimportant.
for order in ("slaac_first", "dhcp_first"):
for ra_mode, add_mode in (
('slaac', 'slaac'),
@@ -265,9 +260,8 @@
@test.idempotent_id('4ab211a0-276f-4552-9070-51e27f58fecf')
def test_dhcp_stateful(self):
- """With all options below, DHCPv6 shall allocate address
- from subnet pool to port.
- """
+ # NOTE: With all options below, DHCPv6 shall allocate address from
+ # subnet pool to port.
for ra_mode, add_mode in (
('dhcpv6-stateful', 'dhcpv6-stateful'),
('dhcpv6-stateful', None),
@@ -287,10 +281,9 @@
@test.idempotent_id('51a5e97f-f02e-4e4e-9a17-a69811d300e3')
def test_dhcp_stateful_fixedips(self):
- """With all options below, port shall be able to get
- requested IP from fixed IP range not depending on
- DHCP stateful (not SLAAC!) settings configured.
- """
+ # NOTE: With all options below, port shall be able to get
+ # requested IP from fixed IP range not depending on
+ # DHCP stateful (not SLAAC!) settings configured.
for ra_mode, add_mode in (
('dhcpv6-stateful', 'dhcpv6-stateful'),
('dhcpv6-stateful', None),
@@ -316,9 +309,8 @@
@test.idempotent_id('98244d88-d990-4570-91d4-6b25d70d08af')
def test_dhcp_stateful_fixedips_outrange(self):
- """When port gets IP address from fixed IP range it
- shall be checked if it's from subnets range.
- """
+ # NOTE: When port gets IP address from fixed IP range it
+ # shall be checked if it's from subnets range.
kwargs = {'ipv6_ra_mode': 'dhcpv6-stateful',
'ipv6_address_mode': 'dhcpv6-stateful'}
subnet = self.create_subnet(self.network, **kwargs)
@@ -334,9 +326,8 @@
@test.idempotent_id('57b8302b-cba9-4fbb-8835-9168df029051')
def test_dhcp_stateful_fixedips_duplicate(self):
- """When port gets IP address from fixed IP range it
- shall be checked if it's not duplicate.
- """
+ # NOTE: When port gets IP address from fixed IP range it
+ # shall be checked if it's not duplicate.
kwargs = {'ipv6_ra_mode': 'dhcpv6-stateful',
'ipv6_address_mode': 'dhcpv6-stateful'}
subnet = self.create_subnet(self.network, **kwargs)
@@ -362,14 +353,13 @@
admin_state_up=True)
port = self.create_router_interface(router['id'],
subnet['id'])
- body = self.client.show_port(port['port_id'])
+ body = self.ports_client.show_port(port['port_id'])
return subnet, body['port']
@test.idempotent_id('e98f65db-68f4-4330-9fea-abd8c5192d4d')
def test_dhcp_stateful_router(self):
- """With all options below the router interface shall
- receive DHCPv6 IP address from allocation pool.
- """
+ # NOTE: With all options below the router interface shall
+ # receive DHCPv6 IP address from allocation pool.
for ra_mode, add_mode in (
('dhcpv6-stateful', 'dhcpv6-stateful'),
('dhcpv6-stateful', None),
diff --git a/tempest/api/network/test_extensions.py b/tempest/api/network/test_extensions.py
index d6b03eb..b83d2b0 100644
--- a/tempest/api/network/test_extensions.py
+++ b/tempest/api/network/test_extensions.py
@@ -19,10 +19,7 @@
class ExtensionsTestJSON(base.BaseNetworkTest):
-
- """
- Tests the following operations in the Neutron API using the REST client for
- Neutron:
+ """Tests the following operations in the Neutron API:
List all available extensions
diff --git a/tempest/api/network/test_extra_dhcp_options.py b/tempest/api/network/test_extra_dhcp_options.py
index 87e3413..062bc69 100644
--- a/tempest/api/network/test_extra_dhcp_options.py
+++ b/tempest/api/network/test_extra_dhcp_options.py
@@ -19,9 +19,7 @@
class ExtraDHCPOptionsTestJSON(base.BaseNetworkTest):
- """
- Tests the following operations with the Extra DHCP Options Neutron API
- extension:
+ """Tests the following operations with the Extra DHCP Options:
port create
port list
@@ -59,14 +57,14 @@
@test.idempotent_id('d2c17063-3767-4a24-be4f-a23dbfa133c9')
def test_create_list_port_with_extra_dhcp_options(self):
# Create a port with Extra DHCP Options
- body = self.client.create_port(
+ body = self.ports_client.create_port(
network_id=self.network['id'],
extra_dhcp_opts=self.extra_dhcp_opts)
port_id = body['port']['id']
- self.addCleanup(self.client.delete_port, port_id)
+ self.addCleanup(self.ports_client.delete_port, port_id)
# Confirm port created has Extra DHCP Options
- body = self.client.list_ports()
+ body = self.ports_client.list_ports()
ports = body['ports']
port = [p for p in ports if p['id'] == port_id]
self.assertTrue(port)
@@ -76,12 +74,12 @@
def test_update_show_port_with_extra_dhcp_options(self):
# Update port with extra dhcp options
name = data_utils.rand_name('new-port-name')
- body = self.client.update_port(
+ body = self.ports_client.update_port(
self.port['id'],
name=name,
extra_dhcp_opts=self.extra_dhcp_opts)
# Confirm extra dhcp options were added to the port
- body = self.client.show_port(self.port['id'])
+ body = self.ports_client.show_port(self.port['id'])
self._confirm_extra_dhcp_options(body['port'], self.extra_dhcp_opts)
def _confirm_extra_dhcp_options(self, port, extra_dhcp_opts):
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index 4b4a4e2..ce9c4be 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -24,9 +24,7 @@
class FloatingIPTestJSON(base.BaseNetworkTest):
- """
- Tests the following operations in the Neutron API using the REST client for
- Neutron:
+ """Tests the following operations in the Neutron API:
Create a Floating IP
Update a Floating IP
@@ -70,11 +68,11 @@
@test.idempotent_id('62595970-ab1c-4b7f-8fcc-fddfe55e8718')
def test_create_list_show_update_delete_floating_ip(self):
# Creates a floating IP
- body = self.client.create_floatingip(
+ body = self.floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id,
port_id=self.ports[0]['id'])
created_floating_ip = body['floatingip']
- self.addCleanup(self.client.delete_floatingip,
+ self.addCleanup(self.floating_ips_client.delete_floatingip,
created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['tenant_id'])
@@ -85,7 +83,8 @@
self.assertIn(created_floating_ip['fixed_ip_address'],
[ip['ip_address'] for ip in self.ports[0]['fixed_ips']])
# Verifies the details of a floating_ip
- floating_ip = self.client.show_floatingip(created_floating_ip['id'])
+ floating_ip = self.floating_ips_client.show_floatingip(
+ created_floating_ip['id'])
shown_floating_ip = floating_ip['floatingip']
self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
self.assertEqual(shown_floating_ip['floating_network_id'],
@@ -97,13 +96,13 @@
self.assertEqual(shown_floating_ip['port_id'], self.ports[0]['id'])
# Verify the floating ip exists in the list of all floating_ips
- floating_ips = self.client.list_floatingips()
+ floating_ips = self.floating_ips_client.list_floatingips()
floatingip_id_list = list()
for f in floating_ips['floatingips']:
floatingip_id_list.append(f['id'])
self.assertIn(created_floating_ip['id'], floatingip_id_list)
# Associate floating IP to the other port
- floating_ip = self.client.update_floatingip(
+ floating_ip = self.floating_ips_client.update_floatingip(
created_floating_ip['id'],
port_id=self.ports[1]['id'])
updated_floating_ip = floating_ip['floatingip']
@@ -113,7 +112,7 @@
self.assertEqual(updated_floating_ip['router_id'], self.router['id'])
# Disassociate floating IP from the port
- floating_ip = self.client.update_floatingip(
+ floating_ip = self.floating_ips_client.update_floatingip(
created_floating_ip['id'],
port_id=None)
updated_floating_ip = floating_ip['floatingip']
@@ -124,21 +123,22 @@
@test.idempotent_id('e1f6bffd-442f-4668-b30e-df13f2705e77')
def test_floating_ip_delete_port(self):
# Create a floating IP
- body = self.client.create_floatingip(
+ body = self.floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id)
created_floating_ip = body['floatingip']
- self.addCleanup(self.client.delete_floatingip,
+ self.addCleanup(self.floating_ips_client.delete_floatingip,
created_floating_ip['id'])
# Create a port
- port = self.client.create_port(network_id=self.network['id'])
+ port = self.ports_client.create_port(network_id=self.network['id'])
created_port = port['port']
- floating_ip = self.client.update_floatingip(
+ floating_ip = self.floating_ips_client.update_floatingip(
created_floating_ip['id'],
port_id=created_port['id'])
# Delete port
- self.client.delete_port(created_port['id'])
+ self.ports_client.delete_port(created_port['id'])
# Verifies the details of the floating_ip
- floating_ip = self.client.show_floatingip(created_floating_ip['id'])
+ floating_ip = self.floating_ips_client.show_floatingip(
+ created_floating_ip['id'])
shown_floating_ip = floating_ip['floatingip']
# Confirm the fields are back to None
self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
@@ -149,11 +149,11 @@
@test.idempotent_id('1bb2f731-fe5a-4b8c-8409-799ade1bed4d')
def test_floating_ip_update_different_router(self):
# Associate a floating IP to a port on a router
- body = self.client.create_floatingip(
+ body = self.floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id,
port_id=self.ports[1]['id'])
created_floating_ip = body['floatingip']
- self.addCleanup(self.client.delete_floatingip,
+ self.addCleanup(self.floating_ips_client.delete_floatingip,
created_floating_ip['id'])
self.assertEqual(created_floating_ip['router_id'], self.router['id'])
network2 = self.create_network()
@@ -163,7 +163,7 @@
self.create_router_interface(router2['id'], subnet2['id'])
port_other_router = self.create_port(network2)
# Associate floating IP to the other port on another router
- floating_ip = self.client.update_floatingip(
+ floating_ip = self.floating_ips_client.update_floatingip(
created_floating_ip['id'],
port_id=port_other_router['id'])
updated_floating_ip = floating_ip['floatingip']
@@ -175,17 +175,17 @@
@test.attr(type='smoke')
@test.idempotent_id('36de4bd0-f09c-43e3-a8e1-1decc1ffd3a5')
def test_create_floating_ip_specifying_a_fixed_ip_address(self):
- body = self.client.create_floatingip(
+ body = self.floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id,
port_id=self.ports[1]['id'],
fixed_ip_address=self.ports[1]['fixed_ips'][0]['ip_address'])
created_floating_ip = body['floatingip']
- self.addCleanup(self.client.delete_floatingip,
+ self.addCleanup(self.floating_ips_client.delete_floatingip,
created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['id'])
self.assertEqual(created_floating_ip['fixed_ip_address'],
self.ports[1]['fixed_ips'][0]['ip_address'])
- floating_ip = self.client.update_floatingip(
+ floating_ip = self.floating_ips_client.update_floatingip(
created_floating_ip['id'],
port_id=None)
self.assertIsNone(floating_ip['floatingip']['port_id'])
@@ -197,23 +197,24 @@
list_ips = [str(ip) for ip in ips[-3:-1]]
fixed_ips = [{'ip_address': list_ips[0]}, {'ip_address': list_ips[1]}]
# Create port
- body = self.client.create_port(network_id=self.network['id'],
- fixed_ips=fixed_ips)
+ body = self.ports_client.create_port(network_id=self.network['id'],
+ fixed_ips=fixed_ips)
port = body['port']
- self.addCleanup(self.client.delete_port, port['id'])
+ self.addCleanup(self.ports_client.delete_port, port['id'])
# Create floating ip
- body = self.client.create_floatingip(
+ body = self.floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id,
port_id=port['id'],
fixed_ip_address=list_ips[0])
floating_ip = body['floatingip']
- self.addCleanup(self.client.delete_floatingip, floating_ip['id'])
+ self.addCleanup(self.floating_ips_client.delete_floatingip,
+ floating_ip['id'])
self.assertIsNotNone(floating_ip['id'])
self.assertEqual(floating_ip['fixed_ip_address'], list_ips[0])
# Update floating ip
- body = self.client.update_floatingip(floating_ip['id'],
- port_id=port['id'],
- fixed_ip_address=list_ips[1])
+ body = self.floating_ips_client.update_floatingip(
+ floating_ip['id'], port_id=port['id'],
+ fixed_ip_address=list_ips[1])
update_floating_ip = body['floatingip']
self.assertEqual(update_floating_ip['fixed_ip_address'],
list_ips[1])
diff --git a/tempest/api/network/test_floating_ips_negative.py b/tempest/api/network/test_floating_ips_negative.py
index e8624d8..f915615 100644
--- a/tempest/api/network/test_floating_ips_negative.py
+++ b/tempest/api/network/test_floating_ips_negative.py
@@ -25,8 +25,7 @@
class FloatingIPNegativeTestJSON(base.BaseNetworkTest):
- """
- Test the following negative operations for floating ips:
+ """Test the following negative operations for floating ips:
Create floatingip with a port that is unreachable to external network
Create floatingip in private network
@@ -54,17 +53,17 @@
@test.attr(type=['negative'])
@test.idempotent_id('22996ea8-4a81-4b27-b6e1-fa5df92fa5e8')
def test_create_floatingip_with_port_ext_net_unreachable(self):
- self.assertRaises(lib_exc.NotFound, self.client.create_floatingip,
- floating_network_id=self.ext_net_id,
- port_id=self.port['id'],
- fixed_ip_address=self.port['fixed_ips'][0]
- ['ip_address'])
+ self.assertRaises(
+ lib_exc.NotFound, self.floating_ips_client.create_floatingip,
+ floating_network_id=self.ext_net_id, port_id=self.port['id'],
+ fixed_ip_address=self.port['fixed_ips'][0]
+ ['ip_address'])
@test.attr(type=['negative'])
@test.idempotent_id('50b9aeb4-9f0b-48ee-aa31-fa955a48ff54')
def test_create_floatingip_in_private_network(self):
self.assertRaises(lib_exc.BadRequest,
- self.client.create_floatingip,
+ self.floating_ips_client.create_floatingip,
floating_network_id=self.network['id'],
port_id=self.port['id'],
fixed_ip_address=self.port['fixed_ips'][0]
@@ -74,12 +73,13 @@
@test.idempotent_id('6b3b8797-6d43-4191-985c-c48b773eb429')
def test_associate_floatingip_port_ext_net_unreachable(self):
# Create floating ip
- body = self.client.create_floatingip(
+ body = self.floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id)
floating_ip = body['floatingip']
- self.addCleanup(self.client.delete_floatingip, floating_ip['id'])
+ self.addCleanup(
+ self.floating_ips_client.delete_floatingip, floating_ip['id'])
# Associate floating IP to the other port
- self.assertRaises(lib_exc.NotFound, self.client.update_floatingip,
- floating_ip['id'], port_id=self.port['id'],
- fixed_ip_address=self.port['fixed_ips'][0]
- ['ip_address'])
+ self.assertRaises(
+ lib_exc.NotFound, self.floating_ips_client.update_floatingip,
+ floating_ip['id'], port_id=self.port['id'],
+ fixed_ip_address=self.port['fixed_ips'][0]['ip_address'])
diff --git a/tempest/api/network/test_metering_extensions.py b/tempest/api/network/test_metering_extensions.py
index ee0dcb0..a213f92 100644
--- a/tempest/api/network/test_metering_extensions.py
+++ b/tempest/api/network/test_metering_extensions.py
@@ -23,9 +23,7 @@
class MeteringTestJSON(base.BaseAdminNetworkTest):
- """
- Tests the following operations in the Neutron API using the REST client for
- Neutron:
+ """Tests the following operations in the Neutron API:
List, Show, Create, Delete Metering labels
List, Show, Create, Delete Metering labels rules
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index 1116573..a266142 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -28,9 +28,7 @@
class NetworksTest(base.BaseNetworkTest):
- """
- Tests the following operations in the Neutron API using the REST client for
- Neutron:
+ """Tests the following operations in the Neutron API:
create a network for a tenant
list tenant's networks
@@ -95,9 +93,8 @@
@classmethod
def _create_subnet_with_last_subnet_block(cls, network, ip_version):
- """Derive last subnet CIDR block from tenant CIDR and
- create the subnet with that derived CIDR
- """
+ # Derive last subnet CIDR block from tenant CIDR and
+ # create the subnet with that derived CIDR
if ip_version == 4:
cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
mask_bits = CONF.network.tenant_network_mask_bits
@@ -133,9 +130,8 @@
return [{'start': str(gateway + 2), 'end': str(gateway + 3)}]
def subnet_dict(self, include_keys):
- """Return a subnet dict which has include_keys and their corresponding
- value from self._subnet_data
- """
+ # Return a subnet dict which has include_keys and their corresponding
+ # value from self._subnet_data
return dict((key, self._subnet_data[self._ip_version][key])
for key in include_keys)
@@ -146,7 +142,7 @@
def _delete_network(self, network):
# Deleting network also deletes its subnets if exists
- self.client.delete_network(network['id'])
+ self.networks_client.delete_network(network['id'])
if network in self.networks:
self.networks.remove(network)
for subnet in self.subnets:
@@ -171,7 +167,7 @@
del subnet['dns_nameservers'], compare_args['dns_nameservers']
self._compare_resource_attrs(subnet, compare_args)
- self.client.delete_network(net_id)
+ self.networks_client.delete_network(net_id)
self.networks.pop()
self.subnets.pop()
@@ -186,7 +182,7 @@
self.assertEqual('ACTIVE', network['status'])
# Verify network update
new_name = "New_network"
- body = self.client.update_network(net_id, name=new_name)
+ body = self.networks_client.update_network(net_id, name=new_name)
updated_net = body['network']
self.assertEqual(updated_net['name'], new_name)
# Find a cidr that is not in use yet and create a subnet with it
@@ -194,7 +190,7 @@
subnet_id = subnet['id']
# Verify subnet update
new_name = "New_subnet"
- body = self.client.update_subnet(subnet_id, name=new_name)
+ body = self.subnets_client.update_subnet(subnet_id, name=new_name)
updated_subnet = body['subnet']
self.assertEqual(updated_subnet['name'], new_name)
@@ -202,7 +198,7 @@
@test.idempotent_id('2bf13842-c93f-4a69-83ed-717d2ec3b44e')
def test_show_network(self):
# Verify the details of a network
- body = self.client.show_network(self.network['id'])
+ body = self.networks_client.show_network(self.network['id'])
network = body['network']
for key in ['id', 'name']:
self.assertEqual(network[key], self.network[key])
@@ -211,8 +207,8 @@
def test_show_network_fields(self):
# Verify specific fields of a network
fields = ['id', 'name']
- body = self.client.show_network(self.network['id'],
- fields=fields)
+ body = self.networks_client.show_network(self.network['id'],
+ fields=fields)
network = body['network']
self.assertEqual(sorted(network.keys()), sorted(fields))
for field_name in fields:
@@ -222,7 +218,7 @@
@test.idempotent_id('f7ffdeda-e200-4a7a-bcbe-05716e86bf43')
def test_list_networks(self):
# Verify the network exists in the list of all networks
- body = self.client.list_networks()
+ body = self.networks_client.list_networks()
networks = [network['id'] for network in body['networks']
if network['id'] == self.network['id']]
self.assertNotEmpty(networks, "Created network not found in the list")
@@ -231,7 +227,7 @@
def test_list_networks_fields(self):
# Verify specific fields of the networks
fields = ['id', 'name']
- body = self.client.list_networks(fields=fields)
+ body = self.networks_client.list_networks(fields=fields)
networks = body['networks']
self.assertNotEmpty(networks, "Network list returned is empty")
for network in networks:
@@ -241,7 +237,7 @@
@test.idempotent_id('bd635d81-6030-4dd1-b3b9-31ba0cfdf6cc')
def test_show_subnet(self):
# Verify the details of a subnet
- body = self.client.show_subnet(self.subnet['id'])
+ body = self.subnets_client.show_subnet(self.subnet['id'])
subnet = body['subnet']
self.assertNotEmpty(subnet, "Subnet returned has no fields")
for key in ['id', 'cidr']:
@@ -252,8 +248,8 @@
def test_show_subnet_fields(self):
# Verify specific fields of a subnet
fields = ['id', 'network_id']
- body = self.client.show_subnet(self.subnet['id'],
- fields=fields)
+ body = self.subnets_client.show_subnet(self.subnet['id'],
+ fields=fields)
subnet = body['subnet']
self.assertEqual(sorted(subnet.keys()), sorted(fields))
for field_name in fields:
@@ -263,7 +259,7 @@
@test.idempotent_id('db68ba48-f4ea-49e9-81d1-e367f6d0b20a')
def test_list_subnets(self):
# Verify the subnet exists in the list of all subnets
- body = self.client.list_subnets()
+ body = self.subnets_client.list_subnets()
subnets = [subnet['id'] for subnet in body['subnets']
if subnet['id'] == self.subnet['id']]
self.assertNotEmpty(subnets, "Created subnet not found in the list")
@@ -272,7 +268,7 @@
def test_list_subnets_fields(self):
# Verify specific fields of subnets
fields = ['id', 'network_id']
- body = self.client.list_subnets(fields=fields)
+ body = self.subnets_client.list_subnets(fields=fields)
subnets = body['subnets']
self.assertNotEmpty(subnets, "Subnet list returned is empty")
for subnet in subnets:
@@ -281,7 +277,7 @@
def _try_delete_network(self, net_id):
# delete network, if it exists
try:
- self.client.delete_network(net_id)
+ self.networks_client.delete_network(net_id)
# if network is not found, this means it was deleted in the test
except lib_exc.NotFound:
pass
@@ -290,7 +286,7 @@
def test_delete_network_with_subnet(self):
# Creates a network
name = data_utils.rand_name('network-')
- body = self.client.create_network(name=name)
+ body = self.networks_client.create_network(name=name)
network = body['network']
net_id = network['id']
self.addCleanup(self._try_delete_network, net_id)
@@ -300,10 +296,10 @@
subnet_id = subnet['id']
# Delete network while the subnet still exists
- body = self.client.delete_network(net_id)
+ body = self.networks_client.delete_network(net_id)
# Verify that the subnet got automatically deleted.
- self.assertRaises(lib_exc.NotFound, self.client.show_subnet,
+ self.assertRaises(lib_exc.NotFound, self.subnets_client.show_subnet,
subnet_id)
# Since create_subnet adds the subnet to the delete list, and it is
@@ -362,8 +358,8 @@
'gateway_ip': new_gateway, 'enable_dhcp': True}
new_name = "New_subnet"
- body = self.client.update_subnet(subnet_id, name=new_name,
- **kwargs)
+ body = self.subnets_client.update_subnet(subnet_id, name=new_name,
+ **kwargs)
updated_subnet = body['subnet']
kwargs['name'] = new_name
self.assertEqual(sorted(updated_subnet['dns_nameservers']),
@@ -382,7 +378,7 @@
@test.idempotent_id('af774677-42a9-4e4b-bb58-16fe6a5bc1ec')
def test_external_network_visibility(self):
"""Verifies user can see external networks but not subnets."""
- body = self.client.list_networks(**{'router:external': True})
+ body = self.networks_client.list_networks(**{'router:external': True})
networks = [network['id'] for network in body['networks']]
self.assertNotEmpty(networks, "No external networks found")
@@ -398,16 +394,14 @@
# subnets_iter is a list (iterator) of lists. This flattens it to a
# list of UUIDs
public_subnets_iter = itertools.chain(*subnets_iter)
- body = self.client.list_subnets()
+ body = self.subnets_client.list_subnets()
subnets = [sub['id'] for sub in body['subnets']
if sub['id'] in public_subnets_iter]
self.assertEmpty(subnets, "Public subnets visible")
class BulkNetworkOpsTestJSON(base.BaseNetworkTest):
- """
- Tests the following operations in the Neutron API using the REST client for
- Neutron:
+ """Tests the following operations in the Neutron API:
bulk network creation
bulk subnet creation
@@ -426,27 +420,27 @@
def _delete_networks(self, created_networks):
for n in created_networks:
- self.client.delete_network(n['id'])
+ self.networks_client.delete_network(n['id'])
# Asserting that the networks are not found in the list after deletion
- body = self.client.list_networks()
+ body = self.networks_client.list_networks()
networks_list = [network['id'] for network in body['networks']]
for n in created_networks:
self.assertNotIn(n['id'], networks_list)
def _delete_subnets(self, created_subnets):
for n in created_subnets:
- self.client.delete_subnet(n['id'])
+ self.subnets_client.delete_subnet(n['id'])
# Asserting that the subnets are not found in the list after deletion
- body = self.client.list_subnets()
+ body = self.subnets_client.list_subnets()
subnets_list = [subnet['id'] for subnet in body['subnets']]
for n in created_subnets:
self.assertNotIn(n['id'], subnets_list)
def _delete_ports(self, created_ports):
for n in created_ports:
- self.client.delete_port(n['id'])
+ self.ports_client.delete_port(n['id'])
# Asserting that the ports are not found in the list after deletion
- body = self.client.list_ports()
+ body = self.ports_client.list_ports()
ports_list = [port['id'] for port in body['ports']]
for n in created_ports:
self.assertNotIn(n['id'], ports_list)
@@ -461,7 +455,7 @@
created_networks = body['networks']
self.addCleanup(self._delete_networks, created_networks)
# Asserting that the networks are found in the list after creation
- body = self.client.list_networks()
+ body = self.networks_client.list_networks()
networks_list = [network['id'] for network in body['networks']]
for n in created_networks:
self.assertIsNotNone(n['id'])
@@ -496,7 +490,7 @@
created_subnets = body['subnets']
self.addCleanup(self._delete_subnets, created_subnets)
# Asserting that the subnets are found in the list after creation
- body = self.client.list_subnets()
+ body = self.subnets_client.list_subnets()
subnets_list = [subnet['id'] for subnet in body['subnets']]
for n in created_subnets:
self.assertIsNotNone(n['id'])
@@ -522,7 +516,7 @@
created_ports = body['ports']
self.addCleanup(self._delete_ports, created_ports)
# Asserting that the ports are found in the list after creation
- body = self.client.list_ports()
+ body = self.ports_client.list_ports()
ports_list = [port['id'] for port in body['ports']]
for n in created_ports:
self.assertIsNotNone(n['id'])
@@ -576,7 +570,7 @@
# Verifies Subnet GW is None in IPv4
self.assertEqual(subnet2['gateway_ip'], None)
# Verifies all 2 subnets in the same network
- body = self.client.list_subnets()
+ body = self.subnets_client.list_subnets()
subnets = [sub['id'] for sub in body['subnets']
if sub['network_id'] == network['id']]
test_subnet_ids = [sub['id'] for sub in (subnet1, subnet2)]
@@ -621,16 +615,16 @@
'ipv6_address_mode': mode})
port = self.create_port(slaac_network)
self.assertIsNotNone(port['fixed_ips'][0]['ip_address'])
- self.client.delete_subnet(subnet_slaac['id'])
+ self.subnets_client.delete_subnet(subnet_slaac['id'])
self.subnets.pop()
- subnets = self.client.list_subnets()
+ subnets = self.subnets_client.list_subnets()
subnet_ids = [subnet['id'] for subnet in subnets['subnets']]
self.assertNotIn(subnet_slaac['id'], subnet_ids,
"Subnet wasn't deleted")
self.assertRaisesRegexp(
lib_exc.Conflict,
"There are one or more ports still in use on the network",
- self.client.delete_network,
+ self.networks_client.delete_network,
slaac_network['id'])
@test.idempotent_id('88554555-ebf8-41ef-9300-4926d45e06e9')
diff --git a/tempest/api/network/test_networks_negative.py b/tempest/api/network/test_networks_negative.py
index 94c3f9a..0ef96a6 100644
--- a/tempest/api/network/test_networks_negative.py
+++ b/tempest/api/network/test_networks_negative.py
@@ -27,42 +27,44 @@
@test.idempotent_id('9293e937-824d-42d2-8d5b-e985ea67002a')
def test_show_non_existent_network(self):
non_exist_id = data_utils.rand_uuid()
- self.assertRaises(lib_exc.NotFound, self.client.show_network,
+ self.assertRaises(lib_exc.NotFound, self.networks_client.show_network,
non_exist_id)
@test.attr(type=['negative'])
@test.idempotent_id('d746b40c-5e09-4043-99f7-cba1be8b70df')
def test_show_non_existent_subnet(self):
non_exist_id = data_utils.rand_uuid()
- self.assertRaises(lib_exc.NotFound, self.client.show_subnet,
+ self.assertRaises(lib_exc.NotFound, self.subnets_client.show_subnet,
non_exist_id)
@test.attr(type=['negative'])
@test.idempotent_id('a954861d-cbfd-44e8-b0a9-7fab111f235d')
def test_show_non_existent_port(self):
non_exist_id = data_utils.rand_uuid()
- self.assertRaises(lib_exc.NotFound, self.client.show_port,
+ self.assertRaises(lib_exc.NotFound, self.ports_client.show_port,
non_exist_id)
@test.attr(type=['negative'])
@test.idempotent_id('98bfe4e3-574e-4012-8b17-b2647063de87')
def test_update_non_existent_network(self):
non_exist_id = data_utils.rand_uuid()
- self.assertRaises(lib_exc.NotFound, self.client.update_network,
- non_exist_id, name="new_name")
+ self.assertRaises(
+ lib_exc.NotFound, self.networks_client.update_network,
+ non_exist_id, name="new_name")
@test.attr(type=['negative'])
@test.idempotent_id('03795047-4a94-4120-a0a1-bd376e36fd4e')
def test_delete_non_existent_network(self):
non_exist_id = data_utils.rand_uuid()
- self.assertRaises(lib_exc.NotFound, self.client.delete_network,
+ self.assertRaises(lib_exc.NotFound,
+ self.networks_client.delete_network,
non_exist_id)
@test.attr(type=['negative'])
@test.idempotent_id('1cc47884-ac52-4415-a31c-e7ce5474a868')
def test_update_non_existent_subnet(self):
non_exist_id = data_utils.rand_uuid()
- self.assertRaises(lib_exc.NotFound, self.client.update_subnet,
+ self.assertRaises(lib_exc.NotFound, self.subnets_client.update_subnet,
non_exist_id, name='new_name')
@test.attr(type=['negative'])
@@ -70,20 +72,21 @@
def test_delete_non_existent_subnet(self):
non_exist_id = data_utils.rand_uuid()
self.assertRaises(lib_exc.NotFound,
- self.client.delete_subnet, non_exist_id)
+ self.subnets_client.delete_subnet, non_exist_id)
@test.attr(type=['negative'])
@test.idempotent_id('13d3b106-47e6-4b9b-8d53-dae947f092fe')
def test_create_port_on_non_existent_network(self):
non_exist_net_id = data_utils.rand_uuid()
self.assertRaises(lib_exc.NotFound,
- self.client.create_port, network_id=non_exist_net_id)
+ self.ports_client.create_port,
+ network_id=non_exist_net_id)
@test.attr(type=['negative'])
@test.idempotent_id('cf8eef21-4351-4f53-adcd-cc5cb1e76b92')
def test_update_non_existent_port(self):
non_exist_port_id = data_utils.rand_uuid()
- self.assertRaises(lib_exc.NotFound, self.client.update_port,
+ self.assertRaises(lib_exc.NotFound, self.ports_client.update_port,
non_exist_port_id, name='new_name')
@test.attr(type=['negative'])
@@ -91,4 +94,4 @@
def test_delete_non_existent_port(self):
non_exist_port_id = data_utils.rand_uuid()
self.assertRaises(lib_exc.NotFound,
- self.client.delete_port, non_exist_port_id)
+ self.ports_client.delete_port, non_exist_port_id)
diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py
index 6a8fbec..43da1c4 100644
--- a/tempest/api/network/test_ports.py
+++ b/tempest/api/network/test_ports.py
@@ -28,8 +28,7 @@
class PortsTestJSON(sec_base.BaseSecGroupTest):
- """
- Test the following operations for ports:
+ """Test the following operations for ports:
port create
port delete
@@ -45,8 +44,8 @@
cls.port = cls.create_port(cls.network)
def _delete_port(self, port_id):
- self.client.delete_port(port_id)
- body = self.client.list_ports()
+ self.ports_client.delete_port(port_id)
+ body = self.ports_client.list_ports()
ports_list = body['ports']
self.assertFalse(port_id in [n['id'] for n in ports_list])
@@ -54,16 +53,16 @@
@test.idempotent_id('c72c1c0c-2193-4aca-aaa4-b1442640f51c')
def test_create_update_delete_port(self):
# Verify port creation
- body = self.client.create_port(network_id=self.network['id'])
+ body = self.ports_client.create_port(network_id=self.network['id'])
port = body['port']
# Schedule port deletion with verification upon test completion
self.addCleanup(self._delete_port, port['id'])
self.assertTrue(port['admin_state_up'])
# Verify port update
new_name = "New_Port"
- body = self.client.update_port(port['id'],
- name=new_name,
- admin_state_up=False)
+ body = self.ports_client.update_port(port['id'],
+ name=new_name,
+ admin_state_up=False)
updated_port = body['port']
self.assertEqual(updated_port['name'], new_name)
self.assertFalse(updated_port['admin_state_up'])
@@ -106,9 +105,9 @@
allocation_pools = {'allocation_pools': [{'start': str(address + 4),
'end': str(address + 6)}]}
subnet = self.create_subnet(network, **allocation_pools)
- self.addCleanup(self.client.delete_subnet, subnet['id'])
- body = self.client.create_port(network_id=net_id)
- self.addCleanup(self.client.delete_port, body['port']['id'])
+ self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
+ body = self.ports_client.create_port(network_id=net_id)
+ self.addCleanup(self.ports_client.delete_port, body['port']['id'])
port = body['port']
ip_address = port['fixed_ips'][0]['ip_address']
start_ip_address = allocation_pools['allocation_pools'][0]['start']
@@ -120,7 +119,7 @@
@test.idempotent_id('c9a685bd-e83f-499c-939f-9f7863ca259f')
def test_show_port(self):
# Verify the details of port
- body = self.client.show_port(self.port['id'])
+ body = self.ports_client.show_port(self.port['id'])
port = body['port']
self.assertIn('id', port)
# TODO(Santosh)- This is a temporary workaround to compare create_port
@@ -134,8 +133,8 @@
def test_show_port_fields(self):
# Verify specific fields of a port
fields = ['id', 'mac_address']
- body = self.client.show_port(self.port['id'],
- fields=fields)
+ body = self.ports_client.show_port(self.port['id'],
+ fields=fields)
port = body['port']
self.assertEqual(sorted(port.keys()), sorted(fields))
for field_name in fields:
@@ -145,7 +144,7 @@
@test.idempotent_id('cf95b358-3e92-4a29-a148-52445e1ac50e')
def test_list_ports(self):
# Verify the port exists in the list of all ports
- body = self.client.list_ports()
+ body = self.ports_client.list_ports()
ports = [port['id'] for port in body['ports']
if port['id'] == self.port['id']]
self.assertNotEmpty(ports, "Created port not found in the list")
@@ -155,41 +154,49 @@
# Create network and subnet
network = self.create_network()
subnet = self.create_subnet(network)
- self.addCleanup(self.client.delete_subnet, subnet['id'])
+ self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
# Create two ports
- port_1 = self.client.create_port(network_id=network['id'])
- self.addCleanup(self.client.delete_port, port_1['port']['id'])
- port_2 = self.client.create_port(network_id=network['id'])
- self.addCleanup(self.client.delete_port, port_2['port']['id'])
+ port_1 = self.ports_client.create_port(network_id=network['id'])
+ self.addCleanup(self.ports_client.delete_port, port_1['port']['id'])
+ port_2 = self.ports_client.create_port(network_id=network['id'])
+ self.addCleanup(self.ports_client.delete_port, port_2['port']['id'])
# List ports filtered by fixed_ips
port_1_fixed_ip = port_1['port']['fixed_ips'][0]['ip_address']
fixed_ips = 'ip_address=' + port_1_fixed_ip
- port_list = self.client.list_ports(fixed_ips=fixed_ips)
+ port_list = self.ports_client.list_ports(fixed_ips=fixed_ips)
# Check that we got the desired port
ports = port_list['ports']
- self.assertEqual(len(ports), 1)
- self.assertEqual(ports[0]['id'], port_1['port']['id'])
- self.assertEqual(ports[0]['fixed_ips'][0]['ip_address'],
- port_1_fixed_ip)
- self.assertEqual(ports[0]['network_id'], network['id'])
+ tenant_ids = set([port['tenant_id'] for port in ports])
+ self.assertEqual(len(tenant_ids), 1,
+ 'Ports from multiple tenants are in the list resp')
+ port_ids = [port['id'] for port in ports]
+ fixed_ips = [port['fixed_ips'] for port in ports]
+ port_ips = []
+ for addr in fixed_ips:
+ port_ips.extend([port['ip_address'] for port in addr])
+
+ port_net_ids = [port['network_id'] for port in ports]
+ self.assertIn(port_1['port']['id'], port_ids)
+ self.assertIn(port_1_fixed_ip, port_ips)
+ self.assertIn(network['id'], port_net_ids)
@test.idempotent_id('5ad01ed0-0e6e-4c5d-8194-232801b15c72')
def test_port_list_filter_by_router_id(self):
# Create a router
network = self.create_network()
- self.addCleanup(self.client.delete_network, network['id'])
+ self.addCleanup(self.networks_client.delete_network, network['id'])
subnet = self.create_subnet(network)
- self.addCleanup(self.client.delete_subnet, subnet['id'])
+ self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
router = self.create_router(data_utils.rand_name('router-'))
self.addCleanup(self.client.delete_router, router['id'])
- port = self.client.create_port(network_id=network['id'])
+ port = self.ports_client.create_port(network_id=network['id'])
# Add router interface to port created above
self.client.add_router_interface_with_port_id(
router['id'], port['port']['id'])
self.addCleanup(self.client.remove_router_interface_with_port_id,
router['id'], port['port']['id'])
# List ports filtered by router_id
- port_list = self.client.list_ports(device_id=router['id'])
+ port_list = self.ports_client.list_ports(device_id=router['id'])
ports = port_list['ports']
self.assertEqual(len(ports), 1)
self.assertEqual(ports[0]['id'], port['port']['id'])
@@ -199,7 +206,7 @@
def test_list_ports_fields(self):
# Verify specific fields of ports
fields = ['id', 'mac_address']
- body = self.client.list_ports(fields=fields)
+ body = self.ports_client.list_ports(fields=fields)
ports = body['ports']
self.assertNotEmpty(ports, "Port list returned is empty")
# Asserting the fields returned are correct
@@ -210,11 +217,11 @@
def test_create_update_port_with_second_ip(self):
# Create a network with two subnets
network = self.create_network()
- self.addCleanup(self.client.delete_network, network['id'])
+ self.addCleanup(self.networks_client.delete_network, network['id'])
subnet_1 = self.create_subnet(network)
- self.addCleanup(self.client.delete_subnet, subnet_1['id'])
+ self.addCleanup(self.subnets_client.delete_subnet, subnet_1['id'])
subnet_2 = self.create_subnet(network)
- self.addCleanup(self.client.delete_subnet, subnet_2['id'])
+ self.addCleanup(self.subnets_client.delete_subnet, subnet_2['id'])
fixed_ip_1 = [{'subnet_id': subnet_1['id']}]
fixed_ip_2 = [{'subnet_id': subnet_2['id']}]
@@ -223,7 +230,7 @@
# Create a port with multiple IP addresses
port = self.create_port(network,
fixed_ips=fixed_ips)
- self.addCleanup(self.client.delete_port, port['id'])
+ self.addCleanup(self.ports_client.delete_port, port['id'])
self.assertEqual(2, len(port['fixed_ips']))
check_fixed_ips = [subnet_1['id'], subnet_2['id']]
for item in port['fixed_ips']:
@@ -239,7 +246,7 @@
def _update_port_with_security_groups(self, security_groups_names):
subnet_1 = self.create_subnet(self.network)
- self.addCleanup(self.client.delete_subnet, subnet_1['id'])
+ self.addCleanup(self.subnets_client.delete_subnet, subnet_1['id'])
fixed_ip_1 = [{'subnet_id': subnet_1['id']}]
security_groups_list = list()
@@ -261,8 +268,8 @@
"network_id": self.network['id'],
"admin_state_up": True,
"fixed_ips": fixed_ip_1}
- body = self.client.create_port(**post_body)
- self.addCleanup(self.client.delete_port, body['port']['id'])
+ body = self.ports_client.create_port(**post_body)
+ self.addCleanup(self.ports_client.delete_port, body['port']['id'])
port = body['port']
# Update the port with security groups
@@ -272,7 +279,7 @@
"admin_state_up": False,
"fixed_ips": fixed_ip_2,
"security_groups": security_groups_list}
- body = self.client.update_port(port['id'], **update_body)
+ body = self.ports_client.update_port(port['id'], **update_body)
port_show = body['port']
# Verify the security groups and other attributes updated to port
exclude_keys = set(port_show).symmetric_difference(update_body)
@@ -300,16 +307,16 @@
@test.idempotent_id('13e95171-6cbd-489c-9d7c-3f9c58215c18')
def test_create_show_delete_port_user_defined_mac(self):
# Create a port for a legal mac
- body = self.client.create_port(network_id=self.network['id'])
+ body = self.ports_client.create_port(network_id=self.network['id'])
old_port = body['port']
free_mac_address = old_port['mac_address']
- self.client.delete_port(old_port['id'])
+ self.ports_client.delete_port(old_port['id'])
# Create a new port with user defined mac
- body = self.client.create_port(network_id=self.network['id'],
- mac_address=free_mac_address)
- self.addCleanup(self.client.delete_port, body['port']['id'])
+ body = self.ports_client.create_port(network_id=self.network['id'],
+ mac_address=free_mac_address)
+ self.addCleanup(self.ports_client.delete_port, body['port']['id'])
port = body['port']
- body = self.client.show_port(port['id'])
+ body = self.ports_client.show_port(port['id'])
show_port = body['port']
self.assertEqual(free_mac_address,
show_port['mac_address'])
@@ -318,11 +325,11 @@
@test.idempotent_id('4179dcb9-1382-4ced-84fe-1b91c54f5735')
def test_create_port_with_no_securitygroups(self):
network = self.create_network()
- self.addCleanup(self.client.delete_network, network['id'])
+ self.addCleanup(self.networks_client.delete_network, network['id'])
subnet = self.create_subnet(network)
- self.addCleanup(self.client.delete_subnet, subnet['id'])
+ self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
port = self.create_port(network, security_groups=[])
- self.addCleanup(self.client.delete_port, port['id'])
+ self.addCleanup(self.ports_client.delete_port, port['id'])
self.assertIsNotNone(port['security_groups'])
self.assertEmpty(port['security_groups'])
@@ -344,9 +351,9 @@
def test_create_port_binding_ext_attr(self):
post_body = {"network_id": self.network['id'],
"binding:host_id": self.host_id}
- body = self.admin_client.create_port(**post_body)
+ body = self.admin_ports_client.create_port(**post_body)
port = body['port']
- self.addCleanup(self.admin_client.delete_port, port['id'])
+ self.addCleanup(self.admin_ports_client.delete_port, port['id'])
host_id = port['binding:host_id']
self.assertIsNotNone(host_id)
self.assertEqual(self.host_id, host_id)
@@ -354,11 +361,11 @@
@test.idempotent_id('6f6c412c-711f-444d-8502-0ac30fbf5dd5')
def test_update_port_binding_ext_attr(self):
post_body = {"network_id": self.network['id']}
- body = self.admin_client.create_port(**post_body)
+ body = self.admin_ports_client.create_port(**post_body)
port = body['port']
- self.addCleanup(self.admin_client.delete_port, port['id'])
+ self.addCleanup(self.admin_ports_client.delete_port, port['id'])
update_body = {"binding:host_id": self.host_id}
- body = self.admin_client.update_port(port['id'], **update_body)
+ body = self.admin_ports_client.update_port(port['id'], **update_body)
updated_port = body['port']
host_id = updated_port['binding:host_id']
self.assertIsNotNone(host_id)
@@ -368,18 +375,18 @@
def test_list_ports_binding_ext_attr(self):
# Create a new port
post_body = {"network_id": self.network['id']}
- body = self.admin_client.create_port(**post_body)
+ body = self.admin_ports_client.create_port(**post_body)
port = body['port']
- self.addCleanup(self.admin_client.delete_port, port['id'])
+ self.addCleanup(self.admin_ports_client.delete_port, port['id'])
# Update the port's binding attributes so that is now 'bound'
# to a host
update_body = {"binding:host_id": self.host_id}
- self.admin_client.update_port(port['id'], **update_body)
+ self.admin_ports_client.update_port(port['id'], **update_body)
# List all ports, ensure new port is part of list and its binding
# attributes are set and accurate
- body = self.admin_client.list_ports()
+ body = self.admin_ports_client.list_ports()
ports_list = body['ports']
pids_list = [p['id'] for p in ports_list]
self.assertIn(port['id'], pids_list)
@@ -391,10 +398,11 @@
@test.idempotent_id('b54ac0ff-35fc-4c79-9ca3-c7dbd4ea4f13')
def test_show_port_binding_ext_attr(self):
- body = self.admin_client.create_port(network_id=self.network['id'])
+ body = self.admin_ports_client.create_port(
+ network_id=self.network['id'])
port = body['port']
- self.addCleanup(self.admin_client.delete_port, port['id'])
- body = self.admin_client.show_port(port['id'])
+ self.addCleanup(self.admin_ports_client.delete_port, port['id'])
+ body = self.admin_ports_client.show_port(port['id'])
show_port = body['port']
self.assertEqual(port['binding:host_id'],
show_port['binding:host_id'])
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index ca5a868..ed191b6 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -144,7 +144,7 @@
self.assertIn('subnet_id', interface.keys())
self.assertIn('port_id', interface.keys())
# Verify router id is equal to device id in port details
- show_port_body = self.client.show_port(
+ show_port_body = self.ports_client.show_port(
interface['port_id'])
self.assertEqual(show_port_body['port']['device_id'],
router['id'])
@@ -155,7 +155,7 @@
network = self.create_network()
self.create_subnet(network)
router = self._create_router(data_utils.rand_name('router-'))
- port_body = self.client.create_port(
+ port_body = self.ports_client.create_port(
network_id=network['id'])
# add router interface to port created above
interface = self.client.add_router_interface_with_port_id(
@@ -165,7 +165,7 @@
self.assertIn('subnet_id', interface.keys())
self.assertIn('port_id', interface.keys())
# Verify router id is equal to device id in port details
- show_port_body = self.client.show_port(
+ show_port_body = self.ports_client.show_port(
interface['port_id'])
self.assertEqual(show_port_body['port']['device_id'],
router['id'])
@@ -181,14 +181,14 @@
self.assertEqual(v, actual_ext_gw_info[k])
def _verify_gateway_port(self, router_id):
- list_body = self.admin_client.list_ports(
+ list_body = self.admin_ports_client.list_ports(
network_id=CONF.network.public_network_id,
device_id=router_id)
self.assertEqual(len(list_body['ports']), 1)
gw_port = list_body['ports'][0]
fixed_ips = gw_port['fixed_ips']
self.assertGreaterEqual(len(fixed_ips), 1)
- public_net_body = self.admin_client.show_network(
+ public_net_body = self.admin_networks_client.show_network(
CONF.network.public_network_id)
public_subnet_id = public_net_body['network']['subnets'][0]
self.assertIn(public_subnet_id,
@@ -245,7 +245,7 @@
self.client.update_router(router['id'], external_gateway_info={})
self._verify_router_gateway(router['id'])
# No gateway port expected
- list_body = self.admin_client.list_ports(
+ list_body = self.admin_ports_client.list_ports(
network_id=CONF.network.public_network_id,
device_id=router['id'])
self.assertFalse(list_body['ports'])
@@ -357,7 +357,7 @@
interface02['port_id'])
def _verify_router_interface(self, router_id, subnet_id, port_id):
- show_port_body = self.client.show_port(port_id)
+ show_port_body = self.ports_client.show_port(port_id)
interface_port = show_port_body['port']
self.assertEqual(router_id, interface_port['device_id'])
self.assertEqual(subnet_id,
diff --git a/tempest/api/network/test_subnetpools_extensions.py b/tempest/api/network/test_subnetpools_extensions.py
new file mode 100644
index 0000000..8a61ff8
--- /dev/null
+++ b/tempest/api/network/test_subnetpools_extensions.py
@@ -0,0 +1,76 @@
+# Copyright 2015 GlobalLogic. 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 tempest.api.network import base
+from tempest.common.utils import data_utils
+from tempest import config
+from tempest import test
+from tempest_lib import exceptions as lib_exc
+
+CONF = config.CONF
+
+
+class SubnetPoolsTestJSON(base.BaseNetworkTest):
+ """Tests the following operations in the subnetpools API:
+
+ Create a subnet pool.
+ Update a subnet pool.
+ Delete a subnet pool.
+ Lists subnet pool.
+ Show subnet pool details.
+
+ v2.0 of the Neutron API is assumed. It is assumed that subnetpools
+ options mentioned in the [network-feature-enabled] section and
+ default_network option mentioned in the [network] section of
+ etc/tempest.conf:
+
+ """
+
+ @classmethod
+ def skip_checks(cls):
+ super(SubnetPoolsTestJSON, cls).skip_checks()
+ if not test.is_extension_enabled('subnetpools', 'network'):
+ msg = "subnet pools extension not enabled."
+ raise cls.skipException(msg)
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('62595970-ab1c-4b7f-8fcc-fddfe55e9811')
+ def test_create_list_show_update_delete_subnetpools(self):
+ subnetpool_name = data_utils.rand_name('subnetpools')
+ # create subnet pool
+ prefix = CONF.network.default_network
+ body = self.client.create_subnetpools(name=subnetpool_name,
+ prefixes=prefix)
+ subnetpool_id = body["subnetpool"]["id"]
+ self.addCleanup(self._cleanup_subnetpools, subnetpool_id)
+ self.assertEqual(subnetpool_name, body["subnetpool"]["name"])
+ # get detail about subnet pool
+ body = self.client.show_subnetpools(subnetpool_id)
+ self.assertEqual(subnetpool_name, body["subnetpool"]["name"])
+ # update the subnet pool
+ subnetpool_name = data_utils.rand_name('subnetpools_update')
+ body = self.client.update_subnetpools(subnetpool_id,
+ name=subnetpool_name)
+ self.assertEqual(subnetpool_name, body["subnetpool"]["name"])
+ # delete subnet pool
+ body = self.client.delete_subnetpools(subnetpool_id)
+ self.assertRaises(lib_exc.NotFound, self.client.show_subnetpools,
+ subnetpool_id)
+
+ def _cleanup_subnetpools(self, subnetpool_id):
+ # this is used to cleanup the resources
+ try:
+ self.client.delete_subnetpools(subnetpool_id)
+ except lib_exc.NotFound:
+ pass
diff --git a/tempest/api/object_storage/base.py b/tempest/api/object_storage/base.py
index 41a7d65..2621581 100644
--- a/tempest/api/object_storage/base.py
+++ b/tempest/api/object_storage/base.py
@@ -90,10 +90,8 @@
pass
def assertHeaders(self, resp, target, method):
- """
- Common method to check the existence and the format of common response
- headers
- """
+ """Check the existence and the format of response headers"""
+
self.assertThat(resp, custom_matchers.ExistsAllResponseHeaders(
target, method))
self.assertThat(resp, custom_matchers.AreAllWellFormatted())
diff --git a/tempest/api/object_storage/test_account_quotas.py b/tempest/api/object_storage/test_account_quotas.py
index 78707d8..0f6a330 100644
--- a/tempest/api/object_storage/test_account_quotas.py
+++ b/tempest/api/object_storage/test_account_quotas.py
@@ -92,8 +92,7 @@
@test.idempotent_id('63f51f9f-5f1d-4fc6-b5be-d454d70949d6')
@test.requires_ext(extension='account_quotas', service='object')
def test_admin_modify_quota(self):
- """Test that the ResellerAdmin is able to modify and remove the quota
- on a user's account.
+ """Test ResellerAdmin can modify/remove the quota on a user's account
Using the account client, the test modifies the quota
successively to:
diff --git a/tempest/api/object_storage/test_account_quotas_negative.py b/tempest/api/object_storage/test_account_quotas_negative.py
index 2bf331a..aee17d3 100644
--- a/tempest/api/object_storage/test_account_quotas_negative.py
+++ b/tempest/api/object_storage/test_account_quotas_negative.py
@@ -83,9 +83,7 @@
@test.idempotent_id('d1dc5076-555e-4e6d-9697-28f1fe976324')
@test.requires_ext(extension='account_quotas', service='object')
def test_user_modify_quota(self):
- """Test that a user is not able to modify or remove a quota on
- its account.
- """
+ """Test that a user cannot modify or remove a quota on its account."""
# Not able to remove quota
self.assertRaises(lib_exc.Forbidden,
diff --git a/tempest/api/object_storage/test_container_quotas.py b/tempest/api/object_storage/test_container_quotas.py
index c78b4c3..896352b 100644
--- a/tempest/api/object_storage/test_container_quotas.py
+++ b/tempest/api/object_storage/test_container_quotas.py
@@ -26,7 +26,7 @@
class ContainerQuotasTest(base.BaseObjectTest):
- """Attemps to test the perfect behavior of quotas in a container."""
+ """Attempts to test the perfect behavior of quotas in a container."""
def setUp(self):
"""Creates and sets a container with quotas.
diff --git a/tempest/api/object_storage/test_container_staticweb.py b/tempest/api/object_storage/test_container_staticweb.py
index 4b4b499..18593f3 100644
--- a/tempest/api/object_storage/test_container_staticweb.py
+++ b/tempest/api/object_storage/test_container_staticweb.py
@@ -28,7 +28,7 @@
cls.container_name = data_utils.rand_name(name="TestContainer")
# This header should be posted on the container before every test
- cls.headers_public_read_acl = {'Read': '.r:*'}
+ cls.headers_public_read_acl = {'Read': '.r:*,.rlistings'}
# Create test container and create one object in it
cls.container_client.create_container(cls.container_name)
diff --git a/tempest/api/object_storage/test_object_services.py b/tempest/api/object_storage/test_object_services.py
index d64efee..e8b035b 100644
--- a/tempest/api/object_storage/test_object_services.py
+++ b/tempest/api/object_storage/test_object_services.py
@@ -545,7 +545,7 @@
self.assertTrue(resp['etag'].strip('\"').isalnum())
self.assertTrue(re.match("^\d+\.?\d*\Z", resp['x-timestamp']))
self.assertNotEqual(len(resp['content-type']), 0)
- self.assertTrue(re.match("^tx[0-9a-f]*-[0-9a-f]*$",
+ self.assertTrue(re.match("^tx[0-9a-f]{21}-[0-9a-f]{10}.*",
resp['x-trans-id']))
self.assertNotEqual(len(resp['date']), 0)
self.assertEqual(resp['accept-ranges'], 'bytes')
@@ -637,7 +637,7 @@
self.assertTrue(resp['etag'].strip('\"').isalnum())
self.assertTrue(re.match("^\d+\.?\d*\Z", resp['x-timestamp']))
self.assertNotEqual(len(resp['content-type']), 0)
- self.assertTrue(re.match("^tx[0-9a-f]*-[0-9a-f]*$",
+ self.assertTrue(re.match("^tx[0-9a-f]{21}-[0-9a-f]{10}.*",
resp['x-trans-id']))
self.assertNotEqual(len(resp['date']), 0)
self.assertEqual(resp['accept-ranges'], 'bytes')
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index 5b6b0fa..4968835 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -50,9 +50,15 @@
cls.servers_client = cls.os.servers_client
cls.keypairs_client = cls.os.keypairs_client
cls.network_client = cls.os.network_client
+ cls.networks_client = cls.os.networks_client
cls.volumes_client = cls.os.volumes_client
cls.images_v2_client = cls.os.image_client_v2
+ if CONF.volume_feature_enabled.api_v2:
+ cls.volumes_client = cls.os.volumes_v2_client
+ else:
+ cls.volumes_client = cls.os.volumes_client
+
@classmethod
def resource_setup(cls):
super(BaseOrchestrationTest, cls).resource_setup()
diff --git a/tempest/api/orchestration/stacks/test_neutron_resources.py b/tempest/api/orchestration/stacks/test_neutron_resources.py
index 8f1f0d6..a614c76 100644
--- a/tempest/api/orchestration/stacks/test_neutron_resources.py
+++ b/tempest/api/orchestration/stacks/test_neutron_resources.py
@@ -16,7 +16,7 @@
import netaddr
from tempest.api.orchestration import base
-from tempest import clients
+from tempest.common import credentials_factory as credentials
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
@@ -38,12 +38,14 @@
@classmethod
def setup_credentials(cls):
super(NeutronResourcesTestJSON, cls).setup_credentials()
- cls.os = clients.Manager()
+ cls.os = credentials.ConfiguredUserManager()
@classmethod
def setup_clients(cls):
super(NeutronResourcesTestJSON, cls).setup_clients()
cls.network_client = cls.os.network_client
+ cls.subnets_client = cls.os.subnets_client
+ cls.ports_client = cls.os.ports_client
@classmethod
def resource_setup(cls):
@@ -118,7 +120,7 @@
def test_created_network(self):
"""Verifies created network."""
network_id = self.test_resources.get('Network')['physical_resource_id']
- body = self.network_client.show_network(network_id)
+ body = self.networks_client.show_network(network_id)
network = body['network']
self.assertIsInstance(network, dict)
self.assertEqual(network_id, network['id'])
@@ -130,7 +132,7 @@
def test_created_subnet(self):
"""Verifies created subnet."""
subnet_id = self.test_resources.get('Subnet')['physical_resource_id']
- body = self.network_client.show_subnet(subnet_id)
+ body = self.subnets_client.show_subnet(subnet_id)
subnet = body['subnet']
network_id = self.test_resources.get('Network')['physical_resource_id']
self.assertEqual(subnet_id, subnet['id'])
@@ -163,7 +165,7 @@
router_id = self.test_resources.get('Router')['physical_resource_id']
network_id = self.test_resources.get('Network')['physical_resource_id']
subnet_id = self.test_resources.get('Subnet')['physical_resource_id']
- body = self.network_client.list_ports()
+ body = self.ports_client.list_ports()
ports = body['ports']
router_ports = filter(lambda port: port['device_id'] ==
router_id, ports)
diff --git a/tempest/api/orchestration/stacks/test_non_empty_stack.py b/tempest/api/orchestration/stacks/test_non_empty_stack.py
index e37587c..4bc2c17 100644
--- a/tempest/api/orchestration/stacks/test_non_empty_stack.py
+++ b/tempest/api/orchestration/stacks/test_non_empty_stack.py
@@ -91,8 +91,7 @@
@test.idempotent_id('c951d55e-7cce-4c1f-83a0-bad735437fa6')
def test_list_resources(self):
- """Getting list of created resources for the stack should be possible.
- """
+ """Get list of created resources for the stack should be possible."""
resources = self.list_resources(self.stack_identifier)
self.assertEqual({self.resource_name: self.resource_type}, resources)
diff --git a/tempest/api/orchestration/stacks/test_volumes.py b/tempest/api/orchestration/stacks/test_volumes.py
index 4ba38ad..ae9a411 100644
--- a/tempest/api/orchestration/stacks/test_volumes.py
+++ b/tempest/api/orchestration/stacks/test_volumes.py
@@ -38,10 +38,19 @@
self.assertEqual('available', volume.get('status'))
self.assertEqual(template['resources']['volume']['properties'][
'size'], volume.get('size'))
+
+ # Some volume properties have been renamed with Cinder v2
+ if CONF.volume_feature_enabled.api_v2:
+ description_field = 'description'
+ name_field = 'name'
+ else:
+ description_field = 'display_description'
+ name_field = 'display_name'
+
self.assertEqual(template['resources']['volume']['properties'][
- 'description'], volume.get('display_description'))
+ 'description'], volume.get(description_field))
self.assertEqual(template['resources']['volume']['properties'][
- 'name'], volume.get('display_name'))
+ 'name'], volume.get(name_field))
def _outputs_verify(self, stack_identifier, template):
self.assertEqual('available',
diff --git a/tempest/api/telemetry/base.py b/tempest/api/telemetry/base.py
index 8f07614..bbd01f0 100644
--- a/tempest/api/telemetry/base.py
+++ b/tempest/api/telemetry/base.py
@@ -61,18 +61,9 @@
cls.glance_v2_notifications = ['image.download', 'image.serve']
cls.server_ids = []
- cls.alarm_ids = []
cls.image_ids = []
@classmethod
- def create_alarm(cls, **kwargs):
- body = cls.telemetry_client.create_alarm(
- name=data_utils.rand_name('telemetry_alarm'),
- type='threshold', **kwargs)
- cls.alarm_ids.append(body['alarm_id'])
- return body
-
- @classmethod
def create_server(cls):
tenant_network = cls.get_tenant_network()
body, server = compute.create_test_server(
@@ -106,14 +97,13 @@
@classmethod
def resource_cleanup(cls):
- cls.cleanup_resources(cls.telemetry_client.delete_alarm, cls.alarm_ids)
cls.cleanup_resources(cls.servers_client.delete_server, cls.server_ids)
cls.cleanup_resources(cls.image_client.delete_image, cls.image_ids)
super(BaseTelemetryTest, cls).resource_cleanup()
def await_samples(self, metric, query):
- """
- This method is to wait for sample to add it to database.
+ """This method is to wait for sample to add it to database.
+
There are long time delays when using Postgresql (or Mysql)
database as ceilometer backend
"""
@@ -153,3 +143,46 @@
raise exceptions.TimeoutException(
'Event with query:%s has not been added to the '
'database within %d seconds' % (query, CONF.compute.build_timeout))
+
+
+class BaseAlarmingTest(tempest.test.BaseTestCase):
+ """Base test case class for all Alarming API tests."""
+
+ credentials = ['primary']
+
+ @classmethod
+ def skip_checks(cls):
+ super(BaseAlarmingTest, cls).skip_checks()
+ if not CONF.service_available.aodh:
+ raise cls.skipException("Aodh support is required")
+
+ @classmethod
+ def setup_clients(cls):
+ super(BaseAlarmingTest, cls).setup_clients()
+ cls.alarming_client = cls.os.alarming_client
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseAlarmingTest, cls).resource_setup()
+ cls.alarm_ids = []
+
+ @classmethod
+ def create_alarm(cls, **kwargs):
+ body = cls.alarming_client.create_alarm(
+ name=data_utils.rand_name('telemetry_alarm'),
+ type='threshold', **kwargs)
+ cls.alarm_ids.append(body['alarm_id'])
+ return body
+
+ @staticmethod
+ def cleanup_resources(method, list_of_ids):
+ for resource_id in list_of_ids:
+ try:
+ method(resource_id)
+ except lib_exc.NotFound:
+ pass
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.cleanup_resources(cls.alarming_client.delete_alarm, cls.alarm_ids)
+ super(BaseAlarmingTest, cls).resource_cleanup()
diff --git a/tempest/api/telemetry/test_telemetry_alarming_api.py b/tempest/api/telemetry/test_alarming_api.py
similarity index 80%
rename from tempest/api/telemetry/test_telemetry_alarming_api.py
rename to tempest/api/telemetry/test_alarming_api.py
index 6c84b98..daa0939 100644
--- a/tempest/api/telemetry/test_telemetry_alarming_api.py
+++ b/tempest/api/telemetry/test_alarming_api.py
@@ -17,7 +17,7 @@
from tempest import test
-class TelemetryAlarmingAPITestJSON(base.BaseTelemetryTest):
+class TelemetryAlarmingAPITestJSON(base.BaseAlarmingTest):
@classmethod
def resource_setup(cls):
@@ -32,7 +32,7 @@
@test.idempotent_id('1c918e06-210b-41eb-bd45-14676dd77cd6')
def test_alarm_list(self):
# List alarms
- alarm_list = self.telemetry_client.list_alarms()
+ alarm_list = self.alarming_client.list_alarms()
# Verify created alarm in the list
fetched_ids = [a['alarm_id'] for a in alarm_list]
@@ -46,7 +46,7 @@
def test_create_update_get_delete_alarm(self):
# Create an alarm
alarm_name = data_utils.rand_name('telemetry_alarm')
- body = self.telemetry_client.create_alarm(
+ body = self.alarming_client.create_alarm(
name=alarm_name, type='threshold', threshold_rule=self.rule)
self.assertEqual(alarm_name, body['name'])
alarm_id = body['alarm_id']
@@ -57,7 +57,7 @@
'threshold': 70.0,
'period': 60}
alarm_name_updated = data_utils.rand_name('telemetry-alarm-update')
- body = self.telemetry_client.update_alarm(
+ body = self.alarming_client.update_alarm(
alarm_id,
threshold_rule=new_rule,
name=alarm_name_updated,
@@ -65,19 +65,19 @@
self.assertEqual(alarm_name_updated, body['name'])
self.assertDictContainsSubset(new_rule, body['threshold_rule'])
# Get and verify details of an alarm after update
- body = self.telemetry_client.show_alarm(alarm_id)
+ body = self.alarming_client.show_alarm(alarm_id)
self.assertEqual(alarm_name_updated, body['name'])
self.assertDictContainsSubset(new_rule, body['threshold_rule'])
# Get history for the alarm and verify the same
- body = self.telemetry_client.show_alarm_history(alarm_id)
+ body = self.alarming_client.show_alarm_history(alarm_id)
self.assertEqual("rule change", body[0]['type'])
self.assertIn(alarm_name_updated, body[0]['detail'])
self.assertEqual("creation", body[1]['type'])
self.assertIn(alarm_name, body[1]['detail'])
# Delete alarm and verify if deleted
- self.telemetry_client.delete_alarm(alarm_id)
+ self.alarming_client.delete_alarm(alarm_id)
self.assertRaises(lib_exc.NotFound,
- self.telemetry_client.show_alarm, alarm_id)
+ self.alarming_client.show_alarm, alarm_id)
@test.idempotent_id('aca49486-70bb-4016-87e0-f6131374f741')
def test_set_get_alarm_state(self):
@@ -86,11 +86,11 @@
# Set alarm state and verify
new_state =\
[elem for elem in alarm_states if elem != alarm['state']][0]
- state = self.telemetry_client.alarm_set_state(alarm['alarm_id'],
- new_state)
+ state = self.alarming_client.alarm_set_state(alarm['alarm_id'],
+ new_state)
self.assertEqual(new_state, state.data)
# Get alarm state and verify
- state = self.telemetry_client.show_alarm_state(alarm['alarm_id'])
+ state = self.alarming_client.show_alarm_state(alarm['alarm_id'])
self.assertEqual(new_state, state.data)
@test.idempotent_id('08d7e45a-1344-4e5c-ba6f-f6cbb77f55b9')
@@ -99,13 +99,13 @@
"operator": "or"}
# Verifies alarm create
alarm_name = data_utils.rand_name('combination_alarm')
- body = self.telemetry_client.create_alarm(name=alarm_name,
- combination_rule=rule,
- type='combination')
+ body = self.alarming_client.create_alarm(name=alarm_name,
+ combination_rule=rule,
+ type='combination')
self.assertEqual(alarm_name, body['name'])
alarm_id = body['alarm_id']
self.assertDictContainsSubset(rule, body['combination_rule'])
# Verify alarm delete
- self.telemetry_client.delete_alarm(alarm_id)
+ self.alarming_client.delete_alarm(alarm_id)
self.assertRaises(lib_exc.NotFound,
- self.telemetry_client.show_alarm, alarm_id)
+ self.alarming_client.show_alarm, alarm_id)
diff --git a/tempest/api/telemetry/test_alarming_api_negative.py b/tempest/api/telemetry/test_alarming_api_negative.py
new file mode 100644
index 0000000..e945556
--- /dev/null
+++ b/tempest/api/telemetry/test_alarming_api_negative.py
@@ -0,0 +1,71 @@
+# Copyright 2015 GlobalLogic. 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 tempest.api.telemetry import base
+from tempest.common.utils import data_utils
+from tempest import test
+from tempest_lib import exceptions as lib_exc
+
+import uuid
+
+
+class TelemetryAlarmingNegativeTest(base.BaseAlarmingTest):
+ """Negative tests for show_alarm, update_alarm, show_alarm_history tests
+
+ ** show non-existent alarm
+ ** show the deleted alarm
+ ** delete deleted alarm
+ ** update deleted alarm
+ """
+
+ @test.attr(type=['negative'])
+ @test.idempotent_id('668743d5-08ad-4480-b2b8-15da34f81e7d')
+ def test_get_non_existent_alarm(self):
+ # get the non-existent alarm
+ non_existent_id = str(uuid.uuid4())
+ self.assertRaises(lib_exc.NotFound, self.alarming_client.show_alarm,
+ non_existent_id)
+
+ @test.attr(type=['negative'])
+ @test.idempotent_id('ef45000d-0a72-4781-866d-4cb7bf2582ad')
+ def test_get_update_show_history_delete_deleted_alarm(self):
+ # get, update and delete the deleted alarm
+ alarm_name = data_utils.rand_name('telemetry_alarm')
+ rule = {'meter_name': 'cpu',
+ 'comparison_operator': 'eq',
+ 'threshold': 100.0,
+ 'period': 90}
+ body = self.alarming_client.create_alarm(
+ name=alarm_name,
+ type='threshold',
+ threshold_rule=rule)
+ alarm_id = body['alarm_id']
+ self.alarming_client.delete_alarm(alarm_id)
+ # get the deleted alarm
+ self.assertRaises(lib_exc.NotFound, self.alarming_client.show_alarm,
+ alarm_id)
+
+ # update the deleted alarm
+ updated_alarm_name = data_utils.rand_name('telemetry_alarm_updated')
+ updated_rule = {'meter_name': 'cpu_new',
+ 'comparison_operator': 'eq',
+ 'threshold': 70,
+ 'period': 50}
+ self.assertRaises(lib_exc.NotFound, self.alarming_client.update_alarm,
+ alarm_id, threshold_rule=updated_rule,
+ name=updated_alarm_name,
+ type='threshold')
+ # delete the deleted alarm
+ self.assertRaises(lib_exc.NotFound, self.alarming_client.delete_alarm,
+ alarm_id)
diff --git a/tempest/api/volume/admin/test_volume_quotas_negative.py b/tempest/api/volume/admin/test_volume_quotas_negative.py
index d1a6db0..9185553 100644
--- a/tempest/api/volume/admin/test_volume_quotas_negative.py
+++ b/tempest/api/volume/admin/test_volume_quotas_negative.py
@@ -16,8 +16,11 @@
from tempest_lib import exceptions as lib_exc
from tempest.api.volume import base
+from tempest import config
from tempest import test
+CONF = config.CONF
+
class BaseVolumeQuotasNegativeV2TestJSON(base.BaseVolumeAdminTest):
force_tenant_isolation = True
@@ -31,11 +34,11 @@
def resource_setup(cls):
super(BaseVolumeQuotasNegativeV2TestJSON, cls).resource_setup()
cls.default_volume_size = cls.volumes_client.default_volume_size
- cls.shared_quota_set = {'gigabytes': 3 * cls.default_volume_size,
- 'volumes': 1, 'snapshots': 1}
+ cls.shared_quota_set = {'gigabytes': 2 * cls.default_volume_size,
+ 'volumes': 1}
# NOTE(gfidente): no need to restore original quota set
- # after the tests as they only work with tenant isolation.
+ # after the tests as they only work with dynamic credentials.
cls.quotas_client.update_quota_set(
cls.demo_tenant_id,
**cls.shared_quota_set)
@@ -43,7 +46,6 @@
# NOTE(gfidente): no need to delete in tearDown as
# they are created using utility wrapper methods.
cls.volume = cls.create_volume()
- cls.snapshot = cls.create_snapshot(cls.volume['id'])
@test.attr(type='negative')
@test.idempotent_id('bf544854-d62a-47f2-a681-90f7a47d86b6')
@@ -52,13 +54,6 @@
self.volumes_client.create_volume)
@test.attr(type='negative')
- @test.idempotent_id('02bbf63f-6c05-4357-9d98-2926a94064ff')
- def test_quota_volume_snapshots(self):
- self.assertRaises(lib_exc.OverLimit,
- self.snapshots_client.create_snapshot,
- self.volume['id'])
-
- @test.attr(type='negative')
@test.idempotent_id('2dc27eee-8659-4298-b900-169d71a91374')
def test_quota_volume_gigabytes(self):
# NOTE(gfidente): quota set needs to be changed for this test
@@ -67,8 +62,7 @@
self.addCleanup(self.quotas_client.update_quota_set,
self.demo_tenant_id,
**self.shared_quota_set)
-
- new_quota_set = {'gigabytes': 2 * self.default_volume_size,
+ new_quota_set = {'gigabytes': self.default_volume_size,
'volumes': 2, 'snapshots': 1}
self.quotas_client.update_quota_set(
self.demo_tenant_id,
@@ -76,15 +70,6 @@
self.assertRaises(lib_exc.OverLimit,
self.volumes_client.create_volume)
- new_quota_set = {'gigabytes': 2 * self.default_volume_size,
- 'volumes': 1, 'snapshots': 2}
- self.quotas_client.update_quota_set(
- self.demo_tenant_id,
- **self.shared_quota_set)
- self.assertRaises(lib_exc.OverLimit,
- self.snapshots_client.create_snapshot,
- self.volume['id'])
-
class VolumeQuotasNegativeV1TestJSON(BaseVolumeQuotasNegativeV2TestJSON):
_api_version = 1
diff --git a/tempest/api/volume/admin/test_volume_services.py b/tempest/api/volume/admin/test_volume_services.py
index 74fffb9..6692594 100644
--- a/tempest/api/volume/admin/test_volume_services.py
+++ b/tempest/api/volume/admin/test_volume_services.py
@@ -18,8 +18,8 @@
class VolumesServicesV2TestJSON(base.BaseVolumeAdminTest):
- """
- Tests Volume Services API.
+ """Tests Volume Services API.
+
volume service list requires admin privileges.
"""
diff --git a/tempest/api/volume/admin/test_volume_snapshot_quotas_negative.py b/tempest/api/volume/admin/test_volume_snapshot_quotas_negative.py
new file mode 100644
index 0000000..ce0b618
--- /dev/null
+++ b/tempest/api/volume/admin/test_volume_snapshot_quotas_negative.py
@@ -0,0 +1,81 @@
+# Copyright 2014 OpenStack Foundation
+# 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 tempest_lib import exceptions as lib_exc
+
+from tempest.api.volume import base
+from tempest import config
+from tempest import test
+
+CONF = config.CONF
+
+
+class VolumeSnapshotQuotasNegativeV2TestJSON(base.BaseVolumeAdminTest):
+ force_tenant_isolation = True
+
+ @classmethod
+ def skip_checks(cls):
+ super(VolumeSnapshotQuotasNegativeV2TestJSON, cls).skip_checks()
+ if not CONF.volume_feature_enabled.snapshot:
+ raise cls.skipException('Cinder volume snapshots are disabled')
+
+ @classmethod
+ def setup_credentials(cls):
+ super(VolumeSnapshotQuotasNegativeV2TestJSON, cls).setup_credentials()
+ cls.demo_tenant_id = cls.os.credentials.tenant_id
+
+ @classmethod
+ def resource_setup(cls):
+ super(VolumeSnapshotQuotasNegativeV2TestJSON, cls).resource_setup()
+ cls.default_volume_size = cls.volumes_client.default_volume_size
+ cls.shared_quota_set = {'gigabytes': 3 * cls.default_volume_size,
+ 'volumes': 1, 'snapshots': 1}
+
+ # NOTE(gfidente): no need to restore original quota set
+ # after the tests as they only work with tenant isolation.
+ cls.quotas_client.update_quota_set(
+ cls.demo_tenant_id,
+ **cls.shared_quota_set)
+
+ # NOTE(gfidente): no need to delete in tearDown as
+ # they are created using utility wrapper methods.
+ cls.volume = cls.create_volume()
+ cls.snapshot = cls.create_snapshot(cls.volume['id'])
+
+ @test.attr(type='negative')
+ @test.idempotent_id('02bbf63f-6c05-4357-9d98-2926a94064ff')
+ def test_quota_volume_snapshots(self):
+ self.assertRaises(lib_exc.OverLimit,
+ self.snapshots_client.create_snapshot,
+ self.volume['id'])
+
+ @test.attr(type='negative')
+ @test.idempotent_id('c99a1ca9-6cdf-498d-9fdf-25832babef27')
+ def test_quota_volume_gigabytes_snapshots(self):
+ self.addCleanup(self.quotas_client.update_quota_set,
+ self.demo_tenant_id,
+ **self.shared_quota_set)
+ new_quota_set = {'gigabytes': 2 * self.default_volume_size,
+ 'volumes': 1, 'snapshots': 2}
+ self.quotas_client.update_quota_set(
+ self.demo_tenant_id,
+ **new_quota_set)
+ self.assertRaises(lib_exc.OverLimit,
+ self.snapshots_client.create_snapshot,
+ self.volume['id'])
+
+
+class VolumeSnapshotNegativeV1TestJSON(VolumeSnapshotQuotasNegativeV2TestJSON):
+ _api_version = 1
diff --git a/tempest/api/volume/test_availability_zone.py b/tempest/api/volume/test_availability_zone.py
index 366b8d2..fe51375 100644
--- a/tempest/api/volume/test_availability_zone.py
+++ b/tempest/api/volume/test_availability_zone.py
@@ -18,10 +18,7 @@
class AvailabilityZoneV2TestJSON(base.BaseVolumeTest):
-
- """
- Tests Availability Zone V2 API List
- """
+ """Tests Availability Zone V2 API List"""
@classmethod
def setup_clients(cls):
diff --git a/tempest/api/volume/test_volumes_list.py b/tempest/api/volume/test_volumes_list.py
index 620366a..b776494 100644
--- a/tempest/api/volume/test_volumes_list.py
+++ b/tempest/api/volume/test_volumes_list.py
@@ -26,14 +26,11 @@
class VolumesV2ListTestJSON(base.BaseVolumeTest):
-
- """
- This test creates a number of 1G volumes. To run successfully,
- ensure that the backing file for the volume group that Nova uses
- has space for at least 3 1G volumes!
- If you are running a Devstack environment, ensure that the
- VOLUME_BACKING_FILE_SIZE is at least 4G in your localrc
- """
+ # NOTE: This test creates a number of 1G volumes. To run successfully,
+ # ensure that the backing file for the volume group that Nova uses
+ # has space for at least 3 1G volumes!
+ # If you are running a Devstack environment, ensure that the
+ # VOLUME_BACKING_FILE_SIZE is at least 4G in your localrc
VOLUME_FIELDS = ('id', 'name')
@@ -83,10 +80,7 @@
super(VolumesV2ListTestJSON, cls).resource_cleanup()
def _list_by_param_value_and_assert(self, params, with_detail=False):
- """
- Perform list or list_details action with given params
- and validates result.
- """
+ """list or list_details with given params and validates result"""
if with_detail:
fetched_vol_list = \
self.client.list_volumes(detail=True, params=params)['volumes']
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 9866da3..856adcc 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -43,10 +43,8 @@
self.volumes_client.wait_for_volume_status(volume_id, 'available')
def _list_by_param_values_and_assert(self, params, with_detail=False):
- """
- Perform list or list_details action with given params
- and validates result.
- """
+ """list or list_details with given params and validates result."""
+
if with_detail:
fetched_snap_list = self.snapshots_client.list_snapshots(
detail=True, params=params)['snapshots']
diff --git a/tempest/api/volume/v2/test_volumes_list.py b/tempest/api/volume/v2/test_volumes_list.py
index 94a9d16..6568627 100644
--- a/tempest/api/volume/v2/test_volumes_list.py
+++ b/tempest/api/volume/v2/test_volumes_list.py
@@ -21,9 +21,7 @@
class VolumesV2ListTestJSON(base.BaseVolumeTest):
-
- """
- volumes v2 specific tests.
+ """volumes v2 specific tests.
This test creates a number of 1G volumes. To run successfully,
ensure that the backing file for the volume group that Nova uses
diff --git a/tempest/api_schema/response/compute/v2_1/aggregates.py b/tempest/api_schema/response/compute/v2_1/aggregates.py
deleted file mode 100644
index 1a9fe41..0000000
--- a/tempest/api_schema/response/compute/v2_1/aggregates.py
+++ /dev/null
@@ -1,92 +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
-
-# create-aggregate api doesn't have 'hosts' and 'metadata' attributes.
-aggregate_for_create = {
- 'type': 'object',
- 'properties': {
- 'availability_zone': {'type': ['string', 'null']},
- 'created_at': {'type': 'string'},
- 'deleted': {'type': 'boolean'},
- 'deleted_at': {'type': ['string', 'null']},
- 'id': {'type': 'integer'},
- 'name': {'type': 'string'},
- 'updated_at': {'type': ['string', 'null']}
- },
- 'additionalProperties': False,
- 'required': ['availability_zone', 'created_at', 'deleted',
- 'deleted_at', 'id', 'name', 'updated_at'],
-}
-
-common_aggregate_info = copy.deepcopy(aggregate_for_create)
-common_aggregate_info['properties'].update({
- 'hosts': {'type': 'array'},
- 'metadata': {'type': 'object'}
-})
-common_aggregate_info['required'].extend(['hosts', 'metadata'])
-
-list_aggregates = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'aggregates': {
- 'type': 'array',
- 'items': common_aggregate_info
- }
- },
- 'additionalProperties': False,
- 'required': ['aggregates'],
- }
-}
-
-get_aggregate = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'aggregate': common_aggregate_info
- },
- 'additionalProperties': False,
- 'required': ['aggregate'],
- }
-}
-
-aggregate_set_metadata = get_aggregate
-# The 'updated_at' attribute of 'update_aggregate' can't be null.
-update_aggregate = copy.deepcopy(get_aggregate)
-update_aggregate['response_body']['properties']['aggregate']['properties'][
- 'updated_at'] = {
- 'type': 'string'
- }
-
-delete_aggregate = {
- 'status_code': [200]
-}
-
-create_aggregate = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'aggregate': aggregate_for_create
- },
- 'additionalProperties': False,
- 'required': ['aggregate'],
- }
-}
-
-aggregate_add_remove_host = get_aggregate
diff --git a/tempest/api_schema/response/compute/v2_1/availability_zone.py b/tempest/api_schema/response/compute/v2_1/availability_zone.py
deleted file mode 100644
index d9aebce..0000000
--- a/tempest/api_schema/response/compute/v2_1/availability_zone.py
+++ /dev/null
@@ -1,78 +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
-
-
-base = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'availabilityZoneInfo': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'zoneName': {'type': 'string'},
- 'zoneState': {
- 'type': 'object',
- 'properties': {
- 'available': {'type': 'boolean'}
- },
- 'additionalProperties': False,
- 'required': ['available']
- },
- # NOTE: Here is the difference between detail and
- # non-detail.
- 'hosts': {'type': 'null'}
- },
- 'additionalProperties': False,
- 'required': ['zoneName', 'zoneState', 'hosts']
- }
- }
- },
- 'additionalProperties': False,
- 'required': ['availabilityZoneInfo']
- }
-}
-
-detail = {
- 'type': 'object',
- 'patternProperties': {
- # NOTE: Here is for a hostname
- '^[a-zA-Z0-9-_.]+$': {
- 'type': 'object',
- 'patternProperties': {
- # NOTE: Here is for a service name
- '^.*$': {
- 'type': 'object',
- 'properties': {
- 'available': {'type': 'boolean'},
- 'active': {'type': 'boolean'},
- 'updated_at': {'type': ['string', 'null']}
- },
- 'additionalProperties': False,
- 'required': ['available', 'active', 'updated_at']
- }
- }
- }
- }
-}
-
-list_availability_zone_list = copy.deepcopy(base)
-
-list_availability_zone_list_detail = copy.deepcopy(base)
-list_availability_zone_list_detail['response_body']['properties'][
- 'availabilityZoneInfo']['items']['properties']['hosts'] = detail
diff --git a/tempest/api_schema/response/compute/v2_1/baremetal_nodes.py b/tempest/api_schema/response/compute/v2_1/baremetal_nodes.py
deleted file mode 100644
index d1ee877..0000000
--- a/tempest/api_schema/response/compute/v2_1/baremetal_nodes.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright 2015 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
-
-node = {
- 'type': 'object',
- 'properties': {
- 'id': {'type': 'string'},
- 'interfaces': {'type': 'array'},
- 'host': {'type': 'string'},
- 'task_state': {'type': ['string', 'null']},
- 'cpus': {'type': ['integer', 'string']},
- 'memory_mb': {'type': ['integer', 'string']},
- 'disk_gb': {'type': ['integer', 'string']},
- },
- 'additionalProperties': False,
- 'required': ['id', 'interfaces', 'host', 'task_state', 'cpus', 'memory_mb',
- 'disk_gb']
-}
-
-list_baremetal_nodes = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'nodes': {
- 'type': 'array',
- 'items': node
- }
- },
- 'additionalProperties': False,
- 'required': ['nodes']
- }
-}
-
-baremetal_node = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'node': node
- },
- 'additionalProperties': False,
- 'required': ['node']
- }
-}
-get_baremetal_node = copy.deepcopy(baremetal_node)
-get_baremetal_node['response_body']['properties']['node'][
- 'properties'].update({'instance_uuid': {'type': ['string', 'null']}})
-get_baremetal_node['response_body']['properties']['node'][
- 'required'].append('instance_uuid')
diff --git a/tempest/api_schema/response/compute/v2_1/certificates.py b/tempest/api_schema/response/compute/v2_1/certificates.py
deleted file mode 100644
index 4e7cbe4..0000000
--- a/tempest/api_schema/response/compute/v2_1/certificates.py
+++ /dev/null
@@ -1,41 +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
-
-_common_schema = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'certificate': {
- 'type': 'object',
- 'properties': {
- 'data': {'type': 'string'},
- 'private_key': {'type': 'string'},
- },
- 'additionalProperties': False,
- 'required': ['data', 'private_key']
- }
- },
- 'additionalProperties': False,
- 'required': ['certificate']
- }
-}
-
-get_certificate = copy.deepcopy(_common_schema)
-get_certificate['response_body']['properties']['certificate'][
- 'properties']['private_key'].update({'type': 'null'})
-
-create_certificate = copy.deepcopy(_common_schema)
diff --git a/tempest/api_schema/response/compute/v2_1/extensions.py b/tempest/api_schema/response/compute/v2_1/extensions.py
deleted file mode 100644
index a6a455c..0000000
--- a/tempest/api_schema/response/compute/v2_1/extensions.py
+++ /dev/null
@@ -1,47 +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.
-
-list_extensions = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'extensions': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'updated': {
- 'type': 'string',
- 'format': 'data-time'
- },
- 'name': {'type': 'string'},
- 'links': {'type': 'array'},
- 'namespace': {
- 'type': 'string',
- 'format': 'uri'
- },
- 'alias': {'type': 'string'},
- 'description': {'type': 'string'}
- },
- 'additionalProperties': False,
- 'required': ['updated', 'name', 'links', 'namespace',
- 'alias', 'description']
- }
- }
- },
- 'additionalProperties': False,
- 'required': ['extensions']
- }
-}
diff --git a/tempest/api_schema/response/compute/v2_1/fixed_ips.py b/tempest/api_schema/response/compute/v2_1/fixed_ips.py
deleted file mode 100644
index 3586b70..0000000
--- a/tempest/api_schema/response/compute/v2_1/fixed_ips.py
+++ /dev/null
@@ -1,42 +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.
-
-from tempest.api_schema.response.compute.v2_1 import parameter_types
-
-get_fixed_ip = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'fixed_ip': {
- 'type': 'object',
- 'properties': {
- 'address': parameter_types.ip_address,
- 'cidr': {'type': 'string'},
- 'host': {'type': 'string'},
- 'hostname': {'type': 'string'}
- },
- 'additionalProperties': False,
- 'required': ['address', 'cidr', 'host', 'hostname']
- }
- },
- 'additionalProperties': False,
- 'required': ['fixed_ip']
- }
-}
-
-reserve_fixed_ip = {
- 'status_code': [202],
- 'response_body': {'type': 'string'}
-}
diff --git a/tempest/api_schema/response/compute/v2_1/flavors.py b/tempest/api_schema/response/compute/v2_1/flavors.py
deleted file mode 100644
index 5f5b2e3..0000000
--- a/tempest/api_schema/response/compute/v2_1/flavors.py
+++ /dev/null
@@ -1,103 +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.
-
-from tempest.api_schema.response.compute.v2_1 import parameter_types
-
-list_flavors = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'flavors': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'name': {'type': 'string'},
- 'links': parameter_types.links,
- 'id': {'type': 'string'}
- },
- 'additionalProperties': False,
- 'required': ['name', 'links', 'id']
- }
- },
- 'flavors_links': parameter_types.links
- },
- 'additionalProperties': False,
- # NOTE(gmann): flavors_links attribute is not necessary
- # to be present always So it is not 'required'.
- 'required': ['flavors']
- }
-}
-
-common_flavor_info = {
- 'type': 'object',
- 'properties': {
- 'name': {'type': 'string'},
- 'links': parameter_types.links,
- 'ram': {'type': 'integer'},
- 'vcpus': {'type': 'integer'},
- # 'swap' attributes comes as integer value but if it is empty
- # it comes as "". So defining type of as string and integer.
- 'swap': {'type': ['integer', 'string']},
- 'disk': {'type': 'integer'},
- 'id': {'type': 'string'},
- 'OS-FLV-DISABLED:disabled': {'type': 'boolean'},
- 'os-flavor-access:is_public': {'type': 'boolean'},
- 'rxtx_factor': {'type': 'number'},
- 'OS-FLV-EXT-DATA:ephemeral': {'type': 'integer'}
- },
- 'additionalProperties': False,
- # 'OS-FLV-DISABLED', 'os-flavor-access', 'rxtx_factor' and
- # 'OS-FLV-EXT-DATA' are API extensions. So they are not 'required'.
- 'required': ['name', 'links', 'ram', 'vcpus', 'swap', 'disk', 'id']
-}
-
-list_flavors_details = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'flavors': {
- 'type': 'array',
- 'items': common_flavor_info
- },
- # NOTE(gmann): flavors_links attribute is not necessary
- # to be present always So it is not 'required'.
- 'flavors_links': parameter_types.links
- },
- 'additionalProperties': False,
- 'required': ['flavors']
- }
-}
-
-unset_flavor_extra_specs = {
- 'status_code': [200]
-}
-
-create_get_flavor_details = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'flavor': common_flavor_info
- },
- 'additionalProperties': False,
- 'required': ['flavor']
- }
-}
-
-delete_flavor = {
- 'status_code': [202]
-}
diff --git a/tempest/api_schema/response/compute/v2_1/flavors_access.py b/tempest/api_schema/response/compute/v2_1/flavors_access.py
deleted file mode 100644
index a4d6af0..0000000
--- a/tempest/api_schema/response/compute/v2_1/flavors_access.py
+++ /dev/null
@@ -1,36 +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.
-
-add_remove_list_flavor_access = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'flavor_access': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'flavor_id': {'type': 'string'},
- 'tenant_id': {'type': 'string'},
- },
- 'additionalProperties': False,
- 'required': ['flavor_id', 'tenant_id'],
- }
- }
- },
- 'additionalProperties': False,
- 'required': ['flavor_access']
- }
-}
diff --git a/tempest/api_schema/response/compute/v2_1/flavors_extra_specs.py b/tempest/api_schema/response/compute/v2_1/flavors_extra_specs.py
deleted file mode 100644
index a438d48..0000000
--- a/tempest/api_schema/response/compute/v2_1/flavors_extra_specs.py
+++ /dev/null
@@ -1,40 +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.
-
-set_get_flavor_extra_specs = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'extra_specs': {
- 'type': 'object',
- 'patternProperties': {
- '^[a-zA-Z0-9_\-\. :]+$': {'type': 'string'}
- }
- }
- },
- 'additionalProperties': False,
- 'required': ['extra_specs']
- }
-}
-
-set_get_flavor_extra_specs_key = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'patternProperties': {
- '^[a-zA-Z0-9_\-\. :]+$': {'type': 'string'}
- }
- }
-}
diff --git a/tempest/api_schema/response/compute/v2_1/hosts.py b/tempest/api_schema/response/compute/v2_1/hosts.py
deleted file mode 100644
index ae70ff1..0000000
--- a/tempest/api_schema/response/compute/v2_1/hosts.py
+++ /dev/null
@@ -1,116 +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
-
-
-list_hosts = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'hosts': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'host_name': {'type': 'string'},
- 'service': {'type': 'string'},
- 'zone': {'type': 'string'}
- },
- 'additionalProperties': False,
- 'required': ['host_name', 'service', 'zone']
- }
- }
- },
- 'additionalProperties': False,
- 'required': ['hosts']
- }
-}
-
-get_host_detail = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'host': {
- 'type': 'array',
- 'item': {
- 'type': 'object',
- 'properties': {
- 'resource': {
- 'type': 'object',
- 'properties': {
- 'cpu': {'type': 'integer'},
- 'disk_gb': {'type': 'integer'},
- 'host': {'type': 'string'},
- 'memory_mb': {'type': 'integer'},
- 'project': {'type': 'string'}
- },
- 'additionalProperties': False,
- 'required': ['cpu', 'disk_gb', 'host',
- 'memory_mb', 'project']
- }
- },
- 'additionalProperties': False,
- 'required': ['resource']
- }
- }
- },
- 'additionalProperties': False,
- 'required': ['host']
- }
-}
-
-startup_host = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'host': {'type': 'string'},
- 'power_action': {'enum': ['startup']}
- },
- 'additionalProperties': False,
- 'required': ['host', 'power_action']
- }
-}
-
-# The 'power_action' attribute of 'shutdown_host' API is 'shutdown'
-shutdown_host = copy.deepcopy(startup_host)
-
-shutdown_host['response_body']['properties']['power_action'] = {
- 'enum': ['shutdown']
-}
-
-# The 'power_action' attribute of 'reboot_host' API is 'reboot'
-reboot_host = copy.deepcopy(startup_host)
-
-reboot_host['response_body']['properties']['power_action'] = {
- 'enum': ['reboot']
-}
-
-update_host = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'host': {'type': 'string'},
- 'maintenance_mode': {'enum': ['on_maintenance',
- 'off_maintenance']},
- 'status': {'enum': ['enabled', 'disabled']}
- },
- 'additionalProperties': False,
- 'required': ['host', 'maintenance_mode', 'status']
- }
-}
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/api_schema/response/compute/v2_1/images.py b/tempest/api_schema/response/compute/v2_1/images.py
deleted file mode 100644
index a513dcb..0000000
--- a/tempest/api_schema/response/compute/v2_1/images.py
+++ /dev/null
@@ -1,154 +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
-
-image_links = copy.deepcopy(parameter_types.links)
-image_links['items']['properties'].update({'type': {'type': 'string'}})
-
-common_image_schema = {
- 'type': 'object',
- 'properties': {
- 'id': {'type': 'string'},
- 'status': {'type': 'string'},
- 'updated': {'type': 'string'},
- 'links': image_links,
- 'name': {'type': 'string'},
- 'created': {'type': 'string'},
- 'minDisk': {'type': 'integer'},
- 'minRam': {'type': 'integer'},
- 'progress': {'type': 'integer'},
- 'metadata': {'type': 'object'},
- 'server': {
- 'type': 'object',
- 'properties': {
- 'id': {'type': 'string'},
- 'links': parameter_types.links
- },
- 'additionalProperties': False,
- 'required': ['id', 'links']
- },
- 'OS-EXT-IMG-SIZE:size': {'type': 'integer'},
- 'OS-DCF:diskConfig': {'type': 'string'}
- },
- 'additionalProperties': False,
- # 'server' attributes only comes in response body if image is
- # associated with any server. 'OS-EXT-IMG-SIZE:size' & 'OS-DCF:diskConfig'
- # are API extension, So those are not defined as 'required'.
- 'required': ['id', 'status', 'updated', 'links', 'name',
- 'created', 'minDisk', 'minRam', 'progress',
- 'metadata']
-}
-
-get_image = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'image': common_image_schema
- },
- 'additionalProperties': False,
- 'required': ['image']
- }
-}
-
-list_images = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'images': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'id': {'type': 'string'},
- 'links': image_links,
- 'name': {'type': 'string'}
- },
- 'additionalProperties': False,
- 'required': ['id', 'links', 'name']
- }
- },
- 'images_links': parameter_types.links
- },
- 'additionalProperties': False,
- # NOTE(gmann): images_links attribute is not necessary to be
- # present always So it is not 'required'.
- 'required': ['images']
- }
-}
-
-create_image = {
- 'status_code': [202],
- 'response_header': {
- 'type': 'object',
- 'properties': parameter_types.response_header
- }
-}
-create_image['response_header']['properties'].update(
- {'location': {
- 'type': 'string',
- 'format': 'uri'}
- }
-)
-create_image['response_header']['required'] = ['location']
-
-delete = {
- 'status_code': [204]
-}
-
-image_metadata = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'metadata': {'type': 'object'}
- },
- 'additionalProperties': False,
- 'required': ['metadata']
- }
-}
-
-image_meta_item = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'meta': {'type': 'object'}
- },
- 'additionalProperties': False,
- 'required': ['meta']
- }
-}
-
-list_images_details = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'images': {
- 'type': 'array',
- 'items': common_image_schema
- },
- 'images_links': parameter_types.links
- },
- 'additionalProperties': False,
- # NOTE(gmann): images_links attribute is not necessary to be
- # present always So it is not 'required'.
- 'required': ['images']
- }
-}
diff --git a/tempest/api_schema/response/compute/v2_1/instance_usage_audit_logs.py b/tempest/api_schema/response/compute/v2_1/instance_usage_audit_logs.py
deleted file mode 100644
index c6c4deb..0000000
--- a/tempest/api_schema/response/compute/v2_1/instance_usage_audit_logs.py
+++ /dev/null
@@ -1,62 +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.
-
-common_instance_usage_audit_log = {
- 'type': 'object',
- 'properties': {
- 'hosts_not_run': {
- 'type': 'array',
- 'items': {'type': 'string'}
- },
- 'log': {'type': 'object'},
- 'num_hosts': {'type': 'integer'},
- 'num_hosts_done': {'type': 'integer'},
- 'num_hosts_not_run': {'type': 'integer'},
- 'num_hosts_running': {'type': 'integer'},
- 'overall_status': {'type': 'string'},
- 'period_beginning': {'type': 'string'},
- 'period_ending': {'type': 'string'},
- 'total_errors': {'type': 'integer'},
- 'total_instances': {'type': 'integer'}
- },
- 'additionalProperties': False,
- 'required': ['hosts_not_run', 'log', 'num_hosts', 'num_hosts_done',
- 'num_hosts_not_run', 'num_hosts_running', 'overall_status',
- 'period_beginning', 'period_ending', 'total_errors',
- 'total_instances']
-}
-
-get_instance_usage_audit_log = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'instance_usage_audit_log': common_instance_usage_audit_log
- },
- 'additionalProperties': False,
- 'required': ['instance_usage_audit_log']
- }
-}
-
-list_instance_usage_audit_log = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'instance_usage_audit_logs': common_instance_usage_audit_log
- },
- 'additionalProperties': False,
- 'required': ['instance_usage_audit_logs']
- }
-}
diff --git a/tempest/api_schema/response/compute/v2_1/limits.py b/tempest/api_schema/response/compute/v2_1/limits.py
deleted file mode 100644
index 81f175f..0000000
--- a/tempest/api_schema/response/compute/v2_1/limits.py
+++ /dev/null
@@ -1,106 +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.
-
-get_limit = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'limits': {
- 'type': 'object',
- 'properties': {
- 'absolute': {
- 'type': 'object',
- 'properties': {
- 'maxTotalRAMSize': {'type': 'integer'},
- 'totalCoresUsed': {'type': 'integer'},
- 'maxTotalInstances': {'type': 'integer'},
- 'maxTotalFloatingIps': {'type': 'integer'},
- 'totalSecurityGroupsUsed': {'type': 'integer'},
- 'maxTotalCores': {'type': 'integer'},
- 'totalFloatingIpsUsed': {'type': 'integer'},
- 'maxSecurityGroups': {'type': 'integer'},
- 'maxServerMeta': {'type': 'integer'},
- 'maxPersonality': {'type': 'integer'},
- 'maxImageMeta': {'type': 'integer'},
- 'maxPersonalitySize': {'type': 'integer'},
- 'maxSecurityGroupRules': {'type': 'integer'},
- 'maxTotalKeypairs': {'type': 'integer'},
- 'totalRAMUsed': {'type': 'integer'},
- 'totalInstancesUsed': {'type': 'integer'},
- 'maxServerGroupMembers': {'type': 'integer'},
- 'maxServerGroups': {'type': 'integer'},
- 'totalServerGroupsUsed': {'type': 'integer'}
- },
- 'additionalProperties': False,
- # NOTE(gmann): maxServerGroupMembers, maxServerGroups
- # and totalServerGroupsUsed are API extension,
- # and some environments return a response without these
- # attributes.So they are not 'required'.
- 'required': ['maxImageMeta',
- 'maxPersonality',
- 'maxPersonalitySize',
- 'maxSecurityGroupRules',
- 'maxSecurityGroups',
- 'maxServerMeta',
- 'maxTotalCores',
- 'maxTotalFloatingIps',
- 'maxTotalInstances',
- 'maxTotalKeypairs',
- 'maxTotalRAMSize',
- 'totalCoresUsed',
- 'totalFloatingIpsUsed',
- 'totalInstancesUsed',
- 'totalRAMUsed',
- 'totalSecurityGroupsUsed']
- },
- 'rate': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'limit': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'next-available':
- {'type': 'string'},
- 'remaining':
- {'type': 'integer'},
- 'unit':
- {'type': 'string'},
- 'value':
- {'type': 'integer'},
- 'verb':
- {'type': 'string'}
- },
- 'additionalProperties': False,
- }
- },
- 'regex': {'type': 'string'},
- 'uri': {'type': 'string'}
- },
- 'additionalProperties': False,
- }
- }
- },
- 'additionalProperties': False,
- 'required': ['absolute', 'rate']
- }
- },
- 'additionalProperties': False,
- 'required': ['limits']
- }
-}
diff --git a/tempest/api_schema/response/compute/v2_1/migrations.py b/tempest/api_schema/response/compute/v2_1/migrations.py
deleted file mode 100644
index b7d66ea..0000000
--- a/tempest/api_schema/response/compute/v2_1/migrations.py
+++ /dev/null
@@ -1,51 +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.
-
-list_migrations = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'migrations': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'id': {'type': 'integer'},
- 'status': {'type': ['string', 'null']},
- 'instance_uuid': {'type': ['string', 'null']},
- 'source_node': {'type': ['string', 'null']},
- 'source_compute': {'type': ['string', 'null']},
- 'dest_node': {'type': ['string', 'null']},
- 'dest_compute': {'type': ['string', 'null']},
- 'dest_host': {'type': ['string', 'null']},
- 'old_instance_type_id': {'type': ['integer', 'null']},
- 'new_instance_type_id': {'type': ['integer', 'null']},
- 'created_at': {'type': 'string'},
- 'updated_at': {'type': ['string', 'null']}
- },
- 'additionalProperties': False,
- 'required': [
- 'id', 'status', 'instance_uuid', 'source_node',
- 'source_compute', 'dest_node', 'dest_compute',
- 'dest_host', 'old_instance_type_id',
- 'new_instance_type_id', 'created_at', 'updated_at'
- ]
- }
- }
- },
- 'additionalProperties': False,
- 'required': ['migrations']
- }
-}
diff --git a/tempest/api_schema/response/compute/v2_1/quota_classes.py b/tempest/api_schema/response/compute/v2_1/quota_classes.py
deleted file mode 100644
index a0cdaf5..0000000
--- a/tempest/api_schema/response/compute/v2_1/quota_classes.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2014 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.
-
-import copy
-
-from tempest.api_schema.response.compute.v2_1 import quotas
-
-# NOTE(mriedem): os-quota-class-sets responses are the same as os-quota-sets
-# except for the key in the response body is quota_class_set instead of
-# quota_set, so update this copy of the schema from os-quota-sets.
-get_quota_class_set = copy.deepcopy(quotas.get_quota_set)
-get_quota_class_set['response_body']['properties']['quota_class_set'] = (
- get_quota_class_set['response_body']['properties'].pop('quota_set'))
-get_quota_class_set['response_body']['required'] = ['quota_class_set']
-
-update_quota_class_set = copy.deepcopy(quotas.update_quota_set)
-update_quota_class_set['response_body']['properties']['quota_class_set'] = (
- update_quota_class_set['response_body']['properties'].pop('quota_set'))
-update_quota_class_set['response_body']['required'] = ['quota_class_set']
diff --git a/tempest/api_schema/response/compute/v2_1/servers.py b/tempest/api_schema/response/compute/v2_1/servers.py
index 44ab9e9..38f7c82 100644
--- a/tempest/api_schema/response/compute/v2_1/servers.py
+++ b/tempest/api_schema/response/compute/v2_1/servers.py
@@ -291,8 +291,8 @@
'status_code': [202]
}
-get_volume_attachment = copy.deepcopy(attach_volume)
-get_volume_attachment['response_body']['properties'][
+show_volume_attachment = copy.deepcopy(attach_volume)
+show_volume_attachment['response_body']['properties'][
'volumeAttachment']['properties'].update({'serverId': {'type': 'string'}})
list_volume_attachments = {
@@ -351,7 +351,7 @@
'required': ['id', 'name', 'policies', 'members', 'metadata']
}
-create_get_server_group = {
+create_show_server_group = {
'status_code': [200],
'response_body': {
'type': 'object',
@@ -436,7 +436,7 @@
# 'events' does not come in response body always so it is not
# defined as 'required'
-get_instance_action = {
+show_instance_action = {
'status_code': [200],
'response_body': {
'type': 'object',
@@ -448,7 +448,7 @@
}
}
-get_password = {
+show_password = {
'status_code': [200],
'response_body': {
'type': 'object',
@@ -520,7 +520,7 @@
'status_code': [204]
}
-set_get_server_metadata_item = {
+set_show_server_metadata_item = {
'status_code': [200],
'response_body': {
'type': 'object',
diff --git a/tempest/api_schema/response/compute/v2_1/services.py b/tempest/api_schema/response/compute/v2_1/services.py
index c2c7a51..ddef7b2 100644
--- a/tempest/api_schema/response/compute/v2_1/services.py
+++ b/tempest/api_schema/response/compute/v2_1/services.py
@@ -43,7 +43,7 @@
}
}
-enable_service = {
+enable_disable_service = {
'status_code': [200],
'response_body': {
'type': 'object',
diff --git a/tempest/clients.py b/tempest/clients.py
index 2756fa8..3b498bd 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -16,10 +16,37 @@
import copy
from oslo_log import log as logging
+from tempest_lib.services.compute.agents_client import AgentsClient
+from tempest_lib.services.compute.aggregates_client import AggregatesClient
+from tempest_lib.services.compute.availability_zone_client import \
+ AvailabilityZoneClient
+from tempest_lib.services.compute.baremetal_nodes_client import \
+ BaremetalNodesClient
+from tempest_lib.services.compute.certificates_client import \
+ CertificatesClient
+from tempest_lib.services.compute.extensions_client import \
+ ExtensionsClient
+from tempest_lib.services.compute.fixed_ips_client import FixedIPsClient
+from tempest_lib.services.compute.flavors_client import FlavorsClient
+from tempest_lib.services.compute.floating_ip_pools_client import \
+ FloatingIPPoolsClient
+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.compute.images_client import ImagesClient
+from tempest_lib.services.compute.instance_usage_audit_log_client import \
+ InstanceUsagesAuditLogClient
+from tempest_lib.services.compute.limits_client import LimitsClient
+from tempest_lib.services.compute.migrations_client import MigrationsClient
+from tempest_lib.services.compute.networks_client import NetworksClient \
+ as ComputeNetworksClient
+from tempest_lib.services.compute.quota_classes_client import \
+ QuotaClassesClient
from tempest_lib.services.identity.v2.token_client import TokenClient
from tempest_lib.services.identity.v3.token_client import V3TokenClient
-from tempest.common import cred_provider
from tempest.common import negative_rest_client
from tempest import config
from tempest import exceptions
@@ -27,42 +54,11 @@
from tempest.services.baremetal.v1.json.baremetal_client import \
BaremetalClient
from tempest.services import botoclients
-from tempest.services.compute.json.agents_client import \
- AgentsClient
-from tempest.services.compute.json.aggregates_client import \
- AggregatesClient
-from tempest.services.compute.json.availability_zone_client import \
- AvailabilityZoneClient
-from tempest.services.compute.json.baremetal_nodes_client import \
- BaremetalNodesClient
-from tempest.services.compute.json.certificates_client import \
- CertificatesClient
-from tempest.services.compute.json.extensions_client import \
- ExtensionsClient
-from tempest.services.compute.json.fixed_ips_client import FixedIPsClient
-from tempest.services.compute.json.flavors_client import FlavorsClient
-from tempest.services.compute.json.floating_ip_pools_client import \
- FloatingIPPoolsClient
-from tempest.services.compute.json.floating_ips_bulk_client import \
- FloatingIPsBulkClient
from tempest.services.compute.json.floating_ips_client import \
- FloatingIPsClient
-from tempest.services.compute.json.hosts_client import HostsClient
-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
+ FloatingIPsClient as ComputeFloatingIPsClient
from tempest.services.compute.json.interfaces_client import \
InterfacesClient
from tempest.services.compute.json.keypairs_client import KeyPairsClient
-from tempest.services.compute.json.limits_client import LimitsClient
-from tempest.services.compute.json.migrations_client import \
- MigrationsClient
-from tempest.services.compute.json.networks_client import NetworksClient \
- as ComputeNetworksClient
-from tempest.services.compute.json.quota_classes_client import \
- QuotaClassesClient
from tempest.services.compute.json.quotas_client import QuotasClient
from tempest.services.compute.json.security_group_default_rules_client import \
SecurityGroupDefaultRulesClient
@@ -74,15 +70,15 @@
ServerGroupsClient
from tempest.services.compute.json.servers_client import ServersClient
from tempest.services.compute.json.services_client import ServicesClient
-from tempest.services.compute.json.snapshots_extensions_client import \
- SnapshotsExtensionsClient
+from tempest.services.compute.json.snapshots_client import \
+ SnapshotsClient as ComputeSnapshotsClient
from tempest.services.compute.json.tenant_networks_client import \
TenantNetworksClient
from tempest.services.compute.json.tenant_usages_client import \
TenantUsagesClient
from tempest.services.compute.json.versions_client import VersionsClient
-from tempest.services.compute.json.volumes_extensions_client import \
- VolumesExtensionsClient
+from tempest.services.compute.json.volumes_client import \
+ VolumesClient as ComputeVolumesClient
from tempest.services.data_processing.v1_1.data_processing_client import \
DataProcessingClient
from tempest.services.database.json.flavors_client import \
@@ -97,6 +93,7 @@
CredentialsClient
from tempest.services.identity.v3.json.endpoints_client import \
EndPointClient
+from tempest.services.identity.v3.json.groups_client import GroupsClient
from tempest.services.identity.v3.json.identity_client import \
IdentityV3Client
from tempest.services.identity.v3.json.policy_client import PolicyClient
@@ -107,12 +104,17 @@
from tempest.services.image.v2.json.image_client import ImageClientV2
from tempest.services.messaging.json.messaging_client import \
MessagingClient
+from tempest.services.network.json.floating_ips_client import FloatingIPsClient
from tempest.services.network.json.network_client import NetworkClient
+from tempest.services.network.json.networks_client import NetworksClient
+from tempest.services.network.json.ports_client import PortsClient
+from tempest.services.network.json.subnets_client import SubnetsClient
from tempest.services.object_storage.account_client import AccountClient
from tempest.services.object_storage.container_client import ContainerClient
from tempest.services.object_storage.object_client import ObjectClient
from tempest.services.orchestration.json.orchestration_client import \
OrchestrationClient
+from tempest.services.telemetry.json.alarming_client import AlarmingClient
from tempest.services.telemetry.json.telemetry_client import \
TelemetryClient
from tempest.services.volume.json.admin.volume_hosts_client import \
@@ -154,10 +156,7 @@
class Manager(manager.Manager):
-
- """
- Top level manager for OpenStack tempest clients
- """
+ """Top level manager for OpenStack tempest clients"""
default_params = {
'disable_ssl_certificate_validation':
@@ -174,7 +173,7 @@
}
default_params_with_timeout_values.update(default_params)
- def __init__(self, credentials=None, service=None):
+ def __init__(self, credentials, service=None):
super(Manager, self).__init__(credentials=credentials)
self._set_compute_clients()
@@ -197,6 +196,38 @@
build_interval=CONF.network.build_interval,
build_timeout=CONF.network.build_timeout,
**self.default_params)
+ self.networks_client = NetworksClient(
+ self.auth_provider,
+ CONF.network.catalog_type,
+ CONF.network.region or CONF.identity.region,
+ endpoint_type=CONF.network.endpoint_type,
+ build_interval=CONF.network.build_interval,
+ build_timeout=CONF.network.build_timeout,
+ **self.default_params)
+ self.subnets_client = SubnetsClient(
+ self.auth_provider,
+ CONF.network.catalog_type,
+ CONF.network.region or CONF.identity.region,
+ endpoint_type=CONF.network.endpoint_type,
+ build_interval=CONF.network.build_interval,
+ build_timeout=CONF.network.build_timeout,
+ **self.default_params)
+ self.ports_client = PortsClient(
+ self.auth_provider,
+ CONF.network.catalog_type,
+ CONF.network.region or CONF.identity.region,
+ endpoint_type=CONF.network.endpoint_type,
+ build_interval=CONF.network.build_interval,
+ build_timeout=CONF.network.build_timeout,
+ **self.default_params)
+ self.floating_ips_client = FloatingIPsClient(
+ self.auth_provider,
+ CONF.network.catalog_type,
+ CONF.network.region or CONF.identity.region,
+ endpoint_type=CONF.network.endpoint_type,
+ build_interval=CONF.network.build_interval,
+ build_timeout=CONF.network.build_timeout,
+ **self.default_params)
self.messaging_client = MessagingClient(
self.auth_provider,
CONF.messaging.catalog_type,
@@ -209,6 +240,13 @@
CONF.identity.region,
endpoint_type=CONF.telemetry.endpoint_type,
**self.default_params_with_timeout_values)
+ if CONF.service_available.aodh:
+ self.alarming_client = AlarmingClient(
+ self.auth_provider,
+ CONF.alarming.catalog_type,
+ CONF.identity.region,
+ endpoint_type=CONF.alarming.endpoint_type,
+ **self.default_params_with_timeout_values)
if CONF.service_available.glance:
self.image_client = ImageClient(
self.auth_provider,
@@ -291,8 +329,8 @@
self.auth_provider, **params)
self.floating_ips_bulk_client = FloatingIPsBulkClient(
self.auth_provider, **params)
- self.floating_ips_client = FloatingIPsClient(self.auth_provider,
- **params)
+ self.compute_floating_ips_client = ComputeFloatingIPsClient(
+ self.auth_provider, **params)
self.security_group_rules_client = SecurityGroupRulesClient(
self.auth_provider, **params)
self.security_groups_client = SecurityGroupsClient(
@@ -325,11 +363,11 @@
'build_interval': CONF.volume.build_interval,
'build_timeout': CONF.volume.build_timeout
})
- self.volumes_extensions_client = VolumesExtensionsClient(
+ self.volumes_extensions_client = ComputeVolumesClient(
self.auth_provider, **params_volume)
self.compute_versions_client = VersionsClient(self.auth_provider,
**params_volume)
- self.snapshots_extensions_client = SnapshotsExtensionsClient(
+ self.snapshots_extensions_client = ComputeSnapshotsClient(
self.auth_provider, **params_volume)
def _set_database_clients(self):
@@ -378,6 +416,7 @@
self.region_client = RegionClient(self.auth_provider, **params)
self.credentials_client = CredentialsClient(self.auth_provider,
**params)
+ self.groups_client = GroupsClient(self.auth_provider, **params_v3)
# Token clients do not use the catalog. They only need default_params.
# They read auth_url, so they should only be set if the corresponding
# API version is marked as enabled
@@ -459,17 +498,3 @@
self.account_client = AccountClient(self.auth_provider, **params)
self.container_client = ContainerClient(self.auth_provider, **params)
self.object_client = ObjectClient(self.auth_provider, **params)
-
-
-class AdminManager(Manager):
-
- """
- Manager object that uses the admin credentials for its
- managed client objects
- """
-
- def __init__(self, service=None):
- super(AdminManager, self).__init__(
- credentials=cred_provider.get_configured_credentials(
- 'identity_admin'),
- service=service)
diff --git a/tempest/cmd/account_generator.py b/tempest/cmd/account_generator.py
index ce7728e..613fb26 100755
--- a/tempest/cmd/account_generator.py
+++ b/tempest/cmd/account_generator.py
@@ -89,10 +89,13 @@
from oslo_log import log as logging
import yaml
+from tempest.common import identity
from tempest import config
from tempest import exceptions as exc
from tempest.services.identity.v2.json import identity_client
from tempest.services.network.json import network_client
+from tempest.services.network.json import networks_client
+from tempest.services.network.json import subnets_client
import tempest_lib.auth
from tempest_lib.common.utils import data_utils
import tempest_lib.exceptions
@@ -136,20 +139,38 @@
**params
)
network_admin = None
+ networks_admin = None
+ subnets_admin = None
+ neutron_iso_networks = False
if (CONF.service_available.neutron and
CONF.auth.create_isolated_networks):
+ neutron_iso_networks = True
network_admin = network_client.NetworkClient(
_auth,
CONF.network.catalog_type,
CONF.network.region or CONF.identity.region,
endpoint_type='adminURL',
**params)
- return identity_admin, network_admin
+ networks_admin = networks_client.NetworksClient(
+ _auth,
+ CONF.network.catalog_type,
+ CONF.network.region or CONF.identity.region,
+ endpoint_type='adminURL',
+ **params)
+ subnets_admin = subnets_client.SubnetsClient(
+ _auth,
+ CONF.network.catalog_type,
+ CONF.network.region or CONF.identity.region,
+ endpoint_type='adminURL',
+ **params)
+ return (identity_admin, neutron_iso_networks, network_admin,
+ networks_admin, subnets_admin)
def create_resources(opts, resources):
- identity_admin, network_admin = get_admin_clients(opts)
- roles = identity_admin.list_roles()
+ (identity_admin, neutron_iso_networks,
+ network_admin, networks_admin, subnets_admin) = get_admin_clients(opts)
+ roles = identity_admin.list_roles()['roles']
for u in resources['users']:
u['role_ids'] = []
for r in u.get('roles', ()):
@@ -168,13 +189,14 @@
LOG.info('Tenants created')
for u in resources['users']:
try:
- tenant = identity_admin.get_tenant_by_name(u['tenant'])
+ tenant = identity.get_tenant_by_name(identity_admin, u['tenant'])
except tempest_lib.exceptions.NotFound:
LOG.error("Tenant: %s - not found" % u['tenant'])
continue
while True:
try:
- identity_admin.get_user_by_username(tenant['id'], u['name'])
+ identity.get_user_by_username(identity_admin,
+ tenant['id'], u['name'])
except tempest_lib.exceptions.NotFound:
identity_admin.create_user(
u['name'], u['pass'], tenant['id'],
@@ -187,24 +209,24 @@
u['name'] = random_user_name(opts.tag, u['prefix'])
LOG.info('Users created')
- if network_admin:
+ if neutron_iso_networks:
for u in resources['users']:
- tenant = identity_admin.get_tenant_by_name(u['tenant'])
- network_name, router_name = create_network_resources(network_admin,
- tenant['id'],
- u['name'])
+ tenant = identity.get_tenant_by_name(identity_admin, u['tenant'])
+ network_name, router_name = create_network_resources(
+ network_admin, networks_admin, subnets_admin, tenant['id'],
+ u['name'])
u['network'] = network_name
u['router'] = router_name
LOG.info('Networks created')
for u in resources['users']:
try:
- tenant = identity_admin.get_tenant_by_name(u['tenant'])
+ tenant = identity.get_tenant_by_name(identity_admin, u['tenant'])
except tempest_lib.exceptions.NotFound:
LOG.error("Tenant: %s - not found" % u['tenant'])
continue
try:
- user = identity_admin.get_user_by_username(tenant['id'],
- u['name'])
+ user = identity.get_user_by_username(identity_admin,
+ tenant['id'], u['name'])
except tempest_lib.exceptions.NotFound:
LOG.error("User: %s - not found" % u['user'])
continue
@@ -218,10 +240,11 @@
LOG.info('Resources deployed successfully!')
-def create_network_resources(network_admin_client, tenant_id, name):
+def create_network_resources(network_admin_client, networks_admin_client,
+ subnets_admin_client, tenant_id, name):
def _create_network(name):
- resp_body = network_admin_client.create_network(
+ resp_body = networks_admin_client.create_network(
name=name, tenant_id=tenant_id)
return resp_body['network']
@@ -230,7 +253,7 @@
mask_bits = CONF.network.tenant_network_mask_bits
for subnet_cidr in base_cidr.subnet(mask_bits):
try:
- resp_body = network_admin_client.\
+ resp_body = subnets_admin_client.\
create_subnet(
network_id=network_id, cidr=str(subnet_cidr),
name=subnet_name,
diff --git a/tempest/cmd/cleanup.py b/tempest/cmd/cleanup.py
old mode 100755
new mode 100644
index 7898035..1c8ddcb
--- a/tempest/cmd/cleanup.py
+++ b/tempest/cmd/cleanup.py
@@ -50,15 +50,16 @@
Please run with **--help** to see full list of options.
"""
-import argparse
import sys
+from cliff import command
from oslo_log import log as logging
from oslo_serialization import jsonutils as json
from tempest import clients
from tempest.cmd import cleanup_service
-from tempest.common import cred_provider
+from tempest.common import credentials_factory as credentials
+from tempest.common import identity
from tempest import config
SAVED_STATE_JSON = "saved_state.json"
@@ -67,13 +68,17 @@
CONF = config.CONF
-class Cleanup(object):
+class TempestCleanup(command.Command):
- def __init__(self):
- self.admin_mgr = clients.AdminManager()
+ def __init__(self, app, cmd):
+ super(TempestCleanup, self).__init__(app, cmd)
+
+ def take_action(self, parsed_args):
+ cleanup_service.init_conf()
+ self.options = parsed_args
+ self.admin_mgr = credentials.AdminManager()
self.dry_run_data = {}
self.json_data = {}
- self._init_options()
self.admin_id = ""
self.admin_role_id = ""
@@ -86,9 +91,7 @@
self.tenant_services = cleanup_service.get_tenant_cleanup_services()
self.global_services = cleanup_service.get_global_cleanup_services()
- def run(self):
- opts = self.options
- if opts.init_saved_state:
+ if parsed_args.init_saved_state:
self._init_state()
return
@@ -157,10 +160,10 @@
tenant_data = dry_run_data["_tenants_to_clean"][tenant_id] = {}
tenant_data['name'] = tenant_name
- kwargs = {"username": CONF.identity.admin_username,
- "password": CONF.identity.admin_password,
+ kwargs = {"username": CONF.auth.admin_username,
+ "password": CONF.auth.admin_password,
"tenant_name": tenant['name']}
- mgr = clients.Manager(credentials=cred_provider.get_credentials(
+ mgr = clients.Manager(credentials=credentials.get_credentials(
**kwargs))
kwargs = {'data': tenant_data,
'is_dry_run': is_dry_run,
@@ -175,22 +178,22 @@
def _init_admin_ids(self):
id_cl = self.admin_mgr.identity_client
- tenant = id_cl.get_tenant_by_name(CONF.identity.admin_tenant_name)
+ tenant = identity.get_tenant_by_name(id_cl,
+ CONF.auth.admin_tenant_name)
self.admin_tenant_id = tenant['id']
- user = id_cl.get_user_by_username(self.admin_tenant_id,
- CONF.identity.admin_username)
+ user = identity.get_user_by_username(id_cl, self.admin_tenant_id,
+ CONF.auth.admin_username)
self.admin_id = user['id']
- roles = id_cl.list_roles()
+ roles = id_cl.list_roles()['roles']
for role in roles:
if role['name'] == CONF.identity.admin_role:
self.admin_role_id = role['id']
break
- def _init_options(self):
- parser = argparse.ArgumentParser(
- description='Cleanup after tempest run')
+ def get_parser(self, prog_name):
+ parser = super(TempestCleanup, self).get_parser(prog_name)
parser.add_argument('--init-saved-state', action="store_true",
dest='init_saved_state', default=False,
help="Creates JSON file: " + SAVED_STATE_JSON +
@@ -211,13 +214,15 @@
help="Generate JSON file:" + DRY_RUN_JSON +
", that reports the objects that would have "
"been deleted had a full cleanup been run.")
+ return parser
- self.options = parser.parse_args()
+ def get_description(self):
+ return 'Cleanup after tempest run'
def _add_admin(self, tenant_id):
id_cl = self.admin_mgr.identity_client
needs_role = True
- roles = id_cl.list_user_roles(tenant_id, self.admin_id)
+ roles = id_cl.list_user_roles(tenant_id, self.admin_id)['roles']
for role in roles:
if role['id'] == self.admin_role_id:
needs_role = False
@@ -232,10 +237,10 @@
LOG.debug("Remove admin user role for tenant: %s" % tenant_id)
# Must initialize AdminManager for each user role
# Otherwise authentication exception is thrown, weird
- id_cl = clients.AdminManager().identity_client
+ id_cl = credentials.AdminManager().identity_client
if (self._tenant_exists(tenant_id)):
try:
- id_cl.remove_user_role(tenant_id, self.admin_id,
+ id_cl.delete_user_role(tenant_id, self.admin_id,
self.admin_role_id)
except Exception as ex:
LOG.exception("Failed removing role from tenant which still"
@@ -244,7 +249,7 @@
def _tenant_exists(self, tenant_id):
id_cl = self.admin_mgr.identity_client
try:
- t = id_cl.get_tenant(tenant_id)
+ t = id_cl.show_tenant(tenant_id)
LOG.debug("Tenant is: %s" % str(t))
return True
except Exception as ex:
@@ -282,14 +287,3 @@
except Exception as ex:
LOG.exception("Exception parsing saved state json : %s" % ex)
sys.exit(ex)
-
-
-def main():
- cleanup_service.init_conf()
- cleanup = Cleanup()
- cleanup.run()
- LOG.info('Cleanup finished!')
- return 0
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index 6d4e3a9..ba6bf6c 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -16,7 +16,8 @@
from oslo_log import log as logging
-from tempest import clients
+from tempest.common import credentials_factory as credentials
+from tempest.common import identity
from tempest import config
from tempest import test
@@ -69,10 +70,10 @@
CONF_PRIV_NETWORK_NAME = CONF.compute.fixed_network_name
CONF_PUB_NETWORK = CONF.network.public_network_id
CONF_PUB_ROUTER = CONF.network.public_router_id
- CONF_TENANTS = [CONF.identity.admin_tenant_name,
+ CONF_TENANTS = [CONF.auth.admin_tenant_name,
CONF.identity.tenant_name,
CONF.identity.alt_tenant_name]
- CONF_USERS = [CONF.identity.admin_username, CONF.identity.username,
+ CONF_USERS = [CONF.auth.admin_username, CONF.identity.username,
CONF.identity.alt_username]
if IS_NEUTRON:
@@ -82,12 +83,12 @@
def _get_network_id(net_name, tenant_name):
- am = clients.AdminManager()
- net_cl = am.network_client
+ am = credentials.AdminManager()
+ net_cl = am.networks_client
id_cl = am.identity_client
networks = net_cl.list_networks()
- tenant = id_cl.get_tenant_by_name(tenant_name)
+ tenant = identity.get_tenant_by_name(id_cl, tenant_name)
t_id = tenant['id']
n_id = None
for net in networks['networks']:
@@ -147,7 +148,7 @@
def list(self):
client = self.client
- snaps = client.list_snapshots()
+ snaps = client.list_snapshots()['snapshots']
LOG.debug("List count, %s Snapshots" % len(snaps))
return snaps
@@ -169,6 +170,7 @@
def __init__(self, manager, **kwargs):
super(ServerService, self).__init__(kwargs)
self.client = manager.servers_client
+ self.server_groups_client = manager.server_groups_client
def list(self):
client = self.client
@@ -194,7 +196,7 @@
class ServerGroupService(ServerService):
def list(self):
- client = self.client
+ client = self.server_groups_client
sgs = client.list_server_groups()['server_groups']
LOG.debug("List count, %s Server Groups" % len(sgs))
return sgs
@@ -293,7 +295,7 @@
class FloatingIpService(BaseService):
def __init__(self, manager, **kwargs):
super(FloatingIpService, self).__init__(kwargs)
- self.client = manager.floating_ips_client
+ self.client = manager.compute_floating_ips_client
def list(self):
client = self.client
@@ -381,6 +383,10 @@
def __init__(self, manager, **kwargs):
super(NetworkService, self).__init__(kwargs)
self.client = manager.network_client
+ self.networks_client = manager.networks_client
+ self.subnets_client = manager.subnets_client
+ self.ports_client = manager.ports_client
+ self.floating_ips_client = manager.floating_ips_client
def _filter_by_conf_networks(self, item_list):
if not item_list or not all(('network_id' in i for i in item_list)):
@@ -390,7 +396,7 @@
not in CONF_NETWORKS]
def list(self):
- client = self.client
+ client = self.networks_client
networks = client.list_networks(**self.tenant_filter)
networks = networks['networks']
# filter out networks declared in tempest.conf
@@ -401,7 +407,7 @@
return networks
def delete(self):
- client = self.client
+ client = self.networks_client
networks = self.list()
for n in networks:
try:
@@ -417,7 +423,7 @@
class NetworkFloatingIpService(NetworkService):
def list(self):
- client = self.client
+ client = self.floating_ips_client
flips = client.list_floatingips(**self.tenant_filter)
flips = flips['floatingips']
LOG.debug("List count, %s Network Floating IPs" % len(flips))
@@ -618,7 +624,7 @@
class NetworkPortService(NetworkService):
def list(self):
- client = self.client
+ client = self.ports_client
ports = [port for port in
client.list_ports(**self.tenant_filter)['ports']
if port["device_owner"] == "" or
@@ -631,7 +637,7 @@
return ports
def delete(self):
- client = self.client
+ client = self.ports_client
ports = self.list()
for port in ports:
try:
@@ -675,7 +681,7 @@
class NetworkSubnetService(NetworkService):
def list(self):
- client = self.client
+ client = self.subnets_client
subnets = client.list_subnets(**self.tenant_filter)
subnets = subnets['subnets']
if self.is_preserve:
@@ -684,7 +690,7 @@
return subnets
def delete(self):
- client = self.client
+ client = self.subnets_client
subnets = self.list()
for subnet in subnets:
try:
@@ -810,7 +816,7 @@
def list(self):
client = self.client
- users = client.get_users()
+ users = client.list_users()['users']
if not self.is_save_state:
users = [user for user in users if user['id']
@@ -822,7 +828,7 @@
elif not self.is_save_state: # Never delete admin user
users = [user for user in users if user['name'] !=
- CONF.identity.admin_username]
+ CONF.auth.admin_username]
LOG.debug("List count, %s Users after reconcile" % len(users))
return users
@@ -852,7 +858,7 @@
def list(self):
client = self.client
try:
- roles = client.list_roles()
+ roles = client.list_roles()['roles']
# reconcile roles with saved state and never list admin role
if not self.is_save_state:
roles = [role for role in roles if
@@ -893,7 +899,7 @@
if not self.is_save_state:
tenants = [tenant for tenant in tenants if (tenant['id']
not in self.saved_state_json['tenants'].keys()
- and tenant['name'] != CONF.identity.admin_tenant_name)]
+ and tenant['name'] != CONF.auth.admin_tenant_name)]
if self.is_preserve:
tenants = [tenant for tenant in tenants if tenant['name']
diff --git a/tempest/cmd/init.py b/tempest/cmd/init.py
index 289b978..ac67ce4 100644
--- a/tempest/cmd/init.py
+++ b/tempest/cmd/init.py
@@ -35,7 +35,9 @@
def get_tempest_default_config_dir():
- """Returns the correct default config dir to support both cases of
+ """Get default config directory of tempest
+
+ Returns the correct default config dir to support both cases of
tempest being or not installed in a virtualenv.
Cases considered:
- no virtual env, python2: real_prefix and base_prefix not set
@@ -52,17 +54,21 @@
real_prefix = getattr(sys, 'real_prefix', None)
base_prefix = getattr(sys, 'base_prefix', None)
prefix = sys.prefix
- if real_prefix is None and base_prefix is None:
- # Not running in a virtual environnment of any kind
- return '/etc/tempest'
- elif (real_prefix is None and base_prefix is not None and
- base_prefix == prefix):
- # Probably not running in a virtual environment
+ if (real_prefix is None and
+ (base_prefix is None or base_prefix == prefix)):
+ # Probably not running in a virtual environment.
# NOTE(andreaf) we cannot distinguish this case from the case of
# a virtual environment created with virtualenv, and running python3.
- return '/etc/tempest'
+ # Also if it appears we are not in virtual env and fail to find
+ # global config: '/etc/tempest', fall back to
+ # '[sys.prefix]/etc/tempest'
+ global_conf_dir = '/etc/tempest'
+ if os.path.isdir(global_conf_dir):
+ return global_conf_dir
+ else:
+ return os.path.join(prefix, 'etc/tempest')
else:
- return os.path.join(sys.prefix, 'etc/tempest')
+ return os.path.join(prefix, 'etc/tempest')
class TempestInit(command.Command):
@@ -99,9 +105,12 @@
def copy_config(self, etc_dir, config_dir):
shutil.copytree(config_dir, etc_dir)
- def generate_sample_config(self, local_dir):
+ def generate_sample_config(self, local_dir, config_dir):
+ conf_generator = os.path.join(config_dir,
+ 'config-generator.tempest.conf')
+
subprocess.call(['oslo-config-generator', '--config-file',
- 'tools/config/config-generator.tempest.conf'],
+ conf_generator],
cwd=local_dir)
def create_working_dir(self, local_dir, config_dir):
@@ -109,6 +118,10 @@
if not os.path.isdir(local_dir):
LOG.debug('Creating local working dir: %s' % local_dir)
os.mkdir(local_dir)
+ elif not os.listdir(local_dir) == []:
+ raise OSError("Directory you are trying to initialize already "
+ "exists and is not empty: %s" % local_dir)
+
lock_dir = os.path.join(local_dir, 'tempest_lock')
etc_dir = os.path.join(local_dir, 'etc')
config_path = os.path.join(etc_dir, 'tempest.conf')
@@ -125,7 +138,7 @@
# Create and copy local etc dir
self.copy_config(etc_dir, config_dir)
# Generate the sample config file
- self.generate_sample_config(local_dir)
+ self.generate_sample_config(local_dir, config_dir)
# Update local confs to reflect local paths
self.update_local_conf(config_path, lock_dir, log_dir)
# Generate a testr conf file
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index 5566f63..3df19fc 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -117,11 +117,12 @@
import six
from tempest_lib import auth
from tempest_lib import exceptions as lib_exc
+from tempest_lib.services.compute import flavors_client
import yaml
+from tempest.common import identity
from tempest.common import waiters
from tempest import config
-from tempest.services.compute.json import flavors_client
from tempest.services.compute.json import floating_ips_client
from tempest.services.compute.json import security_group_rules_client
from tempest.services.compute.json import security_groups_client
@@ -129,8 +130,10 @@
from tempest.services.identity.v2.json import identity_client
from tempest.services.image.v2.json import image_client
from tempest.services.network.json import network_client
+from tempest.services.network.json import subnets_client
from tempest.services.object_storage import container_client
from tempest.services.object_storage import object_client
+from tempest.services.telemetry.json import alarming_client
from tempest.services.telemetry.json import telemetry_client
from tempest.services.volume.json import volumes_client
@@ -224,6 +227,12 @@
CONF.identity.region,
endpoint_type=CONF.telemetry.endpoint_type,
**default_params_with_timeout_values)
+ self.alarming = alarming_client.AlarmingClient(
+ _auth,
+ CONF.alarm.catalog_type,
+ CONF.identity.region,
+ endpoint_type=CONF.alarm.endpoint_type,
+ **default_params_with_timeout_values)
self.volumes = volumes_client.VolumesClient(
_auth,
CONF.volume.catalog_type,
@@ -240,6 +249,14 @@
build_interval=CONF.network.build_interval,
build_timeout=CONF.network.build_timeout,
**default_params)
+ self.subnets = subnets_client.SubnetsClient(
+ _auth,
+ CONF.network.catalog_type,
+ CONF.network.region or CONF.identity.region,
+ endpoint_type=CONF.network.endpoint_type,
+ build_interval=CONF.network.build_interval,
+ build_timeout=CONF.network.build_timeout,
+ **default_params)
def load_resources(fname):
@@ -278,7 +295,7 @@
existing = [x['name'] for x in body]
for tenant in tenants:
if tenant not in existing:
- admin.identity.create_tenant(tenant)
+ admin.identity.create_tenant(tenant)['tenant']
else:
LOG.warn("Tenant '%s' already exists in this environment" % tenant)
@@ -286,7 +303,7 @@
def destroy_tenants(tenants):
admin = keystone_admin()
for tenant in tenants:
- tenant_id = admin.identity.get_tenant_by_name(tenant)['id']
+ tenant_id = identity.get_tenant_by_name(admin.identity, tenant)['id']
admin.identity.delete_tenant(tenant_id)
##############
@@ -338,12 +355,13 @@
admin = keystone_admin()
for u in users:
try:
- tenant = admin.identity.get_tenant_by_name(u['tenant'])
+ tenant = identity.get_tenant_by_name(admin.identity, u['tenant'])
except lib_exc.NotFound:
LOG.error("Tenant: %s - not found" % u['tenant'])
continue
try:
- admin.identity.get_user_by_username(tenant['id'], u['name'])
+ identity.get_user_by_username(admin.identity,
+ tenant['id'], u['name'])
LOG.warn("User '%s' already exists in this environment"
% u['name'])
except lib_exc.NotFound:
@@ -356,9 +374,10 @@
def destroy_users(users):
admin = keystone_admin()
for user in users:
- tenant_id = admin.identity.get_tenant_by_name(user['tenant'])['id']
- user_id = admin.identity.get_user_by_username(tenant_id,
- user['name'])['id']
+ tenant_id = identity.get_tenant_by_name(admin.identity,
+ user['tenant'])['id']
+ user_id = identity.get_user_by_username(admin.identity,
+ tenant_id, user['name'])['id']
admin.identity.delete_user(user_id)
@@ -367,10 +386,11 @@
LOG.info("Collecting users")
admin = keystone_admin()
for u in users:
- tenant = admin.identity.get_tenant_by_name(u['tenant'])
+ tenant = identity.get_tenant_by_name(admin.identity, u['tenant'])
u['tenant_id'] = tenant['id']
USERS[u['name']] = u
- body = admin.identity.get_user_by_username(tenant['id'], u['name'])
+ body = identity.get_user_by_username(admin.identity,
+ tenant['id'], u['name'])
USERS[u['name']]['id'] = body['id']
@@ -423,7 +443,7 @@
LOG.info("checking users")
for name, user in six.iteritems(self.users):
client = keystone_admin()
- found = client.identity.get_user(user['id'])
+ found = client.identity.show_user(user['id'])['user']
self.assertEqual(found['name'], user['name'])
self.assertEqual(found['tenantId'], user['tenant_id'])
@@ -769,9 +789,9 @@
LOG.info("Destroying subnets")
for subnet in subnets:
client = client_for_user(subnet['owner'])
- subnet_id = _get_resource_by_name(client.networks,
+ subnet_id = _get_resource_by_name(client.subnets,
'subnets', subnet['name'])['id']
- client.networks.delete_subnet(subnet_id)
+ client.subnets.delete_subnet(subnet_id)
def create_routers(routers):
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/cmd/run_stress.py b/tempest/cmd/run_stress.py
index 0448589..80f1b85 100755
--- a/tempest/cmd/run_stress.py
+++ b/tempest/cmd/run_stress.py
@@ -33,8 +33,7 @@
def discover_stress_tests(path="./", filter_attr=None, call_inherited=False):
- """Discovers all tempest tests and create action out of them
- """
+ """Discovers all tempest tests and create action out of them"""
LOG.info("Start test discovery")
tests = []
testloader = loader.TestLoader()
diff --git a/tempest/cmd/verify_tempest_config.py b/tempest/cmd/verify_tempest_config.py
index 6d53b59..9c8e2a0 100755
--- a/tempest/cmd/verify_tempest_config.py
+++ b/tempest/cmd/verify_tempest_config.py
@@ -24,7 +24,7 @@
from six.moves.urllib import parse as urlparse
from tempest import clients
-from tempest.common import credentials
+from tempest.common import credentials_factory as credentials
from tempest import config
@@ -65,10 +65,10 @@
# Check glance api versions
_, versions = os.image_client.get_versions()
if CONF.image_feature_enabled.api_v1 != contains_version('v1.', versions):
- print_and_or_update('api_v1', 'image_feature_enabled',
+ print_and_or_update('api_v1', 'image-feature-enabled',
not CONF.image_feature_enabled.api_v1, update)
if CONF.image_feature_enabled.api_v2 != contains_version('v2.', versions):
- print_and_or_update('api_v2', 'image_feature_enabled',
+ print_and_or_update('api_v2', 'image-feature-enabled',
not CONF.image_feature_enabled.api_v2, update)
@@ -105,11 +105,11 @@
versions = _get_api_versions(os, 'keystone')
if (CONF.identity_feature_enabled.api_v2 !=
contains_version('v2.', versions)):
- print_and_or_update('api_v2', 'identity_feature_enabled',
+ print_and_or_update('api_v2', 'identity-feature-enabled',
not CONF.identity_feature_enabled.api_v2, update)
if (CONF.identity_feature_enabled.api_v3 !=
contains_version('v3.', versions)):
- print_and_or_update('api_v3', 'identity_feature_enabled',
+ print_and_or_update('api_v3', 'identity-feature-enabled',
not CONF.identity_feature_enabled.api_v3, update)
@@ -118,11 +118,11 @@
versions = _get_api_versions(os, 'cinder')
if (CONF.volume_feature_enabled.api_v1 !=
contains_version('v1.', versions)):
- print_and_or_update('api_v1', 'volume_feature_enabled',
+ print_and_or_update('api_v1', 'volume-feature-enabled',
not CONF.volume_feature_enabled.api_v1, update)
if (CONF.volume_feature_enabled.api_v2 !=
contains_version('v2.', versions)):
- print_and_or_update('api_v2', 'volume_feature_enabled',
+ print_and_or_update('api_v2', 'volume-feature-enabled',
not CONF.volume_feature_enabled.api_v2, update)
@@ -348,7 +348,7 @@
CONF_PARSER = moves.configparser.SafeConfigParser()
CONF_PARSER.optionxform = str
CONF_PARSER.readfp(conf_file)
- icreds = credentials.get_isolated_credentials('verify_tempest_config')
+ icreds = credentials.get_credentials_provider('verify_tempest_config')
try:
os = clients.Manager(icreds.get_primary_creds())
services = check_service_availability(os, update)
@@ -370,7 +370,7 @@
CONF_PARSER.write(outfile)
outfile.close()
finally:
- icreds.clear_isolated_creds()
+ icreds.clear_creds()
if __name__ == "__main__":
diff --git a/tempest/common/compute.py b/tempest/common/compute.py
index 176be51..6fc3843 100644
--- a/tempest/common/compute.py
+++ b/tempest/common/compute.py
@@ -28,7 +28,8 @@
def create_test_server(clients, validatable=False, validation_resources=None,
- tenant_network=None, wait_until=None, **kwargs):
+ tenant_network=None, wait_until=None,
+ volume_backed=False, **kwargs):
"""Common wrapper utility returning a test server.
This method is a common wrapper returning a test server that can be
@@ -41,6 +42,7 @@
:param tenant_network: Tenant network to be used for creating a server.
:param wait_until: Server status to wait for the server to reach after
its creation.
+ :param volume_backed: Whether the instance is volume backed or not.
:returns a tuple
"""
@@ -85,6 +87,29 @@
if wait_until is None:
wait_until = 'ACTIVE'
+ if volume_backed:
+ volume_name = data_utils.rand_name('volume')
+ volumes_client = clients.volumes_v2_client
+ if CONF.volume_feature_enabled.api_v1:
+ volumes_client = clients.volumes_client
+ volume = volumes_client.create_volume(
+ display_name=volume_name,
+ imageRef=image_id)
+ volumes_client.wait_for_volume_status(volume['volume']['id'],
+ 'available')
+
+ bd_map_v2 = [{
+ 'uuid': volume['volume']['id'],
+ 'source_type': 'volume',
+ 'destination_type': 'volume',
+ 'boot_index': 0,
+ 'delete_on_termination': True}]
+ kwargs['block_device_mapping_v2'] = bd_map_v2
+
+ # Since this is boot from volume an image does not need
+ # to be specified.
+ image_id = ''
+
body = clients.servers_client.create_server(name=name, imageRef=image_id,
flavorRef=flavor,
**kwargs)
@@ -102,7 +127,7 @@
# The name of the method to associate a floating IP to as server is too
# long for PEP8 compliance so:
- assoc = clients.floating_ips_client.associate_floating_ip_to_server
+ assoc = clients.compute_floating_ips_client.associate_floating_ip_to_server
if wait_until:
for server in servers:
diff --git a/tempest/common/cred_client.py b/tempest/common/cred_client.py
index 7c3a77f..13baafb 100644
--- a/tempest/common/cred_client.py
+++ b/tempest/common/cred_client.py
@@ -14,29 +14,26 @@
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__)
@six.add_metaclass(abc.ABCMeta)
class CredsClient(object):
- """This class is a wrapper around the identity clients, to provide a
- single interface for managing credentials in both v2 and v3 cases.
- It's not bound to created credentials, only to a specific set of admin
- credentials used for generating credentials.
+ """This class is a wrapper around the identity clients
+
+ to provide a single interface for managing credentials in both v2 and v3
+ cases. It's not bound to created credentials, only to a specific set of
+ admin credentials used for generating credentials.
"""
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,13 +72,20 @@
@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):
self.identity_client.delete_user(user_id)
def _list_roles(self):
- roles = self.identity_client.list_roles()
+ roles = self.identity_client.list_roles()['roles']
return roles
@@ -89,11 +93,15 @@
def create_project(self, name, description):
tenant = self.identity_client.create_tenant(
- name=name, description=description)
+ name=name, description=description)['tenant']
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 +122,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 +132,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 783a5fc..aa237e0 100644
--- a/tempest/common/cred_provider.py
+++ b/tempest/common/cred_provider.py
@@ -18,99 +18,30 @@
import six
from tempest_lib import auth
-from tempest import config
from tempest import exceptions
-CONF = config.CONF
LOG = logging.getLogger(__name__)
-# Type of credentials available from configuration
-CREDENTIAL_TYPES = {
- 'identity_admin': ('identity', 'admin'),
- 'user': ('identity', None),
- 'alt_user': ('identity', 'alt')
-}
-
-DEFAULT_PARAMS = {
- 'disable_ssl_certificate_validation':
- CONF.identity.disable_ssl_certificate_validation,
- 'ca_certs': CONF.identity.ca_certificates_file,
- 'trace_requests': CONF.debug.trace_requests
-}
-
-
-# Read credentials from configuration, builds a Credentials object
-# based on the specified or configured version
-def get_configured_credentials(credential_type, fill_in=True,
- identity_version=None):
- identity_version = identity_version or CONF.identity.auth_version
- if identity_version not in ('v2', 'v3'):
- raise exceptions.InvalidConfiguration(
- 'Unsupported auth version: %s' % identity_version)
- if credential_type not in CREDENTIAL_TYPES:
- raise exceptions.InvalidCredentials()
- conf_attributes = ['username', 'password', 'tenant_name']
- if identity_version == 'v3':
- conf_attributes.append('domain_name')
- # Read the parts of credentials from config
- params = DEFAULT_PARAMS.copy()
- section, prefix = CREDENTIAL_TYPES[credential_type]
- for attr in conf_attributes:
- _section = getattr(CONF, section)
- if prefix is None:
- params[attr] = getattr(_section, attr)
- else:
- params[attr] = getattr(_section, prefix + "_" + attr)
- # Build and validate credentials. We are reading configured credentials,
- # so validate them even if fill_in is False
- credentials = get_credentials(fill_in=fill_in,
- identity_version=identity_version, **params)
- if not fill_in:
- if not credentials.is_valid():
- msg = ("The %s credentials are incorrectly set in the config file."
- " Double check that all required values are assigned" %
- credential_type)
- raise exceptions.InvalidConfiguration(msg)
- return credentials
-
-
-# Wrapper around auth.get_credentials to use the configured identity version
-# is none is specified
-def get_credentials(fill_in=True, identity_version=None, **kwargs):
- params = dict(DEFAULT_PARAMS, **kwargs)
- identity_version = identity_version or CONF.identity.auth_version
- # In case of "v3" add the domain from config if not specified
- if identity_version == 'v3':
- domain_fields = set(x for x in auth.KeystoneV3Credentials.ATTRIBUTES
- if 'domain' in x)
- if not domain_fields.intersection(kwargs.keys()):
- domain_name = CONF.auth.default_credentials_domain_name
- params['user_domain_name'] = domain_name
-
- auth_url = CONF.identity.uri_v3
- else:
- auth_url = CONF.identity.uri
- return auth.get_credentials(auth_url,
- fill_in=fill_in,
- identity_version=identity_version,
- **params)
-
@six.add_metaclass(abc.ABCMeta)
class CredentialProvider(object):
- def __init__(self, identity_version=None, 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: If specified it will return credentials of the
- corresponding identity version, otherwise it
- uses auth_version from configuration
+
+ :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.identity_version = identity_version
self.name = name or "test_creds"
- self.identity_version = identity_version or CONF.identity.auth_version
+ 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)
@@ -128,7 +59,7 @@
return
@abc.abstractmethod
- def clear_isolated_creds(self):
+ def clear_creds(self):
return
@abc.abstractmethod
diff --git a/tempest/common/credentials.py b/tempest/common/credentials.py
deleted file mode 100644
index 71d905f..0000000
--- a/tempest/common/credentials.py
+++ /dev/null
@@ -1,93 +0,0 @@
-# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
-# 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 os
-
-from tempest.common import accounts
-from tempest.common import cred_provider
-from tempest.common import isolated_creds
-from tempest import config
-from tempest import exceptions
-
-CONF = config.CONF
-
-
-# Return the right implementation of CredentialProvider based on config
-# Dropping interface and password, as they are never used anyways
-# TODO(andreaf) Drop them from the CredentialsProvider interface completely
-def get_isolated_credentials(name, network_resources=None,
- force_tenant_isolation=False,
- identity_version=None):
- # If a test requires a new account to work, it can have it via forcing
- # tenant isolation. A new account will be produced only for that test.
- # In case admin credentials are not available for the account creation,
- # the test should be skipped else it would fail.
- if CONF.auth.allow_tenant_isolation or force_tenant_isolation:
- return isolated_creds.IsolatedCreds(
- name=name,
- network_resources=network_resources,
- identity_version=identity_version)
- 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 accounts.Accounts(name=name,
- identity_version=identity_version)
- else:
- return accounts.NotLockingAccounts(
- name=name, identity_version=identity_version)
-
-
-# We want a helper function here to check and see if admin credentials
-# are available so we can do a single call from skip_checks if admin
-# creds area vailable.
-def is_admin_available():
- is_admin = True
- # If tenant isolation is enabled admin will be available
- if CONF.auth.allow_tenant_isolation:
- return is_admin
- # 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')
- if not check_accounts.admin_available():
- is_admin = False
- else:
- try:
- cred_provider.get_configured_credentials('identity_admin',
- fill_in=False)
- except exceptions.InvalidConfiguration:
- is_admin = False
- return is_admin
-
-
-# We want a helper function here to check and see if alt credentials
-# are available so we can do a single call from skip_checks if alt
-# creds area vailable.
-def is_alt_available():
- # If tenant isolation is enabled admin will be available
- if CONF.auth.allow_tenant_isolation:
- return True
- # 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')
- else:
- check_accounts = accounts.NotLockingAccounts(name='check_alt')
- try:
- if not check_accounts.is_multi_user():
- return False
- else:
- return True
- except exceptions.InvalidConfiguration:
- return False
diff --git a/tempest/common/credentials_factory.py b/tempest/common/credentials_factory.py
new file mode 100644
index 0000000..95dcafc
--- /dev/null
+++ b/tempest/common/credentials_factory.py
@@ -0,0 +1,331 @@
+# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
+# 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 os
+
+from oslo_concurrency import lockutils
+from oslo_log import log as logging
+from tempest_lib import auth
+
+from tempest import clients
+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
+
+CONF = config.CONF
+LOG = logging.getLogger(__name__)
+
+
+"""This module provides factories of credential and credential providers
+
+Credentials providers and clients are (going to be) part of tempest-lib,
+and so they may not hold any dependency to tempest configuration.
+
+Methods in this module collect the relevant configuration details and pass
+them to credentials providers and clients, so that test can have easy
+access to these features.
+
+Client managers with hard-coded configured credentials are also moved here,
+to avoid circular dependencies."""
+
+# === Credential Providers
+
+
+# Subset of the parameters of credential providers that depend on configuration
+def _get_common_provider_params():
+ return {
+ 'credentials_domain': CONF.auth.default_credentials_domain_name,
+ 'admin_role': CONF.identity.admin_role
+ }
+
+
+def _get_dynamic_provider_params():
+ return _get_common_provider_params()
+
+
+def _get_preprov_provider_params():
+ _common_params = _get_common_provider_params()
+ reseller_admin_role = CONF.object_storage.reseller_admin_role
+ return dict(_common_params, **dict([
+ ('accounts_lock_dir', lockutils.get_lock_path(CONF)),
+ ('test_accounts_file', CONF.auth.test_accounts_file),
+ ('object_storage_operator_role', CONF.object_storage.operator_role),
+ ('object_storage_reseller_admin_role', reseller_admin_role)
+ ]))
+
+
+class LegacyCredentialProvider(cred_provider.CredentialProvider):
+
+ def __init__(self, identity_version):
+ """Credentials provider which returns credentials from tempest.conf
+
+ Credentials provider which always returns the first and second
+ configured accounts as primary and alt users.
+ Credentials from tempest.conf are deprecated, and this credential
+ provider is also accordingly.
+
+ This credential provider can be used in case of serial test execution
+ to preserve the current behaviour of the serial tempest run.
+
+ :param identity_version: Version of the identity API
+ :return: CredentialProvider
+ """
+ super(LegacyCredentialProvider, self).__init__(
+ identity_version=identity_version)
+ self._creds = {}
+
+ def _unique_creds(self, cred_arg=None):
+ """Verify that the configured credentials are valid and distinct """
+ try:
+ user = self.get_primary_creds()
+ alt_user = self.get_alt_creds()
+ return getattr(user, cred_arg) != getattr(alt_user, cred_arg)
+ except exceptions.InvalidCredentials as ic:
+ msg = "At least one of the configured credentials is " \
+ "not valid: %s" % ic.message
+ raise exceptions.InvalidConfiguration(msg)
+
+ def is_multi_user(self):
+ return self._unique_creds('username')
+
+ def is_multi_tenant(self):
+ return self._unique_creds('tenant_id')
+
+ def get_primary_creds(self):
+ if self._creds.get('primary'):
+ return self._creds.get('primary')
+ primary_credential = get_configured_credentials(
+ credential_type='user', fill_in=False,
+ identity_version=self.identity_version)
+ self._creds['primary'] = cred_provider.TestResources(
+ primary_credential)
+ return self._creds['primary']
+
+ def get_alt_creds(self):
+ if self._creds.get('alt'):
+ return self._creds.get('alt')
+ alt_credential = get_configured_credentials(
+ credential_type='alt_user', fill_in=False,
+ identity_version=self.identity_version)
+ self._creds['alt'] = cred_provider.TestResources(
+ alt_credential)
+ return self._creds['alt']
+
+ def clear_creds(self):
+ self._creds = {}
+
+ def get_admin_creds(self):
+ if self._creds.get('admin'):
+ return self._creds.get('admin')
+ creds = get_configured_credentials(
+ "identity_admin", fill_in=False)
+ self._creds['admin'] = cred_provider.TestResources(creds)
+ return self._creds['admin']
+
+ def get_creds_by_roles(self, roles, force_new=False):
+ msg = "Credentials being specified through the config file can not be"\
+ " used with tests that specify using credentials by roles. "\
+ "Either exclude/skip the tests doing this or use either an "\
+ "test_accounts_file or dynamic credentials."
+ raise exceptions.InvalidConfiguration(msg)
+
+ def is_role_available(self, role):
+ # NOTE(andreaf) LegacyCredentialProvider does not support credentials
+ # by role, so returning always False.
+ # Test that rely on credentials by role should use this to skip
+ # when this is credential provider is used
+ return False
+
+
+# Return the right implementation of CredentialProvider based on config
+# Dropping interface and password, as they are never used anyways
+# TODO(andreaf) Drop them from the CredentialsProvider interface completely
+def get_credentials_provider(name, network_resources=None,
+ force_tenant_isolation=False,
+ identity_version=None):
+ # If a test requires a new account to work, it can have it via forcing
+ # dynamic credentials. A new account will be produced only for that test.
+ # In case admin credentials are not available for the account creation,
+ # the test should be skipped else it would fail.
+ identity_version = identity_version or CONF.identity.auth_version
+ if CONF.auth.use_dynamic_credentials or force_tenant_isolation:
+ admin_creds = get_configured_credentials(
+ 'identity_admin', fill_in=True, identity_version=identity_version)
+ return dynamic_creds.DynamicCredentialProvider(
+ name=name,
+ network_resources=network_resources,
+ identity_version=identity_version,
+ admin_creds=admin_creds,
+ **_get_dynamic_provider_params())
+ 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,
+ **_get_preprov_provider_params())
+ else:
+ # Dynamic credentials are disabled, and the account file is not
+ # defined - we fall back on credentials configured in tempest.conf
+ return LegacyCredentialProvider(identity_version=identity_version)
+
+
+# We want a helper function here to check and see if admin credentials
+# are available so we can do a single call from skip_checks if admin
+# creds area available.
+# This depends on identity_version as there may be admin credentials
+# available for v2 but not for v3.
+def is_admin_available(identity_version):
+ is_admin = True
+ # If dynamic credentials is enabled admin will be available
+ if CONF.auth.use_dynamic_credentials:
+ return is_admin
+ # 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 = preprov_creds.PreProvisionedCredentialProvider(
+ identity_version=identity_version, name='check_admin',
+ **_get_preprov_provider_params())
+ if not check_accounts.admin_available():
+ is_admin = False
+ else:
+ try:
+ get_configured_credentials('identity_admin', fill_in=False,
+ identity_version=identity_version)
+ except exceptions.InvalidConfiguration:
+ is_admin = False
+ return is_admin
+
+
+# We want a helper function here to check and see if alt credentials
+# are available so we can do a single call from skip_checks if alt
+# creds area available.
+# This depends on identity_version as there may be alt credentials
+# available for v2 but not for v3.
+def is_alt_available(identity_version):
+ # If dynamic credentials is enabled alt will be available
+ if CONF.auth.use_dynamic_credentials:
+ return True
+ # 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 = preprov_creds.PreProvisionedCredentialProvider(
+ identity_version=identity_version, name='check_alt',
+ **_get_preprov_provider_params())
+ else:
+ check_accounts = LegacyCredentialProvider(identity_version)
+ try:
+ if not check_accounts.is_multi_user():
+ return False
+ else:
+ return True
+ except exceptions.InvalidConfiguration:
+ return False
+
+# === Credentials
+
+# Type of credentials available from configuration
+CREDENTIAL_TYPES = {
+ 'identity_admin': ('auth', 'admin'),
+ 'user': ('identity', None),
+ 'alt_user': ('identity', 'alt')
+}
+
+DEFAULT_PARAMS = {
+ 'disable_ssl_certificate_validation':
+ CONF.identity.disable_ssl_certificate_validation,
+ 'ca_certs': CONF.identity.ca_certificates_file,
+ 'trace_requests': CONF.debug.trace_requests
+}
+
+
+# Read credentials from configuration, builds a Credentials object
+# based on the specified or configured version
+def get_configured_credentials(credential_type, fill_in=True,
+ identity_version=None):
+ identity_version = identity_version or CONF.identity.auth_version
+
+ if identity_version not in ('v2', 'v3'):
+ raise exceptions.InvalidConfiguration(
+ 'Unsupported auth version: %s' % identity_version)
+
+ if credential_type not in CREDENTIAL_TYPES:
+ raise exceptions.InvalidCredentials()
+ conf_attributes = ['username', 'password', 'tenant_name']
+
+ if identity_version == 'v3':
+ conf_attributes.append('domain_name')
+ # Read the parts of credentials from config
+ params = DEFAULT_PARAMS.copy()
+ section, prefix = CREDENTIAL_TYPES[credential_type]
+ for attr in conf_attributes:
+ _section = getattr(CONF, section)
+ if prefix is None:
+ params[attr] = getattr(_section, attr)
+ else:
+ params[attr] = getattr(_section, prefix + "_" + attr)
+ # Build and validate credentials. We are reading configured credentials,
+ # so validate them even if fill_in is False
+ credentials = get_credentials(fill_in=fill_in,
+ identity_version=identity_version, **params)
+ if not fill_in:
+ if not credentials.is_valid():
+ msg = ("The %s credentials are incorrectly set in the config file."
+ " Double check that all required values are assigned" %
+ credential_type)
+ raise exceptions.InvalidConfiguration(msg)
+ return credentials
+
+
+# Wrapper around auth.get_credentials to use the configured identity version
+# is none is specified
+def get_credentials(fill_in=True, identity_version=None, **kwargs):
+ params = dict(DEFAULT_PARAMS, **kwargs)
+ identity_version = identity_version or CONF.identity.auth_version
+ # In case of "v3" add the domain from config if not specified
+ if identity_version == 'v3':
+ domain_fields = set(x for x in auth.KeystoneV3Credentials.ATTRIBUTES
+ if 'domain' in x)
+ if not domain_fields.intersection(kwargs.keys()):
+ domain_name = CONF.auth.default_credentials_domain_name
+ params['user_domain_name'] = domain_name
+
+ auth_url = CONF.identity.uri_v3
+ else:
+ auth_url = CONF.identity.uri
+ return auth.get_credentials(auth_url,
+ fill_in=fill_in,
+ identity_version=identity_version,
+ **params)
+
+# === Credential / client managers
+
+
+class ConfiguredUserManager(clients.Manager):
+ """Manager that uses user credentials for its managed client objects"""
+
+ def __init__(self, service=None):
+ super(ConfiguredUserManager, self).__init__(
+ credentials=get_configured_credentials('user'),
+ service=service)
+
+
+class AdminManager(clients.Manager):
+ """Manager that uses admin credentials for its managed client objects"""
+
+ def __init__(self, service=None):
+ super(AdminManager, self).__init__(
+ credentials=get_configured_credentials('identity_admin'),
+ service=service)
diff --git a/tempest/common/custom_matchers.py b/tempest/common/custom_matchers.py
index 839088c..8ba33ed 100644
--- a/tempest/common/custom_matchers.py
+++ b/tempest/common/custom_matchers.py
@@ -19,8 +19,7 @@
class ExistsAllResponseHeaders(object):
- """
- Specific matcher to check the existence of Swift's response headers
+ """Specific matcher to check the existence of Swift's response headers
This matcher checks the existence of common headers for each HTTP method
or the target, which means account, container or object.
@@ -30,7 +29,8 @@
"""
def __init__(self, target, method):
- """
+ """Initialization of ExistsAllResponseHeaders
+
param: target Account/Container/Object
param: method PUT/GET/HEAD/DELETE/COPY/POST
"""
@@ -38,7 +38,8 @@
self.method = method
def match(self, actual):
- """
+ """Check headers
+
param: actual HTTP response headers
"""
# Check common headers for all HTTP methods
@@ -95,10 +96,7 @@
class NonExistentHeader(object):
- """
- Informs an error message for end users in the case of missing a
- certain header in Swift's responses
- """
+ """Informs an error message in the case of missing a certain header"""
def __init__(self, header):
self.header = header
@@ -111,9 +109,7 @@
class AreAllWellFormatted(object):
- """
- Specific matcher to check the correctness of formats of values of Swift's
- response headers
+ """Specific matcher to check the correctness of formats of values
This matcher checks the format of values of response headers.
When checking the format of values of 'specific' headers such as
@@ -149,10 +145,7 @@
class InvalidFormat(object):
- """
- Informs an error message for end users if a format of a certain header
- is invalid
- """
+ """Informs an error message if a format of a certain header is invalid"""
def __init__(self, key, value):
self.key = key
@@ -166,8 +159,9 @@
class MatchesDictExceptForKeys(object):
- """Matches two dictionaries. Verifies all items are equals except for those
- identified by a list of keys.
+ """Matches two dictionaries.
+
+ Verifies all items are equals except for those identified by a list of keys
"""
def __init__(self, expected, excluded_keys=None):
diff --git a/tempest/common/isolated_creds.py b/tempest/common/dynamic_creds.py
similarity index 80%
rename from tempest/common/isolated_creds.py
rename to tempest/common/dynamic_creds.py
index a4081c9..e950c3e 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/dynamic_creds.py
@@ -28,42 +28,63 @@
LOG = logging.getLogger(__name__)
-class IsolatedCreds(cred_provider.CredentialProvider):
+class DynamicCredentialProvider(cred_provider.CredentialProvider):
- def __init__(self, identity_version=None, name=None,
- network_resources=None):
- super(IsolatedCreds, self).__init__(identity_version, name,
- network_resources)
+ def __init__(self, identity_version, name=None, network_resources=None,
+ credentials_domain=None, admin_role=None, admin_creds=None):
+ """Creates credentials dynamically for tests
+
+ A credential provider that, based on an initial set of
+ admin credentials, creates new credentials on the fly for
+ tests to use and then discard.
+
+ :param str identity_version: identity API version to use `v2` or `v3`
+ :param str admin_role: name of the admin role added to admin users
+ :param str name: names of dynamic resources include this parameter
+ when specified
+ :param str credentials_domain: name of the domain where the users
+ are created. If not defined, the project
+ domain from admin_credentials is used
+ :param dict network_resources: network resources to be created for
+ the created credentials
+ :param Credentials admin_creds: initial admin credentials
+ """
+ super(DynamicCredentialProvider, self).__init__(
+ identity_version=identity_version, admin_role=admin_role,
+ name=name, credentials_domain=credentials_domain,
+ network_resources=network_resources)
self.network_resources = network_resources
- self.isolated_creds = {}
+ self._creds = {}
self.ports = []
- self.default_admin_creds = cred_provider.get_configured_credentials(
- 'identity_admin', fill_in=True,
- identity_version=self.identity_version)
- self.identity_admin_client, self.network_admin_client = (
- self._get_admin_clients())
+ self.default_admin_creds = admin_creds
+ (self.identity_admin_client, self.network_admin_client,
+ self.networks_admin_client,
+ self.subnets_admin_client,
+ self.ports_admin_client) = self._get_admin_clients()
# Domain where isolated credentials are provisioned (v3 only).
# Use that of the admin account is None is configured.
self.creds_domain_name = None
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)
def _get_admin_clients(self):
- """
- Returns a tuple with instances of the following admin clients (in this
- order):
+ """Returns a tuple with instances of the following admin clients
+
+ (in this order):
identity
network
"""
os = clients.Manager(self.default_admin_creds)
if self.identity_version == 'v2':
- return os.identity_client, os.network_client
+ return (os.identity_client, os.network_client, os.networks_client,
+ os.subnets_client, os.ports_client)
else:
- return os.identity_v3_client, os.network_client
+ return (os.identity_v3_client, os.network_client,
+ os.networks_client, os.subnets_client, os.ports_client)
def _create_creds(self, suffix="", admin=False, roles=None):
"""Create random credentials under the following schema.
@@ -95,7 +116,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:
@@ -158,7 +179,7 @@
return network, subnet, router
def _create_network(self, name, tenant_id):
- resp_body = self.network_admin_client.create_network(
+ resp_body = self.networks_admin_client.create_network(
name=name, tenant_id=tenant_id)
return resp_body['network']
@@ -168,7 +189,7 @@
for subnet_cidr in base_cidr.subnet(mask_bits):
try:
if self.network_resources:
- resp_body = self.network_admin_client.\
+ resp_body = self.subnets_admin_client.\
create_subnet(
network_id=network_id, cidr=str(subnet_cidr),
name=subnet_name,
@@ -176,7 +197,7 @@
enable_dhcp=self.network_resources['dhcp'],
ip_version=4)
else:
- resp_body = self.network_admin_client.\
+ resp_body = self.subnets_admin_client.\
create_subnet(network_id=network_id,
cidr=str(subnet_cidr),
name=subnet_name,
@@ -205,17 +226,17 @@
router_id, subnet_id)
def get_credentials(self, credential_type):
- if self.isolated_creds.get(str(credential_type)):
- credentials = self.isolated_creds[str(credential_type)]
+ if self._creds.get(str(credential_type)):
+ credentials = self._creds[str(credential_type)]
else:
if credential_type in ['primary', 'alt', 'admin']:
is_admin = (credential_type == 'admin')
credentials = self._create_creds(admin=is_admin)
else:
credentials = self._create_creds(roles=credential_type)
- self.isolated_creds[str(credential_type)] = credentials
+ self._creds[str(credential_type)] = credentials
# Maintained until tests are ported
- LOG.info("Acquired isolated creds:\n credentials: %s"
+ LOG.info("Acquired dynamic creds:\n credentials: %s"
% credentials)
if (CONF.service_available.neutron and
not CONF.baremetal.driver_enabled and
@@ -240,15 +261,15 @@
def get_creds_by_roles(self, roles, force_new=False):
roles = list(set(roles))
# The roles list as a str will become the index as the dict key for
- # the created credentials set in the isolated_creds dict.
- exist_creds = self.isolated_creds.get(str(roles))
+ # the created credentials set in the dynamic_creds dict.
+ exist_creds = self._creds.get(str(roles))
# If force_new flag is True 2 cred sets with the same roles are needed
# handle this by creating a separate index for old one to store it
# separately for cleanup
if exist_creds and force_new:
- new_index = str(roles) + '-' + str(len(self.isolated_creds))
- self.isolated_creds[new_index] = exist_creds
- del self.isolated_creds[str(roles)]
+ new_index = str(roles) + '-' + str(len(self._creds))
+ self._creds[new_index] = exist_creds
+ del self._creds[str(roles)]
return self.get_credentials(roles)
def _clear_isolated_router(self, router_id, router_name):
@@ -260,15 +281,15 @@
router_name)
def _clear_isolated_subnet(self, subnet_id, subnet_name):
- net_client = self.network_admin_client
+ client = self.subnets_admin_client
try:
- net_client.delete_subnet(subnet_id)
+ client.delete_subnet(subnet_id)
except lib_exc.NotFound:
LOG.warn('subnet with name: %s not found for delete' %
subnet_name)
def _clear_isolated_network(self, network_id, network_name):
- net_client = self.network_admin_client
+ net_client = self.networks_admin_client
try:
net_client.delete_network(network_id)
except lib_exc.NotFound:
@@ -289,8 +310,8 @@
def _clear_isolated_net_resources(self):
net_client = self.network_admin_client
- for cred in self.isolated_creds:
- creds = self.isolated_creds.get(cred)
+ for cred in self._creds:
+ creds = self._creds.get(cred)
if (not creds or not any([creds.router, creds.network,
creds.subnet])):
continue
@@ -317,11 +338,11 @@
self._clear_isolated_network(creds.network['id'],
creds.network['name'])
- def clear_isolated_creds(self):
- if not self.isolated_creds:
+ def clear_creds(self):
+ if not self._creds:
return
self._clear_isolated_net_resources()
- for creds in six.itervalues(self.isolated_creds):
+ for creds in six.itervalues(self._creds):
try:
self.creds_client.delete_user(creds.user_id)
except lib_exc.NotFound:
@@ -334,7 +355,7 @@
except lib_exc.NotFound:
LOG.warn("tenant with name: %s not found for delete" %
creds.tenant_name)
- self.isolated_creds = {}
+ self._creds = {}
def is_multi_user(self):
return True
diff --git a/tempest/common/fixed_network.py b/tempest/common/fixed_network.py
index b81830a..1928a22 100644
--- a/tempest/common/fixed_network.py
+++ b/tempest/common/fixed_network.py
@@ -15,11 +15,8 @@
from tempest_lib.common.utils import misc as misc_utils
-from tempest import config
from tempest import exceptions
-CONF = config.CONF
-
LOG = logging.getLogger(__name__)
@@ -31,14 +28,14 @@
object to use for making the network lists api request
:return: The full dictionary for the network in question
:rtype: dict
- :raises InvalidConfiguration: If the name provided is invalid, the networks
+ :raises InvalidTestResource: If the name provided is invalid, the networks
list returns a 404, there are no found networks, or the found network
is invalid
"""
caller = misc_utils.find_test_caller()
if not name:
- raise exceptions.InvalidConfiguration()
+ raise exceptions.InvalidTestResource(type='network', name=name)
networks = compute_networks_client.list_networks()['networks']
networks = [n for n in networks if n['label'] == name]
@@ -53,13 +50,13 @@
if caller:
msg = '(%s) %s' % (caller, msg)
LOG.warn(msg)
- raise exceptions.InvalidConfiguration()
+ raise exceptions.InvalidTestResource(type='network', name=name)
else:
msg = "Network with name: %s not found" % name
if caller:
msg = '(%s) %s' % (caller, msg)
LOG.warn(msg)
- raise exceptions.InvalidConfiguration()
+ raise exceptions.InvalidTestResource(type='network', name=name)
# To be consistent between neutron and nova network always use name even
# if label is used in the api response. If neither is present than then
# the returned network is invalid.
@@ -69,12 +66,13 @@
if caller:
msg = '(%s) %s' % (caller, msg)
LOG.warn(msg)
- raise exceptions.InvalidConfiguration()
+ raise exceptions.InvalidTestResource(type='network', name=name)
network['name'] = name
return network
-def get_tenant_network(creds_provider, compute_networks_client):
+def get_tenant_network(creds_provider, compute_networks_client,
+ shared_network_name):
"""Get a network usable by the primary tenant
:param creds_provider: instance of credential provider
@@ -83,23 +81,24 @@
neutron and nova-network cases. If this is not an admin network
client, set_network_kwargs might fail in case fixed_network_name
is the network to be used, and it's not visible to the tenant
+ :param shared_network_name: name of the shared network to be used if no
+ tenant network is available in the creds provider
:return a dict with 'id' and 'name' of the network
"""
caller = misc_utils.find_test_caller()
- fixed_network_name = CONF.compute.fixed_network_name
net_creds = creds_provider.get_primary_creds()
network = getattr(net_creds, 'network', None)
if not network or not network.get('name'):
- if fixed_network_name:
+ if shared_network_name:
msg = ('No valid network provided or created, defaulting to '
'fixed_network_name')
if caller:
msg = '(%s) %s' % (caller, msg)
LOG.debug(msg)
try:
- network = get_network_from_name(fixed_network_name,
+ network = get_network_from_name(shared_network_name,
compute_networks_client)
- except exceptions.InvalidConfiguration:
+ except exceptions.InvalidTestResource:
network = {}
msg = ('Found network %s available for tenant' % network)
if caller:
diff --git a/tempest/common/generator/base_generator.py b/tempest/common/generator/base_generator.py
index 3e09300..a66002f 100644
--- a/tempest/common/generator/base_generator.py
+++ b/tempest/common/generator/base_generator.py
@@ -41,9 +41,7 @@
def simple_generator(fn):
- """
- Decorator for simple generators that return one value
- """
+ """Decorator for simple generators that return one value"""
@functools.wraps(fn)
def wrapped(self, schema):
result = fn(self, schema)
@@ -110,9 +108,7 @@
jsonschema.validate(schema, self.schema)
def generate_scenarios(self, schema, path=None):
- """
- Generates the scenario (all possible test cases) out of the given
- schema.
+ """Generate scenario (all possible test cases) out of the given schema
:param schema: a dict style schema (see ``BasicGeneratorSet.schema``)
:param path: the schema path if the given schema is a subschema
@@ -157,9 +153,10 @@
return scenarios
def generate_payload(self, test, schema):
- """
- Generates one jsonschema out of the given test. It's mandatory to use
- generate_scenarios before to register all needed variables to the test.
+ """Generates one jsonschema out of the given test.
+
+ It's mandatory to use generate_scenarios before to register all needed
+ variables to the test.
:param test: A test object (scenario) with all _negtest variables on it
:param schema: schema for the test
diff --git a/tempest/common/glance_http.py b/tempest/common/glance_http.py
index 868a3e9..e5431a0 100644
--- a/tempest/common/glance_http.py
+++ b/tempest/common/glance_http.py
@@ -203,8 +203,7 @@
class OpenSSLConnectionDelegator(object):
- """
- An OpenSSL.SSL.Connection delegator.
+ """An OpenSSL.SSL.Connection delegator.
Supplies an additional 'makefile' method which httplib requires
and is not present in OpenSSL.SSL.Connection.
@@ -225,9 +224,8 @@
class VerifiedHTTPSConnection(httplib.HTTPSConnection):
- """
- Extended HTTPSConnection which uses the OpenSSL library
- for enhanced SSL support.
+ """Extended HTTPSConnection which uses OpenSSL library for enhanced SSL
+
Note: Much of this functionality can eventually be replaced
with native Python 3.3 code.
"""
@@ -247,11 +245,10 @@
@staticmethod
def host_matches_cert(host, x509):
- """
- Verify that the the x509 certificate we have received
- from 'host' correctly identifies the server we are
- connecting to, ie that the certificate's Common Name
- or a Subject Alternative Name matches 'host'.
+ """Verify that the x509 certificate we have received from 'host'
+
+ Identifies the server we are connecting to, ie that the certificate's
+ Common Name or a Subject Alternative Name matches 'host'.
"""
# First see if we can match the CN
if x509.get_subject().commonName == host:
@@ -289,9 +286,7 @@
return preverify_ok
def setcontext(self):
- """
- Set up the OpenSSL context.
- """
+ """Set up the OpenSSL context."""
self.context = OpenSSL.SSL.Context(OpenSSL.SSL.SSLv23_METHOD)
if self.ssl_compression is False:
@@ -336,10 +331,7 @@
self.context.set_default_verify_paths()
def connect(self):
- """
- Connect to an SSL port using the OpenSSL library and apply
- per-connection parameters.
- """
+ """Connect to SSL port and apply per-connection parameters."""
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if self.timeout is not None:
# '0' microseconds
diff --git a/tempest/common/identity.py b/tempest/common/identity.py
new file mode 100644
index 0000000..2179363
--- /dev/null
+++ b/tempest/common/identity.py
@@ -0,0 +1,32 @@
+# Copyright 2015 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.
+
+from tempest_lib import exceptions as lib_exc
+
+
+def get_tenant_by_name(client, tenant_name):
+ tenants = client.list_tenants()['tenants']
+ for tenant in tenants:
+ if tenant['name'] == tenant_name:
+ return tenant
+ raise lib_exc.NotFound('No such tenant(%s) in %s' % (tenant_name, tenants))
+
+
+def get_user_by_username(client, tenant_id, username):
+ users = client.list_tenant_users(tenant_id)['users']
+ for user in users:
+ if user['name'] == username:
+ return user
+ raise lib_exc.NotFound('No such user(%s) in %s' % (username, users))
diff --git a/tempest/common/negative_rest_client.py b/tempest/common/negative_rest_client.py
index abd8b31..d97411c 100644
--- a/tempest/common/negative_rest_client.py
+++ b/tempest/common/negative_rest_client.py
@@ -22,9 +22,7 @@
class NegativeRestClient(service_client.ServiceClient):
- """
- Version of RestClient that does not raise exceptions.
- """
+ """Version of RestClient that does not raise exceptions."""
def __init__(self, auth_provider, service,
build_interval=None, build_timeout=None,
disable_ssl_certificate_validation=None,
@@ -43,9 +41,7 @@
trace_requests=trace_requests)
def _get_region_and_endpoint_type(self, service):
- """
- Returns the region for a specific service
- """
+ """Returns the region for a specific service"""
service_region = None
service_endpoint_type = None
for cfgname in dir(CONF._config):
diff --git a/tempest/common/accounts.py b/tempest/common/preprov_creds.py
similarity index 61%
rename from tempest/common/accounts.py
rename to tempest/common/preprov_creds.py
index 9e6bee3..74cc3f0 100644
--- a/tempest/common/accounts.py
+++ b/tempest/common/preprov_creds.py
@@ -18,15 +18,15 @@
from oslo_concurrency import lockutils
from oslo_log import log as logging
import six
+from tempest_lib import auth
+from tempest_lib import exceptions as lib_exc
import yaml
from tempest import clients
from tempest.common import cred_provider
from tempest.common import fixed_network
-from tempest import config
from tempest import exceptions
-CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -36,22 +36,55 @@
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)
- if (CONF.auth.test_accounts_file and
- os.path.isfile(CONF.auth.test_accounts_file)):
- accounts = read_accounts_yaml(CONF.auth.test_accounts_file)
+ def __init__(self, identity_version, test_accounts_file,
+ accounts_lock_dir, name=None, credentials_domain=None,
+ admin_role=None, object_storage_operator_role=None,
+ object_storage_reseller_admin_role=None):
+ """Credentials provider using pre-provisioned accounts
+
+ This credentials provider loads the details of pre-provisioned
+ accounts from a YAML file, in the format specified by
+ `etc/accounts.yaml.sample`. It locks accounts while in use, using the
+ external locking mechanism, allowing for multiple python processes
+ to share a single account file, and thus running tests in parallel.
+
+ The accounts_lock_dir must be generated using `lockutils.get_lock_path`
+ from the oslo.concurrency library. For instance:
+
+ accounts_lock_dir = os.path.join(lockutils.get_lock_path(CONF),
+ 'test_accounts')
+
+ Role names for object storage are optional as long as the
+ `operator` and `reseller_admin` credential types are not used in the
+ accounts file.
+
+ :param identity_version: identity version of the credentials
+ :param admin_role: name of the admin role
+ :param test_accounts_file: path to the accounts YAML file
+ :param accounts_lock_dir: the directory for external locking
+ :param name: name of the hash file (optional)
+ :param credentials_domain: name of the domain credentials belong to
+ (if no domain is configured)
+ :param object_storage_operator_role: name of the role
+ :param object_storage_reseller_admin_role: name of the role
+ """
+ super(PreProvisionedCredentialProvider, self).__init__(
+ identity_version=identity_version, name=name,
+ admin_role=admin_role, credentials_domain=credentials_domain)
+ self.test_accounts_file = test_accounts_file
+ if test_accounts_file and os.path.isfile(test_accounts_file):
+ accounts = read_accounts_yaml(self.test_accounts_file)
self.use_default_creds = False
else:
accounts = {}
self.use_default_creds = True
- self.hash_dict = self.get_hash_dict(accounts)
- self.accounts_dir = os.path.join(lockutils.get_lock_path(CONF),
- 'test_accounts')
- self.isolated_creds = {}
+ self.hash_dict = self.get_hash_dict(
+ accounts, admin_role, object_storage_operator_role,
+ object_storage_reseller_admin_role)
+ self.accounts_dir = accounts_lock_dir
+ self._creds = {}
@classmethod
def _append_role(cls, role, account_hash, hash_dict):
@@ -62,7 +95,9 @@
return hash_dict
@classmethod
- def get_hash_dict(cls, accounts):
+ def get_hash_dict(cls, accounts, admin_role,
+ object_storage_operator_role=None,
+ object_storage_reseller_admin_role=None):
hash_dict = {'roles': {}, 'creds': {}, 'networks': {}}
# Loop over the accounts read from the yaml file
for account in accounts:
@@ -86,31 +121,41 @@
# 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,
- hash_dict)
+ if object_storage_operator_role:
+ hash_dict = cls._append_role(
+ object_storage_operator_role, temp_hash_key,
+ hash_dict)
+ else:
+ msg = ("Type 'operator' configured, but no "
+ "object_storage_operator_role specified")
+ raise lib_exc.InvalidCredentials(msg)
elif type == 'reseller_admin':
- hash_dict = cls._append_role(
- CONF.object_storage.reseller_admin_role,
- temp_hash_key,
- hash_dict)
+ if object_storage_reseller_admin_role:
+ hash_dict = cls._append_role(
+ object_storage_reseller_admin_role,
+ temp_hash_key,
+ hash_dict)
+ else:
+ msg = ("Type 'reseller_admin' configured, but no "
+ "object_storage_reseller_admin_role specified")
+ raise lib_exc.InvalidCredentials(msg)
# Populate the network subdict
for resource in resources:
if resource == 'network':
hash_dict['networks'][temp_hash_key] = resources[resource]
else:
- LOG.warning('Unkown resource type %s, ignoring this field'
+ LOG.warning('Unknown resource type %s, ignoring this field'
% resource)
return hash_dict
def is_multi_user(self):
# Default credentials is not a valid option with locking Account
if self.use_default_creds:
- raise exceptions.InvalidConfiguration(
- "Account file %s doesn't exist" % CONF.auth.test_accounts_file)
+ raise lib_exc.InvalidCredentials(
+ "Account file %s doesn't exist" % self.test_accounts_file)
else:
return len(self.hash_dict['creds']) > 1
@@ -146,7 +191,7 @@
names.append(fd.read())
msg = ('Insufficient number of users provided. %s have allocated all '
'the credentials for this allocation request' % ','.join(names))
- raise exceptions.InvalidConfiguration(msg)
+ raise lib_exc.InvalidCredentials(msg)
def _get_match_hash_list(self, roles=None):
hashes = []
@@ -156,7 +201,7 @@
for role in roles:
temp_hashes = self.hash_dict['roles'].get(role, None)
if not temp_hashes:
- raise exceptions.InvalidConfiguration(
+ raise lib_exc.InvalidCredentials(
"No credentials with role: %s specified in the "
"accounts ""file" % role)
hashes.append(temp_hashes)
@@ -172,9 +217,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:
@@ -188,8 +233,8 @@
def _get_creds(self, roles=None):
if self.use_default_creds:
- raise exceptions.InvalidConfiguration(
- "Account file %s doesn't exist" % CONF.auth.test_accounts_file)
+ raise lib_exc.InvalidCredentials(
+ "Account file %s doesn't exist" % self.test_accounts_file)
useable_hashes = self._get_match_hash_list(roles)
free_hash = self._get_free_hash(useable_hashes)
clean_creds = self._sanitize_creds(
@@ -216,7 +261,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]):
@@ -230,42 +275,42 @@
LOG.info("%s returned allocated creds:\n%s" % (self.name, clean_creds))
def get_primary_creds(self):
- if self.isolated_creds.get('primary'):
- return self.isolated_creds.get('primary')
+ if self._creds.get('primary'):
+ return self._creds.get('primary')
net_creds = self._get_creds()
- self.isolated_creds['primary'] = net_creds
+ self._creds['primary'] = net_creds
return net_creds
def get_alt_creds(self):
- if self.isolated_creds.get('alt'):
- return self.isolated_creds.get('alt')
+ if self._creds.get('alt'):
+ return self._creds.get('alt')
net_creds = self._get_creds()
- self.isolated_creds['alt'] = net_creds
+ self._creds['alt'] = net_creds
return net_creds
def get_creds_by_roles(self, roles, force_new=False):
roles = list(set(roles))
- exist_creds = self.isolated_creds.get(six.text_type(roles).encode(
+ exist_creds = self._creds.get(six.text_type(roles).encode(
'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 isolated_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:
new_index = six.text_type(roles).encode('utf-8') + '-' + \
- six.text_type(len(self.isolated_creds)).encode('utf-8')
- self.isolated_creds[new_index] = exist_creds
+ six.text_type(len(self._creds)).encode('utf-8')
+ self._creds[new_index] = exist_creds
net_creds = self._get_creds(roles=roles)
- self.isolated_creds[six.text_type(roles).encode('utf-8')] = net_creds
+ self._creds[six.text_type(roles).encode('utf-8')] = net_creds
return net_creds
- def clear_isolated_creds(self):
- for creds in self.isolated_creds.values():
+ def clear_creds(self):
+ for creds in self._creds.values():
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:
@@ -276,11 +321,16 @@
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]
- credential = cred_provider.get_credentials(
+ # Make sure a domain scope if defined for users in case of V3
+ creds_dict = self._extend_credentials(creds_dict)
+ # This just builds a Credentials object, it does not validate
+ # nor fill with missing fields.
+ credential = auth.get_credentials(
+ auth_url=None, fill_in=False,
identity_version=self.identity_version, **creds_dict)
net_creds = cred_provider.TestResources(credential)
net_clients = clients.Manager(credentials=credential)
@@ -289,67 +339,16 @@
try:
network = fixed_network.get_network_from_name(
net_name, compute_network_client)
- except exceptions.InvalidConfiguration:
+ except exceptions.InvalidTestResource:
network = {}
net_creds.set_resources(network=network)
return net_creds
-
-class NotLockingAccounts(Accounts):
- """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
- to preserve the current behaviour of the serial tempest run.
- """
-
- def _unique_creds(self, cred_arg=None):
- """Verify that the configured credentials are valid and distinct """
- try:
- user = self.get_primary_creds()
- alt_user = self.get_alt_creds()
- return getattr(user, cred_arg) != getattr(alt_user, cred_arg)
- except exceptions.InvalidCredentials as ic:
- msg = "At least one of the configured credentials is " \
- "not valid: %s" % ic.message
- raise exceptions.InvalidConfiguration(msg)
-
- def is_multi_user(self):
- return self._unique_creds('username')
-
- def is_multi_tenant(self):
- return self._unique_creds('tenant_id')
-
- def get_primary_creds(self):
- if self.isolated_creds.get('primary'):
- return self.isolated_creds.get('primary')
- primary_credential = cred_provider.get_configured_credentials(
- credential_type='user', identity_version=self.identity_version)
- self.isolated_creds['primary'] = cred_provider.TestResources(
- primary_credential)
- return self.isolated_creds['primary']
-
- def get_alt_creds(self):
- if self.isolated_creds.get('alt'):
- return self.isolated_creds.get('alt')
- alt_credential = cred_provider.get_configured_credentials(
- credential_type='alt_user',
- identity_version=self.identity_version)
- self.isolated_creds['alt'] = cred_provider.TestResources(
- alt_credential)
- return self.isolated_creds['alt']
-
- def clear_isolated_creds(self):
- self.isolated_creds = {}
-
- def get_admin_creds(self):
- creds = cred_provider.get_configured_credentials(
- "identity_admin", fill_in=False)
- self.isolated_creds['admin'] = cred_provider.TestResources(creds)
- return self.isolated_creds['admin']
-
- def get_creds_by_roles(self, roles, force_new=False):
- msg = "Credentials being specified through the config file can not be"\
- " used with tests that specify using credentials by roles. "\
- "Either exclude/skip the tests doing this or use either an "\
- "test_accounts_file or tenant isolation."
- raise exceptions.InvalidConfiguration(msg)
+ def _extend_credentials(self, creds_dict):
+ # In case of v3, adds a user_domain_name field to the creds
+ # dict if not defined
+ 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())):
+ creds_dict['user_domain_name'] = self.credentials_domain
+ return creds_dict
diff --git a/tempest/common/service_client.py b/tempest/common/service_client.py
index 87e925d..b3a5a09 100644
--- a/tempest/common/service_client.py
+++ b/tempest/common/service_client.py
@@ -57,8 +57,7 @@
class ResponseBodyData(object):
- """Class that wraps an http response and string data into a single value.
- """
+ """Class that wraps an http response and string data into a single value"""
def __init__(self, response, data):
self.response = response
diff --git a/tempest/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py
index 9308390..10654ff 100644
--- a/tempest/common/utils/linux/remote_client.py
+++ b/tempest/common/utils/linux/remote_client.py
@@ -57,6 +57,7 @@
def validate_authentication(self):
"""Validate ssh connection and authentication
+
This method raises an Exception when the validation fails.
"""
self.ssh_client.test_connection_auth()
@@ -171,3 +172,14 @@
if dhcp_client == 'udhcpc' and not fixed_ip:
raise ValueError("need to set 'fixed_ip' for udhcpc client")
return getattr(self, '_renew_lease_' + dhcp_client)(fixed_ip=fixed_ip)
+
+ def mount(self, dev_name, mount_path='/mnt'):
+ cmd_mount = 'sudo mount /dev/%s %s' % (dev_name, mount_path)
+ self.exec_command(cmd_mount)
+
+ def umount(self, mount_path='/mnt'):
+ self.exec_command('sudo umount %s' % mount_path)
+
+ def make_fs(self, dev_name, fs='ext4'):
+ cmd_mkfs = 'sudo /usr/sbin/mke2fs -t %s /dev/%s' % (fs, dev_name)
+ self.exec_command(cmd_mkfs)
diff --git a/tempest/common/validation_resources.py b/tempest/common/validation_resources.py
index debc200..1908b68 100644
--- a/tempest/common/validation_resources.py
+++ b/tempest/common/validation_resources.py
@@ -58,7 +58,7 @@
validation_data['security_group'] = \
create_ssh_security_group(os, add_rule)
if validation_resources['floating_ip']:
- floating_client = os.floating_ips_client
+ floating_client = os.compute_floating_ips_client
validation_data.update(floating_client.create_floating_ip())
return validation_data
@@ -100,7 +100,7 @@
if not has_exception:
has_exception = exc
if 'floating_ip' in validation_data:
- floating_client = os.floating_ips_client
+ floating_client = os.compute_floating_ips_client
fip_id = validation_data['floating_ip']['id']
try:
floating_client.delete_floating_ip(fip_id)
diff --git a/tempest/config.py b/tempest/config.py
index 3d3ddff..c9fe38d 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -53,7 +53,7 @@
"at least `2 * CONC` distinct accounts configured in "
" the `test_accounts_file`, with CONC == the "
"number of concurrent test processes."),
- cfg.BoolOpt('allow_tenant_isolation',
+ cfg.BoolOpt('use_dynamic_credentials',
default=True,
help="Allows test cases to create/destroy tenants and "
"users. This option requires that OpenStack Identity "
@@ -61,6 +61,8 @@
"test cases and parallel execution, can still be "
"achieved configuring a list of test accounts",
deprecated_opts=[cfg.DeprecatedOpt('allow_tenant_isolation',
+ group='auth'),
+ cfg.DeprecatedOpt('allow_tenant_isolation',
group='compute'),
cfg.DeprecatedOpt('allow_tenant_isolation',
group='orchestration')]),
@@ -76,12 +78,32 @@
group='auth')]),
cfg.BoolOpt('create_isolated_networks',
default=True,
- help="If allow_tenant_isolation is set to True and Neutron is "
- "enabled Tempest will try to create a usable network, "
- "subnet, and router when needed for each tenant it "
+ help="If use_dynamic_credentials is set to True and Neutron "
+ "is enabled Tempest will try to create a usable network, "
+ "subnet, and router when needed for each tenant it "
"creates. However in some neutron configurations, like "
"with VLAN provider networks, this doesn't work. So if "
"set to False the isolated networks will not be created"),
+ cfg.StrOpt('admin_username',
+ help="Username for an administrative user. This is needed for "
+ "authenticating requests made by tenant isolation to "
+ "create users and projects",
+ deprecated_group='identity'),
+ cfg.StrOpt('admin_tenant_name',
+ help="Tenant name to use for an administrative user. This is "
+ "needed for authenticating requests made by tenant "
+ "isolation to create users and projects",
+ deprecated_group='identity'),
+ cfg.StrOpt('admin_password',
+ help="Password to use for an administrative user. This is "
+ "needed for authenticating requests made by tenant "
+ "isolation to create users and projects",
+ secret=True,
+ deprecated_group='identity'),
+ cfg.StrOpt('admin_domain_name',
+ help="Admin domain name for authentication (Keystone V3)."
+ "The same domain applies to user and project",
+ deprecated_group='identity'),
]
identity_group = cfg.OptGroup(name='identity',
@@ -133,42 +155,38 @@
help="The endpoint type to use for OpenStack Identity "
"(Keystone) API v3"),
cfg.StrOpt('username',
- help="Username to use for Nova API requests."),
+ help="Username to use for Nova API requests.",
+ deprecated_for_removal=True),
cfg.StrOpt('tenant_name',
- help="Tenant name to use for Nova API requests."),
+ help="Tenant name to use for Nova API requests.",
+ deprecated_for_removal=True),
cfg.StrOpt('admin_role',
default='admin',
help="Role required to administrate keystone."),
cfg.StrOpt('password',
help="API key to use when authenticating.",
- secret=True),
+ secret=True,
+ deprecated_for_removal=True),
cfg.StrOpt('domain_name',
help="Domain name for authentication (Keystone V3)."
- "The same domain applies to user and project"),
+ "The same domain applies to user and project",
+ deprecated_for_removal=True),
cfg.StrOpt('alt_username',
help="Username of alternate user to use for Nova API "
- "requests."),
+ "requests.",
+ deprecated_for_removal=True),
cfg.StrOpt('alt_tenant_name',
help="Alternate user's Tenant name to use for Nova API "
- "requests."),
+ "requests.",
+ deprecated_for_removal=True),
cfg.StrOpt('alt_password',
help="API key to use when authenticating as alternate user.",
- secret=True),
+ secret=True,
+ deprecated_for_removal=True),
cfg.StrOpt('alt_domain_name',
help="Alternate domain name for authentication (Keystone V3)."
- "The same domain applies to user and project"),
- cfg.StrOpt('admin_username',
- help="Administrative Username to use for "
- "Keystone API requests."),
- cfg.StrOpt('admin_tenant_name',
- help="Administrative Tenant name to use for Keystone API "
- "requests."),
- cfg.StrOpt('admin_password',
- help="API key to use when authenticating as admin.",
- secret=True),
- cfg.StrOpt('admin_domain_name',
- help="Admin domain name for authentication (Keystone V3)."
- "The same domain applies to user and project"),
+ "The same domain applies to user and project",
+ deprecated_for_removal=True),
cfg.StrOpt('default_domain_id',
default='default',
help="ID of the default domain"),
@@ -219,10 +237,6 @@
cfg.StrOpt('image_ssh_password',
default="password",
help="Password used to authenticate to an instance."),
- cfg.StrOpt('image_alt_ssh_user',
- default="root",
- help="User name used to authenticate to an instance using "
- "the alternate image."),
cfg.IntOpt('build_interval',
default=1,
help="Time in seconds between build status checks."),
@@ -237,6 +251,7 @@
"when sshing to a guest."),
cfg.StrOpt('ssh_auth_method',
default='keypair',
+ choices=('keypair', 'configured', 'adminpass', 'disabled'),
help="Auth method used for authenticate to the instance. "
"Valid choices are: keypair, configured, adminpass "
"and disabled. "
@@ -246,6 +261,7 @@
"Disabled: avoid using ssh when it is an option."),
cfg.StrOpt('ssh_connect_method',
default='floating',
+ choices=('fixed', 'floating'),
help="How to connect to the instance? "
"fixed: using the first ip belongs the fixed network "
"floating: creating and using a floating ip."),
@@ -312,7 +328,13 @@
help='Unallocated floating IP range, which will be used to '
'test the floating IP bulk feature for CRUD operation. '
'This block must not overlap an existing floating IP '
- 'pool.')
+ 'pool.'),
+ cfg.IntOpt('min_compute_nodes',
+ default=1,
+ help=('The minimum number of compute nodes expected. This will '
+ 'be utilized by some multinode specific tests to ensure '
+ 'that requests match the expected size of the cluster '
+ 'you are testing with.'))
]
compute_features_group = cfg.OptGroup(name='compute-feature-enabled',
@@ -404,6 +426,12 @@
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?'),
+ cfg.BoolOpt('personality',
+ default=True,
+ help='Does the test environment support server personality'),
# TODO(mriedem): Remove preserve_ports once juno-eol happens.
cfg.BoolOpt('preserve_ports',
default=False,
@@ -424,6 +452,9 @@
help='Does the test environment support creating instances '
'with multiple ports on the same network? This is only '
'valid when using Neutron.'),
+ cfg.BoolOpt('config_drive',
+ default=True,
+ help='Enable special configuration drive with metadata.'),
]
@@ -456,7 +487,16 @@
cfg.IntOpt('build_interval',
default=1,
help="Time in seconds between image operation status "
- "checks.")
+ "checks."),
+ cfg.ListOpt('container_formats',
+ default=['ami', 'ari', 'aki', 'bare', 'ovf', 'ova'],
+ help="A list of image's container formats "
+ "users can specify."),
+ cfg.ListOpt('disk_formats',
+ default=['ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2',
+ 'vdi', 'iso'],
+ help="A list of image's disk formats "
+ "users can specify.")
]
image_feature_group = cfg.OptGroup(name='image-feature-enabled',
@@ -541,6 +581,10 @@
" with pre-configured ports."
" Supported ports are:"
" ['normal','direct','macvtap']"),
+ cfg.ListOpt('default_network',
+ default=["1.0.0.0/16", "2.0.0.0/16"],
+ help="List of ip pools"
+ " for subnetpools creation"),
]
network_feature_group = cfg.OptGroup(name='network-feature-enabled',
@@ -873,6 +917,20 @@
"notification tests")
]
+alarming_group = cfg.OptGroup(name='alarming',
+ title='Alarming Service Options')
+
+AlarmingGroup = [
+ cfg.StrOpt('catalog_type',
+ default='alarming',
+ help="Catalog type of the Alarming service."),
+ cfg.StrOpt('endpoint_type',
+ default='publicURL',
+ choices=['public', 'admin', 'internal',
+ 'publicURL', 'adminURL', 'internalURL'],
+ help="The endpoint type to use for the alarming service."),
+]
+
telemetry_feature_group = cfg.OptGroup(name='telemetry-feature-enabled',
title='Enabled Ceilometer Features')
@@ -898,29 +956,32 @@
]
-data_processing_group = cfg.OptGroup(name="data_processing",
+data_processing_group = cfg.OptGroup(name="data-processing",
title="Data Processing options")
DataProcessingGroup = [
cfg.StrOpt('catalog_type',
- default='data_processing',
+ default='data-processing',
+ deprecated_group="data_processing",
help="Catalog type of the data processing service."),
cfg.StrOpt('endpoint_type',
default='publicURL',
choices=['public', 'admin', 'internal',
'publicURL', 'adminURL', 'internalURL'],
+ deprecated_group="data_processing",
help="The endpoint type to use for the data processing "
"service."),
]
data_processing_feature_group = cfg.OptGroup(
- name="data_processing-feature-enabled",
+ name="data-processing-feature-enabled",
title="Enabled Data Processing features")
DataProcessingFeaturesGroup = [
cfg.ListOpt('plugins',
default=["vanilla", "hdp"],
+ deprecated_group="data_processing-feature-enabled",
help="List of enabled data processing plugins")
]
@@ -1080,6 +1141,9 @@
cfg.BoolOpt('ceilometer',
default=True,
help="Whether or not Ceilometer is expected to be available"),
+ cfg.BoolOpt('aodh',
+ default=False,
+ help="Whether or not Aodh is expected to be available"),
cfg.BoolOpt('horizon',
default=True,
help="Whether or not Horizon is expected to be available"),
@@ -1226,6 +1290,7 @@
(orchestration_group, OrchestrationGroup),
(telemetry_group, TelemetryGroup),
(telemetry_feature_group, TelemetryFeaturesGroup),
+ (alarming_group, AlarmingGroup),
(dashboard_group, DashboardGroup),
(data_processing_group, DataProcessingGroup),
(data_processing_feature_group, DataProcessingFeaturesGroup),
@@ -1266,9 +1331,7 @@
class TempestConfigPrivate(object):
"""Provides OpenStack configuration information."""
- DEFAULT_CONFIG_DIR = os.path.join(
- os.path.abspath(os.path.dirname(os.path.dirname(__file__))),
- "etc")
+ DEFAULT_CONFIG_DIR = os.path.join(os.getcwd(), "etc")
DEFAULT_CONFIG_FILE = "tempest.conf"
@@ -1298,9 +1361,9 @@
self.telemetry = _CONF.telemetry
self.telemetry_feature_enabled = _CONF['telemetry-feature-enabled']
self.dashboard = _CONF.dashboard
- self.data_processing = _CONF.data_processing
+ self.data_processing = _CONF['data-processing']
self.data_processing_feature_enabled = _CONF[
- 'data_processing-feature-enabled']
+ 'data-processing-feature-enabled']
self.boto = _CONF.boto
self.stress = _CONF.stress
self.scenario = _CONF.scenario
diff --git a/tempest/exceptions.py b/tempest/exceptions.py
index b3d60f6..031df7f 100644
--- a/tempest/exceptions.py
+++ b/tempest/exceptions.py
@@ -17,8 +17,7 @@
class TempestException(Exception):
- """
- Base Tempest Exception
+ """Base Tempest Exception
To correctly use this class, inherit from it and define
a 'message' property. That message will get printf'd
@@ -140,6 +139,13 @@
message = "%(num)d cleanUp operation failed"
+# NOTE(andreaf) This exception is added here to facilitate the migration
+# of get_network_from_name and preprov_creds to tempest-lib, and it should
+# be migrated along with them
+class InvalidTestResource(TempestException):
+ message = "%(name) is not a valid %(type), or the name is ambiguous"
+
+
class RFCViolation(RestClientException):
message = "RFC Violation"
diff --git a/tempest/hacking/checks.py b/tempest/hacking/checks.py
index 06ca09b..1dad3ba 100644
--- a/tempest/hacking/checks.py
+++ b/tempest/hacking/checks.py
@@ -30,6 +30,10 @@
RAND_NAME_HYPHEN_RE = re.compile(r".*rand_name\(.+[\-\_][\"\']\)")
mutable_default_args = re.compile(r"^\s*def .+\((.+=\{\}|.+=\[\])")
TESTTOOLS_SKIP_DECORATOR = re.compile(r'\s*@testtools\.skip\((.*)\)')
+METHOD = re.compile(r"^ def .+")
+METHOD_GET_RESOURCE = re.compile(r"^\s*def (list|show)\_.+")
+METHOD_DELETE_RESOURCE = re.compile(r"^\s*def delete_.+")
+CLASS = re.compile(r"^class .+")
def import_no_clients_in_api_and_scenario_tests(physical_line, filename):
@@ -143,6 +147,81 @@
"decorators.skip_because from tempest-lib")
+def _common_service_clients_check(logical_line, physical_line, filename,
+ ignored_list_file=None):
+ if 'tempest/services/' not in filename:
+ return False
+
+ if ignored_list_file is not None:
+ ignored_list = []
+ with open('tempest/hacking/' + ignored_list_file) as f:
+ for line in f:
+ ignored_list.append(line.strip())
+
+ if filename in ignored_list:
+ return False
+
+ if not METHOD.match(physical_line):
+ return False
+
+ if pep8.noqa(physical_line):
+ return False
+
+ return True
+
+
+def get_resources_on_service_clients(logical_line, physical_line, filename,
+ line_number, lines):
+ """Check that service client names of GET should be consistent
+
+ T110
+ """
+ if not _common_service_clients_check(logical_line, physical_line,
+ filename, 'ignored_list_T110.txt'):
+ return
+
+ for line in lines[line_number:]:
+ if METHOD.match(line) or CLASS.match(line):
+ # the end of a method
+ return
+
+ if 'self.get(' not in line:
+ continue
+
+ if METHOD_GET_RESOURCE.match(logical_line):
+ return
+
+ msg = ("T110: [GET /resources] methods should be list_<resource name>s"
+ " or show_<resource name>")
+ yield (0, msg)
+
+
+def delete_resources_on_service_clients(logical_line, physical_line, filename,
+ line_number, lines):
+ """Check that service client names of DELETE should be consistent
+
+ T111
+ """
+ if not _common_service_clients_check(logical_line, physical_line,
+ filename, 'ignored_list_T111.txt'):
+ return
+
+ for line in lines[line_number:]:
+ if METHOD.match(line) or CLASS.match(line):
+ # the end of a method
+ return
+
+ if 'self.delete(' not in line:
+ continue
+
+ if METHOD_DELETE_RESOURCE.match(logical_line):
+ return
+
+ msg = ("T111: [DELETE /resources/<id>] methods should be "
+ "delete_<resource name>")
+ yield (0, msg)
+
+
def factory(register):
register(import_no_clients_in_api_and_scenario_tests)
register(scenario_tests_need_service_tags)
@@ -152,3 +231,5 @@
register(no_hyphen_at_end_of_rand_name)
register(no_mutable_default_args)
register(no_testtools_skip_decorator)
+ register(get_resources_on_service_clients)
+ register(delete_resources_on_service_clients)
diff --git a/tempest/hacking/ignored_list_T110.txt b/tempest/hacking/ignored_list_T110.txt
new file mode 100644
index 0000000..f522865
--- /dev/null
+++ b/tempest/hacking/ignored_list_T110.txt
@@ -0,0 +1,14 @@
+./tempest/services/database/json/flavors_client.py
+./tempest/services/identity/v3/json/credentials_client.py
+./tempest/services/identity/v3/json/groups_client.py
+./tempest/services/identity/v3/json/identity_client.py
+./tempest/services/identity/v3/json/policy_client.py
+./tempest/services/identity/v3/json/region_client.py
+./tempest/services/messaging/json/messaging_client.py
+./tempest/services/object_storage/object_client.py
+./tempest/services/telemetry/json/alarming_client.py
+./tempest/services/telemetry/json/telemetry_client.py
+./tempest/services/volume/json/qos_client.py
+./tempest/services/volume/json/backups_client.py
+./tempest/services/image/v2/json/image_client.py
+./tempest/services/baremetal/base.py
diff --git a/tempest/hacking/ignored_list_T111.txt b/tempest/hacking/ignored_list_T111.txt
new file mode 100644
index 0000000..8017e76
--- /dev/null
+++ b/tempest/hacking/ignored_list_T111.txt
@@ -0,0 +1 @@
+./tempest/services/baremetal/base.py
diff --git a/tempest/manager.py b/tempest/manager.py
index c39d3e5..9904aa6 100644
--- a/tempest/manager.py
+++ b/tempest/manager.py
@@ -23,38 +23,33 @@
class Manager(object):
-
- """
- Base manager class
+ """Base manager class
Manager objects are responsible for providing a configuration object
and a client object for a test case to use in performing actions.
"""
- def __init__(self, credentials=None):
- """
- We allow overriding of the credentials used within the various
- client classes managed by the Manager object. Left as None, the
- standard username/password/tenant_name[/domain_name] is used.
+ def __init__(self, credentials):
+ """Initialization of base manager class
- :param credentials: Override of the credentials
+ Credentials to be used within the various client classes managed by the
+ Manager object must be defined.
+
+ :param credentials: type Credentials or TestResources
"""
- self.auth_version = CONF.identity.auth_version
- if credentials is None:
- self.credentials = cred_provider.get_configured_credentials('user')
- else:
- self.credentials = credentials
+ self.credentials = credentials
# 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
+ self.auth_version = CONF.identity.auth_version
+ # Tenant isolation creates TestResources, but
+ # PreProvisionedCredentialProvider and some tests create Credentials
if isinstance(credentials, cred_provider.TestResources):
creds = self.credentials.credentials
else:
creds = self.credentials
# Creates an auth provider for the credentials
- self.auth_provider = get_auth_provider(creds)
+ self.auth_provider = get_auth_provider(creds, pre_auth=True)
# FIXME(andreaf) unused
self.client_attr_names = []
@@ -66,7 +61,7 @@
return auth.KeystoneV2AuthProvider, CONF.identity.uri
-def get_auth_provider(credentials):
+def get_auth_provider(credentials, pre_auth=False):
default_params = {
'disable_ssl_certificate_validation':
CONF.identity.disable_ssl_certificate_validation,
@@ -78,4 +73,8 @@
'Credentials must be specified')
auth_provider_class, auth_url = get_auth_provider_class(
credentials)
- return auth_provider_class(credentials, auth_url, **default_params)
+ _auth_provider = auth_provider_class(credentials, auth_url,
+ **default_params)
+ if pre_auth:
+ _auth_provider.set_auth()
+ return _auth_provider
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 7ab3864..147c0ba 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -47,7 +47,8 @@
super(ScenarioTest, cls).setup_clients()
# Clients (in alphabetical order)
cls.flavors_client = cls.manager.flavors_client
- cls.floating_ips_client = cls.manager.floating_ips_client
+ cls.compute_floating_ips_client = (
+ cls.manager.compute_floating_ips_client)
# Glance image client v1
cls.image_client = cls.manager.image_client
# Compute image client
@@ -61,6 +62,10 @@
cls.interface_client = cls.manager.interfaces_client
# Neutron network client
cls.network_client = cls.manager.network_client
+ cls.networks_client = cls.manager.networks_client
+ cls.ports_client = cls.manager.ports_client
+ cls.subnets_client = cls.manager.subnets_client
+ cls.floating_ips_client = cls.manager.floating_ips_client
# Heat client
cls.orchestration_client = cls.manager.orchestration_client
@@ -127,14 +132,13 @@
self.cleanup_waits.append(wait_dict)
def _wait_for_cleanups(self):
- """To handle async delete actions, a list of waits is added
- which will be iterated over as the last step of clearing the
- cleanup queue. That way all the delete calls are made up front
- and the tests won't succeed unless the deletes are eventually
- successful. This is the same basic approach used in the api tests to
- limit cleanup execution time except here it is multi-resource,
- because of the nature of the scenario tests.
- """
+ # To handle async delete actions, a list of waits is added
+ # which will be iterated over as the last step of clearing the
+ # cleanup queue. That way all the delete calls are made up front
+ # and the tests won't succeed unless the deletes are eventually
+ # successful. This is the same basic approach used in the api tests to
+ # limit cleanup execution time except here it is multi-resource,
+ # because of the nature of the scenario tests.
for wait in self.cleanup_waits:
waiter_callable = wait.pop('waiter_callable')
waiter_callable(**wait)
@@ -448,21 +452,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,
@@ -493,15 +497,30 @@
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
proc.communicate()
+
return (proc.returncode == 0) == should_succeed
- return tempest.test.call_until_true(ping, timeout, 1)
+ caller = misc_utils.find_test_caller()
+ LOG.debug('%(caller)s begins to ping %(ip)s in %(timeout)s sec and the'
+ ' expected result is %(should_succeed)s' % {
+ 'caller': caller, 'ip': ip_address, 'timeout': timeout,
+ 'should_succeed':
+ 'reachable' if should_succeed else 'unreachable'
+ })
+ result = tempest.test.call_until_true(ping, timeout, 1)
+ LOG.debug('%(caller)s finishes ping %(ip)s in %(timeout)s sec and the '
+ 'ping result is %(result)s' % {
+ 'caller': caller, 'ip': ip_address, 'timeout': timeout,
+ 'result': 'expected' if result else 'unexpected'
+ })
+ return result
def check_vm_connectivity(self, ip_address,
username=None,
private_key=None,
should_connect=True):
- """
+ """Check server connectivity
+
:param ip_address: server to test against
:param username: server's ssh username
:param private_key: server's ssh private key to be used
@@ -544,22 +563,55 @@
raise
def create_floating_ip(self, thing, pool_name=None):
- """Creates a floating IP and associates to a server using
- Nova clients
- """
+ """Create a floating IP and associates to a server on Nova"""
- floating_ip = (self.floating_ips_client.create_floating_ip(pool_name)
- ['floating_ip'])
+ floating_ip = (self.compute_floating_ips_client.
+ create_floating_ip(pool_name)['floating_ip'])
self.addCleanup(self.delete_wrapper,
- self.floating_ips_client.delete_floating_ip,
+ self.compute_floating_ips_client.delete_floating_ip,
floating_ip['id'])
- self.floating_ips_client.associate_floating_ip_to_server(
+ self.compute_floating_ips_client.associate_floating_ip_to_server(
floating_ip['ip'], thing['id'])
return floating_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)
+ cmd_timestamp = 'sudo sh -c "date > %s/timestamp; sync"' % mount_path
+ ssh_client.exec_command(cmd_timestamp)
+ timestamp = ssh_client.exec_command('sudo cat %s/timestamp'
+ % mount_path)
+ if dev_name is not None:
+ ssh_client.umount(mount_path)
+ return timestamp
+
+ 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'
+ % mount_path)
+ if dev_name is not None:
+ ssh_client.umount(mount_path)
+ return timestamp
+
+ def get_server_or_ip(self, server):
+ if CONF.validation.connect_method == 'floating':
+ ip = self.create_floating_ip(server)['ip']
+ else:
+ ip = server
+ return ip
+
class NetworkScenarioTest(ScenarioTest):
"""Base class for network scenario tests.
+
This class provide helpers for network scenario tests, using the neutron
API. Helpers from ancestor which use the nova network API are overridden
with the neutron API.
@@ -582,29 +634,31 @@
super(NetworkScenarioTest, cls).resource_setup()
cls.tenant_id = cls.manager.identity_client.tenant_id
- def _create_network(self, client=None, tenant_id=None,
- namestart='network-smoke-'):
+ def _create_network(self, client=None, networks_client=None,
+ tenant_id=None, namestart='network-smoke-'):
if not client:
client = self.network_client
+ if not networks_client:
+ networks_client = self.networks_client
if not tenant_id:
tenant_id = client.tenant_id
name = data_utils.rand_name(namestart)
- result = client.create_network(name=name, tenant_id=tenant_id)
- network = net_resources.DeletableNetwork(client=client,
- **result['network'])
+ result = networks_client.create_network(name=name, tenant_id=tenant_id)
+ network = net_resources.DeletableNetwork(
+ networks_client=networks_client, **result['network'])
self.assertEqual(network.name, name)
self.addCleanup(self.delete_wrapper, network.delete)
return network
def _list_networks(self, *args, **kwargs):
"""List networks using admin creds """
- networks_list = self.admin_manager.network_client.list_networks(
+ networks_list = self.admin_manager.networks_client.list_networks(
*args, **kwargs)
return networks_list['networks']
def _list_subnets(self, *args, **kwargs):
"""List subnets using admin creds """
- subnets_list = self.admin_manager.network_client.list_subnets(
+ subnets_list = self.admin_manager.subnets_client.list_subnets(
*args, **kwargs)
return subnets_list['subnets']
@@ -616,7 +670,7 @@
def _list_ports(self, *args, **kwargs):
"""List ports using admin creds """
- ports_list = self.admin_manager.network_client.list_ports(
+ ports_list = self.admin_manager.ports_client.list_ports(
*args, **kwargs)
return ports_list['ports']
@@ -626,17 +680,20 @@
*args, **kwargs)
return agents_list['agents']
- def _create_subnet(self, network, client=None, namestart='subnet-smoke',
- **kwargs):
- """
- Create a subnet for the given network within the cidr block
- configured for tenant networks.
+ def _create_subnet(self, network, client=None, subnets_client=None,
+ namestart='subnet-smoke', **kwargs):
+ """Create a subnet for the given network
+
+ within the cidr block configured for tenant networks.
"""
if not client:
client = self.network_client
+ if not subnets_client:
+ subnets_client = self.subnets_client
def cidr_in_use(cidr, tenant_id):
- """
+ """Check cidr existence
+
:return True if subnet with cidr already exist in tenant
False else
"""
@@ -671,15 +728,16 @@
**kwargs
)
try:
- result = client.create_subnet(**subnet)
+ result = subnets_client.create_subnet(**subnet)
break
except lib_exc.Conflict as e:
is_overlapping_cidr = 'overlaps with another subnet' in str(e)
if not is_overlapping_cidr:
raise
self.assertIsNotNone(result, 'Unable to allocate tenant network')
- subnet = net_resources.DeletableSubnet(client=client,
- **result['subnet'])
+ subnet = net_resources.DeletableSubnet(
+ network_client=client, subnets_client=subnets_client,
+ **result['subnet'])
self.assertEqual(subnet.cidr, str_cidr)
self.addCleanup(self.delete_wrapper, subnet.delete)
return subnet
@@ -687,20 +745,20 @@
def _create_port(self, network_id, client=None, namestart='port-quotatest',
**kwargs):
if not client:
- client = self.network_client
+ client = self.ports_client
name = data_utils.rand_name(namestart)
result = client.create_port(
name=name,
network_id=network_id,
**kwargs)
self.assertIsNotNone(result, 'Unable to allocate port')
- port = net_resources.DeletablePort(client=client,
+ port = net_resources.DeletablePort(ports_client=client,
**result['port'])
self.addCleanup(self.delete_wrapper, port.delete)
return port
def _get_server_port_id_and_ip4(self, server, ip_addr=None):
- ports = self._list_ports(device_id=server['id'],
+ ports = self._list_ports(device_id=server['id'], status='ACTIVE',
fixed_ip=ip_addr)
# it might happen here that this port has more then one ip address
# as in case of dual stack- when this port is created on 2 subnets
@@ -709,6 +767,8 @@
for fxip in p["fixed_ips"]
if netaddr.valid_ipv4(fxip["ip_address"])]
+ self.assertNotEqual(0, len(port_map),
+ "No IPv4 addresses found in: %s" % ports)
self.assertEqual(len(port_map), 1,
"Found multiple IPv4 addresses: %s. "
"Unable to determine which port to target."
@@ -723,13 +783,11 @@
def create_floating_ip(self, thing, external_network_id=None,
port_id=None, client=None):
- """Creates a floating IP and associates to a resource/port using
- Neutron client
- """
+ """Create a floating IP and associates to a resource/port on Neutron"""
if not external_network_id:
external_network_id = CONF.network.public_network_id
if not client:
- client = self.network_client
+ client = self.floating_ips_client
if not port_id:
port_id, ip4 = self._get_server_port_id_and_ip4(thing)
else:
@@ -753,9 +811,7 @@
return floating_ip
def _disassociate_floating_ip(self, floating_ip):
- """
- :param floating_ip: type DeletableFloatingIp
- """
+ """:param floating_ip: type DeletableFloatingIp"""
floating_ip.update(port_id=None)
self.assertIsNone(floating_ip.port_id)
return floating_ip
@@ -808,8 +864,7 @@
raise
def _check_remote_connectivity(self, source, dest, should_succeed=True):
- """
- check ping server via source ssh connection
+ """check ping server via source ssh connection
:param source: RemoteClient: an ssh connection from which to ping
:param dest: and IP to ping against
@@ -940,7 +995,9 @@
return sg_rule
def _create_loginable_secgroup_rule(self, client=None, secgroup=None):
- """These rules are intended to permit inbound ssh and icmp
+ """Create loginable security group rule
+
+ These rules are intended to permit inbound ssh and icmp
traffic from all sources, so no group_id is provided.
Setting a group_id would only permit traffic from ports
belonging to the same security group.
@@ -1035,7 +1092,8 @@
router.update(admin_state_up=admin_state_up)
self.assertEqual(admin_state_up, router.admin_state_up)
- def create_networks(self, client=None, tenant_id=None,
+ def create_networks(self, client=None, networks_client=None,
+ subnets_client=None, tenant_id=None,
dns_nameservers=None):
"""Create a network with a subnet connected to a router.
@@ -1061,10 +1119,13 @@
router = None
subnet = None
else:
- network = self._create_network(client=client, tenant_id=tenant_id)
+ network = self._create_network(
+ client=client, networks_client=networks_client,
+ tenant_id=tenant_id)
router = self._get_router(client=client, tenant_id=tenant_id)
- subnet_kwargs = dict(network=network, client=client)
+ subnet_kwargs = dict(network=network, client=client,
+ subnets_client=subnets_client)
# use explicit check because empty list is a valid option
if dns_nameservers is not None:
subnet_kwargs['dns_nameservers'] = dns_nameservers
@@ -1074,9 +1135,14 @@
def create_server(self, name=None, image=None, flavor=None,
wait_on_boot=True, wait_on_delete=True,
- network_client=None, create_kwargs=None):
+ network_client=None, networks_client=None,
+ ports_client=None, create_kwargs=None):
if network_client is None:
network_client = self.network_client
+ if networks_client is None:
+ networks_client = self.networks_client
+ if ports_client is None:
+ ports_client = self.ports_client
vnic_type = CONF.network.port_vnic_type
@@ -1112,7 +1178,7 @@
# as we would expect when passing the call to the clients
# with no networks
if not networks:
- networks = network_client.list_networks(filters={
+ networks = networks_client.list_networks(filters={
'router:external': False})
self.assertEqual(1, len(networks),
"There is more than one"
@@ -1120,7 +1186,7 @@
for net in networks:
net_id = net['uuid']
port = self._create_port(network_id=net_id,
- client=network_client,
+ client=ports_client,
**create_port_body)
ports.append({'port': port.id})
if ports:
@@ -1292,9 +1358,7 @@
class EncryptionScenarioTest(ScenarioTest):
- """
- Base class for encryption scenario tests
- """
+ """Base class for encryption scenario tests"""
credentials = ['primary', 'admin']
@@ -1344,8 +1408,7 @@
class ObjectStorageScenarioTest(ScenarioTest):
- """
- Provide harness to do Object Storage scenario tests.
+ """Provide harness to do Object Storage scenario tests.
Subclasses implement the tests that use the methods provided by this
class.
@@ -1413,10 +1476,8 @@
def list_and_check_container_objects(self, container_name,
present_obj=None,
not_present_obj=None):
- """
- List objects for a given container and assert which are present and
- which are not.
- """
+ # List objects for a given container and assert which are present and
+ # which are not.
if present_obj is None:
present_obj = []
if not_present_obj is None:
diff --git a/tempest/scenario/test_aggregates_basic_ops.py b/tempest/scenario/test_aggregates_basic_ops.py
index 22d2603..62c0262 100644
--- a/tempest/scenario/test_aggregates_basic_ops.py
+++ b/tempest/scenario/test_aggregates_basic_ops.py
@@ -25,8 +25,8 @@
class TestAggregatesBasicOps(manager.ScenarioTest):
- """
- Creates an aggregate within an availability zone
+ """Creates an aggregate within an availability zone
+
Adds a host to the aggregate
Checks aggregate details
Updates aggregate's name
diff --git a/tempest/scenario/test_baremetal_basic_ops.py b/tempest/scenario/test_baremetal_basic_ops.py
index c0b5a44..e629f0a 100644
--- a/tempest/scenario/test_baremetal_basic_ops.py
+++ b/tempest/scenario/test_baremetal_basic_ops.py
@@ -26,9 +26,9 @@
class BaremetalBasicOps(manager.BaremetalScenarioTest):
- """
- This smoke test tests the pxe_ssh Ironic driver. It follows this basic
- set of operations:
+ """This smoke test tests the pxe_ssh Ironic driver.
+
+ It follows this basic set of operations:
* Creates a keypair
* Boots an instance using the keypair
* Monitors the associated Ironic node for power and
@@ -63,15 +63,6 @@
server_id=self.instance['id'],
status='ACTIVE')
- def create_remote_file(self, client, filename):
- """Create a file on the remote client connection.
-
- After creating the file, force a filesystem sync. Otherwise,
- if we issue a rebuild too quickly, the file may not exist.
- """
- client.exec_command('sudo touch ' + filename)
- client.exec_command('sync')
-
def verify_partition(self, client, label, mount, gib_size):
"""Verify a labeled partition's mount point and size."""
LOG.info("Looking for partition %s mounted on %s" % (label, mount))
@@ -107,17 +98,10 @@
return None
return int(ephemeral)
- def add_floating_ip(self):
- floating_ip = (self.floating_ips_client.create_floating_ip()
- ['floating_ip'])
- self.floating_ips_client.associate_floating_ip_to_server(
- floating_ip['ip'], self.instance['id'])
- return floating_ip['ip']
-
def validate_ports(self):
for port in self.get_ports(self.node['uuid']):
n_port_id = port['extra']['vif_port_id']
- body = self.network_client.show_port(n_port_id)
+ body = self.ports_client.show_port(n_port_id)
n_port = body['port']
self.assertEqual(n_port['device_id'], self.instance['id'])
self.assertEqual(n_port['mac_address'], port['address'])
@@ -125,13 +109,12 @@
@test.idempotent_id('549173a5-38ec-42bb-b0e2-c8b9f4a08943')
@test.services('baremetal', 'compute', 'image', 'network')
def test_baremetal_server_ops(self):
- test_filename = '/mnt/rebuild_test.txt'
self.add_keypair()
self.boot_instance()
self.validate_ports()
self.verify_connectivity()
if CONF.compute.ssh_connect_method == 'floating':
- floating_ip = self.add_floating_ip()
+ floating_ip = self.create_floating_ip(self.instance)['ip']
self.verify_connectivity(ip=floating_ip)
vm_client = self.get_remote_client(self.instance)
@@ -139,12 +122,13 @@
# We expect the ephemeral partition to be mounted on /mnt and to have
# the same size as our flavor definition.
eph_size = self.get_flavor_ephemeral_size()
- if eph_size > 0:
+ if eph_size:
preserve_ephemeral = True
self.verify_partition(vm_client, 'ephemeral0', '/mnt', eph_size)
# Create the test file
- self.create_remote_file(vm_client, test_filename)
+ timestamp = self.create_timestamp(
+ floating_ip, private_key=self.keypair['private_key'])
else:
preserve_ephemeral = False
@@ -153,9 +137,9 @@
self.verify_connectivity()
# Check that we maintained our data
- if eph_size > 0:
- vm_client = self.get_remote_client(self.instance)
+ if eph_size:
self.verify_partition(vm_client, 'ephemeral0', '/mnt', eph_size)
- vm_client.exec_command('ls ' + test_filename)
-
+ timestamp2 = self.get_timestamp(
+ floating_ip, private_key=self.keypair['private_key'])
+ self.assertEqual(timestamp, timestamp2)
self.terminate_instance()
diff --git a/tempest/scenario/test_dashboard_basic_ops.py b/tempest/scenario/test_dashboard_basic_ops.py
index d5bad64..cb6b968 100644
--- a/tempest/scenario/test_dashboard_basic_ops.py
+++ b/tempest/scenario/test_dashboard_basic_ops.py
@@ -58,7 +58,8 @@
class TestDashboardBasicOps(manager.ScenarioTest):
- """
+ """The test suite for dashboard basic operations
+
This is a basic scenario test:
* checks that the login page is available
* logs in as a regular user
@@ -90,7 +91,7 @@
# construct login url for dashboard, discovery accommodates non-/ web
# root for dashboard
- login_url = CONF.dashboard.dashboard_url + parser.login[1:]
+ login_url = parse.urljoin(CONF.dashboard.dashboard_url, parser.login)
# Prepare login form request
req = request.Request(login_url)
diff --git a/tempest/scenario/test_encrypted_cinder_volumes.py b/tempest/scenario/test_encrypted_cinder_volumes.py
index b66eb59..99837eb 100644
--- a/tempest/scenario/test_encrypted_cinder_volumes.py
+++ b/tempest/scenario/test_encrypted_cinder_volumes.py
@@ -22,7 +22,8 @@
class TestEncryptedCinderVolumes(manager.EncryptionScenarioTest):
- """
+ """The test suite for encrypted cinder volumes
+
This test is for verifying the functionality of encrypted cinder volumes.
For both LUKS and cryptsetup encryption types, this test performs
@@ -54,8 +55,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_large_ops.py b/tempest/scenario/test_large_ops.py
index 63dd4f0..6497f7a 100644
--- a/tempest/scenario/test_large_ops.py
+++ b/tempest/scenario/test_large_ops.py
@@ -31,8 +31,7 @@
class TestLargeOpsScenario(manager.ScenarioTest):
- """
- Test large operations.
+ """Test large operations.
This test below:
* Spin up multiple instances in one nova call, and repeat three times
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index eac8311..a5b5a1b 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -29,8 +29,7 @@
class TestMinimumBasicScenario(manager.ScenarioTest):
- """
- This is a basic minimum scenario test.
+ """This is a basic minimum scenario test.
This test below:
* across the multiple components
@@ -38,68 +37,75 @@
* with and without optional parameters
* check command outputs
+ Steps:
+ 1. Create image
+ 2. Create keypair
+ 3. Boot instance with keypair and get list of instances
+ 4. Create volume and show list of volumes
+ 5. Attach volume to instance and getlist of volumes
+ 6. Add IP to instance
+ 7. Create and add security group to instance
+ 8. Check SSH connection to instance
+ 9. Reboot instance
+ 10. Check SSH connection to instance after reboot
+
"""
- 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 +113,44 @@
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)
+
+ # check that we can SSH to the server before reboot
+ self.linux_client = self.get_remote_client(
+ floating_ip['ip'], private_key=keypair['private_key'])
+
+ self.nova_reboot(server)
+
+ # check that we can SSH to the server after reboot
+ # (both connections are part of the scenario)
+ 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..3689508 100644
--- a/tempest/scenario/test_network_advanced_server_ops.py
+++ b/tempest/scenario/test_network_advanced_server_ops.py
@@ -27,10 +27,7 @@
class TestNetworkAdvancedServerOps(manager.NetworkScenarioTest):
-
- """
- This test case checks VM connectivity after some advanced
- instance operations executed:
+ """Check VM connectivity after some advanced instance operations executed:
* Stop/Start an instance
* Reboot an instance
@@ -56,7 +53,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 +61,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 +168,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_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index 8ca5e72..8fefd9e 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -36,7 +36,8 @@
class TestNetworkBasicOps(manager.NetworkScenarioTest):
- """
+ """The test suite of network basic operations
+
This smoke test suite assumes that Nova has been configured to
boot VM's with Neutron-managed networking, and attempts to
verify network connectivity as follows:
@@ -123,9 +124,9 @@
self.floating_ip_tuple = Floating_IP_tuple(floating_ip, server)
def check_networks(self):
- """
- Checks that we see the newly created network/subnet/router via
- checking the result of list_[networks,routers,subnets]
+ """Checks that we see the newly created network/subnet/router
+
+ via checking the result of list_[networks,routers,subnets]
"""
seen_nets = self._list_networks()
@@ -182,7 +183,8 @@
def check_public_network_connectivity(
self, should_connect=True, msg=None,
should_check_floating_ip_status=True):
- """Verifies connectivty to a VM via public network and floating IP,
+ """Verifies connectivty to a VM via public network and floating IP
+
and verifies floating IP has resource status is correct.
:param should_connect: bool. determines if connectivity check is
@@ -250,7 +252,7 @@
net_id=self.new_net.id)['interfaceAttachment']
self.addCleanup(self.network_client.wait_for_resource_deletion,
'port',
- interface['port_id'])
+ interface['port_id'], client=self.ports_client)
self.addCleanup(self.delete_wrapper,
self.interface_client.delete_interface,
server['id'], interface['port_id'])
@@ -268,7 +270,7 @@
"Old port: %s. Number of new ports: %d" % (
CONF.network.build_timeout, old_port,
len(self.new_port_list)))
- new_port = net_resources.DeletablePort(client=self.network_client,
+ new_port = net_resources.DeletablePort(ports_client=self.ports_client,
**self.new_port_list[0])
def check_new_nic():
@@ -294,8 +296,8 @@
def _check_network_internal_connectivity(self, network,
should_connect=True):
- """
- via ssh check VM internal connectivity:
+ """via ssh check VM internal connectivity:
+
- ping internal gateway and DHCP port, implying in-tenant connectivity
pinging both, because L3 and DHCP agents might be on different nodes
"""
@@ -312,10 +314,7 @@
should_connect)
def _check_network_external_connectivity(self):
- """
- ping public network default gateway to imply external connectivity
-
- """
+ """ping default gateway to imply external connectivity"""
if not CONF.network.public_network_id:
msg = 'public network not defined.'
LOG.info(msg)
@@ -359,7 +358,8 @@
@test.idempotent_id('f323b3ba-82f8-4db7-8ea6-6a895869ec49')
@test.services('compute', 'network')
def test_network_basic_ops(self):
- """
+ """Basic network operation test
+
For a freshly-booted VM with an IP address ("port") on a given
network:
@@ -412,7 +412,8 @@
'Baremetal relies on a shared physical network.')
@test.services('compute', 'network')
def test_connectivity_between_vms_on_different_networks(self):
- """
+ """Test connectivity between VMs on different networks
+
For a freshly-booted VM with an IP address ("port") on a given
network:
@@ -460,7 +461,8 @@
'vnic_type direct or macvtap')
@test.services('compute', 'network')
def test_hotplug_nic(self):
- """
+ """Test hotplug network interface
+
1. create a new network, with no gateway (to prevent overwriting VM's
gateway)
2. connect VM to new network
@@ -480,7 +482,8 @@
'network')
@test.services('compute', 'network')
def test_update_router_admin_state(self):
- """
+ """Test to update admin state up of router
+
1. Check public connectivity before updating
admin_state_up attribute of router to False
2. Check public connectivity after updating
@@ -512,8 +515,9 @@
"DHCP client is not available.")
@test.services('compute', 'network')
def test_subnet_details(self):
- """Tests that subnet's extra configuration details are affecting
- the VMs. This test relies on non-shared, isolated tenant networks.
+ """Tests that subnet's extra configuration details are affecting VMs.
+
+ This test relies on non-shared, isolated tenant networks.
NOTE: Neutron subnets push data to servers via dhcp-agent, so any
update in subnet requires server to actively renew its DHCP lease.
@@ -567,12 +571,11 @@
"Failed to update subnet's nameservers")
def check_new_dns_server():
- """Server needs to renew its dhcp lease in order to get the new dns
- definitions from subnet
- NOTE(amuller): we are renewing the lease as part of the retry
- because Neutron updates dnsmasq asynchronously after the
- subnet-update API call returns.
- """
+ # NOTE: Server needs to renew its dhcp lease in order to get new
+ # definitions from subnet
+ # NOTE(amuller): we are renewing the lease as part of the retry
+ # because Neutron updates dnsmasq asynchronously after the
+ # subnet-update API call returns.
ssh_client.renew_lease(fixed_ip=floating_ip['fixed_ip_address'])
if ssh_client.get_dns_servers() != [alt_dns_server]:
LOG.debug("Failed to update DNS nameservers")
@@ -594,7 +597,8 @@
"by the test environment")
@test.services('compute', 'network')
def test_update_instance_port_admin_state(self):
- """
+ """Test to update admin_state_up attribute of instance port
+
1. Check public connectivity before updating
admin_state_up attribute of instance port to False
2. Check public connectivity after updating
@@ -609,12 +613,12 @@
self.check_public_network_connectivity(
should_connect=True, msg="before updating "
"admin_state_up of instance port to False")
- self.network_client.update_port(port_id, admin_state_up=False)
+ self.ports_client.update_port(port_id, admin_state_up=False)
self.check_public_network_connectivity(
should_connect=False, msg="after updating "
"admin_state_up of instance port to False",
should_check_floating_ip_status=False)
- self.network_client.update_port(port_id, admin_state_up=True)
+ self.ports_client.update_port(port_id, admin_state_up=True)
self.check_public_network_connectivity(
should_connect=True, msg="after updating "
"admin_state_up of instance port to True")
@@ -625,8 +629,10 @@
'supported in the version of Nova being tested.')
@test.services('compute', 'network')
def test_preserve_preexisting_port(self):
- """Tests that a pre-existing port provided on server boot is not
- deleted if the server is deleted.
+ """Test preserve pre-existing port
+
+ Tests that a pre-existing port provided on server boot is not deleted
+ if the server is deleted.
Nova should unbind the port from the instance on delete if the port was
not created by Nova as part of the boot request.
@@ -653,11 +659,12 @@
waiters.wait_for_server_termination(self.servers_client, server['id'])
# Assert the port still exists on the network but is unbound from
# the deleted server.
- port = self.network_client.show_port(port_id)['port']
+ port = self.ports_client.show_port(port_id)['port']
self.assertEqual(self.network['id'], port['network_id'])
self.assertEqual('', port['device_id'])
self.assertEqual('', port['device_owner'])
+ @test.requires_ext(service='network', extension='l3_agent_scheduler')
@test.idempotent_id('2e788c46-fb3f-4ac9-8f82-0561555bea73')
@test.services('compute', 'network')
def test_router_rescheduling(self):
diff --git a/tempest/scenario/test_network_v6.py b/tempest/scenario/test_network_v6.py
index a9394cb..151eef8 100644
--- a/tempest/scenario/test_network_v6.py
+++ b/tempest/scenario/test_network_v6.py
@@ -70,12 +70,13 @@
'security_groups': [{'name': self.sec_grp['name']}]}
def prepare_network(self, address6_mode, n_subnets6=1, dualnet=False):
- """Creates network with
- given number of IPv6 subnets in the given mode and
- one IPv4 subnet
- Creates router with ports on all subnets
- if dualnet - create IPv6 subnets on a different network
- :return: list of created networks
+ """Prepare network
+
+ Creates network with given number of IPv6 subnets in the given mode and
+ one IPv4 subnet.
+ Creates router with ports on all subnets.
+ if dualnet - create IPv6 subnets on a different network
+ :return: list of created networks
"""
self.network = self._create_network(tenant_id=self.tenant_id)
if dualnet:
@@ -143,8 +144,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))
@@ -187,21 +189,15 @@
self._check_connectivity(sshv4_1, ips_from_api_2['4'])
self._check_connectivity(sshv4_2, ips_from_api_1['4'])
- # Some VM (like cirros) may not have ping6 utility
- result = sshv4_1.exec_command('whereis ping6')
- is_ping6 = False if result == 'ping6:\n' else True
- if is_ping6:
- for i in range(n_subnets6):
- self._check_connectivity(sshv4_1,
- ips_from_api_2['6'][i])
- self._check_connectivity(sshv4_1,
- self.subnets_v6[i].gateway_ip)
- self._check_connectivity(sshv4_2,
- ips_from_api_1['6'][i])
- self._check_connectivity(sshv4_2,
- self.subnets_v6[i].gateway_ip)
- else:
- LOG.warning('Ping6 is not available, skipping')
+ for i in range(n_subnets6):
+ self._check_connectivity(sshv4_1,
+ ips_from_api_2['6'][i])
+ self._check_connectivity(sshv4_1,
+ self.subnets_v6[i].gateway_ip)
+ self._check_connectivity(sshv4_2,
+ ips_from_api_1['6'][i])
+ self._check_connectivity(sshv4_2,
+ self.subnets_v6[i].gateway_ip)
def _check_connectivity(self, source, dest):
self.assertTrue(
diff --git a/tempest/scenario/test_object_storage_basic_ops.py b/tempest/scenario/test_object_storage_basic_ops.py
index 49768c5..98dd705 100644
--- a/tempest/scenario/test_object_storage_basic_ops.py
+++ b/tempest/scenario/test_object_storage_basic_ops.py
@@ -25,8 +25,8 @@
class TestObjectStorageBasicOps(manager.ObjectStorageScenarioTest):
- """
- Test swift basic ops.
+ """Test swift basic ops.
+
* get swift stat.
* create container.
* upload a file to the created container.
@@ -57,6 +57,7 @@
@test.services('object_storage')
def test_swift_acl_anonymous_download(self):
"""This test will cover below steps:
+
1. Create container
2. Upload object to the new container
3. Change the ACL of the container
diff --git a/tempest/scenario/test_object_storage_telemetry_middleware.py b/tempest/scenario/test_object_storage_telemetry_middleware.py
index 3376a7c..eee4d3d 100644
--- a/tempest/scenario/test_object_storage_telemetry_middleware.py
+++ b/tempest/scenario/test_object_storage_telemetry_middleware.py
@@ -35,8 +35,8 @@
class TestObjectStorageTelemetry(manager.ObjectStorageScenarioTest):
- """
- Test that swift uses the ceilometer middleware.
+ """Test that swift uses the ceilometer middleware.
+
* create container.
* upload a file to the created container.
* retrieve the file from the created container.
@@ -57,19 +57,15 @@
cls.telemetry_client = cls.os_operator.telemetry_client
def _confirm_notifications(self, container_name, obj_name):
- """
- Loop seeking for appropriate notifications about the containers
- and objects sent to swift.
- """
+ # NOTE: Loop seeking for appropriate notifications about the containers
+ # and objects sent to swift.
def _check_samples():
- """
- Return True only if we have notifications about some
- containers and some objects and the notifications are about
- the expected containers and objects.
- Otherwise returning False will case _check_samples to be
- called again.
- """
+ # NOTE: Return True only if we have notifications about some
+ # containers and some objects and the notifications are about
+ # the expected containers and objects.
+ # Otherwise returning False will case _check_samples to be
+ # called again.
results = self.telemetry_client.list_samples(
'storage.objects.incoming.bytes')
LOG.debug('got samples %s', results)
diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py
index 297076c..6a23c4b 100644
--- a/tempest/scenario/test_security_groups_basic_ops.py
+++ b/tempest/scenario/test_security_groups_basic_ops.py
@@ -28,7 +28,8 @@
class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
- """
+ """The test suite for security groups
+
This test suite assumes that Nova has been configured to
boot VM's with Neutron-managed networking, and attempts to
verify cross tenant connectivity as follows
@@ -95,8 +96,8 @@
credentials = ['primary', 'alt', 'admin']
class TenantProperties(object):
- """
- helper class to save tenant details
+ """helper class to save tenant details
+
id
credentials
network
@@ -232,9 +233,7 @@
return port['device_owner'].startswith('network:router_interface')
def _create_server(self, name, tenant, security_groups=None):
- """
- creates a server and assigns to security group
- """
+ """creates a server and assigns to security group"""
self._set_compute_context(tenant)
if security_groups is None:
security_groups = [tenant.security_groups['default']]
@@ -249,6 +248,8 @@
server = self.create_server(
name=name,
network_client=tenant.manager.network_client,
+ networks_client=tenant.manager.networks_client,
+ ports_client=tenant.manager.ports_client,
create_kwargs=create_kwargs)
self.assertEqual(
sorted([s['name'] for s in security_groups]),
@@ -266,11 +267,9 @@
tenant.servers.append(server)
def _set_access_point(self, tenant):
- """
- creates a server in a secgroup with rule allowing external ssh
- in order to access tenant internal network
- workaround ip namespace
- """
+ # creates a server in a secgroup with rule allowing external ssh
+ # in order to access tenant internal network
+ # workaround ip namespace
secgroups = tenant.security_groups.values()
name = 'server-{tenant}-access_point'.format(
tenant=tenant.creds.tenant_name)
@@ -284,12 +283,14 @@
public_network_id = CONF.network.public_network_id
floating_ip = self.create_floating_ip(
server, public_network_id,
- client=tenant.manager.network_client)
+ client=tenant.manager.floating_ips_client)
self.floating_ips.setdefault(server['id'], floating_ip)
def _create_tenant_network(self, tenant):
network, subnet, router = self.create_networks(
- client=tenant.manager.network_client)
+ client=tenant.manager.network_client,
+ networks_client=tenant.manager.networks_client,
+ subnets_client=tenant.manager.subnets_client)
tenant.set_network(network, subnet, router)
def _set_compute_context(self, tenant):
@@ -297,8 +298,8 @@
return self.servers_client
def _deploy_tenant(self, tenant_or_id):
- """
- creates:
+ """creates:
+
network
subnet
router (if public not defined)
@@ -316,9 +317,7 @@
self._set_access_point(tenant)
def _get_server_ip(self, server, floating=False):
- """
- returns the ip (floating/internal) of a server
- """
+ """returns the ip (floating/internal) of a server"""
if floating:
server_ip = self.floating_ips[server['id']].floating_ip_address
else:
@@ -329,9 +328,7 @@
return server_ip
def _connect_to_access_point(self, tenant):
- """
- create ssh connection to tenant access point
- """
+ """create ssh connection to tenant access point"""
access_point_ssh = \
self.floating_ips[tenant.access_point['id']].floating_ip_address
private_key = tenant.keypair['private_key']
@@ -370,10 +367,8 @@
ip=self._get_server_ip(server))
def _test_cross_tenant_block(self, source_tenant, dest_tenant):
- """
- if public router isn't defined, then dest_tenant access is via
- floating-ip
- """
+ # if public router isn't defined, then dest_tenant access is via
+ # floating-ip
access_point_ssh = self._connect_to_access_point(source_tenant)
ip = self._get_server_ip(dest_tenant.access_point,
floating=self.floating_ip_access)
@@ -381,8 +376,8 @@
should_succeed=False)
def _test_cross_tenant_allow(self, source_tenant, dest_tenant):
- """
- check for each direction:
+ """check for each direction:
+
creating rule for tenant incoming traffic enables only 1way traffic
"""
ruleset = dict(
@@ -415,10 +410,8 @@
self._check_connectivity(access_point_ssh_2, ip)
def _verify_mac_addr(self, tenant):
- """
- verify that VM (tenant's access point) has the same ip,mac as listed in
- port list
- """
+ """Verify that VM has the same ip, mac as listed in port"""
+
access_point_ssh = self._connect_to_access_point(tenant)
mac_addr = access_point_ssh.get_mac_address()
mac_addr = mac_addr.strip().lower()
@@ -473,9 +466,9 @@
@test.idempotent_id('f4d556d7-1526-42ad-bafb-6bebf48568f6')
@test.services('compute', 'network')
def test_port_update_new_security_group(self):
- """
- This test verifies the traffic after updating the vm port with new
- security group having appropriate rule.
+ """Verifies the traffic after updating the vm port
+
+ With new security group having appropriate rule.
"""
new_tenant = self.primary_tenant
@@ -511,7 +504,7 @@
port_id = self._list_ports(device_id=server_id)[0]['id']
# update port with new security group and check connectivity
- self.network_client.update_port(port_id, security_groups=[
+ self.ports_client.update_port(port_id, security_groups=[
new_tenant.security_groups['new_sg'].id])
self._check_connectivity(
access_point=access_point_ssh,
@@ -524,8 +517,8 @@
@test.idempotent_id('d2f77418-fcc4-439d-b935-72eca704e293')
@test.services('compute', 'network')
def test_multiple_security_groups(self):
- """
- This test verifies multiple security groups and checks that rules
+ """Verify multiple security groups and checks that rules
+
provided in the both the groups is applied onto VM
"""
tenant = self.primary_tenant
@@ -543,13 +536,11 @@
secgroup=tenant.security_groups['default'],
**ruleset
)
- """
- Vm now has 2 security groups one with ssh rule(
- already added in setUp() method),and other with icmp rule
- (added in the above step).The check_vm_connectivity tests
- -that vm ping test is successful
- -ssh to vm is successful
- """
+ # NOTE: Vm now has 2 security groups one with ssh rule(
+ # already added in setUp() method),and other with icmp rule
+ # (added in the above step).The check_vm_connectivity tests
+ # -that vm ping test is successful
+ # -ssh to vm is successful
self.check_vm_connectivity(ip,
username=ssh_login,
private_key=private_key,
@@ -559,10 +550,7 @@
@test.idempotent_id('7c811dcc-263b-49a3-92d2-1b4d8405f50c')
@test.services('compute', 'network')
def test_port_security_disable_security_group(self):
- """
- This test verifies port_security_enabled=False disables
- the default security group rules.
- """
+ """Verify the default security group rules is disabled."""
new_tenant = self.primary_tenant
# Create server
@@ -578,16 +566,16 @@
# Flip the port's port security and check connectivity
try:
- self.network_client.update_port(port_id,
- port_security_enabled=True,
- security_groups=[])
+ self.ports_client.update_port(port_id,
+ port_security_enabled=True,
+ security_groups=[])
self._check_connectivity(access_point=access_point_ssh,
ip=self._get_server_ip(server),
should_succeed=False)
- self.network_client.update_port(port_id,
- port_security_enabled=False,
- security_groups=[])
+ self.ports_client.update_port(port_id,
+ port_security_enabled=False,
+ security_groups=[])
self._check_connectivity(
access_point=access_point_ssh,
ip=self._get_server_ip(server))
diff --git a/tempest/scenario/test_server_advanced_ops.py b/tempest/scenario/test_server_advanced_ops.py
index c83dbb1..9387dc7 100644
--- a/tempest/scenario/test_server_advanced_ops.py
+++ b/tempest/scenario/test_server_advanced_ops.py
@@ -28,9 +28,9 @@
class TestServerAdvancedOps(manager.ScenarioTest):
- """
- This test case stresses some advanced server instance operations:
+ """The test suite for server advanced operations
+ This test case stresses some advanced server instance operations:
* Resizing an instance
* Sequence suspend resume
"""
diff --git a/tempest/scenario/test_server_basic_ops.py b/tempest/scenario/test_server_basic_ops.py
index 0f27cd1..8a19254 100644
--- a/tempest/scenario/test_server_basic_ops.py
+++ b/tempest/scenario/test_server_basic_ops.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import json
+
from oslo_log import log as logging
from tempest import config
@@ -30,15 +32,16 @@
class TestServerBasicOps(manager.ScenarioTest):
- """
- This smoke test case follows this basic set of operations:
+ """The test suite for server basic operations
+ This smoke test case follows this basic set of operations:
* Create a keypair for use in launching an instance
* Create a security group to control network access in instance
* Add simple permissive rules to the security group
* Launch an instance
* Perform ssh to instance
* Verify metadata service
+ * Verify metadata on config_drive
* Terminate the instance
"""
@@ -72,9 +75,12 @@
def boot_instance(self):
# Create server with image and flavor from input scenario
security_groups = [{'name': self.security_group['name']}]
+ self.md = {'meta1': 'data1', 'meta2': 'data2', 'metaN': 'dataN'}
create_kwargs = {
'key_name': self.keypair['name'],
- 'security_groups': security_groups
+ 'security_groups': security_groups,
+ 'config_drive': CONF.compute_feature_enabled.config_drive,
+ 'metadata': self.md
}
self.instance = self.create_server(image=self.image_ref,
flavor=self.flavor_ref,
@@ -83,17 +89,10 @@
def verify_ssh(self):
if self.run_ssh:
# Obtain a floating IP
- self.floating_ip = (self.floating_ips_client.create_floating_ip()
- ['floating_ip'])
- self.addCleanup(self.delete_wrapper,
- self.floating_ips_client.delete_floating_ip,
- self.floating_ip['id'])
- # Attach a floating IP
- self.floating_ips_client.associate_floating_ip_to_server(
- self.floating_ip['ip'], self.instance['id'])
+ self.fip = self.create_floating_ip(self.instance)['ip']
# Check ssh
self.ssh_client = self.get_remote_client(
- server_or_ip=self.floating_ip['ip'],
+ server_or_ip=self.fip,
username=self.image_utils.ssh_user(self.image_ref),
private_key=self.keypair['private_key'])
@@ -104,12 +103,11 @@
def exec_cmd_and_verify_output():
cmd = 'curl ' + md_url
- floating_ip = self.floating_ip['ip']
result = self.ssh_client.exec_command(cmd)
if result:
msg = ('Failed while verifying metadata on server. Result '
- 'of command "%s" is NOT "%s".' % (cmd, floating_ip))
- self.assertEqual(floating_ip, result, msg)
+ 'of command "%s" is NOT "%s".' % (cmd, self.fip))
+ self.assertEqual(self.fip, result, msg)
return 'Verification is successful!'
if not test.call_until_true(exec_cmd_and_verify_output,
@@ -119,6 +117,22 @@
'verify metadata on server. '
'%s is empty.' % md_url)
+ def verify_metadata_on_config_drive(self):
+ if self.run_ssh and CONF.compute_feature_enabled.config_drive:
+ # Verify metadata on config_drive
+ cmd_blkid = 'blkid -t LABEL=config-2 -o device'
+ dev_name = self.ssh_client.exec_command(cmd_blkid)
+ dev_name = dev_name.rstrip()
+ self.ssh_client.exec_command('sudo mount %s /mnt' % dev_name)
+ cmd_md = 'sudo cat /mnt/openstack/latest/meta_data.json'
+ result = self.ssh_client.exec_command(cmd_md)
+ self.ssh_client.exec_command('sudo umount /mnt')
+ result = json.loads(result)
+ self.assertIn('meta', result)
+ msg = ('Failed while verifying metadata on config_drive on server.'
+ ' Result of command "%s" is NOT "%s".' % (cmd_md, self.md))
+ self.assertEqual(self.md, result['meta'], msg)
+
@test.idempotent_id('7fff3fb3-91d8-4fd0-bd7d-0204f1f180ba')
@test.attr(type='smoke')
@test.services('compute', 'network')
@@ -128,4 +142,5 @@
self.boot_instance()
self.verify_ssh()
self.verify_metadata()
+ self.verify_metadata_on_config_drive()
self.servers_client.delete_server(self.instance['id'])
diff --git a/tempest/scenario/test_server_multinode.py b/tempest/scenario/test_server_multinode.py
new file mode 100644
index 0000000..403804d
--- /dev/null
+++ b/tempest/scenario/test_server_multinode.py
@@ -0,0 +1,84 @@
+# Copyright 2012 OpenStack Foundation
+# 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_log import log as logging
+
+from tempest import config
+from tempest import exceptions
+from tempest.scenario import manager
+from tempest import test
+
+CONF = config.CONF
+
+LOG = logging.getLogger(__name__)
+
+
+class TestServerMultinode(manager.ScenarioTest):
+ """This is a set of tests specific to multinode testing."""
+ credentials = ['primary', 'admin']
+
+ @classmethod
+ def setup_clients(cls):
+ super(TestServerMultinode, cls).setup_clients()
+ # Use admin client by default
+ cls.manager = cls.admin_manager
+ # this is needed so that we can use the availability_zone:host
+ # scheduler hint, which is admin_only by default
+ cls.servers_client = cls.admin_manager.servers_client
+ super(TestServerMultinode, cls).resource_setup()
+
+ @test.idempotent_id('9cecbe35-b9d4-48da-a37e-7ce70aa43d30')
+ @test.attr(type='smoke')
+ @test.services('compute', 'network')
+ def test_schedule_to_all_nodes(self):
+ host_client = self.manager.hosts_client
+ hosts = host_client.list_hosts()['hosts']
+ hosts = [x for x in hosts if x['service'] == 'compute']
+
+ # ensure we have at least as many compute hosts as we expect
+ if len(hosts) < CONF.compute.min_compute_nodes:
+ raise exceptions.InvalidConfiguration(
+ "Host list %s is shorter than min_compute_nodes. "
+ "Did a compute worker not boot correctly?" % hosts)
+
+ # create 1 compute for each node, up to the min_compute_nodes
+ # threshold (so that things don't get crazy if you have 1000
+ # compute nodes but set min to 3).
+ servers = []
+
+ for host in hosts[:CONF.compute.min_compute_nodes]:
+ create_kwargs = {
+ 'availability_zone': '%(zone)s:%(host_name)s' % host
+ }
+
+ # by getting to active state here, this means this has
+ # landed on the host in question.
+ inst = self.create_server(image=CONF.compute.image_ref,
+ flavor=CONF.compute.flavor_ref,
+ create_kwargs=create_kwargs)
+ server = self.servers_client.show_server(inst['id'])['server']
+ servers.append(server)
+
+ # make sure we really have the number of servers we think we should
+ self.assertEqual(
+ len(servers), CONF.compute.min_compute_nodes,
+ "Incorrect number of servers built %s" % servers)
+
+ # ensure that every server ended up on a different host
+ host_ids = [x['hostId'] for x in servers]
+ self.assertEqual(
+ len(set(host_ids)), len(servers),
+ "Incorrect number of distinct host_ids scheduled to %s" % servers)
diff --git a/tempest/scenario/test_shelve_instance.py b/tempest/scenario/test_shelve_instance.py
index bf4b8e7..5778107 100644
--- a/tempest/scenario/test_shelve_instance.py
+++ b/tempest/scenario/test_shelve_instance.py
@@ -27,8 +27,8 @@
class TestShelveInstance(manager.ScenarioTest):
- """
- This test shelves then unshelves a Nova instance
+ """This test shelves then unshelves a Nova instance
+
The following is the scenario outline:
* boot an instance and create a timestamp file in it
* shelve the instance
@@ -37,16 +37,6 @@
"""
- def _write_timestamp(self, server_or_ip):
- ssh_client = self.get_remote_client(server_or_ip)
- ssh_client.exec_command('date > /tmp/timestamp; sync')
- self.timestamp = ssh_client.exec_command('cat /tmp/timestamp')
-
- def _check_timestamp(self, server_or_ip):
- ssh_client = self.get_remote_client(server_or_ip)
- got_timestamp = ssh_client.exec_command('cat /tmp/timestamp')
- self.assertEqual(self.timestamp, got_timestamp)
-
def _shelve_then_unshelve_server(self, server):
self.servers_client.shelve_server(server['id'])
offload_time = CONF.compute.shelved_offload_time
@@ -65,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
}
@@ -88,26 +78,18 @@
server = self.create_server(image=CONF.compute.image_ref,
create_kwargs=create_kwargs)
- if CONF.compute.use_floatingip_for_ssh:
- floating_ip = (self.floating_ips_client.create_floating_ip()
- ['floating_ip'])
- self.addCleanup(self.delete_wrapper,
- self.floating_ips_client.delete_floating_ip,
- floating_ip['id'])
- self.floating_ips_client.associate_floating_ip_to_server(
- floating_ip['ip'], server['id'])
- self._write_timestamp(floating_ip['ip'])
- else:
- self._write_timestamp(server)
+ instance_ip = self.get_server_or_ip(server)
+ timestamp = self.create_timestamp(instance_ip,
+ 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:
- self._check_timestamp(floating_ip['ip'])
- else:
- self._check_timestamp(server)
+
+ timestamp2 = self.get_timestamp(instance_ip,
+ private_key=keypair['private_key'])
+ self.assertEqual(timestamp, timestamp2)
@test.idempotent_id('1164e700-0af0-4a4c-8792-35909a88743c')
@testtools.skipUnless(CONF.compute_feature_enabled.shelve,
diff --git a/tempest/scenario/test_snapshot_pattern.py b/tempest/scenario/test_snapshot_pattern.py
index b5e5da8..cd59334 100644
--- a/tempest/scenario/test_snapshot_pattern.py
+++ b/tempest/scenario/test_snapshot_pattern.py
@@ -26,8 +26,8 @@
class TestSnapshotPattern(manager.ScenarioTest):
- """
- This test is for snapshotting an instance and booting with it.
+ """This test is for snapshotting an instance and booting with it.
+
The following is the scenario outline:
* boot an instance and create a timestamp file in it
* snapshot the instance
@@ -36,53 +36,39 @@
"""
- 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 _write_timestamp(self, server_or_ip):
- ssh_client = self.get_remote_client(server_or_ip)
- ssh_client.exec_command('date > /tmp/timestamp; sync')
- self.timestamp = ssh_client.exec_command('cat /tmp/timestamp')
-
- def _check_timestamp(self, server_or_ip):
- ssh_client = self.get_remote_client(server_or_ip)
- got_timestamp = ssh_client.exec_command('cat /tmp/timestamp')
- self.assertEqual(self.timestamp, got_timestamp)
-
@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)
- if CONF.compute.use_floatingip_for_ssh:
- fip_for_server = self.create_floating_ip(server)
- self._write_timestamp(fip_for_server['ip'])
- else:
- self._write_timestamp(server)
+ server = self._boot_image(CONF.compute.image_ref, keypair,
+ security_group)
+ instance_ip = self.get_server_or_ip(server)
+ timestamp = self.create_timestamp(instance_ip,
+ 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)
- self._check_timestamp(fip_for_snapshot['ip'])
- else:
- self._check_timestamp(server_from_snapshot)
+ server_from_snapshot_ip = self.get_server_or_ip(server_from_snapshot)
+ timestamp2 = self.get_timestamp(server_from_snapshot_ip,
+ 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 91e4657..05ae33e 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -33,7 +33,8 @@
class TestStampPattern(manager.ScenarioTest):
- """
+ """The test suite for both snapshoting and attaching of volume
+
This test is for snapshotting an instance/volume and attaching the volume
created from snapshot to the instance booted from snapshot.
The following is the scenario outline:
@@ -63,23 +64,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 _ssh_to_server(self, server_or_ip):
- return self.get_remote_client(server_or_ip)
-
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():
@@ -114,8 +109,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()
@@ -127,23 +123,6 @@
CONF.compute.build_interval):
raise exceptions.TimeoutException
- def _create_timestamp(self, server_or_ip):
- ssh_client = self._ssh_to_server(server_or_ip)
- ssh_client.exec_command('sudo /usr/sbin/mkfs.ext4 /dev/%s'
- % CONF.compute.volume_device_name)
- ssh_client.exec_command('sudo mount /dev/%s /mnt'
- % CONF.compute.volume_device_name)
- ssh_client.exec_command('sudo sh -c "date > /mnt/timestamp;sync"')
- self.timestamp = ssh_client.exec_command('sudo cat /mnt/timestamp')
- ssh_client.exec_command('sudo umount /mnt')
-
- def _check_timestamp(self, server_or_ip):
- ssh_client = self._ssh_to_server(server_or_ip)
- ssh_client.exec_command('sudo mount /dev/%s /mnt'
- % CONF.compute.volume_device_name)
- got_timestamp = ssh_client.exec_command('sudo cat /mnt/timestamp')
- self.assertEqual(self.timestamp, got_timestamp)
-
@decorators.skip_because(bug="1205344")
@test.idempotent_id('10fd234a-515c-41e5-b092-8323060598c5')
@testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
@@ -151,23 +130,23 @@
@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:
- floating_ip_for_server = self.create_floating_ip(server)
- ip_for_server = floating_ip_for_server['ip']
- else:
- ip_for_server = server
+ ip_for_server = self.get_server_or_ip(server)
self._attach_volume(server, volume)
- self._wait_for_volume_available_on_the_system(ip_for_server)
- self._create_timestamp(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,
+ private_key=keypair['private_key'])
self._detach_volume(server, volume)
# snapshot the volume
@@ -181,19 +160,19 @@
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:
- floating_ip_for_snapshot = self.create_floating_ip(
- server_from_snapshot)
- ip_for_snapshot = floating_ip_for_snapshot['ip']
- else:
- ip_for_snapshot = server_from_snapshot
+ ip_for_snapshot = self.get_server_or_ip(server_from_snapshot)
# 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
- self._check_timestamp(ip_for_snapshot)
+ timestamp2 = self.get_timestamp(ip_for_snapshot,
+ 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 ba419a6..96e79e6 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
@@ -26,8 +25,7 @@
class TestVolumeBootPattern(manager.ScenarioTest):
- """
- This test case attempts to reproduce the following steps:
+ """This test case attempts to reproduce the following steps:
* Create in Cinder some bootable volume importing a Glance image
* Boot an instance from the bootable volume
@@ -96,40 +94,10 @@
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']
- else:
- ip = server
-
- return self.get_remote_client(ip, private_key=keypair['private_key'],
- log_console_of_servers=[server])
-
- def _get_content(self, ssh_client):
- return ssh_client.exec_command('cat /tmp/text')
-
- def _write_text(self, ssh_client):
- text = data_utils.rand_name('text')
- ssh_client.exec_command('echo "%s" > /tmp/text; sync' % (text))
-
- return self._get_content(ssh_client)
-
def _delete_server(self, server):
self.servers_client.delete_server(server['id'])
waiters.wait_for_server_termination(self.servers_client, server['id'])
- def _check_content_of_written_file(self, ssh_client, expected):
- actual = self._get_content(ssh_client)
- self.assertEqual(expected, actual)
-
@test.idempotent_id('557cd2c2-4eb8-4dce-98be-f86765ff311b')
@test.attr(type='smoke')
@test.services('compute', 'volume', 'image')
@@ -143,9 +111,9 @@
keypair, security_group)
# write content to volume on instance
- ssh_client_for_instance_1st = self._ssh_to_server(instance_1st,
- keypair)
- text = self._write_text(ssh_client_for_instance_1st)
+ ip_instance_1st = self.get_server_or_ip(instance_1st)
+ timestamp = self.create_timestamp(ip_instance_1st,
+ private_key=keypair['private_key'])
# delete instance
self._delete_server(instance_1st)
@@ -155,28 +123,26 @@
keypair, security_group)
# check the content of written file
- ssh_client_for_instance_2nd = self._ssh_to_server(instance_2nd,
- keypair)
- self._check_content_of_written_file(ssh_client_for_instance_2nd, text)
+ ip_instance_2nd = self.get_server_or_ip(instance_2nd)
+ timestamp2 = self.get_timestamp(ip_instance_2nd,
+ private_key=keypair['private_key'])
+ self.assertEqual(timestamp, timestamp2)
# snapshot a volume
snapshot = self._create_snapshot_from_volume(volume_origin['id'])
# create a 3rd instance from snapshot
volume = self._create_volume_from_snapshot(snapshot['id'])
- instance_from_snapshot = (
+ server_from_snapshot = (
self._boot_instance_from_volume(volume['id'],
keypair, security_group))
# check the content of written file
- ssh_client = self._ssh_to_server(instance_from_snapshot, keypair)
- self._check_content_of_written_file(ssh_client, text)
+ server_from_snapshot_ip = self.get_server_or_ip(server_from_snapshot)
+ timestamp3 = self.get_timestamp(server_from_snapshot_ip,
+ private_key=keypair['private_key'])
+ self.assertEqual(timestamp, timestamp3)
- # 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')
def test_create_ebs_image_and_check_boot(self):
diff --git a/tempest/scenario/utils.py b/tempest/scenario/utils.py
index 2841060..fa7c0c9 100644
--- a/tempest/scenario/utils.py
+++ b/tempest/scenario/utils.py
@@ -19,13 +19,13 @@
from oslo_serialization import jsonutils as json
from tempest_lib.common.utils import misc
+from tempest_lib import exceptions as exc_lib
import testscenarios
import testtools
from tempest import clients
-from tempest.common import credentials
+from tempest.common import credentials_factory as credentials
from tempest import config
-from tempest import exceptions
CONF = config.CONF
@@ -72,8 +72,7 @@
@misc.singleton
class InputScenarioUtils(object):
- """
- Example usage:
+ """Example usage:
import testscenarios
(...)
@@ -104,11 +103,11 @@
'subnet': False,
'dhcp': False,
}
- self.isolated_creds = credentials.get_isolated_credentials(
+ self.cred_provider = credentials.get_credentials_provider(
name='InputScenarioUtils',
identity_version=CONF.identity.auth_version,
network_resources=network_resources)
- os = clients.Manager(self.isolated_creds.get_primary_creds())
+ os = clients.Manager(self.cred_provider.get_primary_creds())
self.images_client = os.images_client
self.flavors_client = os.flavors_client
self.image_pattern = CONF.input_scenario.image_regex
@@ -120,13 +119,11 @@
return nname
def clear_creds(self):
- self.isolated_creds.clear_isolated_creds()
+ self.cred_provider.clear_creds()
@property
def scenario_images(self):
- """
- :return: a scenario with name and uuid of images
- """
+ """:return: a scenario with name and uuid of images"""
if not CONF.service_available.glance:
return []
if not hasattr(self, '_scenario_images'):
@@ -143,9 +140,7 @@
@property
def scenario_flavors(self):
- """
- :return: a scenario with name and uuid of flavors
- """
+ """:return: a scenario with name and uuid of flavors"""
if not hasattr(self, '_scenario_flavors'):
try:
flavors = self.flavors_client.list_flavors()['flavors']
@@ -160,10 +155,11 @@
def load_tests_input_scenario_utils(*args):
+ """Wrapper for testscenarios to set the scenarios
+
+ The purpose is to avoid running a getattr on the CONF object at import.
"""
- Wrapper for testscenarios to set the scenarios to avoid running a getattr
- on the CONF object at import.
- """
+
if getattr(args[0], 'suiteClass', None) is not None:
loader, standard_tests, pattern = args
else:
@@ -174,7 +170,7 @@
scenario_utils = InputScenarioUtils()
scenario_flavor = scenario_utils.scenario_flavors
scenario_image = scenario_utils.scenario_images
- except (exceptions.InvalidConfiguration, TypeError):
+ except (exc_lib.InvalidCredentials, TypeError):
output = standard_tests
finally:
if scenario_utils:
diff --git a/tempest/services/baremetal/base.py b/tempest/services/baremetal/base.py
index 2ac3fb2..004c0de 100644
--- a/tempest/services/baremetal/base.py
+++ b/tempest/services/baremetal/base.py
@@ -40,10 +40,7 @@
class BaremetalClient(service_client.ServiceClient):
- """
- Base Tempest REST client for Ironic API.
-
- """
+ """Base Tempest REST client for Ironic API."""
uri_prefix = ''
@@ -58,8 +55,7 @@
return json.loads(object_str)
def _get_uri(self, resource_name, uuid=None, permanent=False):
- """
- Get URI for a specific resource or object.
+ """Get URI for a specific resource or object.
:param resource_name: The name of the REST resource, e.g., 'nodes'.
:param uuid: The unique identifier of an object in UUID format.
@@ -73,8 +69,7 @@
uuid='/%s' % uuid if uuid else '')
def _make_patch(self, allowed_attributes, **kw):
- """
- Create a JSON patch according to RFC 6902.
+ """Create a JSON patch according to RFC 6902.
:param allowed_attributes: An iterable object that contains a set of
allowed attributes for an object.
@@ -103,8 +98,7 @@
return patch
def _list_request(self, resource, permanent=False, **kwargs):
- """
- Get the list of objects of the specified type.
+ """Get the list of objects of the specified type.
:param resource: The name of the REST resource, e.g., 'nodes'.
"param **kw: Parameters for the request.
@@ -122,8 +116,7 @@
return resp, self.deserialize(body)
def _show_request(self, resource, uuid, permanent=False, **kwargs):
- """
- Gets a specific object of the specified type.
+ """Gets a specific object of the specified type.
:param uuid: Unique identifier of the object in UUID format.
:return: Serialized object as a dictionary.
@@ -139,8 +132,7 @@
return resp, self.deserialize(body)
def _create_request(self, resource, object_dict):
- """
- Create an object of the specified type.
+ """Create an object of the specified type.
:param resource: The name of the REST resource, e.g., 'nodes'.
:param object_dict: A Python dict that represents an object of the
@@ -158,8 +150,7 @@
return resp, self.deserialize(body)
def _delete_request(self, resource, uuid):
- """
- Delete specified object.
+ """Delete specified object.
:param resource: The name of the REST resource, e.g., 'nodes'.
:param uuid: The unique identifier of an object in UUID format.
@@ -173,8 +164,7 @@
return resp, body
def _patch_request(self, resource, uuid, patch_object):
- """
- Update specified object with JSON-patch.
+ """Update specified object with JSON-patch.
:param resource: The name of the REST resource, e.g., 'nodes'.
:param uuid: The unique identifier of an object in UUID format.
@@ -197,8 +187,7 @@
@handle_errors
def get_version_description(self, version='v1'):
- """
- Retrieves the desctription of the API.
+ """Retrieves the desctription of the API.
:param version: The version of the API. Default: 'v1'.
:return: Serialized description of API resources.
@@ -207,10 +196,7 @@
return self._list_request(version, permanent=True)
def _put_request(self, resource, put_object):
- """
- Update specified object with JSON-patch.
-
- """
+ """Update specified object with JSON-patch."""
uri = self._get_uri(resource)
put_body = json.dumps(put_object)
diff --git a/tempest/services/baremetal/v1/json/baremetal_client.py b/tempest/services/baremetal/v1/json/baremetal_client.py
index 479402a..f24ef68 100644
--- a/tempest/services/baremetal/v1/json/baremetal_client.py
+++ b/tempest/services/baremetal/v1/json/baremetal_client.py
@@ -14,9 +14,7 @@
class BaremetalClient(base.BaremetalClient):
- """
- Base Tempest REST client for Ironic API v1.
- """
+ """Base Tempest REST client for Ironic API v1."""
version = '1'
uri_prefix = 'v1'
@@ -62,8 +60,7 @@
@base.handle_errors
def show_node(self, uuid):
- """
- Gets a specific node.
+ """Gets a specific node.
:param uuid: Unique identifier of the node in UUID format.
:return: Serialized node as a dictionary.
@@ -73,8 +70,7 @@
@base.handle_errors
def show_node_by_instance_uuid(self, instance_uuid):
- """
- Gets a node associated with given instance uuid.
+ """Gets a node associated with given instance uuid.
:param uuid: Unique identifier of the node in UUID format.
:return: Serialized node as a dictionary.
@@ -88,8 +84,7 @@
@base.handle_errors
def show_chassis(self, uuid):
- """
- Gets a specific chassis.
+ """Gets a specific chassis.
:param uuid: Unique identifier of the chassis in UUID format.
:return: Serialized chassis as a dictionary.
@@ -99,8 +94,7 @@
@base.handle_errors
def show_port(self, uuid):
- """
- Gets a specific port.
+ """Gets a specific port.
:param uuid: Unique identifier of the port in UUID format.
:return: Serialized port as a dictionary.
@@ -110,8 +104,7 @@
@base.handle_errors
def show_port_by_address(self, address):
- """
- Gets a specific port by address.
+ """Gets a specific port by address.
:param address: MAC address of the port.
:return: Serialized port as a dictionary.
@@ -122,8 +115,7 @@
return self._show_request('ports', uuid=None, uri=uri)
def show_driver(self, driver_name):
- """
- Gets a specific driver.
+ """Gets a specific driver.
:param driver_name: Name of driver.
:return: Serialized driver as a dictionary.
@@ -132,8 +124,7 @@
@base.handle_errors
def create_node(self, chassis_id=None, **kwargs):
- """
- Create a baremetal node with the specified parameters.
+ """Create a baremetal node with the specified parameters.
:param cpu_arch: CPU architecture of the node. Default: x86_64.
:param cpus: Number of CPUs. Default: 8.
@@ -154,8 +145,7 @@
@base.handle_errors
def create_chassis(self, **kwargs):
- """
- Create a chassis with the specified parameters.
+ """Create a chassis with the specified parameters.
:param description: The description of the chassis.
Default: test-chassis
@@ -168,8 +158,7 @@
@base.handle_errors
def create_port(self, node_id, **kwargs):
- """
- Create a port with the specified parameters.
+ """Create a port with the specified parameters.
:param node_id: The ID of the node which owns the port.
:param address: MAC address of the port.
@@ -191,8 +180,7 @@
@base.handle_errors
def delete_node(self, uuid):
- """
- Deletes a node having the specified UUID.
+ """Deletes a node having the specified UUID.
:param uuid: The unique identifier of the node.
:return: A tuple with the server response and the response body.
@@ -202,8 +190,7 @@
@base.handle_errors
def delete_chassis(self, uuid):
- """
- Deletes a chassis having the specified UUID.
+ """Deletes a chassis having the specified UUID.
:param uuid: The unique identifier of the chassis.
:return: A tuple with the server response and the response body.
@@ -213,8 +200,7 @@
@base.handle_errors
def delete_port(self, uuid):
- """
- Deletes a port having the specified UUID.
+ """Deletes a port having the specified UUID.
:param uuid: The unique identifier of the port.
:return: A tuple with the server response and the response body.
@@ -224,8 +210,7 @@
@base.handle_errors
def update_node(self, uuid, **kwargs):
- """
- Update the specified node.
+ """Update the specified node.
:param uuid: The unique identifier of the node.
:return: A tuple with the server response and the updated node.
@@ -244,8 +229,7 @@
@base.handle_errors
def update_chassis(self, uuid, **kwargs):
- """
- Update the specified chassis.
+ """Update the specified chassis.
:param uuid: The unique identifier of the chassis.
:return: A tuple with the server response and the updated chassis.
@@ -258,8 +242,7 @@
@base.handle_errors
def update_port(self, uuid, patch):
- """
- Update the specified port.
+ """Update the specified port.
:param uuid: The unique identifier of the port.
:param patch: List of dicts representing json patches.
@@ -271,8 +254,7 @@
@base.handle_errors
def set_node_power_state(self, node_uuid, state):
- """
- Set power state of the specified node.
+ """Set power state of the specified node.
:param node_uuid: The unique identifier of the node.
:state: desired state to set (on/off/reboot).
@@ -284,8 +266,7 @@
@base.handle_errors
def validate_driver_interface(self, node_uuid):
- """
- Get all driver interfaces of a specific node.
+ """Get all driver interfaces of a specific node.
:param uuid: Unique identifier of the node in UUID format.
@@ -300,8 +281,7 @@
@base.handle_errors
def set_node_boot_device(self, node_uuid, boot_device, persistent=False):
- """
- Set the boot device of the specified node.
+ """Set the boot device of the specified node.
:param node_uuid: The unique identifier of the node.
:param boot_device: The boot device name.
@@ -318,8 +298,7 @@
@base.handle_errors
def get_node_boot_device(self, node_uuid):
- """
- Get the current boot device of the specified node.
+ """Get the current boot device of the specified node.
:param node_uuid: The unique identifier of the node.
@@ -331,8 +310,7 @@
@base.handle_errors
def get_node_supported_boot_devices(self, node_uuid):
- """
- Get the supported boot devices of the specified node.
+ """Get the supported boot devices of the specified node.
:param node_uuid: The unique identifier of the node.
@@ -344,8 +322,7 @@
@base.handle_errors
def get_console(self, node_uuid):
- """
- Get connection information about the console.
+ """Get connection information about the console.
:param node_uuid: Unique identifier of the node in UUID format.
@@ -357,8 +334,7 @@
@base.handle_errors
def set_console_mode(self, node_uuid, enabled):
- """
- Start and stop the node console.
+ """Start and stop the node console.
:param node_uuid: Unique identifier of the node in UUID format.
:param enabled: Boolean value; whether to enable or disable the
diff --git a/tempest/services/botoclients.py b/tempest/services/botoclients.py
index ede464f..e117719 100644
--- a/tempest/services/botoclients.py
+++ b/tempest/services/botoclients.py
@@ -88,20 +88,21 @@
return self.connect_method(**self.connection_data)
def get_aws_credentials(self, identity_client):
- """
- Obtain existing, or create new AWS credentials
+ """Obtain existing, or create new AWS credentials
+
:param identity_client: identity client with embedded credentials
:return: EC2 credentials
"""
ec2_cred_list = identity_client.list_user_ec2_credentials(
- identity_client.user_id)
+ identity_client.user_id)['credentials']
for cred in ec2_cred_list:
if cred['tenant_id'] == identity_client.tenant_id:
ec2_cred = cred
break
else:
- ec2_cred = identity_client.create_user_ec2_credentials(
+ ec2_cred = (identity_client.create_user_ec2_credentials(
identity_client.user_id, identity_client.tenant_id)
+ ['credential'])
if not all((ec2_cred, ec2_cred['access'], ec2_cred['secret'])):
raise lib_exc.NotFound("Unable to get access and secret keys")
else:
diff --git a/tempest/services/compute/json/agents_client.py b/tempest/services/compute/json/agents_client.py
deleted file mode 100644
index d38c8cd..0000000
--- a/tempest/services/compute/json/agents_client.py
+++ /dev/null
@@ -1,56 +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.
-
-from oslo_serialization import jsonutils as json
-from six.moves.urllib import parse as urllib
-
-from tempest.api_schema.response.compute.v2_1 import agents as schema
-from tempest.common import service_client
-
-
-class AgentsClient(service_client.ServiceClient):
- """
- Tests Agents API
- """
-
- def list_agents(self, **params):
- """List all agent builds."""
- url = 'os-agents'
- if params:
- url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_agents, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def create_agent(self, **kwargs):
- """Create an agent build."""
- post_body = json.dumps({'agent': kwargs})
- resp, body = self.post('os-agents', post_body)
- body = json.loads(body)
- self.validate_response(schema.create_agent, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def delete_agent(self, agent_id):
- """Delete an existing agent build."""
- resp, body = self.delete("os-agents/%s" % agent_id)
- self.validate_response(schema.delete_agent, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def update_agent(self, agent_id, **kwargs):
- """Update an agent build."""
- put_body = json.dumps({'para': kwargs})
- resp, body = self.put('os-agents/%s' % agent_id, put_body)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/aggregates_client.py b/tempest/services/compute/json/aggregates_client.py
deleted file mode 100644
index c9895db..0000000
--- a/tempest/services/compute/json/aggregates_client.py
+++ /dev/null
@@ -1,100 +0,0 @@
-# Copyright 2013 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.
-
-from oslo_serialization import jsonutils as json
-from tempest_lib import exceptions as lib_exc
-
-from tempest.api_schema.response.compute.v2_1 import aggregates as schema
-from tempest.common import service_client
-
-
-class AggregatesClient(service_client.ServiceClient):
-
- def list_aggregates(self):
- """Get aggregate list."""
- resp, body = self.get("os-aggregates")
- body = json.loads(body)
- self.validate_response(schema.list_aggregates, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def show_aggregate(self, aggregate_id):
- """Get details of the given aggregate."""
- resp, body = self.get("os-aggregates/%s" % aggregate_id)
- body = json.loads(body)
- self.validate_response(schema.get_aggregate, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def create_aggregate(self, **kwargs):
- """Creates a new aggregate."""
- post_body = json.dumps({'aggregate': kwargs})
- resp, body = self.post('os-aggregates', post_body)
-
- body = json.loads(body)
- self.validate_response(schema.create_aggregate, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def update_aggregate(self, aggregate_id, **kwargs):
- """Update a aggregate."""
- put_body = json.dumps({'aggregate': kwargs})
- resp, body = self.put('os-aggregates/%s' % aggregate_id, put_body)
-
- body = json.loads(body)
- self.validate_response(schema.update_aggregate, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def delete_aggregate(self, aggregate_id):
- """Deletes the given aggregate."""
- resp, body = self.delete("os-aggregates/%s" % aggregate_id)
- self.validate_response(schema.delete_aggregate, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def is_resource_deleted(self, id):
- try:
- self.show_aggregate(id)
- except lib_exc.NotFound:
- return True
- return False
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'aggregate'
-
- def add_host(self, aggregate_id, **kwargs):
- """Adds a host to the given aggregate."""
- post_body = json.dumps({'add_host': kwargs})
- resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- post_body)
- body = json.loads(body)
- self.validate_response(schema.aggregate_add_remove_host, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def remove_host(self, aggregate_id, **kwargs):
- """Removes a host from the given aggregate."""
- post_body = json.dumps({'remove_host': kwargs})
- resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- post_body)
- body = json.loads(body)
- self.validate_response(schema.aggregate_add_remove_host, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def set_metadata(self, aggregate_id, **kwargs):
- """Replaces the aggregate's existing metadata with new metadata."""
- post_body = json.dumps({'set_metadata': kwargs})
- resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- post_body)
- body = json.loads(body)
- self.validate_response(schema.aggregate_set_metadata, resp, body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/availability_zone_client.py b/tempest/services/compute/json/availability_zone_client.py
deleted file mode 100644
index 0012637..0000000
--- a/tempest/services/compute/json/availability_zone_client.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright 2013 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.
-
-from oslo_serialization import jsonutils as json
-
-from tempest.api_schema.response.compute.v2_1 import availability_zone \
- as schema
-from tempest.common import service_client
-
-
-class AvailabilityZoneClient(service_client.ServiceClient):
-
- def list_availability_zones(self, detail=False):
- url = 'os-availability-zone'
- schema_list = schema.list_availability_zone_list
- if detail:
- url += '/detail'
- schema_list = schema.list_availability_zone_list_detail
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema_list, resp, body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/baremetal_nodes_client.py b/tempest/services/compute/json/baremetal_nodes_client.py
deleted file mode 100644
index 15f883a..0000000
--- a/tempest/services/compute/json/baremetal_nodes_client.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright 2015 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.
-
-from oslo_serialization import jsonutils as json
-from six.moves.urllib import parse as urllib
-
-from tempest.api_schema.response.compute.v2_1 import baremetal_nodes \
- as schema
-from tempest.common import service_client
-
-
-class BaremetalNodesClient(service_client.ServiceClient):
- """
- Tests Baremetal API
- """
-
- def list_baremetal_nodes(self, **params):
- """List all baremetal nodes."""
- url = 'os-baremetal-nodes'
- if params:
- url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_baremetal_nodes, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def show_baremetal_node(self, baremetal_node_id):
- """Returns the details of a single baremetal node."""
- url = 'os-baremetal-nodes/%s' % baremetal_node_id
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.get_baremetal_node, resp, body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/certificates_client.py b/tempest/services/compute/json/certificates_client.py
deleted file mode 100644
index d6c72f4..0000000
--- a/tempest/services/compute/json/certificates_client.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright 2013 IBM Corp
-# 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 certificates as schema
-from tempest.common import service_client
-
-
-class CertificatesClient(service_client.ServiceClient):
-
- def show_certificate(self, certificate_id):
- url = "os-certificates/%s" % certificate_id
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.get_certificate, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def create_certificate(self):
- """create certificates."""
- url = "os-certificates"
- resp, body = self.post(url, None)
- body = json.loads(body)
- self.validate_response(schema.create_certificate, resp, body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/extensions_client.py b/tempest/services/compute/json/extensions_client.py
deleted file mode 100644
index 4741812..0000000
--- a/tempest/services/compute/json/extensions_client.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# 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 extensions as schema
-from tempest.common import service_client
-
-
-class ExtensionsClient(service_client.ServiceClient):
-
- def list_extensions(self):
- url = 'extensions'
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_extensions, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def show_extension(self, extension_alias):
- resp, body = self.get('extensions/%s' % extension_alias)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/fixed_ips_client.py b/tempest/services/compute/json/fixed_ips_client.py
deleted file mode 100644
index 23401c3..0000000
--- a/tempest/services/compute/json/fixed_ips_client.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright 2013 IBM Corp
-# 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 fixed_ips as schema
-from tempest.common import service_client
-
-
-class FixedIPsClient(service_client.ServiceClient):
-
- def show_fixed_ip(self, fixed_ip):
- url = "os-fixed-ips/%s" % fixed_ip
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.get_fixed_ip, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def reserve_fixed_ip(self, fixed_ip, **kwargs):
- """This reserves and unreserves fixed ips."""
- url = "os-fixed-ips/%s/action" % fixed_ip
- resp, body = self.post(url, json.dumps(kwargs))
- self.validate_response(schema.reserve_fixed_ip, resp, body)
- return service_client.ResponseBody(resp)
diff --git a/tempest/services/compute/json/flavors_client.py b/tempest/services/compute/json/flavors_client.py
deleted file mode 100644
index 2c32d30..0000000
--- a/tempest/services/compute/json/flavors_client.py
+++ /dev/null
@@ -1,169 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# 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 six.moves.urllib import parse as urllib
-
-from tempest.api_schema.response.compute.v2_1 import flavors as schema
-from tempest.api_schema.response.compute.v2_1 import flavors_access \
- as schema_access
-from tempest.api_schema.response.compute.v2_1 import flavors_extra_specs \
- as schema_extra_specs
-from tempest.common import service_client
-
-
-class FlavorsClient(service_client.ServiceClient):
-
- def list_flavors(self, detail=False, **params):
- url = 'flavors'
- _schema = schema.list_flavors
-
- if detail:
- url += '/detail'
- _schema = schema.list_flavors_details
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(_schema, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def show_flavor(self, flavor_id):
- resp, body = self.get("flavors/%s" % flavor_id)
- body = json.loads(body)
- self.validate_response(schema.create_get_flavor_details, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def create_flavor(self, **kwargs):
- """Creates a new flavor or instance type.
- Most parameters except the following are passed to the API without
- any changes.
- :param ephemeral: The name is changed to OS-FLV-EXT-DATA:ephemeral
- :param is_public: The name is changed to os-flavor-access:is_public
- """
- if kwargs.get('ephemeral'):
- kwargs['OS-FLV-EXT-DATA:ephemeral'] = kwargs.pop('ephemeral')
- if kwargs.get('is_public'):
- kwargs['os-flavor-access:is_public'] = kwargs.pop('is_public')
-
- post_body = json.dumps({'flavor': kwargs})
- resp, body = self.post('flavors', post_body)
-
- body = json.loads(body)
- self.validate_response(schema.create_get_flavor_details, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def delete_flavor(self, flavor_id):
- """Deletes the given flavor."""
- resp, body = self.delete("flavors/{0}".format(flavor_id))
- self.validate_response(schema.delete_flavor, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def is_resource_deleted(self, id):
- # Did not use show_flavor(id) for verification as it gives
- # 200 ok even for deleted id. LP #981263
- # we can remove the loop here and use get by ID when bug gets sortedout
- flavors = self.list_flavors(detail=True)['flavors']
- for flavor in flavors:
- if flavor['id'] == id:
- return False
- return True
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'flavor'
-
- def set_flavor_extra_spec(self, flavor_id, **kwargs):
- """Sets extra Specs to the mentioned flavor."""
- post_body = json.dumps({'extra_specs': kwargs})
- resp, body = self.post('flavors/%s/os-extra_specs' % flavor_id,
- post_body)
- body = json.loads(body)
- self.validate_response(schema_extra_specs.set_get_flavor_extra_specs,
- resp, body)
- return service_client.ResponseBody(resp, body)
-
- def list_flavor_extra_specs(self, flavor_id):
- """Gets extra Specs details of the mentioned flavor."""
- resp, body = self.get('flavors/%s/os-extra_specs' % flavor_id)
- body = json.loads(body)
- self.validate_response(schema_extra_specs.set_get_flavor_extra_specs,
- resp, body)
- return service_client.ResponseBody(resp, body)
-
- def show_flavor_extra_spec(self, flavor_id, key):
- """Gets extra Specs key-value of the mentioned flavor and key."""
- resp, body = self.get('flavors/%s/os-extra_specs/%s' % (flavor_id,
- key))
- body = json.loads(body)
- self.validate_response(
- schema_extra_specs.set_get_flavor_extra_specs_key,
- resp, body)
- return service_client.ResponseBody(resp, body)
-
- def update_flavor_extra_spec(self, flavor_id, key, **kwargs):
- """Update specified extra Specs of the mentioned flavor and key."""
- resp, body = self.put('flavors/%s/os-extra_specs/%s' %
- (flavor_id, key), json.dumps(kwargs))
- body = json.loads(body)
- self.validate_response(
- schema_extra_specs.set_get_flavor_extra_specs_key,
- resp, body)
- return service_client.ResponseBody(resp, body)
-
- def unset_flavor_extra_spec(self, flavor_id, key):
- """Unsets extra Specs from the mentioned flavor."""
- resp, body = self.delete('flavors/%s/os-extra_specs/%s' %
- (flavor_id, key))
- self.validate_response(schema.unset_flavor_extra_specs, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def list_flavor_access(self, flavor_id):
- """Gets flavor access information given the flavor id."""
- resp, body = self.get('flavors/%s/os-flavor-access' % flavor_id)
- body = json.loads(body)
- self.validate_response(schema_access.add_remove_list_flavor_access,
- resp, body)
- return service_client.ResponseBody(resp, body)
-
- def add_flavor_access(self, flavor_id, tenant_id):
- """Add flavor access for the specified tenant."""
- post_body = {
- 'addTenantAccess': {
- 'tenant': tenant_id
- }
- }
- post_body = json.dumps(post_body)
- resp, body = self.post('flavors/%s/action' % flavor_id, post_body)
- body = json.loads(body)
- self.validate_response(schema_access.add_remove_list_flavor_access,
- resp, body)
- return service_client.ResponseBody(resp, body)
-
- def remove_flavor_access(self, flavor_id, tenant_id):
- """Remove flavor access from the specified tenant."""
- post_body = {
- 'removeTenantAccess': {
- 'tenant': tenant_id
- }
- }
- post_body = json.dumps(post_body)
- resp, body = self.post('flavors/%s/action' % flavor_id, post_body)
- body = json.loads(body)
- self.validate_response(schema_access.add_remove_list_flavor_access,
- resp, body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/floating_ip_pools_client.py b/tempest/services/compute/json/floating_ip_pools_client.py
deleted file mode 100644
index c83537a..0000000
--- a/tempest/services/compute/json/floating_ip_pools_client.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# 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 six.moves.urllib import parse as urllib
-
-from tempest.api_schema.response.compute.v2_1 import floating_ips as schema
-from tempest.common import service_client
-
-
-class FloatingIPPoolsClient(service_client.ServiceClient):
-
- def list_floating_ip_pools(self, params=None):
- """Gets all floating IP Pools list."""
- url = 'os-floating-ip-pools'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_floating_ip_pools, resp, body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/floating_ips_bulk_client.py b/tempest/services/compute/json/floating_ips_bulk_client.py
deleted file mode 100644
index dfe69f0..0000000
--- a/tempest/services/compute/json/floating_ips_bulk_client.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# 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 floating_ips as schema
-from tempest.common import service_client
-
-
-class FloatingIPsBulkClient(service_client.ServiceClient):
-
- def create_floating_ips_bulk(self, ip_range, pool, interface):
- """Allocate floating IPs in bulk."""
- post_body = {
- 'ip_range': ip_range,
- 'pool': pool,
- 'interface': interface
- }
- post_body = json.dumps({'floating_ips_bulk_create': post_body})
- resp, body = self.post('os-floating-ips-bulk', post_body)
- body = json.loads(body)
- self.validate_response(schema.create_floating_ips_bulk, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def list_floating_ips_bulk(self):
- """Gets all floating IPs in bulk."""
- resp, body = self.get('os-floating-ips-bulk')
- body = json.loads(body)
- self.validate_response(schema.list_floating_ips_bulk, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def delete_floating_ips_bulk(self, ip_range):
- """Deletes the provided floating IPs in bulk."""
- post_body = json.dumps({'ip_range': ip_range})
- resp, body = self.put('os-floating-ips-bulk/delete', post_body)
- body = json.loads(body)
- self.validate_response(schema.delete_floating_ips_bulk, resp, body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/hosts_client.py b/tempest/services/compute/json/hosts_client.py
deleted file mode 100644
index 3d3cb18..0000000
--- a/tempest/services/compute/json/hosts_client.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# Copyright 2013 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 oslo_serialization import jsonutils as json
-from six.moves.urllib import parse as urllib
-
-from tempest.api_schema.response.compute.v2_1 import hosts as schema
-from tempest.common import service_client
-
-
-class HostsClient(service_client.ServiceClient):
-
- def list_hosts(self, **params):
- """Lists all hosts."""
-
- url = 'os-hosts'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_hosts, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def show_host(self, hostname):
- """Show detail information for the host."""
-
- resp, body = self.get("os-hosts/%s" % hostname)
- body = json.loads(body)
- self.validate_response(schema.get_host_detail, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def update_host(self, hostname, **kwargs):
- """Update a host."""
-
- request_body = {
- 'status': None,
- 'maintenance_mode': None,
- }
- request_body.update(**kwargs)
- request_body = json.dumps(request_body)
-
- resp, body = self.put("os-hosts/%s" % hostname, request_body)
- body = json.loads(body)
- self.validate_response(schema.update_host, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def startup_host(self, hostname):
- """Startup a host."""
-
- resp, body = self.get("os-hosts/%s/startup" % hostname)
- body = json.loads(body)
- self.validate_response(schema.startup_host, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def shutdown_host(self, hostname):
- """Shutdown a host."""
-
- resp, body = self.get("os-hosts/%s/shutdown" % hostname)
- body = json.loads(body)
- self.validate_response(schema.shutdown_host, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def reboot_host(self, hostname):
- """reboot a host."""
-
- resp, body = self.get("os-hosts/%s/reboot" % hostname)
- body = json.loads(body)
- self.validate_response(schema.reboot_host, resp, body)
- return service_client.ResponseBody(resp, body)
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/services/compute/json/images_client.py b/tempest/services/compute/json/images_client.py
deleted file mode 100644
index 99fdfe6..0000000
--- a/tempest/services/compute/json/images_client.py
+++ /dev/null
@@ -1,122 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# 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 six.moves.urllib import parse as urllib
-from tempest_lib import exceptions as lib_exc
-
-from tempest.api_schema.response.compute.v2_1 import images as schema
-from tempest.common import service_client
-
-
-class ImagesClient(service_client.ServiceClient):
-
- def create_image(self, server_id, **kwargs):
- """Creates an image of the original server."""
-
- post_body = {'createImage': kwargs}
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % server_id,
- post_body)
- self.validate_response(schema.create_image, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def list_images(self, detail=False, **params):
- """Returns a list of all images filtered by any parameters."""
- url = 'images'
- _schema = schema.list_images
- if detail:
- url += '/detail'
- _schema = schema.list_images_details
-
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(_schema, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def show_image(self, image_id):
- """Returns the details of a single image."""
- resp, body = self.get("images/%s" % image_id)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- self.validate_response(schema.get_image, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def delete_image(self, image_id):
- """Deletes the provided image."""
- resp, body = self.delete("images/%s" % image_id)
- self.validate_response(schema.delete, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def list_image_metadata(self, image_id):
- """Lists all metadata items for an image."""
- resp, body = self.get("images/%s/metadata" % image_id)
- body = json.loads(body)
- self.validate_response(schema.image_metadata, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def set_image_metadata(self, image_id, meta):
- """Sets the metadata for an image."""
- post_body = json.dumps({'metadata': meta})
- resp, body = self.put('images/%s/metadata' % image_id, post_body)
- body = json.loads(body)
- self.validate_response(schema.image_metadata, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def update_image_metadata(self, image_id, meta):
- """Updates the metadata for an image."""
- post_body = json.dumps({'metadata': meta})
- resp, body = self.post('images/%s/metadata' % image_id, post_body)
- body = json.loads(body)
- self.validate_response(schema.image_metadata, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def show_image_metadata_item(self, image_id, key):
- """Returns the value for a specific image metadata key."""
- resp, body = self.get("images/%s/metadata/%s" % (image_id, key))
- body = json.loads(body)
- self.validate_response(schema.image_meta_item, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def set_image_metadata_item(self, image_id, key, meta):
- """Sets the value for a specific image metadata key."""
- post_body = json.dumps({'meta': meta})
- resp, body = self.put('images/%s/metadata/%s' % (image_id, key),
- post_body)
- body = json.loads(body)
- self.validate_response(schema.image_meta_item, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def delete_image_metadata_item(self, image_id, key):
- """Deletes a single image metadata key/value pair."""
- resp, body = self.delete("images/%s/metadata/%s" %
- (image_id, key))
- self.validate_response(schema.delete, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def is_resource_deleted(self, id):
- try:
- self.show_image(id)
- except lib_exc.NotFound:
- return True
- return False
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'image'
diff --git a/tempest/services/compute/json/instance_usage_audit_log_client.py b/tempest/services/compute/json/instance_usage_audit_log_client.py
deleted file mode 100644
index 4d9625e..0000000
--- a/tempest/services/compute/json/instance_usage_audit_log_client.py
+++ /dev/null
@@ -1,38 +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 \
- instance_usage_audit_logs as schema
-from tempest.common import service_client
-
-
-class InstanceUsagesAuditLogClient(service_client.ServiceClient):
-
- def list_instance_usage_audit_logs(self):
- url = 'os-instance_usage_audit_log'
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_instance_usage_audit_log,
- resp, body)
- return service_client.ResponseBody(resp, body)
-
- def show_instance_usage_audit_log(self, time_before):
- url = 'os-instance_usage_audit_log/%s' % time_before
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.get_instance_usage_audit_log, resp, body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/limits_client.py b/tempest/services/compute/json/limits_client.py
deleted file mode 100644
index b64b4a5..0000000
--- a/tempest/services/compute/json/limits_client.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# 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 limits as schema
-from tempest.common import service_client
-
-
-class LimitsClient(service_client.ServiceClient):
-
- def show_limits(self):
- resp, body = self.get("limits")
- body = json.loads(body)
- self.validate_response(schema.get_limit, resp, body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/migrations_client.py b/tempest/services/compute/json/migrations_client.py
deleted file mode 100644
index b302539..0000000
--- a/tempest/services/compute/json/migrations_client.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2014 NEC Corporation.
-#
-# 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 six.moves.urllib import parse as urllib
-
-from tempest.api_schema.response.compute.v2_1 import migrations as schema
-from tempest.common import service_client
-
-
-class MigrationsClient(service_client.ServiceClient):
-
- def list_migrations(self, **params):
- """Lists all migrations."""
-
- url = 'os-migrations'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_migrations, resp, body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/networks_client.py b/tempest/services/compute/json/networks_client.py
deleted file mode 100644
index dd20ee5..0000000
--- a/tempest/services/compute/json/networks_client.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# 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.common import service_client
-
-
-class NetworksClient(service_client.ServiceClient):
-
- def list_networks(self):
- resp, body = self.get("os-networks")
- body = json.loads(body)
- self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, body)
-
- def show_network(self, network_id):
- resp, body = self.get("os-networks/%s" % network_id)
- body = json.loads(body)
- self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/quota_classes_client.py b/tempest/services/compute/json/quota_classes_client.py
deleted file mode 100644
index d55c3f1..0000000
--- a/tempest/services/compute/json/quota_classes_client.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright 2012 NTT Data
-# 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 quota_classes as classes_schema
-from tempest.common import service_client
-
-
-class QuotaClassesClient(service_client.ServiceClient):
-
- def show_quota_class_set(self, quota_class_id):
- """List the quota class set for a quota class."""
-
- url = 'os-quota-class-sets/%s' % quota_class_id
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(classes_schema.get_quota_class_set, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def update_quota_class_set(self, quota_class_id, **kwargs):
- """
- Updates the quota class's limits for one or more resources.
- """
- post_body = json.dumps({'quota_class_set': kwargs})
-
- resp, body = self.put('os-quota-class-sets/%s' % quota_class_id,
- post_body)
-
- body = json.loads(body)
- self.validate_response(classes_schema.update_quota_class_set,
- resp, body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/quotas_client.py b/tempest/services/compute/json/quotas_client.py
index 4a1b909..e628b3a 100644
--- a/tempest/services/compute/json/quotas_client.py
+++ b/tempest/services/compute/json/quotas_client.py
@@ -42,9 +42,7 @@
return service_client.ResponseBody(resp, body)
def update_quota_set(self, tenant_id, user_id=None, **kwargs):
- """
- Updates the tenant's quota limits for one or more resources
- """
+ """Updates the tenant's quota limits for one or more resources"""
post_body = json.dumps({'quota_set': kwargs})
if user_id:
diff --git a/tempest/services/compute/json/security_group_default_rules_client.py b/tempest/services/compute/json/security_group_default_rules_client.py
index 6e4d1e4..b31baab 100644
--- a/tempest/services/compute/json/security_group_default_rules_client.py
+++ b/tempest/services/compute/json/security_group_default_rules_client.py
@@ -23,8 +23,8 @@
class SecurityGroupDefaultRulesClient(service_client.ServiceClient):
def create_security_default_group_rule(self, **kwargs):
- """
- Creating security group default rules.
+ """Creating security group default rules.
+
ip_protocol : ip_protocol (icmp, tcp, udp).
from_port: Port at start of range.
to_port : Port at end of range.
diff --git a/tempest/services/compute/json/security_group_rules_client.py b/tempest/services/compute/json/security_group_rules_client.py
index 9626f60..314b1ed 100644
--- a/tempest/services/compute/json/security_group_rules_client.py
+++ b/tempest/services/compute/json/security_group_rules_client.py
@@ -22,8 +22,8 @@
class SecurityGroupRulesClient(service_client.ServiceClient):
def create_security_group_rule(self, **kwargs):
- """
- Creating a new security group rules.
+ """Creating a new security group rules.
+
parent_group_id :ID of Security group
ip_protocol : ip_proto (icmp, tcp, udp).
from_port: Port at start of range.
diff --git a/tempest/services/compute/json/security_groups_client.py b/tempest/services/compute/json/security_groups_client.py
index 083d03a..c996079 100644
--- a/tempest/services/compute/json/security_groups_client.py
+++ b/tempest/services/compute/json/security_groups_client.py
@@ -44,8 +44,8 @@
return service_client.ResponseBody(resp, body)
def create_security_group(self, **kwargs):
- """
- Creates a new security group.
+ """Creates a new security group.
+
name (Required): Name of security group.
description (Required): Description of security group.
"""
@@ -56,8 +56,8 @@
return service_client.ResponseBody(resp, body)
def update_security_group(self, security_group_id, **kwargs):
- """
- Update a security group.
+ """Update a security group.
+
security_group_id: a security_group to update
name: new name of security group
description: new description of security group
diff --git a/tempest/services/compute/json/server_groups_client.py b/tempest/services/compute/json/server_groups_client.py
index 33501fb..44ac015 100644
--- a/tempest/services/compute/json/server_groups_client.py
+++ b/tempest/services/compute/json/server_groups_client.py
@@ -22,22 +22,17 @@
class ServerGroupsClient(service_client.ServiceClient):
- def create_server_group(self, name, policies):
- """
- Create the server group
+ def create_server_group(self, **kwargs):
+ """Create the server group
+
name : Name of the server-group
policies : List of the policies - affinity/anti-affinity)
"""
- post_body = {
- 'name': name,
- 'policies': policies,
- }
-
- post_body = json.dumps({'server_group': post_body})
+ post_body = json.dumps({'server_group': kwargs})
resp, body = self.post('os-server-groups', post_body)
body = json.loads(body)
- self.validate_response(schema.create_get_server_group, resp, body)
+ self.validate_response(schema.create_show_server_group, resp, body)
return service_client.ResponseBody(resp, body)
def delete_server_group(self, server_group_id):
@@ -53,9 +48,9 @@
self.validate_response(schema.list_server_groups, resp, body)
return service_client.ResponseBody(resp, body)
- def get_server_group(self, server_group_id):
+ def show_server_group(self, server_group_id):
"""Get the details of given server_group."""
resp, body = self.get("os-server-groups/%s" % server_group_id)
body = json.loads(body)
- self.validate_response(schema.create_get_server_group, resp, body)
+ self.validate_response(schema.create_show_server_group, resp, body)
return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index 1d2c7b2..a0251f1 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -32,8 +32,8 @@
self.enable_instance_password = enable_instance_password
def create_server(self, **kwargs):
- """
- Creates an instance of a server.
+ """Create server
+
Most parameters except the following are passed to the API without
any changes.
:param disk_config: The name is changed to OS-DCF:diskConfig
@@ -69,7 +69,8 @@
return service_client.ResponseBody(resp, body)
def update_server(self, server_id, **kwargs):
- """Updates the properties of an existing server.
+ """Update server
+
Most parameters except the following are passed to the API without
any changes.
:param disk_config: The name is changed to OS-DCF:diskConfig
@@ -84,20 +85,20 @@
return service_client.ResponseBody(resp, body)
def show_server(self, server_id):
- """Returns the details of an existing server."""
+ """Get server details"""
resp, body = self.get("servers/%s" % server_id)
body = json.loads(body)
self.validate_response(schema.get_server, resp, body)
return service_client.ResponseBody(resp, body)
def delete_server(self, server_id):
- """Deletes the given server."""
+ """Delete server"""
resp, body = self.delete("servers/%s" % server_id)
self.validate_response(schema.delete_server, resp, body)
return service_client.ResponseBody(resp, body)
def list_servers(self, detail=False, **params):
- """Lists all servers for a user."""
+ """List servers"""
url = 'servers'
_schema = schema.list_servers
@@ -151,16 +152,16 @@
return self.action(server_id, 'changePassword',
adminPass=adminPass)
- def get_password(self, server_id):
+ def show_password(self, server_id):
resp, body = self.get("servers/%s/os-server-password" %
server_id)
body = json.loads(body)
- self.validate_response(schema.get_password, resp, body)
+ self.validate_response(schema.show_password, resp, body)
return service_client.ResponseBody(resp, body)
def delete_password(self, server_id):
- """
- Removes the encrypted server password from the metadata server
+ """Removes the encrypted server password from the metadata server
+
Note that this does not actually change the instance server
password.
"""
@@ -176,6 +177,7 @@
def rebuild_server(self, server_id, image_ref, **kwargs):
"""Rebuilds a server with a new image.
+
Most parameters except the following are passed to the API without
any changes.
:param disk_config: The name is changed to OS-DCF:diskConfig
@@ -192,6 +194,7 @@
def resize_server(self, server_id, flavor_ref, **kwargs):
"""Changes the flavor of a server.
+
Most parameters except the following are passed to the API without
any changes.
:param disk_config: The name is changed to OS-DCF:diskConfig
@@ -237,10 +240,10 @@
resp, body)
return service_client.ResponseBody(resp, body)
- def get_server_metadata_item(self, server_id, key):
+ def show_server_metadata_item(self, server_id, key):
resp, body = self.get("servers/%s/metadata/%s" % (server_id, key))
body = json.loads(body)
- self.validate_response(schema.set_get_server_metadata_item,
+ self.validate_response(schema.set_show_server_metadata_item,
resp, body)
return service_client.ResponseBody(resp, body)
@@ -249,7 +252,7 @@
resp, body = self.put('servers/%s/metadata/%s' % (server_id, key),
post_body)
body = json.loads(body)
- self.validate_response(schema.set_get_server_metadata_item,
+ self.validate_response(schema.set_show_server_metadata_item,
resp, body)
return service_client.ResponseBody(resp, body)
@@ -275,19 +278,19 @@
self.validate_response(schema.attach_volume, resp, body)
return service_client.ResponseBody(resp, body)
- def detach_volume(self, server_id, volume_id):
+ def detach_volume(self, server_id, volume_id): # noqa
"""Detaches a volume from a server instance."""
resp, body = self.delete('servers/%s/os-volume_attachments/%s' %
(server_id, volume_id))
self.validate_response(schema.detach_volume, resp, body)
return service_client.ResponseBody(resp, body)
- def get_volume_attachment(self, server_id, attach_id):
+ def show_volume_attachment(self, server_id, attach_id):
"""Return details about the given volume attachment."""
resp, body = self.get('servers/%s/os-volume_attachments/%s' % (
server_id, attach_id))
body = json.loads(body)
- self.validate_response(schema.get_volume_attachment, resp, body)
+ self.validate_response(schema.show_volume_attachment, resp, body)
return service_client.ResponseBody(resp, body)
def list_volume_attachments(self, server_id):
@@ -367,9 +370,7 @@
**kwargs)
def list_virtual_interfaces(self, server_id):
- """
- List the virtual interfaces used in an instance.
- """
+ """List the virtual interfaces used in an instance."""
resp, body = self.get('/'.join(['servers', server_id,
'os-virtual-interfaces']))
body = json.loads(body)
@@ -386,7 +387,7 @@
"""Unrescue the provided server."""
return self.action(server_id, 'unrescue')
- def get_server_diagnostics(self, server_id):
+ def show_server_diagnostics(self, server_id):
"""Get the usage data for a server."""
resp, body = self.get("servers/%s/diagnostics" % server_id)
return service_client.ResponseBody(resp, json.loads(body))
@@ -399,12 +400,12 @@
self.validate_response(schema.list_instance_actions, resp, body)
return service_client.ResponseBody(resp, body)
- def get_instance_action(self, server_id, request_id):
+ def show_instance_action(self, server_id, request_id):
"""Returns the action details of the provided server."""
resp, body = self.get("servers/%s/os-instance-actions/%s" %
(server_id, request_id))
body = json.loads(body)
- self.validate_response(schema.get_instance_action, resp, body)
+ self.validate_response(schema.show_instance_action, resp, body)
return service_client.ResponseBody(resp, body)
def force_delete_server(self, server_id, **kwargs):
diff --git a/tempest/services/compute/json/services_client.py b/tempest/services/compute/json/services_client.py
index 232b301..57d0434 100644
--- a/tempest/services/compute/json/services_client.py
+++ b/tempest/services/compute/json/services_client.py
@@ -33,25 +33,26 @@
self.validate_response(schema.list_services, resp, body)
return service_client.ResponseBody(resp, body)
- def enable_service(self, host_name, binary):
- """
- Enable service on a host
+ def enable_service(self, **kwargs):
+ """Enable service on a host
+
host_name: Name of host
binary: Service binary
"""
- post_body = json.dumps({'binary': binary, 'host': host_name})
+ post_body = json.dumps(kwargs)
resp, body = self.put('os-services/enable', post_body)
body = json.loads(body)
- self.validate_response(schema.enable_service, resp, body)
+ self.validate_response(schema.enable_disable_service, resp, body)
return service_client.ResponseBody(resp, body)
- def disable_service(self, host_name, binary):
- """
- Disable service on a host
+ def disable_service(self, **kwargs):
+ """Disable service on a host
+
host_name: Name of host
binary: Service binary
"""
- post_body = json.dumps({'binary': binary, 'host': host_name})
+ post_body = json.dumps(kwargs)
resp, body = self.put('os-services/disable', post_body)
body = json.loads(body)
+ self.validate_response(schema.enable_disable_service, resp, body)
return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/snapshots_extensions_client.py b/tempest/services/compute/json/snapshots_client.py
similarity index 97%
rename from tempest/services/compute/json/snapshots_extensions_client.py
rename to tempest/services/compute/json/snapshots_client.py
index 6902a39..e3f92db 100644
--- a/tempest/services/compute/json/snapshots_extensions_client.py
+++ b/tempest/services/compute/json/snapshots_client.py
@@ -21,7 +21,7 @@
from tempest.common import service_client
-class SnapshotsExtensionsClient(service_client.ServiceClient):
+class SnapshotsClient(service_client.ServiceClient):
def create_snapshot(self, volume_id, **kwargs):
post_body = {
diff --git a/tempest/services/compute/json/volumes_extensions_client.py b/tempest/services/compute/json/volumes_client.py
similarity index 96%
rename from tempest/services/compute/json/volumes_extensions_client.py
rename to tempest/services/compute/json/volumes_client.py
index db92351..69d982e 100644
--- a/tempest/services/compute/json/volumes_extensions_client.py
+++ b/tempest/services/compute/json/volumes_client.py
@@ -21,7 +21,7 @@
from tempest.common import service_client
-class VolumesExtensionsClient(service_client.ServiceClient):
+class VolumesClient(service_client.ServiceClient):
def list_volumes(self, detail=False, **params):
"""List all the volumes created."""
@@ -46,8 +46,8 @@
return service_client.ResponseBody(resp, body)
def create_volume(self, **kwargs):
- """
- Creates a new Volume.
+ """Creates a new Volume.
+
size(Required): Size of volume in GB.
Following optional keyword arguments are accepted:
display_name: Optional Volume Name.
diff --git a/tempest/services/data_processing/v1_1/data_processing_client.py b/tempest/services/data_processing/v1_1/data_processing_client.py
index cba4c42..5aa2622 100644
--- a/tempest/services/data_processing/v1_1/data_processing_client.py
+++ b/tempest/services/data_processing/v1_1/data_processing_client.py
@@ -20,8 +20,7 @@
class DataProcessingClient(service_client.ServiceClient):
def _request_and_check_resp(self, request_func, uri, resp_status):
- """Make a request using specified request_func and check response
- status code.
+ """Make a request and check response status code.
It returns a ResponseBody.
"""
@@ -30,8 +29,7 @@
return service_client.ResponseBody(resp, body)
def _request_and_check_resp_data(self, request_func, uri, resp_status):
- """Make a request using specified request_func and check response
- status code.
+ """Make a request and check response status code.
It returns pair: resp and response data.
"""
@@ -41,8 +39,7 @@
def _request_check_and_parse_resp(self, request_func, uri,
resp_status, *args, **kwargs):
- """Make a request using specified request_func, check response status
- code and parse response body.
+ """Make a request, check response status code and parse response body.
It returns a ResponseBody.
"""
diff --git a/tempest/services/identity/v2/json/identity_client.py b/tempest/services/identity/v2/json/identity_client.py
index 81e967d..3f6727d 100644
--- a/tempest/services/identity/v2/json/identity_client.py
+++ b/tempest/services/identity/v2/json/identity_client.py
@@ -11,7 +11,6 @@
# under the License.
from oslo_serialization import jsonutils as json
-from tempest_lib import exceptions as lib_exc
from tempest.common import service_client
@@ -19,27 +18,13 @@
class IdentityClient(service_client.ServiceClient):
api_version = "v2.0"
- def get_api_description(self):
+ def show_api_description(self):
"""Retrieves info about the v2.0 Identity API"""
url = ''
resp, body = self.get(url)
self.expected_success([200, 203], resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
-
- def has_admin_extensions(self):
- """
- Returns True if the KSADM Admin Extensions are supported
- False otherwise
- """
- if hasattr(self, '_has_admin_extensions'):
- return self._has_admin_extensions
- # Try something that requires admin
- try:
- self.list_roles()
- self._has_admin_extensions = True
- except Exception:
- self._has_admin_extensions = False
- return self._has_admin_extensions
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def create_role(self, name):
"""Create a role."""
@@ -49,9 +34,10 @@
post_body = json.dumps({'role': post_body})
resp, body = self.post('OS-KSADM/roles', post_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
- def get_role(self, role_id):
+ def show_role(self, role_id):
"""Get a role by its id."""
resp, body = self.get('OS-KSADM/roles/%s' % role_id)
self.expected_success(200, resp.status)
@@ -59,8 +45,8 @@
return service_client.ResponseBody(resp, body)
def create_tenant(self, name, **kwargs):
- """
- Create a tenant
+ """Create a tenant
+
name (required): New tenant name
description: Description of new tenant (default is none)
enabled <true|false>: Initial tenant status (default is true)
@@ -73,7 +59,8 @@
post_body = json.dumps({'tenant': post_body})
resp, body = self.post('tenants', post_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def delete_role(self, role_id):
"""Delete a role."""
@@ -86,16 +73,18 @@
url = '/tenants/%s/users/%s/roles' % (tenant_id, user_id)
resp, body = self.get(url)
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def assign_user_role(self, tenant_id, user_id, role_id):
"""Add roles to a user on a tenant."""
resp, body = self.put('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
(tenant_id, user_id, role_id), "")
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
- def remove_user_role(self, tenant_id, user_id, role_id):
+ def delete_user_role(self, tenant_id, user_id, role_id):
"""Removes a role assignment for a user on a tenant."""
resp, body = self.delete('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
(tenant_id, user_id, role_id))
@@ -108,17 +97,19 @@
self.expected_success(204, resp.status)
return service_client.ResponseBody(resp, body)
- def get_tenant(self, tenant_id):
+ def show_tenant(self, tenant_id):
"""Get tenant details."""
resp, body = self.get('tenants/%s' % str(tenant_id))
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def list_roles(self):
"""Returns roles."""
resp, body = self.get('OS-KSADM/roles')
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def list_tenants(self):
"""Returns tenants."""
@@ -127,16 +118,9 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def get_tenant_by_name(self, tenant_name):
- tenants = self.list_tenants()['tenants']
- for tenant in tenants:
- if tenant['name'] == tenant_name:
- return tenant
- raise lib_exc.NotFound('No such tenant')
-
def update_tenant(self, tenant_id, **kwargs):
"""Updates a tenant."""
- body = self.get_tenant(tenant_id)
+ body = self.show_tenant(tenant_id)['tenant']
name = kwargs.get('name', body['name'])
desc = kwargs.get('description', body['description'])
en = kwargs.get('enabled', body['enabled'])
@@ -149,7 +133,8 @@
post_body = json.dumps({'tenant': post_body})
resp, body = self.post('tenants/%s' % tenant_id, post_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def create_user(self, name, password, tenant_id, email, **kwargs):
"""Create a user."""
@@ -165,20 +150,23 @@
post_body = json.dumps({'user': post_body})
resp, body = self.post('users', post_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def update_user(self, user_id, **kwargs):
"""Updates a user."""
put_body = json.dumps({'user': kwargs})
resp, body = self.put('users/%s' % user_id, put_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
- def get_user(self, user_id):
+ def show_user(self, user_id):
"""GET a user."""
resp, body = self.get("users/%s" % user_id)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def delete_user(self, user_id):
"""Delete a user."""
@@ -186,11 +174,12 @@
self.expected_success(204, resp.status)
return service_client.ResponseBody(resp, body)
- def get_users(self):
+ def list_users(self):
"""Get the list of users."""
resp, body = self.get("users")
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def enable_disable_user(self, user_id, enabled):
"""Enables or disables a user."""
@@ -200,13 +189,15 @@
put_body = json.dumps({'user': put_body})
resp, body = self.put('users/%s/enabled' % user_id, put_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
- def get_token(self, token_id):
+ def show_token(self, token_id):
"""Get token details."""
resp, body = self.get("tokens/%s" % token_id)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def delete_token(self, token_id):
"""Delete a token."""
@@ -214,18 +205,12 @@
self.expected_success(204, resp.status)
return service_client.ResponseBody(resp, body)
- def list_users_for_tenant(self, tenant_id):
+ def list_tenant_users(self, tenant_id):
"""List users for a Tenant."""
resp, body = self.get('/tenants/%s/users' % tenant_id)
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, self._parse_resp(body))
-
- def get_user_by_username(self, tenant_id, username):
- users = self.list_users_for_tenant(tenant_id)
- for user in users:
- if user['name'] == username:
- return user
- raise lib_exc.NotFound('No such user')
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def create_service(self, name, type, **kwargs):
"""Create a service."""
@@ -237,20 +222,23 @@
post_body = json.dumps({'OS-KSADM:service': post_body})
resp, body = self.post('/OS-KSADM/services', post_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
- def get_service(self, service_id):
+ def show_service(self, service_id):
"""Get Service."""
url = '/OS-KSADM/services/%s' % service_id
resp, body = self.get(url)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def list_services(self):
"""List Service - Returns Services."""
resp, body = self.get('/OS-KSADM/services')
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def delete_service(self, service_id):
"""Delete Service."""
@@ -271,13 +259,15 @@
post_body = json.dumps({'endpoint': post_body})
resp, body = self.post('/endpoints', post_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def list_endpoints(self):
"""List Endpoints - Returns Endpoints."""
resp, body = self.get('/endpoints')
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def delete_endpoint(self, endpoint_id):
"""Delete an endpoint."""
@@ -295,7 +285,8 @@
put_body = json.dumps({'user': put_body})
resp, body = self.put('users/%s/OS-KSADM/password' % user_id, put_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def update_user_own_password(self, user_id, new_pass, old_pass):
"""User updates own password"""
@@ -306,22 +297,23 @@
patch_body = json.dumps({'user': patch_body})
resp, body = self.patch('OS-KSCRUD/users/%s' % user_id, patch_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def list_extensions(self):
"""List all the extensions."""
resp, body = self.get('/extensions')
self.expected_success(200, resp.status)
body = json.loads(body)
- return service_client.ResponseBodyList(resp,
- body['extensions']['values'])
+ return service_client.ResponseBody(resp, body)
def create_user_ec2_credentials(self, user_id, tenant_id):
post_body = json.dumps({'tenant_id': tenant_id})
resp, body = self.post('/users/%s/credentials/OS-EC2' % user_id,
post_body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def delete_user_ec2_credentials(self, user_id, access):
resp, body = self.delete('/users/%s/credentials/OS-EC2/%s' %
@@ -332,10 +324,12 @@
def list_user_ec2_credentials(self, user_id):
resp, body = self.get('/users/%s/credentials/OS-EC2' % user_id)
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def show_user_ec2_credentials(self, user_id, access):
resp, body = self.get('/users/%s/credentials/OS-EC2/%s' %
(user_id, access))
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/identity/v3/json/credentials_client.py b/tempest/services/identity/v3/json/credentials_client.py
index decf3a8..7d4cf9a 100644
--- a/tempest/services/identity/v3/json/credentials_client.py
+++ b/tempest/services/identity/v3/json/credentials_client.py
@@ -13,6 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+"""
+http://developer.openstack.org/api-ref-identity-v3.html#credentials-v3
+"""
+
from oslo_serialization import jsonutils as json
from tempest.common import service_client
@@ -21,17 +25,13 @@
class CredentialsClient(service_client.ServiceClient):
api_version = "v3"
- def create_credential(self, access_key, secret_key, user_id, project_id):
- """Creates a credential."""
- blob = "{\"access\": \"%s\", \"secret\": \"%s\"}" % (
- access_key, secret_key)
- post_body = {
- "blob": blob,
- "project_id": project_id,
- "type": "ec2",
- "user_id": user_id
- }
- post_body = json.dumps({'credential': post_body})
+ def create_credential(self, **kwargs):
+ """Creates a credential.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-identity-v3.html#createCredential
+ """
+ post_body = json.dumps({'credential': kwargs})
resp, body = self.post('credentials', post_body)
self.expected_success(201, resp.status)
body = json.loads(body)
@@ -39,22 +39,12 @@
return service_client.ResponseBody(resp, body)
def update_credential(self, credential_id, **kwargs):
- """Updates a credential."""
- body = self.get_credential(credential_id)['credential']
- cred_type = kwargs.get('type', body['type'])
- access_key = kwargs.get('access_key', body['blob']['access'])
- secret_key = kwargs.get('secret_key', body['blob']['secret'])
- project_id = kwargs.get('project_id', body['project_id'])
- user_id = kwargs.get('user_id', body['user_id'])
- blob = "{\"access\": \"%s\", \"secret\": \"%s\"}" % (
- access_key, secret_key)
- post_body = {
- "blob": blob,
- "project_id": project_id,
- "type": cred_type,
- "user_id": user_id
- }
- post_body = json.dumps({'credential': post_body})
+ """Updates a credential.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-identity-v3.html#updateCredential
+ """
+ post_body = json.dumps({'credential': kwargs})
resp, body = self.patch('credentials/%s' % credential_id, post_body)
self.expected_success(200, resp.status)
body = json.loads(body)
diff --git a/tempest/services/identity/v3/json/endpoints_client.py b/tempest/services/identity/v3/json/endpoints_client.py
index 6bdf8b3..ede5edb 100644
--- a/tempest/services/identity/v3/json/endpoints_client.py
+++ b/tempest/services/identity/v3/json/endpoints_client.py
@@ -13,6 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+"""
+http://developer.openstack.org/api-ref-identity-v3.html#endpoints-v3
+"""
+
from oslo_serialization import jsonutils as json
from tempest.common import service_client
@@ -28,53 +32,25 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def create_endpoint(self, service_id, interface, url, **kwargs):
+ def create_endpoint(self, **kwargs):
"""Create endpoint.
- Normally this function wouldn't allow setting values that are not
- allowed for 'enabled'. Use `force_enabled` to set a non-boolean.
-
+ Available params: see http://developer.openstack.org/
+ api-ref-identity-v3.html#createEndpoint
"""
- region = kwargs.get('region', None)
- if 'force_enabled' in kwargs:
- enabled = kwargs.get('force_enabled', None)
- else:
- enabled = kwargs.get('enabled', None)
- post_body = {
- 'service_id': service_id,
- 'interface': interface,
- 'url': url,
- 'region': region,
- 'enabled': enabled
- }
- post_body = json.dumps({'endpoint': post_body})
+ post_body = json.dumps({'endpoint': kwargs})
resp, body = self.post('endpoints', post_body)
self.expected_success(201, resp.status)
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def update_endpoint(self, endpoint_id, service_id=None, interface=None,
- url=None, region=None, enabled=None, **kwargs):
+ def update_endpoint(self, endpoint_id, **kwargs):
"""Updates an endpoint with given parameters.
- Normally this function wouldn't allow setting values that are not
- allowed for 'enabled'. Use `force_enabled` to set a non-boolean.
-
+ Available params: see http://developer.openstack.org/
+ api-ref-identity-v3.html#updateEndpoint
"""
- post_body = {}
- if service_id is not None:
- post_body['service_id'] = service_id
- if interface is not None:
- post_body['interface'] = interface
- if url is not None:
- post_body['url'] = url
- if region is not None:
- post_body['region'] = region
- if 'force_enabled' in kwargs:
- post_body['enabled'] = kwargs['force_enabled']
- elif enabled is not None:
- post_body['enabled'] = enabled
- post_body = json.dumps({'endpoint': post_body})
+ post_body = json.dumps({'endpoint': kwargs})
resp, body = self.patch('endpoints/%s' % endpoint_id, post_body)
self.expected_success(200, resp.status)
body = json.loads(body)
diff --git a/tempest/services/identity/v3/json/groups_client.py b/tempest/services/identity/v3/json/groups_client.py
new file mode 100644
index 0000000..5bd610d
--- /dev/null
+++ b/tempest/services/identity/v3/json/groups_client.py
@@ -0,0 +1,94 @@
+# Copyright 2013 OpenStack Foundation
+# 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.common import service_client
+
+
+class GroupsClient(service_client.ServiceClient):
+ api_version = "v3"
+
+ def create_group(self, name, **kwargs):
+ """Creates a group."""
+ description = kwargs.get('description', None)
+ domain_id = kwargs.get('domain_id', 'default')
+ project_id = kwargs.get('project_id', None)
+ post_body = {
+ 'description': description,
+ 'domain_id': domain_id,
+ 'project_id': project_id,
+ 'name': name
+ }
+ post_body = json.dumps({'group': post_body})
+ resp, body = self.post('groups', post_body)
+ self.expected_success(201, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def get_group(self, group_id):
+ """Get group details."""
+ resp, body = self.get('groups/%s' % group_id)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def list_groups(self):
+ """Lists the groups."""
+ resp, body = self.get('groups')
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def update_group(self, group_id, **kwargs):
+ """Updates a group."""
+ body = self.get_group(group_id)['group']
+ name = kwargs.get('name', body['name'])
+ description = kwargs.get('description', body['description'])
+ post_body = {
+ 'name': name,
+ 'description': description
+ }
+ post_body = json.dumps({'group': post_body})
+ resp, body = self.patch('groups/%s' % group_id, post_body)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def delete_group(self, group_id):
+ """Delete a group."""
+ resp, body = self.delete('groups/%s' % str(group_id))
+ self.expected_success(204, resp.status)
+ return service_client.ResponseBody(resp, body)
+
+ def add_group_user(self, group_id, user_id):
+ """Add user into group."""
+ resp, body = self.put('groups/%s/users/%s' % (group_id, user_id),
+ None)
+ self.expected_success(204, resp.status)
+ return service_client.ResponseBody(resp, body)
+
+ def list_group_users(self, group_id):
+ """List users in group."""
+ resp, body = self.get('groups/%s/users' % group_id)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def delete_group_user(self, group_id, user_id):
+ """Delete user in group."""
+ resp, body = self.delete('groups/%s/users/%s' % (group_id, user_id))
+ self.expected_success(204, resp.status)
+ return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/identity/v3/json/identity_client.py b/tempest/services/identity/v3/json/identity_client.py
index 3f27624..bbd8804 100644
--- a/tempest/services/identity/v3/json/identity_client.py
+++ b/tempest/services/identity/v3/json/identity_client.py
@@ -22,7 +22,7 @@
class IdentityV3Client(service_client.ServiceClient):
api_version = "v3"
- def get_api_description(self):
+ def show_api_description(self):
"""Retrieves info about the v3 Identity API"""
url = ''
resp, body = self.get(url)
@@ -54,7 +54,7 @@
def update_user(self, user_id, name, **kwargs):
"""Updates a user."""
- body = self.get_user(user_id)['user']
+ body = self.show_user(user_id)['user']
email = kwargs.get('email', body['email'])
en = kwargs.get('enabled', body['enabled'])
project_id = kwargs.get('project_id', body['project_id'])
@@ -99,7 +99,7 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def get_users(self, params=None):
+ def list_users(self, params=None):
"""Get the list of users."""
url = 'users'
if params:
@@ -109,7 +109,7 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def get_user(self, user_id):
+ def show_user(self, user_id):
"""GET a user."""
resp, body = self.get("users/%s" % user_id)
self.expected_success(200, resp.status)
@@ -191,7 +191,7 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def get_role(self, role_id):
+ def show_role(self, role_id):
"""GET a Role."""
resp, body = self.get('roles/%s' % str(role_id))
self.expected_success(200, resp.status)
@@ -284,7 +284,7 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def get_token(self, resp_token):
+ def show_token(self, resp_token):
"""Get token details."""
headers = {'X-Subject-Token': resp_token}
resp, body = self.get("auth/tokens", headers=headers)
@@ -299,72 +299,6 @@
self.expected_success(204, resp.status)
return service_client.ResponseBody(resp, body)
- def create_group(self, name, **kwargs):
- """Creates a group."""
- description = kwargs.get('description', None)
- domain_id = kwargs.get('domain_id', 'default')
- project_id = kwargs.get('project_id', None)
- post_body = {
- 'description': description,
- 'domain_id': domain_id,
- 'project_id': project_id,
- 'name': name
- }
- post_body = json.dumps({'group': post_body})
- resp, body = self.post('groups', post_body)
- self.expected_success(201, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
- def get_group(self, group_id):
- """Get group details."""
- resp, body = self.get('groups/%s' % group_id)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
- def list_groups(self):
- """Lists the groups."""
- resp, body = self.get('groups')
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
- def update_group(self, group_id, **kwargs):
- """Updates a group."""
- body = self.get_group(group_id)['group']
- name = kwargs.get('name', body['name'])
- description = kwargs.get('description', body['description'])
- post_body = {
- 'name': name,
- 'description': description
- }
- post_body = json.dumps({'group': post_body})
- resp, body = self.patch('groups/%s' % group_id, post_body)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
- def delete_group(self, group_id):
- """Delete a group."""
- resp, body = self.delete('groups/%s' % str(group_id))
- self.expected_success(204, resp.status)
- return service_client.ResponseBody(resp, body)
-
- def add_group_user(self, group_id, user_id):
- """Add user into group."""
- resp, body = self.put('groups/%s/users/%s' % (group_id, user_id),
- None)
- self.expected_success(204, resp.status)
- return service_client.ResponseBody(resp, body)
-
- def list_group_users(self, group_id):
- """List users in group."""
- resp, body = self.get('groups/%s/users' % group_id)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
def list_user_groups(self, user_id):
"""Lists groups which a user belongs to."""
resp, body = self.get('users/%s/groups' % user_id)
@@ -372,12 +306,6 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def delete_group_user(self, group_id, user_id):
- """Delete user in group."""
- resp, body = self.delete('groups/%s/users/%s' % (group_id, user_id))
- self.expected_success(204, resp.status)
- return service_client.ResponseBody(resp, body)
-
def assign_user_role_on_project(self, project_id, user_id, role_id):
"""Add roles to a user on a project."""
resp, body = self.put('projects/%s/users/%s/roles/%s' %
@@ -408,14 +336,14 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def revoke_role_from_user_on_project(self, project_id, user_id, role_id):
+ def delete_role_from_user_on_project(self, project_id, user_id, role_id):
"""Delete role of a user on a project."""
resp, body = self.delete('projects/%s/users/%s/roles/%s' %
(project_id, user_id, role_id))
self.expected_success(204, resp.status)
return service_client.ResponseBody(resp, body)
- def revoke_role_from_user_on_domain(self, domain_id, user_id, role_id):
+ def delete_role_from_user_on_domain(self, domain_id, user_id, role_id):
"""Delete role of a user on a domain."""
resp, body = self.delete('domains/%s/users/%s/roles/%s' %
(domain_id, user_id, role_id))
@@ -452,14 +380,14 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def revoke_role_from_group_on_project(self, project_id, group_id, role_id):
+ def delete_role_from_group_on_project(self, project_id, group_id, role_id):
"""Delete role of a user on a project."""
resp, body = self.delete('projects/%s/groups/%s/roles/%s' %
(project_id, group_id, role_id))
self.expected_success(204, resp.status)
return service_client.ResponseBody(resp, body)
- def revoke_role_from_group_on_domain(self, domain_id, group_id, role_id):
+ def delete_role_from_group_on_domain(self, domain_id, group_id, role_id):
"""Delete role of a user on a domain."""
resp, body = self.delete('domains/%s/groups/%s/roles/%s' %
(domain_id, group_id, role_id))
diff --git a/tempest/services/identity/v3/json/policy_client.py b/tempest/services/identity/v3/json/policy_client.py
index 3231bb0..ecc9df7 100644
--- a/tempest/services/identity/v3/json/policy_client.py
+++ b/tempest/services/identity/v3/json/policy_client.py
@@ -13,6 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+"""
+http://developer.openstack.org/api-ref-identity-v3.html#policies-v3
+"""
+
from oslo_serialization import jsonutils as json
from tempest.common import service_client
@@ -21,13 +25,13 @@
class PolicyClient(service_client.ServiceClient):
api_version = "v3"
- def create_policy(self, blob, type):
- """Creates a Policy."""
- post_body = {
- "blob": blob,
- "type": type
- }
- post_body = json.dumps({'policy': post_body})
+ def create_policy(self, **kwargs):
+ """Creates a Policy.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-identity-v3.html#createPolicy
+ """
+ post_body = json.dumps({'policy': kwargs})
resp, body = self.post('policies', post_body)
self.expected_success(201, resp.status)
body = json.loads(body)
@@ -49,12 +53,12 @@
return service_client.ResponseBody(resp, body)
def update_policy(self, policy_id, **kwargs):
- """Updates a policy."""
- type = kwargs.get('type')
- post_body = {
- 'type': type
- }
- post_body = json.dumps({'policy': post_body})
+ """Updates a policy.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-identity-v3.html#updatePolicy
+ """
+ post_body = json.dumps({'policy': kwargs})
url = 'policies/%s' % policy_id
resp, body = self.patch(url, post_body)
self.expected_success(200, resp.status)
diff --git a/tempest/services/identity/v3/json/region_client.py b/tempest/services/identity/v3/json/region_client.py
index 24c6f33..6ccdc31 100644
--- a/tempest/services/identity/v3/json/region_client.py
+++ b/tempest/services/identity/v3/json/region_client.py
@@ -13,6 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+"""
+http://developer.openstack.org/api-ref-identity-v3.html#regions-v3
+"""
+
from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
@@ -22,31 +26,34 @@
class RegionClient(service_client.ServiceClient):
api_version = "v3"
- def create_region(self, description, **kwargs):
- """Create region."""
- req_body = {
- 'description': description,
- }
- if kwargs.get('parent_region_id'):
- req_body['parent_region_id'] = kwargs.get('parent_region_id')
- req_body = json.dumps({'region': req_body})
- if kwargs.get('unique_region_id'):
- resp, body = self.put(
- 'regions/%s' % kwargs.get('unique_region_id'), req_body)
+ def create_region(self, region_id=None, **kwargs):
+ """Create region.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-identity-v3.html#createRegion
+
+ see http://developer.openstack.org/
+ api-ref-identity-v3.html#createRegionWithID
+ """
+ if region_id is not None:
+ method = self.put
+ url = 'regions/%s' % region_id
else:
- resp, body = self.post('regions', req_body)
+ method = self.post
+ url = 'regions'
+ req_body = json.dumps({'region': kwargs})
+ resp, body = method(url, req_body)
self.expected_success(201, resp.status)
body = json.loads(body)
return service_client.ResponseBody(resp, body)
def update_region(self, region_id, **kwargs):
- """Updates a region."""
- post_body = {}
- if 'description' in kwargs:
- post_body['description'] = kwargs.get('description')
- if 'parent_region_id' in kwargs:
- post_body['parent_region_id'] = kwargs.get('parent_region_id')
- post_body = json.dumps({'region': post_body})
+ """Updates a region.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-identity-v3.html#updateRegion
+ """
+ post_body = json.dumps({'region': kwargs})
resp, body = self.patch('regions/%s' % region_id, post_body)
self.expected_success(200, resp.status)
body = json.loads(body)
diff --git a/tempest/services/identity/v3/json/service_client.py b/tempest/services/identity/v3/json/service_client.py
index 2acc3a8..3dbfe5e 100644
--- a/tempest/services/identity/v3/json/service_client.py
+++ b/tempest/services/identity/v3/json/service_client.py
@@ -13,6 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+"""
+http://developer.openstack.org/api-ref-identity-v3.html#service-catalog-v3
+"""
+
from oslo_serialization import jsonutils as json
from tempest.common import service_client
@@ -22,23 +26,18 @@
api_version = "v3"
def update_service(self, service_id, **kwargs):
- """Updates a service."""
- body = self.get_service(service_id)['service']
- name = kwargs.get('name', body['name'])
- type = kwargs.get('type', body['type'])
- desc = kwargs.get('description', body['description'])
- patch_body = {
- 'description': desc,
- 'type': type,
- 'name': name
- }
- patch_body = json.dumps({'service': patch_body})
+ """Updates a service.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-identity-v3.html#updateService
+ """
+ patch_body = json.dumps({'service': kwargs})
resp, body = self.patch('services/%s' % service_id, patch_body)
self.expected_success(200, resp.status)
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def get_service(self, service_id):
+ def show_service(self, service_id):
"""Get Service."""
url = 'services/%s' % service_id
resp, body = self.get(url)
@@ -46,15 +45,13 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def create_service(self, serv_type, name=None, description=None,
- enabled=True):
- body_dict = {
- 'name': name,
- 'type': serv_type,
- 'enabled': enabled,
- 'description': description,
- }
- body = json.dumps({'service': body_dict})
+ def create_service(self, **kwargs):
+ """Creates a service.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-identity-v3.html#createService
+ """
+ body = json.dumps({'service': kwargs})
resp, body = self.post("services", body)
self.expected_success(201, resp.status)
body = json.loads(body)
diff --git a/tempest/services/image/v2/json/image_client.py b/tempest/services/image/v2/json/image_client.py
index 6cad746..413f70e 100644
--- a/tempest/services/image/v2/json/image_client.py
+++ b/tempest/services/image/v2/json/image_client.py
@@ -200,7 +200,7 @@
self.expected_success(200, resp.status)
return service_client.ResponseBody(resp, json.loads(body))
- def remove_image_member(self, image_id, member_id):
+ def delete_image_member(self, image_id, member_id):
url = 'v2/images/%s/members/%s' % (image_id, member_id)
resp, _ = self.delete(url)
self.expected_success(204, resp.status)
@@ -212,3 +212,63 @@
self.expected_success(200, resp.status)
body = json.loads(body)
return service_client.ResponseBody(resp, body)
+
+ def list_resource_types(self):
+ url = '/v2/metadefs/resource_types'
+ resp, body = self.get(url)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def create_namespaces(self, namespace, **kwargs):
+ params = {
+ "namespace": namespace,
+ }
+
+ for option in kwargs:
+ value = kwargs.get(option)
+ if isinstance(value, dict) or isinstance(value, tuple):
+ params.update(value)
+ else:
+ params[option] = value
+
+ data = json.dumps(params)
+ self._validate_schema(data)
+
+ resp, body = self.post('/v2/metadefs/namespaces', data)
+ self.expected_success(201, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def show_namespaces(self, namespace):
+ url = '/v2/metadefs/namespaces/%s' % namespace
+ resp, body = self.get(url)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def update_namespaces(self, namespace, visibility, **kwargs):
+ params = {
+ "namespace": namespace,
+ "visibility": visibility
+ }
+ for option in kwargs:
+ value = kwargs.get(option)
+ if isinstance(value, dict) or isinstance(value, tuple):
+ params.update(value)
+ else:
+ params[option] = value
+
+ data = json.dumps(params)
+ self._validate_schema(data)
+ url = '/v2/metadefs/namespaces/%s' % namespace
+ resp, body = self.put(url, body=data)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def delete_namespaces(self, namespace):
+ url = '/v2/metadefs/namespaces/%s' % namespace
+ resp, _ = self.delete(url)
+ self.expected_success(204, resp.status)
+ return service_client.ResponseBody(resp)
diff --git a/tempest/services/messaging/json/messaging_client.py b/tempest/services/messaging/json/messaging_client.py
index 2f233a9..5a43841 100644
--- a/tempest/services/messaging/json/messaging_client.py
+++ b/tempest/services/messaging/json/messaging_client.py
@@ -170,7 +170,7 @@
self.expected_success(204, resp.status)
return resp, body
- def release_claim(self, claim_uri):
+ def delete_claim(self, claim_uri):
resp, body = self.delete(claim_uri)
self.expected_success(204, resp.status)
return resp, body
diff --git a/tempest/services/network/json/base.py b/tempest/services/network/json/base.py
index fe150df..6ebc245 100644
--- a/tempest/services/network/json/base.py
+++ b/tempest/services/network/json/base.py
@@ -18,9 +18,10 @@
class BaseNetworkClient(service_client.ServiceClient):
- """
- Base class for Tempest REST clients for Neutron. Child classes use v2 of
- the Neutron API, since the V1 API has been removed from the code base.
+ """Base class for Tempest REST clients for Neutron.
+
+ Child classes use v2 of the Neutron API, since the V1 API has been
+ removed from the code base.
"""
version = '2.0'
diff --git a/tempest/services/network/json/floating_ips_client.py b/tempest/services/network/json/floating_ips_client.py
new file mode 100644
index 0000000..5c490ed
--- /dev/null
+++ b/tempest/services/network/json/floating_ips_client.py
@@ -0,0 +1,38 @@
+# 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.network.json import base
+
+
+class FloatingIPsClient(base.BaseNetworkClient):
+
+ def create_floatingip(self, **kwargs):
+ uri = '/floatingips'
+ post_data = {'floatingip': kwargs}
+ return self.create_resource(uri, post_data)
+
+ def update_floatingip(self, floatingip_id, **kwargs):
+ uri = '/floatingips/%s' % floatingip_id
+ post_data = {'floatingip': kwargs}
+ return self.update_resource(uri, post_data)
+
+ def show_floatingip(self, floatingip_id, **fields):
+ uri = '/floatingips/%s' % floatingip_id
+ return self.show_resource(uri, **fields)
+
+ def delete_floatingip(self, floatingip_id):
+ uri = '/floatingips/%s' % floatingip_id
+ return self.delete_resource(uri)
+
+ def list_floatingips(self, **filters):
+ uri = '/floatingips'
+ return self.list_resources(uri, **filters)
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index a345d56..5a4229c 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -21,9 +21,10 @@
class NetworkClient(base.BaseNetworkClient):
- """
- Tempest REST client for Neutron. Uses v2 of the Neutron API, since the
- V1 API has been removed from the code base.
+ """Tempest REST client for Neutron.
+
+ Uses v2 of the Neutron API, since the V1 API has been removed from the
+ code base.
Implements create, delete, update, list and show for the basic Neutron
abstractions (networks, sub-networks, routers, ports and floating IP):
@@ -34,94 +35,6 @@
quotas
"""
- def create_network(self, **kwargs):
- uri = '/networks'
- post_data = {'network': kwargs}
- return self.create_resource(uri, post_data)
-
- def update_network(self, network_id, **kwargs):
- uri = '/networks/%s' % network_id
- post_data = {'network': kwargs}
- return self.update_resource(uri, post_data)
-
- def show_network(self, network_id, **fields):
- uri = '/networks/%s' % network_id
- return self.show_resource(uri, **fields)
-
- def delete_network(self, network_id):
- uri = '/networks/%s' % network_id
- return self.delete_resource(uri)
-
- def list_networks(self, **filters):
- uri = '/networks'
- return self.list_resources(uri, **filters)
-
- def create_subnet(self, **kwargs):
- uri = '/subnets'
- post_data = {'subnet': kwargs}
- return self.create_resource(uri, post_data)
-
- def update_subnet(self, subnet_id, **kwargs):
- uri = '/subnets/%s' % subnet_id
- post_data = {'subnet': kwargs}
- return self.update_resource(uri, post_data)
-
- def show_subnet(self, subnet_id, **fields):
- uri = '/subnets/%s' % subnet_id
- return self.show_resource(uri, **fields)
-
- def delete_subnet(self, subnet_id):
- uri = '/subnets/%s' % subnet_id
- return self.delete_resource(uri)
-
- def list_subnets(self, **filters):
- uri = '/subnets'
- return self.list_resources(uri, **filters)
-
- def create_port(self, **kwargs):
- uri = '/ports'
- post_data = {'port': kwargs}
- return self.create_resource(uri, post_data)
-
- def update_port(self, port_id, **kwargs):
- uri = '/ports/%s' % port_id
- post_data = {'port': kwargs}
- return self.update_resource(uri, post_data)
-
- def show_port(self, port_id, **fields):
- uri = '/ports/%s' % port_id
- return self.show_resource(uri, **fields)
-
- def delete_port(self, port_id):
- uri = '/ports/%s' % port_id
- return self.delete_resource(uri)
-
- def list_ports(self, **filters):
- uri = '/ports'
- return self.list_resources(uri, **filters)
-
- def create_floatingip(self, **kwargs):
- uri = '/floatingips'
- post_data = {'floatingip': kwargs}
- return self.create_resource(uri, post_data)
-
- def update_floatingip(self, floatingip_id, **kwargs):
- uri = '/floatingips/%s' % floatingip_id
- post_data = {'floatingip': kwargs}
- return self.update_resource(uri, post_data)
-
- def show_floatingip(self, floatingip_id, **fields):
- uri = '/floatingips/%s' % floatingip_id
- return self.show_resource(uri, **fields)
-
- def delete_floatingip(self, floatingip_id):
- uri = '/floatingips/%s' % floatingip_id
- return self.delete_resource(uri)
-
- def list_floatingips(self, **filters):
- uri = '/floatingips'
- return self.list_resources(uri, **filters)
-
def create_metering_label(self, **kwargs):
uri = '/metering/metering-labels'
post_data = {'metering_label': kwargs}
@@ -219,20 +132,22 @@
uri = '/ports'
return self.create_resource(uri, post_data)
- def wait_for_resource_deletion(self, resource_type, id):
+ def wait_for_resource_deletion(self, resource_type, id, client=None):
"""Waits for a resource to be deleted."""
start_time = int(time.time())
while True:
- if self.is_resource_deleted(resource_type, id):
+ if self.is_resource_deleted(resource_type, id, client=client):
return
if int(time.time()) - start_time >= self.build_timeout:
raise exceptions.TimeoutException
time.sleep(self.build_interval)
- def is_resource_deleted(self, resource_type, id):
+ def is_resource_deleted(self, resource_type, id, client=None):
+ if client is None:
+ client = self
method = 'show_' + resource_type
try:
- getattr(self, method)(id)
+ getattr(client, method)(id)
except AttributeError:
raise Exception("Unknown resource type %s " % resource_type)
except lib_exc.NotFound:
@@ -241,8 +156,8 @@
def wait_for_resource_status(self, fetch, status, interval=None,
timeout=None):
- """
- @summary: Waits for a network resource to reach a status
+ """Waits for a network resource to reach a status
+
@param fetch: the callable to be used to query the resource status
@type fecth: callable that takes no parameters and returns the resource
@param status: the status that the resource has to reach
@@ -377,7 +292,8 @@
return self.list_resources(uri)
def update_agent(self, agent_id, agent_info):
- """
+ """Update agent
+
:param agent_info: Agent update information.
E.g {"admin_state_up": True}
"""
@@ -445,3 +361,25 @@
post_body = {'network_id': network_id}
uri = '/agents/%s/dhcp-networks' % agent_id
return self.create_resource(uri, post_body)
+
+ def list_subnetpools(self, **filters):
+ uri = '/subnetpools'
+ return self.list_resources(uri, **filters)
+
+ def create_subnetpools(self, **kwargs):
+ uri = '/subnetpools'
+ post_data = {'subnetpool': kwargs}
+ return self.create_resource(uri, post_data)
+
+ def show_subnetpools(self, subnetpool_id, **fields):
+ uri = '/subnetpools/%s' % subnetpool_id
+ return self.show_resource(uri, **fields)
+
+ def update_subnetpools(self, subnetpool_id, **kwargs):
+ uri = '/subnetpools/%s' % subnetpool_id
+ post_data = {'subnetpool': kwargs}
+ return self.update_resource(uri, post_data)
+
+ def delete_subnetpools(self, subnetpool_id):
+ uri = '/subnetpools/%s' % subnetpool_id
+ return self.delete_resource(uri)
diff --git a/tempest/services/network/json/networks_client.py b/tempest/services/network/json/networks_client.py
new file mode 100644
index 0000000..2907d44
--- /dev/null
+++ b/tempest/services/network/json/networks_client.py
@@ -0,0 +1,38 @@
+# 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.network.json import base
+
+
+class NetworksClient(base.BaseNetworkClient):
+
+ def create_network(self, **kwargs):
+ uri = '/networks'
+ post_data = {'network': kwargs}
+ return self.create_resource(uri, post_data)
+
+ def update_network(self, network_id, **kwargs):
+ uri = '/networks/%s' % network_id
+ post_data = {'network': kwargs}
+ return self.update_resource(uri, post_data)
+
+ def show_network(self, network_id, **fields):
+ uri = '/networks/%s' % network_id
+ return self.show_resource(uri, **fields)
+
+ def delete_network(self, network_id):
+ uri = '/networks/%s' % network_id
+ return self.delete_resource(uri)
+
+ def list_networks(self, **filters):
+ uri = '/networks'
+ return self.list_resources(uri, **filters)
diff --git a/tempest/services/network/json/ports_client.py b/tempest/services/network/json/ports_client.py
new file mode 100644
index 0000000..d52d65e
--- /dev/null
+++ b/tempest/services/network/json/ports_client.py
@@ -0,0 +1,38 @@
+# 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.network.json import base
+
+
+class PortsClient(base.BaseNetworkClient):
+
+ def create_port(self, **kwargs):
+ uri = '/ports'
+ post_data = {'port': kwargs}
+ return self.create_resource(uri, post_data)
+
+ def update_port(self, port_id, **kwargs):
+ uri = '/ports/%s' % port_id
+ post_data = {'port': kwargs}
+ return self.update_resource(uri, post_data)
+
+ def show_port(self, port_id, **fields):
+ uri = '/ports/%s' % port_id
+ return self.show_resource(uri, **fields)
+
+ def delete_port(self, port_id):
+ uri = '/ports/%s' % port_id
+ return self.delete_resource(uri)
+
+ def list_ports(self, **filters):
+ uri = '/ports'
+ return self.list_resources(uri, **filters)
diff --git a/tempest/services/network/json/subnets_client.py b/tempest/services/network/json/subnets_client.py
new file mode 100644
index 0000000..957b606
--- /dev/null
+++ b/tempest/services/network/json/subnets_client.py
@@ -0,0 +1,38 @@
+# 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.network.json import base
+
+
+class SubnetsClient(base.BaseNetworkClient):
+
+ def create_subnet(self, **kwargs):
+ uri = '/subnets'
+ post_data = {'subnet': kwargs}
+ return self.create_resource(uri, post_data)
+
+ def update_subnet(self, subnet_id, **kwargs):
+ uri = '/subnets/%s' % subnet_id
+ post_data = {'subnet': kwargs}
+ return self.update_resource(uri, post_data)
+
+ def show_subnet(self, subnet_id, **fields):
+ uri = '/subnets/%s' % subnet_id
+ return self.show_resource(uri, **fields)
+
+ def delete_subnet(self, subnet_id):
+ uri = '/subnets/%s' % subnet_id
+ return self.delete_resource(uri)
+
+ def list_subnets(self, **filters):
+ uri = '/subnets'
+ return self.list_resources(uri, **filters)
diff --git a/tempest/services/network/resources.py b/tempest/services/network/resources.py
index 4d45515..10911f7 100644
--- a/tempest/services/network/resources.py
+++ b/tempest/services/network/resources.py
@@ -19,10 +19,7 @@
class AttributeDict(dict):
-
- """
- Provide attribute access (dict.key) to dictionary values.
- """
+ """Provide attribute access (dict.key) to dictionary values."""
def __getattr__(self, name):
"""Allow attribute access for all keys in the dict."""
@@ -33,14 +30,17 @@
@six.add_metaclass(abc.ABCMeta)
class DeletableResource(AttributeDict):
+ """Support deletion of neutron resources (networks, subnets)
- """
- Support deletion of neutron resources (networks, subnets) via a
- delete() method, as is supported by keystone and nova resources.
+ via a delete() method, as is supported by keystone and nova resources.
"""
def __init__(self, *args, **kwargs):
self.client = kwargs.pop('client', None)
+ self.network_client = kwargs.pop('network_client', None)
+ self.networks_client = kwargs.pop('networks_client', None)
+ self.subnets_client = kwargs.pop('subnets_client', None)
+ self.ports_client = kwargs.pop('ports_client', None)
super(DeletableResource, self).__init__(*args, **kwargs)
def __str__(self):
@@ -72,7 +72,7 @@
class DeletableNetwork(DeletableResource):
def delete(self):
- self.client.delete_network(self.id)
+ self.networks_client.delete_network(self.id)
class DeletableSubnet(DeletableResource):
@@ -82,23 +82,23 @@
self._router_ids = set()
def update(self, *args, **kwargs):
- result = self.client.update_subnet(self.id,
- *args,
- **kwargs)
+ result = self.subnets_client.update_subnet(self.id,
+ *args,
+ **kwargs)
return super(DeletableSubnet, self).update(**result['subnet'])
def add_to_router(self, router_id):
self._router_ids.add(router_id)
- self.client.add_router_interface_with_subnet_id(router_id,
- subnet_id=self.id)
+ self.network_client.add_router_interface_with_subnet_id(
+ router_id, subnet_id=self.id)
def delete(self):
for router_id in self._router_ids.copy():
- self.client.remove_router_interface_with_subnet_id(
+ self.network_client.remove_router_interface_with_subnet_id(
router_id,
subnet_id=self.id)
self._router_ids.remove(router_id)
- self.client.delete_subnet(self.id)
+ self.subnets_client.delete_subnet(self.id)
class DeletableRouter(DeletableResource):
@@ -149,7 +149,7 @@
class DeletablePort(DeletableResource):
def delete(self):
- self.client.delete_port(self.id)
+ self.ports_client.delete_port(self.id)
class DeletableSecurityGroup(DeletableResource):
diff --git a/tempest/services/object_storage/account_client.py b/tempest/services/object_storage/account_client.py
index d89aa5d..2c7fe29 100644
--- a/tempest/services/object_storage/account_client.py
+++ b/tempest/services/object_storage/account_client.py
@@ -59,8 +59,8 @@
return resp, body
def list_account_metadata(self):
- """
- HEAD on the storage URL
+ """HEAD on the storage URL
+
Returns all account metadata headers
"""
resp, body = self.head('')
@@ -86,9 +86,7 @@
def delete_account_metadata(self, metadata,
metadata_prefix='X-Remove-Account-Meta-'):
- """
- Deletes an account metadata entry.
- """
+ """Deletes an account metadata entry."""
headers = {}
for item in metadata:
@@ -103,9 +101,7 @@
delete_metadata=None,
create_metadata_prefix='X-Account-Meta-',
delete_metadata_prefix='X-Remove-Account-Meta-'):
- """
- Creates and deletes an account metadata entry.
- """
+ """Creates and deletes an account metadata entry."""
headers = {}
for key in create_metadata:
headers[create_metadata_prefix + key] = create_metadata[key]
@@ -117,8 +113,8 @@
return resp, body
def list_account_containers(self, params=None):
- """
- GET on the (base) storage URL
+ """GET on the (base) storage URL
+
Given valid X-Auth-Token, returns a list of all containers for the
account.
diff --git a/tempest/services/object_storage/container_client.py b/tempest/services/object_storage/container_client.py
index e8ee20b..73c25db 100644
--- a/tempest/services/object_storage/container_client.py
+++ b/tempest/services/object_storage/container_client.py
@@ -29,9 +29,9 @@
remove_metadata=None,
metadata_prefix='X-Container-Meta-',
remove_metadata_prefix='X-Remove-Container-Meta-'):
- """
- Creates a container, with optional metadata passed in as a
- dictionary
+ """Creates a container
+
+ with optional metadata passed in as a dictionary
"""
url = str(container_name)
headers = {}
@@ -90,19 +90,17 @@
return resp, body
def list_container_metadata(self, container_name):
- """
- Retrieves container metadata headers
- """
+ """Retrieves container metadata headers"""
url = str(container_name)
resp, body = self.head(url)
self.expected_success(204, resp.status)
return resp, body
def list_all_container_objects(self, container, params=None):
- """
- Returns complete list of all objects in the container, even if
- item count is beyond 10,000 item listing limit.
- Does not require any parameters aside from container name.
+ """Returns complete list of all objects in the container
+
+ even if item count is beyond 10,000 item listing limit.
+ Does not require any parameters aside from container name.
"""
# TODO(dwalleck): Rewrite using json format to avoid newlines at end of
# obj names. Set limit to API limit - 1 (max returned items = 9999)
@@ -121,8 +119,7 @@
return objlist
def list_container_contents(self, container, params=None):
- """
- List the objects in a container, given the container name
+ """List the objects in a container, given the container name
Returns the container object listing as a plain text list, or as
xml or json if that option is specified via the 'format' argument.
diff --git a/tempest/services/object_storage/object_client.py b/tempest/services/object_storage/object_client.py
index 2265587..5890e33 100644
--- a/tempest/services/object_storage/object_client.py
+++ b/tempest/services/object_storage/object_client.py
@@ -149,9 +149,7 @@
return resp, body
def put_object_with_chunk(self, container, name, contents, chunk_size):
- """
- Put an object with Transfer-Encoding header
- """
+ """Put an object with Transfer-Encoding header"""
if self.base_url is None:
self._set_auth()
@@ -204,8 +202,8 @@
def put_object_connection(base_url, container, name, contents=None,
chunk_size=65536, headers=None, query_string=None):
- """
- Helper function to make connection to put object with httplib
+ """Helper function to make connection to put object with httplib
+
:param base_url: base_url of an object client
:param container: container name that the object is in
:param name: object name to put
diff --git a/tempest/services/telemetry/json/alarming_client.py b/tempest/services/telemetry/json/alarming_client.py
new file mode 100644
index 0000000..ce14211
--- /dev/null
+++ b/tempest/services/telemetry/json/alarming_client.py
@@ -0,0 +1,98 @@
+# Copyright 2014 OpenStack Foundation
+# 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 six.moves.urllib import parse as urllib
+
+from tempest.common import service_client
+
+
+class AlarmingClient(service_client.ServiceClient):
+
+ version = '2'
+ uri_prefix = "v2"
+
+ def deserialize(self, body):
+ return json.loads(body.replace("\n", ""))
+
+ def serialize(self, body):
+ return json.dumps(body)
+
+ def list_alarms(self, query=None):
+ uri = '%s/alarms' % self.uri_prefix
+ uri_dict = {}
+ if query:
+ uri_dict = {'q.field': query[0],
+ 'q.op': query[1],
+ 'q.value': query[2]}
+ if uri_dict:
+ uri += "?%s" % urllib.urlencode(uri_dict)
+ resp, body = self.get(uri)
+ self.expected_success(200, resp.status)
+ body = self.deserialize(body)
+ return service_client.ResponseBodyList(resp, body)
+
+ def show_alarm(self, alarm_id):
+ uri = '%s/alarms/%s' % (self.uri_prefix, alarm_id)
+ resp, body = self.get(uri)
+ self.expected_success(200, resp.status)
+ body = self.deserialize(body)
+ return service_client.ResponseBody(resp, body)
+
+ def show_alarm_history(self, alarm_id):
+ uri = "%s/alarms/%s/history" % (self.uri_prefix, alarm_id)
+ resp, body = self.get(uri)
+ self.expected_success(200, resp.status)
+ body = self.deserialize(body)
+ return service_client.ResponseBodyList(resp, body)
+
+ def delete_alarm(self, alarm_id):
+ uri = "%s/alarms/%s" % (self.uri_prefix, alarm_id)
+ resp, body = self.delete(uri)
+ self.expected_success(204, resp.status)
+ if body:
+ body = self.deserialize(body)
+ return service_client.ResponseBody(resp, body)
+
+ def create_alarm(self, **kwargs):
+ uri = "%s/alarms" % self.uri_prefix
+ body = self.serialize(kwargs)
+ resp, body = self.post(uri, body)
+ self.expected_success(201, resp.status)
+ body = self.deserialize(body)
+ return service_client.ResponseBody(resp, body)
+
+ def update_alarm(self, alarm_id, **kwargs):
+ uri = "%s/alarms/%s" % (self.uri_prefix, alarm_id)
+ body = self.serialize(kwargs)
+ resp, body = self.put(uri, body)
+ self.expected_success(200, resp.status)
+ body = self.deserialize(body)
+ return service_client.ResponseBody(resp, body)
+
+ def show_alarm_state(self, alarm_id):
+ uri = "%s/alarms/%s/state" % (self.uri_prefix, alarm_id)
+ resp, body = self.get(uri)
+ self.expected_success(200, resp.status)
+ body = self.deserialize(body)
+ return service_client.ResponseBodyData(resp, body)
+
+ def alarm_set_state(self, alarm_id, state):
+ uri = "%s/alarms/%s/state" % (self.uri_prefix, alarm_id)
+ body = self.serialize(state)
+ resp, body = self.put(uri, body)
+ self.expected_success(200, resp.status)
+ body = self.deserialize(body)
+ return service_client.ResponseBodyData(resp, body)
diff --git a/tempest/services/telemetry/json/telemetry_client.py b/tempest/services/telemetry/json/telemetry_client.py
index fc8951e..05530b1 100644
--- a/tempest/services/telemetry/json/telemetry_client.py
+++ b/tempest/services/telemetry/json/telemetry_client.py
@@ -72,10 +72,6 @@
uri = '%s/meters' % self.uri_prefix
return self._helper_list(uri, query)
- def list_alarms(self, query=None):
- uri = '%s/alarms' % self.uri_prefix
- return self._helper_list(uri, query)
-
def list_statistics(self, meter, period=None, query=None):
uri = "%s/meters/%s/statistics" % (self.uri_prefix, meter)
return self._helper_list(uri, query, period)
@@ -94,56 +90,3 @@
self.expected_success(200, resp.status)
body = self.deserialize(body)
return service_client.ResponseBody(resp, body)
-
- def show_alarm(self, alarm_id):
- uri = '%s/alarms/%s' % (self.uri_prefix, alarm_id)
- resp, body = self.get(uri)
- self.expected_success(200, resp.status)
- body = self.deserialize(body)
- return service_client.ResponseBody(resp, body)
-
- def delete_alarm(self, alarm_id):
- uri = "%s/alarms/%s" % (self.uri_prefix, alarm_id)
- resp, body = self.delete(uri)
- self.expected_success(204, resp.status)
- if body:
- body = self.deserialize(body)
- return service_client.ResponseBody(resp, body)
-
- def create_alarm(self, **kwargs):
- uri = "%s/alarms" % self.uri_prefix
- body = self.serialize(kwargs)
- resp, body = self.post(uri, body)
- self.expected_success(201, resp.status)
- body = self.deserialize(body)
- return service_client.ResponseBody(resp, body)
-
- def update_alarm(self, alarm_id, **kwargs):
- uri = "%s/alarms/%s" % (self.uri_prefix, alarm_id)
- body = self.serialize(kwargs)
- resp, body = self.put(uri, body)
- self.expected_success(200, resp.status)
- body = self.deserialize(body)
- return service_client.ResponseBody(resp, body)
-
- def show_alarm_state(self, alarm_id):
- uri = "%s/alarms/%s/state" % (self.uri_prefix, alarm_id)
- resp, body = self.get(uri)
- self.expected_success(200, resp.status)
- body = self.deserialize(body)
- return service_client.ResponseBodyData(resp, body)
-
- def alarm_set_state(self, alarm_id, state):
- uri = "%s/alarms/%s/state" % (self.uri_prefix, alarm_id)
- body = self.serialize(state)
- resp, body = self.put(uri, body)
- self.expected_success(200, resp.status)
- body = self.deserialize(body)
- return service_client.ResponseBodyData(resp, body)
-
- def show_alarm_history(self, alarm_id):
- uri = "%s/alarms/%s/history" % (self.uri_prefix, alarm_id)
- resp, body = self.get(uri)
- self.expected_success(200, resp.status)
- body = self.deserialize(body)
- return service_client.ResponseBodyList(resp, body)
diff --git a/tempest/services/volume/json/admin/volume_hosts_client.py b/tempest/services/volume/json/admin/volume_hosts_client.py
index ab9cd5a..939db59 100644
--- a/tempest/services/volume/json/admin/volume_hosts_client.py
+++ b/tempest/services/volume/json/admin/volume_hosts_client.py
@@ -20,9 +20,7 @@
class BaseVolumeHostsClient(service_client.ServiceClient):
- """
- Client class to send CRUD Volume Hosts API requests to a Cinder endpoint
- """
+ """Client class to send CRUD Volume Hosts API requests"""
def list_hosts(self, params=None):
"""Lists all hosts."""
@@ -38,6 +36,4 @@
class VolumeHostsClient(BaseVolumeHostsClient):
- """
- Client class to send CRUD Volume Host API V1 requests to a Cinder endpoint
- """
+ """Client class to send CRUD Volume Host API V1 requests"""
diff --git a/tempest/services/volume/json/admin/volume_quotas_client.py b/tempest/services/volume/json/admin/volume_quotas_client.py
index 207554d..f6d4a14 100644
--- a/tempest/services/volume/json/admin/volume_quotas_client.py
+++ b/tempest/services/volume/json/admin/volume_quotas_client.py
@@ -19,9 +19,7 @@
class BaseVolumeQuotasClient(service_client.ServiceClient):
- """
- Client class to send CRUD Volume Quotas API requests to a Cinder endpoint
- """
+ """Client class to send CRUD Volume Quotas API requests"""
TYPE = "json"
@@ -79,6 +77,4 @@
class VolumeQuotasClient(BaseVolumeQuotasClient):
- """
- Client class to send CRUD Volume Type API V1 requests to a Cinder endpoint
- """
+ """Client class to send CRUD Volume Type API V1 requests"""
diff --git a/tempest/services/volume/json/admin/volume_types_client.py b/tempest/services/volume/json/admin/volume_types_client.py
index cd61859..f2da8a5 100644
--- a/tempest/services/volume/json/admin/volume_types_client.py
+++ b/tempest/services/volume/json/admin/volume_types_client.py
@@ -21,9 +21,7 @@
class BaseVolumeTypesClient(service_client.ServiceClient):
- """
- Client class to send CRUD Volume Types API requests to a Cinder endpoint
- """
+ """Client class to send CRUD Volume Types API requests"""
def is_resource_deleted(self, resource):
# to use this method self.resource must be defined to respective value
@@ -69,8 +67,8 @@
return service_client.ResponseBody(resp, body)
def create_volume_type(self, name, **kwargs):
- """
- Creates a new Volume_type.
+ """Creates a new Volume_type.
+
name(Required): Name of volume_type.
Following optional keyword arguments are accepted:
extra_specs: A dictionary of values to be used as extra_specs.
@@ -113,8 +111,8 @@
return service_client.ResponseBody(resp, body)
def create_volume_type_extra_specs(self, vol_type_id, extra_spec):
- """
- Creates a new Volume_type extra spec.
+ """Creates a new Volume_type extra spec.
+
vol_type_id: Id of volume_type.
extra_specs: A dictionary of values to be used as extra_specs.
"""
@@ -134,8 +132,8 @@
def update_volume_type_extra_specs(self, vol_type_id, extra_spec_name,
extra_spec):
- """
- Update a volume_type extra spec.
+ """Update a volume_type extra spec.
+
vol_type_id: Id of volume_type.
extra_spec_name: Name of the extra spec to be updated.
extra_spec: A dictionary of with key as extra_spec_name and the
@@ -150,8 +148,8 @@
return service_client.ResponseBody(resp, body)
def show_encryption_type(self, vol_type_id):
- """
- Get the volume encryption type for the specified volume type.
+ """Get the volume encryption type for the specified volume type.
+
vol_type_id: Id of volume_type.
"""
url = "/types/%s/encryption" % str(vol_type_id)
@@ -161,8 +159,7 @@
return service_client.ResponseBody(resp, body)
def create_encryption_type(self, vol_type_id, **kwargs):
- """
- Create a new encryption type for the specified volume type.
+ """Create a new encryption type for the specified volume type.
vol_type_id: Id of volume_type.
provider: Class providing encryption support.
diff --git a/tempest/services/volume/json/availability_zone_client.py b/tempest/services/volume/json/availability_zone_client.py
index 4d24ede..36f95d6 100644
--- a/tempest/services/volume/json/availability_zone_client.py
+++ b/tempest/services/volume/json/availability_zone_client.py
@@ -28,6 +28,4 @@
class VolumeAvailabilityZoneClient(BaseVolumeAvailabilityZoneClient):
- """
- Volume V1 availability zone client.
- """
+ """Volume V1 availability zone client."""
diff --git a/tempest/services/volume/json/backups_client.py b/tempest/services/volume/json/backups_client.py
index 6827c93..3045992 100644
--- a/tempest/services/volume/json/backups_client.py
+++ b/tempest/services/volume/json/backups_client.py
@@ -24,9 +24,7 @@
class BaseBackupsClient(service_client.ServiceClient):
- """
- Client class to send CRUD Volume backup API requests to a Cinder endpoint
- """
+ """Client class to send CRUD Volume backup API requests"""
def create_backup(self, volume_id, container=None, name=None,
description=None):
diff --git a/tempest/services/volume/json/extensions_client.py b/tempest/services/volume/json/extensions_client.py
index 5744d4a..d7d3197 100644
--- a/tempest/services/volume/json/extensions_client.py
+++ b/tempest/services/volume/json/extensions_client.py
@@ -29,6 +29,4 @@
class ExtensionsClient(BaseExtensionsClient):
- """
- Volume V1 extensions client.
- """
+ """Volume V1 extensions client."""
diff --git a/tempest/services/volume/json/snapshots_client.py b/tempest/services/volume/json/snapshots_client.py
index 3fcf18c..77c9dd1 100644
--- a/tempest/services/volume/json/snapshots_client.py
+++ b/tempest/services/volume/json/snapshots_client.py
@@ -51,8 +51,8 @@
return service_client.ResponseBody(resp, body)
def create_snapshot(self, volume_id, **kwargs):
- """
- Creates a new snapshot.
+ """Creates a new snapshot.
+
volume_id(Required): id of the volume.
force: Create a snapshot even if the volume attached (Default=False)
display_name: Optional snapshot Name.
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index 9304f63..c2a76f0 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -23,9 +23,7 @@
class BaseVolumesClient(service_client.ServiceClient):
- """
- Base client class to send CRUD Volume API requests to a Cinder endpoint
- """
+ """Base client class to send CRUD Volume API requests"""
create_resp = 200
@@ -74,8 +72,8 @@
return service_client.ResponseBody(resp, body)
def create_volume(self, size=None, **kwargs):
- """
- Creates a new Volume.
+ """Creates a new Volume.
+
size: Size of volume in GB.
Following optional keyword arguments are accepted:
display_name: Optional Volume Name(only for V1).
@@ -339,6 +337,4 @@
class VolumesClient(BaseVolumesClient):
- """
- Client class to send CRUD Volume V1 API requests to a Cinder endpoint
- """
+ """Client class to send CRUD Volume V1 API requests"""
diff --git a/tempest/services/volume/v2/json/admin/volume_hosts_client.py b/tempest/services/volume/v2/json/admin/volume_hosts_client.py
index f0cc03f..649c9ec 100644
--- a/tempest/services/volume/v2/json/admin/volume_hosts_client.py
+++ b/tempest/services/volume/v2/json/admin/volume_hosts_client.py
@@ -18,7 +18,5 @@
class VolumeHostsV2Client(volume_hosts_client.BaseVolumeHostsClient):
- """
- Client class to send CRUD Volume V2 API requests to a Cinder endpoint
- """
+ """Client class to send CRUD Volume V2 API requests"""
api_version = "v2"
diff --git a/tempest/services/volume/v2/json/admin/volume_quotas_client.py b/tempest/services/volume/v2/json/admin/volume_quotas_client.py
index 635b6e1..80fffc7 100644
--- a/tempest/services/volume/v2/json/admin/volume_quotas_client.py
+++ b/tempest/services/volume/v2/json/admin/volume_quotas_client.py
@@ -17,7 +17,5 @@
class VolumeQuotasV2Client(volume_quotas_client.BaseVolumeQuotasClient):
- """
- Client class to send CRUD Volume V2 API requests to a Cinder endpoint
- """
+ """Client class to send CRUD Volume V2 API requests"""
api_version = "v2"
diff --git a/tempest/services/volume/v2/json/admin/volume_services_client.py b/tempest/services/volume/v2/json/admin/volume_services_client.py
index d0efc38..88eb82f 100644
--- a/tempest/services/volume/v2/json/admin/volume_services_client.py
+++ b/tempest/services/volume/v2/json/admin/volume_services_client.py
@@ -17,7 +17,5 @@
class VolumesServicesV2Client(vs_cli.BaseVolumesServicesClient):
- """
- Client class to send CRUD Volume V2 API requests to a Cinder endpoint
- """
+ """Client class to send CRUD Volume V2 API requests"""
api_version = "v2"
diff --git a/tempest/services/volume/v2/json/admin/volume_types_client.py b/tempest/services/volume/v2/json/admin/volume_types_client.py
index 1b9ff51..78fe8e5 100644
--- a/tempest/services/volume/v2/json/admin/volume_types_client.py
+++ b/tempest/services/volume/v2/json/admin/volume_types_client.py
@@ -18,7 +18,5 @@
class VolumeTypesV2Client(volume_types_client.BaseVolumeTypesClient):
- """
- Client class to send CRUD Volume V2 API requests to a Cinder endpoint
- """
+ """Client class to send CRUD Volume V2 API requests"""
api_version = "v2"
diff --git a/tempest/services/volume/v2/json/backups_client.py b/tempest/services/volume/v2/json/backups_client.py
index 1ce11ce..8e87505 100644
--- a/tempest/services/volume/v2/json/backups_client.py
+++ b/tempest/services/volume/v2/json/backups_client.py
@@ -17,7 +17,5 @@
class BackupsClientV2(backups_client.BaseBackupsClient):
- """
- Client class to send CRUD Volume V2 API requests to a Cinder endpoint
- """
+ """Client class to send CRUD Volume V2 API requests"""
api_version = "v2"
diff --git a/tempest/services/volume/v2/json/volumes_client.py b/tempest/services/volume/v2/json/volumes_client.py
index a6d081c..a56a7be 100644
--- a/tempest/services/volume/v2/json/volumes_client.py
+++ b/tempest/services/volume/v2/json/volumes_client.py
@@ -17,8 +17,6 @@
class VolumesV2Client(volumes_client.BaseVolumesClient):
- """
- Client class to send CRUD Volume V2 API requests to a Cinder endpoint
- """
+ """Client class to send CRUD Volume V2 API requests"""
api_version = "v2"
create_resp = 202
diff --git a/tempest/stress/actions/ssh_floating.py b/tempest/stress/actions/ssh_floating.py
index d912b25..6bac570 100644
--- a/tempest/stress/actions/ssh_floating.py
+++ b/tempest/stress/actions/ssh_floating.py
@@ -107,12 +107,12 @@
sec_grp_cli.delete_security_group(self.sec_grp['id'])
def _create_floating_ip(self):
- floating_cli = self.manager.floating_ips_client
+ floating_cli = self.manager.compute_floating_ips_client
self.floating = (floating_cli.create_floating_ip(self.floating_pool)
['floating_ip'])
def _destroy_floating_ip(self):
- cli = self.manager.floating_ips_client
+ cli = self.manager.compute_floating_ips_client
cli.delete_floating_ip(self.floating['id'])
cli.wait_for_resource_deletion(self.floating['id'])
self.logger.info("Deleted Floating IP %s", str(self.floating['ip']))
@@ -146,7 +146,7 @@
self._create_vm()
def wait_disassociate(self):
- cli = self.manager.floating_ips_client
+ cli = self.manager.compute_floating_ips_client
def func():
floating = (cli.show_floating_ip(self.floating['id'])
@@ -158,7 +158,7 @@
raise RuntimeError("IP disassociate timeout!")
def run_core(self):
- cli = self.manager.floating_ips_client
+ cli = self.manager.compute_floating_ips_client
cli.associate_floating_ip_to_server(self.floating['ip'],
self.server_id)
for method in self.verify:
diff --git a/tempest/stress/actions/unit_test.py b/tempest/stress/actions/unit_test.py
index c376693..3b27885 100644
--- a/tempest/stress/actions/unit_test.py
+++ b/tempest/stress/actions/unit_test.py
@@ -35,6 +35,7 @@
class UnitTest(stressaction.StressAction):
"""This is a special action for running existing unittests as stress test.
+
You need to pass ``test_method`` and ``class_setup_per``
using ``kwargs`` in the JSON descriptor;
``test_method`` should be the fully qualified name of a unittest,
diff --git a/tempest/stress/actions/volume_attach_verify.py b/tempest/stress/actions/volume_attach_verify.py
index 95841a9..fa0bb8b 100644
--- a/tempest/stress/actions/volume_attach_verify.py
+++ b/tempest/stress/actions/volume_attach_verify.py
@@ -70,12 +70,12 @@
sec_grp_cli.delete_security_group(self.sec_grp['id'])
def _create_floating_ip(self):
- floating_cli = self.manager.floating_ips_client
+ floating_cli = self.manager.compute_floating_ips_client
self.floating = (floating_cli.create_floating_ip(self.floating_pool)
['floating_ip'])
def _destroy_floating_ip(self):
- cli = self.manager.floating_ips_client
+ cli = self.manager.compute_floating_ips_client
cli.delete_floating_ip(self.floating['id'])
cli.wait_for_resource_deletion(self.floating['id'])
self.logger.info("Deleted Floating IP %s", str(self.floating['ip']))
@@ -98,7 +98,7 @@
self.logger.info("deleted volume: %s" % self.volume['id'])
def _wait_disassociate(self):
- cli = self.manager.floating_ips_client
+ cli = self.manager.compute_floating_ips_client
def func():
floating = (cli.show_floating_ip(self.floating['id'])
@@ -111,7 +111,7 @@
def new_server_ops(self):
self._create_vm()
- cli = self.manager.floating_ips_client
+ cli = self.manager.compute_floating_ips_client
cli.associate_floating_ip_to_server(self.floating['ip'],
self.server_id)
if self.ssh_test_before_attach and self.enable_ssh_verify:
@@ -121,6 +121,7 @@
def setUp(self, **kwargs):
"""Note able configuration combinations:
+
Closest options to the test_stamp_pattern:
new_server = True
new_volume = True
@@ -218,7 +219,7 @@
self._destroy_vm()
def tearDown(self):
- cli = self.manager.floating_ips_client
+ cli = self.manager.compute_floating_ips_client
cli.disassociate_floating_ip_from_server(self.floating['ip'],
self.server_id)
self._wait_disassociate()
diff --git a/tempest/stress/cleanup.py b/tempest/stress/cleanup.py
index 9456590..993359d 100644
--- a/tempest/stress/cleanup.py
+++ b/tempest/stress/cleanup.py
@@ -16,14 +16,14 @@
from oslo_log import log as logging
-from tempest import clients
+from tempest.common import credentials_factory as credentials
from tempest.common import waiters
LOG = logging.getLogger(__name__)
def cleanup():
- admin_manager = clients.AdminManager()
+ admin_manager = credentials.AdminManager()
body = admin_manager.servers_client.list_servers(all_tenants=True)
LOG.info("Cleanup::remove %s servers" % len(body['servers']))
@@ -59,16 +59,17 @@
except Exception:
pass
- floating_ips = (admin_manager.floating_ips_client.list_floating_ips()
+ admin_floating_ips_client = admin_manager.compute_floating_ips_client
+ floating_ips = (admin_floating_ips_client.list_floating_ips()
['floating_ips'])
LOG.info("Cleanup::remove %s floating ips" % len(floating_ips))
for f in floating_ips:
try:
- admin_manager.floating_ips_client.delete_floating_ip(f['id'])
+ admin_floating_ips_client.delete_floating_ip(f['id'])
except Exception:
pass
- users = admin_manager.identity_client.get_users()
+ users = admin_manager.identity_client.list_users()['users']
LOG.info("Cleanup::remove %s users" % len(users))
for user in users:
if user['name'].startswith("stress_user"):
diff --git a/tempest/stress/driver.py b/tempest/stress/driver.py
index 7634d2c..8359efd 100644
--- a/tempest/stress/driver.py
+++ b/tempest/stress/driver.py
@@ -26,6 +26,7 @@
from tempest import clients
from tempest.common import cred_client
+from tempest.common import credentials_factory as credentials
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
@@ -48,9 +49,9 @@
def _get_compute_nodes(controller, ssh_user, ssh_key=None):
- """
- Returns a list of active compute nodes. List is generated by running
- nova-manage on the controller.
+ """Returns a list of active compute nodes.
+
+ List is generated by running nova-manage on the controller.
"""
nodes = []
cmd = "nova-manage service list | grep ^nova-compute"
@@ -68,9 +69,7 @@
def _has_error_in_logs(logfiles, nodes, ssh_user, ssh_key=None,
stop_on_error=False):
- """
- Detect errors in the nova log files on the controller and compute nodes.
- """
+ """Detect errors in nova log files on the controller and compute nodes."""
grep = 'egrep "ERROR|TRACE" %s' % logfiles
ret = False
for node in nodes:
@@ -84,9 +83,7 @@
def sigchld_handler(signalnum, frame):
- """
- Signal handler (only active if stop_on_error is True).
- """
+ """Signal handler (only active if stop_on_error is True)."""
for process in processes:
if (not process['process'].is_alive() and
process['process'].exitcode != 0):
@@ -96,9 +93,7 @@
def terminate_all_processes(check_interval=20):
- """
- Goes through the process list and terminates all child processes.
- """
+ """Goes through the process list and terminates all child processes."""
LOG.info("Stopping all processes.")
for process in processes:
if process['process'].is_alive():
@@ -119,10 +114,8 @@
def stress_openstack(tests, duration, max_runs=None, stop_on_error=False):
- """
- Workload driver. Executes an action function against a nova-cluster.
- """
- admin_manager = clients.AdminManager()
+ """Workload driver. Executes an action function against a nova-cluster."""
+ admin_manager = credentials.AdminManager()
ssh_user = CONF.stress.target_ssh_user
ssh_key = CONF.stress.target_private_key_path
@@ -145,7 +138,7 @@
if test.get('use_admin', False):
manager = admin_manager
else:
- manager = clients.Manager()
+ manager = credentials.ConfiguredUserManager()
for p_number in moves.xrange(test.get('threads', default_thread_num)):
if test.get('use_isolated_tenants', False):
username = data_utils.rand_name("stress_user")
diff --git a/tempest/stress/stressaction.py b/tempest/stress/stressaction.py
index a3d0d17..c8bd652 100644
--- a/tempest/stress/stressaction.py
+++ b/tempest/stress/stressaction.py
@@ -40,32 +40,35 @@
@property
def action(self):
- """This methods returns the action. Overload this if you
- create a stress test wrapper.
+ """This methods returns the action.
+
+ Overload this if you create a stress test wrapper.
"""
return self.__class__.__name__
def setUp(self, **kwargs):
- """This method is called before the run method
- to help the test initialize any structures.
- kwargs contains arguments passed in from the
- configuration json file.
+ """Initialize test structures/resources
+
+ This method is called before "run" method to help the test
+ initialize any structures. kwargs contains arguments passed
+ in from the configuration json file.
setUp doesn't count against the time duration.
"""
self.logger.debug("setUp")
def tearDown(self):
- """This method is called to do any cleanup
- after the test is complete.
+ """Cleanup test structures/resources
+
+ This method is called to do any cleanup after the test is complete.
"""
self.logger.debug("tearDown")
def execute(self, shared_statistic):
- """This is the main execution entry point called
- by the driver. We register a signal handler to
- allow us to tearDown gracefully, and then exit.
- We also keep track of how many runs we do.
+ """This is the main execution entry point called by the driver.
+
+ We register a signal handler to allow us to tearDown gracefully,
+ and then exit. We also keep track of how many runs we do.
"""
signal.signal(signal.SIGHUP, self._shutdown_handler)
signal.signal(signal.SIGTERM, self._shutdown_handler)
diff --git a/tempest/test.py b/tempest/test.py
index 142488c..a9c8ba7 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -32,7 +32,7 @@
from tempest import clients
from tempest.common import cred_client
-from tempest.common import credentials
+from tempest.common import credentials_factory as credentials
from tempest.common import fixed_network
import tempest.common.generator.valid_generator as valid
import tempest.common.validation_resources as vresources
@@ -211,6 +211,7 @@
class BaseTestCase(testtools.testcase.WithAttributes,
testtools.TestCase):
"""The test base class defines Tempest framework for class level fixtures.
+
`setUpClass` and `tearDownClass` are defined here and cannot be overwritten
by subclasses (enforced via hacking rule T105).
@@ -224,7 +225,7 @@
Tear-down is also split in a series of steps (teardown stages), which are
stacked for execution only if the corresponding setup stage had been
reached during the setup phase. Tear-down stages are:
- - clear_isolated_creds (defined in the base test class)
+ - clear_credentials (defined in the base test class)
- resource_cleanup
"""
@@ -258,7 +259,7 @@
cls.skip_checks()
try:
# Allocation of all required credentials and client managers
- cls.teardowns.append(('credentials', cls.clear_isolated_creds))
+ cls.teardowns.append(('credentials', cls.clear_credentials))
cls.setup_credentials()
# Shortcuts to clients
cls.setup_clients()
@@ -315,18 +316,23 @@
@classmethod
def skip_checks(cls):
- """Class level skip checks. Subclasses verify in here all
- conditions that might prevent the execution of the entire test class.
+ """Class level skip checks.
+
+ Subclasses verify in here all conditions that might prevent the
+ execution of the entire test class.
Checks implemented here may not make use API calls, and should rely on
configuration alone.
In general skip checks that require an API call are discouraged.
If one is really needed it may be implemented either in the
resource_setup or at test level.
"""
- if 'admin' in cls.credentials and not credentials.is_admin_available():
+ identity_version = cls.get_identity_version()
+ if 'admin' in cls.credentials and not credentials.is_admin_available(
+ identity_version=identity_version):
msg = "Missing Identity Admin API credentials in configuration."
raise cls.skipException(msg)
- if 'alt' in cls.credentials and not credentials.is_alt_available():
+ if 'alt' in cls.credentials and not credentials.is_alt_available(
+ identity_version=identity_version):
msg = "Missing a 2nd set of API credentials in configuration."
raise cls.skipException(msg)
if hasattr(cls, 'identity_version'):
@@ -340,6 +346,7 @@
@classmethod
def setup_credentials(cls):
"""Allocate credentials and the client managers from them.
+
A test class that requires network resources must override
setup_credentials and defined the required resources before super
is invoked.
@@ -377,8 +384,7 @@
@classmethod
def resource_setup(cls):
- """Class level resource setup for test cases.
- """
+ """Class level resource setup for test cases."""
if hasattr(cls, "os"):
cls.validation_resources = vresources.create_validation_resources(
cls.os, cls.validation_resources)
@@ -389,6 +395,7 @@
@classmethod
def resource_cleanup(cls):
"""Class level resource cleanup for test cases.
+
Resource cleanup must be able to handle the case of partially setup
resources, in case a failure during `resource_setup` should happen.
"""
@@ -454,6 +461,12 @@
return cred_client.get_creds_client(client, domain)
@classmethod
+ def get_identity_version(cls):
+ """Returns the identity version used by the test class"""
+ identity_version = getattr(cls, 'identity_version', None)
+ return identity_version or CONF.identity.auth_version
+
+ @classmethod
def _get_credentials_provider(cls):
"""Returns a credentials provider
@@ -464,13 +477,11 @@
not cls._creds_provider.name == cls.__name__):
force_tenant_isolation = getattr(cls, 'force_tenant_isolation',
False)
- identity_version = getattr(cls, 'identity_version', None)
- identity_version = identity_version or CONF.identity.auth_version
- cls._creds_provider = credentials.get_isolated_credentials(
+ cls._creds_provider = credentials.get_credentials_provider(
name=cls.__name__, network_resources=cls.network_resources,
force_tenant_isolation=force_tenant_isolation,
- identity_version=identity_version)
+ identity_version=cls.get_identity_version())
return cls._creds_provider
@classmethod
@@ -515,18 +526,17 @@
return clients.Manager(credentials=creds, service=cls._service)
@classmethod
- def clear_isolated_creds(cls):
- """
- Clears isolated creds if set
- """
+ def clear_credentials(cls):
+ """Clears creds if set"""
if hasattr(cls, '_creds_provider'):
- cls._creds_provider.clear_isolated_creds()
+ cls._creds_provider.clear_creds()
@classmethod
def set_validation_resources(cls, keypair=None, floating_ip=None,
security_group=None,
security_group_rules=None):
"""Specify which ssh server validation resources should be created.
+
Each of the argument must be set to either None, True or False, with
None - use default from config (security groups and security group
rules get created when set to None)
@@ -589,7 +599,7 @@
:return: network dict including 'id' and 'name'
"""
- # Make sure isolated_creds exists and get a network client
+ # Make sure cred_provider exists and get a network client
networks_client = cls.get_client_manager().compute_networks_client
cred_provider = cls._get_credentials_provider()
# In case of nova network, isolated tenants are not able to list the
@@ -597,12 +607,13 @@
# for their servers, so using an admin network client to validate
# the network name
if (not CONF.service_available.neutron and
- credentials.is_admin_available()):
+ credentials.is_admin_available(
+ identity_version=cls.get_identity_version())):
admin_creds = cred_provider.get_admin_creds()
admin_manager = clients.Manager(admin_creds)
networks_client = admin_manager.compute_networks_client
- return fixed_network.get_tenant_network(cred_provider,
- networks_client)
+ return fixed_network.get_tenant_network(
+ cred_provider, networks_client, CONF.compute.fixed_network_name)
def assertEmpty(self, list, msg=None):
self.assertTrue(len(list) == 0, msg)
@@ -623,10 +634,11 @@
@staticmethod
def load_tests(*args):
- """
- Wrapper for testscenarios to set the mandatory scenarios variable
- only in case a real test loader is in place. Will be automatically
- called in case the variable "load_tests" is set.
+ """Wrapper for testscenarios
+
+ To set the mandatory scenarios variable only in case a real test
+ loader is in place. Will be automatically called in case the variable
+ "load_tests" is set.
"""
if getattr(args[0], 'suiteClass', None) is not None:
loader, standard_tests, pattern = args
@@ -641,8 +653,7 @@
@staticmethod
def generate_scenario(description):
- """
- Generates the test scenario list for a given description.
+ """Generates the test scenario list for a given description.
:param description: A file or dictionary with the following entries:
name (required) name for the api
@@ -686,7 +697,8 @@
return scenario_list
def execute(self, description):
- """
+ """Execute a http call
+
Execute a http call on an api that are expected to
result in client errors. First it uses invalid resources that are part
of the url, and then invalid data for queries and http request bodies.
@@ -747,7 +759,8 @@
"mechanism")
if "admin_client" in description and description["admin_client"]:
- if not credentials.is_admin_available():
+ if not credentials.is_admin_available(
+ identity_version=self.get_identity_version()):
msg = ("Missing Identity Admin API credentials in"
"configuration.")
raise self.skipException(msg)
@@ -779,7 +792,8 @@
@classmethod
def set_resource(cls, name, resource):
- """
+ """Register a resoruce for a test
+
This function can be used in setUpClass context to register a resoruce
for a test.
@@ -790,10 +804,10 @@
cls._resources[name] = resource
def get_resource(self, name):
- """
- Return a valid uuid for a type of resource. If a real resource is
- needed as part of a url then this method should return one. Otherwise
- it can return None.
+ """Return a valid uuid for a type of resource.
+
+ If a real resource is needed as part of a url then this method should
+ return one. Otherwise it can return None.
:param name: The name of the kind of resource such as "flavor", "role",
etc.
@@ -810,9 +824,7 @@
def SimpleNegativeAutoTest(klass):
- """
- This decorator registers a test function on basis of the class name.
- """
+ """This decorator registers a test function on basis of the class name."""
@attr(type=['negative'])
def generic_test(self):
if hasattr(self, '_schema'):
@@ -829,10 +841,9 @@
def call_until_true(func, duration, sleep_for):
- """
- Call the given function until it returns True (and return True) or
- until the specified duration (in seconds) elapses (and return
- False).
+ """Call the given function until it returns True (and return True)
+
+ or until the specified duration (in seconds) elapses (and return False).
:param func: A zero argument callable that returns True on success.
:param duration: The number of seconds for which to attempt a
diff --git a/tempest/test_discover/plugins.py b/tempest/test_discover/plugins.py
index 640b004..108b50d 100644
--- a/tempest/test_discover/plugins.py
+++ b/tempest/test_discover/plugins.py
@@ -25,14 +25,14 @@
@six.add_metaclass(abc.ABCMeta)
class TempestPlugin(object):
- """A TempestPlugin class provides the basic hooks for an external
- plugin to provide tempest the necessary information to run the plugin.
+ """Provide basic hooks for an external plugin
+
+ To provide tempest the necessary information to run the plugin.
"""
@abc.abstractmethod
def load_tests(self):
- """Method to return the information necessary to load the tests in the
- plugin.
+ """Return the information necessary to load the tests in the plugin.
:return: a tuple with the first value being the test_dir and the second
being the top_level
@@ -42,9 +42,10 @@
@abc.abstractmethod
def register_opts(self, conf):
- """Method to add additional configuration options to tempest. This
- method will be run for the plugin during the register_opts() function
- in tempest.config
+ """Add additional configuration options to tempest.
+
+ This method will be run for the plugin during the register_opts()
+ function in tempest.config
:param ConfigOpts conf: The conf object that can be used to register
additional options on.
@@ -53,7 +54,7 @@
@abc.abstractmethod
def get_opt_lists(self):
- """Method to get a list of options for sample config generation
+ """Get a list of options for sample config generation
:return option_list: A list of tuples with the group name and options
in that group.
@@ -88,7 +89,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/base.py b/tempest/tests/base.py
index 27eb2c4..fe9268e 100644
--- a/tempest/tests/base.py
+++ b/tempest/tests/base.py
@@ -26,8 +26,7 @@
self.stubs = mox_fixture.stubs
def patch(self, target, **kwargs):
- """
- Returns a started `mock.patch` object for the supplied target.
+ """Returns a started `mock.patch` object for the supplied target.
The caller may then call the returned patcher to create a mock object.
diff --git a/tempest/tests/cmd/test_javelin.py b/tempest/tests/cmd/test_javelin.py
index 4a8f729..d328d56 100644
--- a/tempest/tests/cmd/test_javelin.py
+++ b/tempest/tests/cmd/test_javelin.py
@@ -106,10 +106,12 @@
self.assertFalse(mocked_function.called)
def test_create_users(self):
- self.fake_client.identity.get_tenant_by_name.return_value = \
- self.fake_object['tenant']
- self.fake_client.identity.get_user_by_username.side_effect = \
- lib_exc.NotFound("user is not found")
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.identity.get_tenant_by_name',
+ return_value=self.fake_object['tenant']))
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.identity.get_user_by_username',
+ side_effect=lib_exc.NotFound("user is not found")))
self.useFixture(mockpatch.PatchObject(javelin, "keystone_admin",
return_value=self.fake_client))
@@ -125,8 +127,9 @@
enabled=True)
def test_create_user_missing_tenant(self):
- self.fake_client.identity.get_tenant_by_name.side_effect = \
- lib_exc.NotFound("tenant is not found")
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.identity.get_tenant_by_name',
+ side_effect=lib_exc.NotFound("tenant is not found")))
self.useFixture(mockpatch.PatchObject(javelin, "keystone_admin",
return_value=self.fake_client))
@@ -289,8 +292,9 @@
fake_tenant = self.fake_object['tenant']
fake_auth = self.fake_client
- fake_auth.identity.get_tenant_by_name.return_value = fake_tenant
-
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.identity.get_tenant_by_name',
+ return_value=fake_tenant))
self.useFixture(mockpatch.PatchObject(javelin, "keystone_admin",
return_value=fake_auth))
javelin.destroy_tenants([fake_tenant])
@@ -304,9 +308,13 @@
fake_tenant = self.fake_object['tenant']
fake_auth = self.fake_client
- fake_auth.identity.get_tenant_by_name.return_value = fake_tenant
- fake_auth.identity.get_user_by_username.return_value = fake_user
+ fake_auth.identity.list_tenants.return_value = \
+ {'tenants': [fake_tenant]}
+ fake_auth.identity.list_users.return_value = {'users': [fake_user]}
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.identity.get_user_by_username',
+ return_value=fake_user))
self.useFixture(mockpatch.PatchObject(javelin, "keystone_admin",
return_value=fake_auth))
@@ -380,7 +388,7 @@
javelin.destroy_subnets([self.fake_object])
- mocked_function = self.fake_client.networks.delete_subnet
+ mocked_function = self.fake_client.subnets.delete_subnet
mocked_function.assert_called_once_with(fake_subnet_id)
def test_destroy_routers(self):
diff --git a/tempest/tests/cmd/test_tempest_init.py b/tempest/tests/cmd/test_tempest_init.py
index 6b5af7e..1048a52 100644
--- a/tempest/tests/cmd/test_tempest_init.py
+++ b/tempest/tests/cmd/test_tempest_init.py
@@ -13,6 +13,7 @@
# under the License.
import os
+import shutil
import fixtures
@@ -39,9 +40,39 @@
self.addCleanup(conf_file.close)
self.assertEqual(conf_file.read(), testr_conf_file)
+ def test_generate_sample_config(self):
+ local_dir = self.useFixture(fixtures.TempDir())
+ etc_dir_path = os.path.join(local_dir.path, 'etc/')
+ os.mkdir(etc_dir_path)
+ tmp_dir = self.useFixture(fixtures.TempDir())
+ config_dir = os.path.join(tmp_dir.path, 'config/')
+ shutil.copytree('etc/', config_dir)
+ init_cmd = init.TempestInit(None, None)
+ local_sample_conf_file = os.path.join(etc_dir_path,
+ 'tempest.conf.sample')
+ # Verify no sample config file exist
+ self.assertFalse(os.path.isfile(local_sample_conf_file))
+ init_cmd.generate_sample_config(local_dir.path, config_dir)
+
+ # Verify sample config file exist with some content
+ self.assertTrue(os.path.isfile(local_sample_conf_file))
+ self.assertGreater(os.path.getsize(local_sample_conf_file), 0)
+
+ def test_create_working_dir_with_existing_local_dir_non_empty(self):
+ fake_local_dir = self.useFixture(fixtures.TempDir())
+ fake_local_conf_dir = self.useFixture(fixtures.TempDir())
+ open("%s/foo" % fake_local_dir.path, 'w').close()
+
+ _init = init.TempestInit(None, None)
+ self.assertRaises(OSError,
+ _init.create_working_dir,
+ fake_local_dir.path,
+ fake_local_conf_dir.path)
+
def test_create_working_dir(self):
fake_local_dir = self.useFixture(fixtures.TempDir())
fake_local_conf_dir = self.useFixture(fixtures.TempDir())
+ os.rmdir(fake_local_dir.path)
# Create a fake conf file
fake_file = fake_local_conf_dir.join('conf_file.conf')
open(fake_file, 'w').close()
diff --git a/tempest/tests/cmd/test_verify_tempest_config.py b/tempest/tests/cmd/test_verify_tempest_config.py
index 2de5802..a5dea54 100644
--- a/tempest/tests/cmd/test_verify_tempest_config.py
+++ b/tempest/tests/cmd/test_verify_tempest_config.py
@@ -113,7 +113,7 @@
'print_and_or_update') as print_mock:
verify_tempest_config.verify_keystone_api_versions(fake_os, True)
print_mock.assert_called_once_with('api_v3',
- 'identity_feature_enabled',
+ 'identity-feature-enabled',
False, True)
def test_verify_keystone_api_versions_no_v2(self):
@@ -129,7 +129,7 @@
'print_and_or_update') as print_mock:
verify_tempest_config.verify_keystone_api_versions(fake_os, True)
print_mock.assert_called_once_with('api_v2',
- 'identity_feature_enabled',
+ 'identity-feature-enabled',
False, True)
def test_verify_cinder_api_versions_no_v2(self):
@@ -144,7 +144,7 @@
with mock.patch.object(verify_tempest_config,
'print_and_or_update') as print_mock:
verify_tempest_config.verify_cinder_api_versions(fake_os, True)
- print_mock.assert_called_once_with('api_v2', 'volume_feature_enabled',
+ print_mock.assert_called_once_with('api_v2', 'volume-feature-enabled',
False, True)
def test_verify_cinder_api_versions_no_v1(self):
@@ -159,7 +159,7 @@
with mock.patch.object(verify_tempest_config,
'print_and_or_update') as print_mock:
verify_tempest_config.verify_cinder_api_versions(fake_os, True)
- print_mock.assert_called_once_with('api_v1', 'volume_feature_enabled',
+ print_mock.assert_called_once_with('api_v1', 'volume-feature-enabled',
False, True)
def test_verify_glance_version_no_v2_with_v1_1(self):
@@ -170,7 +170,7 @@
with mock.patch.object(verify_tempest_config,
'print_and_or_update') as print_mock:
verify_tempest_config.verify_glance_api_versions(fake_os, True)
- print_mock.assert_called_once_with('api_v2', 'image_feature_enabled',
+ print_mock.assert_called_once_with('api_v2', 'image-feature-enabled',
False, True)
def test_verify_glance_version_no_v2_with_v1_0(self):
@@ -181,7 +181,7 @@
with mock.patch.object(verify_tempest_config,
'print_and_or_update') as print_mock:
verify_tempest_config.verify_glance_api_versions(fake_os, True)
- print_mock.assert_called_once_with('api_v2', 'image_feature_enabled',
+ print_mock.assert_called_once_with('api_v2', 'image-feature-enabled',
False, True)
def test_verify_glance_version_no_v1(self):
@@ -192,7 +192,7 @@
with mock.patch.object(verify_tempest_config,
'print_and_or_update') as print_mock:
verify_tempest_config.verify_glance_api_versions(fake_os, True)
- print_mock.assert_called_once_with('api_v1', 'image_feature_enabled',
+ print_mock.assert_called_once_with('api_v1', 'image-feature-enabled',
False, True)
def test_verify_extensions_neutron(self):
diff --git a/tempest/tests/common/test_admin_available.py b/tempest/tests/common/test_admin_available.py
index 5c69c5e..75401db 100644
--- a/tempest/tests/common/test_admin_available.py
+++ b/tempest/tests/common/test_admin_available.py
@@ -15,7 +15,7 @@
from oslo_config import cfg
from oslotest import mockpatch
-from tempest.common import credentials
+from tempest.common import credentials_factory as credentials
from tempest import config
from tempest.tests import base
from tempest.tests import fake_config
@@ -23,15 +23,17 @@
class TestAdminAvailable(base.TestCase):
+ identity_version = 'v2'
+
def setUp(self):
super(TestAdminAvailable, self).setUp()
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('allow_tenant_isolation',
- tenant_isolation, group='auth')
+ cfg.CONF.set_default('use_dynamic_credentials',
+ dynamic_creds, group='auth')
if use_accounts_file:
accounts = [{'username': 'u1',
'tenant_name': 't1',
@@ -50,7 +52,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')
@@ -60,45 +62,58 @@
self.useFixture(mockpatch.Patch('os.path.isfile',
return_value=False))
if admin_creds:
- (u, t, p) = ('u', 't', 'p')
+ username = 'u'
+ tenant = 't'
+ password = 'p'
+ domain = 'd'
else:
- (u, t, p) = (None, None, None)
+ username = None
+ tenant = None
+ password = None
+ domain = None
- cfg.CONF.set_default('admin_username', u, group='identity')
- cfg.CONF.set_default('admin_tenant_name', t, group='identity')
- cfg.CONF.set_default('admin_password', p, group='identity')
+ 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
- observed = credentials.is_admin_available()
+ 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')
+
+
+class TestAdminAvailableV3(TestAdminAvailable):
+
+ identity_version = 'v3'
diff --git a/tempest/tests/common/test_alt_available.py b/tempest/tests/common/test_alt_available.py
new file mode 100644
index 0000000..db3f5ec
--- /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_factory as 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/common/test_cred_provider.py b/tempest/tests/common/test_configured_creds.py
similarity index 91%
rename from tempest/tests/common/test_cred_provider.py
rename to tempest/tests/common/test_configured_creds.py
index 1bc7147..96b75fd 100644
--- a/tempest/tests/common/test_cred_provider.py
+++ b/tempest/tests/common/test_configured_creds.py
@@ -18,8 +18,7 @@
from tempest_lib.services.identity.v2 import token_client as v2_client
from tempest_lib.services.identity.v3 import token_client as v3_client
-
-from tempest.common import cred_provider
+from tempest.common import credentials_factory as common_creds
from tempest.common import tempest_fixtures as fixtures
from tempest import config
from tempest.tests import base
@@ -65,12 +64,12 @@
def _verify_credentials(self, credentials_class, filled=True,
identity_version=None):
- for ctype in cred_provider.CREDENTIAL_TYPES:
+ for ctype in common_creds.CREDENTIAL_TYPES:
if identity_version is None:
- creds = cred_provider.get_configured_credentials(
+ creds = common_creds.get_configured_credentials(
credential_type=ctype, fill_in=filled)
else:
- creds = cred_provider.get_configured_credentials(
+ creds = common_creds.get_configured_credentials(
credential_type=ctype, fill_in=filled,
identity_version=identity_version)
self._check(creds, credentials_class, filled)
@@ -123,5 +122,9 @@
cfg.CONF.set_default('auth_version', 'v3', group='identity')
# Identity group items
for prefix in ['', 'alt_', 'admin_']:
+ if prefix == 'admin_':
+ group = 'auth'
+ else:
+ group = 'identity'
cfg.CONF.set_default(prefix + 'domain_name', 'fake_domain_name',
- group='identity')
+ group=group)
diff --git a/tempest/tests/common/test_credentials.py b/tempest/tests/common/test_credentials.py
new file mode 100644
index 0000000..136ac02
--- /dev/null
+++ b/tempest/tests/common/test_credentials.py
@@ -0,0 +1,36 @@
+# Copyright 2015 Hewlett-Packard Development Company, L.P.
+#
+# 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.common import credentials_factory as credentials
+from tempest import config
+from tempest import exceptions
+from tempest.tests import base
+from tempest.tests import fake_config
+
+
+class TestLegacyCredentialsProvider(base.TestCase):
+
+ fixed_params = {'identity_version': 'v2'}
+
+ def setUp(self):
+ super(TestLegacyCredentialsProvider, self).setUp()
+ self.useFixture(fake_config.ConfigFixture())
+ self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
+
+ def test_get_creds_roles_legacy_invalid(self):
+ test_accounts_class = credentials.LegacyCredentialProvider(
+ **self.fixed_params)
+ self.assertRaises(exceptions.InvalidConfiguration,
+ test_accounts_class.get_creds_by_roles,
+ ['fake_role'])
diff --git a/tempest/tests/test_tenant_isolation.py b/tempest/tests/common/test_dynamic_creds.py
similarity index 77%
rename from tempest/tests/test_tenant_isolation.py
rename to tempest/tests/common/test_dynamic_creds.py
index 7bdc1d7..78064a7 100644
--- a/tempest/tests/test_tenant_isolation.py
+++ b/tempest/tests/common/test_dynamic_creds.py
@@ -17,7 +17,8 @@
from oslotest import mockpatch
from tempest_lib.services.identity.v2 import token_client as json_token_client
-from tempest.common import isolated_creds
+from tempest.common import credentials_factory as credentials
+from tempest.common import dynamic_creds
from tempest.common import service_client
from tempest import config
from tempest import exceptions
@@ -30,10 +31,14 @@
from tempest.tests import fake_identity
-class TestTenantIsolation(base.TestCase):
+class TestDynamicCredentialProvider(base.TestCase):
+
+ fixed_params = {'name': 'test class',
+ 'identity_version': 'v2',
+ 'admin_role': 'admin'}
def setUp(self):
- super(TestTenantIsolation, self).setUp()
+ super(TestDynamicCredentialProvider, 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)
@@ -42,20 +47,29 @@
cfg.CONF.set_default('operator_role', 'FakeRole',
group='object-storage')
self._mock_list_ec2_credentials('fake_user_id', 'fake_tenant_id')
+ self.fixed_params.update(
+ admin_creds=self._get_fake_admin_creds())
def test_tempest_client(self):
- iso_creds = isolated_creds.IsolatedCreds(name='test class')
- self.assertTrue(isinstance(iso_creds.identity_admin_client,
+ creds = dynamic_creds.DynamicCredentialProvider(**self.fixed_params)
+ self.assertTrue(isinstance(creds.identity_admin_client,
json_iden_client.IdentityClient))
- self.assertTrue(isinstance(iso_creds.network_admin_client,
+ self.assertTrue(isinstance(creds.network_admin_client,
json_network_client.NetworkClient))
+ def _get_fake_admin_creds(self):
+ return credentials.get_credentials(
+ fill_in=False,
+ identity_version=self.fixed_params['identity_version'],
+ username='fake_username', password='fake_password',
+ tenant_name='fake_tenant')
+
def _mock_user_create(self, id, name):
user_fix = self.useFixture(mockpatch.PatchObject(
json_iden_client.IdentityClient,
'create_user',
return_value=(service_client.ResponseBody
- (200, {'id': id, 'name': name}))))
+ (200, {'user': {'id': id, 'name': name}}))))
return user_fix
def _mock_tenant_create(self, id, name):
@@ -63,28 +77,29 @@
json_iden_client.IdentityClient,
'create_tenant',
return_value=(service_client.ResponseBody
- (200, {'id': id, 'name': name}))))
+ (200, {'tenant': {'id': id, 'name': name}}))))
return tenant_fix
def _mock_list_roles(self, id, name):
roles_fix = self.useFixture(mockpatch.PatchObject(
json_iden_client.IdentityClient,
'list_roles',
- return_value=(service_client.ResponseBodyList
+ return_value=(service_client.ResponseBody
(200,
- [{'id': id, 'name': name},
- {'id': '1', 'name': 'FakeRole'}]))))
+ {'roles': [{'id': id, 'name': name},
+ {'id': '1', 'name': 'FakeRole'},
+ {'id': '2', 'name': 'Member'}]}))))
return roles_fix
def _mock_list_2_roles(self):
roles_fix = self.useFixture(mockpatch.PatchObject(
json_iden_client.IdentityClient,
'list_roles',
- return_value=(service_client.ResponseBodyList
+ return_value=(service_client.ResponseBody
(200,
- [{'id': '1234', 'name': 'role1'},
+ {'roles': [{'id': '1234', 'name': 'role1'},
{'id': '1', 'name': 'FakeRole'},
- {'id': '12345', 'name': 'role2'}]))))
+ {'id': '12345', 'name': 'role2'}]}))))
return roles_fix
def _mock_assign_user_role(self):
@@ -99,32 +114,34 @@
roles_fix = self.useFixture(mockpatch.PatchObject(
json_iden_client.IdentityClient,
'list_roles',
- return_value=(service_client.ResponseBodyList
- (200, [{'id': '1', 'name': 'FakeRole'}]))))
+ return_value=(service_client.ResponseBody
+ (200, {'roles': [{'id': '1',
+ 'name': 'FakeRole'}]}))))
return roles_fix
def _mock_list_ec2_credentials(self, user_id, tenant_id):
ec2_creds_fix = self.useFixture(mockpatch.PatchObject(
json_iden_client.IdentityClient,
'list_user_ec2_credentials',
- return_value=(service_client.ResponseBodyList
- (200, [{'access': 'fake_access',
- 'secret': 'fake_secret',
- 'tenant_id': tenant_id,
- 'user_id': user_id,
- 'trust_id': None}]))))
+ return_value=(service_client.ResponseBody
+ (200, {'credentials': [{
+ 'access': 'fake_access',
+ 'secret': 'fake_secret',
+ 'tenant_id': tenant_id,
+ 'user_id': user_id,
+ 'trust_id': None}]}))))
return ec2_creds_fix
def _mock_network_create(self, iso_creds, id, name):
net_fix = self.useFixture(mockpatch.PatchObject(
- iso_creds.network_admin_client,
+ iso_creds.networks_admin_client,
'create_network',
return_value={'network': {'id': id, 'name': name}}))
return net_fix
def _mock_subnet_create(self, iso_creds, id, name):
subnet_fix = self.useFixture(mockpatch.PatchObject(
- iso_creds.network_admin_client,
+ iso_creds.subnets_admin_client,
'create_subnet',
return_value={'subnet': {'id': id, 'name': name}}))
return subnet_fix
@@ -139,12 +156,12 @@
@mock.patch('tempest_lib.common.rest_client.RestClient')
def test_primary_creds(self, MockRestClient):
cfg.CONF.set_default('neutron', False, 'service_available')
- iso_creds = isolated_creds.IsolatedCreds(name='test class')
+ creds = dynamic_creds.DynamicCredentialProvider(**self.fixed_params)
self._mock_assign_user_role()
self._mock_list_role()
self._mock_tenant_create('1234', 'fake_prim_tenant')
self._mock_user_create('1234', 'fake_prim_user')
- primary_creds = iso_creds.get_primary_creds()
+ primary_creds = creds.get_primary_creds()
self.assertEqual(primary_creds.username, 'fake_prim_user')
self.assertEqual(primary_creds.tenant_name, 'fake_prim_tenant')
# Verify IDs
@@ -154,7 +171,7 @@
@mock.patch('tempest_lib.common.rest_client.RestClient')
def test_admin_creds(self, MockRestClient):
cfg.CONF.set_default('neutron', False, 'service_available')
- iso_creds = isolated_creds.IsolatedCreds(name='test class')
+ creds = dynamic_creds.DynamicCredentialProvider(**self.fixed_params)
self._mock_list_roles('1234', 'admin')
self._mock_user_create('1234', 'fake_admin_user')
self._mock_tenant_create('1234', 'fake_admin_tenant')
@@ -165,7 +182,7 @@
self.addCleanup(user_mock.stop)
with mock.patch.object(json_iden_client.IdentityClient,
'assign_user_role') as user_mock:
- admin_creds = iso_creds.get_admin_creds()
+ admin_creds = creds.get_admin_creds()
user_mock.assert_has_calls([
mock.call('1234', '1234', '1234')])
self.assertEqual(admin_creds.username, 'fake_admin_user')
@@ -177,7 +194,7 @@
@mock.patch('tempest_lib.common.rest_client.RestClient')
def test_role_creds(self, MockRestClient):
cfg.CONF.set_default('neutron', False, 'service_available')
- iso_creds = isolated_creds.IsolatedCreds('v2', 'test class')
+ creds = dynamic_creds.DynamicCredentialProvider(**self.fixed_params)
self._mock_list_2_roles()
self._mock_user_create('1234', 'fake_role_user')
self._mock_tenant_create('1234', 'fake_role_tenant')
@@ -188,7 +205,8 @@
self.addCleanup(user_mock.stop)
with mock.patch.object(json_iden_client.IdentityClient,
'assign_user_role') as user_mock:
- role_creds = iso_creds.get_creds_by_roles(roles=['role1', 'role2'])
+ role_creds = creds.get_creds_by_roles(
+ roles=['role1', 'role2'])
calls = user_mock.mock_calls
# Assert that the role creation is called with the 2 specified roles
self.assertEqual(len(calls), 2)
@@ -205,26 +223,26 @@
@mock.patch('tempest_lib.common.rest_client.RestClient')
def test_all_cred_cleanup(self, MockRestClient):
cfg.CONF.set_default('neutron', False, 'service_available')
- iso_creds = isolated_creds.IsolatedCreds(name='test class')
+ creds = dynamic_creds.DynamicCredentialProvider(**self.fixed_params)
self._mock_assign_user_role()
self._mock_list_role()
self._mock_tenant_create('1234', 'fake_prim_tenant')
self._mock_user_create('1234', 'fake_prim_user')
- iso_creds.get_primary_creds()
+ creds.get_primary_creds()
self._mock_tenant_create('12345', 'fake_alt_tenant')
self._mock_user_create('12345', 'fake_alt_user')
- iso_creds.get_alt_creds()
+ creds.get_alt_creds()
self._mock_tenant_create('123456', 'fake_admin_tenant')
self._mock_user_create('123456', 'fake_admin_user')
self._mock_list_roles('123456', 'admin')
- iso_creds.get_admin_creds()
+ creds.get_admin_creds()
user_mock = self.patch(
'tempest.services.identity.v2.json.identity_client.'
'IdentityClient.delete_user')
tenant_mock = self.patch(
'tempest.services.identity.v2.json.identity_client.'
'IdentityClient.delete_tenant')
- iso_creds.clear_isolated_creds()
+ creds.clear_creds()
# Verify user delete calls
calls = user_mock.mock_calls
self.assertEqual(len(calls), 3)
@@ -245,12 +263,12 @@
@mock.patch('tempest_lib.common.rest_client.RestClient')
def test_alt_creds(self, MockRestClient):
cfg.CONF.set_default('neutron', False, 'service_available')
- iso_creds = isolated_creds.IsolatedCreds(name='test class')
+ creds = dynamic_creds.DynamicCredentialProvider(**self.fixed_params)
self._mock_assign_user_role()
self._mock_list_role()
self._mock_user_create('1234', 'fake_alt_user')
self._mock_tenant_create('1234', 'fake_alt_tenant')
- alt_creds = iso_creds.get_alt_creds()
+ alt_creds = creds.get_alt_creds()
self.assertEqual(alt_creds.username, 'fake_alt_user')
self.assertEqual(alt_creds.tenant_name, 'fake_alt_tenant')
# Verify IDs
@@ -260,22 +278,22 @@
@mock.patch('tempest_lib.common.rest_client.RestClient')
def test_no_network_creation_with_config_set(self, MockRestClient):
cfg.CONF.set_default('create_isolated_networks', False, group='auth')
- iso_creds = isolated_creds.IsolatedCreds(name='test class')
+ creds = dynamic_creds.DynamicCredentialProvider(**self.fixed_params)
self._mock_assign_user_role()
self._mock_list_role()
self._mock_user_create('1234', 'fake_prim_user')
self._mock_tenant_create('1234', 'fake_prim_tenant')
- net = mock.patch.object(iso_creds.network_admin_client,
+ net = mock.patch.object(creds.networks_admin_client,
'delete_network')
net_mock = net.start()
- subnet = mock.patch.object(iso_creds.network_admin_client,
+ subnet = mock.patch.object(creds.subnets_admin_client,
'delete_subnet')
subnet_mock = subnet.start()
- router = mock.patch.object(iso_creds.network_admin_client,
+ router = mock.patch.object(creds.network_admin_client,
'delete_router')
router_mock = router.start()
- primary_creds = iso_creds.get_primary_creds()
+ primary_creds = creds.get_primary_creds()
self.assertEqual(net_mock.mock_calls, [])
self.assertEqual(subnet_mock.mock_calls, [])
self.assertEqual(router_mock.mock_calls, [])
@@ -288,18 +306,18 @@
@mock.patch('tempest_lib.common.rest_client.RestClient')
def test_network_creation(self, MockRestClient):
- iso_creds = isolated_creds.IsolatedCreds(name='test class')
+ creds = dynamic_creds.DynamicCredentialProvider(**self.fixed_params)
self._mock_assign_user_role()
self._mock_list_role()
self._mock_user_create('1234', 'fake_prim_user')
self._mock_tenant_create('1234', 'fake_prim_tenant')
- self._mock_network_create(iso_creds, '1234', 'fake_net')
- self._mock_subnet_create(iso_creds, '1234', 'fake_subnet')
+ self._mock_network_create(creds, '1234', 'fake_net')
+ self._mock_subnet_create(creds, '1234', 'fake_subnet')
self._mock_router_create('1234', 'fake_router')
router_interface_mock = self.patch(
'tempest.services.network.json.network_client.NetworkClient.'
'add_router_interface_with_subnet_id')
- primary_creds = iso_creds.get_primary_creds()
+ primary_creds = creds.get_primary_creds()
router_interface_mock.called_once_with('1234', '1234')
network = primary_creds.network
subnet = primary_creds.subnet
@@ -319,73 +337,71 @@
"description": args['name'],
"security_group_rules": [],
"id": "sg-%s" % args['tenant_id']}]}
- iso_creds = isolated_creds.IsolatedCreds(name='test class')
+ creds = dynamic_creds.DynamicCredentialProvider(**self.fixed_params)
# Create primary tenant and network
self._mock_assign_user_role()
self._mock_list_role()
self._mock_user_create('1234', 'fake_prim_user')
self._mock_tenant_create('1234', 'fake_prim_tenant')
- self._mock_network_create(iso_creds, '1234', 'fake_net')
- self._mock_subnet_create(iso_creds, '1234', 'fake_subnet')
+ self._mock_network_create(creds, '1234', 'fake_net')
+ self._mock_subnet_create(creds, '1234', 'fake_subnet')
self._mock_router_create('1234', 'fake_router')
router_interface_mock = self.patch(
'tempest.services.network.json.network_client.NetworkClient.'
'add_router_interface_with_subnet_id')
- iso_creds.get_primary_creds()
+ creds.get_primary_creds()
router_interface_mock.called_once_with('1234', '1234')
router_interface_mock.reset_mock()
# Create alternate tenant and network
self._mock_user_create('12345', 'fake_alt_user')
self._mock_tenant_create('12345', 'fake_alt_tenant')
- self._mock_network_create(iso_creds, '12345', 'fake_alt_net')
- self._mock_subnet_create(iso_creds, '12345',
- 'fake_alt_subnet')
+ self._mock_network_create(creds, '12345', 'fake_alt_net')
+ self._mock_subnet_create(creds, '12345', 'fake_alt_subnet')
self._mock_router_create('12345', 'fake_alt_router')
- iso_creds.get_alt_creds()
+ creds.get_alt_creds()
router_interface_mock.called_once_with('12345', '12345')
router_interface_mock.reset_mock()
# Create admin tenant and networks
self._mock_user_create('123456', 'fake_admin_user')
self._mock_tenant_create('123456', 'fake_admin_tenant')
- self._mock_network_create(iso_creds, '123456',
- 'fake_admin_net')
- self._mock_subnet_create(iso_creds, '123456',
- 'fake_admin_subnet')
+ self._mock_network_create(creds, '123456', 'fake_admin_net')
+ self._mock_subnet_create(creds, '123456', 'fake_admin_subnet')
self._mock_router_create('123456', 'fake_admin_router')
self._mock_list_roles('123456', 'admin')
- iso_creds.get_admin_creds()
+ creds.get_admin_creds()
self.patch('tempest.services.identity.v2.json.identity_client.'
'IdentityClient.delete_user')
self.patch('tempest.services.identity.v2.json.identity_client.'
'IdentityClient.delete_tenant')
- net = mock.patch.object(iso_creds.network_admin_client,
+ net = mock.patch.object(creds.networks_admin_client,
'delete_network')
net_mock = net.start()
- subnet = mock.patch.object(iso_creds.network_admin_client,
+ subnet = mock.patch.object(creds.subnets_admin_client,
'delete_subnet')
subnet_mock = subnet.start()
- router = mock.patch.object(iso_creds.network_admin_client,
+ router = mock.patch.object(creds.network_admin_client,
'delete_router')
router_mock = router.start()
remove_router_interface_mock = self.patch(
'tempest.services.network.json.network_client.NetworkClient.'
'remove_router_interface_with_subnet_id')
return_values = ({'status': 200}, {'ports': []})
- port_list_mock = mock.patch.object(iso_creds.network_admin_client,
+ port_list_mock = mock.patch.object(creds.ports_admin_client,
'list_ports',
return_value=return_values)
port_list_mock.start()
- secgroup_list_mock = mock.patch.object(iso_creds.network_admin_client,
- 'list_security_groups',
- side_effect=side_effect)
+ secgroup_list_mock = mock.patch.object(
+ creds.network_admin_client,
+ 'list_security_groups',
+ side_effect=side_effect)
secgroup_list_mock.start()
return_values = (fake_http.fake_httplib({}, status=204), {})
remove_secgroup_mock = self.patch(
'tempest.services.network.json.network_client.'
'NetworkClient.delete', return_value=return_values)
- iso_creds.clear_isolated_creds()
+ creds.clear_creds()
# Verify default security group delete
calls = remove_secgroup_mock.mock_calls
self.assertEqual(len(calls), 3)
@@ -429,18 +445,18 @@
@mock.patch('tempest_lib.common.rest_client.RestClient')
def test_network_alt_creation(self, MockRestClient):
- iso_creds = isolated_creds.IsolatedCreds(name='test class')
+ creds = dynamic_creds.DynamicCredentialProvider(**self.fixed_params)
self._mock_assign_user_role()
self._mock_list_role()
self._mock_user_create('1234', 'fake_alt_user')
self._mock_tenant_create('1234', 'fake_alt_tenant')
- self._mock_network_create(iso_creds, '1234', 'fake_alt_net')
- self._mock_subnet_create(iso_creds, '1234', 'fake_alt_subnet')
+ self._mock_network_create(creds, '1234', 'fake_alt_net')
+ self._mock_subnet_create(creds, '1234', 'fake_alt_subnet')
self._mock_router_create('1234', 'fake_alt_router')
router_interface_mock = self.patch(
'tempest.services.network.json.network_client.NetworkClient.'
'add_router_interface_with_subnet_id')
- alt_creds = iso_creds.get_alt_creds()
+ alt_creds = creds.get_alt_creds()
router_interface_mock.called_once_with('1234', '1234')
network = alt_creds.network
subnet = alt_creds.subnet
@@ -454,18 +470,18 @@
@mock.patch('tempest_lib.common.rest_client.RestClient')
def test_network_admin_creation(self, MockRestClient):
- iso_creds = isolated_creds.IsolatedCreds(name='test class')
+ creds = dynamic_creds.DynamicCredentialProvider(**self.fixed_params)
self._mock_assign_user_role()
self._mock_user_create('1234', 'fake_admin_user')
self._mock_tenant_create('1234', 'fake_admin_tenant')
- self._mock_network_create(iso_creds, '1234', 'fake_admin_net')
- self._mock_subnet_create(iso_creds, '1234', 'fake_admin_subnet')
+ self._mock_network_create(creds, '1234', 'fake_admin_net')
+ self._mock_subnet_create(creds, '1234', 'fake_admin_subnet')
self._mock_router_create('1234', 'fake_admin_router')
router_interface_mock = self.patch(
'tempest.services.network.json.network_client.NetworkClient.'
'add_router_interface_with_subnet_id')
self._mock_list_roles('123456', 'admin')
- admin_creds = iso_creds.get_admin_creds()
+ admin_creds = creds.get_admin_creds()
router_interface_mock.called_once_with('1234', '1234')
network = admin_creds.network
subnet = admin_creds.subnet
@@ -485,23 +501,24 @@
'subnet': False,
'dhcp': False,
}
- iso_creds = isolated_creds.IsolatedCreds(name='test class',
- network_resources=net_dict)
+ creds = dynamic_creds.DynamicCredentialProvider(
+ network_resources=net_dict,
+ **self.fixed_params)
self._mock_assign_user_role()
self._mock_list_role()
self._mock_user_create('1234', 'fake_prim_user')
self._mock_tenant_create('1234', 'fake_prim_tenant')
- net = mock.patch.object(iso_creds.network_admin_client,
+ net = mock.patch.object(creds.networks_admin_client,
'delete_network')
net_mock = net.start()
- subnet = mock.patch.object(iso_creds.network_admin_client,
+ subnet = mock.patch.object(creds.subnets_admin_client,
'delete_subnet')
subnet_mock = subnet.start()
- router = mock.patch.object(iso_creds.network_admin_client,
+ router = mock.patch.object(creds.network_admin_client,
'delete_router')
router_mock = router.start()
- primary_creds = iso_creds.get_primary_creds()
+ primary_creds = creds.get_primary_creds()
self.assertEqual(net_mock.mock_calls, [])
self.assertEqual(subnet_mock.mock_calls, [])
self.assertEqual(router_mock.mock_calls, [])
@@ -520,14 +537,15 @@
'subnet': False,
'dhcp': False,
}
- iso_creds = isolated_creds.IsolatedCreds(name='test class',
- network_resources=net_dict)
+ creds = dynamic_creds.DynamicCredentialProvider(
+ network_resources=net_dict,
+ **self.fixed_params)
self._mock_assign_user_role()
self._mock_list_role()
self._mock_user_create('1234', 'fake_prim_user')
self._mock_tenant_create('1234', 'fake_prim_tenant')
self.assertRaises(exceptions.InvalidConfiguration,
- iso_creds.get_primary_creds)
+ creds.get_primary_creds)
@mock.patch('tempest_lib.common.rest_client.RestClient')
def test_subnet_without_network(self, MockRestClient):
@@ -537,14 +555,15 @@
'subnet': True,
'dhcp': False,
}
- iso_creds = isolated_creds.IsolatedCreds(name='test class',
- network_resources=net_dict)
+ creds = dynamic_creds.DynamicCredentialProvider(
+ network_resources=net_dict,
+ **self.fixed_params)
self._mock_assign_user_role()
self._mock_list_role()
self._mock_user_create('1234', 'fake_prim_user')
self._mock_tenant_create('1234', 'fake_prim_tenant')
self.assertRaises(exceptions.InvalidConfiguration,
- iso_creds.get_primary_creds)
+ creds.get_primary_creds)
@mock.patch('tempest_lib.common.rest_client.RestClient')
def test_dhcp_without_subnet(self, MockRestClient):
@@ -554,11 +573,12 @@
'subnet': False,
'dhcp': True,
}
- iso_creds = isolated_creds.IsolatedCreds(name='test class',
- network_resources=net_dict)
+ creds = dynamic_creds.DynamicCredentialProvider(
+ network_resources=net_dict,
+ **self.fixed_params)
self._mock_assign_user_role()
self._mock_list_role()
self._mock_user_create('1234', 'fake_prim_user')
self._mock_tenant_create('1234', 'fake_prim_tenant')
self.assertRaises(exceptions.InvalidConfiguration,
- iso_creds.get_primary_creds)
+ creds.get_primary_creds)
diff --git a/tempest/tests/common/test_accounts.py b/tempest/tests/common/test_preprov_creds.py
similarity index 76%
rename from tempest/tests/common/test_accounts.py
rename to tempest/tests/common/test_preprov_creds.py
index 9bf8059..fd7df16 100644
--- a/tempest/tests/common/test_accounts.py
+++ b/tempest/tests/common/test_preprov_creds.py
@@ -17,27 +17,35 @@
import mock
from oslo_concurrency.fixture import lockutils as lockutils_fixtures
-from oslo_concurrency import lockutils
from oslo_config import cfg
from oslotest import mockpatch
+import shutil
import six
from tempest_lib import auth
+from tempest_lib import exceptions as lib_exc
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
from tempest.tests import fake_config
from tempest.tests import fake_http
from tempest.tests import fake_identity
-class TestAccount(base.TestCase):
+class TestPreProvisionedCredentials(base.TestCase):
+
+ fixed_params = {'name': 'test class',
+ 'identity_version': 'v2',
+ 'test_accounts_file': 'fake_accounts_file',
+ 'accounts_lock_dir': 'fake_locks_dir',
+ 'admin_role': 'admin',
+ 'object_storage_operator_role': 'operator',
+ 'object_storage_reseller_admin_role': 'reseller'}
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,11 +79,15 @@
'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))
+ def tearDown(self):
+ super(TestPreProvisionedCredentials, self).tearDown()
+ shutil.rmtree(self.fixed_params['accounts_lock_dir'],
+ ignore_errors=True)
+
def _get_hash_list(self, accounts_list):
hash_list = []
for account in accounts_list:
@@ -88,7 +100,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(
+ **self.fixed_params)
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,8 +110,10 @@
self.assertEqual(hash_list[3], results)
def test_get_hash_dict(self):
- test_account_class = accounts.Accounts('v2', 'test_name')
- hash_dict = test_account_class.get_hash_dict(self.test_accounts)
+ test_account_class = preprov_creds.PreProvisionedCredentialProvider(
+ **self.fixed_params)
+ 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())
@@ -109,7 +124,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(
+ **self.fixed_params))
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 +136,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(
+ **self.fixed_params))
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 +150,15 @@
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(
+ **self.fixed_params)
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',
+ lock_path = os.path.join(self.fixed_params['accounts_lock_dir'],
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(self.fixed_params['accounts_lock_dir'])
mkdir_mock.mock.assert_called_once_with(mkdir_path)
@mock.patch('oslo_concurrency.lockutils.lock')
@@ -150,10 +168,11 @@
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(
+ **self.fixed_params)
with mock.patch('six.moves.builtins.open', mock.mock_open(),
create=True):
- self.assertRaises(exceptions.InvalidConfiguration,
+ self.assertRaises(lib_exc.InvalidCredentials,
test_account_class._get_free_hash, hash_list)
@mock.patch('oslo_concurrency.lockutils.lock')
@@ -161,7 +180,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(
+ **self.fixed_params)
def _fake_is_file(path):
# Fake isfile() to return that the path exists unless a specific
@@ -174,8 +194,7 @@
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',
+ lock_path = os.path.join(self.fixed_params['accounts_lock_dir'],
hash_list[3])
open_mock.assert_has_calls([mock.call(lock_path, 'w')])
@@ -186,15 +205,14 @@
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(
+ **self.fixed_params)
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),
- 'test_accounts',
+ hash_path = os.path.join(self.fixed_params['accounts_lock_dir'],
hash_list[2])
- lock_path = os.path.join(accounts.CONF.oslo_concurrency.lock_path,
- 'test_accounts')
+ lock_path = self.fixed_params['accounts_lock_dir']
remove_mock.mock.assert_called_once_with(hash_path)
rmdir_mock.mock.assert_called_once_with(lock_path)
@@ -206,33 +224,36 @@
# 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(
+ **self.fixed_params)
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),
- 'test_accounts',
+ hash_path = os.path.join(self.fixed_params['accounts_lock_dir'],
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(
+ **self.fixed_params)
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(
+ **self.fixed_params)
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(
+ **self.fixed_params)
hashes = test_accounts_class.hash_dict['roles']['role4']
temp_hash = hashes[0]
get_free_hash_mock = self.useFixture(mockpatch.PatchObject(
@@ -247,9 +268,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(
+ **self.fixed_params)
hashes = test_accounts_class.hash_dict['roles']['role4']
hashes2 = test_accounts_class.hash_dict['roles']['role2']
hashes = list(set(hashes) & set(hashes2))
@@ -266,9 +288,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(
+ **self.fixed_params)
hashes = list(test_accounts_class.hash_dict['creds'].keys())
admin_hashes = test_accounts_class.hash_dict['roles'][
cfg.CONF.identity.admin_role]
@@ -292,10 +315,11 @@
'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')
- with mock.patch('tempest.services.compute.json.networks_client.'
+ test_accounts_class = preprov_creds.PreProvisionedCredentialProvider(
+ **self.fixed_params)
+ with mock.patch('tempest_lib.services.compute.networks_client.'
'NetworksClient.list_networks',
return_value={'networks': [{'name': 'network-2',
'id': 'fake-id',
@@ -308,31 +332,3 @@
self.assertIn('id', network)
self.assertEqual('fake-id', network['id'])
self.assertEqual('network-2', network['name'])
-
-
-class TestNotLockingAccount(base.TestCase):
-
- def setUp(self):
- super(TestNotLockingAccount, self).setUp()
- self.useFixture(fake_config.ConfigFixture())
- self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
- self.useFixture(lockutils_fixtures.ExternalLockFixture())
- self.test_accounts = [
- {'username': 'test_user1', 'tenant_name': 'test_tenant1',
- 'password': 'p'},
- {'username': 'test_user2', 'tenant_name': 'test_tenant2',
- 'password': 'p'},
- {'username': 'test_user3', 'tenant_name': 'test_tenant3',
- 'password': 'p'},
- ]
- self.useFixture(mockpatch.Patch(
- 'tempest.common.accounts.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')
- self.assertRaises(exceptions.InvalidConfiguration,
- test_accounts_class.get_creds_by_roles,
- ['fake_role'])
diff --git a/tempest/tests/common/test_service_clients.py b/tempest/tests/common/test_service_clients.py
index 00b8470..cf33fb2 100644
--- a/tempest/tests/common/test_service_clients.py
+++ b/tempest/tests/common/test_service_clients.py
@@ -17,37 +17,14 @@
import six
from tempest.services.baremetal.v1.json import baremetal_client
-from tempest.services.compute.json import agents_client
-from tempest.services.compute.json import aggregates_client
-from tempest.services.compute.json import availability_zone_client
-from tempest.services.compute.json import certificates_client
-from tempest.services.compute.json import extensions_client
-from tempest.services.compute.json import fixed_ips_client
-from tempest.services.compute.json import flavors_client
-from tempest.services.compute.json import floating_ip_pools_client
-from tempest.services.compute.json import floating_ips_bulk_client
from tempest.services.compute.json import floating_ips_client
-from tempest.services.compute.json import hosts_client
-from tempest.services.compute.json import hypervisor_client
-from tempest.services.compute.json import images_client
-from tempest.services.compute.json import instance_usage_audit_log_client
from tempest.services.compute.json import interfaces_client
-from tempest.services.compute.json import keypairs_client
-from tempest.services.compute.json import limits_client
-from tempest.services.compute.json import migrations_client
-from tempest.services.compute.json import networks_client as nova_net_client
-from tempest.services.compute.json import quota_classes_client
-from tempest.services.compute.json import quotas_client
-from tempest.services.compute.json import security_group_default_rules_client \
- as nova_secgrop_default_client
from tempest.services.compute.json import security_group_rules_client
-from tempest.services.compute.json import security_groups_client
from tempest.services.compute.json import server_groups_client
from tempest.services.compute.json import servers_client
from tempest.services.compute.json import services_client
-from tempest.services.compute.json import tenant_usages_client
-from tempest.services.compute.json import volumes_extensions_client \
- as compute_volumes_extensions_client
+from tempest.services.compute.json import volumes_client \
+ as compute_volumes_client
from tempest.services.data_processing.v1_1 import data_processing_client
from tempest.services.database.json import flavors_client as db_flavor_client
from tempest.services.database.json import versions_client as db_version_client
@@ -68,6 +45,7 @@
from tempest.services.object_storage import container_client
from tempest.services.object_storage import object_client
from tempest.services.orchestration.json import orchestration_client
+from tempest.services.telemetry.json import alarming_client
from tempest.services.telemetry.json import telemetry_client
from tempest.services.volume.json.admin import volume_hosts_client
from tempest.services.volume.json.admin import volume_quotas_client
@@ -109,35 +87,13 @@
def test_service_client_creations_with_specified_args(self, mock_init):
test_clients = [
baremetal_client.BaremetalClient,
- agents_client.AgentsClient,
- aggregates_client.AggregatesClient,
- availability_zone_client.AvailabilityZoneClient,
- certificates_client.CertificatesClient,
- extensions_client.ExtensionsClient,
- fixed_ips_client.FixedIPsClient,
- flavors_client.FlavorsClient,
- floating_ip_pools_client.FloatingIPPoolsClient,
- floating_ips_bulk_client.FloatingIPsBulkClient,
floating_ips_client.FloatingIPsClient,
- hosts_client.HostsClient,
- hypervisor_client.HypervisorClient,
- images_client.ImagesClient,
- instance_usage_audit_log_client.InstanceUsagesAuditLogClient,
interfaces_client.InterfacesClient,
- keypairs_client.KeyPairsClient,
- limits_client.LimitsClient,
- migrations_client.MigrationsClient,
- nova_net_client.NetworksClient,
- quotas_client.QuotasClient,
- quota_classes_client.QuotaClassesClient,
- nova_secgrop_default_client.SecurityGroupDefaultRulesClient,
security_group_rules_client.SecurityGroupRulesClient,
- security_groups_client.SecurityGroupsClient,
server_groups_client.ServerGroupsClient,
servers_client.ServersClient,
services_client.ServicesClient,
- tenant_usages_client.TenantUsagesClient,
- compute_volumes_extensions_client.VolumesExtensionsClient,
+ compute_volumes_client.VolumesClient,
data_processing_client.DataProcessingClient,
db_flavor_client.DatabaseFlavorsClient,
db_version_client.DatabaseVersionsClient,
@@ -148,6 +104,7 @@
object_client.ObjectClient,
orchestration_client.OrchestrationClient,
telemetry_client.TelemetryClient,
+ alarming_client.AlarmingClient,
qos_client.QosSpecsClient,
volume_hosts_client.VolumeHostsClient,
volume_quotas_client.VolumeQuotasClient,
diff --git a/tempest/tests/fake_config.py b/tempest/tests/fake_config.py
index 4898c9c..ca8bc3e 100644
--- a/tempest/tests/fake_config.py
+++ b/tempest/tests/fake_config.py
@@ -48,9 +48,13 @@
for config_option in ['username', 'password', 'tenant_name']:
# Identity group items
for prefix in ['', 'alt_', 'admin_']:
+ if prefix == 'admin_':
+ group = 'auth'
+ else:
+ group = 'identity'
self.conf.set_default(prefix + config_option,
'fake_' + config_option,
- group='identity')
+ group=group)
class FakePrivate(config.TempestConfigPrivate):
diff --git a/tempest/tests/fake_http.py b/tempest/tests/fake_http.py
index 7d77484..d714055 100644
--- a/tempest/tests/fake_http.py
+++ b/tempest/tests/fake_http.py
@@ -50,7 +50,8 @@
class fake_httplib(object):
def __init__(self, headers, body=None,
version=1.0, status=200, reason="Ok"):
- """
+ """Initialization of fake httplib
+
:param headers: dict representing HTTP response headers
:param body: file-like object
:param version: HTTP Version
diff --git a/tempest/tests/services/compute/test_agents_client.py b/tempest/tests/services/compute/test_agents_client.py
deleted file mode 100644
index 31e576e..0000000
--- a/tempest/tests/services/compute/test_agents_client.py
+++ /dev/null
@@ -1,109 +0,0 @@
-# Copyright 2015 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.
-
-from tempest_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import agents_client
-from tempest.tests.services.compute import base
-
-
-class TestAgentsClient(base.BaseComputeServiceTest):
- FAKE_CREATE_AGENT = {
- "agent":
- {
- "url": "http://foo.com",
- "hypervisor": "kvm",
- "md5hash": "md5",
- "version": "2",
- "architecture": "x86_64",
- "os": "linux",
- "agent_id": 1
- }
- }
-
- FAKE_UPDATE_AGENT = {
- "agent":
- {
- "url": "http://foo.com",
- "hypervisor": "kvm",
- "md5hash": "md5",
- "version": "2",
- "architecture": "x86_64",
- "os": "linux",
- "agent_id": 1
- }
- }
-
- def setUp(self):
- super(TestAgentsClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = agents_client.AgentsClient(fake_auth,
- 'compute', 'regionOne')
-
- def _test_list_agents(self, bytes_body=False):
- self.check_service_client_function(
- self.client.list_agents,
- 'tempest.common.service_client.ServiceClient.get',
- {"agents": []},
- bytes_body)
- self.check_service_client_function(
- self.client.list_agents,
- 'tempest.common.service_client.ServiceClient.get',
- {"agents": []},
- bytes_body,
- hypervisor="kvm")
-
- def _test_create_agent(self, bytes_body=False):
- self.check_service_client_function(
- self.client.create_agent,
- 'tempest.common.service_client.ServiceClient.post',
- self.FAKE_CREATE_AGENT,
- bytes_body,
- url="http://foo.com", hypervisor="kvm", md5hash="md5",
- version="2", architecture="x86_64", os="linux")
-
- def _test_delete_agent(self):
- self.check_service_client_function(
- self.client.delete_agent,
- 'tempest.common.service_client.ServiceClient.delete',
- {}, agent_id="1")
-
- def _test_update_agent(self, bytes_body=False):
- self.check_service_client_function(
- self.client.update_agent,
- 'tempest.common.service_client.ServiceClient.put',
- self.FAKE_UPDATE_AGENT,
- bytes_body,
- agent_id="1", url="http://foo.com", md5hash="md5", version="2")
-
- def test_list_agents_with_str_body(self):
- self._test_list_agents()
-
- def test_list_agents_with_bytes_body(self):
- self._test_list_agents(bytes_body=True)
-
- def test_create_agent_with_str_body(self):
- self._test_create_agent()
-
- def test_create_agent_with_bytes_body(self):
- self._test_create_agent(bytes_body=True)
-
- def test_delete_agent(self):
- self._test_delete_agent()
-
- def test_update_agent_with_str_body(self):
- self._test_update_agent()
-
- def test_update_agent_with_bytes_body(self):
- self._test_update_agent(bytes_body=True)
diff --git a/tempest/tests/services/compute/test_aggregates_client.py b/tempest/tests/services/compute/test_aggregates_client.py
deleted file mode 100644
index e92b76b..0000000
--- a/tempest/tests/services/compute/test_aggregates_client.py
+++ /dev/null
@@ -1,131 +0,0 @@
-# Copyright 2015 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.
-
-from tempest_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import aggregates_client
-from tempest.tests.services.compute import base
-
-
-class TestAggregatesClient(base.BaseComputeServiceTest):
- FAKE_SHOW_AGGREGATE = {
- "aggregate":
- {
- "name": "hoge",
- "availability_zone": None,
- "deleted": False,
- "created_at":
- "2015-07-16T03:07:32.000000",
- "updated_at": None,
- "hosts": [],
- "deleted_at": None,
- "id": 1,
- "metadata": {}
- }
- }
-
- FAKE_CREATE_AGGREGATE = {
- "aggregate":
- {
- "name": u'\xf4',
- "availability_zone": None,
- "deleted": False,
- "created_at": "2015-07-21T04:11:18.000000",
- "updated_at": None,
- "deleted_at": None,
- "id": 1
- }
- }
-
- FAKE_UPDATE_AGGREGATE = {
- "aggregate":
- {
- "name": u'\xe9',
- "availability_zone": None,
- "deleted": False,
- "created_at": "2015-07-16T03:07:32.000000",
- "updated_at": "2015-07-23T05:16:29.000000",
- "hosts": [],
- "deleted_at": None,
- "id": 1,
- "metadata": {}
- }
- }
-
- def setUp(self):
- super(TestAggregatesClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = aggregates_client.AggregatesClient(
- fake_auth, 'compute', 'regionOne')
-
- def _test_list_aggregates(self, bytes_body=False):
- self.check_service_client_function(
- self.client.list_aggregates,
- 'tempest.common.service_client.ServiceClient.get',
- {"aggregates": []},
- bytes_body)
-
- def test_list_aggregates_with_str_body(self):
- self._test_list_aggregates()
-
- def test_list_aggregates_with_bytes_body(self):
- self._test_list_aggregates(bytes_body=True)
-
- def _test_show_aggregate(self, bytes_body=False):
- self.check_service_client_function(
- self.client.show_aggregate,
- 'tempest.common.service_client.ServiceClient.get',
- self.FAKE_SHOW_AGGREGATE,
- bytes_body,
- aggregate_id=1)
-
- def test_show_aggregate_with_str_body(self):
- self._test_show_aggregate()
-
- def test_show_aggregate_with_bytes_body(self):
- self._test_show_aggregate(bytes_body=True)
-
- def _test_create_aggregate(self, bytes_body=False):
- self.check_service_client_function(
- self.client.create_aggregate,
- 'tempest.common.service_client.ServiceClient.post',
- self.FAKE_CREATE_AGGREGATE,
- bytes_body,
- name='hoge')
-
- def test_create_aggregate_with_str_body(self):
- self._test_create_aggregate()
-
- def test_create_aggregate_with_bytes_body(self):
- self._test_create_aggregate(bytes_body=True)
-
- def test_delete_aggregate(self):
- self.check_service_client_function(
- self.client.delete_aggregate,
- 'tempest.common.service_client.ServiceClient.delete',
- {}, aggregate_id="1")
-
- def _test_update_aggregate(self, bytes_body=False):
- self.check_service_client_function(
- self.client.update_aggregate,
- 'tempest.common.service_client.ServiceClient.put',
- self.FAKE_UPDATE_AGGREGATE,
- bytes_body,
- aggregate_id=1)
-
- def test_update_aggregate_with_str_body(self):
- self._test_update_aggregate()
-
- def test_update_aggregate_with_bytes_body(self):
- self._test_update_aggregate(bytes_body=True)
diff --git a/tempest/tests/services/compute/test_availability_zone_client.py b/tempest/tests/services/compute/test_availability_zone_client.py
deleted file mode 100644
index e1d94bc..0000000
--- a/tempest/tests/services/compute/test_availability_zone_client.py
+++ /dev/null
@@ -1,82 +0,0 @@
-# Copyright 2015 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_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import availability_zone_client
-from tempest.tests.services.compute import base
-
-
-class TestAvailabilityZoneClient(base.BaseComputeServiceTest):
-
- FAKE_AZ_INFO = {
- "availabilityZoneInfo":
- [
- {
- "zoneState": {
- "available": True
- },
- "hosts": None,
- "zoneName": u'\xf4'
- }
- ]
- }
-
- FAKE_AZ_DETAILS = {
- "testhost": {
- "nova-compute": {
- "available": True,
- "active": True,
- "updated_at": "2015-09-10T07:16:46.000000"
- }
- }
- }
-
- def setUp(self):
- super(TestAvailabilityZoneClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = availability_zone_client.AvailabilityZoneClient(
- fake_auth, 'compute', 'regionOne')
-
- def _test_availability_zones(self, to_utf=False):
- self.check_service_client_function(
- self.client.list_availability_zones,
- 'tempest.common.service_client.ServiceClient.get',
- self.FAKE_AZ_INFO,
- to_utf)
-
- def _test_availability_zones_with_details(self, to_utf=False):
- fake_az_details = copy.deepcopy(self.FAKE_AZ_INFO)
- fake_az_details['availabilityZoneInfo'][0]['hosts'] = \
- self.FAKE_AZ_DETAILS
- self.check_service_client_function(
- self.client.list_availability_zones,
- 'tempest.common.service_client.ServiceClient.get',
- fake_az_details,
- to_utf,
- detail=True)
-
- def test_list_availability_zones_with_str_body(self):
- self._test_availability_zones()
-
- def test_list_availability_zones_with_bytes_body(self):
- self._test_availability_zones(True)
-
- def test_list_availability_zones_with_str_body_and_details(self):
- self._test_availability_zones_with_details()
-
- def test_list_availability_zones_with_bytes_body_and_details(self):
- self._test_availability_zones_with_details(True)
diff --git a/tempest/tests/services/compute/test_baremetal_nodes_client.py b/tempest/tests/services/compute/test_baremetal_nodes_client.py
deleted file mode 100644
index 86c035c..0000000
--- a/tempest/tests/services/compute/test_baremetal_nodes_client.py
+++ /dev/null
@@ -1,75 +0,0 @@
-# Copyright 2015 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_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import baremetal_nodes_client
-from tempest.tests.services.compute import base
-
-
-class TestBareMetalNodesClient(base.BaseComputeServiceTest):
-
- FAKE_NODE_INFO = {'cpus': '8',
- 'disk_gb': '64',
- 'host': '10.0.2.15',
- 'id': 'Identifier',
- 'instance_uuid': "null",
- 'interfaces': [
- {
- "address": "20::01",
- "datapath_id": "null",
- "id": 1,
- "port_no": None
- }
- ],
- 'memory_mb': '8192',
- 'task_state': None}
-
- def setUp(self):
- super(TestBareMetalNodesClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.baremetal_nodes_client = (baremetal_nodes_client.
- BaremetalNodesClient
- (fake_auth, 'compute',
- 'regionOne'))
-
- def _test_bareMetal_nodes(self, operation='list', bytes_body=False):
- if operation != 'list':
- expected = {"node": self.FAKE_NODE_INFO}
- function = self.baremetal_nodes_client.show_baremetal_node
- else:
- node_info = copy.deepcopy(self.FAKE_NODE_INFO)
- del node_info['instance_uuid']
- expected = {"nodes": [node_info]}
- function = self.baremetal_nodes_client.list_baremetal_nodes
-
- self.check_service_client_function(
- function,
- 'tempest.common.service_client.ServiceClient.get',
- expected, bytes_body, 200,
- baremetal_node_id='Identifier')
-
- def test_list_bareMetal_nodes_with_str_body(self):
- self._test_bareMetal_nodes()
-
- def test_list_bareMetal_nodes_with_bytes_body(self):
- self._test_bareMetal_nodes(bytes_body=True)
-
- def test_show_bareMetal_node_with_str_body(self):
- self._test_bareMetal_nodes('show')
-
- def test_show_bareMetal_node_with_bytes_body(self):
- self._test_bareMetal_nodes('show', True)
diff --git a/tempest/tests/services/compute/test_certificates_client.py b/tempest/tests/services/compute/test_certificates_client.py
deleted file mode 100644
index 2ba90d0..0000000
--- a/tempest/tests/services/compute/test_certificates_client.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# Copyright 2015 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_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import certificates_client
-from tempest.tests.services.compute import base
-
-
-class TestCertificatesClient(base.BaseComputeServiceTest):
-
- FAKE_CERTIFICATE = {
- "certificate": {
- "data": "-----BEGIN----MIICyzCCAjSgAwI----END CERTIFICATE-----\n",
- "private_key": None
- }
- }
-
- def setUp(self):
- super(TestCertificatesClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = certificates_client.CertificatesClient(
- fake_auth, 'compute', 'regionOne')
-
- def _test_show_certificate(self, bytes_body=False):
- self.check_service_client_function(
- self.client.show_certificate,
- 'tempest.common.service_client.ServiceClient.get',
- self.FAKE_CERTIFICATE,
- bytes_body,
- certificate_id="fake-id")
-
- def test_show_certificate_with_str_body(self):
- self._test_show_certificate()
-
- def test_show_certificate_with_bytes_body(self):
- self._test_show_certificate(bytes_body=True)
-
- def _test_create_certificate(self, bytes_body=False):
- cert = copy.deepcopy(self.FAKE_CERTIFICATE)
- cert['certificate']['private_key'] = "my_private_key"
- self.check_service_client_function(
- self.client.create_certificate,
- 'tempest.common.service_client.ServiceClient.post',
- cert,
- bytes_body)
-
- def test_create_certificate_with_str_body(self):
- self._test_create_certificate()
-
- def test_create_certificate_with_bytes_body(self):
- self._test_create_certificate(bytes_body=True)
diff --git a/tempest/tests/services/compute/test_extensions_client.py b/tempest/tests/services/compute/test_extensions_client.py
deleted file mode 100644
index 21efc52..0000000
--- a/tempest/tests/services/compute/test_extensions_client.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# Copyright 2015 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.
-
-from tempest_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import extensions_client
-from tempest.tests.services.compute import base
-
-
-class TestExtensionsClient(base.BaseComputeServiceTest):
-
- FAKE_SHOW_EXTENSION = {
- "extension": {
- "updated": "2011-06-09T00:00:00Z",
- "name": "Multinic",
- "links": [],
- "namespace":
- "http://docs.openstack.org/compute/ext/multinic/api/v1.1",
- "alias": "NMN",
- "description": u'\u2740(*\xb4\u25e1`*)\u2740'
- }
- }
-
- def setUp(self):
- super(TestExtensionsClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = extensions_client.ExtensionsClient(
- fake_auth, 'compute', 'regionOne')
-
- def _test_list_extensions(self, bytes_body=False):
- self.check_service_client_function(
- self.client.list_extensions,
- 'tempest.common.service_client.ServiceClient.get',
- {"extensions": []},
- bytes_body)
-
- def test_list_extensions_with_str_body(self):
- self._test_list_extensions()
-
- def test_list_extensions_with_bytes_body(self):
- self._test_list_extensions(bytes_body=True)
-
- def _test_show_extension(self, bytes_body=False):
- self.check_service_client_function(
- self.client.show_extension,
- 'tempest.common.service_client.ServiceClient.get',
- self.FAKE_SHOW_EXTENSION,
- bytes_body,
- extension_alias="NMN")
-
- def test_show_extension_with_str_body(self):
- self._test_show_extension()
-
- def test_show_extension_with_bytes_body(self):
- self._test_show_extension(bytes_body=True)
diff --git a/tempest/tests/services/compute/test_fixedIPs_client.py b/tempest/tests/services/compute/test_fixedIPs_client.py
deleted file mode 100644
index 5acb422..0000000
--- a/tempest/tests/services/compute/test_fixedIPs_client.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright 2015 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.
-
-from tempest_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import fixed_ips_client
-from tempest.tests.services.compute import base
-
-
-class TestFixedIPsClient(base.BaseComputeServiceTest):
- FIXED_IP_INFO = {"fixed_ip": {"address": "10.0.0.1",
- "cidr": "10.11.12.0/24",
- "host": "localhost",
- "hostname": "OpenStack"}}
-
- def setUp(self):
- super(TestFixedIPsClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.fixedIPsClient = (fixed_ips_client.
- FixedIPsClient
- (fake_auth, 'compute',
- 'regionOne'))
-
- def _test_show_fixed_ip(self, bytes_body=False):
- self.check_service_client_function(
- self.fixedIPsClient.show_fixed_ip,
- 'tempest.common.service_client.ServiceClient.get',
- self.FIXED_IP_INFO, bytes_body,
- status=200, fixed_ip='Identifier')
-
- def test_show_fixed_ip_with_str_body(self):
- self._test_show_fixed_ip()
-
- def test_show_fixed_ip_with_bytes_body(self):
- self._test_show_fixed_ip(True)
diff --git a/tempest/tests/services/compute/test_floating_ip_pools_client.py b/tempest/tests/services/compute/test_floating_ip_pools_client.py
deleted file mode 100644
index 1cb4bf3..0000000
--- a/tempest/tests/services/compute/test_floating_ip_pools_client.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2015 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.
-
-from tempest_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import floating_ip_pools_client
-from tempest.tests.services.compute import base
-
-
-class TestFloatingIPPoolsClient(base.BaseComputeServiceTest):
-
- FAKE_FLOATING_IP_POOLS = {
- "floating_ip_pools":
- [
- {"name": u'\u3042'},
- {"name": u'\u3044'}
- ]
- }
-
- def setUp(self):
- super(TestFloatingIPPoolsClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = floating_ip_pools_client.FloatingIPPoolsClient(
- fake_auth, 'compute', 'regionOne')
-
- def test_list_floating_ip_pools_with_str_body(self):
- self.check_service_client_function(
- self.client.list_floating_ip_pools,
- 'tempest.common.service_client.ServiceClient.get',
- self.FAKE_FLOATING_IP_POOLS)
-
- def test_list_floating_ip_pools_with_bytes_body(self):
- self.check_service_client_function(
- self.client.list_floating_ip_pools,
- 'tempest.common.service_client.ServiceClient.get',
- self.FAKE_FLOATING_IP_POOLS, to_utf=True)
diff --git a/tempest/tests/services/compute/test_floating_ips_bulk_client.py b/tempest/tests/services/compute/test_floating_ips_bulk_client.py
deleted file mode 100644
index 600985b..0000000
--- a/tempest/tests/services/compute/test_floating_ips_bulk_client.py
+++ /dev/null
@@ -1,88 +0,0 @@
-# Copyright 2015 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.
-
-from tempest_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import floating_ips_bulk_client
-from tempest.tests.services.compute import base
-
-
-class TestFloatingIPsBulkClient(base.BaseComputeServiceTest):
-
- FAKE_FIP_BULK_LIST = {"floating_ip_info": [{
- "address": "10.10.10.1",
- "instance_uuid": None,
- "fixed_ip": None,
- "interface": "eth0",
- "pool": "nova",
- "project_id": None
- },
- {
- "address": "10.10.10.2",
- "instance_uuid": None,
- "fixed_ip": None,
- "interface": "eth0",
- "pool": "nova",
- "project_id": None
- }]}
-
- def setUp(self):
- super(TestFloatingIPsBulkClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = floating_ips_bulk_client.FloatingIPsBulkClient(
- fake_auth, 'compute', 'regionOne')
-
- def _test_list_floating_ips_bulk(self, bytes_body=False):
- self.check_service_client_function(
- self.client.list_floating_ips_bulk,
- 'tempest.common.service_client.ServiceClient.get',
- self.FAKE_FIP_BULK_LIST,
- to_utf=bytes_body)
-
- def _test_create_floating_ips_bulk(self, bytes_body=False):
- fake_fip_create_data = {"floating_ips_bulk_create": {
- "ip_range": "192.168.1.0/24", "pool": "nova", "interface": "eth0"}}
- self.check_service_client_function(
- self.client.create_floating_ips_bulk,
- 'tempest.common.service_client.ServiceClient.post',
- fake_fip_create_data,
- to_utf=bytes_body,
- ip_range="192.168.1.0/24", pool="nova", interface="eth0")
-
- def _test_delete_floating_ips_bulk(self, bytes_body=False):
- fake_fip_delete_data = {"floating_ips_bulk_delete": "192.168.1.0/24"}
- self.check_service_client_function(
- self.client.delete_floating_ips_bulk,
- 'tempest.common.service_client.ServiceClient.put',
- fake_fip_delete_data,
- to_utf=bytes_body,
- ip_range="192.168.1.0/24")
-
- def test_list_floating_ips_bulk_with_str_body(self):
- self._test_list_floating_ips_bulk()
-
- def test_list_floating_ips_bulk_with_bytes_body(self):
- self._test_list_floating_ips_bulk(True)
-
- def test_create_floating_ips_bulk_with_str_body(self):
- self._test_create_floating_ips_bulk()
-
- def test_create_floating_ips_bulk_with_bytes_body(self):
- self._test_create_floating_ips_bulk(True)
-
- def test_delete_floating_ips_bulk_with_str_body(self):
- self._test_delete_floating_ips_bulk()
-
- def test_delete_floating_ips_bulk_with_bytes_body(self):
- self._test_delete_floating_ips_bulk(True)
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)
diff --git a/tempest/tests/services/compute/test_instance_usage_audit_log_client.py b/tempest/tests/services/compute/test_instance_usage_audit_log_client.py
deleted file mode 100644
index b4af9d5..0000000
--- a/tempest/tests/services/compute/test_instance_usage_audit_log_client.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# Copyright 2015 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 datetime
-
-from tempest_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import instance_usage_audit_log_client
-from tempest.tests.services.compute import base
-
-
-class TestInstanceUsagesAuditLogClient(base.BaseComputeServiceTest):
-
- FAKE_AUDIT_LOG = {
- "hosts_not_run": [
- "f4eb7cfd155f4574967f8b55a7faed75"
- ],
- "log": {},
- "num_hosts": 1,
- "num_hosts_done": 0,
- "num_hosts_not_run": 1,
- "num_hosts_running": 0,
- "overall_status": "0 of 1 hosts done. 0 errors.",
- "period_beginning": "2012-12-01 00:00:00",
- "period_ending": "2013-01-01 00:00:00",
- "total_errors": 0,
- "total_instances": 0
- }
-
- def setUp(self):
- super(TestInstanceUsagesAuditLogClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = (instance_usage_audit_log_client.
- InstanceUsagesAuditLogClient(fake_auth, 'compute',
- 'regionOne'))
-
- def _test_list_instance_usage_audit_logs(self, bytes_body=False):
- self.check_service_client_function(
- self.client.list_instance_usage_audit_logs,
- 'tempest.common.service_client.ServiceClient.get',
- {"instance_usage_audit_logs": self.FAKE_AUDIT_LOG},
- bytes_body)
-
- def test_list_instance_usage_audit_logs_with_str_body(self):
- self._test_list_instance_usage_audit_logs()
-
- def test_list_instance_usage_audit_logs_with_bytes_body(self):
- self._test_list_instance_usage_audit_logs(bytes_body=True)
-
- def _test_show_instance_usage_audit_log(self, bytes_body=False):
- before_time = datetime.datetime(2012, 12, 1, 0, 0)
- self.check_service_client_function(
- self.client.show_instance_usage_audit_log,
- 'tempest.common.service_client.ServiceClient.get',
- {"instance_usage_audit_log": self.FAKE_AUDIT_LOG},
- bytes_body,
- time_before=before_time)
-
- def test_show_instance_usage_audit_log_with_str_body(self):
- self._test_show_instance_usage_audit_log()
-
- def test_show_network_with_bytes_body_with_bytes_body(self):
- self._test_show_instance_usage_audit_log(bytes_body=True)
diff --git a/tempest/tests/services/compute/test_interfaces_client.py b/tempest/tests/services/compute/test_interfaces_client.py
new file mode 100644
index 0000000..235585a
--- /dev/null
+++ b/tempest/tests/services/compute/test_interfaces_client.py
@@ -0,0 +1,98 @@
+# Copyright 2015 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.
+
+from tempest.services.compute.json import interfaces_client
+from tempest.tests import fake_auth_provider
+from tempest.tests.services.compute import base
+
+
+class TestInterfacesClient(base.BaseComputeServiceTest):
+ # Data Values to be used for testing #
+ FAKE_INTERFACE_DATA = {
+ "fixed_ips": [{
+ "ip_address": "192.168.1.1",
+ "subnet_id": "f8a6e8f8-c2ec-497c-9f23-da9616de54ef"
+ }],
+ "mac_addr": "fa:16:3e:4c:2c:30",
+ "net_id": "3cb9bc59-5699-4588-a4b1-b87f96708bc6",
+ "port_id": "ce531f90-199f-48c0-816c-13e38010b442",
+ "port_state": "ACTIVE"}
+
+ FAKE_SHOW_DATA = {
+ "interfaceAttachment": FAKE_INTERFACE_DATA}
+ FAKE_LIST_DATA = {
+ "interfaceAttachments": [FAKE_INTERFACE_DATA]}
+
+ FAKE_SERVER_ID = "ec14c864-096e-4e27-bb8a-2c2b4dc6f3f5"
+ FAKE_PORT_ID = FAKE_SHOW_DATA['interfaceAttachment']['port_id']
+ func2mock = {
+ 'delete': 'tempest.common.service_client.ServiceClient.delete',
+ 'get': 'tempest.common.service_client.ServiceClient.get',
+ 'post': 'tempest.common.service_client.ServiceClient.post'}
+
+ def setUp(self):
+ super(TestInterfacesClient, self).setUp()
+ fake_auth = fake_auth_provider.FakeAuthProvider()
+ self.client = interfaces_client.InterfacesClient(fake_auth,
+ "compute",
+ "regionOne")
+
+ def _test_interface_operation(self, operation="create", bytes_body=False):
+ response_code = 200
+ expected_op = self.FAKE_SHOW_DATA
+ mock_operation = self.func2mock['get']
+ params = {'server_id': self.FAKE_SERVER_ID,
+ 'port_id': self.FAKE_PORT_ID}
+ if operation == 'list':
+ expected_op = self.FAKE_LIST_DATA
+ function = self.client.list_interfaces
+ params = {'server_id': self.FAKE_SERVER_ID}
+ elif operation == 'show':
+ function = self.client.show_interface
+ elif operation == 'delete':
+ expected_op = {}
+ mock_operation = self.func2mock['delete']
+ function = self.client.delete_interface
+ response_code = 202
+ else:
+ function = self.client.create_interface
+ mock_operation = self.func2mock['post']
+
+ self.check_service_client_function(
+ function, mock_operation, expected_op,
+ bytes_body, response_code, **params)
+
+ def test_list_interfaces_with_str_body(self):
+ self._test_interface_operation('list')
+
+ def test_list_interfaces_with_bytes_body(self):
+ self._test_interface_operation('list', True)
+
+ def test_show_interface_with_str_body(self):
+ self._test_interface_operation('show')
+
+ def test_show_interface_with_bytes_body(self):
+ self._test_interface_operation('show', True)
+
+ def test_delete_interface_with_str_body(self):
+ self._test_interface_operation('delete')
+
+ def test_delete_interface_with_bytes_body(self):
+ self._test_interface_operation('delete', True)
+
+ def test_create_interface_with_str_body(self):
+ self._test_interface_operation()
+
+ def test_create_interface_with_bytes_body(self):
+ self._test_interface_operation(bytes_body=True)
diff --git a/tempest/tests/services/compute/test_limits_client.py b/tempest/tests/services/compute/test_limits_client.py
deleted file mode 100644
index 733d3d1..0000000
--- a/tempest/tests/services/compute/test_limits_client.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# Copyright 2015 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.
-
-from tempest_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import limits_client
-from tempest.tests.services.compute import base
-
-
-class TestLimitsClient(base.BaseComputeServiceTest):
-
- def setUp(self):
- super(TestLimitsClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = limits_client.LimitsClient(
- fake_auth, 'compute', 'regionOne')
-
- def _test_show_limits(self, bytes_body=False):
- expected = {
- "limits": {
- "rate": [],
- "absolute": {
- "maxServerMeta": 128,
- "maxPersonality": 5,
- "totalServerGroupsUsed": 0,
- "maxImageMeta": 128,
- "maxPersonalitySize": 10240,
- "maxServerGroups": 10,
- "maxSecurityGroupRules": 20,
- "maxTotalKeypairs": 100,
- "totalCoresUsed": 0,
- "totalRAMUsed": 0,
- "totalInstancesUsed": 0,
- "maxSecurityGroups": 10,
- "totalFloatingIpsUsed": 0,
- "maxTotalCores": 20,
- "totalSecurityGroupsUsed": 0,
- "maxTotalFloatingIps": 10,
- "maxTotalInstances": 10,
- "maxTotalRAMSize": 51200,
- "maxServerGroupMembers": 10
- }
- }
- }
-
- self.check_service_client_function(
- self.client.show_limits,
- 'tempest.common.service_client.ServiceClient.get',
- expected,
- bytes_body)
-
- def test_show_limits_with_str_body(self):
- self._test_show_limits()
-
- def test_show_limits_with_bytes_body(self):
- self._test_show_limits(bytes_body=True)
diff --git a/tempest/tests/services/compute/test_migrations_client.py b/tempest/tests/services/compute/test_migrations_client.py
deleted file mode 100644
index 55f2ef2..0000000
--- a/tempest/tests/services/compute/test_migrations_client.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright 2015 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.
-
-from tempest_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import migrations_client
-from tempest.tests.services.compute import base
-
-
-class TestMigrationsClient(base.BaseComputeServiceTest):
- FAKE_MIGRATION_INFO = {"migrations": [{
- "created_at": "2012-10-29T13:42:02",
- "dest_compute": "compute2",
- "dest_host": "1.2.3.4",
- "dest_node": "node2",
- "id": 1234,
- "instance_uuid": "e9e4fdd7-f956-44ff-bfeb-d654a96ab3a2",
- "new_instance_type_id": 2,
- "old_instance_type_id": 1,
- "source_compute": "compute1",
- "source_node": "node1",
- "status": "finished",
- "updated_at": "2012-10-29T13:42:02"}]}
-
- def setUp(self):
- super(TestMigrationsClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.mg_client_obj = migrations_client.MigrationsClient(
- fake_auth, 'compute', 'regionOne')
-
- def _test_list_migrations(self, bytes_body=False):
- self.check_service_client_function(
- self.mg_client_obj.list_migrations,
- 'tempest.common.service_client.ServiceClient.get',
- self.FAKE_MIGRATION_INFO,
- bytes_body)
-
- def test_list_migration_with_str_body(self):
- self._test_list_migrations()
-
- def test_list_migration_with_bytes_body(self):
- self._test_list_migrations(True)
diff --git a/tempest/tests/services/compute/test_networks_client.py b/tempest/tests/services/compute/test_networks_client.py
deleted file mode 100644
index cec8262..0000000
--- a/tempest/tests/services/compute/test_networks_client.py
+++ /dev/null
@@ -1,95 +0,0 @@
-# Copyright 2015 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.
-
-from tempest_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import networks_client
-from tempest.tests.services.compute import base
-
-
-class TestNetworksClient(base.BaseComputeServiceTest):
-
- FAKE_NETWORK = {
- "bridge": None,
- "vpn_public_port": None,
- "dhcp_start": None,
- "bridge_interface": None,
- "share_address": None,
- "updated_at": None,
- "id": "34d5ae1e-5659-49cf-af80-73bccd7d7ad3",
- "cidr_v6": None,
- "deleted_at": None,
- "gateway": None,
- "rxtx_base": None,
- "label": u'30d7',
- "priority": None,
- "project_id": None,
- "vpn_private_address": None,
- "deleted": None,
- "vlan": None,
- "broadcast": None,
- "netmask": None,
- "injected": None,
- "cidr": None,
- "vpn_public_address": None,
- "multi_host": None,
- "enable_dhcp": None,
- "dns2": None,
- "created_at": None,
- "host": None,
- "mtu": None,
- "gateway_v6": None,
- "netmask_v6": None,
- "dhcp_server": None,
- "dns1": None
- }
-
- network_id = "34d5ae1e-5659-49cf-af80-73bccd7d7ad3"
-
- FAKE_NETWORKS = [FAKE_NETWORK]
-
- def setUp(self):
- super(TestNetworksClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = networks_client.NetworksClient(
- fake_auth, 'compute', 'regionOne')
-
- def _test_list_networks(self, bytes_body=False):
- fake_list = {"networks": self.FAKE_NETWORKS}
- self.check_service_client_function(
- self.client.list_networks,
- 'tempest.common.service_client.ServiceClient.get',
- fake_list,
- bytes_body)
-
- def test_list_networks_with_str_body(self):
- self._test_list_networks()
-
- def test_list_networks_with_bytes_body(self):
- self._test_list_networks(bytes_body=True)
-
- def _test_show_network(self, bytes_body=False):
- self.check_service_client_function(
- self.client.show_network,
- 'tempest.common.service_client.ServiceClient.get',
- {"network": self.FAKE_NETWORK},
- bytes_body,
- network_id=self.network_id
- )
-
- def test_show_network_with_str_body(self):
- self._test_show_network()
-
- def test_show_network_with_bytes_body(self):
- self._test_show_network(bytes_body=True)
diff --git a/tempest/tests/services/compute/test_quota_classes_client.py b/tempest/tests/services/compute/test_quota_classes_client.py
deleted file mode 100644
index 29800a2..0000000
--- a/tempest/tests/services/compute/test_quota_classes_client.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# Copyright 2015 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_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import quota_classes_client
-from tempest.tests.services.compute import base
-
-
-class TestQuotaClassesClient(base.BaseComputeServiceTest):
-
- FAKE_QUOTA_CLASS_SET = {
- "injected_file_content_bytes": 10240,
- "metadata_items": 128,
- "server_group_members": 10,
- "server_groups": 10,
- "ram": 51200,
- "floating_ips": 10,
- "key_pairs": 100,
- "id": u'\u2740(*\xb4\u25e1`*)\u2740',
- "instances": 10,
- "security_group_rules": 20,
- "security_groups": 10,
- "injected_files": 5,
- "cores": 20,
- "fixed_ips": -1,
- "injected_file_path_bytes": 255,
- }
-
- def setUp(self):
- super(TestQuotaClassesClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = quota_classes_client.QuotaClassesClient(
- fake_auth, 'compute', 'regionOne')
-
- def _test_show_quota_class_set(self, bytes_body=False):
- fake_body = {'quota_class_set': self.FAKE_QUOTA_CLASS_SET}
- self.check_service_client_function(
- self.client.show_quota_class_set,
- 'tempest.common.service_client.ServiceClient.get',
- fake_body,
- bytes_body,
- quota_class_id="test")
-
- def test_show_quota_class_set_with_str_body(self):
- self._test_show_quota_class_set()
-
- def test_show_quota_class_set_with_bytes_body(self):
- self._test_show_quota_class_set(bytes_body=True)
-
- def test_update_quota_class_set(self):
- fake_quota_class_set = copy.deepcopy(self.FAKE_QUOTA_CLASS_SET)
- fake_quota_class_set.pop("id")
- fake_body = {'quota_class_set': fake_quota_class_set}
- self.check_service_client_function(
- self.client.update_quota_class_set,
- 'tempest.common.service_client.ServiceClient.put',
- fake_body,
- quota_class_id="test")
diff --git a/tempest/tests/services/compute/test_server_groups_client.py b/tempest/tests/services/compute/test_server_groups_client.py
index 5e058d6..e531e2f 100644
--- a/tempest/tests/services/compute/test_server_groups_client.py
+++ b/tempest/tests/services/compute/test_server_groups_client.py
@@ -69,16 +69,16 @@
def test_list_server_groups_byte_body(self):
self._test_list_server_groups(bytes_body=True)
- def _test_get_server_group(self, bytes_body=False):
+ def _test_show_server_group(self, bytes_body=False):
expected = {"server_group": TestServerGroupsClient.server_group}
self.check_service_client_function(
- self.client.get_server_group,
+ self.client.show_server_group,
'tempest.common.service_client.ServiceClient.get',
expected, bytes_body,
server_group_id='5bbcc3c4-1da2-4437-a48a-66f15b1b13f9')
- def test_get_server_group_str_body(self):
- self._test_get_server_group(bytes_body=False)
+ def test_show_server_group_str_body(self):
+ self._test_show_server_group(bytes_body=False)
- def test_get_server_group_byte_body(self):
- self._test_get_server_group(bytes_body=True)
+ def test_show_server_group_byte_body(self):
+ self._test_show_server_group(bytes_body=True)
diff --git a/tempest/tests/services/compute/test_servers_client.py b/tempest/tests/services/compute/test_servers_client.py
new file mode 100644
index 0000000..e347cf1
--- /dev/null
+++ b/tempest/tests/services/compute/test_servers_client.py
@@ -0,0 +1,212 @@
+# 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 servers_client
+from tempest.tests import fake_auth_provider
+from tempest.tests.services.compute import base
+
+
+class TestServersClient(base.BaseComputeServiceTest):
+
+ FAKE_SERVERS = {'servers': [{
+ "id": "616fb98f-46ca-475e-917e-2563e5a8cd19",
+ "links": [
+ {
+ "href": "http://os.co/v2/616fb98f-46ca-475e-917e-2563e5a8cd19",
+ "rel": "self"
+ },
+ {
+ "href": "http://os.co/616fb98f-46ca-475e-917e-2563e5a8cd19",
+ "rel": "bookmark"
+ }
+ ],
+ "name": u"new\u1234-server-test"}]
+ }
+
+ FAKE_SERVER_GET = {'server': {
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "addresses": {
+ "private": [
+ {
+ "addr": "192.168.0.3",
+ "version": 4
+ }
+ ]
+ },
+ "created": "2012-08-20T21:11:09Z",
+ "flavor": {
+ "id": "1",
+ "links": [
+ {
+ "href": "http://os.com/openstack/flavors/1",
+ "rel": "bookmark"
+ }
+ ]
+ },
+ "hostId": "65201c14a29663e06d0748e561207d998b343e1d164bfa0aafa9c45d",
+ "id": "893c7791-f1df-4c3d-8383-3caae9656c62",
+ "image": {
+ "id": "70a599e0-31e7-49b7-b260-868f441e862b",
+ "links": [
+ {
+ "href": "http://imgs/70a599e0-31e7-49b7-b260-868f441e862b",
+ "rel": "bookmark"
+ }
+ ]
+ },
+ "links": [
+ {
+ "href": "http://v2/srvs/893c7791-f1df-4c3d-8383-3caae9656c62",
+ "rel": "self"
+ },
+ {
+ "href": "http://srvs/893c7791-f1df-4c3d-8383-3caae9656c62",
+ "rel": "bookmark"
+ }
+ ],
+ "metadata": {
+ u"My Server N\u1234me": u"Apa\u1234che1"
+ },
+ "name": u"new\u1234-server-test",
+ "progress": 0,
+ "status": "ACTIVE",
+ "tenant_id": "openstack",
+ "updated": "2012-08-20T21:11:09Z",
+ "user_id": "fake"}
+ }
+
+ FAKE_SERVER_POST = {"server": {
+ "id": "616fb98f-46ca-475e-917e-2563e5a8cd19",
+ "adminPass": "fake-admin-pass",
+ "security_groups": [
+ 'fake-security-group-1',
+ 'fake-security-group-2'
+ ],
+ "links": [
+ {
+ "href": "http://os.co/v2/616fb98f-46ca-475e-917e-2563e5a8cd19",
+ "rel": "self"
+ },
+ {
+ "href": "http://os.co/616fb98f-46ca-475e-917e-2563e5a8cd19",
+ "rel": "bookmark"
+ }
+ ],
+ "OS-DCF:diskConfig": "fake-disk-config"}
+ }
+
+ FAKE_ADDRESS = {"addresses": {
+ "private": [
+ {
+ "addr": "192.168.0.3",
+ "version": 4
+ }
+ ]}
+ }
+
+ server_id = FAKE_SERVER_GET['server']['id']
+ network_id = 'a6b0875b-6b5d-4a5a-81eb-0c3aa62e5fdb'
+
+ def setUp(self):
+ super(TestServersClient, self).setUp()
+ fake_auth = fake_auth_provider.FakeAuthProvider()
+ self.client = servers_client.ServersClient(
+ fake_auth, 'compute', 'regionOne')
+
+ def test_list_servers_with_str_body(self):
+ self._test_list_servers()
+
+ def test_list_servers_with_bytes_body(self):
+ self._test_list_servers(bytes_body=True)
+
+ def _test_list_servers(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.list_servers,
+ 'tempest.common.service_client.ServiceClient.get',
+ self.FAKE_SERVERS,
+ bytes_body)
+
+ def test_show_server_with_str_body(self):
+ self._test_show_server()
+
+ def test_show_server_with_bytes_body(self):
+ self._test_show_server(bytes_body=True)
+
+ def _test_show_server(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.show_server,
+ 'tempest.common.service_client.ServiceClient.get',
+ self.FAKE_SERVER_GET,
+ bytes_body,
+ server_id=self.server_id
+ )
+
+ def test_delete_server(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.delete_server,
+ 'tempest.common.service_client.ServiceClient.delete',
+ {},
+ status=204,
+ server_id=self.server_id
+ )
+
+ def test_create_server_with_str_body(self):
+ self._test_create_server()
+
+ def test_create_server_with_bytes_body(self):
+ self._test_create_server(True)
+
+ def _test_create_server(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.create_server,
+ 'tempest.common.service_client.ServiceClient.post',
+ self.FAKE_SERVER_POST,
+ bytes_body,
+ status=202,
+ name='fake-name',
+ imageRef='fake-image-ref',
+ flavorRef='fake-flavor-ref'
+ )
+
+ def test_list_addresses_with_str_body(self):
+ self._test_list_addresses()
+
+ def test_list_addresses_with_bytes_body(self):
+ self._test_list_addresses(True)
+
+ def _test_list_addresses(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.list_addresses,
+ 'tempest.common.service_client.ServiceClient.get',
+ self.FAKE_ADDRESS,
+ bytes_body,
+ server_id=self.server_id
+ )
+
+ def test_list_addresses_by_network_with_str_body(self):
+ self._test_list_addresses_by_network()
+
+ def test_list_addresses_by_network_with_bytes_body(self):
+ self._test_list_addresses_by_network(True)
+
+ def _test_list_addresses_by_network(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.list_addresses_by_network,
+ 'tempest.common.service_client.ServiceClient.get',
+ self.FAKE_ADDRESS['addresses'],
+ bytes_body,
+ server_id=self.server_id,
+ network_id=self.network_id
+ )
diff --git a/tempest/tests/services/compute/test_snapshots_client.py b/tempest/tests/services/compute/test_snapshots_client.py
new file mode 100644
index 0000000..c24c6ae
--- /dev/null
+++ b/tempest/tests/services/compute/test_snapshots_client.py
@@ -0,0 +1,103 @@
+# Copyright 2015 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.
+
+from oslotest import mockpatch
+from tempest_lib import exceptions as lib_exc
+
+from tempest.services.compute.json import snapshots_client
+from tempest.tests import fake_auth_provider
+from tempest.tests.services.compute import base
+
+
+class TestSnapshotsClient(base.BaseComputeServiceTest):
+
+ FAKE_SNAPSHOT = {
+ "createdAt": "2015-10-02T16:27:54.724209",
+ "displayDescription": u"Another \u1234.",
+ "displayName": u"v\u1234-001",
+ "id": "100",
+ "size": 100,
+ "status": "available",
+ "volumeId": "12"
+ }
+
+ FAKE_SNAPSHOTS = {"snapshots": [FAKE_SNAPSHOT]}
+
+ def setUp(self):
+ super(TestSnapshotsClient, self).setUp()
+ fake_auth = fake_auth_provider.FakeAuthProvider()
+ self.client = snapshots_client.SnapshotsClient(
+ fake_auth, 'compute', 'regionOne')
+
+ def _test_create_snapshot(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.create_snapshot,
+ 'tempest.common.service_client.ServiceClient.post',
+ {"snapshot": self.FAKE_SNAPSHOT},
+ to_utf=bytes_body, status=200,
+ volume_id=self.FAKE_SNAPSHOT["volumeId"])
+
+ def test_create_snapshot_with_str_body(self):
+ self._test_create_snapshot()
+
+ def test_create_shapshot_with_bytes_body(self):
+ self._test_create_snapshot(bytes_body=True)
+
+ def _test_show_snapshot(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.show_snapshot,
+ 'tempest.common.service_client.ServiceClient.get',
+ {"snapshot": self.FAKE_SNAPSHOT},
+ to_utf=bytes_body, snapshot_id=self.FAKE_SNAPSHOT["id"])
+
+ def test_show_snapshot_with_str_body(self):
+ self._test_show_snapshot()
+
+ def test_show_snapshot_with_bytes_body(self):
+ self._test_show_snapshot(bytes_body=True)
+
+ def _test_list_snapshots(self, bytes_body=False, **params):
+ self.check_service_client_function(
+ self.client.list_snapshots,
+ 'tempest.common.service_client.ServiceClient.get',
+ self.FAKE_SNAPSHOTS, to_utf=bytes_body, **params)
+
+ def test_list_snapshots_with_str_body(self):
+ self._test_list_snapshots()
+
+ def test_list_snapshots_with_byte_body(self):
+ self._test_list_snapshots(bytes_body=True)
+
+ def test_list_snapshots_with_params(self):
+ self._test_list_snapshots('fake')
+
+ def test_delete_snapshot(self):
+ self.check_service_client_function(
+ self.client.delete_snapshot,
+ 'tempest.common.service_client.ServiceClient.delete',
+ {}, status=202, snapshot_id=self.FAKE_SNAPSHOT['id'])
+
+ def test_is_resource_deleted_true(self):
+ module = ('tempest.services.compute.json.snapshots_client.'
+ 'SnapshotsClient.show_snapshot')
+ self.useFixture(mockpatch.Patch(
+ module, side_effect=lib_exc.NotFound))
+ self.assertTrue(self.client.is_resource_deleted('fake-id'))
+
+ def test_is_resource_deleted_false(self):
+ module = ('tempest.services.compute.json.snapshots_client.'
+ 'SnapshotsClient.show_snapshot')
+ self.useFixture(mockpatch.Patch(
+ module, return_value={}))
+ self.assertFalse(self.client.is_resource_deleted('fake-id'))
diff --git a/tempest/tests/services/compute/test_volumes_extensions_client.py b/tempest/tests/services/compute/test_volumes_client.py
similarity index 87%
rename from tempest/tests/services/compute/test_volumes_extensions_client.py
rename to tempest/tests/services/compute/test_volumes_client.py
index 2fe8497..33d4bad 100644
--- a/tempest/tests/services/compute/test_volumes_extensions_client.py
+++ b/tempest/tests/services/compute/test_volumes_client.py
@@ -17,12 +17,12 @@
from oslotest import mockpatch
from tempest_lib import exceptions as lib_exc
-from tempest.services.compute.json import volumes_extensions_client
+from tempest.services.compute.json import volumes_client
from tempest.tests import fake_auth_provider
from tempest.tests.services.compute import base
-class TestVolumesExtensionsClient(base.BaseComputeServiceTest):
+class TestVolumesClient(base.BaseComputeServiceTest):
FAKE_VOLUME = {
"id": "521752a6-acf6-4b2d-bc7a-119f9148cd8c",
@@ -43,9 +43,9 @@
FAKE_VOLUMES = {"volumes": [FAKE_VOLUME]}
def setUp(self):
- super(TestVolumesExtensionsClient, self).setUp()
+ super(TestVolumesClient, self).setUp()
fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = volumes_extensions_client.VolumesExtensionsClient(
+ self.client = volumes_client.VolumesClient(
fake_auth, 'compute', 'regionOne')
def _test_list_volumes(self, bytes_body=False, **params):
@@ -100,15 +100,15 @@
{}, status=202, volume_id=self.FAKE_VOLUME['id'])
def test_is_resource_deleted_true(self):
- module = ('tempest.services.compute.json.volumes_extensions_client.'
- 'VolumesExtensionsClient.show_volume')
+ module = ('tempest.services.compute.json.volumes_client.'
+ 'VolumesClient.show_volume')
self.useFixture(mockpatch.Patch(
module, side_effect=lib_exc.NotFound))
self.assertTrue(self.client.is_resource_deleted('fake-id'))
def test_is_resource_deleted_false(self):
- module = ('tempest.services.compute.json.volumes_extensions_client.'
- 'VolumesExtensionsClient.show_volume')
+ module = ('tempest.services.compute.json.volumes_client.'
+ 'VolumesClient.show_volume')
self.useFixture(mockpatch.Patch(
module, return_value={}))
self.assertFalse(self.client.is_resource_deleted('fake-id'))
diff --git a/tempest/tests/stress/test_stress.py b/tempest/tests/stress/test_stress.py
index 16f1ac7..0ec2a5d 100644
--- a/tempest/tests/stress/test_stress.py
+++ b/tempest/tests/stress/test_stress.py
@@ -25,8 +25,7 @@
class StressFrameworkTest(base.TestCase):
- """Basic test for the stress test framework.
- """
+ """Basic test for the stress test framework."""
def _cmd(self, cmd, param):
"""Executes specified command."""
diff --git a/tempest/tests/test_hacking.py b/tempest/tests/test_hacking.py
index 62d2aee..55f00ef 100644
--- a/tempest/tests/test_hacking.py
+++ b/tempest/tests/test_hacking.py
@@ -17,7 +17,8 @@
class HackingTestCase(base.TestCase):
- """
+ """Test class for hacking rule
+
This class tests the hacking checks in tempest.hacking.checks by passing
strings to the check methods like the pep8/flake8 parser would. The parser
loops over each line in the file and then passes the parameters to the
diff --git a/tempest/thirdparty/boto/test.py b/tempest/thirdparty/boto/test.py
index 1ced180..cfd3747 100644
--- a/tempest/thirdparty/boto/test.py
+++ b/tempest/thirdparty/boto/test.py
@@ -27,7 +27,7 @@
from six.moves.urllib import parse as urlparse
from tempest_lib import exceptions as lib_exc
-import tempest.clients
+from tempest.common import credentials_factory as credentials
from tempest.common.utils import file_utils
from tempest import config
from tempest import exceptions
@@ -67,7 +67,7 @@
raise Exception("Unknown (Authentication?) Error")
# NOTE(andreaf) Setting up an extra manager here is redundant,
# and should be removed.
- openstack = tempest.clients.Manager()
+ openstack = credentials.ConfiguredUserManager()
try:
if urlparse.urlparse(CONF.boto.ec2_url).hostname is None:
raise Exception("Failed to get hostname from the ec2_url")
@@ -110,8 +110,10 @@
CODE_RE = '.*' # regexp makes sense in group match
def match(self, exc):
- """:returns: Returns with an error string if it does not match,
- returns with None when it matches.
+ """Check boto exception
+
+ :returns: Returns with an error string if it does not match,
+ returns with None when it matches.
"""
if not isinstance(exc, exception.BotoServerError):
return "%r not an BotoServerError instance" % exc
@@ -136,9 +138,9 @@
def _add_matcher_class(error_cls, error_data, base=BotoExceptionMatcher):
- """
- Usable for adding an ExceptionMatcher(s) into the exception tree.
- The not leaf elements does wildcard match
+ """Usable for adding an ExceptionMatcher(s) into the exception tree.
+
+ The not leaf elements does wildcard match
"""
# in error_code just literal and '.' characters expected
if not isinstance(error_data, six.string_types):
@@ -227,6 +229,7 @@
@classmethod
def addResourceCleanUp(cls, function, *args, **kwargs):
"""Adds CleanUp callable, used by tearDownClass.
+
Recommended to a use (deep)copy on the mutable args.
"""
cls._sequence = cls._sequence + 1
@@ -242,6 +245,7 @@
def assertBotoError(self, excMatcher, callableObj,
*args, **kwargs):
"""Example usage:
+
self.assertBotoError(self.ec2_error_code.client.
InvalidKeyPair.Duplicate,
self.client.create_keypair,
@@ -258,7 +262,8 @@
@classmethod
def resource_cleanup(cls):
- """Calls the callables added by addResourceCleanUp,
+ """Calls the callables added by addResourceCleanUp
+
when you overwrite this function don't forget to call this too.
"""
fail_count = 0
@@ -302,10 +307,9 @@
@classmethod
def get_lfunction_gone(cls, obj):
- """If the object is instance of a well know type returns back with
- with the corresponding function otherwise it assumes the obj itself
- is the function.
- """
+ # NOTE: If the object is instance of a well know type returns back with
+ # with the corresponding function otherwise it assumes the obj itself
+ # is the function.
ec = cls.ec2_error_code
if isinstance(obj, ec2.instance.Instance):
colusure_matcher = ec.client.InvalidInstanceID.NotFound
@@ -489,6 +493,7 @@
@classmethod
def destroy_security_group_wait(cls, group):
"""Delete group.
+
Use just for teardown!
"""
# NOTE(afazekas): should wait/try until all related instance terminates
@@ -497,6 +502,7 @@
@classmethod
def destroy_volume_wait(cls, volume):
"""Delete volume, tries to detach first.
+
Use just for teardown!
"""
exc_num = 0
diff --git a/test-requirements.txt b/test-requirements.txt
index db2b2ce..5b01ea9 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -5,7 +5,7 @@
# needed for doc build
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
python-subunit>=0.0.18
-oslosphinx>=2.5.0 # Apache-2.0
+oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0
mox>=0.5.3
mock>=1.2
coverage>=3.6
diff --git a/tools/check_uuid.py b/tools/check_uuid.py
index e21c3d8..a71ad39 100755
--- a/tools/check_uuid.py
+++ b/tools/check_uuid.py
@@ -114,10 +114,8 @@
@staticmethod
def _get_idempotent_id(test_node):
- """
- Return key-value dict with all metadata from @test.idempotent_id
- decorators for test method
- """
+ # Return key-value dict with all metadata from @test.idempotent_id
+ # decorators for test method
idempotent_id = None
for decorator in test_node.decorator_list:
if (hasattr(decorator, 'func') and
@@ -264,8 +262,9 @@
return self._filter_tests(check_uuid_in_meta, tests)
def report_collisions(self, tests):
- """Reports collisions if there are any. Returns true if
- collisions exist.
+ """Reports collisions if there are any.
+
+ Returns true if collisions exist.
"""
uuids = {}
@@ -298,8 +297,9 @@
return bool(self._filter_tests(report, tests))
def report_untagged(self, tests):
- """Reports untagged tests if there are any. Returns true if
- untagged tests exist.
+ """Reports untagged tests if there are any.
+
+ Returns true if untagged tests exist.
"""
def report(module_name, test_name, tests):
error_str = "%s:%s\nmissing @test.idempotent_id('...')\n%s\n" % (
@@ -312,9 +312,7 @@
return bool(self._filter_tests(report, tests))
def fix_tests(self, tests):
- """Add uuids to all tests specified in tests and
- fix it in source files
- """
+ """Add uuids to all tests specified in tests and fix it"""
patcher = SourcePatcher()
for module_name in tests:
add_import_once = True
diff --git a/tools/colorizer.py b/tools/colorizer.py
index e7152f2..3f68a51 100755
--- a/tools/colorizer.py
+++ b/tools/colorizer.py
@@ -50,9 +50,9 @@
class _AnsiColorizer(object):
- """
- A colorizer is an object that loosely wraps around a stream, allowing
- callers to write text to the stream in a particular color.
+ """A colorizer is an object that loosely wraps around a stream
+
+ allowing callers to write text to the stream in a particular color.
Colorizer classes must implement C{supported()} and C{write(text, color)}.
"""
@@ -63,7 +63,8 @@
self.stream = stream
def supported(cls, stream=sys.stdout):
- """
+ """Check the current platform supports coloring terminal output
+
A class method that returns True if the current platform supports
coloring terminal output using this method. Returns False otherwise.
"""
@@ -86,8 +87,7 @@
supported = classmethod(supported)
def write(self, text, color):
- """
- Write the given text to the stream in the given color.
+ """Write the given text to the stream in the given color.
@param text: Text to be written to the stream.
@@ -98,9 +98,7 @@
class _Win32Colorizer(object):
- """
- See _AnsiColorizer docstring.
- """
+ """See _AnsiColorizer docstring."""
def __init__(self, stream):
import win32console
red, green, blue, bold = (win32console.FOREGROUND_RED,
@@ -146,9 +144,7 @@
class _NullColorizer(object):
- """
- See _AnsiColorizer docstring.
- """
+ """See _AnsiColorizer docstring."""
def __init__(self, stream):
self.stream = stream
diff --git a/tools/skip_tracker.py b/tools/skip_tracker.py
index 50f33eb..a47e217 100755
--- a/tools/skip_tracker.py
+++ b/tools/skip_tracker.py
@@ -40,7 +40,8 @@
def find_skips(start=TESTDIR):
- """
+ """Find skipped tests
+
Returns a list of tuples (method, bug) that represent
test methods that have been decorated to skip because of
a particular bug.
@@ -67,9 +68,7 @@
def find_skips_in_file(path):
- """
- Return the skip tuples in a test file
- """
+ """Return the skip tuples in a test file"""
BUG_RE = re.compile(r'\s*@.*skip_because\(bug=[\'"](\d+)[\'"]')
DEF_RE = re.compile(r'\s*def (\w+)\(')
bug_found = False
diff --git a/tox.ini b/tox.ini
index 3250344..892cfed 100644
--- a/tox.ini
+++ b/tox.ini
@@ -24,7 +24,7 @@
bash tools/pretty_tox.sh '{posargs}'
[testenv:genconfig]
-commands = oslo-config-generator --config-file tools/config/config-generator.tempest.conf
+commands = oslo-config-generator --config-file etc/config-generator.tempest.conf
[testenv:cover]
setenv = OS_TEST_PATH=./tempest/tests
@@ -129,6 +129,6 @@
# E123 skipped because it is ignored by default in the default pep8
# E129 skipped because it is too limiting when combined with other rules
# Skipped because of new hacking 0.9: H405
-ignore = E125,E123,E129,H404,H405
+ignore = E125,E123,E129
show-source = True
exclude = .git,.venv,.tox,dist,doc,openstack,*egg