Merge "use services decorator to enable telemetry test"
diff --git a/HACKING.rst b/HACKING.rst
index c776c49..45c35df 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -314,6 +314,39 @@
* Check written content in the instance booted from snapshot
"""
+Test Identification with Idempotent ID
+--------------------------------------
+
+Every function that provides a test must have an ``idempotent_id`` decorator
+that is a unique ``uuid-4`` instance. This ID is used to complement the fully
+qualified test name and track test funcionality through refactoring. The
+format of the metadata looks like::
+
+ @test.idempotent_id('585e934c-448e-43c4-acbf-d06a9b899997')
+ def test_list_servers_with_detail(self):
+ # The created server should be in the detailed list of all servers
+ ...
+
+Tempest includes a ``check_uuid.py`` tool that will test for the existence
+and uniqueness of idempotent_id metadata for every test. By default the
+tool runs against the Tempest package by calling::
+
+ python check_uuid.py
+
+It can be invoked against any test suite by passing a package name::
+
+ python check_uuid.py --package <package_name>
+
+Tests without an ``idempotent_id`` can be automatically fixed by running
+the command with the ``--fix`` flag, which will modify the source package
+by inserting randomly generated uuids for every test that does not have
+one::
+
+ python check_uuid.py --fix
+
+The ``check_uuid.py`` tool is used as part of the tempest gate job
+to ensure that all tests have an ``idempotent_id`` decorator.
+
Branchless Tempest Considerations
---------------------------------
diff --git a/README.rst b/README.rst
index af24569..d7063ba 100644
--- a/README.rst
+++ b/README.rst
@@ -107,7 +107,7 @@
----------
Tempest also has a set of unit tests which test the Tempest code itself. These
-tests can be run by specifing the test discovery path::
+tests can be run by specifying the test discovery path::
$> OS_TEST_PATH=./tempest/tests testr run --parallel
diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst
index 0805544..3e6013d 100644
--- a/doc/source/configuration.rst
+++ b/doc/source/configuration.rst
@@ -142,7 +142,7 @@
#. alt_password
#. alt_tenant_name
-And in the auth secion:
+And in the auth section:
#. allow_tenant_isolation = False
#. comment out 'test_accounts_file' or keep it as empty
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index e9e5b2e..07ee026 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -72,14 +72,11 @@
#logging_exception_prefix = %(asctime)s.%(msecs)03d %(process)d ERROR %(name)s %(instance)s
# List of logger=LEVEL pairs. (list value)
-#default_log_levels = amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,suds=INFO,oslo.messaging=INFO,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN,urllib3.connectionpool=WARN,websocket=WARN,requests.packages.urllib3.util.retry=WARN,urllib3.util.retry=WARN,keystonemiddleware=WARN,routes.middleware=WARN,stevedore=WARN
+#default_log_levels = amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,suds=INFO,oslo.messaging=INFO,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN,urllib3.connectionpool=WARN,websocket=WARN,requests.packages.urllib3.util.retry=WARN,urllib3.util.retry=WARN,keystonemiddleware=WARN,routes.middleware=WARN,stevedore=WARN,taskflow=WARN
# Enables or disables publication of error events. (boolean value)
#publish_errors = false
-# Enables or disables fatal status of deprecations. (boolean value)
-#fatal_deprecations = false
-
# The format for an instance that is passed with the log message.
# (string value)
#instance_format = "[instance: %(uuid)s] "
@@ -91,6 +88,15 @@
# Enables or disables fatal status of deprecations. (boolean value)
#fatal_deprecations = false
+#
+# From tempest.config
+#
+
+# Prefix to be added when generating the name for test resources. It
+# can be used to discover all resources associated with a specific
+# test run when running tempest on a real-life cloud (string value)
+#resources_prefix = tempest
+
[auth]
@@ -117,10 +123,10 @@
# Roles to assign to all users created by tempest (list value)
#tempest_roles =
-# Only applicable when identity.auth_version is v3.Domain within which
-# isolated credentials are provisioned.The default "None" means that
-# the domain from theadmin user is used instead. (string value)
-#tenant_isolation_domain_name = <None>
+# Default domain used when getting v3 credentials. This is the name
+# keystone uses for v2 compatibility. (string value)
+# Deprecated group/name - [auth]/tenant_isolation_domain_name
+#default_credentials_domain_name = Default
# If allow_tenant_isolation is set to True and Neutron is enabled
# Tempest will try to create a useable network, subnet, and router
@@ -284,18 +290,10 @@
# (integer value)
#ping_count = 1
-# Timeout in seconds to wait for authentication to succeed. (integer
-# value)
-#ssh_timeout = 300
-
# Additional wait time for clean state, when there is no OS-EXT-STS
# extension available (integer value)
#ready_wait = 0
-# Timeout in seconds to wait for output from ssh channel. (integer
-# value)
-#ssh_channel_timeout = 60
-
# Name of the fixed network that is visible to all test tenants. If
# multiple networks are available for a tenant this is the network
# which will be used for creating servers if tempest does not create a
@@ -307,9 +305,6 @@
# use_floatingip_for_ssh=true or run_validation=false. (string value)
#network_for_ssh = public
-# IP version used for SSH connections. (integer value)
-#ip_version_for_ssh = 4
-
# Does SSH use Floating IPs? (boolean value)
#use_floatingip_for_ssh = true
@@ -431,6 +426,17 @@
# value)
#preserve_ports = false
+# Does the test environment support attaching an encrypted volume to a
+# running server instance? This may depend on the combination of
+# compute_driver in nova and the volume_driver(s) in cinder. (boolean
+# value)
+#attach_encrypted_volume = true
+
+# Does the test environment support creating instances with multiple
+# ports on the same network? This is only valid when using Neutron.
+# (boolean value)
+#allow_duplicate_networks = false
+
[dashboard]
@@ -1126,6 +1132,7 @@
#auth_method = keypair
# Default IP version for ssh connections. (integer value)
+# Deprecated group/name - [compute]/ip_version_for_ssh
#ip_version_for_ssh = 4
# Timeout in seconds to wait for ping to succeed. (integer value)
@@ -1133,9 +1140,11 @@
# Timeout in seconds to wait for the TCP connection to be successful.
# (integer value)
+# Deprecated group/name - [compute]/ssh_channel_timeout
#connect_timeout = 60
# Timeout in seconds to wait for the ssh banner. (integer value)
+# Deprecated group/name - [compute]/ssh_timeout
#ssh_timeout = 300
diff --git a/openstack-common.conf b/openstack-common.conf
index 1920295..16ba6a7 100644
--- a/openstack-common.conf
+++ b/openstack-common.conf
@@ -3,6 +3,8 @@
# The list of modules to copy from openstack-common
module=install_venv_common
module=versionutils
+module=with_venv
+module=install_venv
# The base module to hold the copy of openstack.common
base=tempest
diff --git a/requirements.txt b/requirements.txt
index 60dee97..415eaa5 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,7 +1,8 @@
# 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,>=0.11
+pbr<2.0,>=1.3
+cliff>=1.13.0 # Apache-2.0
anyjson>=0.3.3
httplib2>=0.7.5
jsonschema!=2.5.0,<3.0.0,>=2.0.0
@@ -10,16 +11,17 @@
paramiko>=1.13.0
netaddr>=0.7.12
testrepository>=0.0.18
-pyOpenSSL>=0.11
-oslo.concurrency>=2.1.0 # Apache-2.0
+pyOpenSSL>=0.14
+oslo.concurrency>=2.3.0 # Apache-2.0
oslo.config>=1.11.0 # Apache-2.0
oslo.i18n>=1.5.0 # Apache-2.0
-oslo.log>=1.2.0 # Apache-2.0
+oslo.log>=1.6.0 # Apache-2.0
oslo.serialization>=1.4.0 # Apache-2.0
-oslo.utils>=1.6.0 # Apache-2.0
+oslo.utils>=1.9.0 # Apache-2.0
six>=1.9.0
iso8601>=0.1.9
-fixtures>=0.3.14
+fixtures>=1.3.1
testscenarios>=0.4
-tempest-lib>=0.5.0
+tempest-lib>=0.6.1
PyYAML>=3.1.0
+stevedore>=1.5.0 # Apache-2.0
diff --git a/run_tempest.sh b/run_tempest.sh
index 5a9b742..0f32045 100755
--- a/run_tempest.sh
+++ b/run_tempest.sh
@@ -20,7 +20,7 @@
}
testrargs=""
-venv=.venv
+venv=${VENV:-.venv}
with_venv=tools/with_venv.sh
serial=0
always_venv=0
diff --git a/run_tests.sh b/run_tests.sh
index 971f89b..9a158e4 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -19,7 +19,7 @@
testrargs=""
just_pep8=0
-venv=.venv
+venv=${VENV:-.venv}
with_venv=tools/with_venv.sh
serial=0
always_venv=0
diff --git a/setup.cfg b/setup.cfg
index 3a14bba..f28c481 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -18,6 +18,12 @@
Programming Language :: Python :: 3
Programming Language :: Python :: 3.4
+[files]
+packages =
+ tempest
+data_files =
+ /etc/tempest = etc/*
+
[entry_points]
console_scripts =
verify-tempest-config = tempest.cmd.verify_tempest_config:main
@@ -25,7 +31,9 @@
run-tempest-stress = tempest.cmd.run_stress:main
tempest-cleanup = tempest.cmd.cleanup:main
tempest-account-generator = tempest.cmd.account_generator:main
-
+ tempest = tempest.cmd.main:main
+tempest.cm =
+ init = tempest.cmd.init:TempestInit
oslo.config.opts =
tempest.config = tempest.config:list_opts
diff --git a/setup.py b/setup.py
index 056c16c..d8080d0 100644
--- a/setup.py
+++ b/setup.py
@@ -25,5 +25,5 @@
pass
setuptools.setup(
- setup_requires=['pbr'],
+ setup_requires=['pbr>=1.3'],
pbr=True)
diff --git a/tempest/api/baremetal/admin/base.py b/tempest/api/baremetal/admin/base.py
index 0b5d7d9..d7d2efe 100644
--- a/tempest/api/baremetal/admin/base.py
+++ b/tempest/api/baremetal/admin/base.py
@@ -12,9 +12,9 @@
import functools
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/baremetal/admin/test_chassis.py b/tempest/api/baremetal/admin/test_chassis.py
index 5ad05cc..29fc64c 100644
--- a/tempest/api/baremetal/admin/test_chassis.py
+++ b/tempest/api/baremetal/admin/test_chassis.py
@@ -12,10 +12,10 @@
# under the License.
import six
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.baremetal.admin import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/baremetal/admin/test_nodes.py b/tempest/api/baremetal/admin/test_nodes.py
index 6b963c7..4830dcd 100644
--- a/tempest/api/baremetal/admin/test_nodes.py
+++ b/tempest/api/baremetal/admin/test_nodes.py
@@ -11,10 +11,10 @@
# under the License.
import six
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.baremetal.admin import base
+from tempest.common.utils import data_utils
from tempest.common import waiters
from tempest import test
diff --git a/tempest/api/baremetal/admin/test_ports.py b/tempest/api/baremetal/admin/test_ports.py
index ece4471..5eaf641 100644
--- a/tempest/api/baremetal/admin/test_ports.py
+++ b/tempest/api/baremetal/admin/test_ports.py
@@ -11,11 +11,11 @@
# under the License.
import six
-from tempest_lib.common.utils import data_utils
from tempest_lib import decorators
from tempest_lib import exceptions as lib_exc
from tempest.api.baremetal.admin import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/baremetal/admin/test_ports_negative.py b/tempest/api/baremetal/admin/test_ports_negative.py
index 3d80ee4..610758a 100644
--- a/tempest/api/baremetal/admin/test_ports_negative.py
+++ b/tempest/api/baremetal/admin/test_ports_negative.py
@@ -10,10 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.baremetal.admin import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/compute/admin/test_agents.py b/tempest/api/compute/admin/test_agents.py
index c9a73c7..d9a1ee5 100644
--- a/tempest/api/compute/admin/test_agents.py
+++ b/tempest/api/compute/admin/test_agents.py
@@ -13,10 +13,10 @@
# under the License.
from oslo_log import log
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
LOG = log.getLogger(__name__)
@@ -109,8 +109,7 @@
self.addCleanup(self.client.delete_agent, agent_xen['agent_id'])
agent_id_xen = agent_xen['agent_id']
- params_filter = {'hypervisor': agent_xen['hypervisor']}
- agents = self.client.list_agents(params_filter)
+ agents = self.client.list_agents(hypervisor=agent_xen['hypervisor'])
self.assertTrue(len(agents) > 0, 'Cannot get any agents.(%s)' % agents)
self.assertIn(agent_id_xen, map(lambda x: x['agent_id'], agents))
self.assertNotIn(self.agent_id, map(lambda x: x['agent_id'], agents))
diff --git a/tempest/api/compute/admin/test_aggregates.py b/tempest/api/compute/admin/test_aggregates.py
index 35a6479..9334fb6 100644
--- a/tempest/api/compute/admin/test_aggregates.py
+++ b/tempest/api/compute/admin/test_aggregates.py
@@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
from tempest.common import tempest_fixtures as fixtures
+from tempest.common.utils import data_utils
from tempest import test
@@ -106,7 +106,7 @@
# set the metadata of the aggregate
meta = {"key": "value"}
- body = self.client.set_metadata(aggregate['id'], meta)
+ body = self.client.set_metadata(aggregate['id'], metadata=meta)
self.assertEqual(meta, body["metadata"])
# verify the metadata has been set
@@ -130,9 +130,10 @@
new_aggregate_name = aggregate_name + '_new'
new_az_name = az_name + '_new'
- resp_aggregate = self.client.update_aggregate(aggregate_id,
- new_aggregate_name,
- new_az_name)
+ resp_aggregate = self.client.update_aggregate(
+ aggregate_id,
+ name=new_aggregate_name,
+ availability_zone=new_az_name)
self.assertEqual(new_aggregate_name, resp_aggregate['name'])
self.assertEqual(new_az_name, resp_aggregate['availability_zone'])
@@ -150,13 +151,13 @@
aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- body = self.client.add_host(aggregate['id'], self.host)
+ body = self.client.add_host(aggregate['id'], host=self.host)
self.assertEqual(aggregate_name, body['name'])
self.assertEqual(aggregate['availability_zone'],
body['availability_zone'])
self.assertIn(self.host, body['hosts'])
- body = self.client.remove_host(aggregate['id'], self.host)
+ body = self.client.remove_host(aggregate['id'], host=self.host)
self.assertEqual(aggregate_name, body['name'])
self.assertEqual(aggregate['availability_zone'],
body['availability_zone'])
@@ -169,8 +170,9 @@
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- self.client.add_host(aggregate['id'], self.host)
- self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
+ self.client.add_host(aggregate['id'], host=self.host)
+ self.addCleanup(self.client.remove_host, aggregate['id'],
+ host=self.host)
aggregates = self.client.list_aggregates()
aggs = filter(lambda x: x['id'] == aggregate['id'], aggregates)
@@ -187,8 +189,9 @@
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- self.client.add_host(aggregate['id'], self.host)
- self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
+ self.client.add_host(aggregate['id'], host=self.host)
+ self.addCleanup(self.client.remove_host, aggregate['id'],
+ host=self.host)
body = self.client.show_aggregate(aggregate['id'])
self.assertEqual(aggregate_name, body['name'])
@@ -204,12 +207,13 @@
aggregate = self.client.create_aggregate(
name=aggregate_name, availability_zone=az_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- self.client.add_host(aggregate['id'], self.host)
- self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
+ self.client.add_host(aggregate['id'], host=self.host)
+ self.addCleanup(self.client.remove_host, aggregate['id'],
+ host=self.host)
server_name = data_utils.rand_name('test_server')
admin_servers_client = self.os_adm.servers_client
server = self.create_test_server(name=server_name,
availability_zone=az_name,
wait_until='ACTIVE')
- body = admin_servers_client.get_server(server['id'])
+ body = admin_servers_client.show_server(server['id'])
self.assertEqual(self.host, body[self._host_key])
diff --git a/tempest/api/compute/admin/test_aggregates_negative.py b/tempest/api/compute/admin/test_aggregates_negative.py
index 6942fdb..231c88f 100644
--- a/tempest/api/compute/admin/test_aggregates_negative.py
+++ b/tempest/api/compute/admin/test_aggregates_negative.py
@@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
from tempest.common import tempest_fixtures as fixtures
+from tempest.common.utils import data_utils
from tempest import test
@@ -143,7 +143,7 @@
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
self.assertRaises(lib_exc.NotFound, self.client.add_host,
- aggregate['id'], non_exist_host)
+ aggregate['id'], host=non_exist_host)
@test.attr(type=['negative'])
@test.idempotent_id('7324c334-bd13-4c93-8521-5877322c3d51')
@@ -155,7 +155,7 @@
self.assertRaises(lib_exc.Forbidden,
self.user_client.add_host,
- aggregate['id'], self.host)
+ aggregate['id'], host=self.host)
@test.attr(type=['negative'])
@test.idempotent_id('19dd44e1-c435-4ee1-a402-88c4f90b5950')
@@ -165,11 +165,12 @@
aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- self.client.add_host(aggregate['id'], self.host)
- self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
+ self.client.add_host(aggregate['id'], host=self.host)
+ self.addCleanup(self.client.remove_host, aggregate['id'],
+ host=self.host)
self.assertRaises(lib_exc.Conflict, self.client.add_host,
- aggregate['id'], self.host)
+ aggregate['id'], host=self.host)
@test.attr(type=['negative'])
@test.idempotent_id('7a53af20-137a-4e44-a4ae-e19260e626d9')
@@ -179,12 +180,13 @@
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- self.client.add_host(aggregate['id'], self.host)
- self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
+ self.client.add_host(aggregate['id'], host=self.host)
+ self.addCleanup(self.client.remove_host, aggregate['id'],
+ host=self.host)
self.assertRaises(lib_exc.Forbidden,
self.user_client.remove_host,
- aggregate['id'], self.host)
+ aggregate['id'], host=self.host)
@test.attr(type=['negative'])
@test.idempotent_id('95d6a6fa-8da9-4426-84d0-eec0329f2e4d')
@@ -195,4 +197,4 @@
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
self.assertRaises(lib_exc.NotFound, self.client.remove_host,
- aggregate['id'], non_exist_host)
+ aggregate['id'], host=non_exist_host)
diff --git a/tempest/api/compute/admin/test_fixed_ips.py b/tempest/api/compute/admin/test_fixed_ips.py
index a65fda6..3e20b46 100644
--- a/tempest/api/compute/admin/test_fixed_ips.py
+++ b/tempest/api/compute/admin/test_fixed_ips.py
@@ -38,7 +38,7 @@
def resource_setup(cls):
super(FixedIPsTestJson, cls).resource_setup()
server = cls.create_test_server(wait_until='ACTIVE')
- server = cls.servers_client.get_server(server['id'])
+ server = cls.servers_client.show_server(server['id'])
for ip_set in server['addresses']:
for ip in server['addresses'][ip_set]:
if ip['OS-EXT-IPS:type'] == 'fixed':
@@ -56,11 +56,9 @@
@test.idempotent_id('5485077b-7e46-4cec-b402-91dc3173433b')
@test.services('network')
def test_set_reserve(self):
- body = {"reserve": "None"}
- self.client.reserve_fixed_ip(self.ip, body)
+ self.client.reserve_fixed_ip(self.ip, reserve="None")
@test.idempotent_id('7476e322-b9ff-4710-bf82-49d51bac6e2e')
@test.services('network')
def test_set_unreserve(self):
- body = {"unreserve": "None"}
- self.client.reserve_fixed_ip(self.ip, body)
+ self.client.reserve_fixed_ip(self.ip, unreserve="None")
diff --git a/tempest/api/compute/admin/test_fixed_ips_negative.py b/tempest/api/compute/admin/test_fixed_ips_negative.py
index 35c719d..e67936c 100644
--- a/tempest/api/compute/admin/test_fixed_ips_negative.py
+++ b/tempest/api/compute/admin/test_fixed_ips_negative.py
@@ -40,7 +40,7 @@
def resource_setup(cls):
super(FixedIPsNegativeTestJson, cls).resource_setup()
server = cls.create_test_server(wait_until='ACTIVE')
- server = cls.servers_client.get_server(server['id'])
+ server = cls.servers_client.show_server(server['id'])
for ip_set in server['addresses']:
for ip in server['addresses'][ip_set]:
if ip['OS-EXT-IPS:type'] == 'fixed':
@@ -60,19 +60,17 @@
@test.idempotent_id('ce60042c-fa60-4836-8d43-1c8e3359dc47')
@test.services('network')
def test_set_reserve_with_non_admin_user(self):
- body = {"reserve": "None"}
self.assertRaises(lib_exc.Forbidden,
self.non_admin_client.reserve_fixed_ip,
- self.ip, body)
+ self.ip, reserve="None")
@test.attr(type=['negative'])
@test.idempotent_id('f1f7a35b-0390-48c5-9803-5f27461439db')
@test.services('network')
def test_set_unreserve_with_non_admin_user(self):
- body = {"unreserve": "None"}
self.assertRaises(lib_exc.Forbidden,
self.non_admin_client.reserve_fixed_ip,
- self.ip, body)
+ self.ip, unreserve="None")
@test.attr(type=['negative'])
@test.idempotent_id('f51cf464-7fc5-4352-bc3e-e75cfa2cb717')
@@ -80,19 +78,17 @@
def test_set_reserve_with_invalid_ip(self):
# NOTE(maurosr): since this exercises the same code snippet, we do it
# only for reserve action
- body = {"reserve": "None"}
# NOTE(eliqiao): in Juno, the exception is NotFound, but in master, we
# change the error code to BadRequest, both exceptions should be
# accepted by tempest
self.assertRaises((lib_exc.NotFound, lib_exc.BadRequest),
self.client.reserve_fixed_ip,
- "my.invalid.ip", body)
+ "my.invalid.ip", reserve="None")
@test.attr(type=['negative'])
@test.idempotent_id('fd26ef50-f135-4232-9d32-281aab3f9176')
@test.services('network')
def test_fixed_ip_with_invalid_action(self):
- body = {"invalid_action": "None"}
self.assertRaises(lib_exc.BadRequest,
self.client.reserve_fixed_ip,
- self.ip, body)
+ self.ip, invalid_action="None")
diff --git a/tempest/api/compute/admin/test_flavors.py b/tempest/api/compute/admin/test_flavors.py
index d4b8311..364d080 100644
--- a/tempest/api/compute/admin/test_flavors.py
+++ b/tempest/api/compute/admin/test_flavors.py
@@ -15,10 +15,10 @@
import uuid
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/compute/admin/test_flavors_access.py b/tempest/api/compute/admin/test_flavors_access.py
index 4c743dc..2baa53e 100644
--- a/tempest/api/compute/admin/test_flavors_access.py
+++ b/tempest/api/compute/admin/test_flavors_access.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/compute/admin/test_flavors_access_negative.py b/tempest/api/compute/admin/test_flavors_access_negative.py
index be5e6cc..e5ae23b 100644
--- a/tempest/api/compute/admin/test_flavors_access_negative.py
+++ b/tempest/api/compute/admin/test_flavors_access_negative.py
@@ -15,10 +15,10 @@
import uuid
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/compute/admin/test_flavors_extra_specs.py b/tempest/api/compute/admin/test_flavors_extra_specs.py
index a14a61f..6866c1a 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
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 ba05c7f..8c5a103 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
@@ -14,10 +14,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/compute/admin/test_floating_ips_bulk.py b/tempest/api/compute/admin/test_floating_ips_bulk.py
index 5c45dd8..4ac1915 100644
--- a/tempest/api/compute/admin/test_floating_ips_bulk.py
+++ b/tempest/api/compute/admin/test_floating_ips_bulk.py
@@ -34,7 +34,7 @@
@classmethod
def setup_clients(cls):
super(FloatingIPsBulkAdminTestJSON, cls).setup_clients()
- cls.client = cls.os_adm.floating_ips_client
+ cls.client = cls.os_adm.floating_ips_bulk_client
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/compute/admin/test_hosts.py b/tempest/api/compute/admin/test_hosts.py
index 9fee2a1..0dadea5 100644
--- a/tempest/api/compute/admin/test_hosts.py
+++ b/tempest/api/compute/admin/test_hosts.py
@@ -38,9 +38,7 @@
self.useFixture(fixtures.LockFixture('availability_zone'))
hosts = self.client.list_hosts()
host = hosts[0]
- zone_name = host['zone']
- params = {'zone': zone_name}
- hosts = self.client.list_hosts(params)
+ hosts = self.client.list_hosts(zone=host['zone'])
self.assertTrue(len(hosts) >= 1)
self.assertIn(host, hosts)
@@ -48,16 +46,14 @@
def test_list_hosts_with_a_blank_zone(self):
# If send the request with a blank zone, the request will be successful
# and it will return all the hosts list
- params = {'zone': ''}
- hosts = self.client.list_hosts(params)
+ hosts = self.client.list_hosts(zone='')
self.assertNotEqual(0, len(hosts))
@test.idempotent_id('c6ddbadb-c94e-4500-b12f-8ffc43843ff8')
def test_list_hosts_with_nonexistent_zone(self):
# If send the request with a nonexistent zone, the request will be
# successful and no hosts will be retured
- params = {'zone': 'xxx'}
- hosts = self.client.list_hosts(params)
+ hosts = self.client.list_hosts(zone='xxx')
self.assertEqual(0, len(hosts))
@test.idempotent_id('38adbb12-aee2-4498-8aec-329c72423aa4')
diff --git a/tempest/api/compute/admin/test_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py
index 930d686..b2d2a04 100644
--- a/tempest/api/compute/admin/test_hosts_negative.py
+++ b/tempest/api/compute/admin/test_hosts_negative.py
@@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/compute/admin/test_hypervisor_negative.py b/tempest/api/compute/admin/test_hypervisor_negative.py
index a5c2f0d..701b4bb 100644
--- a/tempest/api/compute/admin/test_hypervisor_negative.py
+++ b/tempest/api/compute/admin/test_hypervisor_negative.py
@@ -15,10 +15,10 @@
import uuid
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/compute/admin/test_live_migration.py b/tempest/api/compute/admin/test_live_migration.py
index a03439a..6ffa4e9 100644
--- a/tempest/api/compute/admin/test_live_migration.py
+++ b/tempest/api/compute/admin/test_live_migration.py
@@ -17,6 +17,7 @@
import testtools
from tempest.api.compute import base
+from tempest.common import waiters
from tempest import config
from tempest import test
@@ -47,7 +48,7 @@
]
def _get_server_details(self, server_id):
- body = self.admin_servers_client.get_server(server_id)
+ body = self.admin_servers_client.show_server(server_id)
return body
def _get_host_for_server(self, server_id):
@@ -103,10 +104,11 @@
if state == 'PAUSED':
self.admin_servers_client.pause_server(server_id)
- self.admin_servers_client.wait_for_server_status(server_id, state)
+ waiters.wait_for_server_status(self.admin_servers_client,
+ server_id, state)
self._migrate_server_to(server_id, target_host)
- self.servers_client.wait_for_server_status(server_id, state)
+ waiters.wait_for_server_status(self.servers_client, server_id, state)
self.assertEqual(target_host, self._get_host_for_server(server_id))
@test.idempotent_id('1dce86b8-eb04-4c03-a9d8-9c1dc3ee0c7b')
@@ -156,5 +158,6 @@
self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
self._migrate_server_to(server_id, target_host)
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client,
+ server_id, 'ACTIVE')
self.assertEqual(target_host, self._get_host_for_server(server_id))
diff --git a/tempest/api/compute/admin/test_migrations.py b/tempest/api/compute/admin/test_migrations.py
index 5434d93..5af7406 100644
--- a/tempest/api/compute/admin/test_migrations.py
+++ b/tempest/api/compute/admin/test_migrations.py
@@ -15,6 +15,7 @@
import testtools
from tempest.api.compute import base
+from tempest.common import waiters
from tempest import config
from tempest import test
@@ -42,9 +43,11 @@
server_id = server['id']
self.servers_client.resize(server_id, self.flavor_ref_alt)
- self.servers_client.wait_for_server_status(server_id, 'VERIFY_RESIZE')
+ waiters.wait_for_server_status(self.servers_client,
+ server_id, 'VERIFY_RESIZE')
self.servers_client.confirm_resize(server_id)
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client,
+ server_id, 'ACTIVE')
body = self.client.list_migrations()
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index 029e578..47bdfa6 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -15,11 +15,11 @@
from oslo_log import log as logging
import six
-from tempest_lib.common.utils import data_utils
from testtools import matchers
from tempest.api.compute import base
from tempest.common import tempest_fixtures as fixtures
+from tempest.common.utils import data_utils
from tempest import test
LOG = logging.getLogger(__name__)
diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py
index c450a1d..33313be 100644
--- a/tempest/api/compute/admin/test_quotas_negative.py
+++ b/tempest/api/compute/admin/test_quotas_negative.py
@@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import decorators
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
@@ -32,6 +32,7 @@
cls.client = cls.os.quotas_client
cls.adm_client = cls.os_adm.quotas_client
cls.sg_client = cls.security_groups_client
+ cls.sgr_client = cls.security_group_rules_client
@classmethod
def resource_setup(cls):
@@ -109,7 +110,10 @@
quota_set = self.adm_client.show_quota_set(self.demo_tenant_id)
default_sg_quota = quota_set['security_groups']
- sg_quota = 0 # Set the quota to zero to conserve resources
+
+ # Set the quota to number of used security groups
+ sg_quota = self.limits_client.show_limits()['absolute'][
+ 'totalSecurityGroupsUsed']
quota_set =\
self.adm_client.update_quota_set(self.demo_tenant_id,
@@ -164,5 +168,5 @@
# A 403 Forbidden or 413 Overlimit (old behaviour) exception
# will be raised when out of quota
self.assertRaises((lib_exc.OverLimit, lib_exc.Forbidden),
- self.sg_client.create_security_group_rule,
+ self.sgr_client.create_security_group_rule,
secgroup_id, ip_protocol, 1025, 1025)
diff --git a/tempest/api/compute/admin/test_security_group_default_rules.py b/tempest/api/compute/admin/test_security_group_default_rules.py
index c1fe18c..13d6cc0 100644
--- a/tempest/api/compute/admin/test_security_group_default_rules.py
+++ b/tempest/api/compute/admin/test_security_group_default_rules.py
@@ -64,7 +64,7 @@
# Delete Security Group default rule
self.adm_client.delete_security_group_default_rule(rule['id'])
self.assertRaises(lib_exc.NotFound,
- self.adm_client.get_security_group_default_rule,
+ self.adm_client.show_security_group_default_rule,
rule['id'])
@test.idempotent_id('4d752e0a-33a1-4c3a-b498-ff8667ca22e5')
@@ -125,6 +125,6 @@
cidr)
self.addCleanup(self.adm_client.delete_security_group_default_rule,
rule['id'])
- fetched_rule = self.adm_client.get_security_group_default_rule(
+ fetched_rule = self.adm_client.show_security_group_default_rule(
rule['id'])
self.assertEqual(rule, fetched_rule)
diff --git a/tempest/api/compute/admin/test_security_groups.py b/tempest/api/compute/admin/test_security_groups.py
index d8679e0..ff87a4f 100644
--- a/tempest/api/compute/admin/test_security_groups.py
+++ b/tempest/api/compute/admin/test_security_groups.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
import testtools
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
@@ -69,8 +69,7 @@
security_group_list.append(adm_securitygroup)
# Fetch all security groups based on 'all_tenants' search filter
- param = {'all_tenants': 'true'}
- fetched_list = self.adm_client.list_security_groups(params=param)
+ fetched_list = self.adm_client.list_security_groups(all_tenants='true')
sec_group_id_list = map(lambda sg: sg['id'], fetched_list)
# Now check if all created Security Groups are present in fetched list
for sec_group in security_group_list:
@@ -78,7 +77,7 @@
# Fetch all security groups for non-admin user with 'all_tenants'
# search filter
- fetched_list = self.client.list_security_groups(params=param)
+ fetched_list = self.client.list_security_groups(all_tenants='true')
# Now check if all created Security Groups are present in fetched list
for sec_group in fetched_list:
self.assertEqual(sec_group['tenant_id'], client_tenant_id,
diff --git a/tempest/api/compute/admin/test_servers.py b/tempest/api/compute/admin/test_servers.py
index 9c53e71..1982eda 100644
--- a/tempest/api/compute/admin/test_servers.py
+++ b/tempest/api/compute/admin/test_servers.py
@@ -12,11 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import decorators
from tempest.api.compute import base
from tempest.common import fixed_network
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import test
@@ -52,7 +53,7 @@
@test.idempotent_id('51717b38-bdc1-458b-b636-1cf82d99f62f')
def test_list_servers_by_admin(self):
# Listing servers by admin user returns empty list by default
- body = self.client.list_servers_with_detail()
+ body = self.client.list_servers(detail=True)
servers = body['servers']
self.assertEqual([], servers)
@@ -61,11 +62,11 @@
# Filter the list of servers by server error status
params = {'status': 'error'}
self.client.reset_state(self.s1_id, state='error')
- body = self.non_admin_client.list_servers(params)
+ body = self.non_admin_client.list_servers(**params)
# Reset server's state to 'active'
self.client.reset_state(self.s1_id, state='active')
# Verify server's state
- server = self.client.get_server(self.s1_id)
+ server = self.client.show_server(self.s1_id)
self.assertEqual(server['status'], 'ACTIVE')
servers = body['servers']
# Verify error server in list result
@@ -77,7 +78,7 @@
# Listing servers by admin user with all tenants parameter
# Here should be listed all servers
params = {'all_tenants': ''}
- body = self.client.list_servers_with_detail(params)
+ body = self.client.list_servers(detail=True, **params)
servers = body['servers']
servers_name = map(lambda x: x['name'], servers)
@@ -91,14 +92,14 @@
# List the primary tenant but get nothing due to odd specified behavior
tenant_id = self.non_admin_client.tenant_id
params = {'tenant_id': tenant_id}
- body = self.client.list_servers_with_detail(params)
+ body = self.client.list_servers(detail=True, **params)
servers = body['servers']
self.assertEqual([], servers)
# List the admin tenant which has no servers
admin_tenant_id = self.client.tenant_id
params = {'all_tenants': '', 'tenant_id': admin_tenant_id}
- body = self.client.list_servers_with_detail(params)
+ body = self.client.list_servers(detail=True, **params)
servers = body['servers']
self.assertEqual([], servers)
@@ -113,15 +114,16 @@
test_server = self.client.create_server(name, image_id, flavor,
**network_kwargs)
self.addCleanup(self.client.delete_server, test_server['id'])
- self.client.wait_for_server_status(test_server['id'], 'ACTIVE')
- server = self.client.get_server(test_server['id'])
+ waiters.wait_for_server_status(self.client,
+ test_server['id'], 'ACTIVE')
+ server = self.client.show_server(test_server['id'])
self.assertEqual(server['status'], 'ACTIVE')
hostname = server[self._host_key]
params = {'host': hostname}
- body = self.client.list_servers(params)
+ body = self.client.list_servers(**params)
servers = body['servers']
nonexistent_params = {'host': 'nonexistent_host'}
- nonexistent_body = self.client.list_servers(nonexistent_params)
+ nonexistent_body = self.client.list_servers(**nonexistent_params)
nonexistent_servers = nonexistent_body['servers']
self.assertIn(test_server['id'], map(lambda x: x['id'], servers))
self.assertNotIn(test_server['id'],
@@ -133,14 +135,14 @@
self.client.reset_state(self.s1_id)
# Verify server's state
- server = self.client.get_server(self.s1_id)
+ server = self.client.show_server(self.s1_id)
self.assertEqual(server['status'], 'ERROR')
# Reset server's state to 'active'
self.client.reset_state(self.s1_id, state='active')
# Verify server's state
- server = self.client.get_server(self.s1_id)
+ server = self.client.show_server(self.s1_id)
self.assertEqual(server['status'], 'ACTIVE')
@decorators.skip_because(bug="1240043")
@@ -163,7 +165,7 @@
self.client.reset_state(self.s1_id, state='error')
rebuilt_server = self.non_admin_client.rebuild(
self.s1_id, self.image_ref_alt)
- self.addCleanup(self.non_admin_client.wait_for_server_status,
+ self.addCleanup(waiters.wait_for_server_status, self.non_admin_client,
self.s1_id, 'ACTIVE')
self.addCleanup(self.non_admin_client.rebuild, self.s1_id,
self.image_ref)
@@ -173,11 +175,11 @@
rebuilt_image_id = rebuilt_server['image']['id']
self.assertEqual(self.image_ref_alt, rebuilt_image_id)
self.assertEqual(self.flavor_ref, rebuilt_server['flavor']['id'])
- self.non_admin_client.wait_for_server_status(rebuilt_server['id'],
- 'ACTIVE',
- raise_on_error=False)
+ waiters.wait_for_server_status(self.non_admin_client,
+ rebuilt_server['id'], 'ACTIVE',
+ raise_on_error=False)
# Verify the server properties after rebuilding
- server = self.non_admin_client.get_server(rebuilt_server['id'])
+ server = self.non_admin_client.show_server(rebuilt_server['id'])
rebuilt_image_id = server['image']['id']
self.assertEqual(self.image_ref_alt, rebuilt_image_id)
diff --git a/tempest/api/compute/admin/test_servers_negative.py b/tempest/api/compute/admin/test_servers_negative.py
index cda4bc4..b93aaca 100644
--- a/tempest/api/compute/admin/test_servers_negative.py
+++ b/tempest/api/compute/admin/test_servers_negative.py
@@ -14,12 +14,13 @@
import uuid
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
import testtools
from tempest.api.compute import base
from tempest.common import tempest_fixtures as fixtures
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import config
from tempest import test
@@ -151,7 +152,8 @@
server_id = server['id']
# suspend the server.
self.client.suspend_server(server_id)
- self.client.wait_for_server_status(server_id, 'SUSPENDED')
+ waiters.wait_for_server_status(self.client,
+ server_id, 'SUSPENDED')
# migrate an suspended server should fail
self.assertRaises(lib_exc.Conflict,
self.client.migrate_server,
diff --git a/tempest/api/compute/admin/test_services.py b/tempest/api/compute/admin/test_services.py
index dd3e78c..db22925 100644
--- a/tempest/api/compute/admin/test_services.py
+++ b/tempest/api/compute/admin/test_services.py
@@ -37,8 +37,7 @@
@test.idempotent_id('f345b1ec-bc6e-4c38-a527-3ca2bc00bef5')
def test_get_service_by_service_binary_name(self):
binary_name = 'nova-compute'
- params = {'binary': binary_name}
- services = self.client.list_services(params)
+ services = self.client.list_services(binary=binary_name)
self.assertNotEqual(0, len(services))
for service in services:
self.assertEqual(binary_name, service['binary'])
@@ -49,9 +48,8 @@
host_name = services[0]['host']
services_on_host = [service for service in services if
service['host'] == host_name]
- params = {'host': host_name}
- services = self.client.list_services(params)
+ services = self.client.list_services(host=host_name)
# we could have a periodic job checkin between the 2 service
# lookups, so only compare binary lists.
@@ -67,9 +65,9 @@
services = self.client.list_services()
host_name = services[0]['host']
binary_name = services[0]['binary']
- params = {'host': host_name, 'binary': binary_name}
- services = self.client.list_services(params)
+ services = self.client.list_services(host=host_name,
+ binary=binary_name)
self.assertEqual(1, len(services))
self.assertEqual(host_name, services[0]['host'])
self.assertEqual(binary_name, services[0]['binary'])
diff --git a/tempest/api/compute/admin/test_services_negative.py b/tempest/api/compute/admin/test_services_negative.py
index 99f31c5..b9335c9 100644
--- a/tempest/api/compute/admin/test_services_negative.py
+++ b/tempest/api/compute/admin/test_services_negative.py
@@ -41,8 +41,7 @@
def test_get_service_by_invalid_params(self):
# return all services if send the request with invalid parameter
services = self.client.list_services()
- params = {'xxx': 'nova-compute'}
- services_xxx = self.client.list_services(params)
+ services_xxx = self.client.list_services(xxx='nova-compute')
self.assertEqual(len(services), len(services_xxx))
@test.attr(type=['negative'])
@@ -50,8 +49,7 @@
def test_get_service_by_invalid_service_and_valid_host(self):
services = self.client.list_services()
host_name = services[0]['host']
- params = {'host': host_name, 'binary': 'xxx'}
- services = self.client.list_services(params)
+ services = self.client.list_services(host=host_name, binary='xxx')
self.assertEqual(0, len(services))
@test.attr(type=['negative'])
@@ -59,6 +57,5 @@
def test_get_service_with_valid_service_and_invalid_host(self):
services = self.client.list_services()
binary_name = services[0]['binary']
- params = {'host': 'xxx', 'binary': binary_name}
- services = self.client.list_services(params)
+ services = self.client.list_services(host='xxx', binary=binary_name)
self.assertEqual(0, len(services))
diff --git a/tempest/api/compute/admin/test_simple_tenant_usage.py b/tempest/api/compute/admin/test_simple_tenant_usage.py
index 98b7c5f..204281c 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage.py
@@ -49,28 +49,22 @@
@test.idempotent_id('062c8ae9-9912-4249-8b51-e38d664e926e')
def test_list_usage_all_tenants(self):
# Get usage for all tenants
- params = {'start': self.start,
- 'end': self.end,
- 'detailed': int(bool(True))}
- tenant_usage = self.adm_client.list_tenant_usages(params)
+ tenant_usage = self.adm_client.list_tenant_usages(
+ start=self.start, end=self.end, detailed="1")
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
- params = {'start': self.start,
- 'end': self.end}
- tenant_usage = self.adm_client.get_tenant_usage(
- self.tenant_id, params)
+ tenant_usage = self.adm_client.show_tenant_usage(
+ self.tenant_id, start=self.start, end=self.end)
self.assertEqual(len(tenant_usage), 8)
@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
- params = {'start': self.start,
- 'end': self.end}
- tenant_usage = self.client.get_tenant_usage(
- self.tenant_id, params)
+ tenant_usage = self.client.show_tenant_usage(
+ self.tenant_id, start=self.start, end=self.end)
self.assertEqual(len(tenant_usage), 8)
diff --git a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
index 5a3c9a4..e9b4ad4 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
@@ -47,8 +47,8 @@
params = {'start': self.start,
'end': self.end}
self.assertRaises(lib_exc.NotFound,
- self.adm_client.get_tenant_usage,
- '', params)
+ self.adm_client.show_tenant_usage,
+ '', **params)
@test.attr(type=['negative'])
@test.idempotent_id('4079dd2a-9e8d-479f-869d-6fa985ce45b6')
@@ -57,8 +57,8 @@
params = {'start': self.end,
'end': self.start}
self.assertRaises(lib_exc.BadRequest,
- self.adm_client.get_tenant_usage,
- self.client.tenant_id, params)
+ self.adm_client.show_tenant_usage,
+ self.client.tenant_id, **params)
@test.attr(type=['negative'])
@test.idempotent_id('bbe6fe2c-15d8-404c-a0a2-44fad0ad5cc7')
@@ -66,6 +66,6 @@
# Get usage for all tenants with non admin user
params = {'start': self.start,
'end': self.end,
- 'detailed': int(bool(True))}
+ 'detailed': "1"}
self.assertRaises(lib_exc.Forbidden,
- self.client.list_tenant_usages, params)
+ self.client.list_tenant_usages, **params)
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index a1f6f99..33442b2 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -16,10 +16,11 @@
import time
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.common import compute
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import config
from tempest import exceptions
import tempest.test
@@ -56,11 +57,14 @@
def setup_clients(cls):
super(BaseComputeTest, 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.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
cls.quotas_client = cls.os.quotas_client
# NOTE(mriedem): os-quota-class-sets is v2 API only
@@ -141,8 +145,8 @@
"""
if getattr(cls, 'server_id', None) is not None:
try:
- cls.servers_client.wait_for_server_status(cls.server_id,
- 'ACTIVE')
+ waiters.wait_for_server_status(cls.servers_client,
+ cls.server_id, 'ACTIVE')
except Exception as exc:
LOG.exception(exc)
cls.servers_client.delete_server(cls.server_id)
@@ -182,7 +186,7 @@
LOG.debug('Clearing server groups: %s', ','.join(cls.server_groups))
for server_group_id in cls.server_groups:
try:
- cls.servers_client.delete_server_group(server_group_id)
+ cls.server_groups_client.delete_server_group(server_group_id)
except lib_exc.NotFound:
# The server-group may have already been deleted which is OK.
pass
@@ -230,7 +234,7 @@
name = data_utils.rand_name(cls.__name__ + "-Server-Group")
if policy is None:
policy = ['affinity']
- body = cls.servers_client.create_server_group(name, policy)
+ body = cls.server_groups_client.create_server_group(name, policy)
cls.server_groups.append(body['id'])
return body
@@ -263,8 +267,8 @@
@classmethod
def prepare_instance_network(cls):
- if (CONF.compute.ssh_auth_method != 'disabled' and
- CONF.compute.ssh_connect_method == 'floating'):
+ if (CONF.validation.auth_method != 'disabled' and
+ CONF.validation.connect_method == 'floating'):
cls.set_network_resources(network=True, subnet=True, router=True,
dhcp=True)
@@ -280,18 +284,18 @@
cls.images.append(image_id)
if 'wait_until' in kwargs:
- cls.images_client.wait_for_image_status(image_id,
- kwargs['wait_until'])
+ waiters.wait_for_image_status(cls.images_client,
+ image_id, kwargs['wait_until'])
image = cls.images_client.show_image(image_id)
if kwargs['wait_until'] == 'ACTIVE':
if kwargs.get('wait_for_server', True):
- cls.servers_client.wait_for_server_status(server_id,
- 'ACTIVE')
+ waiters.wait_for_server_status(cls.servers_client,
+ server_id, 'ACTIVE')
return image
@classmethod
- def rebuild_server(cls, server_id, **kwargs):
+ def rebuild_server(cls, server_id, validatable=False, **kwargs):
# Destroy an existing server and creates a new one
if server_id:
try:
@@ -299,7 +303,11 @@
cls.servers_client.wait_for_server_termination(server_id)
except Exception:
LOG.exception('Failed to delete server %s' % server_id)
- server = cls.create_test_server(wait_until='ACTIVE', **kwargs)
+
+ server = cls.create_test_server(
+ validatable,
+ wait_until='ACTIVE',
+ **kwargs)
cls.password = server['adminPass']
return server['id']
@@ -317,6 +325,21 @@
"""Deletes the given volume and waits for it to be gone."""
cls._delete_volume(cls.volumes_extensions_client, volume_id)
+ @classmethod
+ def get_server_ip(cls, server):
+ """Get the server fixed or floating IP.
+
+ For the floating IP, the address created by the validation resources
+ is returned.
+ For the fixed IP, the server is returned and the current mechanism of
+ address extraction in the remote_client is followed.
+ """
+ if CONF.validation.connect_method == 'floating':
+ ip_or_server = cls.validation_resources['floating_ip']['ip']
+ elif CONF.validation.connect_method == 'fixed':
+ ip_or_server = server
+ return ip_or_server
+
class BaseV2ComputeTest(BaseComputeTest):
_api_version = 2
diff --git a/tempest/api/compute/floating_ips/test_floating_ips_actions.py b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
index 093f16b..8bb4fac 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
@@ -13,10 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute.floating_ips import base
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import test
@@ -113,7 +114,8 @@
# Create server so as to use for Multiple association
new_name = data_utils.rand_name('floating_server')
body = self.create_test_server(name=new_name)
- self.servers_client.wait_for_server_status(body['id'], 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client,
+ body['id'], 'ACTIVE')
self.new_server_id = body['id']
self.addCleanup(self.servers_client.delete_server, self.new_server_id)
diff --git a/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py b/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py
index d22d334..c07af72 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py
@@ -15,10 +15,10 @@
import uuid
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute.floating_ips import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips.py b/tempest/api/compute/floating_ips/test_list_floating_ips.py
index ad52b8c..d26a5e5 100644
--- a/tempest/api/compute/floating_ips/test_list_floating_ips.py
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips.py
@@ -23,6 +23,7 @@
def setup_clients(cls):
super(FloatingIPDetailsTestJSON, cls).setup_clients()
cls.client = cls.floating_ips_client
+ cls.pools_client = cls.floating_ip_pools_client
@classmethod
def resource_setup(cls):
@@ -76,6 +77,6 @@
@test.services('network')
def test_list_floating_ip_pools(self):
# Positive test:Should return the list of floating IP Pools
- floating_ip_pools = self.client.list_floating_ip_pools()
+ floating_ip_pools = self.pools_client.list_floating_ip_pools()
self.assertNotEqual(0, len(floating_ip_pools),
"Expected floating IP Pools. Got zero.")
diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py b/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
index 05d3d05..75b6b55 100644
--- a/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
@@ -15,10 +15,10 @@
import uuid
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/compute/images/test_image_metadata.py b/tempest/api/compute/images/test_image_metadata.py
index 4e0ed97..ab82d91 100644
--- a/tempest/api/compute/images/test_image_metadata.py
+++ b/tempest/api/compute/images/test_image_metadata.py
@@ -15,9 +15,9 @@
import six
-from tempest_lib.common.utils import data_utils
-
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
@@ -53,7 +53,7 @@
cls.images.append(cls.image_id)
image_file = six.StringIO(('*' * 1024))
cls.glance_client.update_image(cls.image_id, data=image_file)
- cls.client.wait_for_image_status(cls.image_id, 'ACTIVE')
+ waiters.wait_for_image_status(cls.client, cls.image_id, 'ACTIVE')
def setUp(self):
super(ImagesMetadataTestJSON, self).setUp()
diff --git a/tempest/api/compute/images/test_image_metadata_negative.py b/tempest/api/compute/images/test_image_metadata_negative.py
index 0c1971a..0f02166 100644
--- a/tempest/api/compute/images/test_image_metadata_negative.py
+++ b/tempest/api/compute/images/test_image_metadata_negative.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/compute/images/test_images.py b/tempest/api/compute/images/test_images.py
index 2896f14..0324df2 100644
--- a/tempest/api/compute/images/test_images.py
+++ b/tempest/api/compute/images/test_images.py
@@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/compute/images/test_images_negative.py b/tempest/api/compute/images/test_images_negative.py
index 54a82e9..9721fa5 100644
--- a/tempest/api/compute/images/test_images_negative.py
+++ b/tempest/api/compute/images/test_images_negative.py
@@ -12,10 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
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
@@ -74,8 +75,8 @@
def test_create_image_from_stopped_server(self):
server = self.create_test_server(wait_until='ACTIVE')
self.servers_client.stop(server['id'])
- self.servers_client.wait_for_server_status(server['id'],
- 'SHUTOFF')
+ 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'],
diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index 1fd165b..40a781c 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -14,9 +14,10 @@
# under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
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
@@ -37,8 +38,8 @@
super(ImagesOneServerTestJSON, self).setUp()
# Check if the server is in a clean state after test
try:
- self.servers_client.wait_for_server_status(self.server_id,
- 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client,
+ self.server_id, 'ACTIVE')
except Exception:
LOG.exception('server %s timed out to become ACTIVE. rebuilding'
% self.server_id)
@@ -81,7 +82,7 @@
meta = {'image_type': 'test'}
body = self.client.create_image(self.server_id, name, meta)
image_id = data_utils.parse_image_id(body.response['location'])
- self.client.wait_for_image_status(image_id, 'ACTIVE')
+ waiters.wait_for_image_status(self.client, image_id, 'ACTIVE')
# Verify the image was created correctly
image = self.client.show_image(image_id)
diff --git a/tempest/api/compute/images/test_images_oneserver_negative.py b/tempest/api/compute/images/test_images_oneserver_negative.py
index 8a39d90..1a74e52 100644
--- a/tempest/api/compute/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/images/test_images_oneserver_negative.py
@@ -15,10 +15,11 @@
# under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
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
@@ -43,8 +44,8 @@
super(ImagesOneServerNegativeTestJSON, self).setUp()
# Check if the server is in a clean state after test
try:
- self.servers_client.wait_for_server_status(self.server_id,
- 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client, self.server_id,
+ 'ACTIVE')
except Exception:
LOG.exception('server %s timed out to become ACTIVE. rebuilding'
% self.server_id)
@@ -68,6 +69,11 @@
raise cls.skipException(skip_msg)
@classmethod
+ def setup_credentials(cls):
+ cls.prepare_instance_network()
+ super(ImagesOneServerNegativeTestJSON, cls).setup_credentials()
+
+ @classmethod
def setup_clients(cls):
super(ImagesOneServerNegativeTestJSON, cls).setup_clients()
cls.client = cls.images_client
diff --git a/tempest/api/compute/images/test_list_image_filters.py b/tempest/api/compute/images/test_list_image_filters.py
index 111398b..2c0ce59 100644
--- a/tempest/api/compute/images/test_list_image_filters.py
+++ b/tempest/api/compute/images/test_list_image_filters.py
@@ -17,10 +17,11 @@
from oslo_log import log as logging
import six
-from tempest_lib.common.utils import data_utils
import testtools
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
@@ -61,7 +62,7 @@
time.sleep(1)
image_file = six.StringIO(('*' * 1024))
cls.glance_client.update_image(image_id, data=image_file)
- cls.client.wait_for_image_status(image_id, 'ACTIVE')
+ waiters.wait_for_image_status(cls.client, image_id, 'ACTIVE')
body = cls.client.show_image(image_id)
return body
@@ -80,8 +81,8 @@
cls.server1 = cls.create_test_server()
cls.server2 = cls.create_test_server(wait_until='ACTIVE')
# NOTE(sdague) this is faster than doing the sync wait_util on both
- cls.servers_client.wait_for_server_status(cls.server1['id'],
- 'ACTIVE')
+ waiters.wait_for_server_status(cls.servers_client,
+ cls.server1['id'], 'ACTIVE')
# Create images to be used in the filter tests
cls.snapshot1 = cls.create_image_from_server(
diff --git a/tempest/api/compute/images/test_list_image_filters_negative.py b/tempest/api/compute/images/test_list_image_filters_negative.py
index 4110619..82062bd 100644
--- a/tempest/api/compute/images/test_list_image_filters_negative.py
+++ b/tempest/api/compute/images/test_list_image_filters_negative.py
@@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/compute/keypairs/test_keypairs.py b/tempest/api/compute/keypairs/test_keypairs.py
index 50ebdeb..45eaa97 100644
--- a/tempest/api/compute/keypairs/test_keypairs.py
+++ b/tempest/api/compute/keypairs/test_keypairs.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/compute/keypairs/test_keypairs_negative.py b/tempest/api/compute/keypairs/test_keypairs_negative.py
index 78db74e..54b07f0 100644
--- a/tempest/api/compute/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/keypairs/test_keypairs_negative.py
@@ -14,10 +14,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/compute/security_groups/test_security_group_rules.py b/tempest/api/compute/security_groups/test_security_group_rules.py
index ff3f25b..4596e1f 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules.py
@@ -25,7 +25,7 @@
@classmethod
def setup_clients(cls):
super(SecurityGroupRulesTestJSON, cls).setup_clients()
- cls.client = cls.security_groups_client
+ cls.client = cls.security_group_rules_client
@classmethod
def resource_setup(cls):
@@ -183,7 +183,7 @@
group_id=sg2_id)
# Delete group2
- self.client.delete_security_group(sg2_id)
+ self.security_groups_client.delete_security_group(sg2_id)
# Get rules of the Group1
rules = \
self.client.list_security_group_rules(sg1_id)
diff --git a/tempest/api/compute/security_groups/test_security_group_rules_negative.py b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
index c654172..e2a1034 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules_negative.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute.security_groups import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
@@ -36,6 +36,7 @@
def setup_clients(cls):
super(SecurityGroupRulesNegativeTestJSON, cls).setup_clients()
cls.client = cls.security_groups_client
+ cls.rules_client = cls.security_group_rules_client
@test.attr(type=['negative'])
@test.idempotent_id('1d507e98-7951-469b-82c3-23f1e6b8c254')
@@ -49,7 +50,7 @@
from_port = 22
to_port = 22
self.assertRaises(lib_exc.NotFound,
- self.client.create_security_group_rule,
+ self.rules_client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
@test.attr(type=['negative'])
@@ -64,7 +65,7 @@
from_port = 22
to_port = 22
self.assertRaises(lib_exc.BadRequest,
- self.client.create_security_group_rule,
+ self.rules_client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
@test.attr(type=['negative'])
@@ -81,14 +82,15 @@
to_port = 22
rule = \
- self.client.create_security_group_rule(parent_group_id,
- ip_protocol,
- from_port,
- to_port)
- self.addCleanup(self.client.delete_security_group_rule, rule['id'])
+ self.rules_client.create_security_group_rule(parent_group_id,
+ ip_protocol,
+ from_port,
+ to_port)
+ self.addCleanup(self.rules_client.delete_security_group_rule,
+ rule['id'])
# Add the same rule to the group should fail
self.assertRaises(lib_exc.BadRequest,
- self.client.create_security_group_rule,
+ self.rules_client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
@test.attr(type=['negative'])
@@ -106,7 +108,7 @@
to_port = 22
self.assertRaises(lib_exc.BadRequest,
- self.client.create_security_group_rule,
+ self.rules_client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
@test.attr(type=['negative'])
@@ -123,7 +125,7 @@
from_port = data_utils.rand_int_id(start=65536)
to_port = 22
self.assertRaises(lib_exc.BadRequest,
- self.client.create_security_group_rule,
+ self.rules_client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
@test.attr(type=['negative'])
@@ -140,7 +142,7 @@
from_port = 22
to_port = data_utils.rand_int_id(start=65536)
self.assertRaises(lib_exc.BadRequest,
- self.client.create_security_group_rule,
+ self.rules_client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
@test.attr(type=['negative'])
@@ -157,7 +159,7 @@
from_port = 22
to_port = 21
self.assertRaises(lib_exc.BadRequest,
- self.client.create_security_group_rule,
+ self.rules_client.create_security_group_rule,
secgroup_id, ip_protocol, from_port, to_port)
@test.attr(type=['negative'])
@@ -168,5 +170,5 @@
# with non existent id
non_existent_rule_id = not_existing_id()
self.assertRaises(lib_exc.NotFound,
- self.client.delete_security_group_rule,
+ self.rules_client.delete_security_group_rule,
non_existent_rule_id)
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index 0ce26a3..bd252b0 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -13,10 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute.security_groups import base
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import test
@@ -75,7 +76,7 @@
"not equal to the requested name")
# Now fetch the created Security Group by its 'id'
fetched_group = \
- self.client.get_security_group(securitygroup['id'])
+ self.client.show_security_group(securitygroup['id'])
self.assertEqual(securitygroup, fetched_group,
"The fetched Security Group is different "
"from the created Group")
@@ -97,7 +98,8 @@
server_name = data_utils.rand_name('server')
server = self.create_test_server(name=server_name)
server_id = server['id']
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client, server_id,
+ 'ACTIVE')
self.servers_client.add_security_group(server_id, sg['name'])
# Check that we are not able to delete the security
@@ -108,7 +110,8 @@
# Reboot and add the other security group
self.servers_client.reboot(server_id, 'HARD')
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client, server_id,
+ 'ACTIVE')
self.servers_client.add_security_group(server_id, sg2['name'])
# Check that we are not able to delete the other security
@@ -141,6 +144,6 @@
description=s_new_des)
# get the security group
fetched_group = \
- self.client.get_security_group(securitygroup_id)
+ self.client.show_security_group(securitygroup_id)
self.assertEqual(s_new_name, fetched_group['name'])
self.assertEqual(s_new_des, fetched_group['description'])
diff --git a/tempest/api/compute/security_groups/test_security_groups_negative.py b/tempest/api/compute/security_groups/test_security_groups_negative.py
index 06e073d..d8cbe3d 100644
--- a/tempest/api/compute/security_groups/test_security_groups_negative.py
+++ b/tempest/api/compute/security_groups/test_security_groups_negative.py
@@ -13,12 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import decorators
from tempest_lib import exceptions as lib_exc
import testtools
from tempest.api.compute.security_groups import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
@@ -58,7 +58,7 @@
# Negative test:Should not be able to GET the details
# of non-existent Security Group
non_exist_id = self._generate_a_non_existent_security_group_id()
- self.assertRaises(lib_exc.NotFound, self.client.get_security_group,
+ self.assertRaises(lib_exc.NotFound, self.client.show_security_group,
non_exist_id)
@decorators.skip_because(bug="1161411",
diff --git a/tempest/api/compute/servers/test_attach_interfaces.py b/tempest/api/compute/servers/test_attach_interfaces.py
index 7ce6269..9e27f33 100644
--- a/tempest/api/compute/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/servers/test_attach_interfaces.py
@@ -46,6 +46,28 @@
super(AttachInterfacesTestJSON, cls).setup_clients()
cls.client = cls.os.interfaces_client
+ def wait_for_interface_status(self, server, port_id, status):
+ """Waits for a interface to reach a given status."""
+ body = self.client.show_interface(server, port_id)
+ interface_status = body['port_state']
+ start = int(time.time())
+
+ while(interface_status != status):
+ time.sleep(self.build_interval)
+ body = self.client.show_interface(server, port_id)
+ interface_status = body['port_state']
+
+ timed_out = int(time.time()) - start >= self.build_timeout
+
+ if interface_status != status and timed_out:
+ message = ('Interface %s failed to reach %s status '
+ '(current %s) within the required time (%s s).' %
+ (port_id, status, interface_status,
+ self.build_timeout))
+ raise exceptions.TimeoutException(message)
+
+ return body
+
def _check_interface(self, iface, port_id=None, network_id=None,
fixed_ip=None, mac_addr=None):
self.assertIn('port_state', iface)
@@ -61,14 +83,14 @@
def _create_server_get_interfaces(self):
server = self.create_test_server(wait_until='ACTIVE')
ifs = self.client.list_interfaces(server['id'])
- body = self.client.wait_for_interface_status(
+ body = self.wait_for_interface_status(
server['id'], ifs[0]['port_id'], 'ACTIVE')
ifs[0]['port_state'] = body['port_state']
return server, ifs
def _test_create_interface(self, server):
iface = self.client.create_interface(server['id'])
- iface = self.client.wait_for_interface_status(
+ iface = self.wait_for_interface_status(
server['id'], iface['port_id'], 'ACTIVE')
self._check_interface(iface)
return iface
@@ -76,8 +98,8 @@
def _test_create_interface_by_network_id(self, server, ifs):
network_id = ifs[0]['net_id']
iface = self.client.create_interface(server['id'],
- network_id=network_id)
- iface = self.client.wait_for_interface_status(
+ net_id=network_id)
+ iface = self.wait_for_interface_status(
server['id'], iface['port_id'], 'ACTIVE')
self._check_interface(iface, network_id=network_id)
return iface
@@ -157,9 +179,9 @@
self.assertTrue(interface_count > 0)
self._check_interface(ifs[0])
network_id = ifs[0]['net_id']
- self.client.add_fixed_ip(server['id'], network_id)
+ self.client.add_fixed_ip(server['id'], networkId=network_id)
# Remove the fixed IP from server.
- server_detail = self.os.servers_client.get_server(
+ server_detail = self.os.servers_client.show_server(
server['id'])
# Get the Fixed IP from server.
fixed_ip = None
@@ -170,4 +192,4 @@
break
if fixed_ip is not None:
break
- self.client.remove_fixed_ip(server['id'], fixed_ip)
+ self.client.remove_fixed_ip(server['id'], address=fixed_ip)
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index 408d4ee..23a9cb3 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -16,10 +16,10 @@
import base64
import netaddr
-from tempest_lib.common.utils import data_utils
import testtools
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest.common.utils.linux import remote_client
from tempest import config
from tempest import test
@@ -63,7 +63,21 @@
personality=personality,
disk_config=disk_config)
cls.password = cls.server_initial['adminPass']
- cls.server = cls.client.get_server(cls.server_initial['id'])
+ cls.server = cls.client.show_server(cls.server_initial['id'])
+
+ 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['network']['id'])
+
+ subnet = self.network_client.create_subnet(
+ network_id=net['network']['id'],
+ cidr=cidr,
+ ip_version=4)
+ self.addCleanup(self.network_client.delete_subnet,
+ subnet['subnet']['id'])
+ return net
@test.attr(type='smoke')
@test.idempotent_id('5de47127-9977-400a-936f-abcfbec1218f')
@@ -91,7 +105,7 @@
@test.idempotent_id('585e934c-448e-43c4-acbf-d06a9b899997')
def test_list_servers_with_detail(self):
# The created server should be in the detailed list of all servers
- body = self.client.list_servers_with_detail()
+ body = self.client.list_servers(detail=True)
servers = body['servers']
found = any([i for i in servers if i['id'] == self.server['id']])
self.assertTrue(found)
@@ -103,8 +117,11 @@
# Verify that the number of vcpus reported by the instance matches
# the amount stated by the flavor
flavor = self.flavors_client.show_flavor(self.flavor_ref)
- linux_client = remote_client.RemoteClient(self.server, self.ssh_user,
- self.password)
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(self.server),
+ self.ssh_user,
+ self.password,
+ self.validation_resources['keypair']['private_key'])
self.assertEqual(flavor['vcpus'], linux_client.get_number_of_vcpus())
@test.idempotent_id('ac1ad47f-984b-4441-9274-c9079b7a0666')
@@ -112,8 +129,11 @@
'Instance validation tests are disabled.')
def test_host_name_is_same_as_server_name(self):
# Verify the instance host name is the same as the server name
- linux_client = remote_client.RemoteClient(self.server, self.ssh_user,
- self.password)
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(self.server),
+ self.ssh_user,
+ self.password,
+ self.validation_resources['keypair']['private_key'])
self.assertTrue(linux_client.hostname_equals_servername(self.name))
@test.idempotent_id('ed20d3fb-9d1f-4329-b160-543fbd5d9811')
@@ -121,17 +141,18 @@
# Create a server with the scheduler hint "group".
name = data_utils.rand_name('server_group')
policies = ['affinity']
- body = self.client.create_server_group(name=name,
- policies=policies)
+ body = self.server_groups_client.create_server_group(
+ name=name, policies=policies)
group_id = body['id']
- self.addCleanup(self.client.delete_server_group, group_id)
+ self.addCleanup(self.server_groups_client.delete_server_group,
+ group_id)
hints = {'group': group_id}
server = self.create_test_server(sched_hints=hints,
wait_until='ACTIVE')
# Check a server is in the group
- server_group = self.client.get_server_group(group_id)
+ server_group = self.server_groups_client.get_server_group(group_id)
self.assertIn(server['id'], server_group['members'])
@test.idempotent_id('0578d144-ed74-43f8-8e57-ab10dbf9b3c2')
@@ -140,29 +161,8 @@
def test_verify_multiple_nics_order(self):
# Verify that the networks order given at the server creation is
# preserved within the server.
- name_net1 = data_utils.rand_name(self.__class__.__name__)
- net1 = self.network_client.create_network(name=name_net1)
- self.addCleanup(self.network_client.delete_network,
- net1['network']['id'])
-
- name_net2 = data_utils.rand_name(self.__class__.__name__)
- net2 = self.network_client.create_network(name=name_net2)
- self.addCleanup(self.network_client.delete_network,
- net2['network']['id'])
-
- subnet1 = self.network_client.create_subnet(
- network_id=net1['network']['id'],
- cidr='19.80.0.0/24',
- ip_version=4)
- self.addCleanup(self.network_client.delete_subnet,
- subnet1['subnet']['id'])
-
- subnet2 = self.network_client.create_subnet(
- network_id=net2['network']['id'],
- cidr='19.86.0.0/24',
- ip_version=4)
- self.addCleanup(self.network_client.delete_subnet,
- subnet2['subnet']['id'])
+ net1 = self._create_net_subnet_ret_net_from_cidr('19.80.0.0/24')
+ net2 = self._create_net_subnet_ret_net_from_cidr('19.86.0.0/24')
networks = [{'uuid': net1['network']['id']},
{'uuid': net2['network']['id']}]
@@ -189,24 +189,71 @@
# other times ['19.80.0.3', '19.86.0.3']. So we check if the first
# address is in first network, similarly second address is in second
# network.
- addr = [addresses[name_net1][0]['addr'],
- addresses[name_net2][0]['addr']]
+ addr = [addresses[net1['network']['name']][0]['addr'],
+ addresses[net2['network']['name']][0]['addr']]
networks = [netaddr.IPNetwork('19.80.0.0/24'),
netaddr.IPNetwork('19.86.0.0/24')]
for address, network in zip(addr, networks):
self.assertIn(address, network)
+ @test.idempotent_id('1678d144-ed74-43f8-8e57-ab10dbf9b3c2')
+ @testtools.skipUnless(CONF.service_available.neutron,
+ 'Neutron service must be available.')
+ # The below skipUnless should be removed once Kilo-eol happens.
+ @testtools.skipUnless(CONF.compute_feature_enabled.
+ allow_duplicate_networks,
+ 'Duplicate networks must be allowed')
+ def test_verify_duplicate_network_nics(self):
+ # Verify that server creation does not fail when more than one nic
+ # is created on the same network.
+ net1 = self._create_net_subnet_ret_net_from_cidr('19.80.0.0/24')
+ net2 = self._create_net_subnet_ret_net_from_cidr('19.86.0.0/24')
+
+ networks = [{'uuid': net1['network']['id']},
+ {'uuid': net2['network']['id']},
+ {'uuid': net1['network']['id']}]
+
+ server_multi_nics = self.create_test_server(
+ networks=networks, wait_until='ACTIVE')
+
+ def cleanup_server():
+ self.client.delete_server(server_multi_nics['id'])
+ self.client.wait_for_server_termination(server_multi_nics['id'])
+
+ self.addCleanup(cleanup_server)
+
+ addresses = self.client.list_addresses(server_multi_nics['id'])
+
+ addr = [addresses[net1['network']['name']][0]['addr'],
+ addresses[net2['network']['name']][0]['addr'],
+ addresses[net1['network']['name']][1]['addr']]
+ networks = [netaddr.IPNetwork('19.80.0.0/24'),
+ netaddr.IPNetwork('19.86.0.0/24'),
+ netaddr.IPNetwork('19.80.0.0/24')]
+ for address, network in zip(addr, networks):
+ self.assertIn(address, network)
+
class ServersWithSpecificFlavorTestJSON(base.BaseV2ComputeAdminTest):
disk_config = 'AUTO'
@classmethod
- def setup_clients(cls):
+ def setup_credentials(cls):
cls.prepare_instance_network()
+ super(ServersWithSpecificFlavorTestJSON, cls).setup_credentials()
+
+ @classmethod
+ def setup_clients(cls):
super(ServersWithSpecificFlavorTestJSON, cls).setup_clients()
cls.flavor_client = cls.os_adm.flavors_client
cls.client = cls.servers_client
+ @classmethod
+ def resource_setup(cls):
+ cls.set_validation_resources()
+
+ super(ServersWithSpecificFlavorTestJSON, cls).resource_setup()
+
@test.idempotent_id('b3c7bcfc-bb5b-4e22-b517-c7f686b802ca')
@testtools.skipUnless(CONF.validation.run_validation,
'Instance validation tests are disabled.')
@@ -257,24 +304,37 @@
admin_pass = self.image_ssh_password
server_no_eph_disk = (self.create_test_server(
+ validatable=True,
wait_until='ACTIVE',
adminPass=admin_pass,
flavor=flavor_no_eph_disk_id))
+
+ # Get partition number of server without extra specs.
+ server_no_eph_disk = self.client.show_server(
+ server_no_eph_disk['id'])
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(server_no_eph_disk),
+ self.ssh_user,
+ admin_pass,
+ self.validation_resources['keypair']['private_key'])
+ partition_num = len(linux_client.get_partitions().split('\n'))
+
+ # Explicit server deletion necessary for Juno compatibility
+ self.client.delete_server(server_no_eph_disk['id'])
+
server_with_eph_disk = (self.create_test_server(
+ validatable=True,
wait_until='ACTIVE',
adminPass=admin_pass,
flavor=flavor_with_eph_disk_id))
- # Get partition number of server without extra specs.
- server_no_eph_disk = self.client.get_server(
- server_no_eph_disk['id'])
- linux_client = remote_client.RemoteClient(server_no_eph_disk,
- self.ssh_user, admin_pass)
- partition_num = len(linux_client.get_partitions().split('\n'))
- server_with_eph_disk = self.client.get_server(
+ server_with_eph_disk = self.client.show_server(
server_with_eph_disk['id'])
- linux_client = remote_client.RemoteClient(server_with_eph_disk,
- self.ssh_user, admin_pass)
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(server_with_eph_disk),
+ self.ssh_user,
+ admin_pass,
+ self.validation_resources['keypair']['private_key'])
partition_num_emph = len(linux_client.get_partitions().split('\n'))
self.assertEqual(partition_num + 1, partition_num_emph)
diff --git a/tempest/api/compute/servers/test_delete_server.py b/tempest/api/compute/servers/test_delete_server.py
index ac6ef4c..b2acd34 100644
--- a/tempest/api/compute/servers/test_delete_server.py
+++ b/tempest/api/compute/servers/test_delete_server.py
@@ -16,6 +16,7 @@
import testtools
from tempest.api.compute import base
+from tempest.common import waiters
from tempest import config
from tempest import test
@@ -51,7 +52,7 @@
# Delete a server while it's VM state is Shutoff
server = self.create_test_server(wait_until='ACTIVE')
self.client.stop(server['id'])
- self.client.wait_for_server_status(server['id'], 'SHUTOFF')
+ waiters.wait_for_server_status(self.client, server['id'], 'SHUTOFF')
self.client.delete_server(server['id'])
self.client.wait_for_server_termination(server['id'])
@@ -62,7 +63,7 @@
# Delete a server while it's VM state is Pause
server = self.create_test_server(wait_until='ACTIVE')
self.client.pause_server(server['id'])
- self.client.wait_for_server_status(server['id'], 'PAUSED')
+ waiters.wait_for_server_status(self.client, server['id'], 'PAUSED')
self.client.delete_server(server['id'])
self.client.wait_for_server_termination(server['id'])
@@ -73,7 +74,7 @@
# Delete a server while it's VM state is Suspended
server = self.create_test_server(wait_until='ACTIVE')
self.client.suspend_server(server['id'])
- self.client.wait_for_server_status(server['id'], 'SUSPENDED')
+ waiters.wait_for_server_status(self.client, server['id'], 'SUSPENDED')
self.client.delete_server(server['id'])
self.client.wait_for_server_termination(server['id'])
@@ -87,12 +88,12 @@
offload_time = CONF.compute.shelved_offload_time
if offload_time >= 0:
- self.client.wait_for_server_status(server['id'],
- 'SHELVED_OFFLOADED',
- extra_timeout=offload_time)
+ waiters.wait_for_server_status(self.client, server['id'],
+ 'SHELVED_OFFLOADED',
+ extra_timeout=offload_time)
else:
- self.client.wait_for_server_status(server['id'],
- 'SHELVED')
+ waiters.wait_for_server_status(self.client, server['id'],
+ 'SHELVED')
self.client.delete_server(server['id'])
self.client.wait_for_server_termination(server['id'])
@@ -103,7 +104,8 @@
# Delete a server while it's VM state is VERIFY_RESIZE
server = self.create_test_server(wait_until='ACTIVE')
self.client.resize(server['id'], self.flavor_ref_alt)
- self.client.wait_for_server_status(server['id'], 'VERIFY_RESIZE')
+ waiters.wait_for_server_status(self.client, server['id'],
+ 'VERIFY_RESIZE')
self.client.delete_server(server['id'])
self.client.wait_for_server_termination(server['id'])
@@ -117,15 +119,18 @@
volume = volumes_client.create_volume()
self.addCleanup(volumes_client.delete_volume, volume['id'])
- volumes_client.wait_for_volume_status(volume['id'], 'available')
+ waiters.wait_for_volume_status(volumes_client,
+ volume['id'], 'available')
self.client.attach_volume(server['id'],
volume['id'],
device=device)
- volumes_client.wait_for_volume_status(volume['id'], 'in-use')
+ waiters.wait_for_volume_status(volumes_client,
+ volume['id'], 'in-use')
self.client.delete_server(server['id'])
self.client.wait_for_server_termination(server['id'])
- volumes_client.wait_for_volume_status(volume['id'], 'available')
+ waiters.wait_for_volume_status(volumes_client,
+ volume['id'], 'available')
class DeleteServersAdminTestJSON(base.BaseV2ComputeAdminTest):
@@ -144,7 +149,7 @@
server = self.create_test_server(wait_until='ACTIVE')
self.admin_client.reset_state(server['id'], state='error')
# Verify server's state
- server = self.non_admin_client.get_server(server['id'])
+ server = self.non_admin_client.show_server(server['id'])
self.assertEqual(server['status'], 'ERROR')
self.non_admin_client.delete_server(server['id'])
self.servers_client.wait_for_server_termination(server['id'],
diff --git a/tempest/api/compute/servers/test_disk_config.py b/tempest/api/compute/servers/test_disk_config.py
index 8482802..3e8a0d2 100644
--- a/tempest/api/compute/servers/test_disk_config.py
+++ b/tempest/api/compute/servers/test_disk_config.py
@@ -16,6 +16,7 @@
import testtools
from tempest.api.compute import base
+from tempest.common import waiters
from tempest import config
from tempest import test
@@ -43,12 +44,12 @@
cls.server_id = server['id']
def _update_server_with_disk_config(self, disk_config):
- server = self.client.get_server(self.server_id)
+ server = self.client.show_server(self.server_id)
if disk_config != server['OS-DCF:diskConfig']:
server = self.client.update_server(self.server_id,
disk_config=disk_config)
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
- server = self.client.get_server(server['id'])
+ waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE')
+ server = self.client.show_server(server['id'])
self.assertEqual(disk_config, server['OS-DCF:diskConfig'])
@test.idempotent_id('bef56b09-2e8c-4883-a370-4950812f430e')
@@ -61,10 +62,10 @@
disk_config='MANUAL')
# Wait for the server to become active
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
+ waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE')
# Verify the specified attributes are set correctly
- server = self.client.get_server(server['id'])
+ server = self.client.show_server(server['id'])
self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])
@test.idempotent_id('9c9fae77-4feb-402f-8450-bf1c8b609713')
@@ -77,14 +78,14 @@
disk_config='AUTO')
# Wait for the server to become active
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
+ waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE')
# Verify the specified attributes are set correctly
- server = self.client.get_server(server['id'])
+ server = self.client.show_server(server['id'])
self.assertEqual('AUTO', server['OS-DCF:diskConfig'])
def _get_alternative_flavor(self):
- server = self.client.get_server(self.server_id)
+ server = self.client.show_server(self.server_id)
if server['flavor']['id'] == self.flavor_ref:
return self.flavor_ref_alt
@@ -101,11 +102,12 @@
# Resize with auto option
flavor_id = self._get_alternative_flavor()
self.client.resize(self.server_id, flavor_id, disk_config='AUTO')
- self.client.wait_for_server_status(self.server_id, 'VERIFY_RESIZE')
+ waiters.wait_for_server_status(self.client, self.server_id,
+ 'VERIFY_RESIZE')
self.client.confirm_resize(self.server_id)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
- server = self.client.get_server(self.server_id)
+ server = self.client.show_server(self.server_id)
self.assertEqual('AUTO', server['OS-DCF:diskConfig'])
@test.idempotent_id('693d16f3-556c-489a-8bac-3d0ca2490bad')
@@ -118,11 +120,12 @@
# Resize with manual option
flavor_id = self._get_alternative_flavor()
self.client.resize(self.server_id, flavor_id, disk_config='MANUAL')
- self.client.wait_for_server_status(self.server_id, 'VERIFY_RESIZE')
+ waiters.wait_for_server_status(self.client, self.server_id,
+ 'VERIFY_RESIZE')
self.client.confirm_resize(self.server_id)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
- server = self.client.get_server(self.server_id)
+ server = self.client.show_server(self.server_id)
self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])
@test.idempotent_id('5ef18867-358d-4de9-b3c9-94d4ba35742f')
@@ -133,8 +136,8 @@
# Update the disk_config attribute to manual
server = self.client.update_server(self.server_id,
disk_config='MANUAL')
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
+ waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE')
# Verify the disk_config attribute is set correctly
- server = self.client.get_server(server['id'])
+ server = self.client.show_server(server['id'])
self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])
diff --git a/tempest/api/compute/servers/test_instance_actions.py b/tempest/api/compute/servers/test_instance_actions.py
index 6233c58..dc126a5 100644
--- a/tempest/api/compute/servers/test_instance_actions.py
+++ b/tempest/api/compute/servers/test_instance_actions.py
@@ -14,6 +14,7 @@
# under the License.
from tempest.api.compute import base
+from tempest.common import waiters
from tempest import test
@@ -35,7 +36,7 @@
def test_list_instance_actions(self):
# List actions of the provided server
self.client.reboot(self.server_id, 'HARD')
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
body = self.client.list_instance_actions(self.server_id)
self.assertTrue(len(body) == 2, str(body))
diff --git a/tempest/api/compute/servers/test_instance_actions_negative.py b/tempest/api/compute/servers/test_instance_actions_negative.py
index afd3b7a..6567da1 100644
--- a/tempest/api/compute/servers/test_instance_actions_negative.py
+++ b/tempest/api/compute/servers/test_instance_actions_negative.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index 7a91cab..a75cb3e 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -13,12 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
from tempest.api import utils
from tempest.common import fixed_network
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import config
from tempest import test
@@ -92,7 +93,7 @@
def test_list_servers_filter_by_image(self):
# Filter the list of servers by image
params = {'image': self.image_ref}
- body = self.client.list_servers(params)
+ body = self.client.list_servers(**params)
servers = body['servers']
self.assertIn(self.s1['id'], map(lambda x: x['id'], servers))
@@ -103,7 +104,7 @@
def test_list_servers_filter_by_flavor(self):
# Filter the list of servers by flavor
params = {'flavor': self.flavor_ref_alt}
- body = self.client.list_servers(params)
+ body = self.client.list_servers(**params)
servers = body['servers']
self.assertNotIn(self.s1['id'], map(lambda x: x['id'], servers))
@@ -114,7 +115,7 @@
def test_list_servers_filter_by_server_name(self):
# Filter the list of servers by server name
params = {'name': self.s1_name}
- body = self.client.list_servers(params)
+ body = self.client.list_servers(**params)
servers = body['servers']
self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
@@ -125,7 +126,7 @@
def test_list_servers_filter_by_server_status(self):
# Filter the list of servers by server status
params = {'status': 'active'}
- body = self.client.list_servers(params)
+ body = self.client.list_servers(**params)
servers = body['servers']
self.assertIn(self.s1['id'], map(lambda x: x['id'], servers))
@@ -137,12 +138,12 @@
# Filter the list of servers by server shutoff status
params = {'status': 'shutoff'}
self.client.stop(self.s1['id'])
- self.client.wait_for_server_status(self.s1['id'],
- 'SHUTOFF')
- body = self.client.list_servers(params)
+ waiters.wait_for_server_status(self.client, self.s1['id'],
+ 'SHUTOFF')
+ body = self.client.list_servers(**params)
self.client.start(self.s1['id'])
- self.client.wait_for_server_status(self.s1['id'],
- 'ACTIVE')
+ waiters.wait_for_server_status(self.client, self.s1['id'],
+ 'ACTIVE')
servers = body['servers']
self.assertIn(self.s1['id'], map(lambda x: x['id'], servers))
@@ -153,21 +154,21 @@
def test_list_servers_filter_by_limit(self):
# Verify only the expected number of servers are returned
params = {'limit': 1}
- servers = self.client.list_servers(params)
+ servers = self.client.list_servers(**params)
self.assertEqual(1, len([x for x in servers['servers'] if 'id' in x]))
@test.idempotent_id('b1495414-2d93-414c-8019-849afe8d319e')
def test_list_servers_filter_by_zero_limit(self):
# Verify only the expected number of servers are returned
params = {'limit': 0}
- servers = self.client.list_servers(params)
+ servers = self.client.list_servers(**params)
self.assertEqual(0, len(servers['servers']))
@test.idempotent_id('37791bbd-90c0-4de0-831e-5f38cba9c6b3')
def test_list_servers_filter_by_exceed_limit(self):
# Verify only the expected number of servers are returned
params = {'limit': 100000}
- servers = self.client.list_servers(params)
+ servers = self.client.list_servers(**params)
all_servers = self.client.list_servers()
self.assertEqual(len([x for x in all_servers['servers'] if 'id' in x]),
len([x for x in servers['servers'] if 'id' in x]))
@@ -177,7 +178,7 @@
def test_list_servers_detailed_filter_by_image(self):
# Filter the detailed list of servers by image
params = {'image': self.image_ref}
- body = self.client.list_servers_with_detail(params)
+ body = self.client.list_servers(detail=True, **params)
servers = body['servers']
self.assertIn(self.s1['id'], map(lambda x: x['id'], servers))
@@ -188,7 +189,7 @@
def test_list_servers_detailed_filter_by_flavor(self):
# Filter the detailed list of servers by flavor
params = {'flavor': self.flavor_ref_alt}
- body = self.client.list_servers_with_detail(params)
+ body = self.client.list_servers(detail=True, **params)
servers = body['servers']
self.assertNotIn(self.s1['id'], map(lambda x: x['id'], servers))
@@ -199,7 +200,7 @@
def test_list_servers_detailed_filter_by_server_name(self):
# Filter the detailed list of servers by server name
params = {'name': self.s1_name}
- body = self.client.list_servers_with_detail(params)
+ body = self.client.list_servers(detail=True, **params)
servers = body['servers']
self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
@@ -210,7 +211,7 @@
def test_list_servers_detailed_filter_by_server_status(self):
# Filter the detailed list of servers by server status
params = {'status': 'active'}
- body = self.client.list_servers_with_detail(params)
+ body = self.client.list_servers(detail=True, **params)
servers = body['servers']
test_ids = [s['id'] for s in (self.s1, self.s2, self.s3)]
@@ -224,7 +225,7 @@
def test_list_servers_filtered_by_name_wildcard(self):
# List all servers that contains '-instance' in name
params = {'name': '-instance'}
- body = self.client.list_servers(params)
+ body = self.client.list_servers(**params)
servers = body['servers']
self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
@@ -235,7 +236,7 @@
part_name = self.s1_name[6:-1]
params = {'name': part_name}
- body = self.client.list_servers(params)
+ body = self.client.list_servers(**params)
servers = body['servers']
self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
@@ -248,7 +249,7 @@
regexes = ['^.*\-instance\-[0-9]+$', '^.*\-instance\-.*$']
for regex in regexes:
params = {'name': regex}
- body = self.client.list_servers(params)
+ body = self.client.list_servers(**params)
servers = body['servers']
self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
@@ -259,7 +260,7 @@
part_name = self.s1_name[-10:]
params = {'name': part_name}
- body = self.client.list_servers(params)
+ body = self.client.list_servers(**params)
servers = body['servers']
self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
@@ -273,7 +274,7 @@
if not self.fixed_network_name:
msg = 'fixed_network_name needs to be configured to run this test'
raise self.skipException(msg)
- self.s1 = self.client.get_server(self.s1['id'])
+ self.s1 = self.client.show_server(self.s1['id'])
for addr_spec in self.s1['addresses'][self.fixed_network_name]:
ip = addr_spec['addr']
if addr_spec['version'] == 4:
@@ -282,7 +283,7 @@
else:
msg = "Skipped until bug 1450859 is resolved"
raise self.skipException(msg)
- body = self.client.list_servers(params)
+ body = self.client.list_servers(**params)
servers = body['servers']
self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
@@ -297,14 +298,14 @@
if not self.fixed_network_name:
msg = 'fixed_network_name needs to be configured to run this test'
raise self.skipException(msg)
- self.s1 = self.client.get_server(self.s1['id'])
+ self.s1 = self.client.show_server(self.s1['id'])
addr_spec = self.s1['addresses'][self.fixed_network_name][0]
ip = addr_spec['addr'][0:-3]
if addr_spec['version'] == 4:
params = {'ip': ip}
else:
params = {'ip6': ip}
- body = self.client.list_servers(params)
+ body = self.client.list_servers(**params)
servers = body['servers']
self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
@@ -315,5 +316,5 @@
def test_list_servers_detailed_limit_results(self):
# Verify only the expected number of detailed results are returned
params = {'limit': 1}
- servers = self.client.list_servers_with_detail(params)
+ servers = self.client.list_servers(detail=True, **params)
self.assertEqual(1, len(servers['servers']))
diff --git a/tempest/api/compute/servers/test_list_servers_negative.py b/tempest/api/compute/servers/test_list_servers_negative.py
index fd4d902..def6cf5 100644
--- a/tempest/api/compute/servers/test_list_servers_negative.py
+++ b/tempest/api/compute/servers/test_list_servers_negative.py
@@ -68,7 +68,7 @@
def test_list_servers_by_non_existing_image(self):
# Listing servers for a non existing image returns empty list
non_existing_image = '1234abcd-zzz0-aaa9-ppp3-0987654abcde'
- body = self.client.list_servers(dict(image=non_existing_image))
+ body = self.client.list_servers(image=non_existing_image)
servers = body['servers']
self.assertEqual([], servers)
@@ -77,7 +77,7 @@
def test_list_servers_by_non_existing_flavor(self):
# Listing servers by non existing flavor returns empty list
non_existing_flavor = 1234
- body = self.client.list_servers(dict(flavor=non_existing_flavor))
+ body = self.client.list_servers(flavor=non_existing_flavor)
servers = body['servers']
self.assertEqual([], servers)
@@ -86,7 +86,7 @@
def test_list_servers_by_non_existing_server_name(self):
# Listing servers for a non existent server name returns empty list
non_existing_name = 'junk_server_1234'
- body = self.client.list_servers(dict(name=non_existing_name))
+ body = self.client.list_servers(name=non_existing_name)
servers = body['servers']
self.assertEqual([], servers)
@@ -95,21 +95,21 @@
def test_list_servers_status_non_existing(self):
# Return an empty list when invalid status is specified
non_existing_status = 'BALONEY'
- body = self.client.list_servers(dict(status=non_existing_status))
+ body = self.client.list_servers(status=non_existing_status)
servers = body['servers']
self.assertEqual([], servers)
@test.idempotent_id('12c80a9f-2dec-480e-882b-98ba15757659')
def test_list_servers_by_limits(self):
# List servers by specifying limits
- body = self.client.list_servers({'limit': 1})
+ body = self.client.list_servers(limit=1)
self.assertEqual(1, len([x for x in body['servers'] if 'id' in x]))
@test.attr(type=['negative'])
@test.idempotent_id('d47c17fb-eebd-4287-8e95-f20a7e627b18')
def test_list_servers_by_limits_greater_than_actual_count(self):
# List servers by specifying a greater value for limit
- body = self.client.list_servers({'limit': 100})
+ body = self.client.list_servers(limit=100)
self.assertEqual(len(self.existing_fixtures), len(body['servers']))
@test.attr(type=['negative'])
@@ -117,28 +117,29 @@
def test_list_servers_by_limits_pass_string(self):
# Return an error if a string value is passed for limit
self.assertRaises(lib_exc.BadRequest, self.client.list_servers,
- {'limit': 'testing'})
+ limit='testing')
@test.attr(type=['negative'])
@test.idempotent_id('62610dd9-4713-4ee0-8beb-fd2c1aa7f950')
def test_list_servers_by_limits_pass_negative_value(self):
# Return an error if a negative value for limit is passed
self.assertRaises(lib_exc.BadRequest, self.client.list_servers,
- {'limit': -1})
+ limit=-1)
@test.attr(type=['negative'])
@test.idempotent_id('87d12517-e20a-4c9c-97b6-dd1628d6d6c9')
def test_list_servers_by_changes_since_invalid_date(self):
# Return an error when invalid date format is passed
+ params = {'changes-since': '2011/01/01'}
self.assertRaises(lib_exc.BadRequest, self.client.list_servers,
- {'changes-since': '2011/01/01'})
+ **params)
@test.attr(type=['negative'])
@test.idempotent_id('74745ad8-b346-45b5-b9b8-509d7447fc1f')
def test_list_servers_by_changes_since_future_date(self):
# Return an empty list when a date in the future is passed
changes_since = {'changes-since': '2051-01-01T12:34:00Z'}
- body = self.client.list_servers(changes_since)
+ body = self.client.list_servers(**changes_since)
self.assertEqual(0, len(body['servers']))
@test.attr(type=['negative'])
@@ -146,7 +147,7 @@
def test_list_servers_detail_server_is_deleted(self):
# Server details are not listed for a deleted server
deleted_ids = [s['id'] for s in self.deleted_fixtures]
- body = self.client.list_servers_with_detail()
+ body = self.client.list_servers(detail=True)
servers = body['servers']
actual = [srv for srv in servers
if srv['id'] in deleted_ids]
diff --git a/tempest/api/compute/servers/test_multiple_create.py b/tempest/api/compute/servers/test_multiple_create.py
index 11b457b..a945411 100644
--- a/tempest/api/compute/servers/test_multiple_create.py
+++ b/tempest/api/compute/servers/test_multiple_create.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/compute/servers/test_multiple_create_negative.py b/tempest/api/compute/servers/test_multiple_create_negative.py
index bfc98ff..8135768 100644
--- a/tempest/api/compute/servers/test_multiple_create_negative.py
+++ b/tempest/api/compute/servers/test_multiple_create_negative.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 6fcd38a..f0f6b8c 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -17,13 +17,14 @@
import logging
from six.moves.urllib import parse as urlparse
-from tempest_lib.common.utils import data_utils
from tempest_lib import decorators
from tempest_lib import exceptions as lib_exc
import testtools
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest.common.utils.linux import remote_client
+from tempest.common import waiters
from tempest import config
from tempest import test
@@ -41,29 +42,39 @@
super(ServerActionsTestJSON, self).setUp()
# Check if the server is in a clean state after test
try:
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.client,
+ self.server_id, 'ACTIVE')
except lib_exc.NotFound:
# The server was deleted by previous test, create a new one
- server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(
+ validatable=True,
+ wait_until='ACTIVE')
self.__class__.server_id = server['id']
except Exception:
# Rebuild server if something happened to it during a test
- self.__class__.server_id = self.rebuild_server(self.server_id)
+ self.__class__.server_id = self.rebuild_server(self.server_id,
+ validatable=True)
def tearDown(self):
self.server_check_teardown()
super(ServerActionsTestJSON, self).tearDown()
@classmethod
+ def setup_credentials(cls):
+ cls.prepare_instance_network()
+ super(ServerActionsTestJSON, cls).setup_credentials()
+
+ @classmethod
def setup_clients(cls):
super(ServerActionsTestJSON, cls).setup_clients()
cls.client = cls.servers_client
@classmethod
def resource_setup(cls):
- cls.prepare_instance_network()
+ cls.set_validation_resources()
+
super(ServerActionsTestJSON, cls).resource_setup()
- cls.server_id = cls.rebuild_server(None)
+ cls.server_id = cls.rebuild_server(None, validatable=True)
@test.idempotent_id('6158df09-4b82-4ab3-af6d-29cf36af858d')
@testtools.skipUnless(CONF.compute_feature_enabled.change_password,
@@ -72,30 +83,38 @@
# The server's password should be set to the provided password
new_password = 'Newpass1234'
self.client.change_password(self.server_id, new_password)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
- if self.run_ssh:
+ if CONF.validation.run_validation:
# Verify that the user can authenticate with the new password
- server = self.client.get_server(self.server_id)
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- new_password)
+ server = self.client.show_server(self.server_id)
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(server),
+ self.ssh_user,
+ new_password)
linux_client.validate_authentication()
def _test_reboot_server(self, reboot_type):
- if self.run_ssh:
+ if CONF.validation.run_validation:
# Get the time the server was last rebooted,
- server = self.client.get_server(self.server_id)
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- self.password)
+ server = self.client.show_server(self.server_id)
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(server),
+ self.ssh_user,
+ self.password,
+ self.validation_resources['keypair']['private_key'])
boot_time = linux_client.get_boot_time()
self.client.reboot(self.server_id, reboot_type)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
- if self.run_ssh:
+ if CONF.validation.run_validation:
# Log in and verify the boot time has changed
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- self.password)
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(server),
+ self.ssh_user,
+ self.password,
+ self.validation_resources['keypair']['private_key'])
new_boot_time = linux_client.get_boot_time()
self.assertTrue(new_boot_time > boot_time,
'%s > %s' % (new_boot_time, boot_time))
@@ -114,7 +133,7 @@
def _rebuild_server_and_check(self, image_ref):
rebuilt_server = self.client.rebuild(self.server_id, image_ref)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
msg = ('Server was not rebuilt to the original image. '
'The original image: {0}. The current image: {1}'
.format(image_ref, rebuilt_server['image']['id']))
@@ -148,28 +167,32 @@
self.assertEqual(self.flavor_ref, rebuilt_server['flavor']['id'])
# Verify the server properties after the rebuild completes
- self.client.wait_for_server_status(rebuilt_server['id'], 'ACTIVE')
- server = self.client.get_server(rebuilt_server['id'])
+ waiters.wait_for_server_status(self.client,
+ rebuilt_server['id'], 'ACTIVE')
+ server = self.client.show_server(rebuilt_server['id'])
rebuilt_image_id = server['image']['id']
self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
self.assertEqual(new_name, server['name'])
- if self.run_ssh:
- # Verify that the user can authenticate with the provided password
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- password)
+ if CONF.validation.run_validation:
+ # TODO(jlanoux) add authentication with the provided password
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(rebuilt_server),
+ self.ssh_user,
+ self.password,
+ self.validation_resources['keypair']['private_key'])
linux_client.validate_authentication()
@test.idempotent_id('30449a88-5aff-4f9b-9866-6ee9b17f906d')
def test_rebuild_server_in_stop_state(self):
# The server in stop state should be rebuilt using the provided
# image and remain in SHUTOFF state
- server = self.client.get_server(self.server_id)
+ server = self.client.show_server(self.server_id)
old_image = server['image']['id']
new_image = (self.image_ref_alt
if old_image == self.image_ref else self.image_ref)
self.client.stop(self.server_id)
- self.client.wait_for_server_status(self.server_id, 'SHUTOFF')
+ waiters.wait_for_server_status(self.client, self.server_id, 'SHUTOFF')
rebuilt_server = self.client.rebuild(self.server_id, new_image)
# If the server was rebuilt on a different image, restore it to the
# original image once the test ends
@@ -183,8 +206,9 @@
self.assertEqual(self.flavor_ref, rebuilt_server['flavor']['id'])
# Verify the server properties after the rebuild completes
- self.client.wait_for_server_status(rebuilt_server['id'], 'SHUTOFF')
- server = self.client.get_server(rebuilt_server['id'])
+ waiters.wait_for_server_status(self.client,
+ rebuilt_server['id'], 'SHUTOFF')
+ server = self.client.show_server(rebuilt_server['id'])
rebuilt_image_id = server['image']['id']
self.assertEqual(new_image, rebuilt_image_id)
@@ -195,18 +219,20 @@
# the provided flavor
if stop:
- self.servers_client.stop(self.server_id)
- self.servers_client.wait_for_server_status(self.server_id,
- 'SHUTOFF')
+ self.client.stop(self.server_id)
+ waiters.wait_for_server_status(self.client, self.server_id,
+ 'SHUTOFF')
self.client.resize(self.server_id, self.flavor_ref_alt)
- self.client.wait_for_server_status(self.server_id, 'VERIFY_RESIZE')
+ waiters.wait_for_server_status(self.client, self.server_id,
+ 'VERIFY_RESIZE')
self.client.confirm_resize(self.server_id)
expected_status = 'SHUTOFF' if stop else 'ACTIVE'
- self.client.wait_for_server_status(self.server_id, expected_status)
+ waiters.wait_for_server_status(self.client, self.server_id,
+ expected_status)
- server = self.client.get_server(self.server_id)
+ server = self.client.show_server(self.server_id)
self.assertEqual(self.flavor_ref_alt, server['flavor']['id'])
if stop:
@@ -237,12 +263,13 @@
# values after a resize is reverted
self.client.resize(self.server_id, self.flavor_ref_alt)
- self.client.wait_for_server_status(self.server_id, 'VERIFY_RESIZE')
+ waiters.wait_for_server_status(self.client, self.server_id,
+ 'VERIFY_RESIZE')
self.client.revert_resize(self.server_id)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
- server = self.client.get_server(self.server_id)
+ server = self.client.show_server(self.server_id)
self.assertEqual(self.flavor_ref, server['flavor']['id'])
@test.idempotent_id('b963d4f1-94b3-4c40-9e97-7b583f46e470')
@@ -253,10 +280,10 @@
# Positive test:create backup successfully and rotate backups correctly
# create the first and the second backup
backup1 = data_utils.rand_name('backup-1')
- resp = self.servers_client.create_backup(self.server_id,
- 'daily',
- 2,
- backup1).response
+ resp = self.client.create_backup(self.server_id,
+ 'daily',
+ 2,
+ backup1).response
oldest_backup_exist = True
# the oldest one should be deleted automatically in this test
@@ -276,11 +303,11 @@
self.os.image_client.wait_for_image_status(image1_id, 'active')
backup2 = data_utils.rand_name('backup-2')
- self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
- resp = self.servers_client.create_backup(self.server_id,
- 'daily',
- 2,
- backup2).response
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
+ resp = self.client.create_backup(self.server_id,
+ 'daily',
+ 2,
+ backup2).response
image2_id = data_utils.parse_image_id(resp['location'])
self.addCleanup(self.os.image_client.delete_image, image2_id)
self.os.image_client.wait_for_image_status(image2_id, 'active')
@@ -304,15 +331,15 @@
# create the third one, due to the rotation is 2,
# the first one will be deleted
backup3 = data_utils.rand_name('backup-3')
- self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
- resp = self.servers_client.create_backup(self.server_id,
- 'daily',
- 2,
- backup3).response
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
+ resp = self.client.create_backup(self.server_id,
+ 'daily',
+ 2,
+ backup3).response
image3_id = data_utils.parse_image_id(resp['location'])
self.addCleanup(self.os.image_client.delete_image, image3_id)
# the first back up should be deleted
- self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
self.os.image_client.wait_for_resource_deletion(image1_id)
oldest_backup_exist = False
image_list = self.os.image_client.list_images(
@@ -330,7 +357,7 @@
(image_list[0]['name'], image_list[1]['name']))
def _get_output(self):
- output = self.servers_client.get_console_output(
+ output = self.client.get_console_output(
self.server_id, 10).data
self.assertTrue(output, "Console output was empty.")
lines = len(output.split('\n'))
@@ -348,9 +375,8 @@
# log file is truncated and we cannot get any console log through
# "console-log" API.
# The detail is https://bugs.launchpad.net/nova/+bug/1251920
- self.servers_client.reboot(self.server_id, 'HARD')
- self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
-
+ self.client.reboot(self.server_id, 'HARD')
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
self.wait_for(self._get_output)
@test.idempotent_id('89104062-69d8-4b19-a71b-f47b7af093d7')
@@ -360,8 +386,8 @@
server = self.create_test_server(wait_until='ACTIVE')
def _check_full_length_console_log():
- output = self.servers_client.get_console_output(server['id'],
- None).data
+ output = self.client.get_console_output(server['id'],
+ None).data
self.assertTrue(output, "Console output was empty.")
lines = len(output.split('\n'))
@@ -385,9 +411,8 @@
server = self.create_test_server(wait_until='ACTIVE')
temp_server_id = server['id']
- self.servers_client.stop(temp_server_id)
- self.servers_client.wait_for_server_status(temp_server_id, 'SHUTOFF')
-
+ self.client.stop(temp_server_id)
+ waiters.wait_for_server_status(self.client, temp_server_id, 'SHUTOFF')
self.wait_for(self._get_output)
@test.idempotent_id('bd61a9fd-062f-4670-972b-2d6c3e3b9e73')
@@ -395,18 +420,19 @@
'Pause is not available.')
def test_pause_unpause_server(self):
self.client.pause_server(self.server_id)
- self.client.wait_for_server_status(self.server_id, 'PAUSED')
+ waiters.wait_for_server_status(self.client, self.server_id, 'PAUSED')
self.client.unpause_server(self.server_id)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
@test.idempotent_id('0d8ee21e-b749-462d-83da-b85b41c86c7f')
@testtools.skipUnless(CONF.compute_feature_enabled.suspend,
'Suspend is not available.')
def test_suspend_resume_server(self):
self.client.suspend_server(self.server_id)
- self.client.wait_for_server_status(self.server_id, 'SUSPENDED')
+ waiters.wait_for_server_status(self.client, self.server_id,
+ 'SUSPENDED')
self.client.resume_server(self.server_id)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
@test.idempotent_id('77eba8e0-036e-4635-944b-f7a8f3b78dc9')
@testtools.skipUnless(CONF.compute_feature_enabled.shelve,
@@ -416,18 +442,18 @@
offload_time = CONF.compute.shelved_offload_time
if offload_time >= 0:
- self.client.wait_for_server_status(self.server_id,
- 'SHELVED_OFFLOADED',
- extra_timeout=offload_time)
+ waiters.wait_for_server_status(self.client, self.server_id,
+ 'SHELVED_OFFLOADED',
+ extra_timeout=offload_time)
else:
- self.client.wait_for_server_status(self.server_id,
- 'SHELVED')
+ waiters.wait_for_server_status(self.client, self.server_id,
+ 'SHELVED')
self.client.shelve_offload_server(self.server_id)
- self.client.wait_for_server_status(self.server_id,
- 'SHELVED_OFFLOADED')
+ waiters.wait_for_server_status(self.client, self.server_id,
+ 'SHELVED_OFFLOADED')
- server = self.client.get_server(self.server_id)
+ server = self.client.show_server(self.server_id)
image_name = server['name'] + '-shelved'
params = {'name': image_name}
images = self.images_client.list_images(**params)
@@ -435,29 +461,29 @@
self.assertEqual(image_name, images[0]['name'])
self.client.unshelve_server(self.server_id)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
@test.idempotent_id('af8eafd4-38a7-4a4b-bdbc-75145a580560')
def test_stop_start_server(self):
- self.servers_client.stop(self.server_id)
- self.servers_client.wait_for_server_status(self.server_id, 'SHUTOFF')
- self.servers_client.start(self.server_id)
- self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+ self.client.stop(self.server_id)
+ waiters.wait_for_server_status(self.client, self.server_id, 'SHUTOFF')
+ self.client.start(self.server_id)
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
@test.idempotent_id('80a8094c-211e-440a-ab88-9e59d556c7ee')
def test_lock_unlock_server(self):
# Lock the server,try server stop(exceptions throw),unlock it and retry
- self.servers_client.lock_server(self.server_id)
- server = self.servers_client.get_server(self.server_id)
+ self.client.lock_server(self.server_id)
+ server = self.client.show_server(self.server_id)
self.assertEqual(server['status'], 'ACTIVE')
# Locked server is not allowed to be stopped by non-admin user
self.assertRaises(lib_exc.Conflict,
- self.servers_client.stop, self.server_id)
- self.servers_client.unlock_server(self.server_id)
- self.servers_client.stop(self.server_id)
- self.servers_client.wait_for_server_status(self.server_id, 'SHUTOFF')
- self.servers_client.start(self.server_id)
- self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+ self.client.stop, self.server_id)
+ self.client.unlock_server(self.server_id)
+ self.client.stop(self.server_id)
+ waiters.wait_for_server_status(self.client, self.server_id, 'SHUTOFF')
+ self.client.start(self.server_id)
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
def _validate_url(self, url):
valid_scheme = ['http', 'https']
@@ -473,8 +499,8 @@
# Get the VNC console of type 'novnc' and 'xvpvnc'
console_types = ['novnc', 'xvpvnc']
for console_type in console_types:
- body = self.servers_client.get_vnc_console(self.server_id,
- console_type)
+ body = self.client.get_vnc_console(self.server_id,
+ console_type)
self.assertEqual(console_type, body['type'])
self.assertNotEqual('', body['url'])
self._validate_url(body['url'])
diff --git a/tempest/api/compute/servers/test_server_group.py b/tempest/api/compute/servers/test_server_group.py
index ca808dd..0e7c1eb 100644
--- a/tempest/api/compute/servers/test_server_group.py
+++ b/tempest/api/compute/servers/test_server_group.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import decorators
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
@@ -37,7 +37,7 @@
@classmethod
def setup_clients(cls):
super(ServerGroupTestJSON, cls).setup_clients()
- cls.client = cls.servers_client
+ cls.client = cls.server_groups_client
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/compute/servers/test_server_metadata_negative.py b/tempest/api/compute/servers/test_server_metadata_negative.py
index a8f7597..c42ec3d 100644
--- a/tempest/api/compute/servers/test_server_metadata_negative.py
+++ b/tempest/api/compute/servers/test_server_metadata_negative.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/compute/servers/test_server_rescue.py b/tempest/api/compute/servers/test_server_rescue.py
index 4e3ce47..98a2f9d 100644
--- a/tempest/api/compute/servers/test_server_rescue.py
+++ b/tempest/api/compute/servers/test_server_rescue.py
@@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
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
@@ -57,7 +57,8 @@
server = cls.create_test_server(wait_until='BUILD')
cls.server_id = server['id']
cls.password = server['adminPass']
- cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(cls.servers_client, cls.server_id,
+ 'ACTIVE')
def setUp(self):
super(ServerRescueTestJSON, self).setUp()
@@ -75,22 +76,26 @@
def _unrescue(self, server_id):
self.servers_client.unrescue_server(server_id)
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client, server_id,
+ 'ACTIVE')
@test.idempotent_id('fd032140-714c-42e4-a8fd-adcd8df06be6')
def test_rescue_unrescue_instance(self):
self.servers_client.rescue_server(
self.server_id, adminPass=self.password)
- self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
+ waiters.wait_for_server_status(self.servers_client, self.server_id,
+ 'RESCUE')
self.servers_client.unrescue_server(self.server_id)
- self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client, self.server_id,
+ 'ACTIVE')
@test.idempotent_id('4842e0cf-e87d-4d9d-b61f-f4791da3cacc')
def test_rescued_vm_associate_dissociate_floating_ip(self):
# Rescue the server
self.servers_client.rescue_server(
self.server_id, adminPass=self.password)
- self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
+ waiters.wait_for_server_status(self.servers_client, self.server_id,
+ 'RESCUE')
self.addCleanup(self._unrescue, self.server_id)
# Association of floating IP to a rescued vm
@@ -107,7 +112,8 @@
# Rescue the server
self.servers_client.rescue_server(
self.server_id, adminPass=self.password)
- self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
+ waiters.wait_for_server_status(self.servers_client, self.server_id,
+ 'RESCUE')
self.addCleanup(self._unrescue, self.server_id)
# Add Security group
diff --git a/tempest/api/compute/servers/test_server_rescue_negative.py b/tempest/api/compute/servers/test_server_rescue_negative.py
index 7798005..2fe63ed 100644
--- a/tempest/api/compute/servers/test_server_rescue_negative.py
+++ b/tempest/api/compute/servers/test_server_rescue_negative.py
@@ -13,11 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
import testtools
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
@@ -53,30 +54,34 @@
cls.servers_client.rescue_server(
cls.rescue_id, adminPass=rescue_password)
- cls.servers_client.wait_for_server_status(cls.rescue_id, 'RESCUE')
- cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(cls.servers_client,
+ cls.rescue_id, 'RESCUE')
+ waiters.wait_for_server_status(cls.servers_client,
+ cls.server_id, 'ACTIVE')
def _create_volume(self):
volume = self.volumes_extensions_client.create_volume(
CONF.volume.volume_size, display_name=data_utils.rand_name(
self.__class__.__name__ + '_volume'))
self.addCleanup(self.delete_volume, volume['id'])
- self.volumes_extensions_client.wait_for_volume_status(
- volume['id'], 'available')
+ waiters.wait_for_volume_status(self.volumes_extensions_client,
+ volume['id'], 'available')
return volume
def _detach(self, server_id, volume_id):
self.servers_client.detach_volume(server_id, volume_id)
- self.volumes_extensions_client.wait_for_volume_status(volume_id,
- 'available')
+ waiters.wait_for_volume_status(self.volumes_extensions_client,
+ volume_id, 'available')
def _unrescue(self, server_id):
self.servers_client.unrescue_server(server_id)
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client,
+ server_id, 'ACTIVE')
def _unpause(self, server_id):
self.servers_client.unpause_server(server_id)
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client,
+ server_id, 'ACTIVE')
@test.idempotent_id('cc3a883f-43c0-4fb6-a9bb-5579d64984ed')
@testtools.skipUnless(CONF.compute_feature_enabled.pause,
@@ -86,7 +91,8 @@
# Rescue a paused server
self.servers_client.pause_server(self.server_id)
self.addCleanup(self._unpause, self.server_id)
- self.servers_client.wait_for_server_status(self.server_id, 'PAUSED')
+ waiters.wait_for_server_status(self.servers_client,
+ self.server_id, 'PAUSED')
self.assertRaises(lib_exc.Conflict,
self.servers_client.rescue_server,
self.server_id)
@@ -123,7 +129,8 @@
# Rescue the server
self.servers_client.rescue_server(self.server_id,
adminPass=self.password)
- self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
+ waiters.wait_for_server_status(self.servers_client,
+ self.server_id, 'RESCUE')
self.addCleanup(self._unrescue, self.server_id)
# Attach the volume to the server
@@ -143,13 +150,14 @@
self.servers_client.attach_volume(self.server_id,
volume['id'],
device='/dev/%s' % self.device)
- self.volumes_extensions_client.wait_for_volume_status(
- volume['id'], 'in-use')
+ waiters.wait_for_volume_status(self.volumes_extensions_client,
+ volume['id'], 'in-use')
# Rescue the server
self.servers_client.rescue_server(self.server_id,
adminPass=self.password)
- self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
+ waiters.wait_for_server_status(self.servers_client,
+ self.server_id, 'RESCUE')
# addCleanup is a LIFO queue
self.addCleanup(self._detach, self.server_id, volume['id'])
self.addCleanup(self._unrescue, self.server_id)
diff --git a/tempest/api/compute/servers/test_servers.py b/tempest/api/compute/servers/test_servers.py
index 31078e3..2c1e69c 100644
--- a/tempest/api/compute/servers/test_servers.py
+++ b/tempest/api/compute/servers/test_servers.py
@@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import test
@@ -52,9 +52,9 @@
wait_until='ACTIVE')
id2 = server['id']
self.assertNotEqual(id1, id2, "Did not create a new server")
- server = self.client.get_server(id1)
+ server = self.client.show_server(id1)
name1 = server['name']
- server = self.client.get_server(id2)
+ server = self.client.show_server(id2)
name2 = server['name']
self.assertEqual(name1, name2)
@@ -67,8 +67,8 @@
self.addCleanup(self.keypairs_client.delete_keypair, key_name)
self.keypairs_client.list_keypairs()
server = self.create_test_server(key_name=key_name)
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
- server = self.client.get_server(server['id'])
+ waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE')
+ server = self.client.show_server(server['id'])
self.assertEqual(key_name, server['key_name'])
def _update_server_name(self, server_id, status):
@@ -77,10 +77,10 @@
# Update the server with a new name
self.client.update_server(server_id,
name=new_name)
- self.client.wait_for_server_status(server_id, status)
+ waiters.wait_for_server_status(self.client, server_id, status)
# Verify the name of the server has changed
- server = self.client.get_server(server_id)
+ server = self.client.show_server(server_id)
self.assertEqual(new_name, server['name'])
return server
@@ -96,7 +96,7 @@
# The server name should be changed to the the provided value
server = self.create_test_server(wait_until='ACTIVE')
self.client.stop(server['id'])
- self.client.wait_for_server_status(server['id'], 'SHUTOFF')
+ waiters.wait_for_server_status(self.client, server['id'], 'SHUTOFF')
updated_server = self._update_server_name(server['id'], 'SHUTOFF')
self.assertNotIn('progress', updated_server)
@@ -109,10 +109,10 @@
self.client.update_server(server['id'],
accessIPv4='1.1.1.1',
accessIPv6='::babe:202:202')
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
+ waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE')
# Verify the access addresses have been updated
- server = self.client.get_server(server['id'])
+ server = self.client.show_server(server['id'])
self.assertEqual('1.1.1.1', server['accessIPv4'])
self.assertEqual('::babe:202:202', server['accessIPv6'])
@@ -120,6 +120,6 @@
def test_create_server_with_ipv6_addr_only(self):
# Create a server without an IPv4 address(only IPv6 address).
server = self.create_test_server(accessIPv6='2001:2001::3')
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
- server = self.client.get_server(server['id'])
+ waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE')
+ server = self.client.show_server(server['id'])
self.assertEqual('2001:2001::3', server['accessIPv6'])
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index 08bebc0..fe05456 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -15,11 +15,12 @@
import sys
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
import testtools
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
@@ -33,7 +34,8 @@
def setUp(self):
super(ServersNegativeTestJSON, self).setUp()
try:
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.client, self.server_id,
+ 'ACTIVE')
except Exception:
self.__class__.server_id = self.rebuild_server(self.server_id)
@@ -157,7 +159,7 @@
def test_pause_paused_server(self):
# Pause a paused server.
self.client.pause_server(self.server_id)
- self.client.wait_for_server_status(self.server_id, 'PAUSED')
+ waiters.wait_for_server_status(self.client, self.server_id, 'PAUSED')
self.assertRaises(lib_exc.Conflict,
self.client.pause_server,
self.server_id)
@@ -326,7 +328,7 @@
def test_get_non_existent_server(self):
# Get a non existent server details
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(lib_exc.NotFound, self.client.get_server,
+ self.assertRaises(lib_exc.NotFound, self.client.show_server,
nonexistent_server)
@test.attr(type=['negative'])
@@ -384,7 +386,8 @@
def test_suspend_server_invalid_state(self):
# suspend a suspended server.
self.client.suspend_server(self.server_id)
- self.client.wait_for_server_status(self.server_id, 'SUSPENDED')
+ waiters.wait_for_server_status(self.client, self.server_id,
+ 'SUSPENDED')
self.assertRaises(lib_exc.Conflict,
self.client.suspend_server,
self.server_id)
@@ -465,14 +468,16 @@
offload_time = CONF.compute.shelved_offload_time
if offload_time >= 0:
- self.client.wait_for_server_status(self.server_id,
- 'SHELVED_OFFLOADED',
- extra_timeout=offload_time)
+ waiters.wait_for_server_status(self.client,
+ self.server_id,
+ 'SHELVED_OFFLOADED',
+ extra_timeout=offload_time)
else:
- self.client.wait_for_server_status(self.server_id,
- 'SHELVED')
+ waiters.wait_for_server_status(self.client,
+ self.server_id,
+ 'SHELVED')
- server = self.client.get_server(self.server_id)
+ server = self.client.show_server(self.server_id)
image_name = server['name'] + '-shelved'
params = {'name': image_name}
images = self.images_client.list_images(**params)
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index af29425..8ee8ad4 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -16,10 +16,10 @@
import six
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
@@ -52,17 +52,19 @@
cls.glance_client = cls.os.image_client
cls.keypairs_client = cls.os.keypairs_client
cls.security_client = cls.os.security_groups_client
+ cls.rule_client = cls.os.security_group_rules_client
cls.alt_client = cls.alt_manager.servers_client
cls.alt_images_client = cls.alt_manager.images_client
cls.alt_keypairs_client = cls.alt_manager.keypairs_client
cls.alt_security_client = cls.alt_manager.security_groups_client
+ cls.alt_rule_client = cls.alt_manager.security_group_rules_client
@classmethod
def resource_setup(cls):
super(AuthorizationTestJSON, cls).resource_setup()
server = cls.create_test_server(wait_until='ACTIVE')
- cls.server = cls.client.get_server(server['id'])
+ cls.server = cls.client.show_server(server['id'])
name = data_utils.rand_name('image')
body = cls.glance_client.create_image(name=name,
@@ -87,7 +89,7 @@
ip_protocol = 'tcp'
from_port = 22
to_port = 22
- cls.rule = cls.security_client.create_security_group_rule(
+ cls.rule = cls.rule_client.create_security_group_rule(
parent_group_id, ip_protocol, from_port, to_port)
@classmethod
@@ -103,7 +105,7 @@
@test.idempotent_id('56816e4a-bd34-47b5-aee9-268c3efeb5d4')
def test_get_server_for_alt_account_fails(self):
# A GET request for a server on another user's account should fail
- self.assertRaises(lib_exc.NotFound, self.alt_client.get_server,
+ self.assertRaises(lib_exc.NotFound, self.alt_client.show_server,
self.server['id'])
@test.idempotent_id('fb8a4870-6d9d-44ad-8375-95d52e98d9f6')
@@ -271,7 +273,7 @@
def test_get_security_group_of_alt_account_fails(self):
# A GET request for another user's security group should fail
self.assertRaises(lib_exc.NotFound,
- self.alt_security_client.get_security_group,
+ self.alt_security_client.show_security_group,
self.security_group['id'])
@test.idempotent_id('155387a5-2bbc-4acf-ab06-698dae537ea5')
@@ -292,21 +294,21 @@
to_port = -1
try:
# Change the base URL to impersonate another user
- self.alt_security_client.auth_provider.set_alt_auth_data(
+ self.alt_rule_client.auth_provider.set_alt_auth_data(
request_part='url',
- auth_data=self.security_client.auth_provider.auth_data
+ auth_data=self.rule_client.auth_provider.auth_data
)
resp = {}
resp['status'] = None
self.assertRaises(lib_exc.BadRequest,
- self.alt_security_client.
+ self.alt_rule_client.
create_security_group_rule,
parent_group_id, ip_protocol, from_port,
to_port)
finally:
# Next request the base_url is back to normal
if resp['status'] is not None:
- self.alt_security_client.delete_security_group_rule(resp['id'])
+ self.alt_rule_client.delete_security_group_rule(resp['id'])
LOG.error("Create security group rule request should not "
"happen if the tenant id does not match the"
" current user")
@@ -316,7 +318,7 @@
# A DELETE request for another user's security group rule
# should fail
self.assertRaises(lib_exc.NotFound,
- self.alt_security_client.delete_security_group_rule,
+ self.alt_rule_client.delete_security_group_rule,
self.rule['id'])
@test.idempotent_id('c5f52351-53d9-4fc9-83e5-917f7f5e3d71')
diff --git a/tempest/api/compute/test_live_block_migration_negative.py b/tempest/api/compute/test_live_block_migration_negative.py
index 5ee76ca..fabe55d 100644
--- a/tempest/api/compute/test_live_block_migration_negative.py
+++ b/tempest/api/compute/test_live_block_migration_negative.py
@@ -13,10 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
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
@@ -55,4 +56,5 @@
self.assertRaises(lib_exc.BadRequest, self._migrate_server_to,
server_id, target_host)
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client, server_id,
+ 'ACTIVE')
diff --git a/tempest/api/compute/test_quotas.py b/tempest/api/compute/test_quotas.py
index e302798..9f37143 100644
--- a/tempest/api/compute/test_quotas.py
+++ b/tempest/api/compute/test_quotas.py
@@ -20,6 +20,13 @@
class QuotasTestJSON(base.BaseV2ComputeTest):
+ @classmethod
+ def skip_checks(cls):
+ super(QuotasTestJSON, cls).skip_checks()
+ if not test.is_extension_enabled('os-quota-sets', 'compute'):
+ msg = "quotas extension not enabled."
+ raise cls.skipException(msg)
+
def setUp(self):
# NOTE(mriedem): Avoid conflicts with os-quota-class-sets tests.
self.useFixture(fixtures.LockFixture('compute_quotas'))
diff --git a/tempest/api/compute/test_tenant_networks.py b/tempest/api/compute/test_tenant_networks.py
index a37dce1..ad5adaa 100644
--- a/tempest/api/compute/test_tenant_networks.py
+++ b/tempest/api/compute/test_tenant_networks.py
@@ -29,5 +29,5 @@
self.assertNotEmpty(tenant_networks, "No tenant networks found.")
for net in tenant_networks:
- tenant_network = self.client.get_tenant_network(net['id'])
+ tenant_network = self.client.show_tenant_network(net['id'])
self.assertEqual(net['id'], tenant_network['id'])
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index 580fb84..8e4278a 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -17,6 +17,7 @@
from tempest.api.compute import base
from tempest.common.utils.linux import remote_client
+from tempest.common import waiters
from tempest import config
from tempest import test
@@ -43,6 +44,8 @@
@classmethod
def resource_setup(cls):
+ cls.set_validation_resources()
+
super(AttachVolumeTestJSON, cls).resource_setup()
cls.device = CONF.compute.volume_device_name
@@ -61,8 +64,10 @@
def _create_and_attach(self):
# Start a server and wait for it to become ready
admin_pass = self.image_ssh_password
- self.server = self.create_test_server(wait_until='ACTIVE',
- adminPass=admin_pass)
+ self.server = self.create_test_server(
+ validatable=True,
+ wait_until='ACTIVE',
+ adminPass=admin_pass)
# Record addresses so that we can ssh later
self.server['addresses'] = (
@@ -93,30 +98,38 @@
self._create_and_attach()
self.servers_client.stop(self.server['id'])
- self.servers_client.wait_for_server_status(self.server['id'],
- 'SHUTOFF')
+ waiters.wait_for_server_status(self.servers_client, self.server['id'],
+ 'SHUTOFF')
self.servers_client.start(self.server['id'])
- self.servers_client.wait_for_server_status(self.server['id'], 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client, self.server['id'],
+ 'ACTIVE')
- linux_client = remote_client.RemoteClient(self.server,
- self.image_ssh_user,
- self.server['adminPass'])
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(self.server),
+ self.image_ssh_user,
+ self.server['adminPass'],
+ self.validation_resources['keypair']['private_key'])
+
partitions = linux_client.get_partitions()
self.assertIn(self.device, partitions)
self._detach(self.server['id'], self.volume['id'])
self.attachment = None
self.servers_client.stop(self.server['id'])
- self.servers_client.wait_for_server_status(self.server['id'],
- 'SHUTOFF')
+ waiters.wait_for_server_status(self.servers_client, self.server['id'],
+ 'SHUTOFF')
self.servers_client.start(self.server['id'])
- self.servers_client.wait_for_server_status(self.server['id'], 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client, self.server['id'],
+ 'ACTIVE')
- linux_client = remote_client.RemoteClient(self.server,
- self.image_ssh_user,
- self.server['adminPass'])
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(self.server),
+ self.image_ssh_user,
+ self.server['adminPass'],
+ self.validation_resources['keypair']['private_key'])
+
partitions = linux_client.get_partitions()
self.assertNotIn(self.device, partitions)
diff --git a/tempest/api/compute/volumes/test_volumes_get.py b/tempest/api/compute/volumes/test_volumes_get.py
index d96dcc2..44339a3 100644
--- a/tempest/api/compute/volumes/test_volumes_get.py
+++ b/tempest/api/compute/volumes/test_volumes_get.py
@@ -13,10 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from testtools import matchers
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
@@ -56,9 +57,9 @@
self.assertTrue(volume['id'] is not None,
"Field volume id is empty or not found.")
# Wait for Volume status to become ACTIVE
- self.client.wait_for_volume_status(volume['id'], 'available')
+ waiters.wait_for_volume_status(self.client, volume['id'], 'available')
# GET Volume
- fetched_volume = self.client.get_volume(volume['id'])
+ fetched_volume = self.client.show_volume(volume['id'])
# Verification of details of fetched Volume
self.assertEqual(v_name,
fetched_volume['displayName'],
diff --git a/tempest/api/compute/volumes/test_volumes_list.py b/tempest/api/compute/volumes/test_volumes_list.py
index fdece0c..22b3d13 100644
--- a/tempest/api/compute/volumes/test_volumes_list.py
+++ b/tempest/api/compute/volumes/test_volumes_list.py
@@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
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
@@ -56,8 +56,9 @@
try:
volume = cls.client.create_volume(display_name=v_name,
metadata=metadata)
- cls.client.wait_for_volume_status(volume['id'], 'available')
- volume = cls.client.get_volume(volume['id'])
+ waiters.wait_for_volume_status(cls.client,
+ volume['id'], 'available')
+ volume = cls.client.show_volume(volume['id'])
cls.volume_list.append(volume)
cls.volume_id_list.append(volume['id'])
except Exception:
@@ -102,7 +103,7 @@
def test_volume_list_with_details(self):
# Should return the list of Volumes with details
# Fetch all Volumes
- fetched_list = self.client.list_volumes_with_detail()
+ fetched_list = self.client.list_volumes(detail=True)
# Now check if all the Volumes created in setup are in fetched list
missing_volumes = [
v for v in self.volume_list if v not in fetched_list
@@ -117,7 +118,7 @@
def test_volume_list_param_limit(self):
# Return the list of volumes based on limit set
params = {'limit': 2}
- fetched_vol_list = self.client.list_volumes(params=params)
+ fetched_vol_list = self.client.list_volumes(**params)
self.assertEqual(len(fetched_vol_list), params['limit'],
"Failed to list volumes by limit set")
@@ -126,7 +127,7 @@
def test_volume_list_with_detail_param_limit(self):
# Return the list of volumes with details based on limit set.
params = {'limit': 2}
- fetched_vol_list = self.client.list_volumes_with_detail(params=params)
+ fetched_vol_list = self.client.list_volumes(detail=True, **params)
self.assertEqual(len(fetched_vol_list), params['limit'],
"Failed to list volume details by limit set")
@@ -137,7 +138,7 @@
# get all volumes list
all_vol_list = self.client.list_volumes()
params = {'offset': 1, 'limit': 1}
- fetched_vol_list = self.client.list_volumes(params=params)
+ fetched_vol_list = self.client.list_volumes(**params)
# Validating length of the fetched volumes
self.assertEqual(len(fetched_vol_list), params['limit'],
@@ -152,9 +153,9 @@
def test_volume_list_with_detail_param_offset_and_limit(self):
# Return the list of volumes details based on offset and limit set.
# get all volumes list
- all_vol_list = self.client.list_volumes_with_detail()
+ all_vol_list = self.client.list_volumes(detail=True)
params = {'offset': 1, 'limit': 1}
- fetched_vol_list = self.client.list_volumes_with_detail(params=params)
+ fetched_vol_list = self.client.list_volumes(detail=True, **params)
# Validating length of the fetched volumes
self.assertEqual(len(fetched_vol_list), params['limit'],
diff --git a/tempest/api/compute/volumes/test_volumes_negative.py b/tempest/api/compute/volumes/test_volumes_negative.py
index 65d9def..01a0baf 100644
--- a/tempest/api/compute/volumes/test_volumes_negative.py
+++ b/tempest/api/compute/volumes/test_volumes_negative.py
@@ -15,10 +15,10 @@
import uuid
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
@@ -45,7 +45,7 @@
# Negative: Should not be able to get details of nonexistent volume
# Creating a nonexistent volume id
# Trying to GET a non existent volume
- self.assertRaises(lib_exc.NotFound, self.client.get_volume,
+ self.assertRaises(lib_exc.NotFound, self.client.show_volume,
str(uuid.uuid4()))
@test.attr(type=['negative'])
@@ -91,13 +91,13 @@
def test_get_invalid_volume_id(self):
# Negative: Should not be able to get volume with invalid id
self.assertRaises(lib_exc.NotFound,
- self.client.get_volume, '#$%%&^&^')
+ self.client.show_volume, '#$%%&^&^')
@test.attr(type=['negative'])
@test.idempotent_id('62bab09a-4c03-4617-8cca-8572bc94af9b')
def test_get_volume_without_passing_volume_id(self):
# Negative: Should not be able to get volume when empty ID is passed
- self.assertRaises(lib_exc.NotFound, self.client.get_volume, '')
+ self.assertRaises(lib_exc.NotFound, self.client.show_volume, '')
@test.attr(type=['negative'])
@test.idempotent_id('62972737-124b-4513-b6cf-2f019f178494')
diff --git a/tempest/api/data_processing/test_cluster_templates.py b/tempest/api/data_processing/test_cluster_templates.py
index cebf493..e357a85 100644
--- a/tempest/api/data_processing/test_cluster_templates.py
+++ b/tempest/api/data_processing/test_cluster_templates.py
@@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.data_processing import base as dp_base
+from tempest.common.utils import data_utils
from tempest import exceptions
from tempest import test
diff --git a/tempest/api/data_processing/test_data_sources.py b/tempest/api/data_processing/test_data_sources.py
index 5d2ed2d..dd16b2f 100644
--- a/tempest/api/data_processing/test_data_sources.py
+++ b/tempest/api/data_processing/test_data_sources.py
@@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.data_processing import base as dp_base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/data_processing/test_job_binaries.py b/tempest/api/data_processing/test_job_binaries.py
index 694cf25..fb21270 100644
--- a/tempest/api/data_processing/test_job_binaries.py
+++ b/tempest/api/data_processing/test_job_binaries.py
@@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.data_processing import base as dp_base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/data_processing/test_job_binary_internals.py b/tempest/api/data_processing/test_job_binary_internals.py
index ee4e68a..3d76ebe 100644
--- a/tempest/api/data_processing/test_job_binary_internals.py
+++ b/tempest/api/data_processing/test_job_binary_internals.py
@@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.data_processing import base as dp_base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/data_processing/test_jobs.py b/tempest/api/data_processing/test_jobs.py
index b155615..83eb54d 100644
--- a/tempest/api/data_processing/test_jobs.py
+++ b/tempest/api/data_processing/test_jobs.py
@@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.data_processing import base as dp_base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/data_processing/test_node_group_templates.py b/tempest/api/data_processing/test_node_group_templates.py
index 4068027..102799d 100644
--- a/tempest/api/data_processing/test_node_group_templates.py
+++ b/tempest/api/data_processing/test_node_group_templates.py
@@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.data_processing import base as dp_base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/identity/admin/v2/test_roles.py b/tempest/api/identity/admin/v2/test_roles.py
index 4e89bfe..1babc45 100644
--- a/tempest/api/identity/admin/v2/test_roles.py
+++ b/tempest/api/identity/admin/v2/test_roles.py
@@ -14,9 +14,9 @@
# under the License.
from six import moves
-from tempest_lib.common.utils import data_utils
from tempest.api.identity import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/identity/admin/v2/test_roles_negative.py b/tempest/api/identity/admin/v2/test_roles_negative.py
index 3654f9c..b38b7dd 100644
--- a/tempest/api/identity/admin/v2/test_roles_negative.py
+++ b/tempest/api/identity/admin/v2/test_roles_negative.py
@@ -15,10 +15,10 @@
import uuid
-from tempest_lib.common.utils import data_utils
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
diff --git a/tempest/api/identity/admin/v2/test_services.py b/tempest/api/identity/admin/v2/test_services.py
index de1d091..ef93981 100644
--- a/tempest/api/identity/admin/v2/test_services.py
+++ b/tempest/api/identity/admin/v2/test_services.py
@@ -14,10 +14,10 @@
# under the License.
from six import moves
-from tempest_lib.common.utils import data_utils
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
diff --git a/tempest/api/identity/admin/v2/test_tenant_negative.py b/tempest/api/identity/admin/v2/test_tenant_negative.py
index 367b699..bccb5ca 100644
--- a/tempest/api/identity/admin/v2/test_tenant_negative.py
+++ b/tempest/api/identity/admin/v2/test_tenant_negative.py
@@ -15,10 +15,10 @@
import uuid
-from tempest_lib.common.utils import data_utils
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
diff --git a/tempest/api/identity/admin/v2/test_tenants.py b/tempest/api/identity/admin/v2/test_tenants.py
index cfd3d7f..f828f66 100644
--- a/tempest/api/identity/admin/v2/test_tenants.py
+++ b/tempest/api/identity/admin/v2/test_tenants.py
@@ -14,9 +14,9 @@
# under the License.
from six import moves
-from tempest_lib.common.utils import data_utils
from tempest.api.identity import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/identity/admin/v2/test_tokens.py b/tempest/api/identity/admin/v2/test_tokens.py
index ee2530b..66d00d1 100644
--- a/tempest/api/identity/admin/v2/test_tokens.py
+++ b/tempest/api/identity/admin/v2/test_tokens.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.identity import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/identity/admin/v2/test_users.py b/tempest/api/identity/admin/v2/test_users.py
index 8eac80c..bfbcfe7 100644
--- a/tempest/api/identity/admin/v2/test_users.py
+++ b/tempest/api/identity/admin/v2/test_users.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from testtools import matchers
from tempest.api.identity import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/identity/admin/v2/test_users_negative.py b/tempest/api/identity/admin/v2/test_users_negative.py
index 3c15006..85f7411 100644
--- a/tempest/api/identity/admin/v2/test_users_negative.py
+++ b/tempest/api/identity/admin/v2/test_users_negative.py
@@ -15,10 +15,10 @@
import uuid
-from tempest_lib.common.utils import data_utils
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
diff --git a/tempest/api/identity/admin/v3/test_credentials.py b/tempest/api/identity/admin/v3/test_credentials.py
index 98ab093..662d06c 100644
--- a/tempest/api/identity/admin/v3/test_credentials.py
+++ b/tempest/api/identity/admin/v3/test_credentials.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.identity import base
+from tempest.common.utils import data_utils
from tempest import test
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 0b9d60e..98fff09 100644
--- a/tempest/api/identity/admin/v3/test_default_project_id.py
+++ b/tempest/api/identity/admin/v3/test_default_project_id.py
@@ -11,10 +11,10 @@
# under the License.
from tempest_lib import auth
-from tempest_lib.common.utils import data_utils
from tempest.api.identity import base
from tempest import clients
+from tempest.common.utils import data_utils
from tempest import config
from tempest import manager
from tempest import test
diff --git a/tempest/api/identity/admin/v3/test_domains.py b/tempest/api/identity/admin/v3/test_domains.py
index 94aab5b..5bfb981 100644
--- a/tempest/api/identity/admin/v3/test_domains.py
+++ b/tempest/api/identity/admin/v3/test_domains.py
@@ -14,11 +14,10 @@
# under the License.
from tempest.api.identity import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
-from tempest_lib.common.utils import data_utils
-
CONF = config.CONF
diff --git a/tempest/api/identity/admin/v3/test_endpoints.py b/tempest/api/identity/admin/v3/test_endpoints.py
index 9ca10a4..9a8104f 100644
--- a/tempest/api/identity/admin/v3/test_endpoints.py
+++ b/tempest/api/identity/admin/v3/test_endpoints.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.identity import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/identity/admin/v3/test_endpoints_negative.py b/tempest/api/identity/admin/v3/test_endpoints_negative.py
index 7972dbb..b043415 100644
--- a/tempest/api/identity/admin/v3/test_endpoints_negative.py
+++ b/tempest/api/identity/admin/v3/test_endpoints_negative.py
@@ -14,10 +14,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
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
diff --git a/tempest/api/identity/admin/v3/test_groups.py b/tempest/api/identity/admin/v3/test_groups.py
index fed4dc2..88e2959 100644
--- a/tempest/api/identity/admin/v3/test_groups.py
+++ b/tempest/api/identity/admin/v3/test_groups.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.identity import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/identity/admin/v3/test_list_projects.py b/tempest/api/identity/admin/v3/test_list_projects.py
index d88b00d..12d80bb 100644
--- a/tempest/api/identity/admin/v3/test_list_projects.py
+++ b/tempest/api/identity/admin/v3/test_list_projects.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.identity import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/identity/admin/v3/test_list_users.py b/tempest/api/identity/admin/v3/test_list_users.py
index eeee3bb..d3d51b4 100644
--- a/tempest/api/identity/admin/v3/test_list_users.py
+++ b/tempest/api/identity/admin/v3/test_list_users.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.identity import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/identity/admin/v3/test_policies.py b/tempest/api/identity/admin/v3/test_policies.py
index 6c5599a..8b67945 100644
--- a/tempest/api/identity/admin/v3/test_policies.py
+++ b/tempest/api/identity/admin/v3/test_policies.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.identity import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/identity/admin/v3/test_projects.py b/tempest/api/identity/admin/v3/test_projects.py
index 41cf840..17712f3 100644
--- a/tempest/api/identity/admin/v3/test_projects.py
+++ b/tempest/api/identity/admin/v3/test_projects.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.identity import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/identity/admin/v3/test_projects_negative.py b/tempest/api/identity/admin/v3/test_projects_negative.py
index 37ec071..d5ee5a7 100644
--- a/tempest/api/identity/admin/v3/test_projects_negative.py
+++ b/tempest/api/identity/admin/v3/test_projects_negative.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
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
diff --git a/tempest/api/identity/admin/v3/test_regions.py b/tempest/api/identity/admin/v3/test_regions.py
index 986007a..7eb92bc 100644
--- a/tempest/api/identity/admin/v3/test_regions.py
+++ b/tempest/api/identity/admin/v3/test_regions.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
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
diff --git a/tempest/api/identity/admin/v3/test_roles.py b/tempest/api/identity/admin/v3/test_roles.py
index 7857e11..f58a5c5 100644
--- a/tempest/api/identity/admin/v3/test_roles.py
+++ b/tempest/api/identity/admin/v3/test_roles.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.identity import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/identity/admin/v3/test_services.py b/tempest/api/identity/admin/v3/test_services.py
index b2a75aa..95a7dcc 100644
--- a/tempest/api/identity/admin/v3/test_services.py
+++ b/tempest/api/identity/admin/v3/test_services.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
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
diff --git a/tempest/api/identity/admin/v3/test_tokens.py b/tempest/api/identity/admin/v3/test_tokens.py
index 41d67c7..951bc78 100644
--- a/tempest/api/identity/admin/v3/test_tokens.py
+++ b/tempest/api/identity/admin/v3/test_tokens.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
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
diff --git a/tempest/api/identity/admin/v3/test_trusts.py b/tempest/api/identity/admin/v3/test_trusts.py
index 8a2d797..1ac34eb 100644
--- a/tempest/api/identity/admin/v3/test_trusts.py
+++ b/tempest/api/identity/admin/v3/test_trusts.py
@@ -14,12 +14,12 @@
import re
from oslo_utils import timeutils
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.identity import base
from tempest import clients
from tempest.common import cred_provider
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/identity/admin/v3/test_users.py b/tempest/api/identity/admin/v3/test_users.py
index c2456c4..19cb24e 100644
--- a/tempest/api/identity/admin/v3/test_users.py
+++ b/tempest/api/identity/admin/v3/test_users.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.identity import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index 913e807..0654f37 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -14,10 +14,10 @@
# under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.common import cred_provider
+from tempest.common.utils import data_utils
from tempest import config
import tempest.test
diff --git a/tempest/api/identity/v2/test_tokens.py b/tempest/api/identity/v2/test_tokens.py
index 5a8afa0..3b508f4 100644
--- a/tempest/api/identity/v2/test_tokens.py
+++ b/tempest/api/identity/v2/test_tokens.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_utils import timeutils
+import six
from tempest.api.identity import base
from tempest import test
@@ -30,9 +32,19 @@
password = creds.password
tenant_name = creds.tenant_name
- body = token_client.auth(username,
- password,
- tenant_name)
+ body = token_client.auth(username, password, tenant_name)
+ self.assertNotEmpty(body['token']['id'])
+ self.assertIsInstance(body['token']['id'], six.string_types)
+
+ now = timeutils.utcnow()
+ expires_at = timeutils.normalize_time(
+ timeutils.parse_isotime(body['token']['expires']))
+ self.assertGreater(expires_at, now)
+
+ self.assertEqual(body['token']['tenant']['id'],
+ creds.credentials.tenant_id)
self.assertEqual(body['token']['tenant']['name'],
tenant_name)
+
+ self.assertEqual(body['user']['id'], creds.credentials.user_id)
diff --git a/tempest/api/identity/v3/test_tokens.py b/tempest/api/identity/v3/test_tokens.py
index ab4a09f..3151763 100644
--- a/tempest/api/identity/v3/test_tokens.py
+++ b/tempest/api/identity/v3/test_tokens.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_utils import timeutils
+import six
from tempest.api.identity import base
from tempest import test
@@ -26,8 +28,25 @@
user_id = creds.user_id
username = creds.username
password = creds.password
- resp = self.non_admin_token.auth(user_id=user_id,
- password=password)
- subject_name = resp['token']['user']['name']
+ token_id, resp = self.non_admin_token.get_token(user_id=user_id,
+ password=password,
+ auth_data=True)
+
+ self.assertNotEmpty(token_id)
+ self.assertIsInstance(token_id, six.string_types)
+
+ now = timeutils.utcnow()
+ expires_at = timeutils.normalize_time(
+ timeutils.parse_isotime(resp['expires_at']))
+ self.assertGreater(resp['expires_at'],
+ resp['issued_at'])
+ self.assertGreater(expires_at, now)
+
+ subject_id = resp['user']['id']
+ self.assertEqual(subject_id, user_id)
+
+ subject_name = resp['user']['name']
self.assertEqual(subject_name, username)
+
+ self.assertEqual(resp['methods'][0], 'password')
diff --git a/tempest/api/image/base.py b/tempest/api/image/base.py
index dc38cab..87013db 100644
--- a/tempest/api/image/base.py
+++ b/tempest/api/image/base.py
@@ -14,9 +14,9 @@
from oslo_log import log as logging
from six import moves
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
+from tempest.common.utils import data_utils
from tempest import config
import tempest.test
diff --git a/tempest/api/image/v1/test_image_members_negative.py b/tempest/api/image/v1/test_image_members_negative.py
index df0e88a..50f5048 100644
--- a/tempest/api/image/v1/test_image_members_negative.py
+++ b/tempest/api/image/v1/test_image_members_negative.py
@@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.image import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/image/v1/test_images.py b/tempest/api/image/v1/test_images.py
index 3f71fcb..8beed32 100644
--- a/tempest/api/image/v1/test_images.py
+++ b/tempest/api/image/v1/test_images.py
@@ -14,9 +14,9 @@
# under the License.
from six import moves
-from tempest_lib.common.utils import data_utils
from tempest.api.image import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index 2859cfe..20e9bca 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -17,9 +17,9 @@
import random
from six import moves
-from tempest_lib.common.utils import data_utils
from tempest.api.image import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/image/v2/test_images_member.py b/tempest/api/image/v2/test_images_member.py
index d497005..d89803d 100644
--- a/tempest/api/image/v2/test_images_member.py
+++ b/tempest/api/image/v2/test_images_member.py
@@ -89,3 +89,19 @@
def test_get_image_members_schema(self):
body = self.os_img_client.show_schema("members")
self.assertEqual("members", body['name'])
+
+ @test.idempotent_id('cb961424-3f68-4d21-8e36-30ad66fb6bfb')
+ def test_get_private_image(self):
+ image_id = self._create_image()
+ member = self.os_img_client.add_image_member(image_id,
+ self.alt_tenant_id)
+ self.assertEqual(member['member_id'], self.alt_tenant_id)
+ self.assertEqual(member['image_id'], image_id)
+ self.assertEqual(member['status'], 'pending')
+ self.assertNotIn(image_id, self._list_image_ids_as_alt())
+ self.alt_img_client.update_image_member(image_id,
+ 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.assertNotIn(image_id, self._list_image_ids_as_alt())
diff --git a/tempest/api/image/v2/test_images_tags.py b/tempest/api/image/v2/test_images_tags.py
index e38136e..42a4b87 100644
--- a/tempest/api/image/v2/test_images_tags.py
+++ b/tempest/api/image/v2/test_images_tags.py
@@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.image import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/image/v2/test_images_tags_negative.py b/tempest/api/image/v2/test_images_tags_negative.py
index 571b1f7..a3f4ca8 100644
--- a/tempest/api/image/v2/test_images_tags_negative.py
+++ b/tempest/api/image/v2/test_images_tags_negative.py
@@ -14,10 +14,10 @@
import uuid
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.image import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/messaging/base.py b/tempest/api/messaging/base.py
index 34ac860..64a7fd5 100644
--- a/tempest/api/messaging/base.py
+++ b/tempest/api/messaging/base.py
@@ -14,8 +14,8 @@
# limitations under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/messaging/test_claims.py b/tempest/api/messaging/test_claims.py
index 34e1fe8..e54bed1 100644
--- a/tempest/api/messaging/test_claims.py
+++ b/tempest/api/messaging/test_claims.py
@@ -16,10 +16,10 @@
import logging
from six.moves.urllib import parse as urlparse
-from tempest_lib.common.utils import data_utils
from tempest_lib import decorators
from tempest.api.messaging import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/messaging/test_messages.py b/tempest/api/messaging/test_messages.py
index c8640b3..efbbf56 100644
--- a/tempest/api/messaging/test_messages.py
+++ b/tempest/api/messaging/test_messages.py
@@ -15,9 +15,8 @@
import logging
-from tempest_lib.common.utils import data_utils
-
from tempest.api.messaging import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/messaging/test_queues.py b/tempest/api/messaging/test_queues.py
index a3541b3..df49663 100644
--- a/tempest/api/messaging/test_queues.py
+++ b/tempest/api/messaging/test_queues.py
@@ -16,11 +16,11 @@
import logging
from six import moves
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from testtools import matchers
from tempest.api.messaging import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/network/admin/test_external_network_extension.py b/tempest/api/network/admin/test_external_network_extension.py
index 75f2719..d942641 100644
--- a/tempest/api/network/admin/test_external_network_extension.py
+++ b/tempest/api/network/admin/test_external_network_extension.py
@@ -10,9 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.network import base
+from tempest.common.utils import data_utils
from tempest import test
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 d4e94ca..dfe7307 100644
--- a/tempest/api/network/admin/test_floating_ips_admin_actions.py
+++ b/tempest/api/network/admin/test_floating_ips_admin_actions.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.network import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
index 38d68c2..d5556b8 100644
--- a/tempest/api/network/admin/test_l3_agent_scheduler.py
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.network import base
+from tempest.common.utils import data_utils
from tempest import exceptions
from tempest import test
diff --git a/tempest/api/network/admin/test_quotas.py b/tempest/api/network/admin/test_quotas.py
index f6046d3..63395cc 100644
--- a/tempest/api/network/admin/test_quotas.py
+++ b/tempest/api/network/admin/test_quotas.py
@@ -14,9 +14,9 @@
# under the License.
import six
-from tempest_lib.common.utils import data_utils
from tempest.api.network import base
+from tempest.common.utils import data_utils
from tempest import test
@@ -61,7 +61,7 @@
# Change quotas for tenant
quota_set = self.admin_client.update_quotas(tenant_id,
- **new_quotas)
+ **new_quotas)['quota']
self.addCleanup(self.admin_client.reset_quotas, tenant_id)
for key, value in six.iteritems(new_quotas):
self.assertEqual(value, quota_set[key])
diff --git a/tempest/api/network/admin/test_routers_dvr.py b/tempest/api/network/admin/test_routers_dvr.py
index e59be02..9e2d080 100644
--- a/tempest/api/network/admin/test_routers_dvr.py
+++ b/tempest/api/network/admin/test_routers_dvr.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.network import base_routers as base
+from tempest.common.utils import data_utils
from tempest import test
@@ -36,10 +35,10 @@
super(RoutersTestDVR, cls).resource_setup()
name = data_utils.rand_name('pretest-check')
router = cls.admin_client.create_router(name)
- if 'distributed' not in router['router']:
- msg = "'distributed' attribute not found. DVR Possibly not enabled"
- raise cls.skipException(msg)
cls.admin_client.delete_router(router['router']['id'])
+ if 'distributed' not in router['router']:
+ msg = "'distributed' flag not found. DVR Possibly not enabled"
+ raise cls.skipException(msg)
@test.idempotent_id('08a2a0a8-f1e4-4b34-8e30-e522e836c44e')
def test_distributed_router_creation(self):
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index bbefc25..fda8fc3 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -15,9 +15,9 @@
import netaddr
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
+from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
import tempest.test
diff --git a/tempest/api/network/base_security_groups.py b/tempest/api/network/base_security_groups.py
index 6699bf7..1cef2cc 100644
--- a/tempest/api/network/base_security_groups.py
+++ b/tempest/api/network/base_security_groups.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.network import base
+from tempest.common.utils import data_utils
class BaseSecGroupTest(base.BaseNetworkTest):
diff --git a/tempest/api/network/test_dhcp_ipv6.py b/tempest/api/network/test_dhcp_ipv6.py
index 5d798e3..f362f85 100644
--- a/tempest/api/network/test_dhcp_ipv6.py
+++ b/tempest/api/network/test_dhcp_ipv6.py
@@ -17,10 +17,10 @@
import random
import six
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.network import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/network/test_extra_dhcp_options.py b/tempest/api/network/test_extra_dhcp_options.py
index 72ac821..87e3413 100644
--- a/tempest/api/network/test_extra_dhcp_options.py
+++ b/tempest/api/network/test_extra_dhcp_options.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.network import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index 57dab5f..f0923d2 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -14,9 +14,9 @@
# under the License.
import netaddr
-from tempest_lib.common.utils import data_utils
from tempest.api.network import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/network/test_floating_ips_negative.py b/tempest/api/network/test_floating_ips_negative.py
index 8790102..e8624d8 100644
--- a/tempest/api/network/test_floating_ips_negative.py
+++ b/tempest/api/network/test_floating_ips_negative.py
@@ -14,10 +14,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.network import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/network/test_metering_extensions.py b/tempest/api/network/test_metering_extensions.py
index 68bc3cd..ee0dcb0 100644
--- a/tempest/api/network/test_metering_extensions.py
+++ b/tempest/api/network/test_metering_extensions.py
@@ -13,9 +13,9 @@
# under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest.api.network import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index 7a96f34..842a56d 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -16,11 +16,11 @@
import netaddr
import six
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.network import base
from tempest.common import custom_matchers
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/network/test_networks_negative.py b/tempest/api/network/test_networks_negative.py
index ae530c2..5dc1c21 100644
--- a/tempest/api/network/test_networks_negative.py
+++ b/tempest/api/network/test_networks_negative.py
@@ -14,10 +14,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.network import base
+from tempest.common.utils import data_utils
from tempest import test
@@ -57,3 +57,38 @@
non_exist_id = data_utils.rand_name('network')
self.assertRaises(lib_exc.NotFound, self.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,
+ non_exist_id, name='new_name')
+
+ @test.attr(type=['negative'])
+ @test.idempotent_id('a176c859-99fb-42ec-a208-8a85b552a239')
+ 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)
+
+ @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)
+
+ @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,
+ non_exist_port_id, name='new_name')
+
+ @test.attr(type=['negative'])
+ @test.idempotent_id('49ec2bbd-ac2e-46fd-8054-798e679ff894')
+ 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)
diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py
index 29600c5..6a8fbec 100644
--- a/tempest/api/network/test_ports.py
+++ b/tempest/api/network/test_ports.py
@@ -16,11 +16,11 @@
import socket
import netaddr
-from tempest_lib.common.utils import data_utils
from tempest.api.network import base
from tempest.api.network import base_security_groups as sec_base
from tempest.common import custom_matchers
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
@@ -156,26 +156,21 @@
network = self.create_network()
subnet = self.create_subnet(network)
self.addCleanup(self.client.delete_subnet, subnet['id'])
- # Create two ports specifying a fixed_ips
- address = self._get_ipaddress_from_tempest_conf()
- _fixed_ip_1 = str(address + 3)
- _fixed_ip_2 = str(address + 4)
- fixed_ips_1 = [{'ip_address': _fixed_ip_1}]
- port_1 = self.client.create_port(network_id=network['id'],
- fixed_ips=fixed_ips_1)
+ # Create two ports
+ port_1 = self.client.create_port(network_id=network['id'])
self.addCleanup(self.client.delete_port, port_1['port']['id'])
- fixed_ips_2 = [{'ip_address': _fixed_ip_2}]
- port_2 = self.client.create_port(network_id=network['id'],
- fixed_ips=fixed_ips_2)
+ port_2 = self.client.create_port(network_id=network['id'])
self.addCleanup(self.client.delete_port, port_2['port']['id'])
# List ports filtered by fixed_ips
- fixed_ips = 'ip_address=' + _fixed_ip_1
+ 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)
+ # 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'],
- _fixed_ip_1)
+ port_1_fixed_ip)
self.assertEqual(ports[0]['network_id'], network['id'])
@test.idempotent_id('5ad01ed0-0e6e-4c5d-8194-232801b15c72')
@@ -344,8 +339,6 @@
super(PortsAdminExtendedAttrsTestJSON, cls).resource_setup()
cls.network = cls.create_network()
cls.host_id = socket.gethostname()
- cls.tenant = cls.identity_client.get_tenant_by_name(
- CONF.identity.tenant_name)
@test.idempotent_id('8e8569c1-9ac7-44db-8bc1-f5fb2814f29b')
def test_create_port_binding_ext_attr(self):
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index 35072b4..78b51c8 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -15,9 +15,9 @@
import netaddr
import six
-from tempest_lib.common.utils import data_utils
from tempest.api.network import base_routers as base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
@@ -270,33 +270,57 @@
@test.idempotent_id('c86ac3a8-50bd-4b00-a6b8-62af84a0765c')
@test.requires_ext(extension='extraroute', service='network')
def test_update_extra_route(self):
- self.network = self.create_network()
- self.name = self.network['name']
- self.subnet = self.create_subnet(self.network)
- # Add router interface with subnet id
+ # Create different cidr for each subnet to avoid cidr duplicate
+ # The cidr starts from tenant_cidr
+ next_cidr = netaddr.IPNetwork(self.tenant_cidr)
+ # Prepare to build several routes
+ test_routes = []
+ routes_num = 5
+ # Create a router
self.router = self._create_router(
data_utils.rand_name('router-'), True)
- self.create_router_interface(self.router['id'], self.subnet['id'])
self.addCleanup(
self._delete_extra_routes,
self.router['id'])
# Update router extra route, second ip of the range is
# used as next hop
- cidr = netaddr.IPNetwork(self.subnet['cidr'])
- next_hop = str(cidr[2])
- destination = str(self.subnet['cidr'])
+ for i in range(routes_num):
+ network = self.create_network()
+ subnet = self.create_subnet(network, cidr=next_cidr)
+ next_cidr = next_cidr.next()
+
+ # Add router interface with subnet id
+ self.create_router_interface(self.router['id'], subnet['id'])
+
+ cidr = netaddr.IPNetwork(subnet['cidr'])
+ next_hop = str(cidr[2])
+ destination = str(subnet['cidr'])
+ test_routes.append(
+ {'nexthop': next_hop, 'destination': destination}
+ )
+
+ test_routes.sort(key=lambda x: x['destination'])
extra_route = self.client.update_extra_routes(self.router['id'],
- next_hop, destination)
- self.assertEqual(1, len(extra_route['router']['routes']))
- self.assertEqual(destination,
- extra_route['router']['routes'][0]['destination'])
- self.assertEqual(next_hop,
- extra_route['router']['routes'][0]['nexthop'])
+ test_routes)
show_body = self.client.show_router(self.router['id'])
- self.assertEqual(destination,
- show_body['router']['routes'][0]['destination'])
- self.assertEqual(next_hop,
- show_body['router']['routes'][0]['nexthop'])
+ # Assert the number of routes
+ self.assertEqual(routes_num, len(extra_route['router']['routes']))
+ self.assertEqual(routes_num, len(show_body['router']['routes']))
+
+ routes = extra_route['router']['routes']
+ routes.sort(key=lambda x: x['destination'])
+ # Assert the nexthops & destination
+ for i in range(routes_num):
+ self.assertEqual(test_routes[i]['destination'],
+ routes[i]['destination'])
+ self.assertEqual(test_routes[i]['nexthop'], routes[i]['nexthop'])
+
+ routes = show_body['router']['routes']
+ routes.sort(key=lambda x: x['destination'])
+ for i in range(routes_num):
+ self.assertEqual(test_routes[i]['destination'],
+ routes[i]['destination'])
+ self.assertEqual(test_routes[i]['nexthop'], routes[i]['nexthop'])
def _delete_extra_routes(self, router_id):
self.client.delete_extra_routes(router_id)
diff --git a/tempest/api/network/test_routers_negative.py b/tempest/api/network/test_routers_negative.py
index d2afcba..90da6fd 100644
--- a/tempest/api/network/test_routers_negative.py
+++ b/tempest/api/network/test_routers_negative.py
@@ -14,10 +14,10 @@
# under the License.
import netaddr
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.network import base_routers as base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/network/test_security_groups.py b/tempest/api/network/test_security_groups.py
index 05f0de4..ccc5232 100644
--- a/tempest/api/network/test_security_groups.py
+++ b/tempest/api/network/test_security_groups.py
@@ -14,9 +14,9 @@
# under the License.
import six
-from tempest_lib.common.utils import data_utils
from tempest.api.network import base_security_groups as base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/object_storage/test_account_quotas.py b/tempest/api/object_storage/test_account_quotas.py
index bbdf367..78707d8 100644
--- a/tempest/api/object_storage/test_account_quotas.py
+++ b/tempest/api/object_storage/test_account_quotas.py
@@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.object_storage import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/object_storage/test_account_quotas_negative.py b/tempest/api/object_storage/test_account_quotas_negative.py
index e945e1e..2bf331a 100644
--- a/tempest/api/object_storage/test_account_quotas_negative.py
+++ b/tempest/api/object_storage/test_account_quotas_negative.py
@@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import decorators
from tempest_lib import exceptions as lib_exc
from tempest.api.object_storage import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/object_storage/test_account_services.py b/tempest/api/object_storage/test_account_services.py
index ac41148..6bab9b3 100644
--- a/tempest/api/object_storage/test_account_services.py
+++ b/tempest/api/object_storage/test_account_services.py
@@ -16,11 +16,11 @@
import random
from six import moves
-from tempest_lib.common.utils import data_utils
import testtools
from tempest.api.object_storage import base
from tempest.common import custom_matchers
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/object_storage/test_container_acl.py b/tempest/api/object_storage/test_container_acl.py
index 4df813d..c1b6711 100644
--- a/tempest/api/object_storage/test_container_acl.py
+++ b/tempest/api/object_storage/test_container_acl.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.object_storage import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/object_storage/test_container_acl_negative.py b/tempest/api/object_storage/test_container_acl_negative.py
index 1c42e97..3bb47f0 100644
--- a/tempest/api/object_storage/test_container_acl_negative.py
+++ b/tempest/api/object_storage/test_container_acl_negative.py
@@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.object_storage import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/object_storage/test_container_quotas.py b/tempest/api/object_storage/test_container_quotas.py
index 2217d18..c78b4c3 100644
--- a/tempest/api/object_storage/test_container_quotas.py
+++ b/tempest/api/object_storage/test_container_quotas.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.object_storage import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/object_storage/test_container_staticweb.py b/tempest/api/object_storage/test_container_staticweb.py
index 20452ab..4b4b499 100644
--- a/tempest/api/object_storage/test_container_staticweb.py
+++ b/tempest/api/object_storage/test_container_staticweb.py
@@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.object_storage import base
from tempest.common import custom_matchers
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/object_storage/test_container_sync.py b/tempest/api/object_storage/test_container_sync.py
index 06e700b..0e39b7e 100644
--- a/tempest/api/object_storage/test_container_sync.py
+++ b/tempest/api/object_storage/test_container_sync.py
@@ -16,12 +16,12 @@
import time
from six.moves.urllib import parse as urlparse
-from tempest_lib.common.utils import data_utils
from tempest_lib import decorators
import testtools
from tempest.api.object_storage import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/object_storage/test_object_expiry.py b/tempest/api/object_storage/test_object_expiry.py
index b263050..1c9d582 100644
--- a/tempest/api/object_storage/test_object_expiry.py
+++ b/tempest/api/object_storage/test_object_expiry.py
@@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
import time
from tempest.api.object_storage import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/object_storage/test_object_formpost.py b/tempest/api/object_storage/test_object_formpost.py
index ce587d7..356f560 100644
--- a/tempest/api/object_storage/test_object_formpost.py
+++ b/tempest/api/object_storage/test_object_formpost.py
@@ -17,9 +17,9 @@
import time
from six.moves.urllib import parse as urlparse
-from tempest_lib.common.utils import data_utils
from tempest.api.object_storage import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/object_storage/test_object_formpost_negative.py b/tempest/api/object_storage/test_object_formpost_negative.py
index 89deca2..7d9e115 100644
--- a/tempest/api/object_storage/test_object_formpost_negative.py
+++ b/tempest/api/object_storage/test_object_formpost_negative.py
@@ -17,10 +17,10 @@
import time
from six.moves.urllib import parse as urlparse
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.object_storage import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/object_storage/test_object_services.py b/tempest/api/object_storage/test_object_services.py
index 3396d8f..2198753 100644
--- a/tempest/api/object_storage/test_object_services.py
+++ b/tempest/api/object_storage/test_object_services.py
@@ -21,10 +21,10 @@
import six
from six import moves
-from tempest_lib.common.utils import data_utils
from tempest.api.object_storage import base
from tempest.common import custom_matchers
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/object_storage/test_object_slo.py b/tempest/api/object_storage/test_object_slo.py
index 6fc7821..5811cb8 100644
--- a/tempest/api/object_storage/test_object_slo.py
+++ b/tempest/api/object_storage/test_object_slo.py
@@ -13,13 +13,13 @@
# under the License.
import hashlib
-import json
-from tempest_lib.common.utils import data_utils
+from oslo_serialization import jsonutils as json
from tempest_lib import exceptions as lib_exc
from tempest.api.object_storage import base
from tempest.common import custom_matchers
+from tempest.common.utils import data_utils
from tempest import test
# Each segment, except for the final one, must be at least 1 megabyte
diff --git a/tempest/api/object_storage/test_object_temp_url.py b/tempest/api/object_storage/test_object_temp_url.py
index 8748269..3d28f6e 100644
--- a/tempest/api/object_storage/test_object_temp_url.py
+++ b/tempest/api/object_storage/test_object_temp_url.py
@@ -17,9 +17,9 @@
import time
from six.moves.urllib import parse as urlparse
-from tempest_lib.common.utils import data_utils
from tempest.api.object_storage import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/object_storage/test_object_temp_url_negative.py b/tempest/api/object_storage/test_object_temp_url_negative.py
index 233cced..6d06143 100644
--- a/tempest/api/object_storage/test_object_temp_url_negative.py
+++ b/tempest/api/object_storage/test_object_temp_url_negative.py
@@ -17,10 +17,10 @@
import time
from six.moves.urllib import parse as urlparse
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.object_storage import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/object_storage/test_object_version.py b/tempest/api/object_storage/test_object_version.py
index 923166a..24ec3f5 100644
--- a/tempest/api/object_storage/test_object_version.py
+++ b/tempest/api/object_storage/test_object_version.py
@@ -15,9 +15,8 @@
import testtools
-from tempest_lib.common.utils import data_utils
-
from tempest.api.object_storage import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index af97794..266f726 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -13,10 +13,10 @@
import os.path
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
import yaml
+from tempest.common.utils import data_utils
from tempest import config
import tempest.test
diff --git a/tempest/api/orchestration/stacks/test_environment.py b/tempest/api/orchestration/stacks/test_environment.py
index ecb824b..0416bc7 100644
--- a/tempest/api/orchestration/stacks/test_environment.py
+++ b/tempest/api/orchestration/stacks/test_environment.py
@@ -12,9 +12,8 @@
import logging
-from tempest_lib.common.utils import data_utils
-
from tempest.api.orchestration import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/orchestration/stacks/test_limits.py b/tempest/api/orchestration/stacks/test_limits.py
index 4291d76..bb5b89d 100644
--- a/tempest/api/orchestration/stacks/test_limits.py
+++ b/tempest/api/orchestration/stacks/test_limits.py
@@ -12,10 +12,10 @@
import logging
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.orchestration import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/orchestration/stacks/test_neutron_resources.py b/tempest/api/orchestration/stacks/test_neutron_resources.py
index a0706ff..b27d6c9 100644
--- a/tempest/api/orchestration/stacks/test_neutron_resources.py
+++ b/tempest/api/orchestration/stacks/test_neutron_resources.py
@@ -14,10 +14,10 @@
import logging
import netaddr
-from tempest_lib.common.utils import data_utils
from tempest.api.orchestration import base
from tempest import clients
+from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
from tempest import test
@@ -183,7 +183,7 @@
def test_created_server(self):
"""Verifies created sever."""
server_id = self.test_resources.get('Server')['physical_resource_id']
- server = self.servers_client.get_server(server_id)
+ server = self.servers_client.show_server(server_id)
self.assertEqual(self.keypair_name, server['key_name'])
self.assertEqual('ACTIVE', server['status'])
network = server['addresses'][self.neutron_basic_template['resources'][
diff --git a/tempest/api/orchestration/stacks/test_non_empty_stack.py b/tempest/api/orchestration/stacks/test_non_empty_stack.py
index bffc306..494b6fd 100644
--- a/tempest/api/orchestration/stacks/test_non_empty_stack.py
+++ b/tempest/api/orchestration/stacks/test_non_empty_stack.py
@@ -12,9 +12,8 @@
import logging
-from tempest_lib.common.utils import data_utils
-
from tempest.api.orchestration import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/orchestration/stacks/test_nova_keypair_resources.py b/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
index c79c3c3..6a04dbd 100644
--- a/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
+++ b/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
@@ -13,9 +13,8 @@
import logging
-from tempest_lib.common.utils import data_utils
-
from tempest.api.orchestration import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/orchestration/stacks/test_soft_conf.py b/tempest/api/orchestration/stacks/test_soft_conf.py
index 13f0a6c..34d93e4 100644
--- a/tempest/api/orchestration/stacks/test_soft_conf.py
+++ b/tempest/api/orchestration/stacks/test_soft_conf.py
@@ -11,10 +11,10 @@
# under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.orchestration import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/orchestration/stacks/test_stacks.py b/tempest/api/orchestration/stacks/test_stacks.py
index 9ce8ebeb..abec906 100644
--- a/tempest/api/orchestration/stacks/test_stacks.py
+++ b/tempest/api/orchestration/stacks/test_stacks.py
@@ -11,9 +11,9 @@
# under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest.api.orchestration import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/orchestration/stacks/test_swift_resources.py b/tempest/api/orchestration/stacks/test_swift_resources.py
index dadabfa..30166df 100644
--- a/tempest/api/orchestration/stacks/test_swift_resources.py
+++ b/tempest/api/orchestration/stacks/test_swift_resources.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.orchestration import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/orchestration/stacks/test_templates.py b/tempest/api/orchestration/stacks/test_templates.py
index 5ccfdfb..9154175 100644
--- a/tempest/api/orchestration/stacks/test_templates.py
+++ b/tempest/api/orchestration/stacks/test_templates.py
@@ -10,9 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.orchestration import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/orchestration/stacks/test_volumes.py b/tempest/api/orchestration/stacks/test_volumes.py
index f40ca02..d8f117e 100644
--- a/tempest/api/orchestration/stacks/test_volumes.py
+++ b/tempest/api/orchestration/stacks/test_volumes.py
@@ -12,10 +12,10 @@
import logging
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.orchestration import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/telemetry/base.py b/tempest/api/telemetry/base.py
index e8f8abe..0f9b7dd 100644
--- a/tempest/api/telemetry/base.py
+++ b/tempest/api/telemetry/base.py
@@ -13,9 +13,9 @@
import time
from oslo_utils import timeutils
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
+from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
import tempest.test
diff --git a/tempest/api/telemetry/test_telemetry_alarming_api.py b/tempest/api/telemetry/test_telemetry_alarming_api.py
index 99b5c37..13da9cb 100644
--- a/tempest/api/telemetry/test_telemetry_alarming_api.py
+++ b/tempest/api/telemetry/test_telemetry_alarming_api.py
@@ -10,10 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.telemetry import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/volume/admin/test_multi_backend.py b/tempest/api/volume/admin/test_multi_backend.py
index b8047b2..c7e989d 100644
--- a/tempest/api/volume/admin/test_multi_backend.py
+++ b/tempest/api/volume/admin/test_multi_backend.py
@@ -11,9 +11,9 @@
# under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest.api.volume import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/volume/admin/test_snapshots_actions.py b/tempest/api/volume/admin/test_snapshots_actions.py
index b885f7d..c860b4b 100644
--- a/tempest/api/volume/admin/test_snapshots_actions.py
+++ b/tempest/api/volume/admin/test_snapshots_actions.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.volume import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/volume/admin/test_volume_quotas.py b/tempest/api/volume/admin/test_volume_quotas.py
index ec8e040..1a48204 100644
--- a/tempest/api/volume/admin/test_volume_quotas.py
+++ b/tempest/api/volume/admin/test_volume_quotas.py
@@ -13,9 +13,9 @@
# under the License.
import six
-from tempest_lib.common.utils import data_utils
from tempest.api.volume import base
+from tempest.common.utils import data_utils
from tempest import test
QUOTA_KEYS = ['gigabytes', 'snapshots', 'volumes']
diff --git a/tempest/api/volume/admin/test_volume_types.py b/tempest/api/volume/admin/test_volume_types.py
index ea9864e..b79c185 100644
--- a/tempest/api/volume/admin/test_volume_types.py
+++ b/tempest/api/volume/admin/test_volume_types.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.volume import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs.py b/tempest/api/volume/admin/test_volume_types_extra_specs.py
index 2feb062..c840697 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.volume import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
index a70a940..e49e8b2 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
@@ -15,10 +15,10 @@
import uuid
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.volume import base
+from tempest.common.utils import data_utils
from tempest import test
diff --git a/tempest/api/volume/admin/test_volumes_actions.py b/tempest/api/volume/admin/test_volumes_actions.py
index 8a30a10..4288d58 100644
--- a/tempest/api/volume/admin/test_volumes_actions.py
+++ b/tempest/api/volume/admin/test_volumes_actions.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils as utils
-
from tempest.api.volume import base
+from tempest.common.utils import data_utils as utils
from tempest import test
diff --git a/tempest/api/volume/admin/test_volumes_backup.py b/tempest/api/volume/admin/test_volumes_backup.py
index 8b85da3..8015c35 100644
--- a/tempest/api/volume/admin/test_volumes_backup.py
+++ b/tempest/api/volume/admin/test_volumes_backup.py
@@ -14,9 +14,9 @@
# under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest.api.volume import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
@@ -38,6 +38,10 @@
cls.volume = cls.create_volume()
+ def _delete_backup(self, backup_id):
+ self.backups_adm_client.delete_backup(backup_id)
+ self.backups_adm_client.wait_for_backup_deletion(backup_id)
+
@test.idempotent_id('a66eb488-8ee1-47d4-8e9f-575a095728c6')
def test_volume_backup_create_get_detailed_list_restore_delete(self):
# Create backup
@@ -74,6 +78,52 @@
self.admin_volume_client.wait_for_volume_status(
restore['volume_id'], 'available')
+ @test.idempotent_id('a99c54a1-dd80-4724-8a13-13bf58d4068d')
+ def test_volume_backup_export_import(self):
+ # Create backup
+ backup_name = data_utils.rand_name('Backup')
+ backup = self.backups_adm_client.create_backup(self.volume['id'],
+ name=backup_name)
+ self.addCleanup(self._delete_backup, backup['id'])
+ self.assertEqual(backup_name, backup['name'])
+ self.backups_adm_client.wait_for_backup_status(backup['id'],
+ 'available')
+
+ # Export Backup
+ export_backup = self.backups_adm_client.export_backup(backup['id'])
+ self.assertIn('backup_service', export_backup)
+ self.assertIn('backup_url', export_backup)
+ self.assertTrue(export_backup['backup_service'].startswith(
+ 'cinder.backup.drivers'))
+ self.assertIsNotNone(export_backup['backup_url'])
+
+ # Import Backup
+ import_backup = self.backups_adm_client.import_backup(
+ backup_service=export_backup['backup_service'],
+ backup_url=export_backup['backup_url'])
+ self.addCleanup(self._delete_backup, import_backup['id'])
+ self.assertIn("id", import_backup)
+ self.backups_adm_client.wait_for_backup_status(import_backup['id'],
+ 'available')
+
+ # Verify Import Backup
+ backups = self.backups_adm_client.list_backups(detail=True)
+ self.assertIn(import_backup['id'], [b['id'] for b in backups])
+
+ # Restore backup
+ restore = self.backups_adm_client.restore_backup(import_backup['id'])
+ self.addCleanup(self.admin_volume_client.delete_volume,
+ restore['volume_id'])
+ self.assertEqual(import_backup['id'], restore['backup_id'])
+ self.admin_volume_client.wait_for_volume_status(restore['volume_id'],
+ 'available')
+
+ # Verify if restored volume is there in volume list
+ volumes = self.admin_volume_client.list_volumes()
+ self.assertIn(restore['volume_id'], [v['id'] for v in volumes])
+ self.backups_adm_client.wait_for_backup_status(import_backup['id'],
+ 'available')
+
class VolumesBackupsV1Test(VolumesBackupsV2Test):
_api_version = 1
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 7f56b18..b67a6d2 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -14,10 +14,10 @@
# under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.common import fixed_network
+from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
import tempest.test
@@ -62,6 +62,7 @@
super(BaseVolumeTest, cls).setup_clients()
cls.servers_client = cls.os.servers_client
cls.networks_client = cls.os.networks_client
+ cls.images_client = cls.os.images_client
if cls._api_version == 1:
cls.snapshots_client = cls.os.snapshots_client
diff --git a/tempest/api/volume/test_qos.py b/tempest/api/volume/test_qos.py
index 863a698..84fd7f6 100644
--- a/tempest/api/volume/test_qos.py
+++ b/tempest/api/volume/test_qos.py
@@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils as utils
-
from tempest.api.volume import base
+from tempest.common.utils import data_utils as utils
from tempest import test
diff --git a/tempest/api/volume/test_volumes_actions.py b/tempest/api/volume/test_volumes_actions.py
index 375d34a..067c0c1 100644
--- a/tempest/api/volume/test_volumes_actions.py
+++ b/tempest/api/volume/test_volumes_actions.py
@@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
from tempest.api.volume import base
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import config
from tempest import test
import testtools
@@ -38,7 +38,8 @@
# Create a test shared instance
srv_name = data_utils.rand_name(cls.__name__ + '-Instance')
cls.server = cls.create_server(srv_name)
- cls.servers_client.wait_for_server_status(cls.server['id'], 'ACTIVE')
+ waiters.wait_for_server_status(cls.servers_client, cls.server['id'],
+ 'ACTIVE')
# Create a test shared volume for attach/detach tests
cls.volume = cls.create_volume()
diff --git a/tempest/api/volume/test_volumes_get.py b/tempest/api/volume/test_volumes_get.py
index 8337f8d..a90f9ca 100644
--- a/tempest/api/volume/test_volumes_get.py
+++ b/tempest/api/volume/test_volumes_get.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
from testtools import matchers
from tempest.api.volume import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
@@ -131,7 +131,11 @@
@test.idempotent_id('54a01030-c7fc-447c-86ee-c1182beae638')
@test.services('image')
def test_volume_create_get_update_delete_from_image(self):
- self._volume_create_get_update_delete(imageRef=CONF.compute.image_ref)
+ image = self.images_client.show_image(CONF.compute.image_ref)
+ min_disk = image.get('minDisk')
+ disk_size = max(min_disk, CONF.volume.volume_size)
+ self._volume_create_get_update_delete(
+ imageRef=CONF.compute.image_ref, size=disk_size)
@test.idempotent_id('3f591b4a-7dc6-444c-bd51-77469506b3a1')
def test_volume_create_get_update_delete_as_clone(self):
diff --git a/tempest/api/volume/test_volumes_list.py b/tempest/api/volume/test_volumes_list.py
index da0d5aa..3847877 100644
--- a/tempest/api/volume/test_volumes_list.py
+++ b/tempest/api/volume/test_volumes_list.py
@@ -16,10 +16,10 @@
import operator
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from testtools import matchers
from tempest.api.volume import base
+from tempest.common.utils import data_utils
from tempest import test
LOG = logging.getLogger(__name__)
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index b591a1a..5203444 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -15,10 +15,11 @@
import uuid
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.volume import base
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import test
@@ -180,8 +181,11 @@
def test_attach_volumes_with_nonexistent_volume_id(self):
srv_name = data_utils.rand_name('Instance')
server = self.create_server(srv_name)
+ self.addCleanup(self.servers_client.wait_for_server_termination,
+ server['id'])
self.addCleanup(self.servers_client.delete_server, server['id'])
- self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client, server['id'],
+ 'ACTIVE')
self.assertRaises(lib_exc.NotFound,
self.client.attach_volume,
str(uuid.uuid4()),
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 550c3b6..1df1896 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -11,9 +11,10 @@
# under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest.api.volume import base
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import config
from tempest import test
@@ -70,7 +71,8 @@
server_name = data_utils.rand_name('instance')
server = self.create_server(server_name)
self.addCleanup(self.servers_client.delete_server, server['id'])
- self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client, server['id'],
+ 'ACTIVE')
mountpoint = '/dev/%s' % CONF.compute.volume_device_name
self.servers_client.attach_volume(
server['id'], self.volume_origin['id'], mountpoint)
diff --git a/tempest/api/volume/test_volumes_snapshots_negative.py b/tempest/api/volume/test_volumes_snapshots_negative.py
index 77f8552..b604360 100644
--- a/tempest/api/volume/test_volumes_snapshots_negative.py
+++ b/tempest/api/volume/test_volumes_snapshots_negative.py
@@ -12,10 +12,10 @@
import uuid
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.api.volume import base
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
diff --git a/tempest/api/volume/v2/test_volumes_list.py b/tempest/api/volume/v2/test_volumes_list.py
index 4c774da..d1eb694 100644
--- a/tempest/api/volume/v2/test_volumes_list.py
+++ b/tempest/api/volume/v2/test_volumes_list.py
@@ -14,6 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from six.moves.urllib import parse
+
from tempest.api.volume import base
from tempest import test
@@ -87,3 +89,101 @@
_list_details_with_multiple_params()
_list_details_with_multiple_params(sort_dir='desc')
+
+ def _test_pagination(self, resource, ids=None, limit=1, **kwargs):
+ """Check list pagination functionality for a resource.
+
+ This method requests the list of resources and follows pagination
+ links.
+
+ If an iterable is supplied in ids it will check that all ids are
+ retrieved and that only those are listed, that we will get a next
+ link for an empty page if the number of items is divisible by used
+ limit (this is expected behavior).
+
+ We can specify number of items per request using limit argument.
+ """
+
+ # Get list method for the type of resource from the client
+ client = getattr(self, resource + '_client')
+ method = getattr(client, 'list_' + resource)
+
+ # Include limit in params for list request
+ params = kwargs.pop('params', {})
+ params['limit'] = limit
+
+ # Store remaining items we are expecting from list
+ if ids is not None:
+ remaining = list(ids)
+ else:
+ remaining = None
+
+ # Mark that we are not comming from a next link
+ next = None
+
+ while True:
+ # Get a list page
+ response = method(return_body=True, params=params, **kwargs)
+
+ # If we have to check ids
+ if remaining is not None:
+ # Confirm we receive expected number of elements
+ num_expected = min(len(remaining), limit)
+ self.assertEqual(num_expected, len(response[resource]),
+ 'Requested %(#expect)d but got %(#received)d '
+ % {'#expect': num_expected,
+ '#received': len(response[resource])})
+
+ # For each received element
+ for element in response[resource]:
+ element_id = element['id']
+ # Check it's one of expected ids
+ self.assertIn(element_id,
+ ids,
+ 'Id %(id)s is not in expected ids %(ids)s' %
+ {'id': element_id, 'ids': ids})
+ # If not in remaining, we have received it twice
+ self.assertIn(element_id,
+ remaining,
+ 'Id %s was received twice' % element_id)
+ # We no longer expect it
+ remaining.remove(element_id)
+
+ # If we come from a next link check that absolute url is the same
+ # as the one used for this request
+ if next:
+ self.assertEqual(next, response.response['content-location'])
+
+ # Get next from response
+ next = None
+ for link in response.get(resource + '_links', ()):
+ if link['rel'] == 'next':
+ next = link['href']
+ break
+
+ # Check if we have next and we shouldn't or the other way around
+ if remaining is not None:
+ if remaining or (num_expected and len(ids) % limit == 0):
+ self.assertIsNotNone(next, 'Missing link to next page')
+ else:
+ self.assertIsNone(next, 'Unexpected link to next page')
+
+ # If we can follow to the next page, get params from url to make
+ # request in the form of a relative URL
+ if next:
+ params = parse.urlparse(next).query
+
+ # If cannot follow make sure it's because we have finished
+ else:
+ self.assertListEqual([], remaining or [],
+ 'No more pages reported, but still '
+ 'missing ids %s' % remaining)
+ break
+
+ @test.idempotent_id('e9138a2c-f67b-4796-8efa-635c196d01de')
+ def test_volume_list_details_pagination(self):
+ self._test_pagination('volumes', ids=self.volume_id_list, detail=True)
+
+ @test.idempotent_id('af55e775-8e4b-4feb-8719-215c43b0238c')
+ def test_volume_list_pagination(self):
+ self._test_pagination('volumes', ids=self.volume_id_list, detail=False)
diff --git a/tempest/api_schema/response/compute/v2_1/fixed_ips.py b/tempest/api_schema/response/compute/v2_1/fixed_ips.py
index 6d5ba67..3586b70 100644
--- a/tempest/api_schema/response/compute/v2_1/fixed_ips.py
+++ b/tempest/api_schema/response/compute/v2_1/fixed_ips.py
@@ -12,6 +12,8 @@
# 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': {
@@ -20,10 +22,7 @@
'fixed_ip': {
'type': 'object',
'properties': {
- 'address': {
- 'type': 'string',
- 'format': 'ip-address'
- },
+ 'address': parameter_types.ip_address,
'cidr': {'type': 'string'},
'host': {'type': 'string'},
'hostname': {'type': 'string'}
diff --git a/tempest/api_schema/response/compute/v2_1/floating_ips.py b/tempest/api_schema/response/compute/v2_1/floating_ips.py
index 28dd40a..3551681 100644
--- a/tempest/api_schema/response/compute/v2_1/floating_ips.py
+++ b/tempest/api_schema/response/compute/v2_1/floating_ips.py
@@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest.api_schema.response.compute.v2_1 import parameter_types
+
common_floating_ip_info = {
'type': 'object',
'properties': {
@@ -21,14 +23,8 @@
'id': {'type': ['integer', 'string']},
'pool': {'type': ['string', 'null']},
'instance_id': {'type': ['string', 'null']},
- 'ip': {
- 'type': 'string',
- 'format': 'ip-address'
- },
- 'fixed_ip': {
- 'type': ['string', 'null'],
- 'format': 'ip-address'
- }
+ 'ip': parameter_types.ip_address,
+ 'fixed_ip': parameter_types.ip_address
},
'additionalProperties': False,
'required': ['id', 'pool', 'instance_id',
@@ -131,18 +127,12 @@
'items': {
'type': 'object',
'properties': {
- 'address': {
- 'type': 'string',
- 'format': 'ip-address'
- },
+ 'address': parameter_types.ip_address,
'instance_uuid': {'type': ['string', 'null']},
'interface': {'type': ['string', 'null']},
'pool': {'type': ['string', 'null']},
'project_id': {'type': ['string', 'null']},
- 'fixed_ip': {
- 'type': ['string', 'null'],
- 'format': 'ip-address'
- }
+ 'fixed_ip': parameter_types.ip_address
},
'additionalProperties': False,
# NOTE: fixed_ip is introduced after JUNO release,
diff --git a/tempest/api_schema/response/compute/v2_1/hypervisors.py b/tempest/api_schema/response/compute/v2_1/hypervisors.py
index e24389d..05901b6 100644
--- a/tempest/api_schema/response/compute/v2_1/hypervisors.py
+++ b/tempest/api_schema/response/compute/v2_1/hypervisors.py
@@ -14,6 +14,8 @@
import copy
+from tempest.api_schema.response.compute.v2_1 import parameter_types
+
get_hypervisor_statistics = {
'status_code': [200],
'response_body': {
@@ -57,10 +59,7 @@
'cpu_info': {'type': 'string'},
'current_workload': {'type': 'integer'},
'disk_available_least': {'type': ['integer', 'null']},
- 'host_ip': {
- 'type': 'string',
- 'format': 'ip-address'
- },
+ 'host_ip': parameter_types.ip_address,
'free_disk_gb': {'type': 'integer'},
'free_ram_mb': {'type': 'integer'},
'hypervisor_hostname': {'type': 'string'},
diff --git a/tempest/api_schema/response/compute/v2_1/interfaces.py b/tempest/api_schema/response/compute/v2_1/interfaces.py
index b18fba6..130775b 100644
--- a/tempest/api_schema/response/compute/v2_1/interfaces.py
+++ b/tempest/api_schema/response/compute/v2_1/interfaces.py
@@ -27,10 +27,7 @@
'type': 'string',
'format': 'uuid'
},
- 'ip_address': {
- 'type': 'string',
- 'format': 'ipv4'
- }
+ 'ip_address': parameter_types.ip_address
},
'additionalProperties': False,
'required': ['subnet_id', 'ip_address']
diff --git a/tempest/api_schema/response/compute/v2_1/migrations.py b/tempest/api_schema/response/compute/v2_1/migrations.py
index 722372c..b7d66ea 100644
--- a/tempest/api_schema/response/compute/v2_1/migrations.py
+++ b/tempest/api_schema/response/compute/v2_1/migrations.py
@@ -23,15 +23,15 @@
'type': 'object',
'properties': {
'id': {'type': 'integer'},
- 'status': {'type': 'string'},
- 'instance_uuid': {'type': 'string'},
- 'source_node': {'type': 'string'},
- 'source_compute': {'type': 'string'},
- 'dest_node': {'type': 'string'},
- 'dest_compute': {'type': 'string'},
- 'dest_host': {'type': 'string'},
- 'old_instance_type_id': {'type': 'integer'},
- 'new_instance_type_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']}
},
diff --git a/tempest/api_schema/response/compute/v2_1/parameter_types.py b/tempest/api_schema/response/compute/v2_1/parameter_types.py
index 7b4264c..07cc890 100644
--- a/tempest/api_schema/response/compute/v2_1/parameter_types.py
+++ b/tempest/api_schema/response/compute/v2_1/parameter_types.py
@@ -33,14 +33,27 @@
'pattern': '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
}
+ip_address = {
+ 'oneOf': [
+ {
+ 'type': 'string',
+ 'oneOf': [
+ {'format': 'ipv4'},
+ {'format': 'ipv6'}
+ ]
+ },
+ {'type': 'null'}
+ ]
+}
+
access_ip_v4 = {
'type': 'string',
- 'anyOf': [{'format': 'ipv4'}, {'enum': ['']}]
+ 'oneOf': [{'format': 'ipv4'}, {'enum': ['']}]
}
access_ip_v6 = {
'type': 'string',
- 'anyOf': [{'format': 'ipv6'}, {'enum': ['']}]
+ 'oneOf': [{'format': 'ipv6'}, {'enum': ['']}]
}
addresses = {
@@ -55,7 +68,7 @@
'version': {'type': 'integer'},
'addr': {
'type': 'string',
- 'anyOf': [
+ 'oneOf': [
{'format': 'ipv4'},
{'format': 'ipv6'}
]
diff --git a/tempest/clients.py b/tempest/clients.py
index f0aedd5..20cefbc 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -25,117 +25,125 @@
from tempest import exceptions
from tempest import manager
from tempest.services.baremetal.v1.json.baremetal_client import \
- BaremetalClientJSON
+ BaremetalClient
from tempest.services import botoclients
from tempest.services.compute.json.agents_client import \
- AgentsClientJSON
+ AgentsClient
from tempest.services.compute.json.aggregates_client import \
- AggregatesClientJSON
+ AggregatesClient
from tempest.services.compute.json.availability_zone_client import \
- AvailabilityZoneClientJSON
+ AvailabilityZoneClient
from tempest.services.compute.json.baremetal_nodes_client import \
- BaremetalNodesClientJSON
+ BaremetalNodesClient
from tempest.services.compute.json.certificates_client import \
- CertificatesClientJSON
+ CertificatesClient
from tempest.services.compute.json.extensions_client import \
- ExtensionsClientJSON
-from tempest.services.compute.json.fixed_ips_client import FixedIPsClientJSON
-from tempest.services.compute.json.flavors_client import FlavorsClientJSON
+ 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 \
- FloatingIPsClientJSON
-from tempest.services.compute.json.hosts_client import HostsClientJSON
+ FloatingIPsClient
+from tempest.services.compute.json.hosts_client import HostsClient
from tempest.services.compute.json.hypervisor_client import \
- HypervisorClientJSON
-from tempest.services.compute.json.images_client import ImagesClientJSON
+ HypervisorClient
+from tempest.services.compute.json.images_client import ImagesClient
from tempest.services.compute.json.instance_usage_audit_log_client import \
- InstanceUsagesAuditLogClientJSON
+ InstanceUsagesAuditLogClient
from tempest.services.compute.json.interfaces_client import \
- InterfacesClientJSON
-from tempest.services.compute.json.keypairs_client import KeyPairsClientJSON
-from tempest.services.compute.json.limits_client import LimitsClientJSON
+ 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 \
- MigrationsClientJSON
-from tempest.services.compute.json.networks_client import NetworksClientJSON
+ MigrationsClient
+from tempest.services.compute.json.networks_client import NetworksClient
from tempest.services.compute.json.quota_classes_client import \
- QuotaClassesClientJSON
-from tempest.services.compute.json.quotas_client import QuotasClientJSON
+ QuotaClassesClient
+from tempest.services.compute.json.quotas_client import QuotasClient
from tempest.services.compute.json.security_group_default_rules_client import \
- SecurityGroupDefaultRulesClientJSON
+ SecurityGroupDefaultRulesClient
+from tempest.services.compute.json.security_group_rules_client import \
+ SecurityGroupRulesClient
from tempest.services.compute.json.security_groups_client import \
- SecurityGroupsClientJSON
-from tempest.services.compute.json.servers_client import ServersClientJSON
-from tempest.services.compute.json.services_client import ServicesClientJSON
+ SecurityGroupsClient
+from tempest.services.compute.json.server_groups_client import \
+ ServerGroupsClient
+from tempest.services.compute.json.servers_client import ServersClient
+from tempest.services.compute.json.services_client import ServicesClient
from tempest.services.compute.json.tenant_networks_client import \
- TenantNetworksClientJSON
+ TenantNetworksClient
from tempest.services.compute.json.tenant_usages_client import \
- TenantUsagesClientJSON
+ TenantUsagesClient
from tempest.services.compute.json.volumes_extensions_client import \
- VolumesExtensionsClientJSON
+ VolumesExtensionsClient
from tempest.services.data_processing.v1_1.data_processing_client import \
DataProcessingClient
from tempest.services.database.json.flavors_client import \
- DatabaseFlavorsClientJSON
+ DatabaseFlavorsClient
from tempest.services.database.json.limits_client import \
- DatabaseLimitsClientJSON
+ DatabaseLimitsClient
from tempest.services.database.json.versions_client import \
- DatabaseVersionsClientJSON
+ DatabaseVersionsClient
from tempest.services.identity.v2.json.identity_client import \
- IdentityClientJSON
+ IdentityClient
from tempest.services.identity.v3.json.credentials_client import \
- CredentialsClientJSON
+ CredentialsClient
from tempest.services.identity.v3.json.endpoints_client import \
- EndPointClientJSON
+ EndPointClient
from tempest.services.identity.v3.json.identity_client import \
- IdentityV3ClientJSON
-from tempest.services.identity.v3.json.policy_client import PolicyClientJSON
-from tempest.services.identity.v3.json.region_client import RegionClientJSON
+ IdentityV3Client
+from tempest.services.identity.v3.json.policy_client import PolicyClient
+from tempest.services.identity.v3.json.region_client import RegionClient
from tempest.services.identity.v3.json.service_client import \
- ServiceClientJSON
-from tempest.services.image.v1.json.image_client import ImageClientJSON
-from tempest.services.image.v2.json.image_client import ImageClientV2JSON
+ ServiceClient
+from tempest.services.image.v1.json.image_client import ImageClient
+from tempest.services.image.v2.json.image_client import ImageClientV2
from tempest.services.messaging.json.messaging_client import \
- MessagingClientJSON
-from tempest.services.network.json.network_client import NetworkClientJSON
+ MessagingClient
+from tempest.services.network.json.network_client import NetworkClient
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.telemetry_client import \
- TelemetryClientJSON
+ TelemetryClient
from tempest.services.volume.json.admin.volume_hosts_client import \
- VolumeHostsClientJSON
+ VolumeHostsClient
from tempest.services.volume.json.admin.volume_quotas_client import \
- VolumeQuotasClientJSON
+ VolumeQuotasClient
from tempest.services.volume.json.admin.volume_services_client import \
- VolumesServicesClientJSON
+ VolumesServicesClient
from tempest.services.volume.json.admin.volume_types_client import \
- VolumeTypesClientJSON
+ VolumeTypesClient
from tempest.services.volume.json.availability_zone_client import \
- VolumeAvailabilityZoneClientJSON
-from tempest.services.volume.json.backups_client import BackupsClientJSON
+ VolumeAvailabilityZoneClient
+from tempest.services.volume.json.backups_client import BackupsClient
from tempest.services.volume.json.extensions_client import \
- ExtensionsClientJSON as VolumeExtensionClientJSON
-from tempest.services.volume.json.qos_client import QosSpecsClientJSON
-from tempest.services.volume.json.snapshots_client import SnapshotsClientJSON
-from tempest.services.volume.json.volumes_client import VolumesClientJSON
+ ExtensionsClient as VolumeExtensionClient
+from tempest.services.volume.json.qos_client import QosSpecsClient
+from tempest.services.volume.json.snapshots_client import SnapshotsClient
+from tempest.services.volume.json.volumes_client import VolumesClient
from tempest.services.volume.v2.json.admin.volume_hosts_client import \
- VolumeHostsV2ClientJSON
+ VolumeHostsV2Client
from tempest.services.volume.v2.json.admin.volume_quotas_client import \
VolumeQuotasV2Client
from tempest.services.volume.v2.json.admin.volume_services_client import \
- VolumesServicesV2ClientJSON
+ VolumesServicesV2Client
from tempest.services.volume.v2.json.admin.volume_types_client import \
- VolumeTypesV2ClientJSON
+ VolumeTypesV2Client
from tempest.services.volume.v2.json.availability_zone_client import \
- VolumeV2AvailabilityZoneClientJSON
-from tempest.services.volume.v2.json.backups_client import BackupsClientV2JSON
+ VolumeV2AvailabilityZoneClient
+from tempest.services.volume.v2.json.backups_client import BackupsClientV2
from tempest.services.volume.v2.json.extensions_client import \
- ExtensionsV2ClientJSON as VolumeV2ExtensionClientJSON
-from tempest.services.volume.v2.json.qos_client import QosSpecsV2ClientJSON
+ ExtensionsV2Client as VolumeV2ExtensionClient
+from tempest.services.volume.v2.json.qos_client import QosSpecsV2Client
from tempest.services.volume.v2.json.snapshots_client import \
- SnapshotsV2ClientJSON
-from tempest.services.volume.v2.json.volumes_client import VolumesV2ClientJSON
+ SnapshotsV2Client
+from tempest.services.volume.v2.json.volumes_client import VolumesV2Client
CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -171,13 +179,13 @@
self._set_volume_clients()
self._set_object_storage_clients()
- self.baremetal_client = BaremetalClientJSON(
+ self.baremetal_client = BaremetalClient(
self.auth_provider,
CONF.baremetal.catalog_type,
CONF.identity.region,
endpoint_type=CONF.baremetal.endpoint_type,
**self.default_params_with_timeout_values)
- self.network_client = NetworkClientJSON(
+ self.network_client = NetworkClient(
self.auth_provider,
CONF.network.catalog_type,
CONF.network.region or CONF.identity.region,
@@ -185,20 +193,20 @@
build_interval=CONF.network.build_interval,
build_timeout=CONF.network.build_timeout,
**self.default_params)
- self.messaging_client = MessagingClientJSON(
+ self.messaging_client = MessagingClient(
self.auth_provider,
CONF.messaging.catalog_type,
CONF.identity.region,
**self.default_params_with_timeout_values)
if CONF.service_available.ceilometer:
- self.telemetry_client = TelemetryClientJSON(
+ self.telemetry_client = TelemetryClient(
self.auth_provider,
CONF.telemetry.catalog_type,
CONF.identity.region,
endpoint_type=CONF.telemetry.endpoint_type,
**self.default_params_with_timeout_values)
if CONF.service_available.glance:
- self.image_client = ImageClientJSON(
+ self.image_client = ImageClient(
self.auth_provider,
CONF.image.catalog_type,
CONF.image.region or CONF.identity.region,
@@ -206,7 +214,7 @@
build_interval=CONF.image.build_interval,
build_timeout=CONF.image.build_timeout,
**self.default_params)
- self.image_client_v2 = ImageClientV2JSON(
+ self.image_client_v2 = ImageClientV2(
self.auth_provider,
CONF.image.catalog_type,
CONF.image.region or CONF.identity.region,
@@ -250,51 +258,59 @@
}
params.update(self.default_params)
- self.agents_client = AgentsClientJSON(self.auth_provider, **params)
- self.networks_client = NetworksClientJSON(self.auth_provider, **params)
- self.migrations_client = MigrationsClientJSON(self.auth_provider,
- **params)
+ self.agents_client = AgentsClient(self.auth_provider, **params)
+ self.networks_client = NetworksClient(self.auth_provider, **params)
+ self.migrations_client = MigrationsClient(self.auth_provider,
+ **params)
self.security_group_default_rules_client = (
- SecurityGroupDefaultRulesClientJSON(self.auth_provider, **params))
- self.certificates_client = CertificatesClientJSON(self.auth_provider,
- **params)
- self.servers_client = ServersClientJSON(
+ SecurityGroupDefaultRulesClient(self.auth_provider, **params))
+ self.certificates_client = CertificatesClient(self.auth_provider,
+ **params)
+ self.servers_client = ServersClient(
self.auth_provider,
enable_instance_password=CONF.compute_feature_enabled
.enable_instance_password,
**params)
- self.limits_client = LimitsClientJSON(self.auth_provider, **params)
- self.images_client = ImagesClientJSON(self.auth_provider, **params)
- self.keypairs_client = KeyPairsClientJSON(self.auth_provider, **params)
- self.quotas_client = QuotasClientJSON(self.auth_provider, **params)
- self.quota_classes_client = QuotaClassesClientJSON(self.auth_provider,
- **params)
- self.flavors_client = FlavorsClientJSON(self.auth_provider, **params)
- self.extensions_client = ExtensionsClientJSON(self.auth_provider,
- **params)
- self.floating_ips_client = FloatingIPsClientJSON(self.auth_provider,
- **params)
- self.security_groups_client = SecurityGroupsClientJSON(
+ self.server_groups_client = ServerGroupsClient(
self.auth_provider, **params)
- self.interfaces_client = InterfacesClientJSON(self.auth_provider,
- **params)
- self.fixed_ips_client = FixedIPsClientJSON(self.auth_provider,
- **params)
- self.availability_zone_client = AvailabilityZoneClientJSON(
+ self.limits_client = LimitsClient(self.auth_provider, **params)
+ self.images_client = ImagesClient(self.auth_provider, **params)
+ self.keypairs_client = KeyPairsClient(self.auth_provider, **params)
+ self.quotas_client = QuotasClient(self.auth_provider, **params)
+ self.quota_classes_client = QuotaClassesClient(self.auth_provider,
+ **params)
+ self.flavors_client = FlavorsClient(self.auth_provider, **params)
+ self.extensions_client = ExtensionsClient(self.auth_provider,
+ **params)
+ self.floating_ip_pools_client = FloatingIpPoolsClient(
self.auth_provider, **params)
- self.aggregates_client = AggregatesClientJSON(self.auth_provider,
- **params)
- self.services_client = ServicesClientJSON(self.auth_provider, **params)
- self.tenant_usages_client = TenantUsagesClientJSON(self.auth_provider,
- **params)
- self.hosts_client = HostsClientJSON(self.auth_provider, **params)
- self.hypervisor_client = HypervisorClientJSON(self.auth_provider,
- **params)
+ self.floating_ips_bulk_client = FloatingIpsBulkClient(
+ self.auth_provider, **params)
+ self.floating_ips_client = FloatingIPsClient(self.auth_provider,
+ **params)
+ self.security_group_rules_client = SecurityGroupRulesClient(
+ self.auth_provider, **params)
+ self.security_groups_client = SecurityGroupsClient(
+ self.auth_provider, **params)
+ self.interfaces_client = InterfacesClient(self.auth_provider,
+ **params)
+ self.fixed_ips_client = FixedIPsClient(self.auth_provider,
+ **params)
+ self.availability_zone_client = AvailabilityZoneClient(
+ self.auth_provider, **params)
+ self.aggregates_client = AggregatesClient(self.auth_provider,
+ **params)
+ self.services_client = ServicesClient(self.auth_provider, **params)
+ self.tenant_usages_client = TenantUsagesClient(self.auth_provider,
+ **params)
+ self.hosts_client = HostsClient(self.auth_provider, **params)
+ self.hypervisor_client = HypervisorClient(self.auth_provider,
+ **params)
self.instance_usages_audit_log_client = \
- InstanceUsagesAuditLogClientJSON(self.auth_provider, **params)
+ InstanceUsagesAuditLogClient(self.auth_provider, **params)
self.tenant_networks_client = \
- TenantNetworksClientJSON(self.auth_provider, **params)
- self.baremetal_nodes_client = BaremetalNodesClientJSON(
+ TenantNetworksClient(self.auth_provider, **params)
+ self.baremetal_nodes_client = BaremetalNodesClient(
self.auth_provider, **params)
# NOTE: The following client needs special timeout values because
@@ -304,22 +320,22 @@
'build_interval': CONF.volume.build_interval,
'build_timeout': CONF.volume.build_timeout
})
- self.volumes_extensions_client = VolumesExtensionsClientJSON(
+ self.volumes_extensions_client = VolumesExtensionsClient(
self.auth_provider, default_volume_size=CONF.volume.volume_size,
**params_volume)
def _set_database_clients(self):
- self.database_flavors_client = DatabaseFlavorsClientJSON(
+ self.database_flavors_client = DatabaseFlavorsClient(
self.auth_provider,
CONF.database.catalog_type,
CONF.identity.region,
**self.default_params_with_timeout_values)
- self.database_limits_client = DatabaseLimitsClientJSON(
+ self.database_limits_client = DatabaseLimitsClient(
self.auth_provider,
CONF.database.catalog_type,
CONF.identity.region,
**self.default_params_with_timeout_values)
- self.database_versions_client = DatabaseVersionsClientJSON(
+ self.database_versions_client = DatabaseVersionsClient(
self.auth_provider,
CONF.database.catalog_type,
CONF.identity.region,
@@ -333,17 +349,17 @@
}
params.update(self.default_params_with_timeout_values)
- self.identity_client = IdentityClientJSON(self.auth_provider,
- **params)
- self.identity_v3_client = IdentityV3ClientJSON(self.auth_provider,
- **params)
- self.endpoints_client = EndPointClientJSON(self.auth_provider,
+ self.identity_client = IdentityClient(self.auth_provider,
+ **params)
+ self.identity_v3_client = IdentityV3Client(self.auth_provider,
**params)
- self.service_client = ServiceClientJSON(self.auth_provider, **params)
- self.policy_client = PolicyClientJSON(self.auth_provider, **params)
- self.region_client = RegionClientJSON(self.auth_provider, **params)
- self.credentials_client = CredentialsClientJSON(self.auth_provider,
- **params)
+ self.endpoints_client = EndPointClient(self.auth_provider,
+ **params)
+ self.service_client = ServiceClient(self.auth_provider, **params)
+ self.policy_client = PolicyClient(self.auth_provider, **params)
+ self.region_client = RegionClient(self.auth_provider, **params)
+ self.credentials_client = CredentialsClient(self.auth_provider,
+ **params)
# 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
@@ -372,46 +388,46 @@
}
params.update(self.default_params)
- self.volume_qos_client = QosSpecsClientJSON(self.auth_provider,
- **params)
- self.volume_qos_v2_client = QosSpecsV2ClientJSON(
+ self.volume_qos_client = QosSpecsClient(self.auth_provider,
+ **params)
+ self.volume_qos_v2_client = QosSpecsV2Client(
self.auth_provider, **params)
- self.volume_services_v2_client = VolumesServicesV2ClientJSON(
+ self.volume_services_v2_client = VolumesServicesV2Client(
self.auth_provider, **params)
- self.backups_client = BackupsClientJSON(self.auth_provider, **params)
- self.backups_v2_client = BackupsClientV2JSON(self.auth_provider,
+ self.backups_client = BackupsClient(self.auth_provider, **params)
+ self.backups_v2_client = BackupsClientV2(self.auth_provider,
+ **params)
+ self.snapshots_client = SnapshotsClient(self.auth_provider,
+ **params)
+ self.snapshots_v2_client = SnapshotsV2Client(self.auth_provider,
**params)
- self.snapshots_client = SnapshotsClientJSON(self.auth_provider,
- **params)
- self.snapshots_v2_client = SnapshotsV2ClientJSON(self.auth_provider,
- **params)
- self.volumes_client = VolumesClientJSON(
+ self.volumes_client = VolumesClient(
self.auth_provider, default_volume_size=CONF.volume.volume_size,
**params)
- self.volumes_v2_client = VolumesV2ClientJSON(
+ self.volumes_v2_client = VolumesV2Client(
self.auth_provider, default_volume_size=CONF.volume.volume_size,
**params)
- self.volume_types_client = VolumeTypesClientJSON(self.auth_provider,
- **params)
- self.volume_services_client = VolumesServicesClientJSON(
+ self.volume_types_client = VolumeTypesClient(self.auth_provider,
+ **params)
+ self.volume_services_client = VolumesServicesClient(
self.auth_provider, **params)
- self.volume_hosts_client = VolumeHostsClientJSON(self.auth_provider,
- **params)
- self.volume_hosts_v2_client = VolumeHostsV2ClientJSON(
+ self.volume_hosts_client = VolumeHostsClient(self.auth_provider,
+ **params)
+ self.volume_hosts_v2_client = VolumeHostsV2Client(
self.auth_provider, **params)
- self.volume_quotas_client = VolumeQuotasClientJSON(self.auth_provider,
- **params)
+ self.volume_quotas_client = VolumeQuotasClient(self.auth_provider,
+ **params)
self.volume_quotas_v2_client = VolumeQuotasV2Client(self.auth_provider,
**params)
- self.volumes_extension_client = VolumeExtensionClientJSON(
+ self.volumes_extension_client = VolumeExtensionClient(
self.auth_provider, **params)
- self.volumes_v2_extension_client = VolumeV2ExtensionClientJSON(
+ self.volumes_v2_extension_client = VolumeV2ExtensionClient(
self.auth_provider, **params)
self.volume_availability_zone_client = \
- VolumeAvailabilityZoneClientJSON(self.auth_provider, **params)
+ VolumeAvailabilityZoneClient(self.auth_provider, **params)
self.volume_v2_availability_zone_client = \
- VolumeV2AvailabilityZoneClientJSON(self.auth_provider, **params)
- self.volume_types_v2_client = VolumeTypesV2ClientJSON(
+ VolumeV2AvailabilityZoneClient(self.auth_provider, **params)
+ self.volume_types_v2_client = VolumeTypesV2Client(
self.auth_provider, **params)
def _set_object_storage_clients(self):
diff --git a/tempest/cmd/account_generator.py b/tempest/cmd/account_generator.py
index fbfbbb7..0360146 100755
--- a/tempest/cmd/account_generator.py
+++ b/tempest/cmd/account_generator.py
@@ -128,7 +128,7 @@
'build_interval': CONF.compute.build_interval,
'build_timeout': CONF.compute.build_timeout
}
- identity_admin = identity_client.IdentityClientJSON(
+ identity_admin = identity_client.IdentityClient(
_auth,
CONF.identity.catalog_type,
CONF.identity.region,
@@ -138,7 +138,7 @@
network_admin = None
if (CONF.service_available.neutron and
CONF.auth.create_isolated_networks):
- network_admin = network_client.NetworkClientJSON(
+ network_admin = network_client.NetworkClient(
_auth,
CONF.network.catalog_type,
CONF.network.region or CONF.identity.region,
diff --git a/tempest/cmd/cleanup.py b/tempest/cmd/cleanup.py
index ed6716e..7898035 100755
--- a/tempest/cmd/cleanup.py
+++ b/tempest/cmd/cleanup.py
@@ -51,10 +51,10 @@
Please run with **--help** to see full list of options.
"""
import argparse
-import json
import sys
from oslo_log import log as logging
+from oslo_serialization import jsonutils as json
from tempest import clients
from tempest.cmd import cleanup_service
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index 1de20d6..2e96c81 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -1,12 +1,12 @@
#!/usr/bin/env python
-# Copyright 2014 Dell Inc.
+# Copyright 2015 Dell 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
+# 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
@@ -76,12 +76,12 @@
CONF.identity.alt_username]
if IS_NEUTRON:
- CONF_PRIV_NETWORK = _get_priv_net_id(CONF.compute.fixed_network_name,
- CONF.identity.tenant_name)
+ CONF_PRIV_NETWORK = _get_network_id(CONF.compute.fixed_network_name,
+ CONF.identity.tenant_name)
CONF_NETWORKS = [CONF_PUB_NETWORK, CONF_PRIV_NETWORK]
-def _get_priv_net_id(prv_net_name, tenant_name):
+def _get_network_id(net_name, tenant_name):
am = clients.AdminManager()
net_cl = am.network_client
id_cl = am.identity_client
@@ -91,7 +91,7 @@
t_id = tenant['id']
n_id = None
for net in networks['networks']:
- if (net['tenant_id'] == t_id and net['name'] == prv_net_name):
+ if (net['tenant_id'] == t_id and net['name'] == net_name):
n_id = net['id']
break
return n_id
@@ -103,6 +103,10 @@
for key, value in kwargs.items():
setattr(self, key, value)
+ self.tenant_filter = {}
+ if hasattr(self, 'tenant_id'):
+ self.tenant_filter['tenant_id'] = self.tenant_id
+
def _filter_by_tenant_id(self, item_list):
if (item_list is None
or len(item_list) == 0
@@ -153,9 +157,8 @@
for snap in snaps:
try:
client.delete_snapshot(snap['id'])
- except Exception as e:
- LOG.exception("Delete Snapshot exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Snapshot exception.")
def dry_run(self):
snaps = self.list()
@@ -180,9 +183,8 @@
for server in servers:
try:
client.delete_server(server['id'])
- except Exception as e:
- LOG.exception("Delete Server exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Server exception.")
def dry_run(self):
servers = self.list()
@@ -203,9 +205,8 @@
for sg in sgs:
try:
client.delete_server_group(sg['id'])
- except Exception as e:
- LOG.exception("Delete Server Group exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Server Group exception.")
def dry_run(self):
sgs = self.list()
@@ -229,9 +230,8 @@
for stack in stacks:
try:
client.delete_stack(stack['id'])
- except Exception as e:
- LOG.exception("Delete Stack exception: %s " % e)
- pass
+ except Exception:
+ LOG.exception("Delete Stack exception.")
def dry_run(self):
stacks = self.list()
@@ -256,9 +256,8 @@
try:
name = k['keypair']['name']
client.delete_keypair(name)
- except Exception as e:
- LOG.exception("Delete Keypairs exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Keypairs exception.")
def dry_run(self):
keypairs = self.list()
@@ -283,8 +282,8 @@
for g in secgrp_del:
try:
client.delete_security_group(g['id'])
- except Exception as e:
- LOG.exception("Delete Security Groups exception: %s" % e)
+ except Exception:
+ LOG.exception("Delete Security Groups exception.")
def dry_run(self):
secgrp_del = self.list()
@@ -308,9 +307,8 @@
for f in floating_ips:
try:
client.delete_floating_ip(f['id'])
- except Exception as e:
- LOG.exception("Delete Floating IPs exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Floating IPs exception.")
def dry_run(self):
floating_ips = self.list()
@@ -334,9 +332,8 @@
for v in vols:
try:
client.delete_volume(v['id'])
- except Exception as e:
- LOG.exception("Delete Volume exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Volume exception.")
def dry_run(self):
vols = self.list()
@@ -352,9 +349,8 @@
client = self.client
try:
client.delete_quota_set(self.tenant_id)
- except Exception as e:
- LOG.exception("Delete Volume Quotas exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Volume Quotas exception.")
def dry_run(self):
quotas = self.client.show_quota_usage(self.tenant_id)
@@ -371,9 +367,8 @@
client = self.client
try:
client.delete_quota_set(self.tenant_id)
- except Exception as e:
- LOG.exception("Delete Quotas exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Quotas exception.")
def dry_run(self):
client = self.limits_client
@@ -396,8 +391,8 @@
def list(self):
client = self.client
- networks = client.list_networks()
- networks = self._filter_by_tenant_id(networks['networks'])
+ networks = client.list_networks(**self.tenant_filter)
+ networks = networks['networks']
# filter out networks declared in tempest.conf
if self.is_preserve:
networks = [network for network in networks
@@ -411,9 +406,8 @@
for n in networks:
try:
client.delete_network(n['id'])
- except Exception as e:
- LOG.exception("Delete Network exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Network exception.")
def dry_run(self):
networks = self.list()
@@ -424,9 +418,8 @@
def list(self):
client = self.client
- flips = client.list_floatingips()
+ flips = client.list_floatingips(**self.tenant_filter)
flips = flips['floatingips']
- flips = self._filter_by_tenant_id(flips)
LOG.debug("List count, %s Network Floating IPs" % len(flips))
return flips
@@ -436,9 +429,8 @@
for flip in flips:
try:
client.delete_floatingip(flip['id'])
- except Exception as e:
- LOG.exception("Delete Network Floating IP exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Network Floating IP exception.")
def dry_run(self):
flips = self.list()
@@ -449,9 +441,8 @@
def list(self):
client = self.client
- routers = client.list_routers()
+ routers = client.list_routers(**self.tenant_filter)
routers = routers['routers']
- routers = self._filter_by_tenant_id(routers)
if self.is_preserve:
routers = [router for router in routers
if router['id'] != CONF_PUB_ROUTER]
@@ -465,15 +456,15 @@
for router in routers:
try:
rid = router['id']
- ports = client.list_router_interfaces(rid)
- ports = ports['ports']
+ ports = [port for port
+ in client.list_router_interfaces(rid)['ports']
+ if port["device_owner"] == "network:router_interface"]
for port in ports:
- subid = port['fixed_ips'][0]['subnet_id']
- client.remove_router_interface_with_subnet_id(rid, subid)
+ client.remove_router_interface_with_port_id(rid,
+ port['id'])
client.delete_router(rid)
- except Exception as e:
- LOG.exception("Delete Router exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Router exception.")
def dry_run(self):
routers = self.list()
@@ -496,9 +487,8 @@
for hm in hms:
try:
client.delete_health_monitor(hm['id'])
- except Exception as e:
- LOG.exception("Delete Health Monitor exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Health Monitor exception.")
def dry_run(self):
hms = self.list()
@@ -521,9 +511,8 @@
for member in members:
try:
client.delete_member(member['id'])
- except Exception as e:
- LOG.exception("Delete Member exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Member exception.")
def dry_run(self):
members = self.list()
@@ -546,9 +535,8 @@
for vip in vips:
try:
client.delete_vip(vip['id'])
- except Exception as e:
- LOG.exception("Delete VIP exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete VIP exception.")
def dry_run(self):
vips = self.list()
@@ -571,9 +559,8 @@
for pool in pools:
try:
client.delete_pool(pool['id'])
- except Exception as e:
- LOG.exception("Delete Pool exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Pool exception.")
def dry_run(self):
pools = self.list()
@@ -596,9 +583,8 @@
for rule in rules:
try:
client.delete_metering_label_rule(rule['id'])
- except Exception as e:
- LOG.exception("Delete Metering Label Rule exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Metering Label Rule exception.")
def dry_run(self):
rules = self.list()
@@ -621,9 +607,8 @@
for label in labels:
try:
client.delete_metering_label(label['id'])
- except Exception as e:
- LOG.exception("Delete Metering Label exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Metering Label exception.")
def dry_run(self):
labels = self.list()
@@ -634,11 +619,14 @@
def list(self):
client = self.client
- ports = client.list_ports()
- ports = ports['ports']
- ports = self._filter_by_tenant_id(ports)
+ ports = [port for port in
+ client.list_ports(**self.tenant_filter)['ports']
+ if port["device_owner"] == "" or
+ port["device_owner"].startswith("compute:")]
+
if self.is_preserve:
ports = self._filter_by_conf_networks(ports)
+
LOG.debug("List count, %s Ports" % len(ports))
return ports
@@ -648,22 +636,48 @@
for port in ports:
try:
client.delete_port(port['id'])
- except Exception as e:
- LOG.exception("Delete Port exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Port exception.")
def dry_run(self):
ports = self.list()
self.data['ports'] = ports
+class NetworkSecGroupService(NetworkService):
+ def list(self):
+ client = self.client
+ filter = self.tenant_filter
+ # cannot delete default sec group so never show it.
+ secgroups = [secgroup for secgroup in
+ client.list_security_groups(**filter)['security_groups']
+ if secgroup['name'] != 'default']
+
+ if self.is_preserve:
+ secgroups = self._filter_by_conf_networks(secgroups)
+ LOG.debug("List count, %s securtiy_groups" % len(secgroups))
+ return secgroups
+
+ def delete(self):
+ client = self.client
+ secgroups = self.list()
+ for secgroup in secgroups:
+ try:
+ client.delete_secgroup(secgroup['id'])
+ except Exception:
+ LOG.exception("Delete security_group exception.")
+
+ def dry_run(self):
+ secgroups = self.list()
+ self.data['secgroups'] = secgroups
+
+
class NetworkSubnetService(NetworkService):
def list(self):
client = self.client
- subnets = client.list_subnets()
+ subnets = client.list_subnets(**self.tenant_filter)
subnets = subnets['subnets']
- subnets = self._filter_by_tenant_id(subnets)
if self.is_preserve:
subnets = self._filter_by_conf_networks(subnets)
LOG.debug("List count, %s Subnets" % len(subnets))
@@ -675,9 +689,8 @@
for subnet in subnets:
try:
client.delete_subnet(subnet['id'])
- except Exception as e:
- LOG.exception("Delete Subnet exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Subnet exception.")
def dry_run(self):
subnets = self.list()
@@ -702,9 +715,8 @@
for alarm in alarms:
try:
client.delete_alarm(alarm['id'])
- except Exception as e:
- LOG.exception("Delete Alarms exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Alarms exception.")
def dry_run(self):
alarms = self.list()
@@ -737,9 +749,8 @@
for flavor in flavors:
try:
client.delete_flavor(flavor['id'])
- except Exception as e:
- LOG.exception("Delete Flavor exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Flavor exception.")
def dry_run(self):
flavors = self.list()
@@ -775,17 +786,16 @@
for image in images:
try:
client.delete_image(image['id'])
- except Exception as e:
- LOG.exception("Delete Image exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Image exception.")
def dry_run(self):
images = self.list()
self.data['images'] = images
def save_state(self):
- images = self.list()
self.data['images'] = {}
+ images = self.list()
for image in images:
self.data['images'][image['id']] = image['name']
@@ -823,9 +833,8 @@
for user in users:
try:
client.delete_user(user['id'])
- except Exception as e:
- LOG.exception("Delete User exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete User exception.")
def dry_run(self):
users = self.list()
@@ -852,8 +861,8 @@
and role['name'] != CONF.identity.admin_role)]
LOG.debug("List count, %s Roles after reconcile" % len(roles))
return roles
- except Exception as ex:
- LOG.exception("Cannot retrieve Roles, exception: %s" % ex)
+ except Exception:
+ LOG.exception("Cannot retrieve Roles.")
return []
def delete(self):
@@ -862,9 +871,8 @@
for role in roles:
try:
client.delete_role(role['id'])
- except Exception as e:
- LOG.exception("Delete Role exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Role exception.")
def dry_run(self):
roles = self.list()
@@ -900,9 +908,8 @@
for tenant in tenants:
try:
client.delete_tenant(tenant['id'])
- except Exception as e:
- LOG.exception("Delete Tenant exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Tenant exception.")
def dry_run(self):
tenants = self.list()
@@ -938,9 +945,8 @@
try:
client.update_domain(domain['id'], enabled=False)
client.delete_domain(domain['id'])
- except Exception as e:
- LOG.exception("Delete Domain exception: %s" % e)
- pass
+ except Exception:
+ LOG.exception("Delete Domain exception.")
def dry_run(self):
domains = self.list()
@@ -955,7 +961,6 @@
def get_tenant_cleanup_services():
tenant_services = []
-
if IS_CEILOMETER:
tenant_services.append(TelemetryAlarmService)
if IS_NOVA:
@@ -969,14 +974,15 @@
if IS_HEAT:
tenant_services.append(StackService)
if IS_NEUTRON:
+ tenant_services.append(NetworkFloatingIpService)
if test.is_extension_enabled('metering', 'network'):
tenant_services.append(NetworkMeteringLabelRuleService)
tenant_services.append(NetworkMeteringLabelService)
tenant_services.append(NetworkRouterService)
- tenant_services.append(NetworkFloatingIpService)
tenant_services.append(NetworkPortService)
tenant_services.append(NetworkSubnetService)
tenant_services.append(NetworkService)
+ tenant_services.append(NetworkSecGroupService)
if IS_CINDER:
tenant_services.append(SnapshotService)
tenant_services.append(VolumeService)
diff --git a/tempest/cmd/init.py b/tempest/cmd/init.py
new file mode 100644
index 0000000..c13fbe5
--- /dev/null
+++ b/tempest/cmd/init.py
@@ -0,0 +1,99 @@
+# 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.
+
+import os
+import shutil
+import subprocess
+
+from cliff import command
+from oslo_log import log as logging
+from six import moves
+
+LOG = logging.getLogger(__name__)
+
+TESTR_CONF = """[DEFAULT]
+test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \\
+ OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \\
+ OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-500} \\
+ ${PYTHON:-python} -m subunit.run discover -t %s %s $LISTOPT $IDOPTION
+test_id_option=--load-list $IDFILE
+test_list_option=--list
+group_regex=([^\.]*\.)*
+"""
+
+
+class TempestInit(command.Command):
+ """Setup a local working environment for running tempest"""
+
+ def get_parser(self, prog_name):
+ parser = super(TempestInit, self).get_parser(prog_name)
+ parser.add_argument('dir', nargs='?', default=os.getcwd())
+ parser.add_argument('--config-dir', '-c', default='/etc/tempest')
+ return parser
+
+ def generate_testr_conf(self, local_path):
+ testr_conf_path = os.path.join(local_path, '.testr.conf')
+ top_level_path = os.path.dirname(os.path.dirname(__file__))
+ discover_path = os.path.join(top_level_path, 'test_discover')
+ testr_conf = TESTR_CONF % (top_level_path, discover_path)
+ with open(testr_conf_path, 'w+') as testr_conf_file:
+ testr_conf_file.write(testr_conf)
+
+ def update_local_conf(self, conf_path, lock_dir, log_dir):
+ config_parse = moves.configparser.SafeConfigParser()
+ config_parse.optionxform = str
+ with open(conf_path, 'w+') as conf_file:
+ config_parse.readfp(conf_file)
+ # Set local lock_dir in tempest conf
+ if not config_parse.has_section('oslo_concurrency'):
+ config_parse.add_section('oslo_concurrency')
+ config_parse.set('oslo_concurrency', 'lock_path', lock_dir)
+ # Set local log_dir in tempest conf
+ config_parse.set('DEFAULT', 'log_dir', log_dir)
+ # Set default log filename to tempest.log
+ config_parse.set('DEFAULT', 'log_file', 'tempest.log')
+
+ def copy_config(self, etc_dir, config_dir):
+ shutil.copytree(config_dir, etc_dir)
+
+ def create_working_dir(self, local_dir, config_dir):
+ # Create local dir if missing
+ if not os.path.isdir(local_dir):
+ LOG.debug('Creating local working dir: %s' % local_dir)
+ os.mkdir(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')
+ log_dir = os.path.join(local_dir, 'logs')
+ testr_dir = os.path.join(local_dir, '.testrepository')
+ # Create lock dir
+ if not os.path.isdir(lock_dir):
+ LOG.debug('Creating lock dir: %s' % lock_dir)
+ os.mkdir(lock_dir)
+ # Create log dir
+ if not os.path.isdir(log_dir):
+ LOG.debug('Creating log dir: %s' % log_dir)
+ os.mkdir(log_dir)
+ # Create and copy local etc dir
+ self.copy_config(etc_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
+ self.generate_testr_conf(local_dir)
+ # setup local testr working dir
+ if not os.path.isdir(testr_dir):
+ subprocess.call(['testr', 'init'], cwd=local_dir)
+
+ def take_action(self, parsed_args):
+ self.create_working_dir(parsed_args.dir, parsed_args.config_dir)
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index 5871628..f35548a 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -122,6 +122,7 @@
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
from tempest.services.compute.json import servers_client
from tempest.services.identity.v2.json import identity_client
@@ -188,25 +189,27 @@
}
_auth = auth.KeystoneV2AuthProvider(
_creds, CONF.identity.uri, **auth_provider_params)
- self.identity = identity_client.IdentityClientJSON(
+ self.identity = identity_client.IdentityClient(
_auth,
CONF.identity.catalog_type,
CONF.identity.region,
endpoint_type='adminURL',
**default_params_with_timeout_values)
- self.servers = servers_client.ServersClientJSON(_auth,
- **compute_params)
- self.flavors = flavors_client.FlavorsClientJSON(_auth,
- **compute_params)
- self.floating_ips = floating_ips_client.FloatingIPsClientJSON(
+ self.servers = servers_client.ServersClient(_auth,
+ **compute_params)
+ self.flavors = flavors_client.FlavorsClient(_auth,
+ **compute_params)
+ self.floating_ips = floating_ips_client.FloatingIPsClient(
_auth, **compute_params)
- self.secgroups = security_groups_client.SecurityGroupsClientJSON(
+ self.secgroups = security_groups_client.SecurityGroupsClient(
+ _auth, **compute_params)
+ self.secrules = security_group_rules_client.SecurityGroupRulesClient(
_auth, **compute_params)
self.objects = object_client.ObjectClient(_auth,
**object_storage_params)
self.containers = container_client.ContainerClient(
_auth, **object_storage_params)
- self.images = image_client.ImageClientV2JSON(
+ self.images = image_client.ImageClientV2(
_auth,
CONF.image.catalog_type,
CONF.image.region or CONF.identity.region,
@@ -214,13 +217,13 @@
build_interval=CONF.image.build_interval,
build_timeout=CONF.image.build_timeout,
**default_params)
- self.telemetry = telemetry_client.TelemetryClientJSON(
+ self.telemetry = telemetry_client.TelemetryClient(
_auth,
CONF.telemetry.catalog_type,
CONF.identity.region,
endpoint_type=CONF.telemetry.endpoint_type,
**default_params_with_timeout_values)
- self.volumes = volumes_client.VolumesClientJSON(
+ self.volumes = volumes_client.VolumesClient(
_auth,
CONF.volume.catalog_type,
CONF.volume.region or CONF.identity.region,
@@ -228,7 +231,7 @@
build_interval=CONF.volume.build_interval,
build_timeout=CONF.volume.build_timeout,
**default_params)
- self.networks = network_client.NetworkClientJSON(
+ self.networks = network_client.NetworkClient(
_auth,
CONF.network.catalog_type,
CONF.network.region or CONF.identity.region,
@@ -453,7 +456,7 @@
found,
"Couldn't find expected server %s" % server['name'])
- found = client.servers.get_server(found['id'])
+ found = client.servers.show_server(found['id'])
# validate neutron is enabled and ironic disabled:
if (CONF.service_available.neutron and
not CONF.baremetal.driver_enabled):
@@ -917,7 +920,7 @@
# for each security group, create the rules
for rule in secgroup['rules']:
ip_proto, from_port, to_port, cidr = rule.split()
- client.secgroups.create_security_group_rule(
+ client.secrules.create_security_group_rule(
secgroup_id, ip_proto, from_port, to_port, cidr=cidr)
diff --git a/tempest/cmd/main.py b/tempest/cmd/main.py
new file mode 100644
index 0000000..762e982
--- /dev/null
+++ b/tempest/cmd/main.py
@@ -0,0 +1,52 @@
+# Copyright 2015 Dell 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.
+
+import logging
+import sys
+
+from cliff import app
+from cliff import commandmanager
+
+TEMPEST_CLI_VERSION = '0.1'
+
+
+class Main(app.App):
+
+ log = logging.getLogger(__name__)
+
+ def __init__(self):
+ super(Main, self).__init__(
+ description='Tempest cli application',
+ version=TEMPEST_CLI_VERSION,
+ command_manager=commandmanager.CommandManager('tempest.cm'),
+ )
+
+ def initialize_app(self, argv):
+ self.log.debug('tempest initialize_app')
+
+ def prepare_to_run_command(self, cmd):
+ self.log.debug('prepare_to_run_command %s', cmd.__class__.__name__)
+
+ def clean_up(self, cmd, result, err):
+ self.log.debug('tempest clean_up %s', cmd.__class__.__name__)
+ if err:
+ self.log.debug('tempest got an error: %s', err)
+
+
+def main(argv=sys.argv[1:]):
+ the_app = Main()
+ return the_app.run(argv)
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
diff --git a/tempest/cmd/run_stress.py b/tempest/cmd/run_stress.py
index 06b338d..0448589 100755
--- a/tempest/cmd/run_stress.py
+++ b/tempest/cmd/run_stress.py
@@ -16,7 +16,6 @@
import argparse
import inspect
-import json
import sys
try:
from unittest import loader
@@ -25,6 +24,7 @@
from unittest2 import loader
from oslo_log import log as logging
+from oslo_serialization import jsonutils as json
from testtools import testsuite
from tempest.stress import driver
diff --git a/tempest/cmd/verify_tempest_config.py b/tempest/cmd/verify_tempest_config.py
index 2269d41..9e7d894 100755
--- a/tempest/cmd/verify_tempest_config.py
+++ b/tempest/cmd/verify_tempest_config.py
@@ -15,11 +15,11 @@
# under the License.
import argparse
-import json
import os
import sys
import httplib2
+from oslo_serialization import jsonutils as json
from six import moves
from six.moves.urllib import parse as urlparse
diff --git a/tempest/common/accounts.py b/tempest/common/accounts.py
index 650faf1..27b44f6 100644
--- a/tempest/common/accounts.py
+++ b/tempest/common/accounts.py
@@ -31,8 +31,8 @@
def read_accounts_yaml(path):
- yaml_file = open(path, 'r')
- accounts = yaml.load(yaml_file)
+ with open(path, 'r') as yaml_file:
+ accounts = yaml.load(yaml_file)
return accounts
@@ -216,7 +216,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.identity.admin_domain_name
+ domain_name = CONF.auth.default_credentials_domain_name
hash_attributes['user_domain_name'] = domain_name
if all([getattr(creds, k) == hash_attributes[k] for
k in init_attributes]):
diff --git a/tempest/common/compute.py b/tempest/common/compute.py
index 5de4b0e..06e3493 100644
--- a/tempest/common/compute.py
+++ b/tempest/common/compute.py
@@ -18,6 +18,7 @@
from tempest_lib.common.utils import data_utils
from tempest.common import fixed_network
+from tempest.common import waiters
from tempest import config
CONF = config.CONF
@@ -98,8 +99,8 @@
if 'wait_until' in kwargs:
for server in servers:
try:
- clients.servers_client.wait_for_server_status(
- server['id'], kwargs['wait_until'])
+ waiters.wait_for_server_status(
+ clients.servers_client, server['id'], kwargs['wait_until'])
# Multiple validatable servers are not supported for now. Their
# creation will fail with the condition above (l.58).
diff --git a/tempest/common/cred_provider.py b/tempest/common/cred_provider.py
index 461097f..783a5fc 100644
--- a/tempest/common/cred_provider.py
+++ b/tempest/common/cred_provider.py
@@ -84,9 +84,9 @@
domain_fields = set(x for x in auth.KeystoneV3Credentials.ATTRIBUTES
if 'domain' in x)
if not domain_fields.intersection(kwargs.keys()):
- # TODO(andreaf) It might be better here to use a dedicated config
- # option such as CONF.auth.tenant_isolation_domain_name
- params['user_domain_name'] = CONF.identity.admin_domain_name
+ 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
@@ -98,20 +98,17 @@
@six.add_metaclass(abc.ABCMeta)
class CredentialProvider(object):
- def __init__(self, identity_version=None, name=None, password='pass',
+ def __init__(self, identity_version=None, name=None,
network_resources=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 name Name of the calling test. Included in provisioned
- credentials when credentials are provisioned on the fly
- :param password Used for provisioned credentials when credentials are
- provisioned on the fly
- :param network_resources Network resources required for the credentials
+ :param identity_version: If specified it will return credentials of the
+ corresponding identity version, otherwise it
+ uses auth_version from configuration
+ :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
"""
- # TODO(andreaf) name and password are tenant isolation specific, and
- # could be removed from this abstract class
self.name = name or "test_creds"
self.identity_version = identity_version or CONF.identity.auth_version
if not auth.is_identity_version_supported(self.identity_version):
diff --git a/tempest/common/fixed_network.py b/tempest/common/fixed_network.py
index de44c4d..9ec0ec6 100644
--- a/tempest/common/fixed_network.py
+++ b/tempest/common/fixed_network.py
@@ -27,7 +27,7 @@
"""Get a full network dict from just a network name
:param str name: the name of the network to use
- :param NetworksClientJSON compute_networks_client: The network client
+ :param NetworksClient compute_networks_client: The network client
object to use for making the network lists api request
:return: The full dictionary for the network in question
:rtype: dict
diff --git a/tempest/common/glance_http.py b/tempest/common/glance_http.py
index 5cd844c..4be3da1 100644
--- a/tempest/common/glance_http.py
+++ b/tempest/common/glance_http.py
@@ -17,7 +17,6 @@
import copy
import hashlib
-import json
import posixpath
import re
import socket
@@ -25,6 +24,7 @@
import OpenSSL
from oslo_log import log as logging
+from oslo_serialization import jsonutils as json
import six
from six import moves
from six.moves import http_client as httplib
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index 5ded3ee..7888811 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -16,11 +16,11 @@
import netaddr
from oslo_log import log as logging
import six
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest import clients
from tempest.common import cred_provider
+from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
from tempest.services.identity.v2.json import identity_client as v2_identity
@@ -51,11 +51,21 @@
def create_project(self, name, description):
pass
- def assign_user_role(self, user, project, role_name):
+ def _check_role_exists(self, role_name):
try:
roles = self._list_roles()
role = next(r for r in roles if r['name'] == role_name)
except StopIteration:
+ return None
+ return role
+
+ def create_user_role(self, role_name):
+ if not self._check_role_exists(role_name):
+ self.identity_client.create_role(role_name)
+
+ def assign_user_role(self, user, project, role_name):
+ role = self._check_role_exists(role_name)
+ if not role:
msg = 'No "%s" role found' % role_name
raise lib_exc.NotFound(msg)
try:
@@ -128,7 +138,7 @@
def get_creds_client(identity_client, project_domain_name=None):
- if isinstance(identity_client, v2_identity.IdentityClientJSON):
+ if isinstance(identity_client, v2_identity.IdentityClient):
return V2CredsClient(identity_client)
else:
return V3CredsClient(identity_client, project_domain_name)
@@ -136,14 +146,13 @@
class IsolatedCreds(cred_provider.CredentialProvider):
- def __init__(self, identity_version=None, name=None, password='pass',
+ def __init__(self, identity_version=None, name=None,
network_resources=None):
- super(IsolatedCreds, self).__init__(identity_version, name, password,
+ super(IsolatedCreds, self).__init__(identity_version, name,
network_resources)
self.network_resources = network_resources
self.isolated_creds = {}
self.ports = []
- self.password = password
self.default_admin_creds = cred_provider.get_configured_credentials(
'identity_admin', fill_in=True,
identity_version=self.identity_version)
@@ -154,8 +163,8 @@
self.creds_domain_name = None
if self.identity_version == 'v3':
self.creds_domain_name = (
- CONF.auth.tenant_isolation_domain_name or
- self.default_admin_creds.project_domain_name)
+ self.default_admin_creds.project_domain_name or
+ CONF.auth.default_credentials_domain_name)
self.creds_client = get_creds_client(
self.identity_admin_client, self.creds_domain_name)
@@ -193,20 +202,32 @@
name=project_name, description=project_desc)
username = data_utils.rand_name(root) + suffix
+ user_password = data_utils.rand_password()
email = data_utils.rand_name(root) + suffix + "@example.com"
user = self.creds_client.create_user(
- username, self.password, project, email)
+ username, user_password, project, email)
+ role_assigned = False
if admin:
self.creds_client.assign_user_role(user, project,
CONF.identity.admin_role)
+ role_assigned = True
# Add roles specified in config file
for conf_role in CONF.auth.tempest_roles:
self.creds_client.assign_user_role(user, project, conf_role)
+ role_assigned = True
# Add roles requested by caller
if roles:
for role in roles:
self.creds_client.assign_user_role(user, project, role)
- creds = self.creds_client.get_credentials(user, project, self.password)
+ role_assigned = True
+ # NOTE(mtreinish) For a user to have access to a project with v3 auth
+ # it must beassigned a role on the project. So we need to ensure that
+ # our newly created user has a role on the newly created project.
+ if self.identity_version == 'v3' and not role_assigned:
+ self.creds_client.create_user_role('Member')
+ self.creds_client.assign_user_role(user, project, 'Member')
+
+ creds = self.creds_client.get_credentials(user, project, user_password)
return cred_provider.TestResources(creds)
def _create_network_resources(self, tenant_id):
diff --git a/tempest/common/utils/__init__.py b/tempest/common/utils/__init__.py
index 04d898d..81b8110 100644
--- a/tempest/common/utils/__init__.py
+++ b/tempest/common/utils/__init__.py
@@ -1,3 +1,45 @@
+# Copyright (c) 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 functools import partial
+
+from tempest import config
+
+from tempest_lib.common.utils import data_utils as lib_data_utils
+
+CONF = config.CONF
+
PING_IPV4_COMMAND = 'ping -c 3 '
PING_IPV6_COMMAND = 'ping6 -c 3 '
PING_PACKET_LOSS_REGEX = '(\d{1,3})\.?\d*\% packet loss'
+
+
+class DataUtils(object):
+ def __getattr__(self, attr):
+ if attr in self.__dict__:
+ return self.__dict__[attr]
+
+ if attr == 'rand_name':
+ # NOTE(flwang): This is a proxy to generate a random name that
+ # includes a random number and a prefix if one is configured in
+ # CONF.resources_prefix
+ attr_obj = partial(lib_data_utils.rand_name,
+ prefix=CONF.resources_prefix)
+ else:
+ attr_obj = getattr(lib_data_utils, attr)
+
+ self.__dict__[attr] = attr_obj
+ return attr_obj
+
+data_utils = DataUtils()
diff --git a/tempest/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py
index d4e6eb8..93c2c10 100644
--- a/tempest/common/utils/linux/remote_client.py
+++ b/tempest/common/utils/linux/remote_client.py
@@ -30,10 +30,10 @@
# NOTE(afazekas): It should always get an address instead of server
def __init__(self, server, username, password=None, pkey=None):
- ssh_timeout = CONF.compute.ssh_timeout
+ ssh_timeout = CONF.validation.ssh_timeout
network = CONF.compute.network_for_ssh
- ip_version = CONF.compute.ip_version_for_ssh
- ssh_channel_timeout = CONF.compute.ssh_channel_timeout
+ ip_version = CONF.validation.ip_version_for_ssh
+ connect_timeout = CONF.validation.connect_timeout
if isinstance(server, six.string_types):
ip_address = server
else:
@@ -46,7 +46,7 @@
raise exceptions.ServerUnreachable()
self.ssh_client = ssh.Client(ip_address, username, password,
ssh_timeout, pkey=pkey,
- channel_timeout=ssh_channel_timeout)
+ channel_timeout=connect_timeout)
def exec_command(self, cmd):
# Shell options below add more clearness on failures,
@@ -72,8 +72,7 @@
return output.split()[1]
def get_number_of_vcpus(self):
- command = 'cat /proc/cpuinfo | grep processor | wc -l'
- output = self.exec_command(command)
+ output = self.exec_command('grep -c processor /proc/cpuinfo')
return int(output)
def get_partitions(self):
diff --git a/tempest/common/validation_resources.py b/tempest/common/validation_resources.py
index d370ebc..18f0b1d 100644
--- a/tempest/common/validation_resources.py
+++ b/tempest/common/validation_resources.py
@@ -14,9 +14,10 @@
from oslo_log import log as logging
from tempest import config
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
+from tempest.common.utils import data_utils
+
CONF = config.CONF
LOG = logging.getLogger(__name__)
diff --git a/tempest/common/waiters.py b/tempest/common/waiters.py
index 249bac9..85a03cf 100644
--- a/tempest/common/waiters.py
+++ b/tempest/common/waiters.py
@@ -33,7 +33,7 @@
# NOTE(afazekas): UNKNOWN status possible on ERROR
# or in a very early stage.
- body = client.get_server(server_id)
+ body = client.show_server(server_id)
old_status = server_status = body['status']
old_task_state = task_state = _get_task_state(body)
start_time = int(time.time())
@@ -60,7 +60,7 @@
return
time.sleep(client.build_interval)
- body = client.get_server(server_id)
+ body = client.show_server(server_id)
server_status = body['status']
task_state = _get_task_state(body)
if (server_status != old_status) or (task_state != old_task_state):
@@ -132,6 +132,27 @@
raise exceptions.TimeoutException(message)
+def wait_for_volume_status(client, volume_id, status):
+ """Waits for a Volume to reach a given status."""
+ body = client.show_volume(volume_id)
+ volume_status = body['status']
+ start = int(time.time())
+
+ while volume_status != status:
+ time.sleep(client.build_interval)
+ body = client.show_volume(volume_id)
+ volume_status = body['status']
+ if volume_status == 'error':
+ raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
+
+ if int(time.time()) - start >= client.build_timeout:
+ message = ('Volume %s failed to reach %s status (current %s) '
+ 'within the required time (%s s).' %
+ (volume_id, status, volume_status,
+ client.build_timeout))
+ raise exceptions.TimeoutException(message)
+
+
def wait_for_bm_node_status(client, node_id, attr, status):
"""Waits for a baremetal node attribute to reach given status.
diff --git a/tempest/config.py b/tempest/config.py
index 3a2906c..bdfdcdc 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -22,6 +22,8 @@
from oslo_log import log as logging
+from tempest.test_discover import plugins
+
# TODO(marun) Replace use of oslo_config's global ConfigOpts
# (cfg.CONF) instance with a local instance (cfg.ConfigOpts()) once
@@ -31,9 +33,10 @@
def register_opt_group(conf, opt_group, options):
- conf.register_group(opt_group)
+ if opt_group:
+ conf.register_group(opt_group)
for opt in options:
- conf.register_opt(opt, group=opt_group.name)
+ conf.register_opt(opt, group=getattr(opt_group, 'name', None))
auth_group = cfg.OptGroup(name='auth',
@@ -64,12 +67,13 @@
cfg.ListOpt('tempest_roles',
help="Roles to assign to all users created by tempest",
default=[]),
- cfg.StrOpt('tenant_isolation_domain_name',
- default=None,
- help="Only applicable when identity.auth_version is v3."
- "Domain within which isolated credentials are provisioned."
- "The default \"None\" means that the domain from the"
- "admin user is used instead."),
+ cfg.StrOpt('default_credentials_domain_name',
+ default='Default',
+ help="Default domain used when getting v3 credentials. "
+ "This is the name keystone uses for v2 compatibility.",
+ deprecated_opts=[cfg.DeprecatedOpt(
+ 'tenant_isolation_domain_name',
+ group='auth')]),
cfg.BoolOpt('create_isolated_networks',
default=True,
help="If allow_tenant_isolation is set to True and Neutron is "
@@ -239,18 +243,10 @@
default=1,
help="The number of ping packets originating from remote "
"linux hosts"),
- cfg.IntOpt('ssh_timeout',
- default=300,
- help="Timeout in seconds to wait for authentication to "
- "succeed."),
cfg.IntOpt('ready_wait',
default=0,
help="Additional wait time for clean state, when there is "
"no OS-EXT-STS extension available"),
- cfg.IntOpt('ssh_channel_timeout',
- default=60,
- help="Timeout in seconds to wait for output from ssh "
- "channel."),
cfg.StrOpt('fixed_network_name',
help="Name of the fixed network that is visible to all test "
"tenants. If multiple networks are available for a tenant"
@@ -262,9 +258,6 @@
default='public',
help="Network used for SSH connections. Ignored if "
"use_floatingip_for_ssh=true or run_validation=false."),
- cfg.IntOpt('ip_version_for_ssh',
- default=4,
- help="IP version used for SSH connections."),
cfg.BoolOpt('use_floatingip_for_ssh',
default=True,
help="Does SSH use Floating IPs?"),
@@ -391,7 +384,21 @@
default=False,
help='Does Nova preserve preexisting ports from Neutron '
'when deleting an instance? This should be set to True '
- 'if testing Kilo+ Nova.')
+ 'if testing Kilo+ Nova.'),
+ cfg.BoolOpt('attach_encrypted_volume',
+ default=True,
+ help='Does the test environment support attaching an '
+ 'encrypted volume to a running server instance? This may '
+ 'depend on the combination of compute_driver in nova and '
+ 'the volume_driver(s) in cinder.'),
+ # TODO(mriedem): Remove allow_duplicate_networks once kilo-eol happens
+ # since the option was removed from nova in Liberty and is the default
+ # behavior starting in Liberty.
+ cfg.BoolOpt('allow_duplicate_networks',
+ default=False,
+ help='Does the test environment support creating instances '
+ 'with multiple ports on the same network? This is only '
+ 'valid when using Neutron.'),
]
@@ -595,17 +602,23 @@
'Additional methods will be handled in a separate spec.'),
cfg.IntOpt('ip_version_for_ssh',
default=4,
- help='Default IP version for ssh connections.'),
+ help='Default IP version for ssh connections.',
+ deprecated_opts=[cfg.DeprecatedOpt('ip_version_for_ssh',
+ group='compute')]),
cfg.IntOpt('ping_timeout',
default=120,
help='Timeout in seconds to wait for ping to succeed.'),
cfg.IntOpt('connect_timeout',
default=60,
help='Timeout in seconds to wait for the TCP connection to be '
- 'successful.'),
+ 'successful.',
+ deprecated_opts=[cfg.DeprecatedOpt('ssh_channel_timeout',
+ group='compute')]),
cfg.IntOpt('ssh_timeout',
default=300,
- help='Timeout in seconds to wait for the ssh banner.'),
+ help='Timeout in seconds to wait for the ssh banner.',
+ deprecated_opts=[cfg.DeprecatedOpt('ssh_timeout',
+ group='compute')]),
]
volume_group = cfg.OptGroup(name='volume',
@@ -1148,6 +1161,15 @@
help="Test generator class for all negative tests"),
]
+DefaultGroup = [
+ cfg.StrOpt('resources_prefix',
+ default='tempest',
+ help="Prefix to be added when generating the name for "
+ "test resources. It can be used to discover all "
+ "resources associated with a specific test run when "
+ "running tempest on a real-life cloud"),
+]
+
_opts = [
(auth_group, AuthGroup),
(compute_group, ComputeGroup),
@@ -1178,13 +1200,18 @@
(debug_group, DebugGroup),
(baremetal_group, BaremetalGroup),
(input_scenario_group, InputScenarioGroup),
- (negative_group, NegativeGroup)
+ (negative_group, NegativeGroup),
+ (None, DefaultGroup)
]
def register_opts():
+ ext_plugins = plugins.TempestTestPluginManager()
+ # Register in-tree tempest config options
for g, o in _opts:
register_opt_group(_CONF, g, o)
+ # Call external plugin config option registration
+ ext_plugins.register_plugin_opts(_CONF)
def list_opts():
@@ -1193,7 +1220,7 @@
The purpose of this is to allow tools like the Oslo sample config file
generator to discover the options exposed to users.
"""
- return [(g.name, o) for g, o in _opts]
+ return [(getattr(g, 'name', None), o) for g, o in _opts]
# this should never be called outside of this class
@@ -1243,9 +1270,11 @@
self.baremetal = _CONF.baremetal
self.input_scenario = _CONF['input-scenario']
self.negative = _CONF.negative
- _CONF.set_default('domain_name', self.identity.admin_domain_name,
+ _CONF.set_default('domain_name',
+ self.auth.default_credentials_domain_name,
group='identity')
- _CONF.set_default('alt_domain_name', self.identity.admin_domain_name,
+ _CONF.set_default('alt_domain_name',
+ self.auth.default_credentials_domain_name,
group='identity')
def __init__(self, parse_conf=True, config_path=None):
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index fff8a5c..e77d07c 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -19,12 +19,13 @@
import netaddr
from oslo_log import log
import six
-from tempest_lib.common.utils import data_utils
from tempest_lib.common.utils import misc as misc_utils
from tempest_lib import exceptions as lib_exc
from tempest.common import fixed_network
+from tempest.common.utils import data_utils
from tempest.common.utils.linux import remote_client
+from tempest.common import waiters
from tempest import config
from tempest import exceptions
from tempest.services.network import resources as net_resources
@@ -53,6 +54,8 @@
cls.keypairs_client = cls.manager.keypairs_client
# Nova security groups client
cls.security_groups_client = cls.manager.security_groups_client
+ cls.security_group_rules_client = (
+ cls.manager.security_group_rules_client)
cls.servers_client = cls.manager.servers_client
cls.volumes_client = cls.manager.volumes_client
cls.snapshots_client = cls.manager.snapshots_client
@@ -177,12 +180,13 @@
cleanup_callable=self.delete_wrapper,
cleanup_args=[self.servers_client.delete_server, server['id']])
if wait_on_boot:
- self.servers_client.wait_for_server_status(server_id=server['id'],
- status='ACTIVE')
+ waiters.wait_for_server_status(self.servers_client,
+ server_id=server['id'],
+ status='ACTIVE')
# The instance retrieved on creation is missing network
# details, necessitating retrieval after it becomes active to
# ensure correct details.
- server = self.servers_client.get_server(server['id'])
+ server = self.servers_client.show_server(server['id'])
self.assertEqual(server['name'], name)
return server
@@ -215,6 +219,7 @@
def _create_loginable_secgroup_rule(self, secgroup_id=None):
_client = self.security_groups_client
+ _client_rules = self.security_group_rules_client
if secgroup_id is None:
sgs = _client.list_security_groups()
for sg in sgs:
@@ -243,10 +248,10 @@
]
rules = list()
for ruleset in rulesets:
- sg_rule = _client.create_security_group_rule(secgroup_id,
- **ruleset)
+ sg_rule = _client_rules.create_security_group_rule(secgroup_id,
+ **ruleset)
self.addCleanup(self.delete_wrapper,
- _client.delete_security_group_rule,
+ _client_rules.delete_security_group_rule,
sg_rule['id'])
rules.append(sg_rule)
return rules
@@ -443,7 +448,8 @@
preserve_ephemeral=preserve_ephemeral,
**rebuild_kwargs)
if wait:
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client,
+ server_id, 'ACTIVE')
def ping_ip_address(self, ip_address, should_succeed=True,
ping_timeout=None):
@@ -559,27 +565,27 @@
def _list_networks(self, *args, **kwargs):
"""List networks using admin creds """
- return self._admin_lister('networks')(*args, **kwargs)
+ networks_list = self.admin_manager.network_client.list_networks(
+ *args, **kwargs)
+ return networks_list['networks']
def _list_subnets(self, *args, **kwargs):
"""List subnets using admin creds """
- return self._admin_lister('subnets')(*args, **kwargs)
+ subnets_list = self.admin_manager.network_client.list_subnets(
+ *args, **kwargs)
+ return subnets_list['subnets']
def _list_routers(self, *args, **kwargs):
"""List routers using admin creds """
- return self._admin_lister('routers')(*args, **kwargs)
+ routers_list = self.admin_manager.network_client.list_routers(
+ *args, **kwargs)
+ return routers_list['routers']
def _list_ports(self, *args, **kwargs):
"""List ports using admin creds """
- return self._admin_lister('ports')(*args, **kwargs)
-
- def _admin_lister(self, resource_type):
- def temp(*args, **kwargs):
- temp_method = self.admin_manager.network_client.__getattr__(
- 'list_%s' % resource_type)
- resource_list = temp_method(*args, **kwargs)
- return resource_list[resource_type]
- return temp
+ ports_list = self.admin_manager.network_client.list_ports(
+ *args, **kwargs)
+ return ports_list['ports']
def _create_subnet(self, network, client=None, namestart='subnet-smoke',
**kwargs):
@@ -1226,10 +1232,10 @@
BaremetalProvisionStates.ACTIVE,
timeout=CONF.baremetal.active_timeout)
- self.servers_client.wait_for_server_status(self.instance['id'],
- 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client,
+ self.instance['id'], 'ACTIVE')
self.node = self.get_node(instance_id=self.instance['id'])
- self.instance = self.servers_client.get_server(self.instance['id'])
+ self.instance = self.servers_client.show_server(self.instance['id'])
def terminate_instance(self):
self.servers_client.delete_server(self.instance['id'])
diff --git a/tempest/scenario/test_aggregates_basic_ops.py b/tempest/scenario/test_aggregates_basic_ops.py
index 0e158ed..f5f4a61 100644
--- a/tempest/scenario/test_aggregates_basic_ops.py
+++ b/tempest/scenario/test_aggregates_basic_ops.py
@@ -14,9 +14,9 @@
# under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest.common import tempest_fixtures as fixtures
+from tempest.common.utils import data_utils
from tempest.scenario import manager
from tempest import test
@@ -64,12 +64,12 @@
return computes[0]['host_name']
def _add_host(self, aggregate_id, host):
- aggregate = self.aggregates_client.add_host(aggregate_id, host)
+ aggregate = self.aggregates_client.add_host(aggregate_id, host=host)
self.addCleanup(self._remove_host, aggregate['id'], host)
self.assertIn(host, aggregate['hosts'])
def _remove_host(self, aggregate_id, host):
- aggregate = self.aggregates_client.remove_host(aggregate_id, host)
+ aggregate = self.aggregates_client.remove_host(aggregate_id, host=host)
self.assertNotIn(host, aggregate['hosts'])
def _check_aggregate_details(self, aggregate, aggregate_name, azone,
@@ -85,7 +85,7 @@
def _set_aggregate_metadata(self, aggregate, meta):
aggregate = self.aggregates_client.set_metadata(aggregate['id'],
- meta)
+ metadata=meta)
for key, value in meta.items():
self.assertEqual(meta[key], aggregate['metadata'][key])
diff --git a/tempest/scenario/test_baremetal_basic_ops.py b/tempest/scenario/test_baremetal_basic_ops.py
index 9fdba39..346f56b 100644
--- a/tempest/scenario/test_baremetal_basic_ops.py
+++ b/tempest/scenario/test_baremetal_basic_ops.py
@@ -15,6 +15,7 @@
from oslo_log import log as logging
+from tempest.common import waiters
from tempest import config
from tempest.scenario import manager
from tempest import test
@@ -52,11 +53,13 @@
self.assertEqual(self.node['uuid'], node['uuid'])
self.node = node
- self.servers_client.wait_for_server_status(
+ waiters.wait_for_server_status(
+ self.servers_client,
server_id=self.instance['id'],
status='REBUILD',
ready_wait=False)
- self.servers_client.wait_for_server_status(
+ waiters.wait_for_server_status(
+ self.servers_client,
server_id=self.instance['id'],
status='ACTIVE')
diff --git a/tempest/scenario/test_encrypted_cinder_volumes.py b/tempest/scenario/test_encrypted_cinder_volumes.py
index e6912d8..b66eb59 100644
--- a/tempest/scenario/test_encrypted_cinder_volumes.py
+++ b/tempest/scenario/test_encrypted_cinder_volumes.py
@@ -13,9 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest import config
from tempest.scenario import manager
from tempest import test
+CONF = config.CONF
+
class TestEncryptedCinderVolumes(manager.EncryptionScenarioTest):
@@ -31,6 +34,12 @@
* Attaches and detaches the encrypted volume to the instance
"""
+ @classmethod
+ def skip_checks(cls):
+ super(TestEncryptedCinderVolumes, cls).skip_checks()
+ if not CONF.compute_feature_enabled.attach_encrypted_volume:
+ raise cls.skipException('Encrypted volume attach is not supported')
+
def launch_instance(self):
self.glance_image_create()
self.nova_boot()
diff --git a/tempest/scenario/test_large_ops.py b/tempest/scenario/test_large_ops.py
index 56d4c7d..fa70d3f 100644
--- a/tempest/scenario/test_large_ops.py
+++ b/tempest/scenario/test_large_ops.py
@@ -14,10 +14,11 @@
# under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
from tempest.common import fixed_network
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import config
from tempest.scenario import manager
from tempest import test
@@ -76,7 +77,8 @@
for server in self.servers:
# Make sure nova list keeps working throughout the build process
self.servers_client.list_servers()
- self.servers_client.wait_for_server_status(server['id'], status)
+ waiters.wait_for_server_status(self.servers_client,
+ server['id'], status)
def nova_boot(self):
name = data_utils.rand_name('scenario-server')
@@ -102,7 +104,7 @@
**create_kwargs)
# needed because of bug 1199788
params = {'name': name}
- server_list = self.servers_client.list_servers(params)
+ server_list = self.servers_client.list_servers(**params)
self.servers = server_list['servers']
for server in self.servers:
# after deleting all servers - wait for all servers to clear
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index 45923ce..f868382 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -16,6 +16,7 @@
from oslo_log import log as logging
from tempest.common import custom_matchers
+from tempest.common import waiters
from tempest import config
from tempest import exceptions
from tempest.scenario import manager
@@ -43,7 +44,8 @@
server_id = self.server['id']
# Raise on error defaults to True, which is consistent with the
# original function from scenario tests here
- self.servers_client.wait_for_server_status(server_id, status)
+ waiters.wait_for_server_status(self.servers_client,
+ server_id, status)
def nova_keypair_add(self):
self.keypair = self.create_keypair()
@@ -60,7 +62,7 @@
self.assertIn(self.server['id'], [x['id'] for x in servers])
def nova_show(self):
- got_server = self.servers_client.get_server(self.server['id'])
+ got_server = self.servers_client.show_server(self.server['id'])
self.assertThat(
self.server, custom_matchers.MatchesDictExceptForKeys(
got_server, excluded_keys=['OS-EXT-AZ:availability_zone']))
@@ -76,15 +78,6 @@
volume = self.volumes_client.show_volume(self.volume['id'])
self.assertEqual(self.volume, volume)
- def nova_volume_attach(self):
- volume_device_path = '/dev/' + CONF.compute.volume_device_name
- volume = self.servers_client.attach_volume(
- self.server['id'], self.volume['id'], volume_device_path)
- self.assertEqual(self.volume['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'])
-
def nova_reboot(self):
self.servers_client.reboot(self.server['id'], 'SOFT')
self._wait_for_server_status('ACTIVE')
@@ -94,14 +87,6 @@
partitions = self.linux_client.get_partitions()
self.assertEqual(1, partitions.count(CONF.compute.volume_device_name))
- 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')
-
- volume = self.volumes_client.show_volume(self.volume['id'])
- self.assertEqual('available', volume['status'])
-
def create_and_add_security_group(self):
secgroup = self._create_security_group()
self.servers_client.add_security_group(self.server['id'],
@@ -110,7 +95,7 @@
self.server['id'], secgroup['name'])
def wait_for_secgroup_add():
- body = self.servers_client.get_server(self.server['id'])
+ body = self.servers_client.show_server(self.server['id'])
return {'name': secgroup['name']} in body['security_groups']
if not test.call_until_true(wait_for_secgroup_add,
diff --git a/tempest/scenario/test_network_advanced_server_ops.py b/tempest/scenario/test_network_advanced_server_ops.py
index 3d6abff..3d233d8 100644
--- a/tempest/scenario/test_network_advanced_server_ops.py
+++ b/tempest/scenario/test_network_advanced_server_ops.py
@@ -14,9 +14,10 @@
# under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
import testtools
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import config
from tempest.scenario import manager
from tempest import test
@@ -90,7 +91,8 @@
servers=[self.server])
def _wait_server_status_and_check_network_connectivity(self):
- self.servers_client.wait_for_server_status(self.server['id'], 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client,
+ self.server['id'], 'ACTIVE')
self._check_network_connectivity()
@test.idempotent_id('61f1aa9a-1573-410e-9054-afa557cab021')
@@ -99,8 +101,8 @@
def test_server_connectivity_stop_start(self):
self._setup_network_and_servers()
self.servers_client.stop(self.server['id'])
- self.servers_client.wait_for_server_status(self.server['id'],
- 'SHUTOFF')
+ waiters.wait_for_server_status(self.servers_client,
+ self.server['id'], 'SHUTOFF')
self._check_network_connectivity(should_connect=False)
self.servers_client.start(self.server['id'])
self._wait_server_status_and_check_network_connectivity()
@@ -128,7 +130,8 @@
def test_server_connectivity_pause_unpause(self):
self._setup_network_and_servers()
self.servers_client.pause_server(self.server['id'])
- self.servers_client.wait_for_server_status(self.server['id'], 'PAUSED')
+ 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()
@@ -140,8 +143,8 @@
def test_server_connectivity_suspend_resume(self):
self._setup_network_and_servers()
self.servers_client.suspend_server(self.server['id'])
- self.servers_client.wait_for_server_status(self.server['id'],
- 'SUSPENDED')
+ waiters.wait_for_server_status(self.servers_client, self.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()
@@ -157,7 +160,7 @@
raise self.skipException(msg)
self._setup_network_and_servers()
self.servers_client.resize(self.server['id'], flavor_ref=resize_flavor)
- self.servers_client.wait_for_server_status(self.server['id'],
- 'VERIFY_RESIZE')
+ waiters.wait_for_server_status(self.servers_client, self.server['id'],
+ 'VERIFY_RESIZE')
self.servers_client.confirm_resize(self.server['id'])
self._wait_server_status_and_check_network_connectivity()
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index 3274ce8..e676063 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -17,9 +17,9 @@
import re
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
import testtools
+from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
from tempest.scenario import manager
@@ -243,8 +243,8 @@
self.assertEqual(1, len(port_list))
old_port = port_list[0]
interface = self.interface_client.create_interface(
- server=server['id'],
- network_id=self.new_net.id)
+ server_id=server['id'],
+ net_id=self.new_net.id)
self.addCleanup(self.network_client.wait_for_resource_deletion,
'port',
interface['port_id'])
diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py
index 8ec10c7..18fd09d 100644
--- a/tempest/scenario/test_security_groups_basic_ops.py
+++ b/tempest/scenario/test_security_groups_basic_ops.py
@@ -14,9 +14,9 @@
# under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest import clients
+from tempest.common.utils import data_utils
from tempest import config
from tempest.scenario import manager
from tempest import test
diff --git a/tempest/scenario/test_server_advanced_ops.py b/tempest/scenario/test_server_advanced_ops.py
index f45f0c9..e405cf5 100644
--- a/tempest/scenario/test_server_advanced_ops.py
+++ b/tempest/scenario/test_server_advanced_ops.py
@@ -16,6 +16,7 @@
from oslo_log import log as logging
import testtools
+from tempest.common import waiters
from tempest import config
from tempest.scenario import manager
from tempest import test
@@ -58,14 +59,14 @@
LOG.debug("Resizing instance %s from flavor %s to flavor %s",
instance['id'], instance['flavor']['id'], resize_flavor)
self.servers_client.resize(instance_id, resize_flavor)
- self.servers_client.wait_for_server_status(instance_id,
- 'VERIFY_RESIZE')
+ waiters.wait_for_server_status(self.servers_client, instance_id,
+ 'VERIFY_RESIZE')
LOG.debug("Confirming resize of instance %s", instance_id)
self.servers_client.confirm_resize(instance_id)
- self.servers_client.wait_for_server_status(instance_id,
- 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client, instance_id,
+ 'ACTIVE')
@test.idempotent_id('949da7d5-72c8-4808-8802-e3d70df98e2c')
@testtools.skipUnless(CONF.compute_feature_enabled.suspend,
@@ -78,23 +79,23 @@
LOG.debug("Suspending instance %s. Current status: %s",
instance_id, instance['status'])
self.servers_client.suspend_server(instance_id)
- self.servers_client.wait_for_server_status(instance_id,
- 'SUSPENDED')
- fetched_instance = self.servers_client.get_server(instance_id)
+ waiters.wait_for_server_status(self.servers_client, instance_id,
+ 'SUSPENDED')
+ fetched_instance = self.servers_client.show_server(instance_id)
LOG.debug("Resuming instance %s. Current status: %s",
instance_id, fetched_instance['status'])
self.servers_client.resume_server(instance_id)
- self.servers_client.wait_for_server_status(instance_id,
- 'ACTIVE')
- fetched_instance = self.servers_client.get_server(instance_id)
+ waiters.wait_for_server_status(self.servers_client, instance_id,
+ 'ACTIVE')
+ fetched_instance = self.servers_client.show_server(instance_id)
LOG.debug("Suspending instance %s. Current status: %s",
instance_id, fetched_instance['status'])
self.servers_client.suspend_server(instance_id)
- self.servers_client.wait_for_server_status(instance_id,
- 'SUSPENDED')
- fetched_instance = self.servers_client.get_server(instance_id)
+ waiters.wait_for_server_status(self.servers_client, instance_id,
+ 'SUSPENDED')
+ fetched_instance = self.servers_client.show_server(instance_id)
LOG.debug("Resuming instance %s. Current status: %s",
instance_id, fetched_instance['status'])
self.servers_client.resume_server(instance_id)
- self.servers_client.wait_for_server_status(instance_id,
- 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client, instance_id,
+ 'ACTIVE')
diff --git a/tempest/scenario/test_shelve_instance.py b/tempest/scenario/test_shelve_instance.py
index e674101..02ee7b9 100644
--- a/tempest/scenario/test_shelve_instance.py
+++ b/tempest/scenario/test_shelve_instance.py
@@ -16,6 +16,7 @@
from oslo_log import log
import testtools
+from tempest.common import waiters
from tempest import config
from tempest.scenario import manager
from tempest import test
@@ -50,15 +51,18 @@
self.servers_client.shelve_server(server['id'])
offload_time = CONF.compute.shelved_offload_time
if offload_time >= 0:
- self.servers_client.wait_for_server_status(
- server['id'], 'SHELVED_OFFLOADED', extra_timeout=offload_time)
+ waiters.wait_for_server_status(self.servers_client, server['id'],
+ 'SHELVED_OFFLOADED',
+ extra_timeout=offload_time)
else:
- self.servers_client.wait_for_server_status(server['id'], 'SHELVED')
+ waiters.wait_for_server_status(self.servers_client,
+ server['id'], 'SHELVED')
self.servers_client.shelve_offload_server(server['id'])
- self.servers_client.wait_for_server_status(server['id'],
- 'SHELVED_OFFLOADED')
+ waiters.wait_for_server_status(self.servers_client, server['id'],
+ 'SHELVED_OFFLOADED')
self.servers_client.unshelve_server(server['id'])
- self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+ waiters.wait_for_server_status(self.servers_client, server['id'],
+ 'ACTIVE')
@test.idempotent_id('1164e700-0af0-4a4c-8792-35909a88743c')
@testtools.skipUnless(CONF.compute_feature_enabled.shelve,
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index 51c4c59..c1d9a1b 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -16,11 +16,11 @@
import time
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
from tempest_lib import decorators
from tempest_lib import exceptions as lib_exc
import testtools
+from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
from tempest.scenario import manager
diff --git a/tempest/scenario/test_swift_telemetry_middleware.py b/tempest/scenario/test_swift_telemetry_middleware.py
index 302ccbe..29ce1a0 100644
--- a/tempest/scenario/test_swift_telemetry_middleware.py
+++ b/tempest/scenario/test_swift_telemetry_middleware.py
@@ -74,7 +74,7 @@
called again.
"""
results = self.telemetry_client.list_samples(
- 'storage.api.request')
+ 'storage.objects.incoming.bytes')
LOG.debug('got samples %s', results)
# Extract container info from samples.
diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py
index 1731c48..45b7b74 100644
--- a/tempest/scenario/test_volume_boot_pattern.py
+++ b/tempest/scenario/test_volume_boot_pattern.py
@@ -11,8 +11,9 @@
# under the License.
from oslo_log import log
-from tempest_lib.common.utils import data_utils
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import config
from tempest.scenario import manager
from tempest import test
@@ -47,7 +48,7 @@
vol_name = data_utils.rand_name('volume-origin')
return self.create_volume(name=vol_name, imageRef=img_uuid)
- def _boot_instance_from_volume(self, vol_id, keypair):
+ def _boot_instance_from_volume(self, vol_id, keypair, security_group):
# NOTE(gfidente): the syntax for block_device_mapping is
# dev_name=id:type:size:delete_on_terminate
# where type needs to be "snap" if the server is booted
@@ -56,12 +57,10 @@
'device_name': 'vda',
'volume_id': vol_id,
'delete_on_termination': '0'}]
- self.security_group = self._create_security_group()
- security_groups = [{'name': self.security_group['name']}]
create_kwargs = {
'block_device_mapping': bd_map,
'key_name': keypair['name'],
- 'security_groups': security_groups
+ 'security_groups': [{'name': security_group['name']}]
}
return self.create_server(image='', create_kwargs=create_kwargs)
@@ -87,7 +86,8 @@
for i in instances:
self.servers_client.stop(i['id'])
for i in instances:
- self.servers_client.wait_for_server_status(i['id'], 'SHUTOFF')
+ waiters.wait_for_server_status(self.servers_client,
+ i['id'], 'SHUTOFF')
def _detach_volumes(self, volumes):
# NOTE(gfidente): two loops so we do not wait for the status twice
@@ -134,12 +134,12 @@
@test.services('compute', 'volume', 'image')
def test_volume_boot_pattern(self):
keypair = self.create_keypair()
- self.security_group = self._create_security_group()
+ security_group = self._create_security_group()
# create an instance from volume
volume_origin = self._create_volume_from_image()
instance_1st = self._boot_instance_from_volume(volume_origin['id'],
- keypair)
+ keypair, security_group)
# write content to volume on instance
ssh_client_for_instance_1st = self._ssh_to_server(instance_1st,
@@ -151,7 +151,7 @@
# create a 2nd instance from volume
instance_2nd = self._boot_instance_from_volume(volume_origin['id'],
- keypair)
+ keypair, security_group)
# check the content of written file
ssh_client_for_instance_2nd = self._ssh_to_server(instance_2nd,
@@ -163,8 +163,9 @@
# create a 3rd instance from snapshot
volume = self._create_volume_from_snapshot(snapshot['id'])
- instance_from_snapshot = self._boot_instance_from_volume(volume['id'],
- keypair)
+ instance_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)
@@ -176,15 +177,16 @@
class TestVolumeBootPatternV2(TestVolumeBootPattern):
- def _boot_instance_from_volume(self, vol_id, keypair):
- bdms = [{'uuid': vol_id, 'source_type': 'volume',
- 'destination_type': 'volume', 'boot_index': 0,
- 'delete_on_termination': False}]
- self.security_group = self._create_security_group()
- security_groups = [{'name': self.security_group['name']}]
+ def _boot_instance_from_volume(self, vol_id, keypair, security_group):
+ bd_map_v2 = [{
+ 'uuid': vol_id,
+ 'source_type': 'volume',
+ 'destination_type': 'volume',
+ 'boot_index': 0,
+ 'delete_on_termination': False}]
create_kwargs = {
- 'block_device_mapping_v2': bdms,
+ 'block_device_mapping_v2': bd_map_v2,
'key_name': keypair['name'],
- 'security_groups': security_groups
+ 'security_groups': [{'name': security_group['name']}]
}
return self.create_server(image='', create_kwargs=create_kwargs)
diff --git a/tempest/scenario/utils.py b/tempest/scenario/utils.py
index cd9d925..b1246d2 100644
--- a/tempest/scenario/utils.py
+++ b/tempest/scenario/utils.py
@@ -13,11 +13,11 @@
# under the License.
-import json
import re
import string
import unicodedata
+from oslo_serialization import jsonutils as json
from tempest_lib.common.utils import misc
import testscenarios
import testtools
diff --git a/tempest/services/baremetal/base.py b/tempest/services/baremetal/base.py
index 1461198..2ac3fb2 100644
--- a/tempest/services/baremetal/base.py
+++ b/tempest/services/baremetal/base.py
@@ -11,8 +11,8 @@
# under the License.
import functools
-import json
+from oslo_serialization import jsonutils as json
import six
from six.moves.urllib import parse as urllib
diff --git a/tempest/services/baremetal/v1/json/baremetal_client.py b/tempest/services/baremetal/v1/json/baremetal_client.py
index 0c319f6..479402a 100644
--- a/tempest/services/baremetal/v1/json/baremetal_client.py
+++ b/tempest/services/baremetal/v1/json/baremetal_client.py
@@ -13,7 +13,7 @@
from tempest.services.baremetal import base
-class BaremetalClientJSON(base.BaremetalClient):
+class BaremetalClient(base.BaremetalClient):
"""
Base Tempest REST client for Ironic API v1.
"""
diff --git a/tempest/services/compute/json/agents_client.py b/tempest/services/compute/json/agents_client.py
index c69e483..1a1d832 100644
--- a/tempest/services/compute/json/agents_client.py
+++ b/tempest/services/compute/json/agents_client.py
@@ -12,20 +12,19 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+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 AgentsClientJSON(service_client.ServiceClient):
+class AgentsClient(service_client.ServiceClient):
"""
Tests Agents API
"""
- def list_agents(self, params=None):
+ def list_agents(self, **params):
"""List all agent builds."""
url = 'os-agents'
if params:
@@ -45,12 +44,13 @@
def delete_agent(self, agent_id):
"""Delete an existing agent build."""
- resp, body = self.delete("os-agents/%s" % str(agent_id))
+ 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' % str(agent_id), put_body)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ resp, body = self.put('os-agents/%s' % agent_id, put_body)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body['agent'])
diff --git a/tempest/services/compute/json/aggregates_client.py b/tempest/services/compute/json/aggregates_client.py
index 6c02b63..4114b8b 100644
--- a/tempest/services/compute/json/aggregates_client.py
+++ b/tempest/services/compute/json/aggregates_client.py
@@ -13,15 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+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 AggregatesClientJSON(service_client.ServiceClient):
+class AggregatesClient(service_client.ServiceClient):
def list_aggregates(self):
"""Get aggregate list."""
@@ -32,7 +31,7 @@
def show_aggregate(self, aggregate_id):
"""Get details of the given aggregate."""
- resp, body = self.get("os-aggregates/%s" % str(aggregate_id))
+ 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['aggregate'])
@@ -46,14 +45,10 @@
self.validate_response(schema.create_aggregate, resp, body)
return service_client.ResponseBody(resp, body['aggregate'])
- def update_aggregate(self, aggregate_id, name, availability_zone=None):
+ def update_aggregate(self, aggregate_id, **kwargs):
"""Update a aggregate."""
- put_body = {
- 'name': name,
- 'availability_zone': availability_zone
- }
- put_body = json.dumps({'aggregate': put_body})
- resp, body = self.put('os-aggregates/%s' % str(aggregate_id), put_body)
+ 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)
@@ -61,7 +56,7 @@
def delete_aggregate(self, aggregate_id):
"""Deletes the given aggregate."""
- resp, body = self.delete("os-aggregates/%s" % str(aggregate_id))
+ resp, body = self.delete("os-aggregates/%s" % aggregate_id)
self.validate_response(schema.delete_aggregate, resp, body)
return service_client.ResponseBody(resp, body)
@@ -77,36 +72,27 @@
"""Returns the primary type of resource this client works with."""
return 'aggregate'
- def add_host(self, aggregate_id, host):
+ def add_host(self, aggregate_id, **kwargs):
"""Adds a host to the given aggregate."""
- post_body = {
- 'host': host,
- }
- post_body = json.dumps({'add_host': post_body})
+ 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['aggregate'])
- def remove_host(self, aggregate_id, host):
+ def remove_host(self, aggregate_id, **kwargs):
"""Removes a host from the given aggregate."""
- post_body = {
- 'host': host,
- }
- post_body = json.dumps({'remove_host': post_body})
+ 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['aggregate'])
- def set_metadata(self, aggregate_id, meta):
+ def set_metadata(self, aggregate_id, **kwargs):
"""Replaces the aggregate's existing metadata with new metadata."""
- post_body = {
- 'metadata': meta,
- }
- post_body = json.dumps({'set_metadata': post_body})
+ post_body = json.dumps({'set_metadata': kwargs})
resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
post_body)
body = json.loads(body)
diff --git a/tempest/services/compute/json/availability_zone_client.py b/tempest/services/compute/json/availability_zone_client.py
index 925d79f..c74fd10 100644
--- a/tempest/services/compute/json/availability_zone_client.py
+++ b/tempest/services/compute/json/availability_zone_client.py
@@ -13,14 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+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 AvailabilityZoneClientJSON(service_client.ServiceClient):
+class AvailabilityZoneClient(service_client.ServiceClient):
def list_availability_zones(self, detail=False):
url = 'os-availability-zone'
diff --git a/tempest/services/compute/json/baremetal_nodes_client.py b/tempest/services/compute/json/baremetal_nodes_client.py
index d8f13c4..8165292 100644
--- a/tempest/services/compute/json/baremetal_nodes_client.py
+++ b/tempest/services/compute/json/baremetal_nodes_client.py
@@ -12,8 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+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 \
@@ -21,12 +20,12 @@
from tempest.common import service_client
-class BaremetalNodesClientJSON(service_client.ServiceClient):
+class BaremetalNodesClient(service_client.ServiceClient):
"""
Tests Baremetal API
"""
- def list_baremetal_nodes(self, params=None):
+ def list_baremetal_nodes(self, **params):
"""List all baremetal nodes."""
url = 'os-baremetal-nodes'
if params:
diff --git a/tempest/services/compute/json/certificates_client.py b/tempest/services/compute/json/certificates_client.py
index 752a48e..c25b273 100644
--- a/tempest/services/compute/json/certificates_client.py
+++ b/tempest/services/compute/json/certificates_client.py
@@ -13,16 +13,16 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+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 CertificatesClientJSON(service_client.ServiceClient):
+class CertificatesClient(service_client.ServiceClient):
- def show_certificate(self, id):
- url = "os-certificates/%s" % (id)
+ 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)
diff --git a/tempest/services/compute/json/extensions_client.py b/tempest/services/compute/json/extensions_client.py
index 265b381..da342a8 100644
--- a/tempest/services/compute/json/extensions_client.py
+++ b/tempest/services/compute/json/extensions_client.py
@@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+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 ExtensionsClientJSON(service_client.ServiceClient):
+class ExtensionsClient(service_client.ServiceClient):
def list_extensions(self):
url = 'extensions'
@@ -28,11 +28,6 @@
self.validate_response(schema.list_extensions, resp, body)
return service_client.ResponseBodyList(resp, body['extensions'])
- def is_enabled(self, extension):
- extensions = self.list_extensions()
- exts = extensions['extensions']
- return any([e for e in exts if e['name'] == extension])
-
def show_extension(self, extension_alias):
resp, body = self.get('extensions/%s' % extension_alias)
body = json.loads(body)
diff --git a/tempest/services/compute/json/fixed_ips_client.py b/tempest/services/compute/json/fixed_ips_client.py
index 769bfdc..d0d9ca1 100644
--- a/tempest/services/compute/json/fixed_ips_client.py
+++ b/tempest/services/compute/json/fixed_ips_client.py
@@ -13,24 +13,24 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+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 FixedIPsClientJSON(service_client.ServiceClient):
+class FixedIPsClient(service_client.ServiceClient):
def show_fixed_ip(self, fixed_ip):
- url = "os-fixed-ips/%s" % (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['fixed_ip'])
- def reserve_fixed_ip(self, ip, body):
+ def reserve_fixed_ip(self, fixed_ip, **kwargs):
"""This reserves and unreserves fixed ips."""
- url = "os-fixed-ips/%s/action" % (ip)
- resp, body = self.post(url, json.dumps(body))
+ 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
index ebe4117..b928f9f 100644
--- a/tempest/services/compute/json/flavors_client.py
+++ b/tempest/services/compute/json/flavors_client.py
@@ -13,8 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+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
@@ -25,7 +24,7 @@
from tempest.common import service_client
-class FlavorsClientJSON(service_client.ServiceClient):
+class FlavorsClient(service_client.ServiceClient):
def list_flavors(self, detail=False, **params):
url = 'flavors'
@@ -43,7 +42,7 @@
return service_client.ResponseBodyList(resp, body['flavors'])
def show_flavor(self, flavor_id):
- resp, body = self.get("flavors/%s" % str(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['flavor'])
@@ -113,7 +112,7 @@
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' % (str(flavor_id),
+ resp, body = self.get('flavors/%s/os-extra_specs/%s' % (flavor_id,
key))
body = json.loads(body)
self.validate_response(
@@ -134,7 +133,7 @@
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' %
- (str(flavor_id), key))
+ (flavor_id, key))
self.validate_response(schema.unset_flavor_extra_specs, 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
new file mode 100644
index 0000000..1cc411b
--- /dev/null
+++ b/tempest/services/compute/json/floating_ip_pools_client.py
@@ -0,0 +1,35 @@
+# 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.
+
+import 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):
+ """Returns a list of all floating IP Pools."""
+ 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.ResponseBodyList(resp, body['floating_ip_pools'])
diff --git a/tempest/services/compute/json/floating_ips_bulk_client.py b/tempest/services/compute/json/floating_ips_bulk_client.py
new file mode 100644
index 0000000..c8e7350
--- /dev/null
+++ b/tempest/services/compute/json/floating_ips_bulk_client.py
@@ -0,0 +1,52 @@
+# 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.
+
+import 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['floating_ips_bulk_create'])
+
+ def list_floating_ips_bulk(self):
+ """Returns a list of all floating IPs 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.ResponseBodyList(resp, body['floating_ip_info'])
+
+ def delete_floating_ips_bulk(self, ip_range):
+ """Deletes the provided floating IPs 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)
+ data = body['floating_ips_bulk_delete']
+ return service_client.ResponseBodyData(resp, data)
diff --git a/tempest/services/compute/json/floating_ips_client.py b/tempest/services/compute/json/floating_ips_client.py
index 6095dc0..2193949 100644
--- a/tempest/services/compute/json/floating_ips_client.py
+++ b/tempest/services/compute/json/floating_ips_client.py
@@ -13,8 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest_lib import exceptions as lib_exc
@@ -22,9 +21,9 @@
from tempest.common import service_client
-class FloatingIPsClientJSON(service_client.ServiceClient):
+class FloatingIPsClient(service_client.ServiceClient):
- def list_floating_ips(self, params=None):
+ def list_floating_ips(self, **params):
"""Returns a list of all floating IPs filtered by any parameters."""
url = 'os-floating-ips'
if params:
@@ -37,7 +36,7 @@
def show_floating_ip(self, floating_ip_id):
"""Get the details of a floating IP."""
- url = "os-floating-ips/%s" % str(floating_ip_id)
+ url = "os-floating-ips/%s" % floating_ip_id
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.create_get_floating_ip, resp, body)
@@ -55,14 +54,14 @@
def delete_floating_ip(self, floating_ip_id):
"""Deletes the provided floating IP from the project."""
- url = "os-floating-ips/%s" % str(floating_ip_id)
+ url = "os-floating-ips/%s" % floating_ip_id
resp, body = self.delete(url)
self.validate_response(schema.add_remove_floating_ip, resp, body)
return service_client.ResponseBody(resp, body)
def associate_floating_ip_to_server(self, floating_ip, server_id):
"""Associate the provided floating IP to a specific server."""
- url = "servers/%s/action" % str(server_id)
+ url = "servers/%s/action" % server_id
post_body = {
'addFloatingIp': {
'address': floating_ip,
@@ -76,7 +75,7 @@
def disassociate_floating_ip_from_server(self, floating_ip, server_id):
"""Disassociate the provided floating IP from a specific server."""
- url = "servers/%s/action" % str(server_id)
+ url = "servers/%s/action" % server_id
post_body = {
'removeFloatingIp': {
'address': floating_ip,
@@ -99,44 +98,3 @@
def resource_type(self):
"""Returns the primary type of resource this client works with."""
return 'floating_ip'
-
- def list_floating_ip_pools(self, params=None):
- """Returns a list of all floating IP Pools."""
- 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.ResponseBodyList(resp, body['floating_ip_pools'])
-
- 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['floating_ips_bulk_create'])
-
- def list_floating_ips_bulk(self):
- """Returns a list of all floating IPs 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.ResponseBodyList(resp, body['floating_ip_info'])
-
- def delete_floating_ips_bulk(self, ip_range):
- """Deletes the provided floating IPs 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)
- data = body['floating_ips_bulk_delete']
- return service_client.ResponseBodyData(resp, data)
diff --git a/tempest/services/compute/json/hosts_client.py b/tempest/services/compute/json/hosts_client.py
index 223b80f..752af68 100644
--- a/tempest/services/compute/json/hosts_client.py
+++ b/tempest/services/compute/json/hosts_client.py
@@ -12,17 +12,16 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+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 HostsClientJSON(service_client.ServiceClient):
+class HostsClient(service_client.ServiceClient):
- def list_hosts(self, params=None):
+ def list_hosts(self, **params):
"""Lists all hosts."""
url = 'os-hosts'
@@ -37,7 +36,7 @@
def show_host(self, hostname):
"""Show detail information for the host."""
- resp, body = self.get("os-hosts/%s" % str(hostname))
+ resp, body = self.get("os-hosts/%s" % hostname)
body = json.loads(body)
self.validate_response(schema.get_host_detail, resp, body)
return service_client.ResponseBodyList(resp, body['host'])
@@ -52,7 +51,7 @@
request_body.update(**kwargs)
request_body = json.dumps(request_body)
- resp, body = self.put("os-hosts/%s" % str(hostname), 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)
@@ -60,7 +59,7 @@
def startup_host(self, hostname):
"""Startup a host."""
- resp, body = self.get("os-hosts/%s/startup" % str(hostname))
+ 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['host'])
@@ -68,7 +67,7 @@
def shutdown_host(self, hostname):
"""Shutdown a host."""
- resp, body = self.get("os-hosts/%s/shutdown" % str(hostname))
+ 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['host'])
@@ -76,7 +75,7 @@
def reboot_host(self, hostname):
"""reboot a host."""
- resp, body = self.get("os-hosts/%s/reboot" % str(hostname))
+ 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['host'])
diff --git a/tempest/services/compute/json/hypervisor_client.py b/tempest/services/compute/json/hypervisor_client.py
index 2f9f701..e894a5c 100644
--- a/tempest/services/compute/json/hypervisor_client.py
+++ b/tempest/services/compute/json/hypervisor_client.py
@@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+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 HypervisorClientJSON(service_client.ServiceClient):
+class HypervisorClient(service_client.ServiceClient):
def list_hypervisors(self, detail=False):
"""List hypervisors information."""
@@ -34,16 +34,16 @@
self.validate_response(_schema, resp, body)
return service_client.ResponseBodyList(resp, body['hypervisors'])
- def show_hypervisor(self, hyper_id):
+ def show_hypervisor(self, hypervisor_id):
"""Display the details of the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s' % hyper_id)
+ 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['hypervisor'])
- def list_servers_on_hypervisor(self, hyper_name):
+ def list_servers_on_hypervisor(self, hypervisor_name):
"""List instances belonging to the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/servers' % hyper_name)
+ 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.ResponseBodyList(resp, body['hypervisors'])
@@ -55,16 +55,16 @@
self.validate_response(schema.get_hypervisor_statistics, resp, body)
return service_client.ResponseBody(resp, body['hypervisor_statistics'])
- def show_hypervisor_uptime(self, hyper_id):
+ def show_hypervisor_uptime(self, hypervisor_id):
"""Display the uptime of the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/uptime' % hyper_id)
+ 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['hypervisor'])
- def search_hypervisor(self, hyper_name):
+ def search_hypervisor(self, hypervisor_name):
"""Search specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/search' % hyper_name)
+ 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.ResponseBodyList(resp, body['hypervisors'])
diff --git a/tempest/services/compute/json/images_client.py b/tempest/services/compute/json/images_client.py
index 3736a15..b0ce2dc 100644
--- a/tempest/services/compute/json/images_client.py
+++ b/tempest/services/compute/json/images_client.py
@@ -13,17 +13,15 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+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
-from tempest.common import waiters
-class ImagesClientJSON(service_client.ServiceClient):
+class ImagesClient(service_client.ServiceClient):
def create_image(self, server_id, name, meta=None):
"""Creates an image of the original server."""
@@ -38,7 +36,7 @@
post_body['createImage']['metadata'] = meta
post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % str(server_id),
+ 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)
@@ -61,7 +59,7 @@
def show_image(self, image_id):
"""Returns the details of a single image."""
- resp, body = self.get("images/%s" % str(image_id))
+ 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)
@@ -69,17 +67,13 @@
def delete_image(self, image_id):
"""Deletes the provided image."""
- resp, body = self.delete("images/%s" % str(image_id))
+ resp, body = self.delete("images/%s" % image_id)
self.validate_response(schema.delete, resp, body)
return service_client.ResponseBody(resp, body)
- def wait_for_image_status(self, image_id, status):
- """Waits for an image to reach a given status."""
- waiters.wait_for_image_status(self, image_id, status)
-
def list_image_metadata(self, image_id):
"""Lists all metadata items for an image."""
- resp, body = self.get("images/%s/metadata" % str(image_id))
+ 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['metadata'])
@@ -87,7 +81,7 @@
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' % str(image_id), post_body)
+ 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['metadata'])
@@ -95,14 +89,14 @@
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' % str(image_id), post_body)
+ 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['metadata'])
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" % (str(image_id), 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['meta'])
@@ -110,7 +104,7 @@
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' % (str(image_id), key),
+ 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)
@@ -119,7 +113,7 @@
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" %
- (str(image_id), key))
+ (image_id, key))
self.validate_response(schema.delete, resp, body)
return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/instance_usage_audit_log_client.py b/tempest/services/compute/json/instance_usage_audit_log_client.py
index 2b6dbb7..f06a675 100644
--- a/tempest/services/compute/json/instance_usage_audit_log_client.py
+++ b/tempest/services/compute/json/instance_usage_audit_log_client.py
@@ -13,14 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+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 InstanceUsagesAuditLogClientJSON(service_client.ServiceClient):
+class InstanceUsagesAuditLogClient(service_client.ServiceClient):
def list_instance_usage_audit_logs(self):
url = 'os-instance_usage_audit_log'
diff --git a/tempest/services/compute/json/interfaces_client.py b/tempest/services/compute/json/interfaces_client.py
index 223e90b..c437c08 100644
--- a/tempest/services/compute/json/interfaces_client.py
+++ b/tempest/services/compute/json/interfaces_client.py
@@ -13,96 +13,57 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-import time
+from oslo_serialization import jsonutils as json
from tempest.api_schema.response.compute.v2_1 import interfaces as schema
from tempest.api_schema.response.compute.v2_1 import servers as servers_schema
from tempest.common import service_client
-from tempest import exceptions
-class InterfacesClientJSON(service_client.ServiceClient):
+class InterfacesClient(service_client.ServiceClient):
- def list_interfaces(self, server):
- resp, body = self.get('servers/%s/os-interface' % server)
+ def list_interfaces(self, server_id):
+ resp, body = self.get('servers/%s/os-interface' % server_id)
body = json.loads(body)
self.validate_response(schema.list_interfaces, resp, body)
return service_client.ResponseBodyList(resp,
body['interfaceAttachments'])
- def create_interface(self, server, port_id=None, network_id=None,
- fixed_ip=None):
- post_body = dict(interfaceAttachment=dict())
- if port_id:
- post_body['interfaceAttachment']['port_id'] = port_id
- if network_id:
- post_body['interfaceAttachment']['net_id'] = network_id
- if fixed_ip:
- fip = dict(ip_address=fixed_ip)
- post_body['interfaceAttachment']['fixed_ips'] = [fip]
+ def create_interface(self, server_id, **kwargs):
+ post_body = {'interfaceAttachment': kwargs}
post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/os-interface' % server,
+ resp, body = self.post('servers/%s/os-interface' % server_id,
body=post_body)
body = json.loads(body)
self.validate_response(schema.get_create_interfaces, resp, body)
return service_client.ResponseBody(resp, body['interfaceAttachment'])
- def show_interface(self, server, port_id):
- resp, body = self.get('servers/%s/os-interface/%s' % (server, port_id))
+ def show_interface(self, server_id, port_id):
+ resp, body = self.get('servers/%s/os-interface/%s' % (server_id,
+ port_id))
body = json.loads(body)
self.validate_response(schema.get_create_interfaces, resp, body)
return service_client.ResponseBody(resp, body['interfaceAttachment'])
- def delete_interface(self, server, port_id):
- resp, body = self.delete('servers/%s/os-interface/%s' % (server,
+ def delete_interface(self, server_id, port_id):
+ resp, body = self.delete('servers/%s/os-interface/%s' % (server_id,
port_id))
self.validate_response(schema.delete_interface, resp, body)
return service_client.ResponseBody(resp, body)
- def wait_for_interface_status(self, server, port_id, status):
- """Waits for a interface to reach a given status."""
- body = self.show_interface(server, port_id)
- interface_status = body['port_state']
- start = int(time.time())
-
- while(interface_status != status):
- time.sleep(self.build_interval)
- body = self.show_interface(server, port_id)
- interface_status = body['port_state']
-
- timed_out = int(time.time()) - start >= self.build_timeout
-
- if interface_status != status and timed_out:
- message = ('Interface %s failed to reach %s status '
- '(current %s) within the required time (%s s).' %
- (port_id, status, interface_status,
- self.build_timeout))
- raise exceptions.TimeoutException(message)
-
- return body
-
- def add_fixed_ip(self, server_id, network_id):
+ def add_fixed_ip(self, server_id, **kwargs):
"""Add a fixed IP to input server instance."""
- post_body = json.dumps({
- 'addFixedIp': {
- 'networkId': network_id
- }
- })
- resp, body = self.post('servers/%s/action' % str(server_id),
+ post_body = json.dumps({'addFixedIp': kwargs})
+ resp, body = self.post('servers/%s/action' % server_id,
post_body)
self.validate_response(servers_schema.server_actions_common_schema,
resp, body)
return service_client.ResponseBody(resp, body)
- def remove_fixed_ip(self, server_id, ip_address):
+ def remove_fixed_ip(self, server_id, **kwargs):
"""Remove input fixed IP from input server instance."""
- post_body = json.dumps({
- 'removeFixedIp': {
- 'address': ip_address
- }
- })
- resp, body = self.post('servers/%s/action' % str(server_id),
+ post_body = json.dumps({'removeFixedIp': kwargs})
+ resp, body = self.post('servers/%s/action' % server_id,
post_body)
self.validate_response(servers_schema.server_actions_common_schema,
resp, body)
diff --git a/tempest/services/compute/json/keypairs_client.py b/tempest/services/compute/json/keypairs_client.py
index 143fe72..6f819ae 100644
--- a/tempest/services/compute/json/keypairs_client.py
+++ b/tempest/services/compute/json/keypairs_client.py
@@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+from oslo_serialization import jsonutils as json
from tempest.api_schema.response.compute.v2_1 import keypairs as schema
from tempest.common import service_client
-class KeyPairsClientJSON(service_client.ServiceClient):
+class KeyPairsClient(service_client.ServiceClient):
def list_keypairs(self):
resp, body = self.get("os-keypairs")
@@ -32,8 +32,8 @@
self.validate_response(schema.list_keypairs, resp, body)
return service_client.ResponseBodyList(resp, body['keypairs'])
- def show_keypair(self, key_name):
- resp, body = self.get("os-keypairs/%s" % str(key_name))
+ def show_keypair(self, keypair_name):
+ resp, body = self.get("os-keypairs/%s" % keypair_name)
body = json.loads(body)
self.validate_response(schema.get_keypair, resp, body)
return service_client.ResponseBody(resp, body['keypair'])
@@ -48,7 +48,7 @@
self.validate_response(schema.create_keypair, resp, body)
return service_client.ResponseBody(resp, body['keypair'])
- def delete_keypair(self, key_name):
- resp, body = self.delete("os-keypairs/%s" % str(key_name))
+ def delete_keypair(self, keypair_name):
+ resp, body = self.delete("os-keypairs/%s" % keypair_name)
self.validate_response(schema.delete_keypair, 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
index 1454b73..4287619 100644
--- a/tempest/services/compute/json/limits_client.py
+++ b/tempest/services/compute/json/limits_client.py
@@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+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 LimitsClientJSON(service_client.ServiceClient):
+class LimitsClient(service_client.ServiceClient):
def show_limits(self):
resp, body = self.get("limits")
diff --git a/tempest/services/compute/json/migrations_client.py b/tempest/services/compute/json/migrations_client.py
index f708a07..06c8f13 100644
--- a/tempest/services/compute/json/migrations_client.py
+++ b/tempest/services/compute/json/migrations_client.py
@@ -12,17 +12,16 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+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 MigrationsClientJSON(service_client.ServiceClient):
+class MigrationsClient(service_client.ServiceClient):
- def list_migrations(self, params=None):
+ def list_migrations(self, **params):
"""Lists all migrations."""
url = 'os-migrations'
diff --git a/tempest/services/compute/json/networks_client.py b/tempest/services/compute/json/networks_client.py
index e641787..6373f01 100644
--- a/tempest/services/compute/json/networks_client.py
+++ b/tempest/services/compute/json/networks_client.py
@@ -13,12 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+from oslo_serialization import jsonutils as json
from tempest.common import service_client
-class NetworksClientJSON(service_client.ServiceClient):
+class NetworksClient(service_client.ServiceClient):
def list_networks(self):
resp, body = self.get("os-networks")
@@ -27,7 +27,7 @@
return service_client.ResponseBodyList(resp, body['networks'])
def show_network(self, network_id):
- resp, body = self.get("os-networks/%s" % str(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['network'])
diff --git a/tempest/services/compute/json/quota_classes_client.py b/tempest/services/compute/json/quota_classes_client.py
index ad35e3f..30d3501 100644
--- a/tempest/services/compute/json/quota_classes_client.py
+++ b/tempest/services/compute/json/quota_classes_client.py
@@ -13,14 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+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 QuotaClassesClientJSON(service_client.ServiceClient):
+class QuotaClassesClient(service_client.ServiceClient):
def show_quota_class_set(self, quota_class_id):
"""List the quota class set for a quota class."""
diff --git a/tempest/services/compute/json/quotas_client.py b/tempest/services/compute/json/quotas_client.py
index f488817..88d0567 100644
--- a/tempest/services/compute/json/quotas_client.py
+++ b/tempest/services/compute/json/quotas_client.py
@@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+from oslo_serialization import jsonutils as json
from tempest.api_schema.response.compute.v2_1 import quotas as schema
from tempest.common import service_client
-class QuotasClientJSON(service_client.ServiceClient):
+class QuotasClient(service_client.ServiceClient):
def show_quota_set(self, tenant_id, user_id=None):
"""List the quota set for a tenant."""
@@ -41,59 +41,11 @@
self.validate_response(schema.get_quota_set, resp, body)
return service_client.ResponseBody(resp, body['quota_set'])
- def update_quota_set(self, tenant_id, user_id=None,
- force=None, injected_file_content_bytes=None,
- metadata_items=None, ram=None, floating_ips=None,
- fixed_ips=None, key_pairs=None, instances=None,
- security_group_rules=None, injected_files=None,
- cores=None, injected_file_path_bytes=None,
- security_groups=None):
+ def update_quota_set(self, tenant_id, user_id=None, **kwargs):
"""
Updates the tenant's quota limits for one or more resources
"""
- post_body = {}
-
- if force is not None:
- post_body['force'] = force
-
- if injected_file_content_bytes is not None:
- post_body['injected_file_content_bytes'] = \
- injected_file_content_bytes
-
- if metadata_items is not None:
- post_body['metadata_items'] = metadata_items
-
- if ram is not None:
- post_body['ram'] = ram
-
- if floating_ips is not None:
- post_body['floating_ips'] = floating_ips
-
- if fixed_ips is not None:
- post_body['fixed_ips'] = fixed_ips
-
- if key_pairs is not None:
- post_body['key_pairs'] = key_pairs
-
- if instances is not None:
- post_body['instances'] = instances
-
- if security_group_rules is not None:
- post_body['security_group_rules'] = security_group_rules
-
- if injected_files is not None:
- post_body['injected_files'] = injected_files
-
- if cores is not None:
- post_body['cores'] = cores
-
- if injected_file_path_bytes is not None:
- post_body['injected_file_path_bytes'] = injected_file_path_bytes
-
- if security_groups is not None:
- post_body['security_groups'] = security_groups
-
- post_body = json.dumps({'quota_set': post_body})
+ post_body = json.dumps({'quota_set': kwargs})
if user_id:
resp, body = self.put('os-quota-sets/%s?user_id=%s' %
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 3bf3263..fcc715a 100644
--- a/tempest/services/compute/json/security_group_default_rules_client.py
+++ b/tempest/services/compute/json/security_group_default_rules_client.py
@@ -13,14 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+from oslo_serialization import jsonutils as json
from tempest.api_schema.response.compute.v2_1 import \
security_group_default_rule as schema
from tempest.common import service_client
-class SecurityGroupDefaultRulesClientJSON(service_client.ServiceClient):
+class SecurityGroupDefaultRulesClient(service_client.ServiceClient):
def create_security_default_group_rule(self, ip_protocol, from_port,
to_port, **kwargs):
@@ -49,7 +49,7 @@
def delete_security_group_default_rule(self,
security_group_default_rule_id):
"""Deletes the provided Security Group default rule."""
- resp, body = self.delete('os-security-group-default-rules/%s' % str(
+ resp, body = self.delete('os-security-group-default-rules/%s' % (
security_group_default_rule_id))
self.validate_response(schema.delete_security_group_default_rule,
resp, body)
@@ -64,10 +64,10 @@
rules = body['security_group_default_rules']
return service_client.ResponseBodyList(resp, rules)
- def get_security_group_default_rule(self, security_group_default_rule_id):
+ def show_security_group_default_rule(self, security_group_default_rule_id):
"""Return the details of provided Security Group default rule."""
- resp, body = self.get('os-security-group-default-rules/%s' % str(
- security_group_default_rule_id))
+ resp, body = self.get('os-security-group-default-rules/%s' %
+ security_group_default_rule_id)
body = json.loads(body)
self.validate_response(schema.create_get_security_group_default_rule,
resp, body)
diff --git a/tempest/services/compute/json/security_group_rules_client.py b/tempest/services/compute/json/security_group_rules_client.py
new file mode 100644
index 0000000..f570eb7
--- /dev/null
+++ b/tempest/services/compute/json/security_group_rules_client.py
@@ -0,0 +1,68 @@
+# 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.
+
+import json
+
+from tempest_lib import exceptions as lib_exc
+
+from tempest.api_schema.response.compute.v2_1 import security_groups as schema
+from tempest.common import service_client
+
+
+class SecurityGroupRulesClient(service_client.ServiceClient):
+
+ def create_security_group_rule(self, parent_group_id, ip_proto, from_port,
+ to_port, **kwargs):
+ """
+ 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.
+ to_port : Port at end of range.
+ Following optional keyword arguments are accepted:
+ cidr : CIDR for address range.
+ group_id : ID of the Source group
+ """
+ post_body = {
+ 'parent_group_id': parent_group_id,
+ 'ip_protocol': ip_proto,
+ 'from_port': from_port,
+ 'to_port': to_port,
+ 'cidr': kwargs.get('cidr'),
+ 'group_id': kwargs.get('group_id'),
+ }
+ post_body = json.dumps({'security_group_rule': post_body})
+ url = 'os-security-group-rules'
+ resp, body = self.post(url, post_body)
+ body = json.loads(body)
+ self.validate_response(schema.create_security_group_rule, resp, body)
+ return service_client.ResponseBody(resp, body['security_group_rule'])
+
+ def delete_security_group_rule(self, group_rule_id):
+ """Deletes the provided Security Group rule."""
+ resp, body = self.delete('os-security-group-rules/%s' %
+ group_rule_id)
+ self.validate_response(schema.delete_security_group_rule, resp, body)
+ return service_client.ResponseBody(resp, body)
+
+ def list_security_group_rules(self, security_group_id):
+ """List all rules for a security group."""
+ resp, body = self.get('os-security-groups')
+ body = json.loads(body)
+ self.validate_response(schema.list_security_groups, resp, body)
+ for sg in body['security_groups']:
+ if sg['id'] == security_group_id:
+ return service_client.ResponseBodyList(resp, sg['rules'])
+ raise lib_exc.NotFound('No such Security Group')
diff --git a/tempest/services/compute/json/security_groups_client.py b/tempest/services/compute/json/security_groups_client.py
index 2855e13..eec961c 100644
--- a/tempest/services/compute/json/security_groups_client.py
+++ b/tempest/services/compute/json/security_groups_client.py
@@ -13,8 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest_lib import exceptions as lib_exc
@@ -22,9 +21,9 @@
from tempest.common import service_client
-class SecurityGroupsClientJSON(service_client.ServiceClient):
+class SecurityGroupsClient(service_client.ServiceClient):
- def list_security_groups(self, params=None):
+ def list_security_groups(self, **params):
"""List all security groups for a user."""
url = 'os-security-groups'
@@ -36,9 +35,9 @@
self.validate_response(schema.list_security_groups, resp, body)
return service_client.ResponseBodyList(resp, body['security_groups'])
- def get_security_group(self, security_group_id):
+ def show_security_group(self, security_group_id):
"""Get the details of a Security Group."""
- url = "os-security-groups/%s" % str(security_group_id)
+ url = "os-security-groups/%s" % security_group_id
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.get_security_group, resp, body)
@@ -74,7 +73,7 @@
if description:
post_body['description'] = description
post_body = json.dumps({'security_group': post_body})
- resp, body = self.put('os-security-groups/%s' % str(security_group_id),
+ resp, body = self.put('os-security-groups/%s' % security_group_id,
post_body)
body = json.loads(body)
self.validate_response(schema.update_security_group, resp, body)
@@ -83,57 +82,13 @@
def delete_security_group(self, security_group_id):
"""Deletes the provided Security Group."""
resp, body = self.delete(
- 'os-security-groups/%s' % str(security_group_id))
+ 'os-security-groups/%s' % security_group_id)
self.validate_response(schema.delete_security_group, resp, body)
return service_client.ResponseBody(resp, body)
- def create_security_group_rule(self, parent_group_id, ip_proto, from_port,
- to_port, **kwargs):
- """
- 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.
- to_port : Port at end of range.
- Following optional keyword arguments are accepted:
- cidr : CIDR for address range.
- group_id : ID of the Source group
- """
- post_body = {
- 'parent_group_id': parent_group_id,
- 'ip_protocol': ip_proto,
- 'from_port': from_port,
- 'to_port': to_port,
- 'cidr': kwargs.get('cidr'),
- 'group_id': kwargs.get('group_id'),
- }
- post_body = json.dumps({'security_group_rule': post_body})
- url = 'os-security-group-rules'
- resp, body = self.post(url, post_body)
- body = json.loads(body)
- self.validate_response(schema.create_security_group_rule, resp, body)
- return service_client.ResponseBody(resp, body['security_group_rule'])
-
- def delete_security_group_rule(self, group_rule_id):
- """Deletes the provided Security Group rule."""
- resp, body = self.delete('os-security-group-rules/%s' %
- str(group_rule_id))
- self.validate_response(schema.delete_security_group_rule, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def list_security_group_rules(self, security_group_id):
- """List all rules for a security group."""
- resp, body = self.get('os-security-groups')
- body = json.loads(body)
- self.validate_response(schema.list_security_groups, resp, body)
- for sg in body['security_groups']:
- if sg['id'] == security_group_id:
- return service_client.ResponseBodyList(resp, sg['rules'])
- raise lib_exc.NotFound('No such Security Group')
-
def is_resource_deleted(self, id):
try:
- self.get_security_group(id)
+ self.show_security_group(id)
except lib_exc.NotFound:
return True
return False
diff --git a/tempest/services/compute/json/server_groups_client.py b/tempest/services/compute/json/server_groups_client.py
new file mode 100644
index 0000000..9fec930
--- /dev/null
+++ b/tempest/services/compute/json/server_groups_client.py
@@ -0,0 +1,61 @@
+# Copyright 2012 OpenStack Foundation
+# Copyright 2013 Hewlett-Packard Development Company, L.P.
+# 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 json
+
+from tempest.api_schema.response.compute.v2_1 import servers as schema
+from tempest.common import service_client
+
+
+class ServerGroupsClient(service_client.ServiceClient):
+
+ def create_server_group(self, name, policies):
+ """
+ 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})
+ resp, body = self.post('os-server-groups', post_body)
+
+ body = json.loads(body)
+ self.validate_response(schema.create_get_server_group, resp, body)
+ return service_client.ResponseBody(resp, body['server_group'])
+
+ def delete_server_group(self, server_group_id):
+ """Delete the given server-group."""
+ resp, body = self.delete("os-server-groups/%s" % server_group_id)
+ self.validate_response(schema.delete_server_group, resp, body)
+ return service_client.ResponseBody(resp, body)
+
+ def list_server_groups(self):
+ """List the server-groups."""
+ resp, body = self.get("os-server-groups")
+ body = json.loads(body)
+ self.validate_response(schema.list_server_groups, resp, body)
+ return service_client.ResponseBodyList(resp, body['server_groups'])
+
+ def get_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)
+ return service_client.ResponseBody(resp, body['server_group'])
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index 1af1b37..1159a58 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -14,23 +14,22 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
import time
+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 servers as schema
from tempest.common import service_client
-from tempest.common import waiters
from tempest import exceptions
-class ServersClientJSON(service_client.ServiceClient):
+class ServersClient(service_client.ServiceClient):
def __init__(self, auth_provider, service, region,
enable_instance_password=True, **kwargs):
- super(ServersClientJSON, self).__init__(
+ super(ServersClient, self).__init__(
auth_provider, service, region, **kwargs)
self.enable_instance_password = enable_instance_password
@@ -131,62 +130,47 @@
post_body['OS-DCF:diskConfig'] = disk_config
post_body = json.dumps({'server': post_body})
- resp, body = self.put("servers/%s" % str(server_id), post_body)
+ resp, body = self.put("servers/%s" % server_id, post_body)
body = json.loads(body)
self.validate_response(schema.update_server, resp, body)
return service_client.ResponseBody(resp, body['server'])
- def get_server(self, server_id):
+ def show_server(self, server_id):
"""Returns the details of an existing server."""
- resp, body = self.get("servers/%s" % str(server_id))
+ 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['server'])
def delete_server(self, server_id):
"""Deletes the given server."""
- resp, body = self.delete("servers/%s" % str(server_id))
+ 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, params=None):
+ def list_servers(self, detail=False, **params):
"""Lists all servers for a user."""
url = 'servers'
+ _schema = schema.list_servers
+
+ if detail:
+ url += '/detail'
+ _schema = schema.list_servers_detail
if params:
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
- self.validate_response(schema.list_servers, resp, body)
+ self.validate_response(_schema, resp, body)
return service_client.ResponseBody(resp, body)
- def list_servers_with_detail(self, params=None):
- """Lists all servers in detail for a user."""
-
- url = 'servers/detail'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_servers_detail, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def wait_for_server_status(self, server_id, status, extra_timeout=0,
- raise_on_error=True, ready_wait=True):
- """Waits for a server to reach a given status."""
- return waiters.wait_for_server_status(self, server_id, status,
- extra_timeout=extra_timeout,
- raise_on_error=raise_on_error,
- ready_wait=ready_wait)
-
def wait_for_server_termination(self, server_id, ignore_error=False):
"""Waits for server to reach termination."""
start_time = int(time.time())
while True:
try:
- body = self.get_server(server_id)
+ body = self.show_server(server_id)
except lib_exc.NotFound:
return
@@ -201,7 +185,7 @@
def list_addresses(self, server_id):
"""Lists all addresses for a server."""
- resp, body = self.get("servers/%s/ips" % str(server_id))
+ resp, body = self.get("servers/%s/ips" % server_id)
body = json.loads(body)
self.validate_response(schema.list_addresses, resp, body)
return service_client.ResponseBody(resp, body['addresses'])
@@ -209,7 +193,7 @@
def list_addresses_by_network(self, server_id, network_id):
"""Lists all addresses of a specific network type for a server."""
resp, body = self.get("servers/%s/ips/%s" %
- (str(server_id), network_id))
+ (server_id, network_id))
body = json.loads(body)
self.validate_response(schema.list_addresses_by_network, resp, body)
return service_client.ResponseBody(resp, body)
@@ -218,7 +202,7 @@
schema=schema.server_actions_common_schema,
response_class=service_client.ResponseBody, **kwargs):
post_body = json.dumps({action_name: kwargs})
- resp, body = self.post('servers/%s/action' % str(server_id),
+ resp, body = self.post('servers/%s/action' % server_id,
post_body)
if response_key is not None:
body = json.loads(body)
@@ -250,7 +234,7 @@
def get_password(self, server_id):
resp, body = self.get("servers/%s/os-server-password" %
- str(server_id))
+ server_id)
body = json.loads(body)
self.validate_response(schema.get_password, resp, body)
return service_client.ResponseBody(resp, body)
@@ -262,7 +246,7 @@
password.
"""
resp, body = self.delete("servers/%s/os-server-password" %
- str(server_id))
+ server_id)
self.validate_response(schema.server_actions_delete_password,
resp, body)
return service_client.ResponseBody(resp, body)
@@ -303,7 +287,7 @@
return self.action(server_id, 'revertResize', None, **kwargs)
def list_server_metadata(self, server_id):
- resp, body = self.get("servers/%s/metadata" % str(server_id))
+ resp, body = self.get("servers/%s/metadata" % server_id)
body = json.loads(body)
self.validate_response(schema.list_server_metadata, resp, body)
return service_client.ResponseBody(resp, body['metadata'])
@@ -313,7 +297,7 @@
post_body = ""
else:
post_body = json.dumps({'metadata': meta})
- resp, body = self.put('servers/%s/metadata' % str(server_id),
+ resp, body = self.put('servers/%s/metadata' % server_id,
post_body)
body = json.loads(body)
self.validate_response(schema.set_server_metadata, resp, body)
@@ -321,7 +305,7 @@
def update_server_metadata(self, server_id, meta):
post_body = json.dumps({'metadata': meta})
- resp, body = self.post('servers/%s/metadata' % str(server_id),
+ resp, body = self.post('servers/%s/metadata' % server_id,
post_body)
body = json.loads(body)
self.validate_response(schema.update_server_metadata,
@@ -329,7 +313,7 @@
return service_client.ResponseBody(resp, body['metadata'])
def get_server_metadata_item(self, server_id, key):
- resp, body = self.get("servers/%s/metadata/%s" % (str(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,
resp, body)
@@ -337,7 +321,7 @@
def set_server_metadata_item(self, server_id, key, meta):
post_body = json.dumps({'meta': meta})
- resp, body = self.put('servers/%s/metadata/%s' % (str(server_id), key),
+ 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,
@@ -346,7 +330,7 @@
def delete_server_metadata_item(self, server_id, key):
resp, body = self.delete("servers/%s/metadata/%s" %
- (str(server_id), key))
+ (server_id, key))
self.validate_response(schema.delete_server_metadata_item,
resp, body)
return service_client.ResponseBody(resp, body)
@@ -381,7 +365,7 @@
def get_volume_attachment(self, server_id, attach_id):
"""Return details about the given volume attachment."""
resp, body = self.get('servers/%s/os-volume_attachments/%s' % (
- str(server_id), attach_id))
+ server_id, attach_id))
body = json.loads(body)
self.validate_response(schema.get_volume_attachment, resp, body)
return service_client.ResponseBody(resp, body['volumeAttachment'])
@@ -389,7 +373,7 @@
def list_volume_attachments(self, server_id):
"""Returns the list of volume attachments for a given instance."""
resp, body = self.get('servers/%s/os-volume_attachments' % (
- str(server_id)))
+ server_id))
body = json.loads(body)
self.validate_response(schema.list_volume_attachments, resp, body)
return service_client.ResponseBodyList(resp, body['volumeAttachments'])
@@ -413,7 +397,7 @@
req_body = json.dumps({'os-migrateLive': migrate_params})
- resp, body = self.post("servers/%s/action" % str(server_id), req_body)
+ resp, body = self.post("servers/%s/action" % server_id, req_body)
self.validate_response(schema.server_actions_common_schema,
resp, body)
return service_client.ResponseBody(resp, body)
@@ -492,13 +476,13 @@
def get_server_diagnostics(self, server_id):
"""Get the usage data for a server."""
- resp, body = self.get("servers/%s/diagnostics" % str(server_id))
+ resp, body = self.get("servers/%s/diagnostics" % server_id)
return service_client.ResponseBody(resp, json.loads(body))
def list_instance_actions(self, server_id):
"""List the provided server action."""
resp, body = self.get("servers/%s/os-instance-actions" %
- str(server_id))
+ server_id)
body = json.loads(body)
self.validate_response(schema.list_instance_actions, resp, body)
return service_client.ResponseBodyList(resp, body['instanceActions'])
@@ -506,7 +490,7 @@
def get_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" %
- (str(server_id), str(request_id)))
+ (server_id, request_id))
body = json.loads(body)
self.validate_response(schema.get_instance_action, resp, body)
return service_client.ResponseBody(resp, body['instanceAction'])
@@ -532,41 +516,3 @@
return self.action(server_id, "os-getVNCConsole",
"console", schema.get_vnc_console,
type=console_type)
-
- def create_server_group(self, name, policies):
- """
- 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})
- resp, body = self.post('os-server-groups', post_body)
-
- body = json.loads(body)
- self.validate_response(schema.create_get_server_group, resp, body)
- return service_client.ResponseBody(resp, body['server_group'])
-
- def delete_server_group(self, server_group_id):
- """Delete the given server-group."""
- resp, body = self.delete("os-server-groups/%s" % str(server_group_id))
- self.validate_response(schema.delete_server_group, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def list_server_groups(self):
- """List the server-groups."""
- resp, body = self.get("os-server-groups")
- body = json.loads(body)
- self.validate_response(schema.list_server_groups, resp, body)
- return service_client.ResponseBodyList(resp, body['server_groups'])
-
- def get_server_group(self, server_group_id):
- """Get the details of given server_group."""
- resp, body = self.get("os-server-groups/%s" % str(server_group_id))
- body = json.loads(body)
- self.validate_response(schema.create_get_server_group, resp, body)
- return service_client.ResponseBody(resp, body['server_group'])
diff --git a/tempest/services/compute/json/services_client.py b/tempest/services/compute/json/services_client.py
index 156ad8d..699d3e7 100644
--- a/tempest/services/compute/json/services_client.py
+++ b/tempest/services/compute/json/services_client.py
@@ -14,17 +14,16 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest.api_schema.response.compute.v2_1 import services as schema
from tempest.common import service_client
-class ServicesClientJSON(service_client.ServiceClient):
+class ServicesClient(service_client.ServiceClient):
- def list_services(self, params=None):
+ def list_services(self, **params):
url = 'os-services'
if params:
url += '?%s' % urllib.urlencode(params)
diff --git a/tempest/services/compute/json/tenant_networks_client.py b/tempest/services/compute/json/tenant_networks_client.py
index 11251f6..d31c5f5 100644
--- a/tempest/services/compute/json/tenant_networks_client.py
+++ b/tempest/services/compute/json/tenant_networks_client.py
@@ -12,13 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+from oslo_serialization import jsonutils as json
from tempest.api_schema.response.compute.v2_1 import tenant_networks as schema
from tempest.common import service_client
-class TenantNetworksClientJSON(service_client.ServiceClient):
+class TenantNetworksClient(service_client.ServiceClient):
def list_tenant_networks(self):
resp, body = self.get("os-tenant-networks")
@@ -26,8 +26,8 @@
self.validate_response(schema.list_tenant_networks, resp, body)
return service_client.ResponseBodyList(resp, body['networks'])
- def get_tenant_network(self, network_id):
- resp, body = self.get("os-tenant-networks/%s" % str(network_id))
+ def show_tenant_network(self, network_id):
+ resp, body = self.get("os-tenant-networks/%s" % network_id)
body = json.loads(body)
self.validate_response(schema.get_tenant_network, resp, body)
return service_client.ResponseBody(resp, body['network'])
diff --git a/tempest/services/compute/json/tenant_usages_client.py b/tempest/services/compute/json/tenant_usages_client.py
index 52f46e2..72fcde2 100644
--- a/tempest/services/compute/json/tenant_usages_client.py
+++ b/tempest/services/compute/json/tenant_usages_client.py
@@ -13,17 +13,16 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest.api_schema.response.compute.v2_1 import tenant_usages as schema
from tempest.common import service_client
-class TenantUsagesClientJSON(service_client.ServiceClient):
+class TenantUsagesClient(service_client.ServiceClient):
- def list_tenant_usages(self, params=None):
+ def list_tenant_usages(self, **params):
url = 'os-simple-tenant-usage'
if params:
url += '?%s' % urllib.urlencode(params)
@@ -33,7 +32,7 @@
self.validate_response(schema.list_tenant_usage, resp, body)
return service_client.ResponseBodyList(resp, body['tenant_usages'][0])
- def get_tenant_usage(self, tenant_id, params=None):
+ def show_tenant_usage(self, tenant_id, **params):
url = 'os-simple-tenant-usage/%s' % tenant_id
if params:
url += '?%s' % urllib.urlencode(params)
diff --git a/tempest/services/compute/json/volumes_extensions_client.py b/tempest/services/compute/json/volumes_extensions_client.py
index 4d7a7aa..ac55049 100644
--- a/tempest/services/compute/json/volumes_extensions_client.py
+++ b/tempest/services/compute/json/volumes_extensions_client.py
@@ -13,28 +13,28 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-import time
-
+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 volumes as schema
from tempest.common import service_client
-from tempest import exceptions
-class VolumesExtensionsClientJSON(service_client.ServiceClient):
+class VolumesExtensionsClient(service_client.ServiceClient):
def __init__(self, auth_provider, service, region,
default_volume_size=1, **kwargs):
- super(VolumesExtensionsClientJSON, self).__init__(
+ super(VolumesExtensionsClient, self).__init__(
auth_provider, service, region, **kwargs)
self.default_volume_size = default_volume_size
- def list_volumes(self, params=None):
+ def list_volumes(self, detail=False, **params):
"""List all the volumes created."""
url = 'os-volumes'
+
+ if detail:
+ url += '/detail'
if params:
url += '?%s' % urllib.urlencode(params)
@@ -43,20 +43,9 @@
self.validate_response(schema.list_volumes, resp, body)
return service_client.ResponseBodyList(resp, body['volumes'])
- def list_volumes_with_detail(self, params=None):
- """List all the details of volumes."""
- url = 'os-volumes/detail'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_volumes, resp, body)
- return service_client.ResponseBodyList(resp, body['volumes'])
-
- def get_volume(self, volume_id):
+ def show_volume(self, volume_id):
"""Returns the details of a single volume."""
- url = "os-volumes/%s" % str(volume_id)
+ url = "os-volumes/%s" % volume_id
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.create_get_volume, resp, body)
@@ -85,33 +74,13 @@
def delete_volume(self, volume_id):
"""Deletes the Specified Volume."""
- resp, body = self.delete("os-volumes/%s" % str(volume_id))
+ resp, body = self.delete("os-volumes/%s" % volume_id)
self.validate_response(schema.delete_volume, resp, body)
return service_client.ResponseBody(resp, body)
- def wait_for_volume_status(self, volume_id, status):
- """Waits for a Volume to reach a given status."""
- body = self.get_volume(volume_id)
- volume_status = body['status']
- start = int(time.time())
-
- while volume_status != status:
- time.sleep(self.build_interval)
- body = self.get_volume(volume_id)
- volume_status = body['status']
- if volume_status == 'error':
- raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
-
- if int(time.time()) - start >= self.build_timeout:
- message = ('Volume %s failed to reach %s status (current %s) '
- 'within the required time (%s s).' %
- (volume_id, status, volume_status,
- self.build_timeout))
- raise exceptions.TimeoutException(message)
-
def is_resource_deleted(self, id):
try:
- self.get_volume(id)
+ self.show_volume(id)
except lib_exc.NotFound:
return True
return False
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 04cf9a3..bbc0f2a 100644
--- a/tempest/services/data_processing/v1_1/data_processing_client.py
+++ b/tempest/services/data_processing/v1_1/data_processing_client.py
@@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+from oslo_serialization import jsonutils as json
from tempest.common import service_client
diff --git a/tempest/services/database/json/flavors_client.py b/tempest/services/database/json/flavors_client.py
index c956e27..4fe5a46 100644
--- a/tempest/services/database/json/flavors_client.py
+++ b/tempest/services/database/json/flavors_client.py
@@ -18,7 +18,7 @@
from tempest.common import service_client
-class DatabaseFlavorsClientJSON(service_client.ServiceClient):
+class DatabaseFlavorsClient(service_client.ServiceClient):
def list_db_flavors(self, params=None):
url = 'flavors'
diff --git a/tempest/services/database/json/limits_client.py b/tempest/services/database/json/limits_client.py
index f99ceaa..830b67f 100644
--- a/tempest/services/database/json/limits_client.py
+++ b/tempest/services/database/json/limits_client.py
@@ -18,7 +18,7 @@
from tempest.common import service_client
-class DatabaseLimitsClientJSON(service_client.ServiceClient):
+class DatabaseLimitsClient(service_client.ServiceClient):
def list_db_limits(self, params=None):
"""List all limits."""
diff --git a/tempest/services/database/json/versions_client.py b/tempest/services/database/json/versions_client.py
index 0db9c6a..ed1ba81 100644
--- a/tempest/services/database/json/versions_client.py
+++ b/tempest/services/database/json/versions_client.py
@@ -18,14 +18,14 @@
from tempest.common import service_client
-class DatabaseVersionsClientJSON(service_client.ServiceClient):
+class DatabaseVersionsClient(service_client.ServiceClient):
def __init__(self, auth_provider, service, region,
endpoint_type=None, build_interval=None, build_timeout=None,
disable_ssl_certificate_validation=None, ca_certs=None,
trace_requests=None):
dscv = disable_ssl_certificate_validation
- super(DatabaseVersionsClientJSON, self).__init__(
+ super(DatabaseVersionsClient, self).__init__(
auth_provider, service, region,
endpoint_type=endpoint_type,
build_interval=build_interval,
diff --git a/tempest/services/identity/v2/json/identity_client.py b/tempest/services/identity/v2/json/identity_client.py
index c5f7338..1076fca 100644
--- a/tempest/services/identity/v2/json/identity_client.py
+++ b/tempest/services/identity/v2/json/identity_client.py
@@ -10,13 +10,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+from oslo_serialization import jsonutils as json
from tempest_lib import exceptions as lib_exc
from tempest.common import service_client
-class IdentityClientJSON(service_client.ServiceClient):
+class IdentityClient(service_client.ServiceClient):
+ api_version = "v2.0"
def get_api_description(self):
"""Retrieves info about the v2.0 Identity API"""
diff --git a/tempest/services/identity/v3/json/credentials_client.py b/tempest/services/identity/v3/json/credentials_client.py
index 0a614cd..e27f960 100644
--- a/tempest/services/identity/v3/json/credentials_client.py
+++ b/tempest/services/identity/v3/json/credentials_client.py
@@ -13,12 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+from oslo_serialization import jsonutils as json
from tempest.common import service_client
-class CredentialsClientJSON(service_client.ServiceClient):
+class CredentialsClient(service_client.ServiceClient):
api_version = "v3"
def create_credential(self, access_key, secret_key, user_id, project_id):
diff --git a/tempest/services/identity/v3/json/endpoints_client.py b/tempest/services/identity/v3/json/endpoints_client.py
index 5b7e812..f93fb74 100644
--- a/tempest/services/identity/v3/json/endpoints_client.py
+++ b/tempest/services/identity/v3/json/endpoints_client.py
@@ -13,12 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+from oslo_serialization import jsonutils as json
from tempest.common import service_client
-class EndPointClientJSON(service_client.ServiceClient):
+class EndPointClient(service_client.ServiceClient):
api_version = "v3"
def list_endpoints(self):
diff --git a/tempest/services/identity/v3/json/identity_client.py b/tempest/services/identity/v3/json/identity_client.py
index 30fb3e1..87d4b79 100644
--- a/tempest/services/identity/v3/json/identity_client.py
+++ b/tempest/services/identity/v3/json/identity_client.py
@@ -13,14 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest.common import service_client
-class IdentityV3ClientJSON(service_client.ServiceClient):
+class IdentityV3Client(service_client.ServiceClient):
api_version = "v3"
def get_api_description(self):
diff --git a/tempest/services/identity/v3/json/policy_client.py b/tempest/services/identity/v3/json/policy_client.py
index 8c9c9ce..f820598 100644
--- a/tempest/services/identity/v3/json/policy_client.py
+++ b/tempest/services/identity/v3/json/policy_client.py
@@ -13,12 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+from oslo_serialization import jsonutils as json
from tempest.common import service_client
-class PolicyClientJSON(service_client.ServiceClient):
+class PolicyClient(service_client.ServiceClient):
api_version = "v3"
def create_policy(self, blob, type):
diff --git a/tempest/services/identity/v3/json/region_client.py b/tempest/services/identity/v3/json/region_client.py
index 02df354..43226be 100644
--- a/tempest/services/identity/v3/json/region_client.py
+++ b/tempest/services/identity/v3/json/region_client.py
@@ -13,14 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest.common import service_client
-class RegionClientJSON(service_client.ServiceClient):
+class RegionClient(service_client.ServiceClient):
api_version = "v3"
def create_region(self, description, **kwargs):
diff --git a/tempest/services/identity/v3/json/service_client.py b/tempest/services/identity/v3/json/service_client.py
index e039dc6..52ff479 100644
--- a/tempest/services/identity/v3/json/service_client.py
+++ b/tempest/services/identity/v3/json/service_client.py
@@ -13,12 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+from oslo_serialization import jsonutils as json
from tempest.common import service_client
-class ServiceClientJSON(service_client.ServiceClient):
+class ServiceClient(service_client.ServiceClient):
api_version = "v3"
def update_service(self, service_id, **kwargs):
diff --git a/tempest/services/image/v1/json/image_client.py b/tempest/services/image/v1/json/image_client.py
index add26a9..a07612a 100644
--- a/tempest/services/image/v1/json/image_client.py
+++ b/tempest/services/image/v1/json/image_client.py
@@ -15,11 +15,11 @@
import copy
import errno
-import json
import os
import time
from oslo_log import log as logging
+from oslo_serialization import jsonutils as json
import six
from six.moves.urllib import parse as urllib
from tempest_lib.common.utils import misc as misc_utils
@@ -32,13 +32,13 @@
LOG = logging.getLogger(__name__)
-class ImageClientJSON(service_client.ServiceClient):
+class ImageClient(service_client.ServiceClient):
def __init__(self, auth_provider, catalog_type, region, endpoint_type=None,
build_interval=None, build_timeout=None,
disable_ssl_certificate_validation=None,
ca_certs=None, trace_requests=None):
- super(ImageClientJSON, self).__init__(
+ super(ImageClient, self).__init__(
auth_provider,
catalog_type,
region,
diff --git a/tempest/services/image/v2/json/image_client.py b/tempest/services/image/v2/json/image_client.py
index 383c72b..67f7708 100644
--- a/tempest/services/image/v2/json/image_client.py
+++ b/tempest/services/image/v2/json/image_client.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
import jsonschema
+from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest_lib import exceptions as lib_exc
@@ -23,13 +22,13 @@
from tempest.common import service_client
-class ImageClientV2JSON(service_client.ServiceClient):
+class ImageClientV2(service_client.ServiceClient):
def __init__(self, auth_provider, catalog_type, region, endpoint_type=None,
build_interval=None, build_timeout=None,
disable_ssl_certificate_validation=None, ca_certs=None,
trace_requests=None):
- super(ImageClientV2JSON, self).__init__(
+ super(ImageClientV2, self).__init__(
auth_provider,
catalog_type,
region,
diff --git a/tempest/services/messaging/json/messaging_client.py b/tempest/services/messaging/json/messaging_client.py
index 5f6c32a..2f233a9 100644
--- a/tempest/services/messaging/json/messaging_client.py
+++ b/tempest/services/messaging/json/messaging_client.py
@@ -13,23 +13,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import json
import uuid
+from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest.api_schema.response.messaging.v1 import queues as queues_schema
from tempest.common import service_client
-class MessagingClientJSON(service_client.ServiceClient):
+class MessagingClient(service_client.ServiceClient):
def __init__(self, auth_provider, service, region,
endpoint_type=None, build_interval=None, build_timeout=None,
disable_ssl_certificate_validation=None, ca_certs=None,
trace_requests=None):
dscv = disable_ssl_certificate_validation
- super(MessagingClientJSON, self).__init__(
+ super(MessagingClient, self).__init__(
auth_provider, service, region,
endpoint_type=endpoint_type,
build_interval=build_interval,
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index 5f85199..ce200d2 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -10,9 +10,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
import time
+from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest_lib.common.utils import misc
from tempest_lib import exceptions as lib_exc
@@ -21,7 +21,7 @@
from tempest import exceptions
-class NetworkClientJSON(service_client.ServiceClient):
+class NetworkClient(service_client.ServiceClient):
"""
Tempest REST client for Neutron. Uses v2 of the Neutron API, since the
@@ -39,178 +39,233 @@
version = '2.0'
uri_prefix = "v2.0"
- def get_uri(self, plural_name):
- # get service prefix from resource name
+ def _list_resources(self, uri, **filters):
+ req_uri = self.uri_prefix + uri
+ if filters:
+ req_uri += '?' + urllib.urlencode(filters, doseq=1)
+ resp, body = self.get(req_uri)
+ body = json.loads(body)
+ self.expected_success(200, resp.status)
+ return service_client.ResponseBody(resp, body)
- # the following map is used to construct proper URI
- # for the given neutron resource
- service_resource_prefix_map = {
- 'networks': '',
- 'subnets': '',
- 'ports': '',
- 'metering_labels': 'metering',
- 'metering_label_rules': 'metering',
- }
- service_prefix = service_resource_prefix_map.get(
- plural_name)
- plural_name = plural_name.replace("_", "-")
- if service_prefix:
- uri = '%s/%s/%s' % (self.uri_prefix, service_prefix,
- plural_name)
- else:
- uri = '%s/%s' % (self.uri_prefix, plural_name)
- return uri
+ def _delete_resource(self, uri):
+ req_uri = self.uri_prefix + uri
+ resp, body = self.delete(req_uri)
+ self.expected_success(204, resp.status)
+ return service_client.ResponseBody(resp, body)
- def pluralize(self, resource_name):
- # get plural from map or just add 's'
-
- # map from resource name to a plural name
- # needed only for those which can't be constructed as name + 's'
- resource_plural_map = {
- 'security_groups': 'security_groups',
- 'security_group_rules': 'security_group_rules',
- 'quotas': 'quotas',
- }
- return resource_plural_map.get(resource_name, resource_name + 's')
-
- def _lister(self, plural_name):
- def _list(**filters):
- uri = self.get_uri(plural_name)
- if filters:
- uri += '?' + urllib.urlencode(filters, doseq=1)
- resp, body = self.get(uri)
- result = {plural_name: self.deserialize_list(body)}
- self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, result)
-
- return _list
-
- def _deleter(self, resource_name):
- def _delete(resource_id):
- plural = self.pluralize(resource_name)
- uri = '%s/%s' % (self.get_uri(plural), resource_id)
- resp, body = self.delete(uri)
- self.expected_success(204, resp.status)
- return service_client.ResponseBody(resp, body)
-
- return _delete
-
- def _shower(self, resource_name):
- def _show(resource_id, **fields):
- # fields is a dict which key is 'fields' and value is a
- # list of field's name. An example:
- # {'fields': ['id', 'name']}
- plural = self.pluralize(resource_name)
- uri = '%s/%s' % (self.get_uri(plural), resource_id)
- if fields:
- uri += '?' + urllib.urlencode(fields, doseq=1)
- resp, body = self.get(uri)
- body = self.deserialize_single(body)
- self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, body)
-
- return _show
+ def _show_resource(self, uri, **fields):
+ # fields is a dict which key is 'fields' and value is a
+ # list of field's name. An example:
+ # {'fields': ['id', 'name']}
+ req_uri = self.uri_prefix + uri
+ if fields:
+ req_uri += '?' + urllib.urlencode(fields, doseq=1)
+ resp, body = self.get(req_uri)
+ body = json.loads(body)
+ self.expected_success(200, resp.status)
+ return service_client.ResponseBody(resp, body)
def _create_resource(self, uri, post_data):
req_uri = self.uri_prefix + uri
- req_post_data = self.serialize(post_data)
+ req_post_data = json.dumps(post_data)
resp, body = self.post(req_uri, req_post_data)
- body = self.deserialize_single(body)
+ body = json.loads(body)
self.expected_success(201, resp.status)
return service_client.ResponseBody(resp, body)
- def _updater(self, resource_name):
- def _update(res_id, **kwargs):
- plural = self.pluralize(resource_name)
- uri = '%s/%s' % (self.get_uri(plural), res_id)
- post_data = self.serialize({resource_name: kwargs})
- resp, body = self.put(uri, post_data)
- body = self.deserialize_single(body)
- self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, body)
-
- return _update
-
- def __getattr__(self, name):
- method_prefixes = ["list_", "delete_", "show_", "update_"]
- method_functors = [self._lister,
- self._deleter,
- self._shower,
- self._updater]
- for index, prefix in enumerate(method_prefixes):
- prefix_len = len(prefix)
- if name[:prefix_len] == prefix:
- return method_functors[index](name[prefix_len:])
- raise AttributeError(name)
+ def _update_resource(self, uri, post_data):
+ req_uri = self.uri_prefix + uri
+ req_post_data = json.dumps(post_data)
+ resp, body = self.put(req_uri, req_post_data)
+ body = json.loads(body)
+ self.expected_success(200, resp.status)
+ return service_client.ResponseBody(resp, body)
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}
return self._create_resource(uri, post_data)
+ def show_metering_label(self, metering_label_id, **fields):
+ uri = '/metering/metering-labels/%s' % metering_label_id
+ return self._show_resource(uri, **fields)
+
+ def delete_metering_label(self, metering_label_id):
+ uri = '/metering/metering-labels/%s' % metering_label_id
+ return self._delete_resource(uri)
+
+ def list_metering_labels(self, **filters):
+ uri = '/metering/metering-labels'
+ return self._list_resources(uri, **filters)
+
def create_metering_label_rule(self, **kwargs):
uri = '/metering/metering-label-rules'
post_data = {'metering_label_rule': kwargs}
return self._create_resource(uri, post_data)
+ def show_metering_label_rule(self, metering_label_rule_id, **fields):
+ uri = '/metering/metering-label-rules/%s' % metering_label_rule_id
+ return self._show_resource(uri, **fields)
+
+ def delete_metering_label_rule(self, metering_label_rule_id):
+ uri = '/metering/metering-label-rules/%s' % metering_label_rule_id
+ return self._delete_resource(uri)
+
+ def list_metering_label_rules(self, **filters):
+ uri = '/metering/metering-label-rules'
+ return self._list_resources(uri, **filters)
+
def create_security_group(self, **kwargs):
uri = '/security-groups'
post_data = {'security_group': kwargs}
return self._create_resource(uri, post_data)
+ def update_security_group(self, security_group_id, **kwargs):
+ uri = '/security-groups/%s' % security_group_id
+ post_data = {'security_group': kwargs}
+ return self._update_resource(uri, post_data)
+
+ def show_security_group(self, security_group_id, **fields):
+ uri = '/security-groups/%s' % security_group_id
+ return self._show_resource(uri, **fields)
+
+ def delete_security_group(self, security_group_id):
+ uri = '/security-groups/%s' % security_group_id
+ return self._delete_resource(uri)
+
+ def list_security_groups(self, **filters):
+ uri = '/security-groups'
+ return self._list_resources(uri, **filters)
+
def create_security_group_rule(self, **kwargs):
uri = '/security-group-rules'
post_data = {'security_group_rule': kwargs}
return self._create_resource(uri, post_data)
- # Common methods that are hard to automate
+ def show_security_group_rule(self, security_group_rule_id, **fields):
+ uri = '/security-group-rules/%s' % security_group_rule_id
+ return self._show_resource(uri, **fields)
+
+ def delete_security_group_rule(self, security_group_rule_id):
+ uri = '/security-group-rules/%s' % security_group_rule_id
+ return self._delete_resource(uri)
+
+ def list_security_group_rules(self, **filters):
+ uri = '/security-group-rules'
+ return self._list_resources(uri, **filters)
+
+ def show_extension(self, ext_alias, **fields):
+ uri = '/extensions/%s' % ext_alias
+ return self._show_resource(uri, **fields)
+
+ def list_extensions(self, **filters):
+ uri = '/extensions'
+ return self._list_resources(uri, **filters)
+
def create_bulk_network(self, names):
network_list = [{'name': name} for name in names]
post_data = {'networks': network_list}
- body = self.serialize_list(post_data, "networks", "network")
- uri = self.get_uri("networks")
- resp, body = self.post(uri, body)
- body = {'networks': self.deserialize_list(body)}
- self.expected_success(201, resp.status)
- return service_client.ResponseBody(resp, body)
+ uri = '/networks'
+ return self._create_resource(uri, post_data)
def create_bulk_subnet(self, subnet_list):
post_data = {'subnets': subnet_list}
- body = self.serialize_list(post_data, 'subnets', 'subnet')
- uri = self.get_uri('subnets')
- resp, body = self.post(uri, body)
- body = {'subnets': self.deserialize_list(body)}
- self.expected_success(201, resp.status)
- return service_client.ResponseBody(resp, body)
+ uri = '/subnets'
+ return self._create_resource(uri, post_data)
def create_bulk_port(self, port_list):
post_data = {'ports': port_list}
- body = self.serialize_list(post_data, 'ports', 'port')
- uri = self.get_uri('ports')
- resp, body = self.post(uri, body)
- body = {'ports': self.deserialize_list(body)}
- self.expected_success(201, resp.status)
- return service_client.ResponseBody(resp, body)
+ uri = '/ports'
+ return self._create_resource(uri, post_data)
def wait_for_resource_deletion(self, resource_type, id):
"""Waits for a resource to be deleted."""
@@ -269,56 +324,33 @@
message = '(%s) %s' % (caller, message)
raise exceptions.TimeoutException(message)
- def deserialize_single(self, body):
- return json.loads(body)
-
- def deserialize_list(self, body):
- res = json.loads(body)
- # expecting response in form
- # {'resources': [ res1, res2] } => when pagination disabled
- # {'resources': [..], 'resources_links': {}} => if pagination enabled
- for k in res.keys():
- if k.endswith("_links"):
- continue
- return res[k]
-
- def serialize(self, data):
- return json.dumps(data)
-
- def serialize_list(self, data, root=None, item=None):
- return self.serialize(data)
-
def update_quotas(self, tenant_id, **kwargs):
put_body = {'quota': kwargs}
- body = json.dumps(put_body)
- uri = '%s/quotas/%s' % (self.uri_prefix, tenant_id)
- resp, body = self.put(uri, body)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body['quota'])
+ uri = '/quotas/%s' % tenant_id
+ return self._update_resource(uri, put_body)
def reset_quotas(self, tenant_id):
- uri = '%s/quotas/%s' % (self.uri_prefix, tenant_id)
- resp, body = self.delete(uri)
- self.expected_success(204, resp.status)
- return service_client.ResponseBody(resp, body)
+ uri = '/quotas/%s' % tenant_id
+ return self._delete_resource(uri)
+
+ def show_quotas(self, tenant_id, **fields):
+ uri = '/quotas/%s' % tenant_id
+ return self._show_resource(uri, **fields)
+
+ def list_quotas(self, **filters):
+ uri = '/quotas'
+ return self._list_resources(uri, **filters)
def create_router(self, name, admin_state_up=True, **kwargs):
post_body = {'router': kwargs}
post_body['router']['name'] = name
post_body['router']['admin_state_up'] = admin_state_up
- body = json.dumps(post_body)
- uri = '%s/routers' % (self.uri_prefix)
- resp, body = self.post(uri, body)
- self.expected_success(201, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ uri = '/routers'
+ return self._create_resource(uri, post_body)
def _update_router(self, router_id, set_enable_snat, **kwargs):
- uri = '%s/routers/%s' % (self.uri_prefix, router_id)
- resp, body = self.get(uri)
- self.expected_success(200, resp.status)
- body = json.loads(body)
+ uri = '/routers/%s' % router_id
+ body = self._show_resource(uri)
update_body = {}
update_body['name'] = kwargs.get('name', body['router']['name'])
update_body['admin_state_up'] = kwargs.get(
@@ -337,11 +369,7 @@
if 'distributed' in kwargs:
update_body['distributed'] = kwargs['distributed']
update_body = dict(router=update_body)
- update_body = json.dumps(update_body)
- resp, body = self.put(uri, update_body)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ return self._update_resource(uri, update_body)
def update_router(self, router_id, **kwargs):
"""Update a router leaving enable_snat to its default value."""
@@ -352,6 +380,18 @@
# policy is to restrict enable_snat usage to admins only.
return self._update_router(router_id, set_enable_snat=False, **kwargs)
+ def show_router(self, router_id, **fields):
+ uri = '/routers/%s' % router_id
+ return self._show_resource(uri, **fields)
+
+ def delete_router(self, router_id):
+ uri = '/routers/%s' % router_id
+ return self._delete_resource(uri)
+
+ def list_routers(self, **filters):
+ uri = '/routers'
+ return self._list_resources(uri, **filters)
+
def update_router_with_snat_gw_info(self, router_id, **kwargs):
"""Update a router passing also the enable_snat attribute.
@@ -361,149 +401,95 @@
return self._update_router(router_id, set_enable_snat=True, **kwargs)
def add_router_interface_with_subnet_id(self, router_id, subnet_id):
- uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
- router_id)
+ uri = '/routers/%s/add_router_interface' % router_id
update_body = {"subnet_id": subnet_id}
- update_body = json.dumps(update_body)
- resp, body = self.put(uri, update_body)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ return self._update_resource(uri, update_body)
def add_router_interface_with_port_id(self, router_id, port_id):
- uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
- router_id)
+ uri = '/routers/%s/add_router_interface' % router_id
update_body = {"port_id": port_id}
- update_body = json.dumps(update_body)
- resp, body = self.put(uri, update_body)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ return self._update_resource(uri, update_body)
def remove_router_interface_with_subnet_id(self, router_id, subnet_id):
- uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
- router_id)
+ uri = '/routers/%s/remove_router_interface' % router_id
update_body = {"subnet_id": subnet_id}
- update_body = json.dumps(update_body)
- resp, body = self.put(uri, update_body)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ return self._update_resource(uri, update_body)
def remove_router_interface_with_port_id(self, router_id, port_id):
- uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
- router_id)
+ uri = '/routers/%s/remove_router_interface' % router_id
update_body = {"port_id": port_id}
- update_body = json.dumps(update_body)
- resp, body = self.put(uri, update_body)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ return self._update_resource(uri, update_body)
def list_router_interfaces(self, uuid):
- uri = '%s/ports?device_id=%s' % (self.uri_prefix, uuid)
- resp, body = self.get(uri)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ uri = '/ports?device_id=%s' % uuid
+ return self._list_resources(uri)
def update_agent(self, agent_id, agent_info):
"""
:param agent_info: Agent update information.
E.g {"admin_state_up": True}
"""
- uri = '%s/agents/%s' % (self.uri_prefix, agent_id)
+ uri = '/agents/%s' % agent_id
agent = {"agent": agent_info}
- body = json.dumps(agent)
- resp, body = self.put(uri, body)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ return self._update_resource(uri, agent)
+
+ def show_agent(self, agent_id, **fields):
+ uri = '/agents/%s' % agent_id
+ return self._show_resource(uri, **fields)
+
+ def list_agents(self, **filters):
+ uri = '/agents'
+ return self._list_resources(uri, **filters)
def list_routers_on_l3_agent(self, agent_id):
- uri = '%s/agents/%s/l3-routers' % (self.uri_prefix, agent_id)
- resp, body = self.get(uri)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ uri = '/agents/%s/l3-routers' % agent_id
+ return self._list_resources(uri)
def list_l3_agents_hosting_router(self, router_id):
- uri = '%s/routers/%s/l3-agents' % (self.uri_prefix, router_id)
- resp, body = self.get(uri)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ uri = '/routers/%s/l3-agents' % router_id
+ return self._list_resources(uri)
def add_router_to_l3_agent(self, agent_id, router_id):
- uri = '%s/agents/%s/l3-routers' % (self.uri_prefix, agent_id)
+ uri = '/agents/%s/l3-routers' % agent_id
post_body = {"router_id": router_id}
- body = json.dumps(post_body)
- resp, body = self.post(uri, body)
- self.expected_success(201, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ return self._create_resource(uri, post_body)
def remove_router_from_l3_agent(self, agent_id, router_id):
- uri = '%s/agents/%s/l3-routers/%s' % (
- self.uri_prefix, agent_id, router_id)
- resp, body = self.delete(uri)
- self.expected_success(204, resp.status)
- return service_client.ResponseBody(resp, body)
+ uri = '/agents/%s/l3-routers/%s' % (agent_id, router_id)
+ return self._delete_resource(uri)
def list_dhcp_agent_hosting_network(self, network_id):
- uri = '%s/networks/%s/dhcp-agents' % (self.uri_prefix, network_id)
- resp, body = self.get(uri)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ uri = '/networks/%s/dhcp-agents' % network_id
+ return self._list_resources(uri)
def list_networks_hosted_by_one_dhcp_agent(self, agent_id):
- uri = '%s/agents/%s/dhcp-networks' % (self.uri_prefix, agent_id)
- resp, body = self.get(uri)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ uri = '/agents/%s/dhcp-networks' % agent_id
+ return self._list_resources(uri)
def remove_network_from_dhcp_agent(self, agent_id, network_id):
- uri = '%s/agents/%s/dhcp-networks/%s' % (self.uri_prefix, agent_id,
- network_id)
- resp, body = self.delete(uri)
- self.expected_success(204, resp.status)
- return service_client.ResponseBody(resp, body)
+ uri = '/agents/%s/dhcp-networks/%s' % (agent_id,
+ network_id)
+ return self._delete_resource(uri)
- def update_extra_routes(self, router_id, nexthop, destination):
- uri = '%s/routers/%s' % (self.uri_prefix, router_id)
+ def update_extra_routes(self, router_id, routes):
+ uri = '/routers/%s' % router_id
put_body = {
'router': {
- 'routes': [{'nexthop': nexthop,
- "destination": destination}]
+ 'routes': routes
}
}
- body = json.dumps(put_body)
- resp, body = self.put(uri, body)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ return self._update_resource(uri, put_body)
def delete_extra_routes(self, router_id):
- uri = '%s/routers/%s' % (self.uri_prefix, router_id)
- null_routes = None
+ uri = '/routers/%s' % router_id
put_body = {
'router': {
- 'routes': null_routes
+ 'routes': None
}
}
- body = json.dumps(put_body)
- resp, body = self.put(uri, body)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ return self._update_resource(uri, put_body)
def add_dhcp_agent_to_network(self, agent_id, network_id):
post_body = {'network_id': network_id}
- body = json.dumps(post_body)
- uri = '%s/agents/%s/dhcp-networks' % (self.uri_prefix, agent_id)
- resp, body = self.post(uri, body)
- self.expected_success(201, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ uri = '/agents/%s/dhcp-networks' % agent_id
+ return self._create_resource(uri, post_body)
diff --git a/tempest/services/object_storage/account_client.py b/tempest/services/object_storage/account_client.py
index dece763..d89aa5d 100644
--- a/tempest/services/object_storage/account_client.py
+++ b/tempest/services/object_storage/account_client.py
@@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
from xml.etree import ElementTree as etree
+from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest.common import service_client
diff --git a/tempest/services/object_storage/container_client.py b/tempest/services/object_storage/container_client.py
index 8e225b0..b31fe1b 100644
--- a/tempest/services/object_storage/container_client.py
+++ b/tempest/services/object_storage/container_client.py
@@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
from xml.etree import ElementTree as etree
+from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest.common import service_client
diff --git a/tempest/services/orchestration/json/orchestration_client.py b/tempest/services/orchestration/json/orchestration_client.py
index 4d443d3..84a9ed9 100644
--- a/tempest/services/orchestration/json/orchestration_client.py
+++ b/tempest/services/orchestration/json/orchestration_client.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
import re
import time
+from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest_lib import exceptions as lib_exc
diff --git a/tempest/services/telemetry/json/telemetry_client.py b/tempest/services/telemetry/json/telemetry_client.py
index b89b9e3..1f181e3 100644
--- a/tempest/services/telemetry/json/telemetry_client.py
+++ b/tempest/services/telemetry/json/telemetry_client.py
@@ -19,7 +19,7 @@
from tempest.common import service_client
-class TelemetryClientJSON(service_client.ServiceClient):
+class TelemetryClient(service_client.ServiceClient):
version = '2'
uri_prefix = "v2"
diff --git a/tempest/services/volume/json/admin/volume_hosts_client.py b/tempest/services/volume/json/admin/volume_hosts_client.py
index 1dfabaf..6801453 100644
--- a/tempest/services/volume/json/admin/volume_hosts_client.py
+++ b/tempest/services/volume/json/admin/volume_hosts_client.py
@@ -13,14 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest.common import service_client
-class BaseVolumeHostsClientJSON(service_client.ServiceClient):
+class BaseVolumeHostsClient(service_client.ServiceClient):
"""
Client class to send CRUD Volume Hosts API requests to a Cinder endpoint
"""
@@ -38,7 +37,7 @@
return service_client.ResponseBodyList(resp, body['hosts'])
-class VolumeHostsClientJSON(BaseVolumeHostsClientJSON):
+class VolumeHostsClient(BaseVolumeHostsClient):
"""
Client class to send CRUD Volume Host API V1 requests to a Cinder endpoint
"""
diff --git a/tempest/services/volume/json/admin/volume_quotas_client.py b/tempest/services/volume/json/admin/volume_quotas_client.py
index cbab3f0..a979523 100644
--- a/tempest/services/volume/json/admin/volume_quotas_client.py
+++ b/tempest/services/volume/json/admin/volume_quotas_client.py
@@ -18,7 +18,7 @@
from tempest.common import service_client
-class BaseVolumeQuotasClientJSON(service_client.ServiceClient):
+class BaseVolumeQuotasClient(service_client.ServiceClient):
"""
Client class to send CRUD Volume Quotas API requests to a Cinder endpoint
"""
@@ -75,7 +75,7 @@
return service_client.ResponseBody(resp, body)
-class VolumeQuotasClientJSON(BaseVolumeQuotasClientJSON):
+class VolumeQuotasClient(BaseVolumeQuotasClient):
"""
Client class to send CRUD Volume Type API V1 requests to a Cinder endpoint
"""
diff --git a/tempest/services/volume/json/admin/volume_services_client.py b/tempest/services/volume/json/admin/volume_services_client.py
index 94792e0..c8607c1 100644
--- a/tempest/services/volume/json/admin/volume_services_client.py
+++ b/tempest/services/volume/json/admin/volume_services_client.py
@@ -13,14 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest.common import service_client
-class BaseVolumesServicesClientJSON(service_client.ServiceClient):
+class BaseVolumesServicesClient(service_client.ServiceClient):
def list_services(self, params=None):
url = 'os-services'
@@ -33,5 +32,5 @@
return service_client.ResponseBodyList(resp, body['services'])
-class VolumesServicesClientJSON(BaseVolumesServicesClientJSON):
+class VolumesServicesClient(BaseVolumesServicesClient):
"""Volume V1 volume services client"""
diff --git a/tempest/services/volume/json/admin/volume_types_client.py b/tempest/services/volume/json/admin/volume_types_client.py
index 2436d88..84c7bc5 100644
--- a/tempest/services/volume/json/admin/volume_types_client.py
+++ b/tempest/services/volume/json/admin/volume_types_client.py
@@ -13,15 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
+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.common import service_client
-class BaseVolumeTypesClientJSON(service_client.ServiceClient):
+class BaseVolumeTypesClient(service_client.ServiceClient):
"""
Client class to send CRUD Volume Types API requests to a Cinder endpoint
"""
@@ -188,5 +187,5 @@
return service_client.ResponseBody(resp, body)
-class VolumeTypesClientJSON(BaseVolumeTypesClientJSON):
+class VolumeTypesClient(BaseVolumeTypesClient):
"""Volume V1 Volume Types client"""
diff --git a/tempest/services/volume/json/availability_zone_client.py b/tempest/services/volume/json/availability_zone_client.py
index dc0388f..13d5d55 100644
--- a/tempest/services/volume/json/availability_zone_client.py
+++ b/tempest/services/volume/json/availability_zone_client.py
@@ -13,12 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+from oslo_serialization import jsonutils as json
from tempest.common import service_client
-class BaseVolumeAvailabilityZoneClientJSON(service_client.ServiceClient):
+class BaseVolumeAvailabilityZoneClient(service_client.ServiceClient):
def list_availability_zones(self):
resp, body = self.get('os-availability-zone')
@@ -27,7 +27,7 @@
return service_client.ResponseBody(resp, body['availabilityZoneInfo'])
-class VolumeAvailabilityZoneClientJSON(BaseVolumeAvailabilityZoneClientJSON):
+class VolumeAvailabilityZoneClient(BaseVolumeAvailabilityZoneClient):
"""
Volume V1 availability zone client.
"""
diff --git a/tempest/services/volume/json/backups_client.py b/tempest/services/volume/json/backups_client.py
index 83ec182..8d34230 100644
--- a/tempest/services/volume/json/backups_client.py
+++ b/tempest/services/volume/json/backups_client.py
@@ -13,14 +13,17 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
import time
+from oslo_serialization import jsonutils as json
+
+from tempest_lib import exceptions as lib_exc
+
from tempest.common import service_client
from tempest import exceptions
-class BaseBackupsClientJSON(service_client.ServiceClient):
+class BaseBackupsClient(service_client.ServiceClient):
"""
Client class to send CRUD Volume backup API requests to a Cinder endpoint
"""
@@ -74,6 +77,24 @@
self.expected_success(200, resp.status)
return service_client.ResponseBodyList(resp, body['backups'])
+ def export_backup(self, backup_id):
+ """Export backup metadata record."""
+ url = "backups/%s/export_record" % backup_id
+ resp, body = self.get(url)
+ body = json.loads(body)
+ self.expected_success(200, resp.status)
+ return service_client.ResponseBody(resp, body['backup-record'])
+
+ def import_backup(self, backup_service, backup_url):
+ """Import backup metadata record."""
+ post_body = {'backup_service': backup_service,
+ 'backup_url': backup_url}
+ post_body = json.dumps({'backup-record': post_body})
+ resp, body = self.post("backups/import_record", post_body)
+ body = json.loads(body)
+ self.expected_success(201, resp.status)
+ return service_client.ResponseBody(resp, body['backup'])
+
def wait_for_backup_status(self, backup_id, status):
"""Waits for a Backup to reach a given status."""
body = self.show_backup(backup_id)
@@ -94,6 +115,18 @@
self.build_timeout))
raise exceptions.TimeoutException(message)
+ def wait_for_backup_deletion(self, backup_id):
+ """Waits for backup deletion"""
+ start_time = int(time.time())
+ while True:
+ try:
+ self.show_backup(backup_id)
+ except lib_exc.NotFound:
+ return
+ if int(time.time()) - start_time >= self.build_timeout:
+ raise exceptions.TimeoutException
+ time.sleep(self.build_interval)
-class BackupsClientJSON(BaseBackupsClientJSON):
+
+class BackupsClient(BaseBackupsClient):
"""Volume V1 Backups client"""
diff --git a/tempest/services/volume/json/extensions_client.py b/tempest/services/volume/json/extensions_client.py
index 8a7bce7..1098e1e 100644
--- a/tempest/services/volume/json/extensions_client.py
+++ b/tempest/services/volume/json/extensions_client.py
@@ -13,12 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+from oslo_serialization import jsonutils as json
from tempest.common import service_client
-class BaseExtensionsClientJSON(service_client.ServiceClient):
+class BaseExtensionsClient(service_client.ServiceClient):
def list_extensions(self):
url = 'extensions'
@@ -28,7 +28,7 @@
return service_client.ResponseBodyList(resp, body['extensions'])
-class ExtensionsClientJSON(BaseExtensionsClientJSON):
+class ExtensionsClient(BaseExtensionsClient):
"""
Volume V1 extensions client.
"""
diff --git a/tempest/services/volume/json/qos_client.py b/tempest/services/volume/json/qos_client.py
index e9d3777..e3d6a29 100644
--- a/tempest/services/volume/json/qos_client.py
+++ b/tempest/services/volume/json/qos_client.py
@@ -12,16 +12,16 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
import time
+from oslo_serialization import jsonutils as json
from tempest_lib import exceptions as lib_exc
from tempest.common import service_client
from tempest import exceptions
-class BaseQosSpecsClientJSON(service_client.ServiceClient):
+class BaseQosSpecsClient(service_client.ServiceClient):
"""Client class to send CRUD QoS API requests"""
def is_resource_deleted(self, qos_id):
@@ -157,5 +157,5 @@
return service_client.ResponseBody(resp, body)
-class QosSpecsClientJSON(BaseQosSpecsClientJSON):
+class QosSpecsClient(BaseQosSpecsClient):
"""Volume V1 QoS client."""
diff --git a/tempest/services/volume/json/snapshots_client.py b/tempest/services/volume/json/snapshots_client.py
index cfa02bd..fa1f9dd 100644
--- a/tempest/services/volume/json/snapshots_client.py
+++ b/tempest/services/volume/json/snapshots_client.py
@@ -10,10 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
import time
from oslo_log import log as logging
+from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
from tempest_lib import exceptions as lib_exc
@@ -24,7 +24,7 @@
LOG = logging.getLogger(__name__)
-class BaseSnapshotsClientJSON(service_client.ServiceClient):
+class BaseSnapshotsClient(service_client.ServiceClient):
"""Base Client class to send CRUD Volume API requests."""
create_resp = 200
@@ -198,5 +198,5 @@
return service_client.ResponseBody(resp, body)
-class SnapshotsClientJSON(BaseSnapshotsClientJSON):
+class SnapshotsClient(BaseSnapshotsClient):
"""Client class to send CRUD Volume V1 API requests."""
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index 65aa0f4..26f186e 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -13,17 +13,16 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-import time
-
+from oslo_serialization import jsonutils as json
+import six
from six.moves.urllib import parse as urllib
from tempest_lib import exceptions as lib_exc
from tempest.common import service_client
-from tempest import exceptions
+from tempest.common import waiters
-class BaseVolumesClientJSON(service_client.ServiceClient):
+class BaseVolumesClient(service_client.ServiceClient):
"""
Base client class to send CRUD Volume API requests to a Cinder endpoint
"""
@@ -32,7 +31,7 @@
def __init__(self, auth_provider, service, region,
default_volume_size=1, **kwargs):
- super(BaseVolumesClientJSON, self).__init__(
+ super(BaseVolumesClient, self).__init__(
auth_provider, service, region, **kwargs)
self.default_volume_size = default_volume_size
@@ -40,18 +39,57 @@
"""Return the element 'attachment' from input volumes."""
return volume['attachments'][0]
- def list_volumes(self, detail=False, params=None):
- """List all the volumes created."""
+ def _ext_get(self, url, key=None, status=200):
+ """Extended get method.
+
+ Retrieves requested url, checks that status is expected status and
+ return a ResponseBody, ResponseBodyList or ResponseBodyData depending
+ on received data's key entry.
+
+ If key is not specified or is None we will return the whole body in a
+ ResponseBody class.
+ """
+
+ resp, body = self.get(url)
+ body = json.loads(body)
+ self.expected_success(status, resp.status)
+
+ if not key:
+ return service_client.ResponseBody(resp, body)
+ elif isinstance(body[key], dict):
+ return service_client.ResponseBody(resp, body[key])
+ elif isinstance(body[key], list):
+ return service_client.ResponseBodyList(resp, body[key])
+
+ return service_client.ResponseBodyData(resp, body[key])
+
+ def _prepare_params(self, params):
+ """Prepares params for use in get or _ext_get methods.
+
+ If params is a string it will be left as it is, but if it's not it will
+ be urlencoded.
+ """
+ if isinstance(params, six.string_types):
+ return params
+ return urllib.urlencode(params)
+
+ def list_volumes(self, detail=False, params=None, return_body=False):
+ """List all the volumes created.
+
+ Params can be a string (must be urlencoded) or a dictionary.
+ If return_body is True then we will return the whole response body in
+ a ResponseBody class, it it's False or has not been specified we will
+ return only the list of volumes in a ResponseBodyList (inherits from
+ list).
+ """
url = 'volumes'
if detail:
url += '/detail'
if params:
- url += '?%s' % urllib.urlencode(params)
+ url += '?%s' % self._prepare_params(params)
- resp, body = self.get(url)
- body = json.loads(body)
- self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, body['volumes'])
+ key = None if return_body else 'volumes'
+ return self._ext_get(url, key)
def show_volume(self, volume_id):
"""Returns the details of a single volume."""
@@ -161,25 +199,7 @@
def wait_for_volume_status(self, volume_id, status):
"""Waits for a Volume to reach a given status."""
- body = self.show_volume(volume_id)
- volume_status = body['status']
- start = int(time.time())
-
- while volume_status != status:
- time.sleep(self.build_interval)
- body = self.show_volume(volume_id)
- volume_status = body['status']
- if volume_status == 'error':
- raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
-
- if int(time.time()) - start >= self.build_timeout:
- message = ('Volume %s failed to reach %s status (current: %s) '
- 'within the required time '
- '(%s s).' % (volume_id,
- status,
- volume_status,
- self.build_timeout))
- raise exceptions.TimeoutException(message)
+ waiters.wait_for_volume_status(self, volume_id, status)
def is_resource_deleted(self, id):
try:
@@ -345,7 +365,7 @@
self.expected_success(202, resp.status)
-class VolumesClientJSON(BaseVolumesClientJSON):
+class VolumesClient(BaseVolumesClient):
"""
Client class to send CRUD Volume V1 API requests to a Cinder endpoint
"""
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 b93d031..f0cc03f 100644
--- a/tempest/services/volume/v2/json/admin/volume_hosts_client.py
+++ b/tempest/services/volume/v2/json/admin/volume_hosts_client.py
@@ -17,7 +17,7 @@
from tempest.services.volume.json.admin import volume_hosts_client
-class VolumeHostsV2ClientJSON(volume_hosts_client.BaseVolumeHostsClientJSON):
+class VolumeHostsV2Client(volume_hosts_client.BaseVolumeHostsClient):
"""
Client class to send CRUD Volume V2 API requests to a Cinder endpoint
"""
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 1dc48cd..635b6e1 100644
--- a/tempest/services/volume/v2/json/admin/volume_quotas_client.py
+++ b/tempest/services/volume/v2/json/admin/volume_quotas_client.py
@@ -16,7 +16,7 @@
from tempest.services.volume.json.admin import volume_quotas_client
-class VolumeQuotasV2Client(volume_quotas_client.BaseVolumeQuotasClientJSON):
+class VolumeQuotasV2Client(volume_quotas_client.BaseVolumeQuotasClient):
"""
Client class to send CRUD Volume V2 API requests to a Cinder endpoint
"""
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 51224c5..d0efc38 100644
--- a/tempest/services/volume/v2/json/admin/volume_services_client.py
+++ b/tempest/services/volume/v2/json/admin/volume_services_client.py
@@ -16,7 +16,7 @@
from tempest.services.volume.json.admin import volume_services_client as vs_cli
-class VolumesServicesV2ClientJSON(vs_cli.BaseVolumesServicesClientJSON):
+class VolumesServicesV2Client(vs_cli.BaseVolumesServicesClient):
"""
Client class to send CRUD Volume V2 API requests to a Cinder endpoint
"""
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 24099b2..1b9ff51 100644
--- a/tempest/services/volume/v2/json/admin/volume_types_client.py
+++ b/tempest/services/volume/v2/json/admin/volume_types_client.py
@@ -17,7 +17,7 @@
from tempest.services.volume.json.admin import volume_types_client
-class VolumeTypesV2ClientJSON(volume_types_client.BaseVolumeTypesClientJSON):
+class VolumeTypesV2Client(volume_types_client.BaseVolumeTypesClient):
"""
Client class to send CRUD Volume V2 API requests to a Cinder endpoint
"""
diff --git a/tempest/services/volume/v2/json/availability_zone_client.py b/tempest/services/volume/v2/json/availability_zone_client.py
index dc85634..2e1ab20 100644
--- a/tempest/services/volume/v2/json/availability_zone_client.py
+++ b/tempest/services/volume/v2/json/availability_zone_client.py
@@ -16,6 +16,6 @@
from tempest.services.volume.json import availability_zone_client
-class VolumeV2AvailabilityZoneClientJSON(
- availability_zone_client.BaseVolumeAvailabilityZoneClientJSON):
+class VolumeV2AvailabilityZoneClient(
+ availability_zone_client.BaseVolumeAvailabilityZoneClient):
api_version = "v2"
diff --git a/tempest/services/volume/v2/json/backups_client.py b/tempest/services/volume/v2/json/backups_client.py
index 30d9e8e..1ce11ce 100644
--- a/tempest/services/volume/v2/json/backups_client.py
+++ b/tempest/services/volume/v2/json/backups_client.py
@@ -16,7 +16,7 @@
from tempest.services.volume.json import backups_client
-class BackupsClientV2JSON(backups_client.BaseBackupsClientJSON):
+class BackupsClientV2(backups_client.BaseBackupsClient):
"""
Client class to send CRUD Volume V2 API requests to a Cinder endpoint
"""
diff --git a/tempest/services/volume/v2/json/extensions_client.py b/tempest/services/volume/v2/json/extensions_client.py
index 8dda833..3e32c0c 100644
--- a/tempest/services/volume/v2/json/extensions_client.py
+++ b/tempest/services/volume/v2/json/extensions_client.py
@@ -16,5 +16,5 @@
from tempest.services.volume.json import extensions_client
-class ExtensionsV2ClientJSON(extensions_client.BaseExtensionsClientJSON):
+class ExtensionsV2Client(extensions_client.BaseExtensionsClient):
api_version = "v2"
diff --git a/tempest/services/volume/v2/json/qos_client.py b/tempest/services/volume/v2/json/qos_client.py
index d17da6d..42bd1c9 100644
--- a/tempest/services/volume/v2/json/qos_client.py
+++ b/tempest/services/volume/v2/json/qos_client.py
@@ -15,5 +15,5 @@
from tempest.services.volume.json import qos_client
-class QosSpecsV2ClientJSON(qos_client.BaseQosSpecsClientJSON):
+class QosSpecsV2Client(qos_client.BaseQosSpecsClient):
api_version = "v2"
diff --git a/tempest/services/volume/v2/json/snapshots_client.py b/tempest/services/volume/v2/json/snapshots_client.py
index 90580f9..a94f9cd 100644
--- a/tempest/services/volume/v2/json/snapshots_client.py
+++ b/tempest/services/volume/v2/json/snapshots_client.py
@@ -13,7 +13,7 @@
from tempest.services.volume.json import snapshots_client
-class SnapshotsV2ClientJSON(snapshots_client.BaseSnapshotsClientJSON):
+class SnapshotsV2Client(snapshots_client.BaseSnapshotsClient):
"""Client class to send CRUD Volume V2 API requests."""
api_version = "v2"
create_resp = 202
diff --git a/tempest/services/volume/v2/json/volumes_client.py b/tempest/services/volume/v2/json/volumes_client.py
index 85ffb91..a6d081c 100644
--- a/tempest/services/volume/v2/json/volumes_client.py
+++ b/tempest/services/volume/v2/json/volumes_client.py
@@ -16,7 +16,7 @@
from tempest.services.volume.json import volumes_client
-class VolumesV2ClientJSON(volumes_client.BaseVolumesClientJSON):
+class VolumesV2Client(volumes_client.BaseVolumesClient):
"""
Client class to send CRUD Volume V2 API requests to a Cinder endpoint
"""
diff --git a/tempest/stress/actions/server_create_destroy.py b/tempest/stress/actions/server_create_destroy.py
index c0a3178..9f41526 100644
--- a/tempest/stress/actions/server_create_destroy.py
+++ b/tempest/stress/actions/server_create_destroy.py
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from tempest_lib.common.utils import data_utils
-
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import config
import tempest.stress.stressaction as stressaction
@@ -32,8 +32,8 @@
server = self.manager.servers_client.create_server(
name, self.image, self.flavor)
server_id = server['id']
- self.manager.servers_client.wait_for_server_status(server_id,
- 'ACTIVE')
+ waiters.wait_for_server_status(self.manager.servers_client, server_id,
+ 'ACTIVE')
self.logger.info("created %s" % server_id)
self.logger.info("deleting %s" % name)
self.manager.servers_client.delete_server(server_id)
diff --git a/tempest/stress/actions/ssh_floating.py b/tempest/stress/actions/ssh_floating.py
index b2a30e9..4a27466 100644
--- a/tempest/stress/actions/ssh_floating.py
+++ b/tempest/stress/actions/ssh_floating.py
@@ -13,8 +13,8 @@
import socket
import subprocess
-from tempest_lib.common.utils import data_utils
-
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import config
import tempest.stress.stressaction as stressaction
import tempest.test
@@ -80,8 +80,8 @@
**vm_args)
self.server_id = server['id']
if self.wait_after_vm_create:
- self.manager.servers_client.wait_for_server_status(self.server_id,
- 'ACTIVE')
+ waiters.wait_for_server_status(self.manager.servers_client,
+ self.server_id, 'ACTIVE')
def _destroy_vm(self):
self.logger.info("deleting %s" % self.server_id)
@@ -173,8 +173,8 @@
self._create_vm()
if self.reboot:
self.manager.servers_client.reboot(self.server_id, 'HARD')
- self.manager.servers_client.wait_for_server_status(self.server_id,
- 'ACTIVE')
+ waiters.wait_for_server_status(self.manager.servers_client,
+ self.server_id, 'ACTIVE')
self.run_core()
diff --git a/tempest/stress/actions/volume_attach_delete.py b/tempest/stress/actions/volume_attach_delete.py
index 93400c4..d6965c7 100644
--- a/tempest/stress/actions/volume_attach_delete.py
+++ b/tempest/stress/actions/volume_attach_delete.py
@@ -11,8 +11,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from tempest_lib.common.utils import data_utils
-
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import config
import tempest.stress.stressaction as stressaction
@@ -41,7 +41,8 @@
server = self.manager.servers_client.create_server(
vm_name, self.image, self.flavor)
server_id = server['id']
- self.manager.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+ waiters.wait_for_server_status(self.manager.servers_client, server_id,
+ 'ACTIVE')
self.logger.info("created vm %s" % server_id)
# Step 3: attach volume to vm
diff --git a/tempest/stress/actions/volume_attach_verify.py b/tempest/stress/actions/volume_attach_verify.py
index ea53481..3ba2a91 100644
--- a/tempest/stress/actions/volume_attach_verify.py
+++ b/tempest/stress/actions/volume_attach_verify.py
@@ -12,9 +12,9 @@
import re
-from tempest_lib.common.utils import data_utils
-
+from tempest.common.utils import data_utils
from tempest.common.utils.linux import remote_client
+from tempest.common import waiters
from tempest import config
import tempest.stress.stressaction as stressaction
import tempest.test
@@ -42,8 +42,8 @@
self.flavor,
**vm_args)
self.server_id = server['id']
- self.manager.servers_client.wait_for_server_status(self.server_id,
- 'ACTIVE')
+ waiters.wait_for_server_status(self.manager.servers_client,
+ self.server_id, 'ACTIVE')
def _destroy_vm(self):
self.logger.info("deleting server: %s" % self.server_id)
diff --git a/tempest/stress/actions/volume_create_delete.py b/tempest/stress/actions/volume_create_delete.py
index b1899a0..4870055 100644
--- a/tempest/stress/actions/volume_create_delete.py
+++ b/tempest/stress/actions/volume_create_delete.py
@@ -10,8 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from tempest_lib.common.utils import data_utils
-
+from tempest.common.utils import data_utils
import tempest.stress.stressaction as stressaction
diff --git a/tempest/stress/cleanup.py b/tempest/stress/cleanup.py
index 29c4401..b785156 100644
--- a/tempest/stress/cleanup.py
+++ b/tempest/stress/cleanup.py
@@ -24,7 +24,7 @@
def cleanup():
admin_manager = clients.AdminManager()
- body = admin_manager.servers_client.list_servers({"all_tenants": True})
+ body = admin_manager.servers_client.list_servers(all_tenants=True)
LOG.info("Cleanup::remove %s servers" % len(body['servers']))
for s in body['servers']:
try:
@@ -47,7 +47,7 @@
pass
secgrp_client = admin_manager.security_groups_client
- secgrp = secgrp_client.list_security_groups({"all_tenants": True})
+ secgrp = secgrp_client.list_security_groups(all_tenants=True)
secgrp_del = [grp for grp in secgrp if grp['name'] != 'default']
LOG.info("Cleanup::remove %s Security Group" % len(secgrp_del))
for g in secgrp_del:
diff --git a/tempest/stress/driver.py b/tempest/stress/driver.py
index 3f8e537..bdb39d8 100644
--- a/tempest/stress/driver.py
+++ b/tempest/stress/driver.py
@@ -22,10 +22,11 @@
import six
from six import moves
from tempest_lib.common import ssh
-from tempest_lib.common.utils import data_utils
+
from tempest import clients
from tempest.common import isolated_creds
+from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
from tempest.stress import cleanup
diff --git a/tempest/test.py b/tempest/test.py
index 0d709f6c..df6b30d 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -15,7 +15,6 @@
import atexit
import functools
-import json
import os
import re
import sys
@@ -25,6 +24,7 @@
import fixtures
from oslo_log import log as logging
+from oslo_serialization import jsonutils as json
from oslo_utils import importutils
import six
import testscenarios
@@ -43,8 +43,8 @@
CONF = config.CONF
-def attr(*args, **kwargs):
- """A decorator which applies the testtools attr decorator
+def attr(**kwargs):
+ """A decorator which applies the testtools attr decorator
This decorator applies the testtools.testcase.attr if it is in the list of
attributes to testtools we want to apply.
@@ -98,7 +98,7 @@
return service_list
-def services(*args, **kwargs):
+def services(*args):
"""A decorator used to set an attr for each service used in a test case
This decorator applies a testtools attr for each service that gets
@@ -128,7 +128,7 @@
return decorator
-def stresstest(*args, **kwargs):
+def stresstest(**kwargs):
"""Add stress test decorator
For all functions with this decorator a attr stress will be
@@ -154,7 +154,7 @@
return decorator
-def requires_ext(*args, **kwargs):
+def requires_ext(**kwargs):
"""A decorator to skip tests if an extension is not enabled
@param extension
diff --git a/tempest/test_discover/plugins.py b/tempest/test_discover/plugins.py
new file mode 100644
index 0000000..45cd609
--- /dev/null
+++ b/tempest/test_discover/plugins.py
@@ -0,0 +1,81 @@
+# Copyright (c) 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.
+
+import abc
+import logging
+
+import six
+import stevedore
+from tempest_lib.common.utils import misc
+
+
+LOG = logging.getLogger(__name__)
+
+
+@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.
+ """
+
+ @abc.abstractmethod
+ def load_tests(self):
+ """Method to 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
+ :rtype: tuple
+ """
+ return
+
+ @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
+
+ :param ConfigOpts conf: The conf object that can be used to register
+ additional options on.
+ """
+ return
+
+
+@misc.singleton
+class TempestTestPluginManager(object):
+ """Tempest test plugin manager class
+
+ This class is used to manage the lifecycle of external tempest test
+ plugins. It provides functions for getting set
+ """
+ def __init__(self):
+ self.ext_plugins = stevedore.ExtensionManager(
+ 'tempest.test_plugins', invoke_on_load=True,
+ propagate_map_exceptions=True,
+ on_load_failure_callback=self.failure_hook)
+
+ @staticmethod
+ def failure_hook(_, ep, err):
+ LOG.error('Could not load %r: %s', ep.name, err)
+ raise err
+
+ def get_plugin_load_tests_tuple(self):
+ load_tests_dict = {}
+ for plug in self.ext_plugins:
+ load_tests_dict[plug.name] = plug.obj.load_tests()
+ return load_tests_dict
+
+ def register_plugin_opts(self, conf):
+ for plug in self.ext_plugins:
+ plug.obj.register_opts(conf)
diff --git a/tempest/test_discover/test_discover.py b/tempest/test_discover/test_discover.py
index 4a4b43a..dac7d91 100644
--- a/tempest/test_discover/test_discover.py
+++ b/tempest/test_discover/test_discover.py
@@ -15,6 +15,8 @@
import os
import sys
+from tempest.test_discover import plugins
+
if sys.version_info >= (2, 7):
import unittest
else:
@@ -22,14 +24,32 @@
def load_tests(loader, tests, pattern):
+ ext_plugins = plugins.TempestTestPluginManager()
+
suite = unittest.TestSuite()
base_path = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
base_path = os.path.split(base_path)[0]
- for test_dir in ['./tempest/api', './tempest/scenario',
- './tempest/thirdparty']:
+ # Load local tempest tests
+ for test_dir in ['tempest/api', 'tempest/scenario',
+ 'tempest/thirdparty']:
+ full_test_dir = os.path.join(base_path, test_dir)
if not pattern:
- suite.addTests(loader.discover(test_dir, top_level_dir=base_path))
+ suite.addTests(loader.discover(full_test_dir,
+ top_level_dir=base_path))
+ else:
+ suite.addTests(loader.discover(full_test_dir, pattern=pattern,
+ top_level_dir=base_path))
+
+ plugin_load_tests = ext_plugins.get_plugin_load_tests_tuple()
+ if not plugin_load_tests:
+ return suite
+
+ # Load any installed plugin tests
+ for plugin in plugin_load_tests:
+ test_dir, top_path = plugin_load_tests[plugin]
+ if not pattern:
+ suite.addTests(loader.discover(test_dir, top_level_dir=top_path))
else:
suite.addTests(loader.discover(test_dir, pattern=pattern,
- top_level_dir=base_path))
+ top_level_dir=top_path))
return suite
diff --git a/tempest/tests/cmd/test_tempest_init.py b/tempest/tests/cmd/test_tempest_init.py
new file mode 100644
index 0000000..6b5af7e
--- /dev/null
+++ b/tempest/tests/cmd/test_tempest_init.py
@@ -0,0 +1,66 @@
+# 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.
+
+import os
+
+import fixtures
+
+from tempest.cmd import init
+from tempest.tests import base
+
+
+class TestTempestInit(base.TestCase):
+
+ def test_generate_testr_conf(self):
+ # Create fake conf dir
+ conf_dir = self.useFixture(fixtures.TempDir())
+
+ init_cmd = init.TempestInit(None, None)
+ init_cmd.generate_testr_conf(conf_dir.path)
+
+ # Generate expected file contents
+ top_level_path = os.path.dirname(os.path.dirname(init.__file__))
+ discover_path = os.path.join(top_level_path, 'test_discover')
+ testr_conf_file = init.TESTR_CONF % (top_level_path, discover_path)
+
+ conf_path = conf_dir.join('.testr.conf')
+ conf_file = open(conf_path, 'r')
+ self.addCleanup(conf_file.close)
+ self.assertEqual(conf_file.read(), testr_conf_file)
+
+ def test_create_working_dir(self):
+ fake_local_dir = self.useFixture(fixtures.TempDir())
+ fake_local_conf_dir = self.useFixture(fixtures.TempDir())
+ # Create a fake conf file
+ fake_file = fake_local_conf_dir.join('conf_file.conf')
+ open(fake_file, 'w').close()
+ init_cmd = init.TempestInit(None, None)
+ init_cmd.create_working_dir(fake_local_dir.path,
+ fake_local_conf_dir.path)
+ # Assert directories are created
+ lock_path = os.path.join(fake_local_dir.path, 'tempest_lock')
+ etc_dir = os.path.join(fake_local_dir.path, 'etc')
+ log_dir = os.path.join(fake_local_dir.path, 'logs')
+ testr_dir = os.path.join(fake_local_dir.path, '.testrepository')
+ self.assertTrue(os.path.isdir(lock_path))
+ self.assertTrue(os.path.isdir(etc_dir))
+ self.assertTrue(os.path.isdir(log_dir))
+ self.assertTrue(os.path.isdir(testr_dir))
+ # Assert file creation
+ fake_file_moved = os.path.join(etc_dir, 'conf_file.conf')
+ local_conf_file = os.path.join(etc_dir, 'tempest.conf')
+ local_testr_conf = os.path.join(fake_local_dir.path, '.testr.conf')
+ self.assertTrue(os.path.isfile(fake_file_moved))
+ self.assertTrue(os.path.isfile(local_conf_file))
+ self.assertTrue(os.path.isfile(local_testr_conf))
diff --git a/tempest/tests/cmd/test_verify_tempest_config.py b/tempest/tests/cmd/test_verify_tempest_config.py
index 7286d76..6bc96f2 100644
--- a/tempest/tests/cmd/test_verify_tempest_config.py
+++ b/tempest/tests/cmd/test_verify_tempest_config.py
@@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
import mock
+from oslo_serialization import jsonutils as json
from oslotest import mockpatch
from tempest.cmd import verify_tempest_config
diff --git a/tempest/tests/common/test_accounts.py b/tempest/tests/common/test_accounts.py
index e713969..8fc3745 100644
--- a/tempest/tests/common/test_accounts.py
+++ b/tempest/tests/common/test_accounts.py
@@ -291,14 +291,12 @@
{'username': 'test_user14', 'tenant_name': 'test_tenant14',
'password': 'p', 'roles': ['role-7', 'role-11'],
'resources': {'network': 'network-2'}}]
- # Clear previous mock using self.test_accounts
- self.accounts_mock.cleanUp()
self.useFixture(mockpatch.Patch(
'tempest.common.accounts.read_accounts_yaml',
return_value=test_accounts))
test_accounts_class = accounts.Accounts('v2', 'test_name')
with mock.patch('tempest.services.compute.json.networks_client.'
- 'NetworksClientJSON.list_networks',
+ 'NetworksClient.list_networks',
return_value=[{'name': 'network-2', 'id': 'fake-id',
'label': 'network-2'}]):
creds = test_accounts_class.get_creds_by_roles(['role-7'])
diff --git a/tempest/tests/common/test_service_clients.py b/tempest/tests/common/test_service_clients.py
index c6c1053..3a0873c 100644
--- a/tempest/tests/common/test_service_clients.py
+++ b/tempest/tests/common/test_service_clients.py
@@ -24,6 +24,8 @@
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
@@ -38,7 +40,9 @@
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
@@ -104,71 +108,75 @@
@mock.patch('tempest_lib.common.rest_client.RestClient.__init__')
def test_service_client_creations_with_specified_args(self, mock_init):
test_clients = [
- baremetal_client.BaremetalClientJSON,
- agents_client.AgentsClientJSON,
- aggregates_client.AggregatesClientJSON,
- availability_zone_client.AvailabilityZoneClientJSON,
- certificates_client.CertificatesClientJSON,
- extensions_client.ExtensionsClientJSON,
- fixed_ips_client.FixedIPsClientJSON,
- flavors_client.FlavorsClientJSON,
- floating_ips_client.FloatingIPsClientJSON,
- hosts_client.HostsClientJSON,
- hypervisor_client.HypervisorClientJSON,
- images_client.ImagesClientJSON,
- instance_usage_audit_log_client.InstanceUsagesAuditLogClientJSON,
- interfaces_client.InterfacesClientJSON,
- keypairs_client.KeyPairsClientJSON,
- limits_client.LimitsClientJSON,
- migrations_client.MigrationsClientJSON,
- nova_net_client.NetworksClientJSON,
- quotas_client.QuotasClientJSON,
- quota_classes_client.QuotaClassesClientJSON,
- nova_secgrop_default_client.SecurityGroupDefaultRulesClientJSON,
- security_groups_client.SecurityGroupsClientJSON,
- servers_client.ServersClientJSON,
- services_client.ServicesClientJSON,
- tenant_usages_client.TenantUsagesClientJSON,
- compute_volumes_extensions_client.VolumesExtensionsClientJSON,
+ 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,
data_processing_client.DataProcessingClient,
- db_flavor_client.DatabaseFlavorsClientJSON,
- db_version_client.DatabaseVersionsClientJSON,
- messaging_client.MessagingClientJSON,
- network_client.NetworkClientJSON,
+ db_flavor_client.DatabaseFlavorsClient,
+ db_version_client.DatabaseVersionsClient,
+ messaging_client.MessagingClient,
+ network_client.NetworkClient,
account_client.AccountClient,
container_client.ContainerClient,
object_client.ObjectClient,
orchestration_client.OrchestrationClient,
- telemetry_client.TelemetryClientJSON,
- qos_client.QosSpecsClientJSON,
- volume_hosts_client.VolumeHostsClientJSON,
- volume_quotas_client.VolumeQuotasClientJSON,
- volume_services_client.VolumesServicesClientJSON,
- volume_types_client.VolumeTypesClientJSON,
- volume_az_client.VolumeAvailabilityZoneClientJSON,
- backups_client.BackupsClientJSON,
- volume_extensions_client.ExtensionsClientJSON,
- snapshots_client.SnapshotsClientJSON,
- volumes_client.VolumesClientJSON,
- volume_v2_hosts_client.VolumeHostsV2ClientJSON,
+ telemetry_client.TelemetryClient,
+ qos_client.QosSpecsClient,
+ volume_hosts_client.VolumeHostsClient,
+ volume_quotas_client.VolumeQuotasClient,
+ volume_services_client.VolumesServicesClient,
+ volume_types_client.VolumeTypesClient,
+ volume_az_client.VolumeAvailabilityZoneClient,
+ backups_client.BackupsClient,
+ volume_extensions_client.ExtensionsClient,
+ snapshots_client.SnapshotsClient,
+ volumes_client.VolumesClient,
+ volume_v2_hosts_client.VolumeHostsV2Client,
volume_v2_quotas_client.VolumeQuotasV2Client,
- volume_v2_services_client.VolumesServicesV2ClientJSON,
- volume_v2_types_client.VolumeTypesV2ClientJSON,
- volume_v2_az_client.VolumeV2AvailabilityZoneClientJSON,
- volume_v2_backups_client.BackupsClientV2JSON,
- volume_v2_extensions_client.ExtensionsV2ClientJSON,
- volume_v2_qos_client.QosSpecsV2ClientJSON,
- volume_v2_snapshots_client.SnapshotsV2ClientJSON,
- volume_v2_volumes_client.VolumesV2ClientJSON,
- identity_v2_identity_client.IdentityClientJSON,
- credentials_client.CredentialsClientJSON,
- endpoints_client.EndPointClientJSON,
- identity_v3_identity_client.IdentityV3ClientJSON,
- policy_client.PolicyClientJSON,
- region_client.RegionClientJSON,
- service_client.ServiceClientJSON,
- image_client.ImageClientJSON,
- image_v2_client.ImageClientV2JSON
+ volume_v2_services_client.VolumesServicesV2Client,
+ volume_v2_types_client.VolumeTypesV2Client,
+ volume_v2_az_client.VolumeV2AvailabilityZoneClient,
+ volume_v2_backups_client.BackupsClientV2,
+ volume_v2_extensions_client.ExtensionsV2Client,
+ volume_v2_qos_client.QosSpecsV2Client,
+ volume_v2_snapshots_client.SnapshotsV2Client,
+ volume_v2_volumes_client.VolumesV2Client,
+ identity_v2_identity_client.IdentityClient,
+ credentials_client.CredentialsClient,
+ endpoints_client.EndPointClient,
+ identity_v3_identity_client.IdentityV3Client,
+ policy_client.PolicyClient,
+ region_client.RegionClient,
+ service_client.ServiceClient,
+ image_client.ImageClient,
+ image_v2_client.ImageClientV2
]
for client in test_clients:
diff --git a/tempest/tests/common/utils/linux/test_remote_client.py b/tempest/tests/common/utils/linux/test_remote_client.py
index 3506856..3ff8e0d 100644
--- a/tempest/tests/common/utils/linux/test_remote_client.py
+++ b/tempest/tests/common/utils/linux/test_remote_client.py
@@ -28,9 +28,9 @@
super(TestRemoteClient, self).setUp()
self.useFixture(fake_config.ConfigFixture())
self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
- cfg.CONF.set_default('ip_version_for_ssh', 4, group='compute')
+ cfg.CONF.set_default('ip_version_for_ssh', 4, group='validation')
cfg.CONF.set_default('network_for_ssh', 'public', group='compute')
- cfg.CONF.set_default('ssh_channel_timeout', 1, group='compute')
+ cfg.CONF.set_default('connect_timeout', 1, group='validation')
self.conn = remote_client.RemoteClient('127.0.0.1', 'user', 'pass')
self.ssh_mock = self.useFixture(mockpatch.PatchObject(self.conn,
@@ -79,8 +79,7 @@
def test_get_number_of_vcpus(self):
self.ssh_mock.mock.exec_command.return_value = '16'
self.assertEqual(self.conn.get_number_of_vcpus(), 16)
- self._assert_exec_called_with(
- 'cat /proc/cpuinfo | grep processor | wc -l')
+ self._assert_exec_called_with('grep -c processor /proc/cpuinfo')
def test_get_partitions(self):
proc_partitions = """major minor #blocks name
diff --git a/tempest/tests/fake_identity.py b/tempest/tests/fake_identity.py
index ad78f85..d0de927 100644
--- a/tempest/tests/fake_identity.py
+++ b/tempest/tests/fake_identity.py
@@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
import httplib2
+from oslo_serialization import jsonutils as json
FAKE_AUTH_URL = 'http://fake_uri.com/auth'
diff --git a/tempest/tests/services/__init__.py b/tempest/tests/services/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/tests/services/__init__.py
diff --git a/tempest/tests/services/compute/__init__.py b/tempest/tests/services/compute/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/tests/services/compute/__init__.py
diff --git a/tempest/tests/services/compute/test_agents_client.py b/tempest/tests/services/compute/test_agents_client.py
new file mode 100644
index 0000000..8316c90
--- /dev/null
+++ b/tempest/tests/services/compute/test_agents_client.py
@@ -0,0 +1,104 @@
+# 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 httplib2
+
+from oslo_serialization import jsonutils as json
+from oslotest import mockpatch
+
+from tempest.services.compute.json import agents_client
+from tempest.tests import base
+from tempest.tests import fake_auth_provider
+
+
+class TestAgentsClient(base.TestCase):
+
+ 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):
+ body = '{"agents": []}'
+ if bytes_body:
+ body = body.encode('utf-8')
+ expected = []
+ response = (httplib2.Response({'status': 200}), body)
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.service_client.ServiceClient.get',
+ return_value=response))
+ self.assertEqual(expected, self.client.list_agents())
+
+ def _test_create_agent(self, bytes_body=False):
+ expected = {"url": "http://foo.com", "hypervisor": "kvm",
+ "md5hash": "md5", "version": "2", "architecture": "x86_64",
+ "os": "linux", "agent_id": 1}
+ serialized_body = json.dumps({"agent": expected})
+ if bytes_body:
+ serialized_body = serialized_body.encode('utf-8')
+
+ mocked_resp = (httplib2.Response({'status': 200}), serialized_body)
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.service_client.ServiceClient.post',
+ return_value=mocked_resp))
+ resp = self.client.create_agent(
+ url="http://foo.com", hypervisor="kvm", md5hash="md5",
+ version="2", architecture="x86_64", os="linux"
+ )
+ self.assertEqual(expected, resp)
+
+ def _test_delete_agent(self):
+ mocked_resp = (httplib2.Response({'status': 200}), None)
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.service_client.ServiceClient.delete',
+ return_value=mocked_resp))
+ self.client.delete_agent("1")
+
+ def _test_update_agent(self, bytes_body=False):
+ expected = {"url": "http://foo.com", "md5hash": "md5", "version": "2",
+ "agent_id": 1}
+ serialized_body = json.dumps({"agent": expected})
+ if bytes_body:
+ serialized_body = serialized_body.encode('utf-8')
+
+ mocked_resp = (httplib2.Response({'status': 200}), serialized_body)
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.service_client.ServiceClient.put',
+ return_value=mocked_resp))
+ resp = self.client.update_agent(
+ "1", url="http://foo.com", md5hash="md5", version="2"
+ )
+ self.assertEqual(expected, resp)
+
+ 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
new file mode 100644
index 0000000..9fe4544
--- /dev/null
+++ b/tempest/tests/services/compute/test_aggregates_client.py
@@ -0,0 +1,47 @@
+# 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 httplib2
+
+from oslotest import mockpatch
+
+from tempest.services.compute.json import aggregates_client
+from tempest.tests import base
+from tempest.tests import fake_auth_provider
+
+
+class TestAggregatesClient(base.TestCase):
+
+ 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):
+ body = '{"aggregates": []}'
+ if bytes_body:
+ body = body.encode('utf-8')
+ expected = []
+ response = (httplib2.Response({'status': 200}), body)
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.service_client.ServiceClient.get',
+ return_value=response))
+ self.assertEqual(expected, self.client.list_aggregates())
+
+ 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)
diff --git a/tempest/tests/services/compute/test_keypairs_client.py b/tempest/tests/services/compute/test_keypairs_client.py
new file mode 100644
index 0000000..e79e411
--- /dev/null
+++ b/tempest/tests/services/compute/test_keypairs_client.py
@@ -0,0 +1,47 @@
+# 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 httplib2
+
+from oslotest import mockpatch
+
+from tempest.services.compute.json import keypairs_client
+from tempest.tests import base
+from tempest.tests import fake_auth_provider
+
+
+class TestKeyPairsClient(base.TestCase):
+
+ def setUp(self):
+ super(TestKeyPairsClient, self).setUp()
+ fake_auth = fake_auth_provider.FakeAuthProvider()
+ self.client = keypairs_client.KeyPairsClient(
+ fake_auth, 'compute', 'regionOne')
+
+ def _test_list_keypairs(self, bytes_body=False):
+ body = '{"keypairs": []}'
+ if bytes_body:
+ body = body.encode('utf-8')
+ expected = []
+ response = (httplib2.Response({'status': 200}), body)
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.service_client.ServiceClient.get',
+ return_value=response))
+ self.assertEqual(expected, self.client.list_keypairs())
+
+ def test_list_keypairs_with_str_body(self):
+ self._test_list_keypairs()
+
+ def test_list_keypairs_with_bytes_body(self):
+ self._test_list_keypairs(bytes_body=True)
diff --git a/tempest/tests/test_decorators.py b/tempest/tests/test_decorators.py
index e5f51f2..ce3eb7e 100644
--- a/tempest/tests/test_decorators.py
+++ b/tempest/tests/test_decorators.py
@@ -213,8 +213,8 @@
service='compute')
def test_requires_ext_decorator_with_all_ext_enabled(self):
- # disable fixture so the default (all) is used.
- self.config_fixture.cleanUp()
+ cfg.CONF.set_default('api_extensions', 'all',
+ group='compute-feature-enabled')
self._test_requires_ext_helper(expected_to_skip=False,
extension='random_ext',
service='compute')
diff --git a/tempest/tests/test_glance_http.py b/tempest/tests/test_glance_http.py
index 7850ee4..105caec 100644
--- a/tempest/tests/test_glance_http.py
+++ b/tempest/tests/test_glance_http.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
import socket
import mock
+from oslo_serialization import jsonutils as json
from oslotest import mockpatch
import six
from six.moves import http_client as httplib
@@ -137,7 +137,8 @@
resp, body = self.client.raw_request('PUT', '/images', body=req_body)
self.assertEqual(200, resp.status)
self.assertEqual('fake_response_body', body.read())
- httplib.HTTPConnection.send.assert_call_count(req_body.tell())
+ call_count = httplib.HTTPConnection.send.call_count
+ self.assertEqual(call_count - 1, req_body.tell())
def test_get_connection_class_for_https(self):
conn_class = self.client.get_connection_class('https')
diff --git a/tempest/tests/test_tenant_isolation.py b/tempest/tests/test_tenant_isolation.py
index 72a63c3..fa1b6f7 100644
--- a/tempest/tests/test_tenant_isolation.py
+++ b/tempest/tests/test_tenant_isolation.py
@@ -46,13 +46,13 @@
def test_tempest_client(self):
iso_creds = isolated_creds.IsolatedCreds(name='test class')
self.assertTrue(isinstance(iso_creds.identity_admin_client,
- json_iden_client.IdentityClientJSON))
+ json_iden_client.IdentityClient))
self.assertTrue(isinstance(iso_creds.network_admin_client,
- json_network_client.NetworkClientJSON))
+ json_network_client.NetworkClient))
def _mock_user_create(self, id, name):
user_fix = self.useFixture(mockpatch.PatchObject(
- json_iden_client.IdentityClientJSON,
+ json_iden_client.IdentityClient,
'create_user',
return_value=(service_client.ResponseBody
(200, {'id': id, 'name': name}))))
@@ -60,7 +60,7 @@
def _mock_tenant_create(self, id, name):
tenant_fix = self.useFixture(mockpatch.PatchObject(
- json_iden_client.IdentityClientJSON,
+ json_iden_client.IdentityClient,
'create_tenant',
return_value=(service_client.ResponseBody
(200, {'id': id, 'name': name}))))
@@ -68,7 +68,7 @@
def _mock_list_roles(self, id, name):
roles_fix = self.useFixture(mockpatch.PatchObject(
- json_iden_client.IdentityClientJSON,
+ json_iden_client.IdentityClient,
'list_roles',
return_value=(service_client.ResponseBodyList
(200,
@@ -78,7 +78,7 @@
def _mock_list_2_roles(self):
roles_fix = self.useFixture(mockpatch.PatchObject(
- json_iden_client.IdentityClientJSON,
+ json_iden_client.IdentityClient,
'list_roles',
return_value=(service_client.ResponseBodyList
(200,
@@ -89,7 +89,7 @@
def _mock_assign_user_role(self):
tenant_fix = self.useFixture(mockpatch.PatchObject(
- json_iden_client.IdentityClientJSON,
+ json_iden_client.IdentityClient,
'assign_user_role',
return_value=(service_client.ResponseBody
(200, {}))))
@@ -97,7 +97,7 @@
def _mock_list_role(self):
roles_fix = self.useFixture(mockpatch.PatchObject(
- json_iden_client.IdentityClientJSON,
+ json_iden_client.IdentityClient,
'list_roles',
return_value=(service_client.ResponseBodyList
(200, [{'id': '1', 'name': 'FakeRole'}]))))
@@ -105,7 +105,7 @@
def _mock_list_ec2_credentials(self, user_id, tenant_id):
ec2_creds_fix = self.useFixture(mockpatch.PatchObject(
- json_iden_client.IdentityClientJSON,
+ json_iden_client.IdentityClient,
'list_user_ec2_credentials',
return_value=(service_client.ResponseBodyList
(200, [{'access': 'fake_access',
@@ -131,7 +131,7 @@
def _mock_router_create(self, id, name):
router_fix = self.useFixture(mockpatch.PatchObject(
- json_network_client.NetworkClientJSON,
+ json_network_client.NetworkClient,
'create_router',
return_value={'router': {'id': id, 'name': name}}))
return router_fix
@@ -139,8 +139,7 @@
@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',
- password='fake_password')
+ iso_creds = isolated_creds.IsolatedCreds(name='test class')
self._mock_assign_user_role()
self._mock_list_role()
self._mock_tenant_create('1234', 'fake_prim_tenant')
@@ -155,17 +154,16 @@
@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',
- password='fake_password')
+ iso_creds = isolated_creds.IsolatedCreds(name='test class')
self._mock_list_roles('1234', 'admin')
self._mock_user_create('1234', 'fake_admin_user')
self._mock_tenant_create('1234', 'fake_admin_tenant')
- user_mock = mock.patch.object(json_iden_client.IdentityClientJSON,
+ user_mock = mock.patch.object(json_iden_client.IdentityClient,
'assign_user_role')
user_mock.start()
self.addCleanup(user_mock.stop)
- with mock.patch.object(json_iden_client.IdentityClientJSON,
+ with mock.patch.object(json_iden_client.IdentityClient,
'assign_user_role') as user_mock:
admin_creds = iso_creds.get_admin_creds()
user_mock.assert_has_calls([
@@ -179,17 +177,16 @@
@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',
- password='fake_password')
+ iso_creds = isolated_creds.IsolatedCreds('v2', 'test class')
self._mock_list_2_roles()
self._mock_user_create('1234', 'fake_role_user')
self._mock_tenant_create('1234', 'fake_role_tenant')
- user_mock = mock.patch.object(json_iden_client.IdentityClientJSON,
+ user_mock = mock.patch.object(json_iden_client.IdentityClient,
'assign_user_role')
user_mock.start()
self.addCleanup(user_mock.stop)
- with mock.patch.object(json_iden_client.IdentityClientJSON,
+ 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'])
calls = user_mock.mock_calls
@@ -208,31 +205,25 @@
@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',
- password='fake_password')
+ iso_creds = isolated_creds.IsolatedCreds(name='test class')
self._mock_assign_user_role()
- roles_fix = self._mock_list_role()
- tenant_fix = self._mock_tenant_create('1234', 'fake_prim_tenant')
- user_fix = self._mock_user_create('1234', 'fake_prim_user')
+ 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()
- tenant_fix.cleanUp()
- user_fix.cleanUp()
- tenant_fix = self._mock_tenant_create('12345', 'fake_alt_tenant')
- user_fix = self._mock_user_create('12345', 'fake_alt_user')
+ self._mock_tenant_create('12345', 'fake_alt_tenant')
+ self._mock_user_create('12345', 'fake_alt_user')
iso_creds.get_alt_creds()
- tenant_fix.cleanUp()
- user_fix.cleanUp()
- roles_fix.cleanUp()
- tenant_fix = self._mock_tenant_create('123456', 'fake_admin_tenant')
- user_fix = self._mock_user_create('123456', 'fake_admin_user')
+ 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()
user_mock = self.patch(
'tempest.services.identity.v2.json.identity_client.'
- 'IdentityClientJSON.delete_user')
+ 'IdentityClient.delete_user')
tenant_mock = self.patch(
'tempest.services.identity.v2.json.identity_client.'
- 'IdentityClientJSON.delete_tenant')
+ 'IdentityClient.delete_tenant')
iso_creds.clear_isolated_creds()
# Verify user delete calls
calls = user_mock.mock_calls
@@ -254,8 +245,7 @@
@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',
- password='fake_password')
+ iso_creds = isolated_creds.IsolatedCreds(name='test class')
self._mock_assign_user_role()
self._mock_list_role()
self._mock_user_create('1234', 'fake_alt_user')
@@ -270,8 +260,7 @@
@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',
- password='fake_password')
+ iso_creds = isolated_creds.IsolatedCreds(name='test class')
self._mock_assign_user_role()
self._mock_list_role()
self._mock_user_create('1234', 'fake_prim_user')
@@ -299,8 +288,7 @@
@mock.patch('tempest_lib.common.rest_client.RestClient')
def test_network_creation(self, MockRestClient):
- iso_creds = isolated_creds.IsolatedCreds(name='test class',
- password='fake_password')
+ iso_creds = isolated_creds.IsolatedCreds(name='test class')
self._mock_assign_user_role()
self._mock_list_role()
self._mock_user_create('1234', 'fake_prim_user')
@@ -309,7 +297,7 @@
self._mock_subnet_create(iso_creds, '1234', 'fake_subnet')
self._mock_router_create('1234', 'fake_router')
router_interface_mock = self.patch(
- 'tempest.services.network.json.network_client.NetworkClientJSON.'
+ 'tempest.services.network.json.network_client.NetworkClient.'
'add_router_interface_with_subnet_id')
primary_creds = iso_creds.get_primary_creds()
router_interface_mock.called_once_with('1234', '1234')
@@ -331,57 +319,45 @@
"description": args['name'],
"security_group_rules": [],
"id": "sg-%s" % args['tenant_id']}]}
- iso_creds = isolated_creds.IsolatedCreds(name='test class',
- password='fake_password')
+ iso_creds = isolated_creds.IsolatedCreds(name='test class')
# Create primary tenant and network
self._mock_assign_user_role()
- roles_fix = self._mock_list_role()
- user_fix = self._mock_user_create('1234', 'fake_prim_user')
- tenant_fix = self._mock_tenant_create('1234', 'fake_prim_tenant')
- net_fix = self._mock_network_create(iso_creds, '1234', 'fake_net')
- subnet_fix = self._mock_subnet_create(iso_creds, '1234', 'fake_subnet')
- router_fix = self._mock_router_create('1234', 'fake_router')
+ 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_router_create('1234', 'fake_router')
router_interface_mock = self.patch(
- 'tempest.services.network.json.network_client.NetworkClientJSON.'
+ 'tempest.services.network.json.network_client.NetworkClient.'
'add_router_interface_with_subnet_id')
iso_creds.get_primary_creds()
router_interface_mock.called_once_with('1234', '1234')
router_interface_mock.reset_mock()
- tenant_fix.cleanUp()
- user_fix.cleanUp()
- net_fix.cleanUp()
- subnet_fix.cleanUp()
- router_fix.cleanUp()
# Create alternate tenant and network
- user_fix = self._mock_user_create('12345', 'fake_alt_user')
- tenant_fix = self._mock_tenant_create('12345', 'fake_alt_tenant')
- net_fix = self._mock_network_create(iso_creds, '12345', 'fake_alt_net')
- subnet_fix = self._mock_subnet_create(iso_creds, '12345',
- 'fake_alt_subnet')
- router_fix = self._mock_router_create('12345', 'fake_alt_router')
+ 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_router_create('12345', 'fake_alt_router')
iso_creds.get_alt_creds()
router_interface_mock.called_once_with('12345', '12345')
router_interface_mock.reset_mock()
- tenant_fix.cleanUp()
- user_fix.cleanUp()
- net_fix.cleanUp()
- subnet_fix.cleanUp()
- router_fix.cleanUp()
- roles_fix.cleanUp()
# Create admin tenant and networks
- user_fix = self._mock_user_create('123456', 'fake_admin_user')
- tenant_fix = self._mock_tenant_create('123456', 'fake_admin_tenant')
- net_fix = self._mock_network_create(iso_creds, '123456',
- 'fake_admin_net')
- subnet_fix = self._mock_subnet_create(iso_creds, '123456',
- 'fake_admin_subnet')
- router_fix = self._mock_router_create('123456', 'fake_admin_router')
+ 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_router_create('123456', 'fake_admin_router')
self._mock_list_roles('123456', 'admin')
iso_creds.get_admin_creds()
self.patch('tempest.services.identity.v2.json.identity_client.'
- 'IdentityClientJSON.delete_user')
+ 'IdentityClient.delete_user')
self.patch('tempest.services.identity.v2.json.identity_client.'
- 'IdentityClientJSON.delete_tenant')
+ 'IdentityClient.delete_tenant')
net = mock.patch.object(iso_creds.network_admin_client,
'delete_network')
net_mock = net.start()
@@ -392,7 +368,7 @@
'delete_router')
router_mock = router.start()
remove_router_interface_mock = self.patch(
- 'tempest.services.network.json.network_client.NetworkClientJSON.'
+ '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,
@@ -408,7 +384,7 @@
return_values = (fake_http.fake_httplib({}, status=204), {})
remove_secgroup_mock = self.patch(
'tempest.services.network.json.network_client.'
- 'NetworkClientJSON.delete', return_value=return_values)
+ 'NetworkClient.delete', return_value=return_values)
iso_creds.clear_isolated_creds()
# Verify default security group delete
calls = remove_secgroup_mock.mock_calls
@@ -453,8 +429,7 @@
@mock.patch('tempest_lib.common.rest_client.RestClient')
def test_network_alt_creation(self, MockRestClient):
- iso_creds = isolated_creds.IsolatedCreds(name='test class',
- password='fake_password')
+ iso_creds = isolated_creds.IsolatedCreds(name='test class')
self._mock_assign_user_role()
self._mock_list_role()
self._mock_user_create('1234', 'fake_alt_user')
@@ -463,7 +438,7 @@
self._mock_subnet_create(iso_creds, '1234', 'fake_alt_subnet')
self._mock_router_create('1234', 'fake_alt_router')
router_interface_mock = self.patch(
- 'tempest.services.network.json.network_client.NetworkClientJSON.'
+ 'tempest.services.network.json.network_client.NetworkClient.'
'add_router_interface_with_subnet_id')
alt_creds = iso_creds.get_alt_creds()
router_interface_mock.called_once_with('1234', '1234')
@@ -479,8 +454,7 @@
@mock.patch('tempest_lib.common.rest_client.RestClient')
def test_network_admin_creation(self, MockRestClient):
- iso_creds = isolated_creds.IsolatedCreds(name='test class',
- password='fake_password')
+ iso_creds = isolated_creds.IsolatedCreds(name='test class')
self._mock_assign_user_role()
self._mock_user_create('1234', 'fake_admin_user')
self._mock_tenant_create('1234', 'fake_admin_tenant')
@@ -488,7 +462,7 @@
self._mock_subnet_create(iso_creds, '1234', 'fake_admin_subnet')
self._mock_router_create('1234', 'fake_admin_router')
router_interface_mock = self.patch(
- 'tempest.services.network.json.network_client.NetworkClientJSON.'
+ '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()
@@ -512,7 +486,6 @@
'dhcp': False,
}
iso_creds = isolated_creds.IsolatedCreds(name='test class',
- password='fake_password',
network_resources=net_dict)
self._mock_assign_user_role()
self._mock_list_role()
@@ -548,7 +521,6 @@
'dhcp': False,
}
iso_creds = isolated_creds.IsolatedCreds(name='test class',
- password='fake_password',
network_resources=net_dict)
self._mock_assign_user_role()
self._mock_list_role()
@@ -566,7 +538,6 @@
'dhcp': False,
}
iso_creds = isolated_creds.IsolatedCreds(name='test class',
- password='fake_password',
network_resources=net_dict)
self._mock_assign_user_role()
self._mock_list_role()
@@ -584,7 +555,6 @@
'dhcp': True,
}
iso_creds = isolated_creds.IsolatedCreds(name='test class',
- password='fake_password',
network_resources=net_dict)
self._mock_assign_user_role()
self._mock_list_role()
diff --git a/tempest/thirdparty/boto/test_ec2_instance_run.py b/tempest/thirdparty/boto/test_ec2_instance_run.py
index b7f0e81..920f602 100644
--- a/tempest/thirdparty/boto/test_ec2_instance_run.py
+++ b/tempest/thirdparty/boto/test_ec2_instance_run.py
@@ -14,8 +14,8 @@
# under the License.
from oslo_log import log as logging
-from tempest_lib.common.utils import data_utils
+from tempest.common.utils import data_utils
from tempest.common.utils.linux import remote_client
from tempest import config
from tempest import exceptions
diff --git a/tempest/thirdparty/boto/test_ec2_keys.py b/tempest/thirdparty/boto/test_ec2_keys.py
index 58a5776..1b58cb4 100644
--- a/tempest/thirdparty/boto/test_ec2_keys.py
+++ b/tempest/thirdparty/boto/test_ec2_keys.py
@@ -13,8 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
+from tempest.common.utils import data_utils
from tempest import test
from tempest.thirdparty.boto import test as boto_test
diff --git a/tempest/thirdparty/boto/test_ec2_security_groups.py b/tempest/thirdparty/boto/test_ec2_security_groups.py
index 94fab09..88ff154 100644
--- a/tempest/thirdparty/boto/test_ec2_security_groups.py
+++ b/tempest/thirdparty/boto/test_ec2_security_groups.py
@@ -13,8 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
+from tempest.common.utils import data_utils
from tempest import test
from tempest.thirdparty.boto import test as boto_test
diff --git a/tempest/thirdparty/boto/test_s3_buckets.py b/tempest/thirdparty/boto/test_s3_buckets.py
index 45401fd..f008973 100644
--- a/tempest/thirdparty/boto/test_s3_buckets.py
+++ b/tempest/thirdparty/boto/test_s3_buckets.py
@@ -13,8 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib.common.utils import data_utils
-
+from tempest.common.utils import data_utils
from tempest import test
from tempest.thirdparty.boto import test as boto_test
diff --git a/tempest/thirdparty/boto/test_s3_ec2_images.py b/tempest/thirdparty/boto/test_s3_ec2_images.py
index 1521249..c41c7ac 100644
--- a/tempest/thirdparty/boto/test_s3_ec2_images.py
+++ b/tempest/thirdparty/boto/test_s3_ec2_images.py
@@ -15,8 +15,7 @@
import os
-from tempest_lib.common.utils import data_utils
-
+from tempest.common.utils import data_utils
from tempest import config
from tempest import test
from tempest.thirdparty.boto import test as boto_test
diff --git a/tempest/thirdparty/boto/test_s3_objects.py b/tempest/thirdparty/boto/test_s3_objects.py
index dba231c..c42d85c 100644
--- a/tempest/thirdparty/boto/test_s3_objects.py
+++ b/tempest/thirdparty/boto/test_s3_objects.py
@@ -16,8 +16,8 @@
import contextlib
import boto.s3.key
-from tempest_lib.common.utils import data_utils
+from tempest.common.utils import data_utils
from tempest import test
from tempest.thirdparty.boto import test as boto_test
diff --git a/test-requirements.txt b/test-requirements.txt
index 9bd3f46..2ea30ec 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -7,7 +7,6 @@
python-subunit>=0.0.18
oslosphinx>=2.5.0 # Apache-2.0
mox>=0.5.3
-mock>=1.0
+mock>=1.2
coverage>=3.6
-oslotest>=1.5.1 # Apache-2.0
-stevedore>=1.5.0 # Apache-2.0
+oslotest>=1.9.0 # Apache-2.0
diff --git a/tools/install_venv.py b/tools/install_venv.py
index 96b8279..d6d9c8e 100644
--- a/tools/install_venv.py
+++ b/tools/install_venv.py
@@ -48,11 +48,11 @@
def main(argv):
root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
- if os.environ.get('tools_path'):
- root = os.environ['tools_path']
+ if os.environ.get('TOOLS_PATH'):
+ root = os.environ['TOOLS_PATH']
venv = os.path.join(root, '.venv')
- if os.environ.get('venv'):
- venv = os.environ['venv']
+ if os.environ.get('VENV'):
+ venv = os.environ['VENV']
pip_requires = os.path.join(root, 'requirements.txt')
test_requires = os.path.join(root, 'test-requirements.txt')
diff --git a/tools/install_venv_common.py b/tools/install_venv_common.py
index 743b59d..e279159 100644
--- a/tools/install_venv_common.py
+++ b/tools/install_venv_common.py
@@ -101,6 +101,7 @@
print('done.')
else:
print("venv already exists...")
+ pass
def pip_install(self, *args):
self.run_command(['tools/with_venv.sh',
@@ -124,7 +125,7 @@
parser.add_option('-n', '--no-site-packages',
action='store_true',
help="Do not inherit packages from global Python "
- "install")
+ "install.")
return parser.parse_args(argv[1:])[0]
diff --git a/tools/with_venv.sh b/tools/with_venv.sh
index 550c477..165c883 100755
--- a/tools/with_venv.sh
+++ b/tools/with_venv.sh
@@ -1,4 +1,6 @@
#!/bin/bash
-TOOLS=`dirname $0`
-VENV=$TOOLS/../.venv
-source $VENV/bin/activate && "$@"
+TOOLS_PATH=${TOOLS_PATH:-$(dirname $0)/../}
+VENV_PATH=${VENV_PATH:-${TOOLS_PATH}}
+VENV_DIR=${VENV_DIR:-/.venv}
+VENV=${VENV:-${VENV_PATH}/${VENV_DIR}}
+source ${VENV}/bin/activate && "$@"
diff --git a/tox.ini b/tox.ini
index b495fd6..389fee2 100644
--- a/tox.ini
+++ b/tox.ini
@@ -13,13 +13,7 @@
[testenv]
setenv = VIRTUAL_ENV={envdir}
OS_TEST_PATH=./tempest/tests
-passenv = OS_STDOUT_CAPTURE
- OS_STDERR_CAPTURE
- OS_TEST_TIMEOUT
- OS_TEST_LOCK_PATH
- OS_TEST_PATH
- TEMPEST_CONFIG
- TEMPEST_CONFIG_DIR
+passenv = OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_TEST_TIMEOUT OS_TEST_LOCK_PATH OS_TEST_PATH TEMPEST_CONFIG TEMPEST_CONFIG_DIR http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
usedevelop = True
install_command = pip install -U {opts} {packages}
whitelist_externals = *
@@ -46,6 +40,16 @@
find . -type f -name "*.pyc" -delete
bash tools/pretty_tox.sh '{posargs}'
+[testenv:all-plugin]
+sitepackages = True
+# 'all' includes slow tests
+setenv = {[tempestenv]setenv}
+ OS_TEST_TIMEOUT=1200
+deps = {[tempestenv]deps}
+commands =
+ find . -type f -name "*.pyc" -delete
+ bash tools/pretty_tox.sh '{posargs}'
+
[testenv:full]
sitepackages = {[tempestenv]sitepackages}
setenv = {[tempestenv]setenv}