Merge "test_server_basic_ops: Test metadata service"
diff --git a/HACKING.rst b/HACKING.rst
index 04b5eb6..45c35df 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -14,6 +14,7 @@
- [T105] Tests cannot use setUpClass/tearDownClass
- [T106] vim configuration should not be kept in source files.
- [T107] Check that a service tag isn't in the module path
+- [T108] Check no hyphen at the end of rand_name() argument
- [N322] Method's default argument shouldn't be mutable
Test Data/Configuration
@@ -313,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/account_generator.rst b/doc/source/account_generator.rst
new file mode 100644
index 0000000..1c30473
--- /dev/null
+++ b/doc/source/account_generator.rst
@@ -0,0 +1,5 @@
+--------------------------------
+Tempest Test-Account Generator Utility
+--------------------------------
+
+.. automodule:: tempest.cmd.account_generator
\ No newline at end of file
diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst
index eab7487..3e6013d 100644
--- a/doc/source/configuration.rst
+++ b/doc/source/configuration.rst
@@ -112,7 +112,7 @@
available in the file. (if running serially the worker count is 1)
You can check the sample file packaged in tempest for the yaml format
- #. Provide tempest with the location of you accounts.yaml file with the
+ #. Provide tempest with the location of your accounts.yaml file with the
test_accounts_file option in the auth section
#. Set allow_tenant_isolation = False in the auth group
@@ -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/doc/source/index.rst b/doc/source/index.rst
index cb1c504..f925018 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -45,6 +45,7 @@
.. toctree::
:maxdepth: 1
+ account_generator
cleanup
javelin
diff --git a/etc/accounts.yaml.sample b/etc/accounts.yaml.sample
index 3f57eb7..decc659 100644
--- a/etc/accounts.yaml.sample
+++ b/etc/accounts.yaml.sample
@@ -41,3 +41,4 @@
- 'admin'
resources:
network: 'public'
+ router: 'admin_tenant_1-router'
diff --git a/etc/javelin-resources.yaml.sample b/etc/javelin-resources.yaml.sample
new file mode 100644
index 0000000..fb270a4
--- /dev/null
+++ b/etc/javelin-resources.yaml.sample
@@ -0,0 +1,65 @@
+tenants:
+ - javelin
+ - discuss
+
+users:
+ - name: javelin
+ pass: gungnir
+ tenant: javelin
+ - name: javelin2
+ pass: gungnir2
+ tenant: discuss
+
+secgroups:
+ - name: secgroup1
+ owner: javelin
+ description: SecurityGroup1
+ rules:
+ - 'icmp -1 -1 0.0.0.0/0'
+ - 'tcp 22 22 0.0.0.0/0'
+ - name: secgroup2
+ owner: javelin2
+ description: SecurityGroup2
+ rules:
+ - 'tcp 80 80 0.0.0.0/0'
+
+images:
+ - name: cirros1
+ owner: javelin
+ imgdir: images
+ file: cirros.img
+ container_format: bare
+ disk_format: qcow2
+ - name: cirros2
+ owner: javelin2
+ imgdir: files/images/cirros-0.3.2-x86_64-uec
+ file: cirros-0.3.2-x86_64-blank.img
+ container_format: ami
+ disk_format: ami
+ aki: cirros-0.3.2-x86_64-vmlinuz
+ ari: cirros-0.3.2-x86_64-initrd
+
+networks:
+ - name: network1
+ owner: javelin
+ - name: network2
+ owner: javelin2
+
+subnets:
+ - name: net1-subnet1
+ range: 10.1.0.0/24
+ network: network1
+ owner: javelin
+ - name: net2-subnet2
+ range: 192.168.1.0/24
+ network: network2
+ owner: javelin2
+
+objects:
+ - container: container1
+ name: object1
+ owner: javelin
+ file: /etc/hosts
+ swift_role: Member
+
+telemetry: true
\ No newline at end of file
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index a1f3dcf..7d4ba86 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -39,8 +39,8 @@
# Deprecated group/name - [DEFAULT]/logdir
#log_dir = <None>
-# Use syslog for logging. Existing syslog format is DEPRECATED during
-# I, and changed in J to honor RFC5424. (boolean value)
+# Use syslog for logging. Existing syslog format is DEPRECATED and
+# will be changed later to honor RFC5424. (boolean value)
#use_syslog = false
# (Optional) Enables or disables syslog rfc5424 format for logging. If
@@ -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
@@ -254,6 +260,10 @@
# value)
#build_timeout = 300
+# Shell fragments to use before executing a command when sshing to a
+# guest. (string value)
+#ssh_shell_prologue = set -eu -o pipefail; PATH=$$PATH:/sbin;
+
# Auth method used for authenticate to the instance. Valid choices
# are: keypair, configured, adminpass and disabled. Keypair: start the
# servers with a ssh keypair. Configured: use the configured user and
@@ -280,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
@@ -303,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 +430,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]
@@ -652,6 +662,10 @@
# Is the v1 image API enabled (boolean value)
#api_v1 = true
+# Is the deactivate-image feature enabled. The feature has been
+# integrated since Kilo. (boolean value)
+#deactivate_image = false
+
[input-scenario]
@@ -797,7 +811,8 @@
# A list of enabled network extensions with a special entry all which
# indicates every extension is enabled. Empty list indicates all
-# extensions are disabled (list value)
+# extensions are disabled. To get the list of extensions run: 'neutron
+# ext-list' (list value)
#api_extensions = all
# Allow the execution of IPv6 subnet tests that use the extended IPv6
@@ -1087,6 +1102,16 @@
#too_slow_to_test = true
+[telemetry-feature-enabled]
+
+#
+# From tempest.config
+#
+
+# Runs Ceilometer event-related tests (boolean value)
+#events = false
+
+
[validation]
#
@@ -1111,6 +1136,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)
@@ -1118,9 +1144,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 7fe8858..415eaa5 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,25 +1,27 @@
# 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>=0.11,<2.0
+pbr<2.0,>=1.3
+cliff>=1.13.0 # Apache-2.0
anyjson>=0.3.3
httplib2>=0.7.5
-jsonschema>=2.0.0,<3.0.0
-testtools>=0.9.36,!=1.2.0
+jsonschema!=2.5.0,<3.0.0,>=2.0.0
+testtools>=1.4.0
boto>=2.32.1
paramiko>=1.13.0
netaddr>=0.7.12
testrepository>=0.0.18
-pyOpenSSL>=0.11
-oslo.concurrency>=1.8.0 # Apache-2.0
-oslo.config>=1.11.0 # Apache-2.0
-oslo.i18n>=1.5.0 # Apache-2.0
-oslo.log>=1.0.0 # Apache-2.0
-oslo.serialization>=1.4.0 # Apache-2.0
-oslo.utils>=1.4.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.6.0 # Apache-2.0
+oslo.serialization>=1.4.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
old mode 100755
new mode 100644
index 7363757..d8080d0
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,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 eec4688..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':
@@ -50,17 +50,15 @@
@test.idempotent_id('16b7d848-2f7c-4709-85a3-2dfb4576cc52')
@test.services('network')
def test_list_fixed_ip_details(self):
- fixed_ip = self.client.get_fixed_ip_details(self.ip)
+ fixed_ip = self.client.show_fixed_ip(self.ip)
self.assertEqual(fixed_ip['address'], self.ip)
@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 ac8a60d..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':
@@ -54,25 +54,23 @@
@test.services('network')
def test_list_fixed_ip_details_with_non_admin_user(self):
self.assertRaises(lib_exc.Forbidden,
- self.non_admin_client.get_fixed_ip_details, self.ip)
+ self.non_admin_client.show_fixed_ip, self.ip)
@test.attr(type=['negative'])
@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 8aab8da..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
@@ -82,7 +82,7 @@
self.assertEqual(flavor['os-flavor-access:is_public'], True)
# Verify flavor is retrieved
- flavor = self.client.get_flavor_details(flavor['id'])
+ flavor = self.client.show_flavor(flavor['id'])
self.assertEqual(flavor['name'], flavor_name)
return flavor['id']
@@ -125,7 +125,7 @@
self.addCleanup(self.flavor_clean_up, flavor['id'])
flag = False
# Verify flavor is retrieved
- flavors = self.client.list_flavors_with_detail()
+ flavors = self.client.list_flavors(detail=True)
for flavor in flavors:
if flavor['name'] == flavor_name:
flag = True
@@ -160,12 +160,12 @@
verify_flavor_response_extension(flavor)
# Verify flavor is retrieved
- flavor = self.client.get_flavor_details(new_flavor_id)
+ flavor = self.client.show_flavor(new_flavor_id)
self.assertEqual(flavor['name'], flavor_name)
verify_flavor_response_extension(flavor)
# Check if flavor is present in list
- flavors = self.user_client.list_flavors_with_detail()
+ flavors = self.user_client.list_flavors(detail=True)
for flavor in flavors:
if flavor['name'] == flavor_name:
verify_flavor_response_extension(flavor)
@@ -190,7 +190,7 @@
self.addCleanup(self.flavor_clean_up, flavor['id'])
# Verify flavor is retrieved
flag = False
- flavors = self.client.list_flavors_with_detail()
+ flavors = self.client.list_flavors(detail=True)
for flavor in flavors:
if flavor['name'] == flavor_name:
flag = True
@@ -198,7 +198,7 @@
# Verify flavor is not retrieved with other user
flag = False
- flavors = self.user_client.list_flavors_with_detail()
+ flavors = self.user_client.list_flavors(detail=True)
for flavor in flavors:
if flavor['name'] == flavor_name:
flag = True
@@ -240,7 +240,7 @@
flag = False
self.new_client = self.flavors_client
# Verify flavor is retrieved with new user
- flavors = self.new_client.list_flavors_with_detail()
+ flavors = self.new_client.list_flavors(detail=True)
for flavor in flavors:
if flavor['name'] == flavor_name:
flag = True
@@ -278,7 +278,7 @@
def _test_string_variations(variations, flavor_name):
for string in variations:
params = {'is_public': string}
- flavors = self.client.list_flavors_with_detail(params)
+ flavors = self.client.list_flavors(detail=True, **params)
flavor = _flavor_lookup(flavors, flavor_name)
self.assertIsNotNone(flavor)
diff --git a/tempest/api/compute/admin/test_flavors_access.py b/tempest/api/compute/admin/test_flavors_access.py
index 61d3dc6..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
@@ -87,7 +86,7 @@
self.assertIn(resp_body, add_body)
# The flavor is present in list.
- flavors = self.flavors_client.list_flavors_with_detail()
+ flavors = self.flavors_client.list_flavors(detail=True)
self.assertIn(new_flavor['id'], map(lambda x: x['id'], flavors))
# Remove flavor access from a tenant.
@@ -96,5 +95,5 @@
self.assertNotIn(resp_body, remove_body)
# The flavor is not present in list.
- flavors = self.flavors_client.list_flavors_with_detail()
+ flavors = self.flavors_client.list_flavors(detail=True)
self.assertNotIn(new_flavor['id'], map(lambda x: x['id'], flavors))
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 2ed1e35..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
@@ -75,7 +74,7 @@
self.client.set_flavor_extra_spec(self.flavor['id'], specs)
self.assertEqual(set_body, specs)
# GET extra specs and verify
- get_body = self.client.get_flavor_extra_spec(self.flavor['id'])
+ get_body = self.client.list_flavor_extra_specs(self.flavor['id'])
self.assertEqual(get_body, specs)
# UPDATE the value of the extra specs key1
@@ -87,7 +86,7 @@
# GET extra specs and verify the value of the key2
# is the same as before
- get_body = self.client.get_flavor_extra_spec(self.flavor['id'])
+ get_body = self.client.list_flavor_extra_specs(self.flavor['id'])
self.assertEqual(get_body, {"key1": "value", "key2": "value2"})
# UNSET extra specs that were set in this test
@@ -98,7 +97,7 @@
def test_flavor_non_admin_get_all_keys(self):
specs = {"key1": "value1", "key2": "value2"}
self.client.set_flavor_extra_spec(self.flavor['id'], specs)
- body = self.flavors_client.get_flavor_extra_spec(self.flavor['id'])
+ body = self.flavors_client.list_flavor_extra_specs(self.flavor['id'])
for key in specs:
self.assertEqual(body[key], specs[key])
@@ -109,7 +108,7 @@
body = self.client.set_flavor_extra_spec(self.flavor['id'], specs)
self.assertEqual(body['key1'], 'value1')
self.assertIn('key2', body)
- body = self.flavors_client.get_flavor_extra_spec_with_key(
+ body = self.flavors_client.show_flavor_extra_spec(
self.flavor['id'], 'key1')
self.assertEqual(body['key1'], 'value1')
self.assertNotIn('key2', body)
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 df592dd..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
@@ -115,7 +115,7 @@
@test.idempotent_id('329a7be3-54b2-48be-8052-bf2ce4afd898')
def test_flavor_get_nonexistent_key(self):
self.assertRaises(lib_exc.NotFound,
- self.flavors_client.get_flavor_extra_spec_with_key,
+ self.flavors_client.show_flavor_extra_spec,
self.flavor['id'],
"nonexistent_key")
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 a91c9bf..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')
@@ -69,7 +65,7 @@
for host in hosts:
hostname = host['host_name']
- resources = self.client.show_host_detail(hostname)
+ resources = self.client.show_host(hostname)
self.assertTrue(len(resources) >= 1)
host_resource = resources[0]['resource']
self.assertIsNotNone(host_resource)
diff --git a/tempest/api/compute/admin/test_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py
index 042d1fb..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
@@ -48,7 +48,7 @@
def test_show_host_detail_with_nonexistent_hostname(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
self.assertRaises(lib_exc.NotFound,
- self.client.show_host_detail, nonexitent_hostname)
+ self.client.show_host, nonexitent_hostname)
@test.attr(type=['negative'])
@test.idempotent_id('19ebe09c-bfd4-4b7c-81a2-e2e0710f59cc')
@@ -56,7 +56,7 @@
hostname = self._get_host_name()
self.assertRaises(lib_exc.Forbidden,
- self.non_admin_client.show_host_detail,
+ self.non_admin_client.show_host,
hostname)
@test.attr(type=['negative'])
diff --git a/tempest/api/compute/admin/test_hypervisor.py b/tempest/api/compute/admin/test_hypervisor.py
index 9483f52..47f66af 100644
--- a/tempest/api/compute/admin/test_hypervisor.py
+++ b/tempest/api/compute/admin/test_hypervisor.py
@@ -30,7 +30,7 @@
def _list_hypervisors(self):
# List of hypervisors
- hypers = self.client.get_hypervisor_list()
+ hypers = self.client.list_hypervisors()
return hypers
def assertHypervisors(self, hypers):
@@ -45,7 +45,7 @@
@test.idempotent_id('1e7fdac2-b672-4ad1-97a4-bad0e3030118')
def test_get_hypervisor_list_details(self):
# Display the details of the all hypervisor
- hypers = self.client.get_hypervisor_list_details()
+ hypers = self.client.list_hypervisors(detail=True)
self.assertHypervisors(hypers)
@test.idempotent_id('94ff9eae-a183-428e-9cdb-79fde71211cc')
@@ -54,7 +54,7 @@
hypers = self._list_hypervisors()
self.assertHypervisors(hypers)
- details = self.client.get_hypervisor_show_details(hypers[0]['id'])
+ details = self.client.show_hypervisor(hypers[0]['id'])
self.assertTrue(len(details) > 0)
self.assertEqual(details['hypervisor_hostname'],
hypers[0]['hypervisor_hostname'])
@@ -66,13 +66,13 @@
self.assertHypervisors(hypers)
hostname = hypers[0]['hypervisor_hostname']
- hypervisors = self.client.get_hypervisor_servers(hostname)
+ hypervisors = self.client.list_servers_on_hypervisor(hostname)
self.assertTrue(len(hypervisors) > 0)
@test.idempotent_id('797e4f28-b6e0-454d-a548-80cc77c00816')
def test_get_hypervisor_stats(self):
# Verify the stats of the all hypervisor
- stats = self.client.get_hypervisor_stats()
+ stats = self.client.show_hypervisor_statistics()
self.assertTrue(len(stats) > 0)
@test.idempotent_id('91a50d7d-1c2b-4f24-b55a-a1fe20efca70')
@@ -88,7 +88,7 @@
ironic_only = True
hypers_without_ironic = []
for hyper in hypers:
- details = self.client.get_hypervisor_show_details(hypers[0]['id'])
+ details = self.client.show_hypervisor(hypers[0]['id'])
if details['hypervisor_type'] != 'ironic':
hypers_without_ironic.append(hyper)
ironic_only = False
@@ -102,7 +102,7 @@
# because hypervisors might be disabled, this loops looking
# for any good hit.
try:
- uptime = self.client.get_hypervisor_uptime(hyper['id'])
+ uptime = self.client.show_hypervisor_uptime(hyper['id'])
if len(uptime) > 0:
has_valid_uptime = True
break
diff --git a/tempest/api/compute/admin/test_hypervisor_negative.py b/tempest/api/compute/admin/test_hypervisor_negative.py
index 24b0090..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
@@ -36,7 +36,7 @@
def _list_hypervisors(self):
# List of hypervisors
- hypers = self.client.get_hypervisor_list()
+ hypers = self.client.list_hypervisors()
return hypers
@test.attr(type=['negative'])
@@ -46,7 +46,7 @@
self.assertRaises(
lib_exc.NotFound,
- self.client.get_hypervisor_show_details,
+ self.client.show_hypervisor,
nonexistent_hypervisor_id)
@test.attr(type=['negative'])
@@ -57,7 +57,7 @@
self.assertRaises(
lib_exc.Forbidden,
- self.non_adm_client.get_hypervisor_show_details,
+ self.non_adm_client.show_hypervisor,
hypers[0]['id'])
@test.attr(type=['negative'])
@@ -68,7 +68,7 @@
self.assertRaises(
lib_exc.Forbidden,
- self.non_adm_client.get_hypervisor_servers,
+ self.non_adm_client.list_servers_on_hypervisor,
hypers[0]['id'])
@test.attr(type=['negative'])
@@ -78,7 +78,7 @@
self.assertRaises(
lib_exc.NotFound,
- self.client.get_hypervisor_servers,
+ self.client.list_servers_on_hypervisor,
nonexistent_hypervisor_id)
@test.attr(type=['negative'])
@@ -86,7 +86,7 @@
def test_get_hypervisor_stats_with_non_admin_user(self):
self.assertRaises(
lib_exc.Forbidden,
- self.non_adm_client.get_hypervisor_stats)
+ self.non_adm_client.show_hypervisor_statistics)
@test.attr(type=['negative'])
@test.idempotent_id('f60aa680-9a3a-4c7d-90e1-fae3a4891303')
@@ -95,7 +95,7 @@
self.assertRaises(
lib_exc.NotFound,
- self.client.get_hypervisor_uptime,
+ self.client.show_hypervisor_uptime,
nonexistent_hypervisor_id)
@test.attr(type=['negative'])
@@ -106,7 +106,7 @@
self.assertRaises(
lib_exc.Forbidden,
- self.non_adm_client.get_hypervisor_uptime,
+ self.non_adm_client.show_hypervisor_uptime,
hypers[0]['id'])
@test.attr(type=['negative'])
@@ -115,7 +115,7 @@
# List of hypervisor and available services with non admin user
self.assertRaises(
lib_exc.Forbidden,
- self.non_adm_client.get_hypervisor_list)
+ self.non_adm_client.list_hypervisors)
@test.attr(type=['negative'])
@test.idempotent_id('dc02db05-e801-4c5f-bc8e-d915290ab345')
@@ -123,7 +123,7 @@
# List of hypervisor details and available services with non admin user
self.assertRaises(
lib_exc.Forbidden,
- self.non_adm_client.get_hypervisor_list_details)
+ self.non_adm_client.list_hypervisors, detail=True)
@test.attr(type=['negative'])
@test.idempotent_id('19a45cc1-1000-4055-b6d2-28e8b2ec4faa')
diff --git a/tempest/api/compute/admin/test_instance_usage_audit_log.py b/tempest/api/compute/admin/test_instance_usage_audit_log.py
index 9da7901..189c316 100644
--- a/tempest/api/compute/admin/test_instance_usage_audit_log.py
+++ b/tempest/api/compute/admin/test_instance_usage_audit_log.py
@@ -44,7 +44,7 @@
def test_get_instance_usage_audit_log(self):
# Get instance usage audit log before specified time
now = datetime.datetime.now()
- body = self.adm_client.get_instance_usage_audit_log(
+ body = self.adm_client.show_instance_usage_audit_log(
urllib.quote(now.strftime("%Y-%m-%d %H:%M:%S")))
expected_items = ['total_errors', 'total_instances', 'log',
diff --git a/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py b/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py
index 97d665b..eea3103 100644
--- a/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py
+++ b/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py
@@ -39,12 +39,12 @@
now = datetime.datetime.now()
self.assertRaises(lib_exc.Forbidden,
self.instance_usages_audit_log_client.
- get_instance_usage_audit_log,
+ show_instance_usage_audit_log,
urllib.quote(now.strftime("%Y-%m-%d %H:%M:%S")))
@test.attr(type=['negative'])
@test.idempotent_id('9b952047-3641-41c7-ba91-a809fc5974c8')
def test_get_instance_usage_audit_logs_with_invalid_time(self):
self.assertRaises(lib_exc.BadRequest,
- self.adm_client.get_instance_usage_audit_log,
+ self.adm_client.show_instance_usage_audit_log,
"invalid_time")
diff --git a/tempest/api/compute/admin/test_live_migration.py b/tempest/api/compute/admin/test_live_migration.py
index d3b1f5e..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):
@@ -78,7 +79,7 @@
return server_id
def _volume_clean_up(self, server_id, volume_id):
- body = self.volumes_client.get_volume(volume_id)
+ body = self.volumes_client.show_volume(volume_id)
if body['status'] == 'in-use':
self.servers_client.detach_volume(server_id, volume_id)
self.volumes_client.wait_for_volume_status(volume_id, 'available')
@@ -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_networks.py b/tempest/api/compute/admin/test_networks.py
index 477dc61..981a5c9 100644
--- a/tempest/api/compute/admin/test_networks.py
+++ b/tempest/api/compute/admin/test_networks.py
@@ -47,7 +47,7 @@
else:
configured_network = networks
configured_network = configured_network[0]
- network = self.client.get_network(configured_network['id'])
+ network = self.client.show_network(configured_network['id'])
self.assertEqual(configured_network['label'], network['label'])
@test.idempotent_id('df3d1046-6fa5-4b2c-ad0c-cfa46a351cb9')
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index 01db25c..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__)
@@ -58,7 +58,7 @@
def test_get_default_quotas(self):
# Admin can get the default resource quota set for a tenant
expected_quota_set = self.default_quota_set | set(['id'])
- quota_set = self.adm_client.get_default_quota_set(
+ quota_set = self.adm_client.show_default_quota_set(
self.demo_tenant_id)
self.assertEqual(quota_set['id'], self.demo_tenant_id)
for quota in expected_quota_set:
@@ -67,7 +67,7 @@
@test.idempotent_id('55fbe2bf-21a9-435b-bbd2-4162b0ed799a')
def test_update_all_quota_resources_for_tenant(self):
# Admin can update all the resource quota limits for a tenant
- default_quota_set = self.adm_client.get_default_quota_set(
+ default_quota_set = self.adm_client.show_default_quota_set(
self.demo_tenant_id)
new_quota_set = {'injected_file_content_bytes': 20480,
'metadata_items': 256, 'injected_files': 10,
@@ -107,7 +107,7 @@
self.addCleanup(identity_client.delete_tenant, tenant_id)
self.adm_client.update_quota_set(tenant_id, ram='5120')
- quota_set = self.adm_client.get_quota_set(tenant_id)
+ quota_set = self.adm_client.show_quota_set(tenant_id)
self.assertEqual(5120, quota_set['ram'])
# Verify that GET shows the updated quota set of user
@@ -124,8 +124,8 @@
self.adm_client.update_quota_set(tenant_id,
user_id=user_id,
ram='2048')
- quota_set = self.adm_client.get_quota_set(tenant_id,
- user_id=user_id)
+ quota_set = self.adm_client.show_quota_set(tenant_id,
+ user_id=user_id)
self.assertEqual(2048, quota_set['ram'])
@test.idempotent_id('389d04f0-3a41-405f-9317-e5f86e3c44f0')
@@ -138,14 +138,14 @@
description=tenant_desc)
tenant_id = tenant['id']
self.addCleanup(identity_client.delete_tenant, tenant_id)
- quota_set_default = self.adm_client.get_quota_set(tenant_id)
+ quota_set_default = self.adm_client.show_quota_set(tenant_id)
ram_default = quota_set_default['ram']
self.adm_client.update_quota_set(tenant_id, ram='5120')
self.adm_client.delete_quota_set(tenant_id)
- quota_set_new = self.adm_client.get_quota_set(tenant_id)
+ quota_set_new = self.adm_client.show_quota_set(tenant_id)
self.assertEqual(ram_default, quota_set_new['ram'])
@@ -176,7 +176,7 @@
@test.idempotent_id('7932ab0f-5136-4075-b201-c0e2338df51a')
def test_update_default_quotas(self):
LOG.debug("get the current 'default' quota class values")
- body = self.adm_client.get_quota_class_set('default')
+ body = self.adm_client.show_quota_class_set('default')
self.assertIn('id', body)
self.assertEqual('default', body.pop('id'))
# restore the defaults when the test is done
diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py
index d20ebf3..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):
@@ -54,7 +55,7 @@
@test.idempotent_id('91058876-9947-4807-9f22-f6eb17140d9b')
def test_create_server_when_cpu_quota_is_full(self):
# Disallow server creation when tenant's vcpu quota is full
- quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
+ quota_set = self.adm_client.show_quota_set(self.demo_tenant_id)
default_vcpu_quota = quota_set['cores']
vcpu_quota = 0 # Set the quota to zero to conserve resources
@@ -71,7 +72,7 @@
@test.idempotent_id('6fdd7012-584d-4327-a61c-49122e0d5864')
def test_create_server_when_memory_quota_is_full(self):
# Disallow server creation when tenant's memory quota is full
- quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
+ quota_set = self.adm_client.show_quota_set(self.demo_tenant_id)
default_mem_quota = quota_set['ram']
mem_quota = 0 # Set the quota to zero to conserve resources
@@ -88,7 +89,7 @@
@test.idempotent_id('7c6be468-0274-449a-81c3-ac1c32ee0161')
def test_create_server_when_instances_quota_is_full(self):
# Once instances quota limit is reached, disallow server creation
- quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
+ quota_set = self.adm_client.show_quota_set(self.demo_tenant_id)
default_instances_quota = quota_set['instances']
instances_quota = 0 # Set quota to zero to disallow server creation
@@ -107,9 +108,12 @@
def test_security_groups_exceed_limit(self):
# Negative test: Creation Security Groups over limit should FAIL
- quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
+ 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,
@@ -136,7 +140,7 @@
# Negative test: Creation of Security Group Rules should FAIL
# when we reach limit maxSecurityGroupRules
- quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
+ quota_set = self.adm_client.show_quota_set(self.demo_tenant_id)
default_sg_rules_quota = quota_set['security_group_rules']
sg_rules_quota = 0 # Set the quota to zero to conserve resources
@@ -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 7f78ce8..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
@@ -53,7 +54,7 @@
flavor_id = data_utils.rand_int_id(start=1000)
while True:
try:
- self.flavors_client.get_flavor_details(flavor_id)
+ self.flavors_client.show_flavor(flavor_id)
except lib_exc.NotFound:
break
flavor_id = data_utils.rand_int_id(start=1000)
@@ -68,7 +69,7 @@
self.useFixture(fixtures.LockFixture('compute_quotas'))
flavor_name = data_utils.rand_name("flavor")
flavor_id = self._get_unused_flavor_id()
- quota_set = self.quotas_client.get_default_quota_set(self.tenant_id)
+ quota_set = self.quotas_client.show_default_quota_set(self.tenant_id)
ram = int(quota_set['ram']) + 1
vcpus = 8
disk = 10
@@ -91,7 +92,7 @@
flavor_name = data_utils.rand_name("flavor")
flavor_id = self._get_unused_flavor_id()
ram = 512
- quota_set = self.quotas_client.get_default_quota_set(self.tenant_id)
+ quota_set = self.quotas_client.show_default_quota_set(self.tenant_id)
vcpus = int(quota_set['cores']) + 1
disk = 10
flavor_ref = self.flavors_client.create_flavor(flavor_name,
@@ -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 9aacfa5..33442b2 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -16,11 +16,11 @@
import time
from oslo_log import log as logging
-from oslo_utils import excutils
-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 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
@@ -57,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
@@ -142,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)
@@ -183,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
@@ -192,41 +195,21 @@
server_group_id)
@classmethod
- def create_test_server(cls, **kwargs):
- """Wrapper utility that returns a test server."""
- name = data_utils.rand_name(cls.__name__ + "-instance")
- if 'name' in kwargs:
- name = kwargs.pop('name')
- flavor = kwargs.get('flavor', cls.flavor_ref)
- image_id = kwargs.get('image_id', cls.image_ref)
+ def create_test_server(cls, validatable=False, **kwargs):
+ """Wrapper utility that returns a test server.
- kwargs = fixed_network.set_networks_kwarg(
- cls.get_tenant_network(), kwargs) or {}
- body = cls.servers_client.create_server(
- name, image_id, flavor, **kwargs)
-
- # handle the case of multiple servers
- servers = [body]
- if 'min_count' in kwargs or 'max_count' in kwargs:
- # Get servers created which name match with name param.
- b = cls.servers_client.list_servers()
- servers = [s for s in b['servers'] if s['name'].startswith(name)]
-
- if 'wait_until' in kwargs:
- for server in servers:
- try:
- cls.servers_client.wait_for_server_status(
- server['id'], kwargs['wait_until'])
- except Exception:
- with excutils.save_and_reraise_exception():
- if ('preserve_server_on_error' not in kwargs
- or kwargs['preserve_server_on_error'] is False):
- for server in servers:
- try:
- cls.servers_client.delete_server(
- server['id'])
- except Exception:
- pass
+ This wrapper utility calls the common create test server and
+ returns a test server. The purpose of this wrapper is to minimize
+ the impact on the code of the tests already using this
+ function.
+ """
+ tenant_network = cls.get_tenant_network()
+ body, servers = compute.create_test_server(
+ cls.os,
+ validatable,
+ validation_resources=cls.validation_resources,
+ tenant_network=tenant_network,
+ **kwargs)
cls.servers.extend(servers)
@@ -251,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
@@ -284,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)
@@ -301,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:
@@ -320,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']
@@ -338,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/flavors/test_flavors.py b/tempest/api/compute/flavors/test_flavors.py
index c1c87f9..728fefb 100644
--- a/tempest/api/compute/flavors/test_flavors.py
+++ b/tempest/api/compute/flavors/test_flavors.py
@@ -33,7 +33,7 @@
def test_list_flavors(self):
# List of all flavors should contain the expected flavor
flavors = self.client.list_flavors()
- flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor = self.client.show_flavor(self.flavor_ref)
flavor_min_detail = {'id': flavor['id'], 'links': flavor['links'],
'name': flavor['name']}
self.assertIn(flavor_min_detail, flavors)
@@ -41,89 +41,89 @@
@test.idempotent_id('6e85fde4-b3cd-4137-ab72-ed5f418e8c24')
def test_list_flavors_with_detail(self):
# Detailed list of all flavors should contain the expected flavor
- flavors = self.client.list_flavors_with_detail()
- flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavors = self.client.list_flavors(detail=True)
+ flavor = self.client.show_flavor(self.flavor_ref)
self.assertIn(flavor, flavors)
@test.attr(type='smoke')
@test.idempotent_id('1f12046b-753d-40d2-abb6-d8eb8b30cb2f')
def test_get_flavor(self):
# The expected flavor details should be returned
- flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor = self.client.show_flavor(self.flavor_ref)
self.assertEqual(self.flavor_ref, flavor['id'])
@test.idempotent_id('8d7691b3-6ed4-411a-abc9-2839a765adab')
def test_list_flavors_limit_results(self):
# Only the expected number of flavors should be returned
params = {'limit': 1}
- flavors = self.client.list_flavors(params)
+ flavors = self.client.list_flavors(**params)
self.assertEqual(1, len(flavors))
@test.idempotent_id('b26f6327-2886-467a-82be-cef7a27709cb')
def test_list_flavors_detailed_limit_results(self):
# Only the expected number of flavors (detailed) should be returned
params = {'limit': 1}
- flavors = self.client.list_flavors_with_detail(params)
+ flavors = self.client.list_flavors(detail=True, **params)
self.assertEqual(1, len(flavors))
@test.idempotent_id('e800f879-9828-4bd0-8eae-4f17189951fb')
def test_list_flavors_using_marker(self):
# The list of flavors should start from the provided marker
- flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor = self.client.show_flavor(self.flavor_ref)
flavor_id = flavor['id']
params = {'marker': flavor_id}
- flavors = self.client.list_flavors(params)
+ flavors = self.client.list_flavors(**params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]),
'The list of flavors did not start after the marker.')
@test.idempotent_id('6db2f0c0-ddee-4162-9c84-0703d3dd1107')
def test_list_flavors_detailed_using_marker(self):
# The list of flavors should start from the provided marker
- flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor = self.client.show_flavor(self.flavor_ref)
flavor_id = flavor['id']
params = {'marker': flavor_id}
- flavors = self.client.list_flavors_with_detail(params)
+ flavors = self.client.list_flavors(detail=True, **params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]),
'The list of flavors did not start after the marker.')
@test.idempotent_id('3df2743e-3034-4e57-a4cb-b6527f6eac79')
def test_list_flavors_detailed_filter_by_min_disk(self):
# The detailed list of flavors should be filtered by disk space
- flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor = self.client.show_flavor(self.flavor_ref)
flavor_id = flavor['id']
params = {self._min_disk: flavor['disk'] + 1}
- flavors = self.client.list_flavors_with_detail(params)
+ flavors = self.client.list_flavors(detail=True, **params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
@test.idempotent_id('09fe7509-b4ee-4b34-bf8b-39532dc47292')
def test_list_flavors_detailed_filter_by_min_ram(self):
# The detailed list of flavors should be filtered by RAM
- flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor = self.client.show_flavor(self.flavor_ref)
flavor_id = flavor['id']
params = {self._min_ram: flavor['ram'] + 1}
- flavors = self.client.list_flavors_with_detail(params)
+ flavors = self.client.list_flavors(detail=True, **params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
@test.idempotent_id('10645a4d-96f5-443f-831b-730711e11dd4')
def test_list_flavors_filter_by_min_disk(self):
# The list of flavors should be filtered by disk space
- flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor = self.client.show_flavor(self.flavor_ref)
flavor_id = flavor['id']
params = {self._min_disk: flavor['disk'] + 1}
- flavors = self.client.list_flavors(params)
+ flavors = self.client.list_flavors(**params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
@test.idempotent_id('935cf550-e7c8-4da6-8002-00f92d5edfaa')
def test_list_flavors_filter_by_min_ram(self):
# The list of flavors should be filtered by RAM
- flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor = self.client.show_flavor(self.flavor_ref)
flavor_id = flavor['id']
params = {self._min_ram: flavor['ram'] + 1}
- flavors = self.client.list_flavors(params)
+ flavors = self.client.list_flavors(**params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
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 5f438fb..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
@@ -67,7 +68,7 @@
self.addCleanup(self.client.delete_floating_ip,
floating_ip_id_allocated)
floating_ip_details = \
- self.client.get_floating_ip_details(floating_ip_id_allocated)
+ self.client.show_floating_ip(floating_ip_id_allocated)
# Checking if the details of allocated IP is in list of floating IP
body = self.client.list_floating_ips()
self.assertIn(floating_ip_details, body)
@@ -97,7 +98,7 @@
self.server_id)
# Check instance_id in the floating_ip body
- body = self.client.get_floating_ip_details(self.floating_ip_id)
+ body = self.client.show_floating_ip(self.floating_ip_id)
self.assertEqual(self.server_id, body['instance_id'])
# Disassociation of floating IP that was associated in this method
@@ -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 62bc92c..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):
@@ -63,7 +64,7 @@
floating_ip_instance_id = body['instance_id']
floating_ip_ip = body['ip']
floating_ip_fixed_ip = body['fixed_ip']
- body = self.client.get_floating_ip_details(floating_ip_id)
+ body = self.client.show_floating_ip(floating_ip_id)
# Comparing the details of floating IP
self.assertEqual(floating_ip_instance_id,
body['instance_id'])
@@ -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 e1e30a4..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
@@ -44,4 +44,4 @@
else:
non_exist_id = data_utils.rand_int_id(start=999)
self.assertRaises(lib_exc.NotFound,
- self.client.get_floating_ip_details, non_exist_id)
+ self.client.show_floating_ip, non_exist_id)
diff --git a/tempest/api/compute/images/test_image_metadata.py b/tempest/api/compute/images/test_image_metadata.py
index 9664c61..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()
@@ -93,8 +93,8 @@
@test.idempotent_id('4f5db52f-6685-4c75-b848-f4bb363f9aa6')
def test_get_image_metadata_item(self):
# The value for a specific metadata key should be returned
- meta = self.client.get_image_metadata_item(self.image_id,
- 'os_distro')
+ meta = self.client.show_image_metadata_item(self.image_id,
+ 'os_distro')
self.assertEqual('value2', meta['os_distro'])
@test.idempotent_id('f2de776a-4778-4d90-a5da-aae63aee64ae')
diff --git a/tempest/api/compute/images/test_image_metadata_negative.py b/tempest/api/compute/images/test_image_metadata_negative.py
index e44fbfc..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
@@ -49,7 +49,7 @@
def test_get_nonexistent_image_metadata_item(self):
# Negative test: Get on non-existent image should not happen
self.assertRaises(lib_exc.NotFound,
- self.client.get_image_metadata_item,
+ self.client.show_image_metadata_item,
data_utils.rand_uuid(), 'os_version')
@test.attr(type=['negative'])
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 3771a43..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)
@@ -70,7 +71,7 @@
cls.server_id = server['id']
def _get_default_flavor_disk_size(self, flavor_id):
- flavor = self.flavors_client.get_flavor_details(flavor_id)
+ flavor = self.flavors_client.show_flavor(flavor_id)
return flavor['disk']
@test.idempotent_id('3731d080-d4c5-4872-b41a-64d0d0021314')
@@ -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 e2d4bd9..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(
@@ -105,7 +106,7 @@
# The list of images should contain only images with the
# provided status
params = {'status': 'ACTIVE'}
- images = self.client.list_images(params)
+ images = self.client.list_images(**params)
self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
@@ -116,7 +117,7 @@
# List of all images should contain the expected images filtered
# by name
params = {'name': self.image1['name']}
- images = self.client.list_images(params)
+ images = self.client.list_images(**params)
self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
self.assertFalse(any([i for i in images if i['id'] == self.image2_id]))
@@ -128,7 +129,7 @@
def test_list_images_filter_by_server_id(self):
# The images should contain images filtered by server id
params = {'server': self.server1['id']}
- images = self.client.list_images(params)
+ images = self.client.list_images(**params)
self.assertTrue(any([i for i in images
if i['id'] == self.snapshot1_id]),
@@ -149,7 +150,7 @@
# Try all server link types
for link in server_links:
params = {'server': link['href']}
- images = self.client.list_images(params)
+ images = self.client.list_images(**params)
self.assertFalse(any([i for i in images
if i['id'] == self.snapshot1_id]))
@@ -164,7 +165,7 @@
def test_list_images_filter_by_type(self):
# The list of servers should be filtered by image type
params = {'type': 'snapshot'}
- images = self.client.list_images(params)
+ images = self.client.list_images(**params)
self.assertTrue(any([i for i in images
if i['id'] == self.snapshot1_id]))
@@ -179,7 +180,7 @@
def test_list_images_limit_results(self):
# Verify only the expected number of results are returned
params = {'limit': '1'}
- images = self.client.list_images(params)
+ images = self.client.list_images(**params)
self.assertEqual(1, len([x for x in images if 'id' in x]))
@test.idempotent_id('18bac3ae-da27-436c-92a9-b22474d13aab')
@@ -189,7 +190,7 @@
# Becoming ACTIVE will modify the updated time
# Filter by the image's created time
params = {'changes-since': self.image3['created']}
- images = self.client.list_images(params)
+ images = self.client.list_images(**params)
found = any([i for i in images if i['id'] == self.image3_id])
self.assertTrue(found)
@@ -198,7 +199,7 @@
# Detailed list of all images should only contain images
# with the provided status
params = {'status': 'ACTIVE'}
- images = self.client.list_images_with_detail(params)
+ images = self.client.list_images(detail=True, **params)
self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
@@ -209,7 +210,7 @@
# Detailed list of all images should contain the expected
# images filtered by name
params = {'name': self.image1['name']}
- images = self.client.list_images_with_detail(params)
+ images = self.client.list_images(detail=True, **params)
self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
self.assertFalse(any([i for i in images if i['id'] == self.image2_id]))
@@ -220,7 +221,7 @@
# Verify only the expected number of results (with full details)
# are returned
params = {'limit': '1'}
- images = self.client.list_images_with_detail(params)
+ images = self.client.list_images(detail=True, **params)
self.assertEqual(1, len(images))
@test.idempotent_id('8c78f822-203b-4bf6-8bba-56ebd551cf84')
@@ -233,7 +234,7 @@
# Try all server link types
for link in server_links:
params = {'server': link['href']}
- images = self.client.list_images_with_detail(params)
+ images = self.client.list_images(detail=True, **params)
self.assertFalse(any([i for i in images
if i['id'] == self.snapshot1_id]))
@@ -248,7 +249,7 @@
def test_list_images_with_detail_filter_by_type(self):
# The detailed list of servers should be filtered by image type
params = {'type': 'snapshot'}
- images = self.client.list_images_with_detail(params)
+ images = self.client.list_images(detail=True, **params)
self.client.show_image(self.image_ref)
self.assertTrue(any([i for i in images
@@ -267,5 +268,5 @@
# Becoming ACTIVE will modify the updated time
# Filter by the image's created time
params = {'changes-since': self.image1['created']}
- images = self.client.list_images_with_detail(params)
+ images = self.client.list_images(detail=True, **params)
self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
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/images/test_list_images.py b/tempest/api/compute/images/test_list_images.py
index 5b80c72..b67378c 100644
--- a/tempest/api/compute/images/test_list_images.py
+++ b/tempest/api/compute/images/test_list_images.py
@@ -50,6 +50,6 @@
@test.idempotent_id('9f94cb6b-7f10-48c5-b911-a0b84d7d4cd6')
def test_list_images_with_detail(self):
# Detailed list of all images should contain the expected images
- images = self.client.list_images_with_detail()
+ images = self.client.list_images(detail=True)
found = any([i for i in images if i['id'] == self.image_ref])
self.assertTrue(found)
diff --git a/tempest/api/compute/keypairs/test_keypairs.py b/tempest/api/compute/keypairs/test_keypairs.py
index 01e3c86..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
@@ -82,7 +81,7 @@
# Keypair should be created, Got details by name and deleted
k_name = data_utils.rand_name('keypair')
self._create_keypair(k_name)
- keypair_detail = self.client.get_keypair(k_name)
+ keypair_detail = self.client.show_keypair(k_name)
self.assertIn('name', keypair_detail)
self.assertIn('public_key', keypair_detail)
self.assertEqual(keypair_detail['name'], k_name,
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/limits/test_absolute_limits.py b/tempest/api/compute/limits/test_absolute_limits.py
index 974814c..0029bb9 100644
--- a/tempest/api/compute/limits/test_absolute_limits.py
+++ b/tempest/api/compute/limits/test_absolute_limits.py
@@ -27,7 +27,8 @@
@test.idempotent_id('b54c66af-6ab6-4cf0-a9e5-a0cb58d75e0b')
def test_absLimits_get(self):
# To check if all limits are present in the response
- absolute_limits = self.client.get_absolute_limits()
+ limits = self.client.show_limits()
+ absolute_limits = limits['absolute']
expected_elements = ['maxImageMeta', 'maxPersonality',
'maxPersonalitySize',
'maxServerMeta', 'maxTotalCores',
diff --git a/tempest/api/compute/limits/test_absolute_limits_negative.py b/tempest/api/compute/limits/test_absolute_limits_negative.py
index bdbe3f1..cbd2004 100644
--- a/tempest/api/compute/limits/test_absolute_limits_negative.py
+++ b/tempest/api/compute/limits/test_absolute_limits_negative.py
@@ -38,7 +38,8 @@
def test_max_image_meta_exceed_limit(self):
# We should not create vm with image meta over maxImageMeta limit
# Get max limit value
- max_meta = self.client.get_specific_absolute_limit('maxImageMeta')
+ limits = self.client.show_limits()
+ max_meta = limits['absolute']['maxImageMeta']
# No point in running this test if there is no limit.
if int(max_meta) == -1:
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 9012d3d..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
@@ -53,15 +53,31 @@
personality = [{'path': '/test.txt',
'contents': base64.b64encode(file_contents)}]
disk_config = cls.disk_config
- cls.server_initial = cls.create_test_server(name=cls.name,
- meta=cls.meta,
- accessIPv4=cls.accessIPv4,
- accessIPv6=cls.accessIPv6,
- personality=personality,
- disk_config=disk_config)
+ cls.server_initial = cls.create_test_server(
+ validatable=True,
+ wait_until='ACTIVE',
+ name=cls.name,
+ meta=cls.meta,
+ accessIPv4=cls.accessIPv4,
+ accessIPv6=cls.accessIPv6,
+ personality=personality,
+ disk_config=disk_config)
cls.password = cls.server_initial['adminPass']
- cls.client.wait_for_server_status(cls.server_initial['id'], 'ACTIVE')
- 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')
@@ -89,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)
@@ -100,9 +116,12 @@
def test_verify_created_server_vcpus(self):
# Verify that the number of vcpus reported by the instance matches
# the amount stated by the flavor
- flavor = self.flavors_client.get_flavor_details(self.flavor_ref)
- linux_client = remote_client.RemoteClient(self.server, self.ssh_user,
- self.password)
+ flavor = self.flavors_client.show_flavor(self.flavor_ref)
+ 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')
@@ -110,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')
@@ -119,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')
@@ -138,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']}]
@@ -187,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.')
@@ -255,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 c2ed0ce..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,25 +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(
+ 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,
@@ -68,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))
@@ -110,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']))
@@ -144,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
@@ -179,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)
@@ -191,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:
@@ -233,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')
@@ -249,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
@@ -272,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')
@@ -287,8 +318,9 @@
'backup_type': "daily",
'instance_uuid': self.server_id,
}
- image_list = self.os.image_client.image_list_detail(
- properties,
+ image_list = self.os.image_client.list_images(
+ detail=True,
+ properties=properties,
status='active',
sort_key='created_at',
sort_dir='asc')
@@ -299,19 +331,20 @@
# 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.image_list_detail(
- properties,
+ image_list = self.os.image_client.list_images(
+ detail=True,
+ properties=properties,
status='active',
sort_key='created_at',
sort_dir='asc')
@@ -324,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'))
@@ -342,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')
@@ -354,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'))
@@ -379,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')
@@ -389,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,
@@ -410,48 +442,48 @@
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)
+ images = self.images_client.list_images(**params)
self.assertEqual(1, len(images))
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']
@@ -467,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 1a977ab..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
@@ -137,7 +137,7 @@
# A 403 Forbidden or 413 Overlimit (old behaviour) exception
# will be raised while exceeding metadata items limit for
# tenant.
- quota_set = self.quotas.get_quota_set(self.tenant_id)
+ quota_set = self.quotas.show_quota_set(self.tenant_id)
quota_metadata = quota_set['metadata_items']
if quota_metadata == -1:
raise self.skipException("No limit for metadata_items")
diff --git a/tempest/api/compute/servers/test_server_personality.py b/tempest/api/compute/servers/test_server_personality.py
index 3a019b4..b3cc072 100644
--- a/tempest/api/compute/servers/test_server_personality.py
+++ b/tempest/api/compute/servers/test_server_personality.py
@@ -34,8 +34,8 @@
# number of files are injected into the server.
file_contents = 'This is a test file.'
personality = []
- max_file_limit = \
- self.user_client.get_specific_absolute_limit("maxPersonality")
+ limits = self.user_client.show_limits()
+ max_file_limit = limits['absolute']['maxPersonality']
if max_file_limit == -1:
raise self.skipException("No limit for personality files")
for i in range(0, int(max_file_limit) + 1):
@@ -52,8 +52,8 @@
# Server should be created successfully if maximum allowed number of
# files is injected into the server during creation.
file_contents = 'This is a test file.'
- max_file_limit = \
- self.user_client.get_specific_absolute_limit("maxPersonality")
+ limits = self.user_client.show_limits()
+ max_file_limit = limits['absolute']['maxPersonality']
if max_file_limit == -1:
raise self.skipException("No limit for personality files")
person = []
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 82ef7f5..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,17 +468,19 @@
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)
+ images = self.images_client.list_images(**params)
self.assertEqual(1, len(images))
self.assertEqual(image_name, images[0]['name'])
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index 63b78a0..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')
@@ -219,7 +221,7 @@
def test_get_keypair_of_alt_account_fails(self):
# A GET request for another user's keypair should fail
self.assertRaises(lib_exc.NotFound,
- self.alt_keypairs_client.get_keypair,
+ self.alt_keypairs_client.show_keypair,
self.keypairname)
@test.idempotent_id('6d841683-a8e0-43da-a1b8-b339f7692b61')
@@ -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')
@@ -356,7 +358,7 @@
self.images_client.set_image_metadata(self.image['id'],
req_metadata)
self.assertRaises(lib_exc.NotFound,
- self.alt_images_client.get_image_metadata_item,
+ self.alt_images_client.show_image_metadata_item,
self.image['id'], 'meta1')
@test.idempotent_id('79531e2e-e721-493c-8b30-a35db36fdaa6')
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 a6e877c..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'))
@@ -47,14 +54,14 @@
def test_get_quotas(self):
# User can get the quota set for it's tenant
expected_quota_set = self.default_quota_set | set(['id'])
- quota_set = self.client.get_quota_set(self.tenant_id)
+ quota_set = self.client.show_quota_set(self.tenant_id)
self.assertEqual(quota_set['id'], self.tenant_id)
for quota in expected_quota_set:
self.assertIn(quota, quota_set.keys())
# get the quota set using user id
- quota_set = self.client.get_quota_set(self.tenant_id,
- self.user_id)
+ quota_set = self.client.show_quota_set(self.tenant_id,
+ self.user_id)
self.assertEqual(quota_set['id'], self.tenant_id)
for quota in expected_quota_set:
self.assertIn(quota, quota_set.keys())
@@ -63,7 +70,7 @@
def test_get_default_quotas(self):
# User can get the default quota set for it's tenant
expected_quota_set = self.default_quota_set | set(['id'])
- quota_set = self.client.get_default_quota_set(self.tenant_id)
+ quota_set = self.client.show_default_quota_set(self.tenant_id)
self.assertEqual(quota_set['id'], self.tenant_id)
for quota in expected_quota_set:
self.assertIn(quota, quota_set.keys())
@@ -72,6 +79,6 @@
def test_compare_tenant_quotas_with_default_quotas(self):
# Tenants are created with the default quota values
defualt_quota_set = \
- self.client.get_default_quota_set(self.tenant_id)
- tenant_quota_set = self.client.get_quota_set(self.tenant_id)
+ self.client.show_default_quota_set(self.tenant_id)
+ tenant_quota_set = self.client.show_quota_set(self.tenant_id)
self.assertEqual(defualt_quota_set, tenant_quota_set)
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/database/flavors/test_flavors.py b/tempest/api/database/flavors/test_flavors.py
index eeb472c..e698baa 100644
--- a/tempest/api/database/flavors/test_flavors.py
+++ b/tempest/api/database/flavors/test_flavors.py
@@ -58,7 +58,7 @@
@test.services('compute')
def test_compare_db_flavors_with_os(self):
db_flavors = self.client.list_db_flavors()
- os_flavors = self.os_flavors_client.list_flavors_with_detail()
+ os_flavors = self.os_flavors_client.list_flavors(detail=True)
self.assertEqual(len(os_flavors), len(db_flavors),
"OS flavors %s do not match DB flavors %s" %
(os_flavors, db_flavors))
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 bcac853..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
@@ -50,7 +50,7 @@
self.alt_email, enabled=False)
self.data.users.append(user)
self.assertEqual(name, user['name'])
- self.assertEqual('false', str(user['enabled']).lower())
+ self.assertEqual(False, user['enabled'])
self.assertEqual(self.alt_email, user['email'])
@test.idempotent_id('39d05857-e8a5-4ed4-ba83-0b52d3ab97ee')
@@ -71,13 +71,13 @@
enabled=False)
self.assertEqual(u_name2, update_user['name'])
self.assertEqual(u_email2, update_user['email'])
- self.assertEqual('false', str(update_user['enabled']).lower())
+ self.assertEqual(False, update_user['enabled'])
# GET by id after updating
updated_user = self.client.get_user(user['id'])
# Assert response body of GET after updating
self.assertEqual(u_name2, updated_user['name'])
self.assertEqual(u_email2, updated_user['email'])
- self.assertEqual('false', str(updated_user['enabled']).lower())
+ self.assertEqual(False, update_user['enabled'])
@test.idempotent_id('29ed26f4-a74e-4425-9a85-fdb49fa269d2')
def test_delete_user(self):
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 b775e91..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
@@ -79,12 +78,12 @@
self.assertIsNotNone(updated_domain['id'])
self.assertEqual(new_name, updated_domain['name'])
self.assertEqual(new_desc, updated_domain['description'])
- self.assertEqual('true', str(updated_domain['enabled']).lower())
+ self.assertEqual(True, updated_domain['enabled'])
fetched_domain = self.client.get_domain(domain['id'])
self.assertEqual(new_name, fetched_domain['name'])
self.assertEqual(new_desc, fetched_domain['description'])
- self.assertEqual('true', str(fetched_domain['enabled']).lower())
+ self.assertEqual(True, fetched_domain['enabled'])
@test.idempotent_id('036df86e-bb5d-42c0-a7c2-66b9db3a6046')
def test_create_domain_with_disabled_status(self):
@@ -101,7 +100,7 @@
@test.idempotent_id('2abf8764-309a-4fa9-bc58-201b799817ad')
def test_create_domain_without_description(self):
# Create domain only with name
- d_name = data_utils.rand_name('domain-')
+ d_name = data_utils.rand_name('domain')
domain = self.client.create_domain(d_name)
self.addCleanup(self._delete_domain, domain['id'])
self.assertIn('id', domain)
diff --git a/tempest/api/identity/admin/v3/test_endpoints.py b/tempest/api/identity/admin/v3/test_endpoints.py
index 1672d47..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
@@ -126,4 +125,4 @@
self.assertEqual(interface2, endpoint['interface'])
self.assertEqual(url2, endpoint['url'])
self.assertEqual(region2, endpoint['region'])
- self.assertEqual('false', str(endpoint['enabled']).lower())
+ self.assertEqual(False, endpoint['enabled'])
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 3ebb90d..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
@@ -46,7 +46,7 @@
def create_trustor_and_roles(self):
# create a project that trusts will be granted on
- self.trustor_project_name = data_utils.rand_name(name='project-')
+ self.trustor_project_name = data_utils.rand_name(name='project')
project = self.client.create_project(self.trustor_project_name,
domain_id='default')
self.trustor_project_id = project['id']
diff --git a/tempest/api/identity/admin/v3/test_users.py b/tempest/api/identity/admin/v3/test_users.py
index 7fe369e..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
@@ -53,7 +52,7 @@
self.assertEqual(project['id'],
update_user['project_id'])
self.assertEqual(u_email2, update_user['email'])
- self.assertEqual('false', str(update_user['enabled']).lower())
+ self.assertEqual(False, update_user['enabled'])
# GET by id after updation
new_user_get = self.client.get_user(user['id'])
# Assert response body of GET after updation
@@ -62,7 +61,7 @@
self.assertEqual(project['id'],
new_user_get['project_id'])
self.assertEqual(u_email2, new_user_get['email'])
- self.assertEqual('false', str(new_user_get['enabled']).lower())
+ self.assertEqual(False, new_user_get['enabled'])
@test.idempotent_id('2d223a0e-e457-4a70-9fb1-febe027a0ff9')
def test_update_user_password(self):
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_api_discovery.py b/tempest/api/identity/v2/test_api_discovery.py
new file mode 100644
index 0000000..8132ee1
--- /dev/null
+++ b/tempest/api/identity/v2/test_api_discovery.py
@@ -0,0 +1,57 @@
+# Copyright 2015 OpenStack Foundation.
+# Copyright 2015, Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.identity import base
+from tempest import test
+
+
+class TestApiDiscovery(base.BaseIdentityV2Test):
+ """Tests for API discovery features."""
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('ea889a68-a15f-4166-bfb1-c12456eae853')
+ def test_api_version_resources(self):
+ descr = self.non_admin_client.get_api_description()
+ expected_resources = ('id', 'links', 'media-types', 'status',
+ 'updated')
+
+ keys = descr.keys()
+ for res in expected_resources:
+ self.assertIn(res, keys)
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('007a0be0-78fe-4fdb-bbee-e9216cc17bb2')
+ def test_api_media_types(self):
+ descr = self.non_admin_client.get_api_description()
+ # Get MIME type bases and descriptions
+ media_types = [(media_type['base'], media_type['type']) for
+ media_type in descr['media-types']]
+ # These are supported for API version 2
+ supported_types = [('application/json',
+ 'application/vnd.openstack.identity-v2.0+json')]
+
+ # Check if supported types exist in response body
+ for s_type in supported_types:
+ self.assertIn(s_type, media_types)
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('77fd6be0-8801-48e6-b9bf-38cdd2f253ec')
+ def test_api_version_statuses(self):
+ descr = self.non_admin_client.get_api_description()
+ status = descr['status'].lower()
+ supported_statuses = ['current', 'stable', 'experimental',
+ 'supported', 'deprecated']
+
+ self.assertIn(status, supported_statuses)
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_api_discovery.py b/tempest/api/identity/v3/test_api_discovery.py
new file mode 100644
index 0000000..2ec8ad8
--- /dev/null
+++ b/tempest/api/identity/v3/test_api_discovery.py
@@ -0,0 +1,57 @@
+# Copyright 2015 OpenStack Foundation.
+# Copyright 2015, Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.identity import base
+from tempest import test
+
+
+class TestApiDiscovery(base.BaseIdentityV3Test):
+ """Tests for API discovery features."""
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('b9232f5e-d9e5-4d97-b96c-28d3db4de1bd')
+ def test_api_version_resources(self):
+ descr = self.non_admin_client.get_api_description()
+ expected_resources = ('id', 'links', 'media-types', 'status',
+ 'updated')
+
+ keys = descr.keys()
+ for res in expected_resources:
+ self.assertIn(res, keys)
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('657c1970-4722-4189-8831-7325f3bc4265')
+ def test_api_media_types(self):
+ descr = self.non_admin_client.get_api_description()
+ # Get MIME type bases and descriptions
+ media_types = [(media_type['base'], media_type['type']) for
+ media_type in descr['media-types']]
+ # These are supported for API version 2
+ supported_types = [('application/json',
+ 'application/vnd.openstack.identity-v3+json')]
+
+ # Check if supported types exist in response body
+ for s_type in supported_types:
+ self.assertIn(s_type, media_types)
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('8879a470-abfb-47bb-bb8d-5a7fd279ad1e')
+ def test_api_version_statuses(self):
+ descr = self.non_admin_client.get_api_description()
+ status = descr['status'].lower()
+ supported_statuses = ['current', 'stable', 'experimental',
+ 'supported', 'deprecated']
+
+ self.assertIn(status, supported_statuses)
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/admin/__init__.py b/tempest/api/image/admin/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api/image/admin/__init__.py
diff --git a/tempest/api/image/admin/v2/__init__.py b/tempest/api/image/admin/v2/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api/image/admin/v2/__init__.py
diff --git a/tempest/api/image/admin/v2/test_images.py b/tempest/api/image/admin/v2/test_images.py
new file mode 100644
index 0000000..1608b76
--- /dev/null
+++ b/tempest/api/image/admin/v2/test_images.py
@@ -0,0 +1,55 @@
+# Copyright 2015 Red Hat, Inc.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from six import moves
+from tempest_lib.common.utils import data_utils
+import testtools
+
+from tempest.api.image import base
+from tempest import config
+from tempest import test
+
+
+CONF = config.CONF
+
+
+class BasicAdminOperationsImagesTest(base.BaseV2ImageAdminTest):
+
+ """
+ Here we test admin operations of images
+ """
+ @testtools.skipUnless(CONF.image_feature_enabled.deactivate_image,
+ 'deactivate-image is not available.')
+ @test.idempotent_id('951ebe01-969f-4ea9-9898-8a3f1f442ab0')
+ def test_admin_deactivate_reactivate_image(self):
+ # Create image by non-admin tenant
+ image_name = data_utils.rand_name('image')
+ body = self.client.create_image(name=image_name,
+ container_format='bare',
+ disk_format='raw',
+ visibility='private')
+ image_id = body['id']
+ self.addCleanup(self.client.delete_image, image_id)
+ # upload an image file
+ image_file = moves.cStringIO(data_utils.random_bytes())
+ self.client.store_image_file(image_id, image_file)
+ # deactivate image
+ self.admin_client.deactivate_image(image_id)
+ body = self.client.show_image(image_id)
+ self.assertEqual("deactivated", body['status'])
+ # reactivate image
+ self.admin_client.reactivate_image(image_id)
+ body = self.client.show_image(image_id)
+ self.assertEqual("active", body['status'])
diff --git a/tempest/api/image/base.py b/tempest/api/image/base.py
index 00959d9..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
@@ -158,3 +158,23 @@
image_id = image['id']
self.addCleanup(self.os_img_client.delete_image, image_id)
return image_id
+
+
+class BaseV1ImageAdminTest(BaseImageTest):
+ credentials = ['admin', 'primary']
+
+ @classmethod
+ def setup_clients(cls):
+ super(BaseV1ImageAdminTest, cls).setup_clients()
+ cls.client = cls.os.image_client
+ cls.admin_client = cls.os_adm.image_client
+
+
+class BaseV2ImageAdminTest(BaseImageTest):
+ credentials = ['admin', 'primary']
+
+ @classmethod
+ def setup_clients(cls):
+ super(BaseV2ImageAdminTest, cls).setup_clients()
+ cls.client = cls.os.image_client_v2
+ cls.admin_client = cls.os_adm.image_client_v2
diff --git a/tempest/api/image/v1/test_image_members.py b/tempest/api/image/v1/test_image_members.py
index 4969858..eb6969b 100644
--- a/tempest/api/image/v1/test_image_members.py
+++ b/tempest/api/image/v1/test_image_members.py
@@ -36,7 +36,7 @@
self.client.add_member(self.alt_tenant_id, image)
share_image = self._create_image()
self.client.add_member(self.alt_tenant_id, share_image)
- body = self.client.get_shared_images(self.alt_tenant_id)
+ body = self.client.list_shared_images(self.alt_tenant_id)
images = body['shared_images']
images = map(lambda x: x['image_id'], images)
self.assertIn(share_image, images)
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 6c25c93..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
@@ -211,9 +211,10 @@
@test.idempotent_id('e5dc26d9-9aa2-48dd-bda5-748e1445da98')
def test_index_status_active_detail(self):
- images_list = self.client.image_list_detail(status='active',
- sort_key='size',
- sort_dir='desc')
+ images_list = self.client.list_images(detail=True,
+ status='active',
+ sort_key='size',
+ sort_dir='desc')
top_size = images_list[0]['size'] # We have non-zero sized images
for image in images_list:
size = image['size']
@@ -223,7 +224,8 @@
@test.idempotent_id('097af10a-bae8-4342-bff4-edf89969ed2a')
def test_index_name(self):
- images_list = self.client.image_list_detail(
+ images_list = self.client.list_images(
+ detail=True,
name='New Remote Image dup')
result_set = set(map(lambda x: x['id'], images_list))
for image in images_list:
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index 8cccddd..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
@@ -56,7 +56,7 @@
# Now try uploading an image file
file_content = data_utils.random_bytes()
image_file = moves.cStringIO(file_content)
- self.client.store_image(image_id, image_file)
+ self.client.store_image_file(image_id, image_file)
# Now try to get image details
body = self.client.show_image(image_id)
@@ -67,7 +67,7 @@
self.assertEqual(1024, body.get('size'))
# Now try get image file
- body = self.client.get_image_file(image_id)
+ body = self.client.load_image_file(image_id)
self.assertEqual(file_content, body.data)
@test.attr(type='smoke')
@@ -109,7 +109,7 @@
# Now try uploading an image file
image_file = moves.cStringIO(data_utils.random_bytes())
- self.client.store_image(image_id, image_file)
+ self.client.store_image_file(image_id, image_file)
# Update Image
new_image_name = data_utils.rand_name('new-image')
@@ -156,7 +156,7 @@
disk_format=disk_format,
visibility='private')
image_id = body['id']
- cls.client.store_image(image_id, data=image_file)
+ cls.client.store_image_file(image_id, data=image_file)
return image_id
@@ -244,12 +244,12 @@
def test_get_image_schema(self):
# Test to get image schema
schema = "image"
- body = self.client.get_schema(schema)
+ body = self.client.show_schema(schema)
self.assertEqual("image", body['name'])
@test.idempotent_id('25c8d7b2-df21-460f-87ac-93130bcdc684')
def test_get_images_schema(self):
# Test to get images schema
schema = "images"
- body = self.client.get_schema(schema)
+ body = self.client.show_schema(schema)
self.assertEqual("images", body['name'])
diff --git a/tempest/api/image/v2/test_images_member.py b/tempest/api/image/v2/test_images_member.py
index 07c2073..d89803d 100644
--- a/tempest/api/image/v2/test_images_member.py
+++ b/tempest/api/image/v2/test_images_member.py
@@ -19,15 +19,15 @@
@test.idempotent_id('5934c6ea-27dc-4d6e-9421-eeb5e045494a')
def test_image_share_accept(self):
image_id = self._create_image()
- member = self.os_img_client.add_member(image_id,
- self.alt_tenant_id)
+ 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_member_status(image_id,
- self.alt_tenant_id,
- 'accepted')
+ 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())
body = self.os_img_client.list_image_members(image_id)
members = body['members']
@@ -40,29 +40,29 @@
@test.idempotent_id('d9e83e5f-3524-4b38-a900-22abcb26e90e')
def test_image_share_reject(self):
image_id = self._create_image()
- member = self.os_img_client.add_member(image_id,
- self.alt_tenant_id)
+ 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_member_status(image_id,
- self.alt_tenant_id,
- 'rejected')
+ self.alt_img_client.update_image_member(image_id,
+ self.alt_tenant_id,
+ {'status': 'rejected'})
self.assertNotIn(image_id, self._list_image_ids_as_alt())
@test.idempotent_id('a6ee18b9-4378-465e-9ad9-9a6de58a3287')
def test_get_image_member(self):
image_id = self._create_image()
- self.os_img_client.add_member(image_id,
- self.alt_tenant_id)
- self.alt_img_client.update_member_status(image_id,
- self.alt_tenant_id,
- 'accepted')
+ self.os_img_client.add_image_member(image_id,
+ self.alt_tenant_id)
+ 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())
- member = self.os_img_client.get_member(image_id,
- self.alt_tenant_id)
+ member = self.os_img_client.show_image_member(image_id,
+ self.alt_tenant_id)
self.assertEqual(self.alt_tenant_id, member['member_id'])
self.assertEqual(image_id, member['image_id'])
self.assertEqual('accepted', member['status'])
@@ -70,22 +70,38 @@
@test.idempotent_id('72989bc7-2268-48ed-af22-8821e835c914')
def test_remove_image_member(self):
image_id = self._create_image()
- self.os_img_client.add_member(image_id,
- self.alt_tenant_id)
- self.alt_img_client.update_member_status(image_id,
- self.alt_tenant_id,
- 'accepted')
+ self.os_img_client.add_image_member(image_id,
+ self.alt_tenant_id)
+ 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_member(image_id, self.alt_tenant_id)
+ self.os_img_client.remove_image_member(image_id, self.alt_tenant_id)
self.assertNotIn(image_id, self._list_image_ids_as_alt())
@test.idempotent_id('634dcc3f-f6e2-4409-b8fd-354a0bb25d83')
def test_get_image_member_schema(self):
- body = self.os_img_client.get_schema("member")
+ body = self.os_img_client.show_schema("member")
self.assertEqual("member", body['name'])
@test.idempotent_id('6ae916ef-1052-4e11-8d36-b3ae14853cbb')
def test_get_image_members_schema(self):
- body = self.os_img_client.get_schema("members")
+ 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_member_negative.py b/tempest/api/image/v2/test_images_member_negative.py
index d95e5c1..ae8913c 100644
--- a/tempest/api/image/v2/test_images_member_negative.py
+++ b/tempest/api/image/v2/test_images_member_negative.py
@@ -22,22 +22,23 @@
@test.idempotent_id('b79efb37-820d-4cf0-b54c-308b00cf842c')
def test_image_share_invalid_status(self):
image_id = self._create_image()
- member = self.os_img_client.add_member(image_id,
- self.alt_tenant_id)
+ member = self.os_img_client.add_image_member(image_id,
+ self.alt_tenant_id)
self.assertEqual(member['status'], 'pending')
self.assertRaises(lib_exc.BadRequest,
- self.alt_img_client.update_member_status,
- image_id, self.alt_tenant_id, 'notavalidstatus')
+ self.alt_img_client.update_image_member,
+ image_id, self.alt_tenant_id,
+ {'status': 'notavalidstatus'})
@test.attr(type=['negative'])
@test.idempotent_id('27002f74-109e-4a37-acd0-f91cd4597967')
def test_image_share_owner_cannot_accept(self):
image_id = self._create_image()
- member = self.os_img_client.add_member(image_id,
- self.alt_tenant_id)
+ member = self.os_img_client.add_image_member(image_id,
+ self.alt_tenant_id)
self.assertEqual(member['status'], 'pending')
self.assertNotIn(image_id, self._list_image_ids_as_alt())
self.assertRaises(lib_exc.Forbidden,
- self.os_img_client.update_member_status,
- image_id, self.alt_tenant_id, 'accepted')
+ self.os_img_client.update_image_member,
+ image_id, self.alt_tenant_id, {'status': 'accepted'})
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 2dac346..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
@@ -33,7 +33,7 @@
@test.idempotent_id('9f1c4c72-80c5-4dac-acf3-188cef42e36c')
def test_create_delete_queue(self):
# Create & Delete Queue
- queue_name = data_utils.rand_name('test-')
+ queue_name = data_utils.rand_name('test')
_, body = self.create_queue(queue_name)
self.addCleanup(self.client.delete_queue, queue_name)
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 160cc06..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
@@ -27,6 +26,7 @@
class L3AgentSchedulerTestJSON(base.BaseAdminNetworkTest):
_agent_mode = 'legacy'
+ is_dvr_router = False
"""
Tests the following operations in the Neutron API using the REST client for
@@ -72,15 +72,22 @@
# query and setup steps are only required if the extension is available
# and only if the router's default type is distributed.
if test.is_extension_enabled('dvr', 'network'):
- is_dvr_router = cls.admin_client.show_router(
+ cls.is_dvr_router = cls.admin_client.show_router(
cls.router['id'])['router'].get('distributed', False)
- if is_dvr_router:
+ if cls.is_dvr_router:
cls.network = cls.create_network()
- cls.create_subnet(cls.network)
+ cls.subnet = cls.create_subnet(cls.network)
cls.port = cls.create_port(cls.network)
cls.client.add_router_interface_with_port_id(
cls.router['id'], cls.port['id'])
+ @classmethod
+ def resource_cleanup(cls):
+ if cls.is_dvr_router:
+ cls.client.remove_router_interface_with_port_id(
+ cls.router['id'], cls.port['id'])
+ super(L3AgentSchedulerTestJSON, cls).resource_cleanup()
+
@test.idempotent_id('b7ce6e89-e837-4ded-9b78-9ed3c9c6a45a')
def test_list_routers_on_l3_agent(self):
self.admin_client.list_routers_on_l3_agent(self.agent['id'])
diff --git a/tempest/api/network/admin/test_lbaas_agent_scheduler.py b/tempest/api/network/admin/test_lbaas_agent_scheduler.py
deleted file mode 100644
index 7234348..0000000
--- a/tempest/api/network/admin/test_lbaas_agent_scheduler.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# Copyright 2013 IBM Corp.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest_lib.common.utils import data_utils
-
-from tempest.api.network import base
-from tempest import test
-
-
-class LBaaSAgentSchedulerTestJSON(base.BaseAdminNetworkTest):
- """
- Tests the following operations in the Neutron API using the REST client for
- Neutron:
-
- List pools the given LBaaS agent is hosting.
- Show a LBaaS agent hosting the given pool.
-
- v2.0 of the Neutron API is assumed. It is also assumed that the following
- options are defined in the [networki-feature-enabled] section of
- etc/tempest.conf:
-
- api_extensions
- """
-
- @classmethod
- def skip_checks(cls):
- super(LBaaSAgentSchedulerTestJSON, cls).skip_checks()
- if not test.is_extension_enabled('lbaas_agent_scheduler', 'network'):
- msg = "LBaaS Agent Scheduler Extension not enabled."
- raise cls.skipException(msg)
-
- @classmethod
- def resource_setup(cls):
- super(LBaaSAgentSchedulerTestJSON, cls).resource_setup()
- cls.network = cls.create_network()
- cls.subnet = cls.create_subnet(cls.network)
- pool_name = data_utils.rand_name('pool-')
- cls.pool = cls.create_pool(pool_name, "ROUND_ROBIN",
- "HTTP", cls.subnet)
-
- @test.idempotent_id('e5ea8b15-4f44-4350-963c-e0fcb533ee79')
- def test_list_pools_on_lbaas_agent(self):
- found = False
- body = self.admin_client.list_agents(
- agent_type="Loadbalancer agent")
- agents = body['agents']
- for a in agents:
- msg = 'Load Balancer agent expected'
- self.assertEqual(a['agent_type'], 'Loadbalancer agent', msg)
- body = (
- self.admin_client.list_pools_hosted_by_one_lbaas_agent(
- a['id']))
- pools = body['pools']
- if self.pool['id'] in [p['id'] for p in pools]:
- found = True
- msg = 'Unable to find Load Balancer agent hosting pool'
- self.assertTrue(found, msg)
-
- @test.idempotent_id('e2745593-fd79-4b98-a262-575fd7865796')
- def test_show_lbaas_agent_hosting_pool(self):
- body = self.admin_client.show_lbaas_agent_hosting_pool(
- self.pool['id'])
- self.assertEqual('Loadbalancer agent', body['agent']['agent_type'])
diff --git a/tempest/api/network/admin/test_load_balancer_admin_actions.py b/tempest/api/network/admin/test_load_balancer_admin_actions.py
deleted file mode 100644
index 24a04be..0000000
--- a/tempest/api/network/admin/test_load_balancer_admin_actions.py
+++ /dev/null
@@ -1,118 +0,0 @@
-# Copyright 2014 Mirantis.inc
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest_lib.common.utils import data_utils
-
-from tempest.api.network import base
-from tempest import test
-
-
-class LoadBalancerAdminTestJSON(base.BaseAdminNetworkTest):
- """
- Test admin actions for load balancer.
-
- Create VIP for another tenant
- Create health monitor for another tenant
- """
-
- force_tenant_isolation = True
-
- @classmethod
- def skip_checks(cls):
- super(LoadBalancerAdminTestJSON, cls).skip_checks()
- if not test.is_extension_enabled('lbaas', 'network'):
- msg = "lbaas extension not enabled."
- raise cls.skipException(msg)
-
- @classmethod
- def setup_clients(cls):
- super(LoadBalancerAdminTestJSON, cls).setup_clients()
- cls.client = cls.manager.network_client
-
- @classmethod
- def resource_setup(cls):
- super(LoadBalancerAdminTestJSON, cls).resource_setup()
- cls.tenant_id = cls.os.credentials.tenant_id
- cls.network = cls.create_network()
- cls.subnet = cls.create_subnet(cls.network)
- cls.pool = cls.create_pool(data_utils.rand_name('pool-'),
- "ROUND_ROBIN", "HTTP", cls.subnet)
-
- @test.idempotent_id('6b0a20d8-4fcd-455e-b54f-ec4db5199518')
- def test_create_vip_as_admin_for_another_tenant(self):
- name = data_utils.rand_name('vip-')
- body = self.admin_client.create_pool(
- name=data_utils.rand_name('pool-'),
- lb_method="ROUND_ROBIN",
- protocol="HTTP",
- subnet_id=self.subnet['id'],
- tenant_id=self.tenant_id)
- pool = body['pool']
- self.addCleanup(self.admin_client.delete_pool, pool['id'])
- body = self.admin_client.create_vip(name=name,
- protocol="HTTP",
- protocol_port=80,
- subnet_id=self.subnet['id'],
- pool_id=pool['id'],
- tenant_id=self.tenant_id)
- vip = body['vip']
- self.addCleanup(self.admin_client.delete_vip, vip['id'])
- self.assertIsNotNone(vip['id'])
- self.assertEqual(self.tenant_id, vip['tenant_id'])
- body = self.client.show_vip(vip['id'])
- show_vip = body['vip']
- self.assertEqual(vip['id'], show_vip['id'])
- self.assertEqual(vip['name'], show_vip['name'])
-
- @test.idempotent_id('74552cfc-ab78-4fb6-825b-f67bca379921')
- def test_create_health_monitor_as_admin_for_another_tenant(self):
- body = (
- self.admin_client.create_health_monitor(delay=4,
- max_retries=3,
- type="TCP",
- timeout=1,
- tenant_id=self.tenant_id))
- health_monitor = body['health_monitor']
- self.addCleanup(self.admin_client.delete_health_monitor,
- health_monitor['id'])
- self.assertIsNotNone(health_monitor['id'])
- self.assertEqual(self.tenant_id, health_monitor['tenant_id'])
- body = self.client.show_health_monitor(health_monitor['id'])
- show_health_monitor = body['health_monitor']
- self.assertEqual(health_monitor['id'], show_health_monitor['id'])
-
- @test.idempotent_id('266a192d-3c22-46c4-a8fb-802450301e82')
- def test_create_pool_from_admin_user_other_tenant(self):
- body = self.admin_client.create_pool(
- name=data_utils.rand_name('pool-'),
- lb_method="ROUND_ROBIN",
- protocol="HTTP",
- subnet_id=self.subnet['id'],
- tenant_id=self.tenant_id)
- pool = body['pool']
- self.addCleanup(self.admin_client.delete_pool, pool['id'])
- self.assertIsNotNone(pool['id'])
- self.assertEqual(self.tenant_id, pool['tenant_id'])
-
- @test.idempotent_id('158bb272-b9ed-4cfc-803c-661dac46f783')
- def test_create_member_from_admin_user_other_tenant(self):
- body = self.admin_client.create_member(address="10.0.9.47",
- protocol_port=80,
- pool_id=self.pool['id'],
- tenant_id=self.tenant_id)
- member = body['member']
- self.addCleanup(self.admin_client.delete_member, member['id'])
- self.assertIsNotNone(member['id'])
- self.assertEqual(self.tenant_id, member['tenant_id'])
diff --git a/tempest/api/network/admin/test_quotas.py b/tempest/api/network/admin/test_quotas.py
index 46d6651..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])
@@ -90,10 +90,3 @@
def test_quotas(self):
new_quotas = {'network': 0, 'security_group': 0}
self._check_quotas(new_quotas)
-
- @test.idempotent_id('a7add2b1-691e-44d6-875f-697d9685f091')
- @test.requires_ext(extension='lbaas', service='network')
- def test_lbaas_quotas(self):
- new_quotas = {'vip': 1, 'pool': 2,
- 'member': 3, 'health_monitor': 4}
- self._check_quotas(new_quotas)
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 f864f95..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
@@ -82,64 +82,19 @@
cls.subnets = []
cls.ports = []
cls.routers = []
- cls.pools = []
- cls.vips = []
- cls.members = []
- cls.health_monitors = []
- cls.vpnservices = []
- cls.ikepolicies = []
cls.floating_ips = []
cls.metering_labels = []
cls.metering_label_rules = []
- cls.fw_rules = []
- cls.fw_policies = []
- cls.ipsecpolicies = []
cls.ethertype = "IPv" + str(cls._ip_version)
@classmethod
def resource_cleanup(cls):
if CONF.service_available.neutron:
- # Clean up ipsec policies
- for ipsecpolicy in cls.ipsecpolicies:
- cls._try_delete_resource(cls.client.delete_ipsecpolicy,
- ipsecpolicy['id'])
- # Clean up firewall policies
- for fw_policy in cls.fw_policies:
- cls._try_delete_resource(cls.client.delete_firewall_policy,
- fw_policy['id'])
- # Clean up firewall rules
- for fw_rule in cls.fw_rules:
- cls._try_delete_resource(cls.client.delete_firewall_rule,
- fw_rule['id'])
- # Clean up ike policies
- for ikepolicy in cls.ikepolicies:
- cls._try_delete_resource(cls.client.delete_ikepolicy,
- ikepolicy['id'])
- # Clean up vpn services
- for vpnservice in cls.vpnservices:
- cls._try_delete_resource(cls.client.delete_vpnservice,
- vpnservice['id'])
# Clean up floating IPs
for floating_ip in cls.floating_ips:
cls._try_delete_resource(cls.client.delete_floatingip,
floating_ip['id'])
- # Clean up health monitors
- for health_monitor in cls.health_monitors:
- cls._try_delete_resource(cls.client.delete_health_monitor,
- health_monitor['id'])
- # Clean up members
- for member in cls.members:
- cls._try_delete_resource(cls.client.delete_member,
- member['id'])
- # Clean up vips
- for vip in cls.vips:
- cls._try_delete_resource(cls.client.delete_vip,
- vip['id'])
- # Clean up pools
- for pool in cls.pools:
- cls._try_delete_resource(cls.client.delete_pool,
- pool['id'])
# Clean up metering label rules
for metering_label_rule in cls.metering_label_rules:
cls._try_delete_resource(
@@ -284,78 +239,6 @@
return fip
@classmethod
- def create_pool(cls, name, lb_method, protocol, subnet):
- """Wrapper utility that returns a test pool."""
- body = cls.client.create_pool(
- name=name,
- lb_method=lb_method,
- protocol=protocol,
- subnet_id=subnet['id'])
- pool = body['pool']
- cls.pools.append(pool)
- return pool
-
- @classmethod
- def update_pool(cls, name):
- """Wrapper utility that returns a test pool."""
- body = cls.client.update_pool(name=name)
- pool = body['pool']
- return pool
-
- @classmethod
- def create_vip(cls, name, protocol, protocol_port, subnet, pool):
- """Wrapper utility that returns a test vip."""
- body = cls.client.create_vip(name=name,
- protocol=protocol,
- protocol_port=protocol_port,
- subnet_id=subnet['id'],
- pool_id=pool['id'])
- vip = body['vip']
- cls.vips.append(vip)
- return vip
-
- @classmethod
- def update_vip(cls, name):
- body = cls.client.update_vip(name=name)
- vip = body['vip']
- return vip
-
- @classmethod
- def create_member(cls, protocol_port, pool, ip_version=None):
- """Wrapper utility that returns a test member."""
- ip_version = ip_version if ip_version is not None else cls._ip_version
- member_address = "fd00::abcd" if ip_version == 6 else "10.0.9.46"
- body = cls.client.create_member(address=member_address,
- protocol_port=protocol_port,
- pool_id=pool['id'])
- member = body['member']
- cls.members.append(member)
- return member
-
- @classmethod
- def update_member(cls, admin_state_up):
- body = cls.client.update_member(admin_state_up=admin_state_up)
- member = body['member']
- return member
-
- @classmethod
- def create_health_monitor(cls, delay, max_retries, Type, timeout):
- """Wrapper utility that returns a test health monitor."""
- body = cls.client.create_health_monitor(delay=delay,
- max_retries=max_retries,
- type=Type,
- timeout=timeout)
- health_monitor = body['health_monitor']
- cls.health_monitors.append(health_monitor)
- return health_monitor
-
- @classmethod
- def update_health_monitor(cls, admin_state_up):
- body = cls.client.update_vip(admin_state_up=admin_state_up)
- health_monitor = body['health_monitor']
- return health_monitor
-
- @classmethod
def create_router_interface(cls, router_id, subnet_id):
"""Wrapper utility that returns a router interface."""
interface = cls.client.add_router_interface_with_subnet_id(
@@ -363,44 +246,6 @@
return interface
@classmethod
- def create_vpnservice(cls, subnet_id, router_id):
- """Wrapper utility that returns a test vpn service."""
- body = cls.client.create_vpnservice(
- subnet_id=subnet_id, router_id=router_id, admin_state_up=True,
- name=data_utils.rand_name("vpnservice-"))
- vpnservice = body['vpnservice']
- cls.vpnservices.append(vpnservice)
- return vpnservice
-
- @classmethod
- def create_ikepolicy(cls, name):
- """Wrapper utility that returns a test ike policy."""
- body = cls.client.create_ikepolicy(name=name)
- ikepolicy = body['ikepolicy']
- cls.ikepolicies.append(ikepolicy)
- return ikepolicy
-
- @classmethod
- def create_firewall_rule(cls, action, protocol):
- """Wrapper utility that returns a test firewall rule."""
- body = cls.client.create_firewall_rule(
- name=data_utils.rand_name("fw-rule"),
- action=action,
- protocol=protocol)
- fw_rule = body['firewall_rule']
- cls.fw_rules.append(fw_rule)
- return fw_rule
-
- @classmethod
- def create_firewall_policy(cls):
- """Wrapper utility that returns a test firewall policy."""
- body = cls.client.create_firewall_policy(
- name=data_utils.rand_name("fw-policy"))
- fw_policy = body['firewall_policy']
- cls.fw_policies.append(fw_policy)
- return fw_policy
-
- @classmethod
def delete_router(cls, router):
body = cls.client.list_router_interfaces(router['id'])
interfaces = body['ports']
@@ -412,14 +257,6 @@
pass
cls.client.delete_router(router['id'])
- @classmethod
- def create_ipsecpolicy(cls, name):
- """Wrapper utility that returns a test ipsec policy."""
- body = cls.client.create_ipsecpolicy(name=name)
- ipsecpolicy = body['ipsecpolicy']
- cls.ipsecpolicies.append(ipsecpolicy)
- return ipsecpolicy
-
class BaseAdminNetworkTest(BaseNetworkTest):
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_extensions.py b/tempest/api/network/test_extensions.py
index e9f1bf4..be7174b 100644
--- a/tempest/api/network/test_extensions.py
+++ b/tempest/api/network/test_extensions.py
@@ -57,7 +57,6 @@
self.assertIn('updated', ext_details.keys())
self.assertIn('name', ext_details.keys())
self.assertIn('description', ext_details.keys())
- self.assertIn('namespace', ext_details.keys())
self.assertIn('links', ext_details.keys())
self.assertIn('alias', ext_details.keys())
self.assertEqual(ext_details['name'], ext_name)
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_fwaas_extensions.py b/tempest/api/network/test_fwaas_extensions.py
deleted file mode 100644
index 651b4ab..0000000
--- a/tempest/api/network/test_fwaas_extensions.py
+++ /dev/null
@@ -1,333 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import 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 import config
-from tempest import exceptions
-from tempest import test
-
-CONF = config.CONF
-
-
-class FWaaSExtensionTestJSON(base.BaseNetworkTest):
- """
- Tests the following operations in the Neutron API using the REST client for
- Neutron:
-
- List firewall rules
- Create firewall rule
- Update firewall rule
- Delete firewall rule
- Show firewall rule
- List firewall policies
- Create firewall policy
- Update firewall policy
- Insert firewall rule to policy
- Remove firewall rule from policy
- Insert firewall rule after/before rule in policy
- Update firewall policy audited attribute
- Delete firewall policy
- Show firewall policy
- List firewall
- Create firewall
- Update firewall
- Delete firewall
- Show firewall
- """
-
- @classmethod
- def skip_checks(cls):
- super(FWaaSExtensionTestJSON, cls).skip_checks()
- if not test.is_extension_enabled('fwaas', 'network'):
- msg = "FWaaS Extension not enabled."
- raise cls.skipException(msg)
-
- @classmethod
- def resource_setup(cls):
- super(FWaaSExtensionTestJSON, cls).resource_setup()
- cls.fw_rule = cls.create_firewall_rule("allow", "tcp")
- cls.fw_policy = cls.create_firewall_policy()
-
- def _try_delete_policy(self, policy_id):
- # delete policy, if it exists
- try:
- self.client.delete_firewall_policy(policy_id)
- # if policy is not found, this means it was deleted in the test
- except lib_exc.NotFound:
- pass
-
- def _try_delete_rule(self, rule_id):
- # delete rule, if it exists
- try:
- self.client.delete_firewall_rule(rule_id)
- # if rule is not found, this means it was deleted in the test
- except lib_exc.NotFound:
- pass
-
- def _try_delete_firewall(self, fw_id):
- # delete firewall, if it exists
- try:
- self.client.delete_firewall(fw_id)
- # if firewall is not found, this means it was deleted in the test
- except lib_exc.NotFound:
- pass
-
- self.client.wait_for_resource_deletion('firewall', fw_id)
-
- def _wait_until_ready(self, fw_id):
- target_states = ('ACTIVE', 'CREATED')
-
- def _wait():
- firewall = self.client.show_firewall(fw_id)
- firewall = firewall['firewall']
- return firewall['status'] in target_states
-
- if not test.call_until_true(_wait, CONF.network.build_timeout,
- CONF.network.build_interval):
- status = self.client.show_firewall(fw_id)['firewall']['status']
- m = ("Timed out waiting for firewall %s to reach %s state(s) "
- "after %ss, currently in %s state." %
- (fw_id,
- target_states,
- CONF.network.build_interval,
- status))
- raise exceptions.TimeoutException(m)
-
- @test.idempotent_id('1b84cf01-9c09-4ce7-bc72-b15e39076468')
- def test_list_firewall_rules(self):
- # List firewall rules
- fw_rules = self.client.list_firewall_rules()
- fw_rules = fw_rules['firewall_rules']
- self.assertIn((self.fw_rule['id'],
- self.fw_rule['name'],
- self.fw_rule['action'],
- self.fw_rule['protocol'],
- self.fw_rule['ip_version'],
- self.fw_rule['enabled']),
- [(m['id'],
- m['name'],
- m['action'],
- m['protocol'],
- m['ip_version'],
- m['enabled']) for m in fw_rules])
-
- @test.idempotent_id('563564f7-7077-4f5e-8cdc-51f37ae5a2b9')
- def test_create_update_delete_firewall_rule(self):
- # Create firewall rule
- body = self.client.create_firewall_rule(
- name=data_utils.rand_name("fw-rule"),
- action="allow",
- protocol="tcp")
- fw_rule_id = body['firewall_rule']['id']
-
- # Update firewall rule
- body = self.client.update_firewall_rule(fw_rule_id,
- shared=True)
- self.assertTrue(body["firewall_rule"]['shared'])
-
- # Delete firewall rule
- self.client.delete_firewall_rule(fw_rule_id)
- # Confirm deletion
- fw_rules = self.client.list_firewall_rules()
- self.assertNotIn(fw_rule_id,
- [m['id'] for m in fw_rules['firewall_rules']])
-
- @test.idempotent_id('3ff8c08e-26ff-4034-ae48-810ed213a998')
- def test_show_firewall_rule(self):
- # show a created firewall rule
- fw_rule = self.client.show_firewall_rule(self.fw_rule['id'])
- for key, value in six.iteritems(fw_rule['firewall_rule']):
- self.assertEqual(self.fw_rule[key], value)
-
- @test.idempotent_id('1086dd93-a4c0-4bbb-a1bd-6d4bc62c199f')
- def test_list_firewall_policies(self):
- fw_policies = self.client.list_firewall_policies()
- fw_policies = fw_policies['firewall_policies']
- self.assertIn((self.fw_policy['id'],
- self.fw_policy['name'],
- self.fw_policy['firewall_rules']),
- [(m['id'],
- m['name'],
- m['firewall_rules']) for m in fw_policies])
-
- @test.idempotent_id('bbf37b6c-498c-421e-9c95-45897d3ed775')
- def test_create_update_delete_firewall_policy(self):
- # Create firewall policy
- body = self.client.create_firewall_policy(
- name=data_utils.rand_name("fw-policy"))
- fw_policy_id = body['firewall_policy']['id']
- self.addCleanup(self._try_delete_policy, fw_policy_id)
-
- # Update firewall policy
- body = self.client.update_firewall_policy(fw_policy_id,
- shared=True,
- name="updated_policy")
- updated_fw_policy = body["firewall_policy"]
- self.assertTrue(updated_fw_policy['shared'])
- self.assertEqual("updated_policy", updated_fw_policy['name'])
-
- # Delete firewall policy
- self.client.delete_firewall_policy(fw_policy_id)
- # Confirm deletion
- fw_policies = self.client.list_firewall_policies()
- fw_policies = fw_policies['firewall_policies']
- self.assertNotIn(fw_policy_id, [m['id'] for m in fw_policies])
-
- @test.idempotent_id('1df59b3a-517e-41d4-96f6-fc31cf4ecff2')
- def test_show_firewall_policy(self):
- # show a created firewall policy
- fw_policy = self.client.show_firewall_policy(self.fw_policy['id'])
- fw_policy = fw_policy['firewall_policy']
- for key, value in six.iteritems(fw_policy):
- self.assertEqual(self.fw_policy[key], value)
-
- @test.idempotent_id('02082a03-3cdd-4789-986a-1327dd80bfb7')
- def test_create_show_delete_firewall(self):
- # Create tenant network resources required for an ACTIVE firewall
- network = self.create_network()
- subnet = self.create_subnet(network)
- router = self.create_router(
- data_utils.rand_name('router-'),
- admin_state_up=True)
- self.client.add_router_interface_with_subnet_id(
- router['id'], subnet['id'])
-
- # Create firewall
- body = self.client.create_firewall(
- name=data_utils.rand_name("firewall"),
- firewall_policy_id=self.fw_policy['id'])
- created_firewall = body['firewall']
- firewall_id = created_firewall['id']
- self.addCleanup(self._try_delete_firewall, firewall_id)
-
- # Wait for the firewall resource to become ready
- self._wait_until_ready(firewall_id)
-
- # show a created firewall
- firewall = self.client.show_firewall(firewall_id)
- firewall = firewall['firewall']
-
- for key, value in six.iteritems(firewall):
- if key == 'status':
- continue
- self.assertEqual(created_firewall[key], value)
-
- # list firewall
- firewalls = self.client.list_firewalls()
- firewalls = firewalls['firewalls']
- self.assertIn((created_firewall['id'],
- created_firewall['name'],
- created_firewall['firewall_policy_id']),
- [(m['id'],
- m['name'],
- m['firewall_policy_id']) for m in firewalls])
-
- # Delete firewall
- self.client.delete_firewall(firewall_id)
-
- @test.idempotent_id('53305b4b-9897-4e01-87c0-2ae386083180')
- def test_firewall_rule_insertion_position_removal_rule_from_policy(self):
- # Create firewall rule
- body = self.client.create_firewall_rule(
- name=data_utils.rand_name("fw-rule"),
- action="allow",
- protocol="tcp")
- fw_rule_id1 = body['firewall_rule']['id']
- self.addCleanup(self._try_delete_rule, fw_rule_id1)
- # Create firewall policy
- body = self.client.create_firewall_policy(
- name=data_utils.rand_name("fw-policy"))
- fw_policy_id = body['firewall_policy']['id']
- self.addCleanup(self._try_delete_policy, fw_policy_id)
-
- # Insert rule to firewall policy
- self.client.insert_firewall_rule_in_policy(
- fw_policy_id, fw_rule_id1, '', '')
-
- # Verify insertion of rule in policy
- self.assertIn(fw_rule_id1, self._get_list_fw_rule_ids(fw_policy_id))
- # Create another firewall rule
- body = self.client.create_firewall_rule(
- name=data_utils.rand_name("fw-rule"),
- action="allow",
- protocol="icmp")
- fw_rule_id2 = body['firewall_rule']['id']
- self.addCleanup(self._try_delete_rule, fw_rule_id2)
-
- # Insert rule to firewall policy after the first rule
- self.client.insert_firewall_rule_in_policy(
- fw_policy_id, fw_rule_id2, fw_rule_id1, '')
-
- # Verify the posiition of rule after insertion
- fw_rule = self.client.show_firewall_rule(
- fw_rule_id2)
-
- self.assertEqual(int(fw_rule['firewall_rule']['position']), 2)
- # Remove rule from the firewall policy
- self.client.remove_firewall_rule_from_policy(
- fw_policy_id, fw_rule_id2)
- # Insert rule to firewall policy before the first rule
- self.client.insert_firewall_rule_in_policy(
- fw_policy_id, fw_rule_id2, '', fw_rule_id1)
- # Verify the posiition of rule after insertion
- fw_rule = self.client.show_firewall_rule(
- fw_rule_id2)
- self.assertEqual(int(fw_rule['firewall_rule']['position']), 1)
- # Remove rule from the firewall policy
- self.client.remove_firewall_rule_from_policy(
- fw_policy_id, fw_rule_id2)
- # Verify removal of rule from firewall policy
- self.assertNotIn(fw_rule_id2, self._get_list_fw_rule_ids(fw_policy_id))
-
- # Remove rule from the firewall policy
- self.client.remove_firewall_rule_from_policy(
- fw_policy_id, fw_rule_id1)
-
- # Verify removal of rule from firewall policy
- self.assertNotIn(fw_rule_id1, self._get_list_fw_rule_ids(fw_policy_id))
-
- def _get_list_fw_rule_ids(self, fw_policy_id):
- fw_policy = self.client.show_firewall_policy(
- fw_policy_id)
- return [ruleid for ruleid in fw_policy['firewall_policy']
- ['firewall_rules']]
-
- @test.idempotent_id('8515ca8a-0d2f-4298-b5ff-6f924e4587ca')
- def test_update_firewall_policy_audited_attribute(self):
- # Create firewall rule
- body = self.client.create_firewall_rule(
- name=data_utils.rand_name("fw-rule"),
- action="allow",
- protocol="icmp")
- fw_rule_id = body['firewall_rule']['id']
- self.addCleanup(self._try_delete_rule, fw_rule_id)
- # Create firewall policy
- body = self.client.create_firewall_policy(
- name=data_utils.rand_name('fw-policy'))
- fw_policy_id = body['firewall_policy']['id']
- self.addCleanup(self._try_delete_policy, fw_policy_id)
- self.assertFalse(body['firewall_policy']['audited'])
- # Update firewall policy audited attribute to ture
- self.client.update_firewall_policy(fw_policy_id,
- audited=True)
- # Insert Firewall rule to firewall policy
- self.client.insert_firewall_rule_in_policy(
- fw_policy_id, fw_rule_id, '', '')
- body = self.client.show_firewall_policy(
- fw_policy_id)
- self.assertFalse(body['firewall_policy']['audited'])
diff --git a/tempest/api/network/test_load_balancer.py b/tempest/api/network/test_load_balancer.py
deleted file mode 100644
index 38a6fe9..0000000
--- a/tempest/api/network/test_load_balancer.py
+++ /dev/null
@@ -1,432 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import six
-from tempest_lib.common.utils import data_utils
-from tempest_lib import decorators
-
-from tempest.api.network import base
-from tempest import test
-
-
-class LoadBalancerTestJSON(base.BaseNetworkTest):
- """
- Tests the following operations in the Neutron API using the REST client for
- Neutron:
-
- create vIP, and Pool
- show vIP
- list vIP
- update vIP
- delete vIP
- update pool
- delete pool
- show pool
- list pool
- health monitoring operations
- """
-
- @classmethod
- def skip_checks(cls):
- super(LoadBalancerTestJSON, cls).skip_checks()
- if not test.is_extension_enabled('lbaas', 'network'):
- msg = "lbaas extension not enabled."
- raise cls.skipException(msg)
-
- @classmethod
- def resource_setup(cls):
- super(LoadBalancerTestJSON, cls).resource_setup()
- cls.network = cls.create_network()
- cls.name = cls.network['name']
- cls.subnet = cls.create_subnet(cls.network)
- pool_name = data_utils.rand_name('pool-')
- vip_name = data_utils.rand_name('vip-')
- cls.pool = cls.create_pool(pool_name, "ROUND_ROBIN",
- "HTTP", cls.subnet)
- cls.vip = cls.create_vip(name=vip_name,
- protocol="HTTP",
- protocol_port=80,
- subnet=cls.subnet,
- pool=cls.pool)
- cls.member = cls.create_member(80, cls.pool, cls._ip_version)
- cls.member_address = ("10.0.9.47" if cls._ip_version == 4
- else "2015::beef")
- cls.health_monitor = cls.create_health_monitor(delay=4,
- max_retries=3,
- Type="TCP",
- timeout=1)
-
- def _check_list_with_filter(self, obj_name, attr_exceptions, **kwargs):
- create_obj = getattr(self.client, 'create_' + obj_name)
- delete_obj = getattr(self.client, 'delete_' + obj_name)
- list_objs = getattr(self.client, 'list_' + obj_name + 's')
-
- body = create_obj(**kwargs)
- obj = body[obj_name]
- self.addCleanup(delete_obj, obj['id'])
- for key, value in six.iteritems(obj):
- # It is not relevant to filter by all arguments. That is why
- # there is a list of attr to except
- if key not in attr_exceptions:
- body = list_objs(**{key: value})
- objs = [v[key] for v in body[obj_name + 's']]
- self.assertIn(value, objs)
-
- @test.idempotent_id('c96dbfab-4a80-4e74-a535-e950b5bedd47')
- def test_list_vips(self):
- # Verify the vIP exists in the list of all vIPs
- body = self.client.list_vips()
- vips = body['vips']
- self.assertIn(self.vip['id'], [v['id'] for v in vips])
-
- @test.idempotent_id('b8853f65-5089-4e69-befd-041a143427ff')
- def test_list_vips_with_filter(self):
- name = data_utils.rand_name('vip-')
- body = self.client.create_pool(name=data_utils.rand_name("pool-"),
- lb_method="ROUND_ROBIN",
- protocol="HTTPS",
- subnet_id=self.subnet['id'])
- pool = body['pool']
- self.addCleanup(self.client.delete_pool, pool['id'])
- attr_exceptions = ['status', 'session_persistence',
- 'status_description']
- self._check_list_with_filter(
- 'vip', attr_exceptions, name=name, protocol="HTTPS",
- protocol_port=81, subnet_id=self.subnet['id'], pool_id=pool['id'],
- description=data_utils.rand_name('description-'),
- admin_state_up=False)
-
- @test.idempotent_id('27f56083-9af9-4a48-abe9-ca1bcc6c9035')
- def test_create_update_delete_pool_vip(self):
- # Creates a vip
- name = data_utils.rand_name('vip-')
- address = self.subnet['allocation_pools'][0]['end']
- body = self.client.create_pool(
- name=data_utils.rand_name("pool-"),
- lb_method='ROUND_ROBIN',
- protocol='HTTP',
- subnet_id=self.subnet['id'])
- pool = body['pool']
- body = self.client.create_vip(name=name,
- protocol="HTTP",
- protocol_port=80,
- subnet_id=self.subnet['id'],
- pool_id=pool['id'],
- address=address)
- vip = body['vip']
- vip_id = vip['id']
- # Confirm VIP's address correctness with a show
- body = self.client.show_vip(vip_id)
- vip = body['vip']
- self.assertEqual(address, vip['address'])
- # Verification of vip update
- new_name = "New_vip"
- new_description = "New description"
- persistence_type = "HTTP_COOKIE"
- update_data = {"session_persistence": {
- "type": persistence_type}}
- body = self.client.update_vip(vip_id,
- name=new_name,
- description=new_description,
- connection_limit=10,
- admin_state_up=False,
- **update_data)
- updated_vip = body['vip']
- self.assertEqual(new_name, updated_vip['name'])
- self.assertEqual(new_description, updated_vip['description'])
- self.assertEqual(10, updated_vip['connection_limit'])
- self.assertFalse(updated_vip['admin_state_up'])
- self.assertEqual(persistence_type,
- updated_vip['session_persistence']['type'])
- self.client.delete_vip(vip['id'])
- self.client.wait_for_resource_deletion('vip', vip['id'])
- # Verification of pool update
- new_name = "New_pool"
- body = self.client.update_pool(pool['id'],
- name=new_name,
- description="new_description",
- lb_method='LEAST_CONNECTIONS')
- updated_pool = body['pool']
- self.assertEqual(new_name, updated_pool['name'])
- self.assertEqual('new_description', updated_pool['description'])
- self.assertEqual('LEAST_CONNECTIONS', updated_pool['lb_method'])
- self.client.delete_pool(pool['id'])
-
- @test.idempotent_id('0435a95e-1d19-4d90-9e9f-3b979e9ad089')
- def test_show_vip(self):
- # Verifies the details of a vip
- body = self.client.show_vip(self.vip['id'])
- vip = body['vip']
- for key, value in six.iteritems(vip):
- # 'status' should not be confirmed in api tests
- if key != 'status':
- self.assertEqual(self.vip[key], value)
-
- @test.idempotent_id('6e7a7d31-8451-456d-b24a-e50479ce42a7')
- def test_show_pool(self):
- # Here we need to new pool without any dependence with vips
- body = self.client.create_pool(name=data_utils.rand_name("pool-"),
- lb_method='ROUND_ROBIN',
- protocol='HTTP',
- subnet_id=self.subnet['id'])
- pool = body['pool']
- self.addCleanup(self.client.delete_pool, pool['id'])
- # Verifies the details of a pool
- body = self.client.show_pool(pool['id'])
- shown_pool = body['pool']
- for key, value in six.iteritems(pool):
- # 'status' should not be confirmed in api tests
- if key != 'status':
- self.assertEqual(value, shown_pool[key])
-
- @test.idempotent_id('d1ab1ffa-e06a-487f-911f-56418cb27727')
- def test_list_pools(self):
- # Verify the pool exists in the list of all pools
- body = self.client.list_pools()
- pools = body['pools']
- self.assertIn(self.pool['id'], [p['id'] for p in pools])
-
- @test.idempotent_id('27cc4c1a-caac-4273-b983-2acb4afaad4f')
- def test_list_pools_with_filters(self):
- attr_exceptions = ['status', 'vip_id', 'members', 'provider',
- 'status_description']
- self._check_list_with_filter(
- 'pool', attr_exceptions, name=data_utils.rand_name("pool-"),
- lb_method="ROUND_ROBIN", protocol="HTTPS",
- subnet_id=self.subnet['id'],
- description=data_utils.rand_name('description-'),
- admin_state_up=False)
-
- @test.idempotent_id('282d0dfd-5c3a-4c9b-b39c-c99782f39193')
- def test_list_members(self):
- # Verify the member exists in the list of all members
- body = self.client.list_members()
- members = body['members']
- self.assertIn(self.member['id'], [m['id'] for m in members])
-
- @test.idempotent_id('243b5126-24c6-4879-953e-7c7e32d8a57f')
- def test_list_members_with_filters(self):
- attr_exceptions = ['status', 'status_description']
- self._check_list_with_filter('member', attr_exceptions,
- address=self.member_address,
- protocol_port=80,
- pool_id=self.pool['id'])
-
- @test.idempotent_id('fb833ee8-9e69-489f-b540-a409762b78b2')
- def test_create_update_delete_member(self):
- # Creates a member
- body = self.client.create_member(address=self.member_address,
- protocol_port=80,
- pool_id=self.pool['id'])
- member = body['member']
- # Verification of member update
- body = self.client.update_member(member['id'],
- admin_state_up=False)
- updated_member = body['member']
- self.assertFalse(updated_member['admin_state_up'])
- # Verification of member delete
- self.client.delete_member(member['id'])
-
- @test.idempotent_id('893cd71f-a7dd-4485-b162-f6ab9a534914')
- def test_show_member(self):
- # Verifies the details of a member
- body = self.client.show_member(self.member['id'])
- member = body['member']
- for key, value in six.iteritems(member):
- # 'status' should not be confirmed in api tests
- if key != 'status':
- self.assertEqual(self.member[key], value)
-
- @test.idempotent_id('8e5822c5-68a4-4224-8d6c-a617741ebc2d')
- def test_list_health_monitors(self):
- # Verify the health monitor exists in the list of all health monitors
- body = self.client.list_health_monitors()
- health_monitors = body['health_monitors']
- self.assertIn(self.health_monitor['id'],
- [h['id'] for h in health_monitors])
-
- @test.idempotent_id('49bac58a-511c-4875-b794-366698211d25')
- def test_list_health_monitors_with_filters(self):
- attr_exceptions = ['status', 'status_description', 'pools']
- self._check_list_with_filter('health_monitor', attr_exceptions,
- delay=5, max_retries=4, type="TCP",
- timeout=2)
-
- @test.idempotent_id('e8ce05c4-d554-4d1e-a257-ad32ce134bb5')
- def test_create_update_delete_health_monitor(self):
- # Creates a health_monitor
- body = self.client.create_health_monitor(delay=4,
- max_retries=3,
- type="TCP",
- timeout=1)
- health_monitor = body['health_monitor']
- # Verification of health_monitor update
- body = (self.client.update_health_monitor
- (health_monitor['id'],
- admin_state_up=False))
- updated_health_monitor = body['health_monitor']
- self.assertFalse(updated_health_monitor['admin_state_up'])
- # Verification of health_monitor delete
- body = self.client.delete_health_monitor(health_monitor['id'])
-
- @test.idempotent_id('d3e1aebc-06c2-49b3-9816-942af54012eb')
- def test_create_health_monitor_http_type(self):
- hm_type = "HTTP"
- body = self.client.create_health_monitor(delay=4,
- max_retries=3,
- type=hm_type,
- timeout=1)
- health_monitor = body['health_monitor']
- self.addCleanup(self.client.delete_health_monitor,
- health_monitor['id'])
- self.assertEqual(hm_type, health_monitor['type'])
-
- @test.idempotent_id('0eff9f67-90fb-4bb1-b4ed-c5fda99fff0c')
- def test_update_health_monitor_http_method(self):
- body = self.client.create_health_monitor(delay=4,
- max_retries=3,
- type="HTTP",
- timeout=1)
- health_monitor = body['health_monitor']
- self.addCleanup(self.client.delete_health_monitor,
- health_monitor['id'])
- body = (self.client.update_health_monitor
- (health_monitor['id'],
- http_method="POST",
- url_path="/home/user",
- expected_codes="290"))
- updated_health_monitor = body['health_monitor']
- self.assertEqual("POST", updated_health_monitor['http_method'])
- self.assertEqual("/home/user", updated_health_monitor['url_path'])
- self.assertEqual("290", updated_health_monitor['expected_codes'])
-
- @test.idempotent_id('08e126ab-1407-483f-a22e-b11cc032ca7c')
- def test_show_health_monitor(self):
- # Verifies the details of a health_monitor
- body = self.client.show_health_monitor(self.health_monitor['id'])
- health_monitor = body['health_monitor']
- for key, value in six.iteritems(health_monitor):
- # 'status' should not be confirmed in api tests
- if key != 'status':
- self.assertEqual(self.health_monitor[key], value)
-
- @test.idempotent_id('87f7628e-8918-493d-af50-0602845dbb5b')
- def test_associate_disassociate_health_monitor_with_pool(self):
- # Verify that a health monitor can be associated with a pool
- self.client.associate_health_monitor_with_pool(
- self.health_monitor['id'], self.pool['id'])
- body = self.client.show_health_monitor(
- self.health_monitor['id'])
- health_monitor = body['health_monitor']
- body = self.client.show_pool(self.pool['id'])
- pool = body['pool']
- self.assertIn(pool['id'],
- [p['pool_id'] for p in health_monitor['pools']])
- self.assertIn(health_monitor['id'], pool['health_monitors'])
- # Verify that a health monitor can be disassociated from a pool
- (self.client.disassociate_health_monitor_with_pool
- (self.health_monitor['id'], self.pool['id']))
- body = self.client.show_pool(self.pool['id'])
- pool = body['pool']
- body = self.client.show_health_monitor(
- self.health_monitor['id'])
- health_monitor = body['health_monitor']
- self.assertNotIn(health_monitor['id'], pool['health_monitors'])
- self.assertNotIn(pool['id'],
- [p['pool_id'] for p in health_monitor['pools']])
-
- @test.idempotent_id('525fc7dc-be24-408d-938d-822e9783e027')
- def test_get_lb_pool_stats(self):
- # Verify the details of pool stats
- body = self.client.list_lb_pool_stats(self.pool['id'])
- stats = body['stats']
- self.assertIn("bytes_in", stats)
- self.assertIn("total_connections", stats)
- self.assertIn("active_connections", stats)
- self.assertIn("bytes_out", stats)
-
- @test.idempotent_id('66236be2-5121-4047-8cde-db4b83b110a5')
- def test_update_list_of_health_monitors_associated_with_pool(self):
- (self.client.associate_health_monitor_with_pool
- (self.health_monitor['id'], self.pool['id']))
- self.client.update_health_monitor(
- self.health_monitor['id'], admin_state_up=False)
- body = self.client.show_pool(self.pool['id'])
- health_monitors = body['pool']['health_monitors']
- for health_monitor_id in health_monitors:
- body = self.client.show_health_monitor(health_monitor_id)
- self.assertFalse(body['health_monitor']['admin_state_up'])
- (self.client.disassociate_health_monitor_with_pool
- (self.health_monitor['id'], self.pool['id']))
-
- @test.idempotent_id('44ec9b40-b501-41e2-951f-4fc673b15ac0')
- def test_update_admin_state_up_of_pool(self):
- self.client.update_pool(self.pool['id'],
- admin_state_up=False)
- body = self.client.show_pool(self.pool['id'])
- pool = body['pool']
- self.assertFalse(pool['admin_state_up'])
-
- @test.idempotent_id('466a9d4c-37c6-4ea2-b807-133437beb48c')
- def test_show_vip_associated_with_pool(self):
- body = self.client.show_pool(self.pool['id'])
- pool = body['pool']
- body = self.client.show_vip(pool['vip_id'])
- vip = body['vip']
- self.assertEqual(self.vip['name'], vip['name'])
- self.assertEqual(self.vip['id'], vip['id'])
-
- @test.idempotent_id('7b97694e-69d0-4151-b265-e1052a465aa8')
- def test_show_members_associated_with_pool(self):
- body = self.client.show_pool(self.pool['id'])
- members = body['pool']['members']
- for member_id in members:
- body = self.client.show_member(member_id)
- self.assertIsNotNone(body['member']['status'])
- self.assertEqual(member_id, body['member']['id'])
- self.assertIsNotNone(body['member']['admin_state_up'])
-
- @test.idempotent_id('73ed6f27-595b-4b2c-969c-dbdda6b8ab34')
- def test_update_pool_related_to_member(self):
- # Create new pool
- body = self.client.create_pool(name=data_utils.rand_name("pool-"),
- lb_method='ROUND_ROBIN',
- protocol='HTTP',
- subnet_id=self.subnet['id'])
- new_pool = body['pool']
- self.addCleanup(self.client.delete_pool, new_pool['id'])
- # Update member with new pool's id
- body = self.client.update_member(self.member['id'],
- pool_id=new_pool['id'])
- # Confirm with show that pool_id change
- body = self.client.show_member(self.member['id'])
- member = body['member']
- self.assertEqual(member['pool_id'], new_pool['id'])
- # Update member with old pool id, this is needed for clean up
- body = self.client.update_member(self.member['id'],
- pool_id=self.pool['id'])
-
- @test.idempotent_id('cf63f071-bbe3-40ba-97a0-a33e11923162')
- def test_update_member_weight(self):
- self.client.update_member(self.member['id'],
- weight=2)
- body = self.client.show_member(self.member['id'])
- member = body['member']
- self.assertEqual(2, member['weight'])
-
-
-@decorators.skip_because(bug="1402007")
-class LoadBalancerIpV6TestJSON(LoadBalancerTestJSON):
- _ip_version = 6
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/network/test_vpnaas_extensions.py b/tempest/api/network/test_vpnaas_extensions.py
deleted file mode 100644
index 9fe2a56..0000000
--- a/tempest/api/network/test_vpnaas_extensions.py
+++ /dev/null
@@ -1,319 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-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 import config
-from tempest import test
-
-CONF = config.CONF
-
-
-class VPNaaSTestJSON(base.BaseAdminNetworkTest):
- """
- Tests the following operations in the Neutron API using the REST client for
- Neutron:
- List, Show, Create, Delete, and Update VPN Service
- List, Show, Create, Delete, and Update IKE policy
- List, Show, Create, Delete, and Update IPSec policy
- """
-
- @classmethod
- def skip_checks(cls):
- super(VPNaaSTestJSON, cls).skip_checks()
- if not test.is_extension_enabled('vpnaas', 'network'):
- msg = "vpnaas extension not enabled."
- raise cls.skipException(msg)
-
- @classmethod
- def resource_setup(cls):
- super(VPNaaSTestJSON, cls).resource_setup()
- cls.ext_net_id = CONF.network.public_network_id
- cls.network = cls.create_network()
- cls.subnet = cls.create_subnet(cls.network)
- cls.router = cls.create_router(
- data_utils.rand_name("router"),
- external_network_id=CONF.network.public_network_id)
- cls.create_router_interface(cls.router['id'], cls.subnet['id'])
- cls.vpnservice = cls.create_vpnservice(cls.subnet['id'],
- cls.router['id'])
-
- cls.ikepolicy = cls.create_ikepolicy(
- data_utils.rand_name("ike-policy-"))
- cls.ipsecpolicy = cls.create_ipsecpolicy(
- data_utils.rand_name("ipsec-policy-"))
-
- def _delete_ike_policy(self, ike_policy_id):
- # Deletes a ike policy and verifies if it is deleted or not
- ike_list = list()
- all_ike = self.client.list_ikepolicies()
- for ike in all_ike['ikepolicies']:
- ike_list.append(ike['id'])
- if ike_policy_id in ike_list:
- self.client.delete_ikepolicy(ike_policy_id)
- # Asserting that the policy is not found in list after deletion
- ikepolicies = self.client.list_ikepolicies()
- ike_id_list = list()
- for i in ikepolicies['ikepolicies']:
- ike_id_list.append(i['id'])
- self.assertNotIn(ike_policy_id, ike_id_list)
-
- def _delete_ipsec_policy(self, ipsec_policy_id):
- # Deletes an ike policy if it exists
- try:
- self.client.delete_ipsecpolicy(ipsec_policy_id)
-
- except lib_exc.NotFound:
- pass
-
- def _assertExpected(self, expected, actual):
- # Check if not expected keys/values exists in actual response body
- for key, value in six.iteritems(expected):
- self.assertIn(key, actual)
- self.assertEqual(value, actual[key])
-
- def _delete_vpn_service(self, vpn_service_id):
- self.client.delete_vpnservice(vpn_service_id)
- # Asserting if vpn service is found in the list after deletion
- body = self.client.list_vpnservices()
- vpn_services = [vs['id'] for vs in body['vpnservices']]
- self.assertNotIn(vpn_service_id, vpn_services)
-
- def _get_tenant_id(self):
- """
- Returns the tenant_id of the client current user
- """
- # TODO(jroovers) This is a temporary workaround to get the tenant_id
- # of the the current client. Replace this once tenant_isolation for
- # neutron is fixed.
- body = self.client.show_network(self.network['id'])
- return body['network']['tenant_id']
-
- @test.idempotent_id('14311574-0737-4e53-ac05-f7ae27742eed')
- def test_admin_create_ipsec_policy_for_tenant(self):
- tenant_id = self._get_tenant_id()
- # Create IPSec policy for the newly created tenant
- name = data_utils.rand_name('ipsec-policy')
- body = (self.admin_client.
- create_ipsecpolicy(name=name, tenant_id=tenant_id))
- ipsecpolicy = body['ipsecpolicy']
- self.assertIsNotNone(ipsecpolicy['id'])
- self.addCleanup(self.admin_client.delete_ipsecpolicy,
- ipsecpolicy['id'])
-
- # Assert that created ipsec policy is found in API list call
- body = self.client.list_ipsecpolicies()
- ipsecpolicies = [policy['id'] for policy in body['ipsecpolicies']]
- self.assertIn(ipsecpolicy['id'], ipsecpolicies)
-
- @test.idempotent_id('b62acdc6-0c53-4d84-84aa-859b22b79799')
- def test_admin_create_vpn_service_for_tenant(self):
- tenant_id = self._get_tenant_id()
-
- # Create vpn service for the newly created tenant
- network2 = self.create_network()
- subnet2 = self.create_subnet(network2)
- router2 = self.create_router(data_utils.rand_name('router-'),
- external_network_id=self.ext_net_id)
- self.create_router_interface(router2['id'], subnet2['id'])
- name = data_utils.rand_name('vpn-service')
- body = self.admin_client.create_vpnservice(
- subnet_id=subnet2['id'],
- router_id=router2['id'],
- name=name,
- admin_state_up=True,
- tenant_id=tenant_id)
- vpnservice = body['vpnservice']
- self.assertIsNotNone(vpnservice['id'])
- self.addCleanup(self.admin_client.delete_vpnservice, vpnservice['id'])
- # Assert that created vpnservice is found in API list call
- body = self.client.list_vpnservices()
- vpn_services = [vs['id'] for vs in body['vpnservices']]
- self.assertIn(vpnservice['id'], vpn_services)
-
- @test.idempotent_id('58cc4a1c-443b-4f39-8fb6-c19d39f343ab')
- def test_admin_create_ike_policy_for_tenant(self):
- tenant_id = self._get_tenant_id()
-
- # Create IKE policy for the newly created tenant
- name = data_utils.rand_name('ike-policy')
- body = (self.admin_client.
- create_ikepolicy(name=name, ike_version="v1",
- encryption_algorithm="aes-128",
- auth_algorithm="sha1",
- tenant_id=tenant_id))
- ikepolicy = body['ikepolicy']
- self.assertIsNotNone(ikepolicy['id'])
- self.addCleanup(self.admin_client.delete_ikepolicy, ikepolicy['id'])
-
- # Assert that created ike policy is found in API list call
- body = self.client.list_ikepolicies()
- ikepolicies = [ikp['id'] for ikp in body['ikepolicies']]
- self.assertIn(ikepolicy['id'], ikepolicies)
-
- @test.idempotent_id('de5bb04c-3a1f-46b1-b329-7a8abba5c7f1')
- def test_list_vpn_services(self):
- # Verify the VPN service exists in the list of all VPN services
- body = self.client.list_vpnservices()
- vpnservices = body['vpnservices']
- self.assertIn(self.vpnservice['id'], [v['id'] for v in vpnservices])
-
- @test.idempotent_id('aacb13b1-fdc7-41fd-bab2-32621aee1878')
- def test_create_update_delete_vpn_service(self):
- # Creates a VPN service and sets up deletion
- network1 = self.create_network()
- subnet1 = self.create_subnet(network1)
- router1 = self.create_router(data_utils.rand_name('router-'),
- external_network_id=self.ext_net_id)
- self.create_router_interface(router1['id'], subnet1['id'])
- name = data_utils.rand_name('vpn-service1')
- body = self.client.create_vpnservice(subnet_id=subnet1['id'],
- router_id=router1['id'],
- name=name,
- admin_state_up=True)
- vpnservice = body['vpnservice']
- self.addCleanup(self._delete_vpn_service, vpnservice['id'])
- # Assert if created vpnservices are not found in vpnservices list
- body = self.client.list_vpnservices()
- vpn_services = [vs['id'] for vs in body['vpnservices']]
- self.assertIsNotNone(vpnservice['id'])
- self.assertIn(vpnservice['id'], vpn_services)
-
- # TODO(raies): implement logic to update vpnservice
- # VPNaaS client function to update is implemented.
- # But precondition is that current state of vpnservice
- # should be "ACTIVE" not "PENDING*"
-
- @test.idempotent_id('0dedfc1d-f8ee-4e2a-bfd4-7997b9dc17ff')
- def test_show_vpn_service(self):
- # Verifies the details of a vpn service
- body = self.client.show_vpnservice(self.vpnservice['id'])
- vpnservice = body['vpnservice']
- self.assertEqual(self.vpnservice['id'], vpnservice['id'])
- self.assertEqual(self.vpnservice['name'], vpnservice['name'])
- self.assertEqual(self.vpnservice['description'],
- vpnservice['description'])
- self.assertEqual(self.vpnservice['router_id'], vpnservice['router_id'])
- self.assertEqual(self.vpnservice['subnet_id'], vpnservice['subnet_id'])
- self.assertEqual(self.vpnservice['tenant_id'], vpnservice['tenant_id'])
- valid_status = ["ACTIVE", "DOWN", "BUILD", "ERROR", "PENDING_CREATE",
- "PENDING_UPDATE", "PENDING_DELETE"]
- self.assertIn(vpnservice['status'], valid_status)
-
- @test.idempotent_id('e0fb6200-da3d-4869-8340-a8c1956ca618')
- def test_list_ike_policies(self):
- # Verify the ike policy exists in the list of all IKE policies
- body = self.client.list_ikepolicies()
- ikepolicies = body['ikepolicies']
- self.assertIn(self.ikepolicy['id'], [i['id'] for i in ikepolicies])
-
- @test.idempotent_id('d61f29a5-160c-487d-bc0d-22e32e731b44')
- def test_create_update_delete_ike_policy(self):
- # Creates a IKE policy
- name = data_utils.rand_name('ike-policy')
- body = (self.client.create_ikepolicy(
- name=name,
- ike_version="v1",
- encryption_algorithm="aes-128",
- auth_algorithm="sha1"))
- ikepolicy = body['ikepolicy']
- self.assertIsNotNone(ikepolicy['id'])
- self.addCleanup(self._delete_ike_policy, ikepolicy['id'])
-
- # Update IKE Policy
- new_ike = {'name': data_utils.rand_name("New-IKE"),
- 'description': "Updated ike policy",
- 'encryption_algorithm': "aes-256",
- 'ike_version': "v2",
- 'pfs': "group14",
- 'lifetime': {'units': "seconds", 'value': 2000}}
- self.client.update_ikepolicy(ikepolicy['id'], **new_ike)
- # Confirm that update was successful by verifying using 'show'
- body = self.client.show_ikepolicy(ikepolicy['id'])
- ike_policy = body['ikepolicy']
- for key, value in six.iteritems(new_ike):
- self.assertIn(key, ike_policy)
- self.assertEqual(value, ike_policy[key])
-
- # Verification of ike policy delete
- self.client.delete_ikepolicy(ikepolicy['id'])
- body = self.client.list_ikepolicies()
- ikepolicies = [ikp['id'] for ikp in body['ikepolicies']]
- self.assertNotIn(ike_policy['id'], ikepolicies)
-
- @test.idempotent_id('b5fcf3a3-9407-452d-b8a8-e7c6c32baea8')
- def test_show_ike_policy(self):
- # Verifies the details of a ike policy
- body = self.client.show_ikepolicy(self.ikepolicy['id'])
- ikepolicy = body['ikepolicy']
- self.assertEqual(self.ikepolicy['id'], ikepolicy['id'])
- self.assertEqual(self.ikepolicy['name'], ikepolicy['name'])
- self.assertEqual(self.ikepolicy['description'],
- ikepolicy['description'])
- self.assertEqual(self.ikepolicy['encryption_algorithm'],
- ikepolicy['encryption_algorithm'])
- self.assertEqual(self.ikepolicy['auth_algorithm'],
- ikepolicy['auth_algorithm'])
- self.assertEqual(self.ikepolicy['tenant_id'],
- ikepolicy['tenant_id'])
- self.assertEqual(self.ikepolicy['pfs'],
- ikepolicy['pfs'])
- self.assertEqual(self.ikepolicy['phase1_negotiation_mode'],
- ikepolicy['phase1_negotiation_mode'])
- self.assertEqual(self.ikepolicy['ike_version'],
- ikepolicy['ike_version'])
-
- @test.idempotent_id('19ea0a2f-add9-44be-b732-ffd8a7b42f37')
- def test_list_ipsec_policies(self):
- # Verify the ipsec policy exists in the list of all ipsec policies
- body = self.client.list_ipsecpolicies()
- ipsecpolicies = body['ipsecpolicies']
- self.assertIn(self.ipsecpolicy['id'], [i['id'] for i in ipsecpolicies])
-
- @test.idempotent_id('9c1701c9-329a-4e5d-930a-1ead1b3f86ad')
- def test_create_update_delete_ipsec_policy(self):
- # Creates an ipsec policy
- ipsec_policy_body = {'name': data_utils.rand_name('ipsec-policy'),
- 'pfs': 'group5',
- 'encryption_algorithm': "aes-128",
- 'auth_algorithm': 'sha1'}
- resp_body = self.client.create_ipsecpolicy(**ipsec_policy_body)
- ipsecpolicy = resp_body['ipsecpolicy']
- self.addCleanup(self._delete_ipsec_policy, ipsecpolicy['id'])
- self._assertExpected(ipsec_policy_body, ipsecpolicy)
- # Verification of ipsec policy update
- new_ipsec = {'description': 'Updated ipsec policy',
- 'pfs': 'group2',
- 'name': data_utils.rand_name("New-IPSec"),
- 'encryption_algorithm': "aes-256",
- 'lifetime': {'units': "seconds", 'value': '2000'}}
- body = self.client.update_ipsecpolicy(ipsecpolicy['id'],
- **new_ipsec)
- updated_ipsec_policy = body['ipsecpolicy']
- self._assertExpected(new_ipsec, updated_ipsec_policy)
- # Verification of ipsec policy delete
- self.client.delete_ipsecpolicy(ipsecpolicy['id'])
- self.assertRaises(lib_exc.NotFound,
- self.client.delete_ipsecpolicy, ipsecpolicy['id'])
-
- @test.idempotent_id('601f8a05-9d3c-4539-a400-1c4b3a21b03b')
- def test_show_ipsec_policy(self):
- # Verifies the details of an ipsec policy
- body = self.client.show_ipsecpolicy(self.ipsecpolicy['id'])
- ipsecpolicy = body['ipsecpolicy']
- self._assertExpected(self.ipsecpolicy, ipsecpolicy)
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 fec6873..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
@@ -56,18 +56,33 @@
# we want to ensure that we will sleep long enough for things to
# actually expire, so figure out how many secs in the future that is.
sleepy_time = int(resp['x-delete-at']) - int(time.time())
-
+ sleepy_time = sleepy_time if sleepy_time > 0 else 0
resp, body = self.object_client.get_object(self.container_name,
self.object_name)
self.assertHeaders(resp, 'Object', 'GET')
self.assertIn('x-delete-at', resp)
- # add a couple of seconds for safety.
- time.sleep(sleepy_time + 3)
+ # add several seconds for safety.
+ time.sleep(sleepy_time)
+
+ # Checking whether object still exists for several seconds:
+ # sometimes object is not deleted immediately, so we are making
+ # get calls for an approximately 1 minute in a total. Get calls
+ # can take 3s each sometimes so we are making the requests in
+ # exponential periodicity
+ for i in range(1, 6):
+ time.sleep(2 ** i)
+ try:
+ self.object_client.get_object(self.container_name,
+ self.object_name)
+ except lib_exc.NotFound:
+ break
# object should not be there anymore
- self.assertRaises(lib_exc.NotFound, self.object_client.get_object,
- self.container_name, self.object_name)
+ self.assertRaises(lib_exc.NotFound,
+ self.object_client.get_object,
+ self.container_name,
+ self.object_name)
@test.idempotent_id('fb024a42-37f3-4ba5-9684-4f40a7910b41')
def test_get_object_after_expiry_time(self):
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 627895e..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
@@ -827,8 +827,8 @@
resp, _ = self.object_client.create_object(src_container_name,
object_name, data)
# set object metadata
- meta_key = data_utils.rand_name(name='test-')
- meta_value = data_utils.rand_name(name='MetaValue-')
+ meta_key = data_utils.rand_name(name='test')
+ meta_value = data_utils.rand_name(name='MetaValue')
orig_metadata = {meta_key: meta_value}
resp, _ = self.object_client.update_object_metadata(src_container_name,
object_name,
diff --git a/tempest/api/object_storage/test_object_slo.py b/tempest/api/object_storage/test_object_slo.py
index 7df0dde..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
@@ -110,6 +110,7 @@
self.assertHeaders(resp, 'Object', method)
@test.idempotent_id('2c3f24a6-36e8-4711-9aa2-800ee1fc7b5b')
+ @test.requires_ext(extension='slo', service='object')
def test_upload_manifest(self):
# create static large object from multipart manifest
manifest = self._create_manifest()
@@ -124,6 +125,7 @@
self._assertHeadersSLO(resp, 'PUT')
@test.idempotent_id('e69ad766-e1aa-44a2-bdd2-bf62c09c1456')
+ @test.requires_ext(extension='slo', service='object')
def test_list_large_object_metadata(self):
# list static large object metadata using multipart manifest
object_name = self._create_large_object()
@@ -135,6 +137,7 @@
self._assertHeadersSLO(resp, 'HEAD')
@test.idempotent_id('49bc49bc-dd1b-4c0f-904e-d9f10b830ee8')
+ @test.requires_ext(extension='slo', service='object')
def test_retrieve_large_object(self):
# list static large object using multipart manifest
object_name = self._create_large_object()
@@ -149,6 +152,7 @@
self.assertEqual(body, sum_data)
@test.idempotent_id('87b6dfa1-abe9-404d-8bf0-6c3751e6aa77')
+ @test.requires_ext(extension='slo', service='object')
def test_delete_large_object(self):
# delete static large object using multipart manifest
object_name = self._create_large_object()
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 43180e5..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
@@ -55,8 +55,7 @@
cls.nova_notifications = ['memory', 'vcpus', 'disk.root.size',
'disk.ephemeral.size']
- cls.glance_notifications = ['image.update', 'image.upload',
- 'image.delete']
+ cls.glance_notifications = ['image.size']
cls.glance_v2_notifications = ['image.download', 'image.serve']
@@ -122,3 +121,27 @@
'Sample for metric:%s with query:%s has not been added to the '
'database within %d seconds' % (metric, query,
CONF.compute.build_timeout))
+
+
+class BaseTelemetryAdminTest(BaseTelemetryTest):
+ """Base test case class for admin Telemetry API tests."""
+
+ credentials = ['primary', 'admin']
+
+ @classmethod
+ def setup_clients(cls):
+ super(BaseTelemetryAdminTest, cls).setup_clients()
+ cls.telemetry_admin_client = cls.os_adm.telemetry_client
+
+ def await_events(self, query):
+ timeout = CONF.compute.build_timeout
+ start = timeutils.utcnow()
+ while timeutils.delta_seconds(start, timeutils.utcnow()) < timeout:
+ body = self.telemetry_admin_client.list_events(query)
+ if body:
+ return body
+ time.sleep(CONF.compute.build_interval)
+
+ raise exceptions.TimeoutException(
+ 'Event with query:%s has not been added to the '
+ 'database within %d seconds' % (query, CONF.compute.build_timeout))
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/telemetry/test_telemetry_notification_api.py b/tempest/api/telemetry/test_telemetry_notification_api.py
index 73a5fd4..71a00c9 100644
--- a/tempest/api/telemetry/test_telemetry_notification_api.py
+++ b/tempest/api/telemetry/test_telemetry_notification_api.py
@@ -30,8 +30,7 @@
"is disabled")
@test.idempotent_id('d7f8c1c8-d470-4731-8604-315d3956caad')
- @testtools.skipIf(not CONF.service_available.nova,
- "Nova is not available.")
+ @test.services('compute')
def test_check_nova_notification(self):
body = self.create_server()
@@ -46,7 +45,6 @@
@test.services("image")
@testtools.skipIf(not CONF.image_feature_enabled.api_v1,
"Glance api v1 is disabled")
- @decorators.skip_because(bug='1351627')
def test_check_glance_v1_notifications(self):
body = self.create_image(self.image_client)
self.image_client.update_image(body['id'], data='data')
@@ -63,14 +61,38 @@
@test.services("image")
@testtools.skipIf(not CONF.image_feature_enabled.api_v2,
"Glance api v2 is disabled")
- @decorators.skip_because(bug='1351627')
def test_check_glance_v2_notifications(self):
body = self.create_image(self.image_client_v2)
- self.image_client_v2.store_image(body['id'], "file")
- self.image_client_v2.get_image_file(body['id'])
+ self.image_client_v2.store_image_file(body['id'], "file")
+ self.image_client_v2.load_image_file(body['id'])
query = 'resource', 'eq', body['id']
for metric in self.glance_v2_notifications:
self.await_samples(metric, query)
+
+
+class TelemetryNotificationAdminAPITestJSON(base.BaseTelemetryAdminTest):
+
+ @classmethod
+ def skip_checks(cls):
+ super(TelemetryNotificationAdminAPITestJSON, cls).skip_checks()
+ if CONF.telemetry.too_slow_to_test:
+ raise cls.skipException("Ceilometer feature for fast work mysql "
+ "is disabled")
+
+ @test.idempotent_id('29604198-8b45-4fc0-8af8-1cae4f94ebe9')
+ @test.services('compute')
+ @decorators.skip_because(bug='1480490')
+ def test_check_nova_notification_event_and_meter(self):
+
+ body = self.create_server()
+
+ if CONF.telemetry_feature_enabled.events:
+ query = ('instance_id', 'eq', body['id'])
+ self.await_events(query)
+
+ query = ('resource', 'eq', body['id'])
+ for metric in self.nova_notifications:
+ self.await_samples(metric, query)
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 24c7c63..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']
@@ -98,7 +98,7 @@
@test.idempotent_id('874b35a9-51f1-4258-bec5-cd561b6690d3')
def test_delete_quota(self):
# Admin can delete the resource quota set for a tenant
- tenant_name = data_utils.rand_name('quota_tenant_')
+ tenant_name = data_utils.rand_name('quota_tenant')
identity_client = self.os_adm.identity_client
tenant = identity_client.create_tenant(tenant_name)
tenant_id = tenant['id']
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/agents.py b/tempest/api_schema/response/compute/v2_1/agents.py
index 84c5fd3..da38198 100644
--- a/tempest/api_schema/response/compute/v2_1/agents.py
+++ b/tempest/api_schema/response/compute/v2_1/agents.py
@@ -23,6 +23,7 @@
'url': {'type': 'string', 'format': 'uri'},
'md5hash': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['agent_id', 'hypervisor', 'os', 'architecture',
'version', 'url', 'md5hash']
}
@@ -37,6 +38,7 @@
'items': common_agent_info
}
},
+ 'additionalProperties': False,
'required': ['agents']
}
}
@@ -48,6 +50,7 @@
'properties': {
'agent': common_agent_info
},
+ 'additionalProperties': False,
'required': ['agent']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/aggregates.py b/tempest/api_schema/response/compute/v2_1/aggregates.py
index c935592..1a9fe41 100644
--- a/tempest/api_schema/response/compute/v2_1/aggregates.py
+++ b/tempest/api_schema/response/compute/v2_1/aggregates.py
@@ -26,6 +26,7 @@
'name': {'type': 'string'},
'updated_at': {'type': ['string', 'null']}
},
+ 'additionalProperties': False,
'required': ['availability_zone', 'created_at', 'deleted',
'deleted_at', 'id', 'name', 'updated_at'],
}
@@ -47,6 +48,7 @@
'items': common_aggregate_info
}
},
+ 'additionalProperties': False,
'required': ['aggregates'],
}
}
@@ -58,6 +60,7 @@
'properties': {
'aggregate': common_aggregate_info
},
+ 'additionalProperties': False,
'required': ['aggregate'],
}
}
@@ -81,6 +84,7 @@
'properties': {
'aggregate': aggregate_for_create
},
+ 'additionalProperties': False,
'required': ['aggregate'],
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/availability_zone.py b/tempest/api_schema/response/compute/v2_1/availability_zone.py
index 5c1224e..d9aebce 100644
--- a/tempest/api_schema/response/compute/v2_1/availability_zone.py
+++ b/tempest/api_schema/response/compute/v2_1/availability_zone.py
@@ -31,16 +31,19 @@
'properties': {
'available': {'type': 'boolean'}
},
+ 'additionalProperties': False,
'required': ['available']
},
# NOTE: Here is the difference between detail and
# non-detail.
'hosts': {'type': 'null'}
},
+ 'additionalProperties': False,
'required': ['zoneName', 'zoneState', 'hosts']
}
}
},
+ 'additionalProperties': False,
'required': ['availabilityZoneInfo']
}
}
@@ -60,6 +63,7 @@
'active': {'type': 'boolean'},
'updated_at': {'type': ['string', 'null']}
},
+ 'additionalProperties': False,
'required': ['available', 'active', 'updated_at']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/baremetal_nodes.py b/tempest/api_schema/response/compute/v2_1/baremetal_nodes.py
index 82506e7..d1ee877 100644
--- a/tempest/api_schema/response/compute/v2_1/baremetal_nodes.py
+++ b/tempest/api_schema/response/compute/v2_1/baremetal_nodes.py
@@ -25,6 +25,7 @@
'memory_mb': {'type': ['integer', 'string']},
'disk_gb': {'type': ['integer', 'string']},
},
+ 'additionalProperties': False,
'required': ['id', 'interfaces', 'host', 'task_state', 'cpus', 'memory_mb',
'disk_gb']
}
@@ -39,6 +40,7 @@
'items': node
}
},
+ 'additionalProperties': False,
'required': ['nodes']
}
}
@@ -50,6 +52,7 @@
'properties': {
'node': node
},
+ 'additionalProperties': False,
'required': ['node']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/certificates.py b/tempest/api_schema/response/compute/v2_1/certificates.py
index 35445d8..4e7cbe4 100644
--- a/tempest/api_schema/response/compute/v2_1/certificates.py
+++ b/tempest/api_schema/response/compute/v2_1/certificates.py
@@ -25,9 +25,11 @@
'data': {'type': 'string'},
'private_key': {'type': 'string'},
},
+ 'additionalProperties': False,
'required': ['data', 'private_key']
}
},
+ 'additionalProperties': False,
'required': ['certificate']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/extensions.py b/tempest/api_schema/response/compute/v2_1/extensions.py
index 570cd03..a6a455c 100644
--- a/tempest/api_schema/response/compute/v2_1/extensions.py
+++ b/tempest/api_schema/response/compute/v2_1/extensions.py
@@ -35,11 +35,13 @@
'alias': {'type': 'string'},
'description': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['updated', 'name', 'links', 'namespace',
'alias', 'description']
}
}
},
+ 'additionalProperties': False,
'required': ['extensions']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/fixed_ips.py b/tempest/api_schema/response/compute/v2_1/fixed_ips.py
index 13e70bf..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,17 +22,16 @@
'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'}
},
+ 'additionalProperties': False,
'required': ['address', 'cidr', 'host', 'hostname']
}
},
+ 'additionalProperties': False,
'required': ['fixed_ip']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/flavors.py b/tempest/api_schema/response/compute/v2_1/flavors.py
index 26760ac..5f5b2e3 100644
--- a/tempest/api_schema/response/compute/v2_1/flavors.py
+++ b/tempest/api_schema/response/compute/v2_1/flavors.py
@@ -28,11 +28,13 @@
'links': parameter_types.links,
'id': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['name', 'links', 'id']
}
},
'flavors_links': parameter_types.links
},
+ 'additionalProperties': False,
# NOTE(gmann): flavors_links attribute is not necessary
# to be present always So it is not 'required'.
'required': ['flavors']
@@ -56,6 +58,7 @@
'rxtx_factor': {'type': 'number'},
'OS-FLV-EXT-DATA:ephemeral': {'type': 'integer'}
},
+ 'additionalProperties': False,
# 'OS-FLV-DISABLED', 'os-flavor-access', 'rxtx_factor' and
# 'OS-FLV-EXT-DATA' are API extensions. So they are not 'required'.
'required': ['name', 'links', 'ram', 'vcpus', 'swap', 'disk', 'id']
@@ -74,6 +77,7 @@
# to be present always So it is not 'required'.
'flavors_links': parameter_types.links
},
+ 'additionalProperties': False,
'required': ['flavors']
}
}
@@ -89,6 +93,7 @@
'properties': {
'flavor': common_flavor_info
},
+ 'additionalProperties': False,
'required': ['flavor']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/flavors_access.py b/tempest/api_schema/response/compute/v2_1/flavors_access.py
index cd31b0a..a4d6af0 100644
--- a/tempest/api_schema/response/compute/v2_1/flavors_access.py
+++ b/tempest/api_schema/response/compute/v2_1/flavors_access.py
@@ -25,10 +25,12 @@
'flavor_id': {'type': 'string'},
'tenant_id': {'type': 'string'},
},
+ 'additionalProperties': False,
'required': ['flavor_id', 'tenant_id'],
}
}
},
+ 'additionalProperties': False,
'required': ['flavor_access']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/flavors_extra_specs.py b/tempest/api_schema/response/compute/v2_1/flavors_extra_specs.py
index faa25d0..a438d48 100644
--- a/tempest/api_schema/response/compute/v2_1/flavors_extra_specs.py
+++ b/tempest/api_schema/response/compute/v2_1/flavors_extra_specs.py
@@ -24,6 +24,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['extra_specs']
}
}
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 ad1c531..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,15 +23,10 @@
'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',
'ip', 'fixed_ip'],
@@ -44,6 +41,7 @@
'items': common_floating_ip_info
},
},
+ 'additionalProperties': False,
'required': ['floating_ips'],
}
}
@@ -55,6 +53,7 @@
'properties': {
'floating_ip': common_floating_ip_info
},
+ 'additionalProperties': False,
'required': ['floating_ip'],
}
}
@@ -71,10 +70,12 @@
'properties': {
'name': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['name'],
}
}
},
+ 'additionalProperties': False,
'required': ['floating_ip_pools'],
}
}
@@ -95,9 +96,11 @@
'ip_range': {'type': 'string'},
'pool': {'type': ['string', 'null']},
},
+ 'additionalProperties': False,
'required': ['interface', 'ip_range', 'pool'],
}
},
+ 'additionalProperties': False,
'required': ['floating_ips_bulk_create'],
}
}
@@ -109,6 +112,7 @@
'properties': {
'floating_ips_bulk_delete': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['floating_ips_bulk_delete'],
}
}
@@ -123,19 +127,14 @@
'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,
# So it is not defined as 'required'.
'required': ['address', 'instance_uuid', 'interface',
@@ -143,6 +142,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['floating_ip_info'],
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/hosts.py b/tempest/api_schema/response/compute/v2_1/hosts.py
index 72d5a07..ae70ff1 100644
--- a/tempest/api_schema/response/compute/v2_1/hosts.py
+++ b/tempest/api_schema/response/compute/v2_1/hosts.py
@@ -29,10 +29,12 @@
'service': {'type': 'string'},
'zone': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['host_name', 'service', 'zone']
}
}
},
+ 'additionalProperties': False,
'required': ['hosts']
}
}
@@ -56,14 +58,17 @@
'memory_mb': {'type': 'integer'},
'project': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['cpu', 'disk_gb', 'host',
'memory_mb', 'project']
}
},
+ 'additionalProperties': False,
'required': ['resource']
}
}
},
+ 'additionalProperties': False,
'required': ['host']
}
}
@@ -76,6 +81,7 @@
'host': {'type': 'string'},
'power_action': {'enum': ['startup']}
},
+ 'additionalProperties': False,
'required': ['host', 'power_action']
}
}
@@ -104,6 +110,7 @@
'off_maintenance']},
'status': {'enum': ['enabled', 'disabled']}
},
+ 'additionalProperties': False,
'required': ['host', 'maintenance_mode', 'status']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/hypervisors.py b/tempest/api_schema/response/compute/v2_1/hypervisors.py
index 3efa46b..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': {
@@ -35,6 +37,7 @@
'vcpus': {'type': 'integer'},
'vcpus_used': {'type': 'integer'}
},
+ 'additionalProperties': False,
'required': ['count', 'current_workload',
'disk_available_least', 'free_disk_gb',
'free_ram_mb', 'local_gb', 'local_gb_used',
@@ -42,6 +45,7 @@
'vcpus', 'vcpus_used']
}
},
+ 'additionalProperties': False,
'required': ['hypervisor_statistics']
}
}
@@ -55,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'},
@@ -77,11 +78,13 @@
'id': {'type': ['integer', 'string']},
'disabled_reason': {'type': ['string', 'null']}
},
+ 'additionalProperties': False,
'required': ['host', 'id']
},
'vcpus': {'type': 'integer'},
'vcpus_used': {'type': 'integer'}
},
+ 'additionalProperties': False,
# NOTE: When loading os-hypervisor-status extension,
# a response contains status and state. So these params
# should not be required.
@@ -104,6 +107,7 @@
'items': hypervisor_detail
}
},
+ 'additionalProperties': False,
'required': ['hypervisors']
}
}
@@ -115,6 +119,7 @@
'properties': {
'hypervisor': hypervisor_detail
},
+ 'additionalProperties': False,
'required': ['hypervisor']
}
}
@@ -134,6 +139,7 @@
'id': {'type': ['integer', 'string']},
'hypervisor_hostname': {'type': 'string'}
},
+ 'additionalProperties': False,
# NOTE: When loading os-hypervisor-status extension,
# a response contains status and state. So these params
# should not be required.
@@ -141,6 +147,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['hypervisors']
}
}
@@ -159,12 +166,14 @@
'hypervisor_hostname': {'type': 'string'},
'uptime': {'type': 'string'}
},
+ 'additionalProperties': False,
# NOTE: When loading os-hypervisor-status extension,
# a response contains status and state. So these params
# should not be required.
'required': ['id', 'hypervisor_hostname', 'uptime']
}
},
+ 'additionalProperties': False,
'required': ['hypervisor']
}
}
@@ -178,7 +187,8 @@
'properties': {
'uuid': {'type': 'string'},
'name': {'type': 'string'}
- }
+ },
+ 'additionalProperties': False,
}
}
# In V2 API, if there is no servers (VM) on the Hypervisor host then 'servers'
diff --git a/tempest/api_schema/response/compute/v2_1/images.py b/tempest/api_schema/response/compute/v2_1/images.py
index e6f8db6..a513dcb 100644
--- a/tempest/api_schema/response/compute/v2_1/images.py
+++ b/tempest/api_schema/response/compute/v2_1/images.py
@@ -38,11 +38,13 @@
'id': {'type': 'string'},
'links': parameter_types.links
},
+ 'additionalProperties': False,
'required': ['id', 'links']
},
'OS-EXT-IMG-SIZE:size': {'type': 'integer'},
'OS-DCF:diskConfig': {'type': 'string'}
},
+ 'additionalProperties': False,
# 'server' attributes only comes in response body if image is
# associated with any server. 'OS-EXT-IMG-SIZE:size' & 'OS-DCF:diskConfig'
# are API extension, So those are not defined as 'required'.
@@ -58,6 +60,7 @@
'properties': {
'image': common_image_schema
},
+ 'additionalProperties': False,
'required': ['image']
}
}
@@ -76,11 +79,13 @@
'links': image_links,
'name': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['id', 'links', 'name']
}
},
'images_links': parameter_types.links
},
+ 'additionalProperties': False,
# NOTE(gmann): images_links attribute is not necessary to be
# present always So it is not 'required'.
'required': ['images']
@@ -113,6 +118,7 @@
'properties': {
'metadata': {'type': 'object'}
},
+ 'additionalProperties': False,
'required': ['metadata']
}
}
@@ -124,6 +130,7 @@
'properties': {
'meta': {'type': 'object'}
},
+ 'additionalProperties': False,
'required': ['meta']
}
}
@@ -139,6 +146,7 @@
},
'images_links': parameter_types.links
},
+ 'additionalProperties': False,
# NOTE(gmann): images_links attribute is not necessary to be
# present always So it is not 'required'.
'required': ['images']
diff --git a/tempest/api_schema/response/compute/v2_1/instance_usage_audit_logs.py b/tempest/api_schema/response/compute/v2_1/instance_usage_audit_logs.py
index 658f574..c6c4deb 100644
--- a/tempest/api_schema/response/compute/v2_1/instance_usage_audit_logs.py
+++ b/tempest/api_schema/response/compute/v2_1/instance_usage_audit_logs.py
@@ -30,6 +30,7 @@
'total_errors': {'type': 'integer'},
'total_instances': {'type': 'integer'}
},
+ 'additionalProperties': False,
'required': ['hosts_not_run', 'log', 'num_hosts', 'num_hosts_done',
'num_hosts_not_run', 'num_hosts_running', 'overall_status',
'period_beginning', 'period_ending', 'total_errors',
@@ -43,6 +44,7 @@
'properties': {
'instance_usage_audit_log': common_instance_usage_audit_log
},
+ 'additionalProperties': False,
'required': ['instance_usage_audit_log']
}
}
@@ -54,6 +56,7 @@
'properties': {
'instance_usage_audit_logs': common_instance_usage_audit_log
},
+ 'additionalProperties': False,
'required': ['instance_usage_audit_logs']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/interfaces.py b/tempest/api_schema/response/compute/v2_1/interfaces.py
index 033f816..130775b 100644
--- a/tempest/api_schema/response/compute/v2_1/interfaces.py
+++ b/tempest/api_schema/response/compute/v2_1/interfaces.py
@@ -27,11 +27,9 @@
'type': 'string',
'format': 'uuid'
},
- 'ip_address': {
- 'type': 'string',
- 'format': 'ipv4'
- }
+ 'ip_address': parameter_types.ip_address
},
+ 'additionalProperties': False,
'required': ['subnet_id', 'ip_address']
}
},
@@ -39,6 +37,7 @@
'net_id': {'type': 'string', 'format': 'uuid'},
'mac_addr': parameter_types.mac_address
},
+ 'additionalProperties': False,
'required': ['port_state', 'fixed_ips', 'port_id', 'net_id', 'mac_addr']
}
@@ -49,6 +48,7 @@
'properties': {
'interfaceAttachment': interface_common_info
},
+ 'additionalProperties': False,
'required': ['interfaceAttachment']
}
}
@@ -63,6 +63,7 @@
'items': interface_common_info
}
},
+ 'additionalProperties': False,
'required': ['interfaceAttachments']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/keypairs.py b/tempest/api_schema/response/compute/v2_1/keypairs.py
index ceae6cf..9c04c79 100644
--- a/tempest/api_schema/response/compute/v2_1/keypairs.py
+++ b/tempest/api_schema/response/compute/v2_1/keypairs.py
@@ -31,6 +31,7 @@
'id': {'type': 'integer'}
},
+ 'additionalProperties': False,
# When we run the get keypair API, response body includes
# all the above mentioned attributes.
# But in Nova API sample file, response body includes only
@@ -39,6 +40,7 @@
'required': ['public_key', 'name', 'fingerprint']
}
},
+ 'additionalProperties': False,
'required': ['keypair']
}
}
@@ -57,12 +59,14 @@
'user_id': {'type': 'string'},
'private_key': {'type': 'string'}
},
+ 'additionalProperties': False,
# When create keypair API is being called with 'Public key'
# (Importing keypair) then, response body does not contain
# 'private_key' So it is not defined as 'required'
'required': ['fingerprint', 'name', 'public_key', 'user_id']
}
},
+ 'additionalProperties': False,
'required': ['keypair']
}
}
@@ -88,13 +92,16 @@
'name': {'type': 'string'},
'fingerprint': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['public_key', 'name', 'fingerprint']
}
},
+ 'additionalProperties': False,
'required': ['keypair']
}
}
},
+ 'additionalProperties': False,
'required': ['keypairs']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/limits.py b/tempest/api_schema/response/compute/v2_1/limits.py
index a7decb7..81f175f 100644
--- a/tempest/api_schema/response/compute/v2_1/limits.py
+++ b/tempest/api_schema/response/compute/v2_1/limits.py
@@ -43,6 +43,7 @@
'maxServerGroups': {'type': 'integer'},
'totalServerGroupsUsed': {'type': 'integer'}
},
+ 'additionalProperties': False,
# NOTE(gmann): maxServerGroupMembers, maxServerGroups
# and totalServerGroupsUsed are API extension,
# and some environments return a response without these
@@ -84,18 +85,22 @@
{'type': 'integer'},
'verb':
{'type': 'string'}
- }
+ },
+ 'additionalProperties': False,
}
},
'regex': {'type': 'string'},
'uri': {'type': 'string'}
- }
+ },
+ 'additionalProperties': False,
}
}
},
+ 'additionalProperties': False,
'required': ['absolute', 'rate']
}
},
+ 'additionalProperties': False,
'required': ['limits']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/migrations.py b/tempest/api_schema/response/compute/v2_1/migrations.py
index 6549272..b7d66ea 100644
--- a/tempest/api_schema/response/compute/v2_1/migrations.py
+++ b/tempest/api_schema/response/compute/v2_1/migrations.py
@@ -23,18 +23,19 @@
'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']}
},
+ 'additionalProperties': False,
'required': [
'id', 'status', 'instance_uuid', 'source_node',
'source_compute', 'dest_node', 'dest_compute',
@@ -44,6 +45,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['migrations']
}
}
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 90d4c8f..07cc890 100644
--- a/tempest/api_schema/response/compute/v2_1/parameter_types.py
+++ b/tempest/api_schema/response/compute/v2_1/parameter_types.py
@@ -23,6 +23,7 @@
},
'rel': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['href', 'rel']
}
}
@@ -32,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 = {
@@ -54,12 +68,13 @@
'version': {'type': 'integer'},
'addr': {
'type': 'string',
- 'anyOf': [
+ 'oneOf': [
{'format': 'ipv4'},
{'format': 'ipv6'}
]
}
},
+ 'additionalProperties': False,
'required': ['version', 'addr']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/quotas.py b/tempest/api_schema/response/compute/v2_1/quotas.py
index 9141f7e..7953983 100644
--- a/tempest/api_schema/response/compute/v2_1/quotas.py
+++ b/tempest/api_schema/response/compute/v2_1/quotas.py
@@ -37,6 +37,7 @@
'injected_file_content_bytes': {'type': 'integer'},
'injected_file_path_bytes': {'type': 'integer'}
},
+ 'additionalProperties': False,
# NOTE: server_group_members and server_groups are represented
# when enabling quota_server_group extension. So they should
# not be required.
@@ -48,6 +49,7 @@
'injected_file_path_bytes']
}
},
+ 'additionalProperties': False,
'required': ['quota_set']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/security_group_default_rule.py b/tempest/api_schema/response/compute/v2_1/security_group_default_rule.py
index 9246ab8..2ec2826 100644
--- a/tempest/api_schema/response/compute/v2_1/security_group_default_rule.py
+++ b/tempest/api_schema/response/compute/v2_1/security_group_default_rule.py
@@ -23,10 +23,12 @@
'properties': {
'cidr': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['cidr'],
},
'to_port': {'type': 'integer'},
},
+ 'additionalProperties': False,
'required': ['from_port', 'id', 'ip_protocol', 'ip_range', 'to_port'],
}
@@ -38,6 +40,7 @@
'security_group_default_rule':
common_security_group_default_rule_info
},
+ 'additionalProperties': False,
'required': ['security_group_default_rule']
}
}
@@ -56,6 +59,7 @@
'items': common_security_group_default_rule_info
}
},
+ 'additionalProperties': False,
'required': ['security_group_default_rules']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/security_groups.py b/tempest/api_schema/response/compute/v2_1/security_groups.py
index 9a852e5..5ed5a5c 100644
--- a/tempest/api_schema/response/compute/v2_1/security_groups.py
+++ b/tempest/api_schema/response/compute/v2_1/security_groups.py
@@ -20,7 +20,8 @@
'properties': {
'tenant_id': {'type': 'string'},
'name': {'type': 'string'}
- }
+ },
+ 'additionalProperties': False,
},
'ip_protocol': {'type': ['string', 'null']},
# 'parent_group_id' can be UUID so defining it as 'string' also.
@@ -29,7 +30,8 @@
'type': 'object',
'properties': {
'cidr': {'type': 'string'}
- }
+ },
+ 'additionalProperties': False,
# When optional argument is provided in request body
# like 'group_id' then, attribute 'cidr' does not
# comes in response body. So it is not 'required'.
@@ -47,11 +49,13 @@
'type': 'array',
'items': {
'type': ['object', 'null'],
- 'properties': common_security_group_rule
+ 'properties': common_security_group_rule,
+ 'additionalProperties': False,
}
},
'description': {'type': 'string'},
},
+ 'additionalProperties': False,
'required': ['id', 'name', 'tenant_id', 'rules', 'description'],
}
@@ -65,6 +69,7 @@
'items': common_security_group
}
},
+ 'additionalProperties': False,
'required': ['security_groups']
}
}
@@ -76,6 +81,7 @@
'properties': {
'security_group': common_security_group
},
+ 'additionalProperties': False,
'required': ['security_group']
}
}
@@ -92,10 +98,12 @@
'security_group_rule': {
'type': 'object',
'properties': common_security_group_rule,
+ 'additionalProperties': False,
'required': ['from_port', 'to_port', 'group', 'ip_protocol',
'parent_group_id', 'id', 'ip_range']
}
},
+ 'additionalProperties': False,
'required': ['security_group_rule']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/servers.py b/tempest/api_schema/response/compute/v2_1/servers.py
index 875f607..44ab9e9 100644
--- a/tempest/api_schema/response/compute/v2_1/servers.py
+++ b/tempest/api_schema/response/compute/v2_1/servers.py
@@ -29,12 +29,14 @@
'links': parameter_types.links,
'OS-DCF:diskConfig': {'type': 'string'}
},
+ 'additionalProperties': False,
# NOTE: OS-DCF:diskConfig & security_groups are API extension,
# and some environments return a response without these
# attributes.So they are not 'required'.
'required': ['id', 'links']
}
},
+ 'additionalProperties': False,
'required': ['server']
}
}
@@ -59,11 +61,13 @@
'links': parameter_types.links,
'name': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['id', 'links', 'name']
}
},
'servers_links': parameter_types.links
},
+ 'additionalProperties': False,
# NOTE(gmann): servers_links attribute is not necessary to be
# present always So it is not 'required'.
'required': ['servers']
@@ -86,6 +90,7 @@
'id': {'type': 'string'},
'links': parameter_types.links
},
+ 'additionalProperties': False,
'required': ['id', 'links']},
{'type': ['string', 'null']}
]},
@@ -95,6 +100,7 @@
'id': {'type': 'string'},
'links': parameter_types.links
},
+ 'additionalProperties': False,
'required': ['id', 'links']
},
'fault': {
@@ -105,6 +111,7 @@
'message': {'type': 'string'},
'details': {'type': 'string'},
},
+ 'additionalProperties': False,
# NOTE(gmann): 'details' is not necessary to be present
# in the 'fault'. So it is not defined as 'required'.
'required': ['code', 'created', 'message']
@@ -122,6 +129,7 @@
'accessIPv4': parameter_types.access_ip_v4,
'accessIPv6': parameter_types.access_ip_v6
},
+ 'additionalProperties': False,
# NOTE(GMann): 'progress' attribute is present in the response
# only when server's status is one of the progress statuses
# ("ACTIVE","BUILD", "REBUILD", "RESIZE","VERIFY_RESIZE")
@@ -142,6 +150,7 @@
'properties': {
'server': common_show_server
},
+ 'additionalProperties': False,
'required': ['server']
}
}
@@ -184,6 +193,7 @@
'properties': {
'server': server_detail
},
+ 'additionalProperties': False,
'required': ['server']
}
}
@@ -199,6 +209,7 @@
},
'servers_links': parameter_types.links
},
+ 'additionalProperties': False,
# NOTE(gmann): servers_links attribute is not necessary to be
# present always So it is not 'required'.
'required': ['servers']
@@ -221,6 +232,7 @@
'properties': {
'adminPass': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['adminPass']
}
}
@@ -239,12 +251,14 @@
'mac_address': parameter_types.mac_address,
'OS-EXT-VIF-NET:net_id': {'type': 'string'}
},
+ 'additionalProperties': False,
# 'OS-EXT-VIF-NET:net_id' is API extension So it is
# not defined as 'required'
'required': ['id', 'mac_address']
}
}
},
+ 'additionalProperties': False,
'required': ['virtual_interfaces']
}
}
@@ -257,6 +271,7 @@
'volumeId': {'type': 'string'},
'serverId': {'type': ['integer', 'string']}
},
+ 'additionalProperties': False,
'required': ['id', 'device', 'volumeId', 'serverId']
}
@@ -267,6 +282,7 @@
'properties': {
'volumeAttachment': common_attach_volume_info
},
+ 'additionalProperties': False,
'required': ['volumeAttachment']
}
}
@@ -289,6 +305,7 @@
'items': common_attach_volume_info
}
},
+ 'additionalProperties': False,
'required': ['volumeAttachments']
}
}
@@ -308,6 +325,7 @@
'properties': {
'addresses': parameter_types.addresses
},
+ 'additionalProperties': False,
'required': ['addresses']
}
}
@@ -329,6 +347,7 @@
},
'metadata': {'type': 'object'}
},
+ 'additionalProperties': False,
'required': ['id', 'name', 'policies', 'members', 'metadata']
}
@@ -339,6 +358,7 @@
'properties': {
'server_group': common_server_group
},
+ 'additionalProperties': False,
'required': ['server_group']
}
}
@@ -357,6 +377,7 @@
'items': common_server_group
}
},
+ 'additionalProperties': False,
'required': ['server_groups']
}
}
@@ -372,6 +393,7 @@
'message': {'type': ['string', 'null']},
'instance_uuid': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['action', 'request_id', 'user_id', 'project_id',
'start_time', 'message', 'instance_uuid']
}
@@ -387,6 +409,7 @@
'result': {'type': 'string'},
'traceback': {'type': ['string', 'null']}
},
+ 'additionalProperties': False,
'required': ['event', 'start_time', 'finish_time', 'result',
'traceback']
}
@@ -402,6 +425,7 @@
'items': instance_actions
}
},
+ 'additionalProperties': False,
'required': ['instanceActions']
}
}
@@ -419,6 +443,7 @@
'properties': {
'instanceAction': instance_actions_with_events
},
+ 'additionalProperties': False,
'required': ['instanceAction']
}
}
@@ -430,6 +455,7 @@
'properties': {
'password': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['password']
}
}
@@ -448,9 +474,11 @@
'format': 'uri'
}
},
+ 'additionalProperties': False,
'required': ['type', 'url']
}
},
+ 'additionalProperties': False,
'required': ['console']
}
}
@@ -462,6 +490,7 @@
'properties': {
'output': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['output']
}
}
@@ -478,6 +507,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['metadata']
}
}
@@ -502,6 +532,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['meta']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/services.py b/tempest/api_schema/response/compute/v2_1/services.py
index 6f361ef..c2c7a51 100644
--- a/tempest/api_schema/response/compute/v2_1/services.py
+++ b/tempest/api_schema/response/compute/v2_1/services.py
@@ -32,11 +32,13 @@
'updated_at': {'type': ['string', 'null']},
'disabled_reason': {'type': ['string', 'null']}
},
+ 'additionalProperties': False,
'required': ['id', 'zone', 'host', 'state', 'binary',
'status', 'updated_at', 'disabled_reason']
}
}
},
+ 'additionalProperties': False,
'required': ['services']
}
}
@@ -53,9 +55,11 @@
'binary': {'type': 'string'},
'host': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['status', 'binary', 'host']
}
},
+ 'additionalProperties': False,
'required': ['service']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/tenant_networks.py b/tempest/api_schema/response/compute/v2_1/tenant_networks.py
index 0b2868a..ddfab96 100644
--- a/tempest/api_schema/response/compute/v2_1/tenant_networks.py
+++ b/tempest/api_schema/response/compute/v2_1/tenant_networks.py
@@ -19,6 +19,7 @@
'cidr': {'type': ['string', 'null']},
'label': {'type': 'string'}
},
+ 'additionalProperties': False,
'required': ['id', 'cidr', 'label']
}
@@ -33,6 +34,7 @@
'items': param_network
}
},
+ 'additionalProperties': False,
'required': ['networks']
}
}
@@ -45,6 +47,7 @@
'properties': {
'network': param_network
},
+ 'additionalProperties': False,
'required': ['network']
}
}
diff --git a/tempest/api_schema/response/compute/v2_1/volumes.py b/tempest/api_schema/response/compute/v2_1/volumes.py
index 541d3ff..bb34acb 100644
--- a/tempest/api_schema/response/compute/v2_1/volumes.py
+++ b/tempest/api_schema/response/compute/v2_1/volumes.py
@@ -39,7 +39,8 @@
'device': {'type': 'string'},
'volumeId': {'type': 'string'},
'serverId': {'type': 'string'}
- }
+ },
+ 'additionalProperties': False,
# NOTE- If volume is not attached to any server
# then, 'attachments' attributes comes as array
# with empty objects "[{}]" due to that elements
@@ -49,11 +50,13 @@
}
}
},
+ 'additionalProperties': False,
'required': ['id', 'status', 'displayName', 'availabilityZone',
'createdAt', 'displayDescription', 'volumeType',
'snapshotId', 'metadata', 'size', 'attachments']
}
},
+ 'additionalProperties': False,
'required': ['volume']
}
}
@@ -87,7 +90,8 @@
'device': {'type': 'string'},
'volumeId': {'type': 'string'},
'serverId': {'type': 'string'}
- }
+ },
+ 'additionalProperties': False,
# NOTE- If volume is not attached to any server
# then, 'attachments' attributes comes as array
# with empty object "[{}]" due to that elements
@@ -97,6 +101,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['id', 'status', 'displayName',
'availabilityZone', 'createdAt',
'displayDescription', 'volumeType',
@@ -105,6 +110,7 @@
}
}
},
+ 'additionalProperties': False,
'required': ['volumes']
}
}
diff --git a/tempest/clients.py b/tempest/clients.py
index 9f6a9bb..e32d401 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -25,116 +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
-from tempest.services.compute.json.quotas_client import QuotaClassesClientJSON
-from tempest.services.compute.json.quotas_client import QuotasClientJSON
+ MigrationsClient
+from tempest.services.compute.json.networks_client import NetworksClient
+from tempest.services.compute.json.quota_classes_client import \
+ QuotaClassesClient
+from tempest.services.compute.json.quotas_client import QuotasClient
from tempest.services.compute.json.security_group_default_rules_client import \
- 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__)
@@ -170,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,
@@ -184,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,
@@ -205,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,
@@ -249,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
@@ -303,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,
@@ -332,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
@@ -371,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 0a48b8d..0360146 100755
--- a/tempest/cmd/account_generator.py
+++ b/tempest/cmd/account_generator.py
@@ -14,7 +14,76 @@
# License for the specific language governing permissions and limitations
# under the License.
+"""
+Utility for creating **accounts.yaml** file for concurrent test runs.
+Creates one primary user, one alt user, one swift admin, one stack owner
+and one admin (optionally) for each concurrent thread. The utility creates
+user for each tenant. The **accounts.yaml** file will be valid and contain
+credentials for created users, so each user will be in separate tenant and
+have the username, tenant_name, password and roles.
+
+**Usage:** ``tempest-account-generator [-h] [OPTIONS] accounts_file.yaml``.
+
+Positional Arguments
+-----------------
+**accounts_file.yaml** (Required) Provide an output accounts yaml file. Utility
+creates a .yaml file in the directory where the command is ran. The appropriate
+name for the file is *accounts.yaml* and it should be placed in *tempest/etc*
+directory.
+
+Authentication
+--------------
+
+Account generator creates users and tenants so it needs the admin credentials
+of your cloud to operate properly. The corresponding info can be given either
+through CLI options or environment variables.
+
+You're probably familiar with these, but just to remind::
+
+ +----------+------------------+----------------------+
+ | Param | CLI | Environment Variable |
+ +----------+------------------+----------------------+
+ | Username | --os-username | OS_USERNAME |
+ | Password | --os-password | OS_PASSWORD |
+ | Tenant | --os-tenant-name | OS_TENANT_NAME |
+ +----------+------------------+----------------------+
+
+Optional Arguments
+-----------------
+**-h**, **--help** (Optional) Shows help message with the description of
+utility and its arguments, and exits.
+
+**c /etc/tempest.conf**, **--config-file /etc/tempest.conf** (Optional) Path to
+tempest config file.
+
+**--os-username <auth-user-name>** (Optional) Name used for authentication with
+the OpenStack Identity service. Defaults to env[OS_USERNAME]. Note: User should
+have permissions to create new user accounts and tenants.
+
+**--os-password <auth-password>** (Optional) Password used for authentication
+with the OpenStack Identity service. Defaults to env[OS_PASSWORD].
+
+**--os-tenant-name <auth-tenant-name>** (Optional) Tenant to request
+authorization on. Defaults to env[OS_TENANT_NAME].
+
+**--tag TAG** (Optional) Resources tag. Each created resource (user, project)
+will have the prefix with the given TAG in its name. Using tag is recommended
+for the further using, cleaning resources.
+
+**-r CONCURRENCY**, **--concurrency CONCURRENCY** (Required) Concurrency count
+(default: 1). The number of accounts required can be estimated as
+CONCURRENCY x 2. Each user provided in *accounts.yaml* file will be in
+a different tenant. This is required to provide isolation between test for
+running in parallel.
+
+**--with-admin** (Optional) Creates admin for each concurrent group
+(default: False).
+
+To see help on specific argument, please do: ``tempest-account-generator
+[OPTIONS] <accounts_file.yaml> -h``.
+"""
import argparse
+import netaddr
import os
from oslo_log import log as logging
@@ -23,6 +92,7 @@
from tempest import config
from tempest import exceptions
from tempest.services.identity.v2.json import identity_client
+from tempest.services.network.json import network_client
import tempest_lib.auth
from tempest_lib.common.utils import data_utils
import tempest_lib.exceptions
@@ -37,7 +107,7 @@
LOG = logging.getLogger(__name__)
-def keystone_admin(opts):
+def get_admin_clients(opts):
_creds = tempest_lib.auth.KeystoneV2Credentials(
username=opts.os_username,
password=opts.os_password,
@@ -58,18 +128,28 @@
'build_interval': CONF.compute.build_interval,
'build_timeout': CONF.compute.build_timeout
}
- return identity_client.IdentityClientJSON(
+ identity_admin = identity_client.IdentityClient(
_auth,
CONF.identity.catalog_type,
CONF.identity.region,
endpoint_type='adminURL',
**params
)
+ network_admin = None
+ if (CONF.service_available.neutron and
+ CONF.auth.create_isolated_networks):
+ network_admin = network_client.NetworkClient(
+ _auth,
+ CONF.network.catalog_type,
+ CONF.network.region or CONF.identity.region,
+ endpoint_type='adminURL',
+ **params)
+ return identity_admin, network_admin
def create_resources(opts, resources):
- admin = keystone_admin(opts)
- roles = admin.list_roles()
+ identity_admin, network_admin = get_admin_clients(opts)
+ roles = identity_admin.list_roles()
for u in resources['users']:
u['role_ids'] = []
for r in u.get('roles', ()):
@@ -80,24 +160,24 @@
raise exceptions.TempestException(
"Role: %s - doesn't exist" % r
)
- existing = [x['name'] for x in admin.list_tenants()]
+ existing = [x['name'] for x in identity_admin.list_tenants()]
for tenant in resources['tenants']:
if tenant not in existing:
- admin.create_tenant(tenant)
+ identity_admin.create_tenant(tenant)
else:
LOG.warn("Tenant '%s' already exists in this environment" % tenant)
LOG.info('Tenants created')
for u in resources['users']:
try:
- tenant = admin.get_tenant_by_name(u['tenant'])
+ tenant = identity_admin.get_tenant_by_name(u['tenant'])
except tempest_lib.exceptions.NotFound:
LOG.error("Tenant: %s - not found" % u['tenant'])
continue
while True:
try:
- admin.get_user_by_username(tenant['id'], u['name'])
+ identity_admin.get_user_by_username(tenant['id'], u['name'])
except tempest_lib.exceptions.NotFound:
- admin.create_user(
+ identity_admin.create_user(
u['name'], u['pass'], tenant['id'],
"%s@%s" % (u['name'], tenant['id']),
enabled=True)
@@ -108,21 +188,30 @@
u['name'] = random_user_name(opts.tag, u['prefix'])
LOG.info('Users created')
+ if network_admin:
+ for u in resources['users']:
+ tenant = identity_admin.get_tenant_by_name(u['tenant'])
+ network_name, router_name = create_network_resources(network_admin,
+ tenant['id'],
+ u['name'])
+ u['network'] = network_name
+ u['router'] = router_name
+ LOG.info('Networks created')
for u in resources['users']:
try:
- tenant = admin.get_tenant_by_name(u['tenant'])
+ tenant = identity_admin.get_tenant_by_name(u['tenant'])
except tempest_lib.exceptions.NotFound:
LOG.error("Tenant: %s - not found" % u['tenant'])
continue
try:
- user = admin.get_user_by_username(tenant['id'],
- u['name'])
+ user = identity_admin.get_user_by_username(tenant['id'],
+ u['name'])
except tempest_lib.exceptions.NotFound:
LOG.error("User: %s - not found" % u['user'])
continue
for r in u['role_ids']:
try:
- admin.assign_user_role(tenant['id'], user['id'], r)
+ identity_admin.assign_user_role(tenant['id'], user['id'], r)
except tempest_lib.exceptions.Conflict:
# don't care if it's already assigned
pass
@@ -130,6 +219,57 @@
LOG.info('Resources deployed successfully!')
+def create_network_resources(network_admin_client, tenant_id, name):
+
+ def _create_network(name):
+ resp_body = network_admin_client.create_network(
+ name=name, tenant_id=tenant_id)
+ return resp_body['network']
+
+ def _create_subnet(subnet_name, network_id):
+ base_cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
+ mask_bits = CONF.network.tenant_network_mask_bits
+ for subnet_cidr in base_cidr.subnet(mask_bits):
+ try:
+ resp_body = network_admin_client.\
+ create_subnet(
+ network_id=network_id, cidr=str(subnet_cidr),
+ name=subnet_name,
+ tenant_id=tenant_id,
+ enable_dhcp=True,
+ ip_version=4)
+ break
+ except tempest_lib.exceptions.BadRequest as e:
+ if 'overlaps with another subnet' not in str(e):
+ raise
+ else:
+ message = 'Available CIDR for subnet creation could not be found'
+ raise Exception(message)
+ return resp_body['subnet']
+
+ def _create_router(router_name):
+ external_net_id = dict(
+ network_id=CONF.network.public_network_id)
+ resp_body = network_admin_client.create_router(
+ router_name,
+ external_gateway_info=external_net_id,
+ tenant_id=tenant_id)
+ return resp_body['router']
+
+ def _add_router_interface(router_id, subnet_id):
+ network_admin_client.add_router_interface_with_subnet_id(
+ router_id, subnet_id)
+
+ network_name = name + "-network"
+ network = _create_network(network_name)
+ subnet_name = name + "-subnet"
+ subnet = _create_subnet(subnet_name, network['id'])
+ router_name = name + "-router"
+ router = _create_router(router_name)
+ _add_router_interface(router['id'], subnet['id'])
+ return network_name, router_name
+
+
def random_user_name(tag, prefix):
if tag:
return data_utils.rand_name('-'.join((tag, prefix)))
@@ -185,12 +325,19 @@
def dump_accounts(opts, resources):
accounts = []
for user in resources['users']:
- accounts.append({
+ account = {
'username': user['name'],
'tenant_name': user['tenant'],
'password': user['pass'],
'roles': user['roles']
- })
+ }
+ if 'network' or 'router' in user:
+ account['resources'] = {}
+ if 'network' in user:
+ account['resources']['network'] = user['network']
+ if 'router' in user:
+ account['resources']['router'] = user['router']
+ accounts.append(account)
if os.path.exists(opts.accounts):
os.rename(opts.accounts, '.'.join((opts.accounts, 'bak')))
with open(opts.accounts, 'w') as f:
@@ -199,9 +346,9 @@
def get_options():
- usage_string = ('account_generator [-h] <ARG> ...\n\n'
+ usage_string = ('tempest-account-generator [-h] <ARG> ...\n\n'
'To see help on specific argument, do:\n'
- 'account_generator <ARG> -h')
+ 'tempest-account-generator <ARG> -h')
parser = argparse.ArgumentParser(
description='Create accounts.yaml file for concurrent test runs. '
'One primary user, one alt user, '
@@ -218,7 +365,7 @@
parser.add_argument('--os-username',
metavar='<auth-user-name>',
default=os.environ.get('OS_USERNAME'),
- help='User should have permitions '
+ help='User should have permissions '
'to create new user accounts and '
'tenants. Defaults to env[OS_USERNAME].')
parser.add_argument('--os-password',
@@ -243,7 +390,7 @@
parser.add_argument('--with-admin',
action='store_true',
dest='admin',
- help='Create admin in every tenant')
+ help='Creates admin for each concurrent group')
parser.add_argument('accounts',
metavar='accounts_file.yaml',
help='Output accounts yaml file')
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 eb6f143..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,14 +367,13 @@
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
- quotas = client.get_absolute_limits()
- self.data['compute_quotas'] = quotas
+ quotas = client.show_limits()
+ self.data['compute_quotas'] = quotas['absolute']
# Begin network service classes
@@ -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,147 +406,20 @@
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()
self.data['networks'] = networks
-class NetworkIpSecPolicyService(NetworkService):
-
- def list(self):
- client = self.client
- ipsecpols = client.list_ipsecpolicies()
- ipsecpols = ipsecpols['ipsecpolicies']
- ipsecpols = self._filter_by_tenant_id(ipsecpols)
- LOG.debug("List count, %s IP Security Policies" % len(ipsecpols))
- return ipsecpols
-
- def delete(self):
- client = self.client
- ipsecpols = self.list()
- for ipsecpol in ipsecpols:
- try:
- client.delete_ipsecpolicy(ipsecpol['id'])
- except Exception as e:
- LOG.exception("Delete IP Securty Policy exception: %s" % e)
- pass
-
- def dry_run(self):
- ipsecpols = self.list()
- self.data['ip_security_policies'] = ipsecpols
-
-
-class NetworkFwPolicyService(NetworkService):
-
- def list(self):
- client = self.client
- fwpols = client.list_firewall_policies()
- fwpols = fwpols['firewall_policies']
- fwpols = self._filter_by_tenant_id(fwpols)
- LOG.debug("List count, %s Firewall Policies" % len(fwpols))
- return fwpols
-
- def delete(self):
- client = self.client
- fwpols = self.list()
- for fwpol in fwpols:
- try:
- client.delete_firewall_policy(fwpol['id'])
- except Exception as e:
- LOG.exception("Delete Firewall Policy exception: %s" % e)
- pass
-
- def dry_run(self):
- fwpols = self.list()
- self.data['firewall_policies'] = fwpols
-
-
-class NetworkFwRulesService(NetworkService):
-
- def list(self):
- client = self.client
- fwrules = client.list_firewall_rules()
- fwrules = fwrules['firewall_rules']
- fwrules = self._filter_by_tenant_id(fwrules)
- LOG.debug("List count, %s Firewall Rules" % len(fwrules))
- return fwrules
-
- def delete(self):
- client = self.client
- fwrules = self.list()
- for fwrule in fwrules:
- try:
- client.delete_firewall_rule(fwrule['id'])
- except Exception as e:
- LOG.exception("Delete Firewall Rule exception: %s" % e)
- pass
-
- def dry_run(self):
- fwrules = self.list()
- self.data['firewall_rules'] = fwrules
-
-
-class NetworkIkePolicyService(NetworkService):
-
- def list(self):
- client = self.client
- ikepols = client.list_ikepolicies()
- ikepols = ikepols['ikepolicies']
- ikepols = self._filter_by_tenant_id(ikepols)
- LOG.debug("List count, %s IKE Policies" % len(ikepols))
- return ikepols
-
- def delete(self):
- client = self.client
- ikepols = self.list()
- for ikepol in ikepols:
- try:
- client.delete_firewall_rule(ikepol['id'])
- except Exception as e:
- LOG.exception("Delete IKE Policy exception: %s" % e)
- pass
-
- def dry_run(self):
- ikepols = self.list()
- self.data['ike_policies'] = ikepols
-
-
-class NetworkVpnServiceService(NetworkService):
-
- def list(self):
- client = self.client
- vpnsrvs = client.list_vpnservices()
- vpnsrvs = vpnsrvs['vpnservices']
- vpnsrvs = self._filter_by_tenant_id(vpnsrvs)
- LOG.debug("List count, %s VPN Services" % len(vpnsrvs))
- return vpnsrvs
-
- def delete(self):
- client = self.client
- vpnsrvs = self.list()
- for vpnsrv in vpnsrvs:
- try:
- client.delete_vpnservice(vpnsrv['id'])
- except Exception as e:
- LOG.exception("Delete VPN Service exception: %s" % e)
- pass
-
- def dry_run(self):
- vpnsrvs = self.list()
- self.data['vpn_services'] = vpnsrvs
-
-
class NetworkFloatingIpService(NetworkService):
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
@@ -561,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()
@@ -574,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]
@@ -590,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()
@@ -621,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()
@@ -646,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()
@@ -671,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()
@@ -696,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()
@@ -721,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()
@@ -746,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()
@@ -759,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
@@ -773,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))
@@ -800,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()
@@ -827,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()
@@ -862,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()
@@ -900,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']
@@ -948,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()
@@ -977,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):
@@ -987,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()
@@ -1025,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()
@@ -1063,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()
@@ -1080,7 +961,6 @@
def get_tenant_cleanup_services():
tenant_services = []
-
if IS_CEILOMETER:
tenant_services.append(TelemetryAlarmService)
if IS_NOVA:
@@ -1094,26 +974,15 @@
if IS_HEAT:
tenant_services.append(StackService)
if IS_NEUTRON:
- if test.is_extension_enabled('vpnaas', 'network'):
- tenant_services.append(NetworkIpSecPolicyService)
- tenant_services.append(NetworkIkePolicyService)
- tenant_services.append(NetworkVpnServiceService)
- if test.is_extension_enabled('fwaas', 'network'):
- tenant_services.append(NetworkFwPolicyService)
- tenant_services.append(NetworkFwRulesService)
- if test.is_extension_enabled('lbaas', 'network'):
- tenant_services.append(NetworkHealthMonitorService)
- tenant_services.append(NetworkMemberService)
- tenant_services.append(NetworkVipService)
- tenant_services.append(NetworkPoolService)
+ 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 d3426c6..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):
@@ -651,13 +654,13 @@
name, fname = _resolve_image(image, 'aki')
aki = client.images.create_image(
'javelin_' + name, 'aki', 'aki')
- client.images.store_image(aki.get('id'), open(fname, 'r'))
+ client.images.store_image_file(aki.get('id'), open(fname, 'r'))
extras['kernel_id'] = aki.get('id')
name, fname = _resolve_image(image, 'ari')
ari = client.images.create_image(
'javelin_' + name, 'ari', 'ari')
- client.images.store_image(ari.get('id'), open(fname, 'r'))
+ client.images.store_image_file(ari.get('id'), open(fname, 'r'))
extras['ramdisk_id'] = ari.get('id')
_, fname = _resolve_image(image, 'file')
@@ -665,7 +668,7 @@
image['name'], image['container_format'],
image['disk_format'], **extras)
image_id = body.get('id')
- client.images.store_image(image_id, open(fname, 'r'))
+ client.images.store_image_file(image_id, open(fname, 'r'))
def destroy_images(images):
@@ -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 f51d9aa..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
@@ -57,14 +57,17 @@
change_option(option, group, value)
+def contains_version(prefix, versions):
+ return any([x for x in versions if x.startswith(prefix)])
+
+
def verify_glance_api_versions(os, update):
# Check glance api versions
- versions = os.image_client.get_versions()
- if CONF.image_feature_enabled.api_v1 != ('v1.1' in versions or 'v1.0' in
- versions):
+ _, versions = os.image_client.get_versions()
+ if CONF.image_feature_enabled.api_v1 != contains_version('v1.', versions):
print_and_or_update('api_v1', 'image_feature_enabled',
not CONF.image_feature_enabled.api_v1, update)
- if CONF.image_feature_enabled.api_v2 != ('v2.0' in versions):
+ if CONF.image_feature_enabled.api_v2 != contains_version('v2.', versions):
print_and_or_update('api_v2', 'image_feature_enabled',
not CONF.image_feature_enabled.api_v2, update)
@@ -100,10 +103,12 @@
def verify_keystone_api_versions(os, update):
# Check keystone api versions
versions = _get_api_versions(os, 'keystone')
- if CONF.identity_feature_enabled.api_v2 != ('v2.0' in versions):
+ if (CONF.identity_feature_enabled.api_v2 !=
+ contains_version('v2.', versions)):
print_and_or_update('api_v2', 'identity_feature_enabled',
not CONF.identity_feature_enabled.api_v2, update)
- if CONF.identity_feature_enabled.api_v3 != ('v3.0' in versions):
+ if (CONF.identity_feature_enabled.api_v3 !=
+ contains_version('v3.', versions)):
print_and_or_update('api_v3', 'identity_feature_enabled',
not CONF.identity_feature_enabled.api_v3, update)
@@ -111,10 +116,12 @@
def verify_cinder_api_versions(os, update):
# Check cinder api versions
versions = _get_api_versions(os, 'cinder')
- if CONF.volume_feature_enabled.api_v1 != ('v1.0' in versions):
+ if (CONF.volume_feature_enabled.api_v1 !=
+ contains_version('v1.', versions)):
print_and_or_update('api_v1', 'volume_feature_enabled',
not CONF.volume_feature_enabled.api_v1, update)
- if CONF.volume_feature_enabled.api_v2 != ('v2.0' in versions):
+ if (CONF.volume_feature_enabled.api_v2 !=
+ contains_version('v2.', versions)):
print_and_or_update('api_v2', 'volume_feature_enabled',
not CONF.volume_feature_enabled.api_v2, update)
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
new file mode 100644
index 0000000..06e3493
--- /dev/null
+++ b/tempest/common/compute.py
@@ -0,0 +1,125 @@
+# Copyright (c) 2015 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.
+
+from oslo_log import log as logging
+from oslo_utils import excutils
+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
+
+LOG = logging.getLogger(__name__)
+
+
+def create_test_server(clients, validatable, validation_resources=None,
+ tenant_network=None, **kwargs):
+ """Common wrapper utility returning a test server.
+
+ This method is a common wrapper returning a test server that can be
+ pingable or sshable.
+
+ :param clients: Client manager which provides Openstack Tempest clients.
+ :param validatable: Whether the server will be pingable or sshable.
+ :param validation_resources: Resources created for the connection to the
+ server. Include a keypair, a security group and an IP.
+ :returns a tuple
+ """
+
+ # TODO(jlanoux) add support of wait_until PINGABLE/SSHABLE
+
+ if 'name' in kwargs:
+ name = kwargs.pop('name')
+ else:
+ name = data_utils.rand_name(__name__ + "-instance")
+
+ flavor = kwargs.get('flavor', CONF.compute.flavor_ref)
+ image_id = kwargs.get('image_id', CONF.compute.image_ref)
+
+ kwargs = fixed_network.set_networks_kwarg(
+ tenant_network, kwargs) or {}
+
+ if CONF.validation.run_validation and validatable:
+ # As a first implementation, multiple pingable or sshable servers will
+ # not be supported
+ if 'min_count' in kwargs or 'max_count' in kwargs:
+ msg = ("Multiple pingable or sshable servers not supported at "
+ "this stage.")
+ raise ValueError(msg)
+
+ if 'security_groups' in kwargs:
+ kwargs['security_groups'].append(
+ {'name': validation_resources['security_group']['name']})
+ else:
+ try:
+ kwargs['security_groups'] = [
+ {'name': validation_resources['security_group']['name']}]
+ except KeyError:
+ LOG.debug("No security group provided.")
+
+ if 'key_name' not in kwargs:
+ try:
+ kwargs['key_name'] = validation_resources['keypair']['name']
+ except KeyError:
+ LOG.debug("No key provided.")
+
+ if CONF.validation.connect_method == 'floating':
+ if 'wait_until' not in kwargs:
+ kwargs['wait_until'] = 'ACTIVE'
+
+ body = clients.servers_client.create_server(name, image_id, flavor,
+ **kwargs)
+
+ # handle the case of multiple servers
+ servers = [body]
+ if 'min_count' in kwargs or 'max_count' in kwargs:
+ # Get servers created which name match with name param.
+ body_servers = clients.servers_client.list_servers()
+ servers = \
+ [s for s in body_servers['servers'] if s['name'].startswith(name)]
+
+ # The name of the method to associate a floating IP to as server is too
+ # long for PEP8 compliance so:
+ assoc = clients.floating_ips_client.associate_floating_ip_to_server
+
+ if 'wait_until' in kwargs:
+ for server in servers:
+ try:
+ 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).
+ if CONF.validation.run_validation and validatable:
+ if CONF.validation.connect_method == 'floating':
+ assoc(floating_ip=validation_resources[
+ 'floating_ip']['ip'],
+ server_id=servers[0]['id'])
+
+ except Exception:
+ with excutils.save_and_reraise_exception():
+ if ('preserve_server_on_error' not in kwargs
+ or kwargs['preserve_server_on_error'] is False):
+ for server in servers:
+ try:
+ clients.servers_client.delete_server(
+ server['id'])
+ except Exception:
+ LOG.exception('Deleting server %s failed'
+ % server['id'])
+
+ return body, servers
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 2c6e334..9ec0ec6 100644
--- a/tempest/common/fixed_network.py
+++ b/tempest/common/fixed_network.py
@@ -14,7 +14,6 @@
from oslo_log import log as logging
from tempest_lib.common.utils import misc as misc_utils
-from tempest_lib import exceptions as lib_exc
from tempest import config
from tempest import exceptions
@@ -28,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
@@ -41,19 +40,8 @@
if not name:
raise exceptions.InvalidConfiguration()
- try:
- networks = compute_networks_client.list_networks(name=name)
- except lib_exc.NotFound:
- # In case of nova network, if the fixed_network_name is not
- # owned by the tenant, and the network client is not an admin
- # one, list_networks will not find it
- msg = ('Unable to find network %s. '
- 'Starting instance without specifying a network.' %
- name)
- if caller:
- msg = '(%s) %s' % (caller, msg)
- LOG.info(msg)
- raise exceptions.InvalidConfiguration()
+ networks = compute_networks_client.list_networks()
+ networks = [n for n in networks if n['label'] == name]
# Check that a network exists, else raise an InvalidConfigurationException
if len(networks) == 1:
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 4b3995b..93c2c10 100644
--- a/tempest/common/utils/linux/remote_client.py
+++ b/tempest/common/utils/linux/remote_client.py
@@ -14,6 +14,7 @@
import re
import time
+from oslo_log import log as logging
import six
from tempest_lib.common import ssh
@@ -22,15 +23,17 @@
CONF = config.CONF
+LOG = logging.getLogger(__name__)
+
class RemoteClient(object):
# 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:
@@ -43,12 +46,13 @@
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,
# path is extended for some non-cirros guest oses (centos7)
- cmd = "set -eu -o pipefail; PATH=$PATH:/sbin; " + cmd
+ cmd = CONF.compute.ssh_shell_prologue + " " + cmd
+ LOG.debug("Remote command: %s" % cmd)
return self.ssh_client.exec_command(cmd)
def validate_authentication(self):
@@ -68,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 61ce408..ab503e3 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 "
@@ -206,6 +210,10 @@
help="Timeout in seconds to wait for an instance to build. "
"Other services that do not define build_timeout will "
"inherit this value."),
+ cfg.StrOpt('ssh_shell_prologue',
+ default="set -eu -o pipefail; PATH=$$PATH:/sbin;",
+ help="Shell fragments to use before executing a command "
+ "when sshing to a guest."),
cfg.StrOpt('ssh_auth_method',
default='keypair',
help="Auth method used for authenticate to the instance. "
@@ -235,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"
@@ -258,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 +388,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.'),
]
@@ -437,6 +448,10 @@
cfg.BoolOpt('api_v1',
default=True,
help="Is the v1 image API enabled"),
+ cfg.BoolOpt('deactivate_image',
+ default=False,
+ help="Is the deactivate-image feature enabled."
+ " The feature has been integrated since Kilo."),
]
network_group = cfg.OptGroup(name='network',
@@ -516,9 +531,10 @@
help="Allow the execution of IPv6 tests"),
cfg.ListOpt('api_extensions',
default=['all'],
- help='A list of enabled network extensions with a special '
- 'entry all which indicates every extension is enabled. '
- 'Empty list indicates all extensions are disabled'),
+ help="A list of enabled network extensions with a special "
+ "entry all which indicates every extension is enabled. "
+ "Empty list indicates all extensions are disabled. "
+ "To get the list of extensions run: 'neutron ext-list'"),
cfg.BoolOpt('ipv6_subnet_attributes',
default=False,
help="Allow the execution of IPv6 subnet tests that use "
@@ -590,17 +606,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',
@@ -821,6 +843,16 @@
]
+telemetry_feature_group = cfg.OptGroup(name='telemetry-feature-enabled',
+ title='Enabled Ceilometer Features')
+
+TelemetryFeaturesGroup = [
+ cfg.BoolOpt('events',
+ default=False,
+ help="Runs Ceilometer event-related tests"),
+]
+
+
dashboard_group = cfg.OptGroup(name="dashboard",
title="Dashboard options")
@@ -1133,6 +1165,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),
@@ -1152,6 +1193,7 @@
(database_group, DatabaseGroup),
(orchestration_group, OrchestrationGroup),
(telemetry_group, TelemetryGroup),
+ (telemetry_feature_group, TelemetryFeaturesGroup),
(dashboard_group, DashboardGroup),
(data_processing_group, DataProcessingGroup),
(data_processing_feature_group, DataProcessingFeaturesGroup),
@@ -1162,13 +1204,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():
@@ -1177,7 +1224,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
@@ -1214,6 +1261,7 @@
self.orchestration = _CONF.orchestration
self.messaging = _CONF.messaging
self.telemetry = _CONF.telemetry
+ self.telemetry_feature_enabled = _CONF['telemetry-feature-enabled']
self.dashboard = _CONF.dashboard
self.data_processing = _CONF.data_processing
self.data_processing_feature_enabled = _CONF[
@@ -1226,9 +1274,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/hacking/checks.py b/tempest/hacking/checks.py
index 29898a9..db6375f 100644
--- a/tempest/hacking/checks.py
+++ b/tempest/hacking/checks.py
@@ -27,6 +27,7 @@
SETUP_TEARDOWN_CLASS_DEFINITION = re.compile(r'^\s+def (setUp|tearDown)Class')
SCENARIO_DECORATOR = re.compile(r'\s*@.*services\((.*)\)')
VI_HEADER_RE = re.compile(r"^#\s+vim?:.+")
+RAND_NAME_HYPHEN_RE = re.compile(r".*rand_name\(.+[\-\_][\"\']\)")
mutable_default_args = re.compile(r"^\s*def .+\((.+=\{\}|.+=\[\])")
@@ -106,6 +107,21 @@
"T107: service tag should not be in path")
+def no_hyphen_at_end_of_rand_name(logical_line, filename):
+ """Check no hyphen at the end of rand_name() argument
+
+ T108
+ """
+ if './tempest/api/network/' in filename:
+ # Network API tests are migrating from Tempest to Neutron repo now.
+ # So here should avoid network API tests checks.
+ return
+
+ msg = "T108: hyphen should not be specified at the end of rand_name()"
+ if RAND_NAME_HYPHEN_RE.match(logical_line):
+ return 0, msg
+
+
def no_mutable_default_args(logical_line):
"""Check that mutable object isn't used as default argument
@@ -122,4 +138,5 @@
register(no_setup_teardown_class_for_tests)
register(no_vi_headers)
register(service_tags_not_in_module_path)
+ register(no_hyphen_at_end_of_rand_name)
register(no_mutable_default_args)
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 5f8d605..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):
@@ -934,41 +940,6 @@
return rules
- def _create_pool(self, lb_method, protocol, subnet_id):
- """Wrapper utility that returns a test pool."""
- client = self.network_client
- name = data_utils.rand_name('pool')
- resp_pool = client.create_pool(protocol=protocol, name=name,
- subnet_id=subnet_id,
- lb_method=lb_method)
- pool = net_resources.DeletablePool(client=client, **resp_pool['pool'])
- self.assertEqual(pool['name'], name)
- self.addCleanup(self.delete_wrapper, pool.delete)
- return pool
-
- def _create_member(self, address, protocol_port, pool_id):
- """Wrapper utility that returns a test member."""
- client = self.network_client
- resp_member = client.create_member(protocol_port=protocol_port,
- pool_id=pool_id,
- address=address)
- member = net_resources.DeletableMember(client=client,
- **resp_member['member'])
- self.addCleanup(self.delete_wrapper, member.delete)
- return member
-
- def _create_vip(self, protocol, protocol_port, subnet_id, pool_id):
- """Wrapper utility that returns a test vip."""
- client = self.network_client
- name = data_utils.rand_name('vip')
- resp_vip = client.create_vip(protocol=protocol, name=name,
- subnet_id=subnet_id, pool_id=pool_id,
- protocol_port=protocol_port)
- vip = net_resources.DeletableVip(client=client, **resp_vip['vip'])
- self.assertEqual(vip['name'], name)
- self.addCleanup(self.delete_wrapper, vip.delete)
- return vip
-
def _ssh_to_server(self, server, private_key):
ssh_login = CONF.compute.image_ssh_user
return self.get_remote_client(server,
@@ -1261,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 e54c25a..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')
@@ -98,7 +101,7 @@
def get_flavor_ephemeral_size(self):
"""Returns size of the ephemeral partition in GiB."""
f_id = self.instance['flavor']['id']
- flavor = self.flavors_client.get_flavor_details(f_id)
+ flavor = self.flavors_client.show_flavor(f_id)
ephemeral = flavor.get('OS-FLV-EXT-DATA:ephemeral')
if not ephemeral or ephemeral == 'N/A':
return None
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_load_balancer_basic.py b/tempest/scenario/test_load_balancer_basic.py
deleted file mode 100644
index 691c7c9..0000000
--- a/tempest/scenario/test_load_balancer_basic.py
+++ /dev/null
@@ -1,321 +0,0 @@
-# Copyright 2014 Mirantis.inc
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-
-import tempfile
-import time
-
-import six
-from six.moves.urllib import request as urllib2
-
-from tempest.common import commands
-from tempest import config
-from tempest import exceptions
-from tempest.scenario import manager
-from tempest.services.network import resources as net_resources
-from tempest import test
-
-config = config.CONF
-
-
-class TestLoadBalancerBasic(manager.NetworkScenarioTest):
-
- """
- This test checks basic load balancing.
-
- The following is the scenario outline:
- 1. Create an instance
- 2. SSH to the instance and start two servers
- 3. Create a load balancer with two members and with ROUND_ROBIN algorithm
- associate the VIP with a floating ip
- 4. Send NUM requests to the floating ip and check that they are shared
- between the two servers.
- """
-
- @classmethod
- def skip_checks(cls):
- super(TestLoadBalancerBasic, cls).skip_checks()
- cfg = config.network
- if not test.is_extension_enabled('lbaas', 'network'):
- msg = 'LBaaS Extension is not enabled'
- raise cls.skipException(msg)
- if not (cfg.tenant_networks_reachable or cfg.public_network_id):
- msg = ('Either tenant_networks_reachable must be "true", or '
- 'public_network_id must be defined.')
- raise cls.skipException(msg)
-
- @classmethod
- def resource_setup(cls):
- super(TestLoadBalancerBasic, cls).resource_setup()
- cls.servers_keypairs = {}
- cls.members = []
- cls.floating_ips = {}
- cls.server_ips = {}
- cls.port1 = 80
- cls.port2 = 88
- cls.num = 50
-
- def setUp(self):
- super(TestLoadBalancerBasic, self).setUp()
- self.server_ips = {}
- self.server_fixed_ips = {}
- self._create_security_group_for_test()
- self._set_net_and_subnet()
-
- def _set_net_and_subnet(self):
- """
- Query and set appropriate network and subnet attributes to be used
- for the test. Existing tenant networks are used if they are found.
- The configured private network and associated subnet is used as a
- fallback in absence of tenant networking.
- """
- try:
- tenant_net = self._list_networks(tenant_id=self.tenant_id)[0]
- except IndexError:
- tenant_net = None
-
- if tenant_net:
- tenant_subnet = self._list_subnets(tenant_id=self.tenant_id)[0]
- self.subnet = net_resources.DeletableSubnet(
- client=self.network_client,
- **tenant_subnet)
- self.network = tenant_net
- else:
- self.network = self._get_network_by_name(
- config.compute.fixed_network_name)
- # TODO(adam_g): We are assuming that the first subnet associated
- # with the fixed network is the one we want. In the future, we
- # should instead pull a subnet id from config, which is set by
- # devstack/admin/etc.
- subnet = self._list_subnets(network_id=self.network['id'])[0]
- self.subnet = net_resources.AttributeDict(subnet)
-
- def _create_security_group_for_test(self):
- self.security_group = self._create_security_group(
- tenant_id=self.tenant_id)
- self._create_security_group_rules_for_port(self.port1)
- self._create_security_group_rules_for_port(self.port2)
-
- def _create_security_group_rules_for_port(self, port):
- rule = {
- 'direction': 'ingress',
- 'protocol': 'tcp',
- 'port_range_min': port,
- 'port_range_max': port,
- }
- self._create_security_group_rule(
- secgroup=self.security_group,
- tenant_id=self.tenant_id,
- **rule)
-
- def _create_server(self, name):
- keypair = self.create_keypair()
- security_groups = [{'name': self.security_group['name']}]
- create_kwargs = {
- 'networks': [
- {'uuid': self.network['id']},
- ],
- 'key_name': keypair['name'],
- 'security_groups': security_groups,
- }
- net_name = self.network['name']
- server = self.create_server(name=name, create_kwargs=create_kwargs)
- self.servers_keypairs[server['id']] = keypair
- if (config.network.public_network_id and not
- config.network.tenant_networks_reachable):
- public_network_id = config.network.public_network_id
- floating_ip = self.create_floating_ip(
- server, public_network_id)
- self.floating_ips[floating_ip] = server
- self.server_ips[server['id']] = floating_ip.floating_ip_address
- else:
- self.server_ips[server['id']] =\
- server['addresses'][net_name][0]['addr']
- self.server_fixed_ips[server['id']] =\
- server['addresses'][net_name][0]['addr']
- self.assertTrue(self.servers_keypairs)
- return server
-
- def _create_servers(self):
- for count in range(2):
- self._create_server(name=("server%s" % (count + 1)))
- self.assertEqual(len(self.servers_keypairs), 2)
-
- def _start_servers(self):
- """
- Start two backends
-
- 1. SSH to the instance
- 2. Start two http backends listening on ports 80 and 88 respectively
- """
- for server_id, ip in six.iteritems(self.server_ips):
- private_key = self.servers_keypairs[server_id]['private_key']
- server_name = self.servers_client.get_server(server_id)['name']
- username = config.scenario.ssh_user
- ssh_client = self.get_remote_client(
- server_or_ip=ip,
- private_key=private_key)
-
- # Write a backend's response into a file
- resp = ('echo -ne "HTTP/1.1 200 OK\r\nContent-Length: 7\r\n'
- 'Connection: close\r\nContent-Type: text/html; '
- 'charset=UTF-8\r\n\r\n%s"; cat >/dev/null')
-
- with tempfile.NamedTemporaryFile() as script:
- script.write(resp % server_name)
- script.flush()
- with tempfile.NamedTemporaryFile() as key:
- key.write(private_key)
- key.flush()
- commands.copy_file_to_host(script.name,
- "/tmp/script1",
- ip,
- username, key.name)
-
- # Start netcat
- start_server = ('while true; do '
- 'sudo nc -ll -p %(port)s -e sh /tmp/%(script)s; '
- 'done > /dev/null &')
- cmd = start_server % {'port': self.port1,
- 'script': 'script1'}
- ssh_client.exec_command(cmd)
-
- if len(self.server_ips) == 1:
- with tempfile.NamedTemporaryFile() as script:
- script.write(resp % 'server2')
- script.flush()
- with tempfile.NamedTemporaryFile() as key:
- key.write(private_key)
- key.flush()
- commands.copy_file_to_host(script.name,
- "/tmp/script2", ip,
- username, key.name)
- cmd = start_server % {'port': self.port2,
- 'script': 'script2'}
- ssh_client.exec_command(cmd)
-
- def _check_connection(self, check_ip, port=80):
- def try_connect(ip, port):
- try:
- resp = urllib2.urlopen("http://{0}:{1}/".format(ip, port))
- if resp.getcode() == 200:
- return True
- return False
- except IOError:
- return False
- except urllib2.HTTPError:
- return False
- timeout = config.compute.ping_timeout
- start = time.time()
- while not try_connect(check_ip, port):
- if (time.time() - start) > timeout:
- message = "Timed out trying to connect to %s" % check_ip
- raise exceptions.TimeoutException(message)
-
- def _create_pool(self):
- """Create a pool with ROUND_ROBIN algorithm."""
- self.pool = super(TestLoadBalancerBasic, self)._create_pool(
- lb_method='ROUND_ROBIN',
- protocol='HTTP',
- subnet_id=self.subnet.id)
- self.assertTrue(self.pool)
-
- def _create_members(self):
- """
- Create two members.
-
- In case there is only one server, create both members with the same ip
- but with different ports to listen on.
- """
-
- for server_id, ip in six.iteritems(self.server_fixed_ips):
- if len(self.server_fixed_ips) == 1:
- member1 = self._create_member(address=ip,
- protocol_port=self.port1,
- pool_id=self.pool.id)
- member2 = self._create_member(address=ip,
- protocol_port=self.port2,
- pool_id=self.pool.id)
- self.members.extend([member1, member2])
- else:
- member = self._create_member(address=ip,
- protocol_port=self.port1,
- pool_id=self.pool.id)
- self.members.append(member)
- self.assertTrue(self.members)
-
- def _assign_floating_ip_to_vip(self, vip):
- public_network_id = config.network.public_network_id
- port_id = vip.port_id
- floating_ip = self.create_floating_ip(vip, public_network_id,
- port_id=port_id)
- self.floating_ips.setdefault(vip.id, [])
- self.floating_ips[vip.id].append(floating_ip)
- # Check for floating ip status before you check load-balancer
- self.check_floating_ip_status(floating_ip, "ACTIVE")
-
- def _create_load_balancer(self):
- self._create_pool()
- self._create_members()
- self.vip = self._create_vip(protocol='HTTP',
- protocol_port=80,
- subnet_id=self.subnet.id,
- pool_id=self.pool.id)
- self.vip.wait_for_status('ACTIVE')
- if (config.network.public_network_id and not
- config.network.tenant_networks_reachable):
- self._assign_floating_ip_to_vip(self.vip)
- self.vip_ip = self.floating_ips[
- self.vip.id][0]['floating_ip_address']
- else:
- self.vip_ip = self.vip.address
-
- # Currently the ovs-agent is not enforcing security groups on the
- # vip port - see https://bugs.launchpad.net/neutron/+bug/1163569
- # However the linuxbridge-agent does, and it is necessary to add a
- # security group with a rule that allows tcp port 80 to the vip port.
- self.network_client.update_port(
- self.vip.port_id, security_groups=[self.security_group.id])
-
- def _check_load_balancing(self):
- """
- 1. Send NUM requests on the floating ip associated with the VIP
- 2. Check that the requests are shared between the two servers
- """
-
- self._check_connection(self.vip_ip)
- self._send_requests(self.vip_ip, ["server1", "server2"])
-
- def _send_requests(self, vip_ip, servers):
- counters = dict.fromkeys(servers, 0)
- for i in range(self.num):
- try:
- server = urllib2.urlopen("http://{0}/".format(vip_ip)).read()
- counters[server] += 1
- # HTTP exception means fail of server, so don't increase counter
- # of success and continue connection tries
- except urllib2.HTTPError:
- continue
- # Assert that each member of the pool gets balanced at least once
- for member, counter in six.iteritems(counters):
- self.assertGreater(counter, 0, 'Member %s never balanced' % member)
-
- @test.idempotent_id('c0c6f1ca-603b-4509-9c0f-2c63f0d838ee')
- @test.services('compute', 'network')
- def test_load_balancer_basic(self):
- self._create_server('server1')
- self._start_servers()
- self._create_load_balancer()
- self._check_load_balancing()
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_network_v6.py b/tempest/scenario/test_network_v6.py
index 6e67c4b..fba839a 100644
--- a/tempest/scenario/test_network_v6.py
+++ b/tempest/scenario/test_network_v6.py
@@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import functools
-import netaddr
from oslo_log import log as logging
import six
@@ -28,12 +27,13 @@
class TestGettingAddress(manager.NetworkScenarioTest):
- """Create network with 2 subnets: IPv4 and IPv6 in a given address mode
+ """Create network with subnets: one IPv4 and
+ one or few IPv6 in a given address mode
Boot 2 VMs on this network
Allocate and assign 2 FIP4
- Check that vNIC of server matches port data from OpenStack DB
- Ping4 tenant IPv4 of one VM from another one
- Will do the same with ping6 when available in VM
+ Check that vNICs of all VMs gets all addresses actually assigned
+ Ping4 to one VM from another one
+ If ping6 available in VM, do ping6 to all v6 addresses
"""
@classmethod
@@ -65,41 +65,41 @@
'key_name': self.keypair['name'],
'security_groups': [{'name': self.sec_grp['name']}]}
- def prepare_network(self, address6_mode):
+ def prepare_network(self, address6_mode, n_subnets6=1):
"""Creates network with
- one IPv6 subnet in the given mode and
+ given number of IPv6 subnets in the given mode and
one IPv4 subnet
- Creates router with ports on both subnets
+ Creates router with ports on all subnets
"""
self.network = self._create_network(tenant_id=self.tenant_id)
sub4 = self._create_subnet(network=self.network,
namestart='sub4',
ip_version=4,)
- # since https://bugs.launchpad.net/neutron/+bug/1394112 we need
- # to specify gateway_ip manually
- net_range = netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr)
- gateway_ip = (netaddr.IPAddress(net_range) + 1).format()
- sub6 = self._create_subnet(network=self.network,
- namestart='sub6',
- ip_version=6,
- gateway_ip=gateway_ip,
- ipv6_ra_mode=address6_mode,
- ipv6_address_mode=address6_mode)
router = self._get_router(tenant_id=self.tenant_id)
sub4.add_to_router(router_id=router['id'])
- sub6.add_to_router(router_id=router['id'])
self.addCleanup(sub4.delete)
- self.addCleanup(sub6.delete)
+
+ for _ in range(n_subnets6):
+ sub6 = self._create_subnet(network=self.network,
+ namestart='sub6',
+ ip_version=6,
+ ipv6_ra_mode=address6_mode,
+ ipv6_address_mode=address6_mode)
+
+ sub6.add_to_router(router_id=router['id'])
+ self.addCleanup(sub6.delete)
@staticmethod
def define_server_ips(srv):
+ ips = {'4': None, '6': []}
for net_name, nics in six.iteritems(srv['addresses']):
for nic in nics:
if nic['version'] == 6:
- srv['accessIPv6'] = nic['addr']
+ ips['6'].append(nic['addr'])
else:
- srv['accessIPv4'] = nic['addr']
+ ips['4'] = nic['addr']
+ return ips
def prepare_server(self):
username = CONF.compute.image_ssh_user
@@ -109,53 +109,56 @@
srv = self.create_server(create_kwargs=create_kwargs)
fip = self.create_floating_ip(thing=srv)
- self.define_server_ips(srv=srv)
+ ips = self.define_server_ips(srv=srv)
ssh = self.get_remote_client(
server_or_ip=fip.floating_ip_address,
username=username)
- return ssh, srv
+ return ssh, ips
- def _prepare_and_test(self, address6_mode):
- self.prepare_network(address6_mode=address6_mode)
+ def _prepare_and_test(self, address6_mode, n_subnets6=1):
+ self.prepare_network(address6_mode=address6_mode,
+ n_subnets6=n_subnets6)
- ssh1, srv1 = self.prepare_server()
- ssh2, srv2 = self.prepare_server()
+ sshv4_1, ips_from_api_1 = self.prepare_server()
+ sshv4_2, ips_from_api_2 = self.prepare_server()
def guest_has_address(ssh, addr):
return addr in ssh.get_ip_list()
- srv1_v6_addr_assigned = functools.partial(
- guest_has_address, ssh1, srv1['accessIPv6'])
- srv2_v6_addr_assigned = functools.partial(
- guest_has_address, ssh2, srv2['accessIPv6'])
+ # get addresses assigned to vNIC as reported by 'ip address' utility
+ ips_from_ip_1 = sshv4_1.get_ip_list()
+ ips_from_ip_2 = sshv4_2.get_ip_list()
+ self.assertIn(ips_from_api_1['4'], ips_from_ip_1)
+ self.assertIn(ips_from_api_2['4'], ips_from_ip_2)
+ for i in range(n_subnets6):
+ # v6 should be configured since the image supports it
+ # It can take time for ipv6 automatic address to get assigned
+ srv1_v6_addr_assigned = functools.partial(
+ guest_has_address, sshv4_1, ips_from_api_1['6'][i])
- result = ssh1.get_ip_list()
- self.assertIn(srv1['accessIPv4'], result)
- # v6 should be configured since the image supports it
- # It can take time for ipv6 automatic address to get assigned
- self.assertTrue(
- test.call_until_true(srv1_v6_addr_assigned,
- CONF.compute.ping_timeout, 1))
- result = ssh2.get_ip_list()
- self.assertIn(srv2['accessIPv4'], result)
- # v6 should be configured since the image supports it
- # It can take time for ipv6 automatic address to get assigned
- self.assertTrue(
- test.call_until_true(srv2_v6_addr_assigned,
- CONF.compute.ping_timeout, 1))
- result = ssh1.ping_host(srv2['accessIPv4'])
+ srv2_v6_addr_assigned = functools.partial(
+ guest_has_address, sshv4_2, ips_from_api_2['6'][i])
+
+ self.assertTrue(test.call_until_true(srv1_v6_addr_assigned,
+ CONF.compute.ping_timeout, 1))
+
+ self.assertTrue(test.call_until_true(srv2_v6_addr_assigned,
+ CONF.compute.ping_timeout, 1))
+
+ result = sshv4_1.ping_host(ips_from_api_2['4'])
self.assertIn('0% packet loss', result)
- result = ssh2.ping_host(srv1['accessIPv4'])
+ result = sshv4_2.ping_host(ips_from_api_1['4'])
self.assertIn('0% packet loss', result)
# Some VM (like cirros) may not have ping6 utility
- result = ssh1.exec_command('whereis ping6')
+ result = sshv4_1.exec_command('whereis ping6')
is_ping6 = False if result == 'ping6:\n' else True
if is_ping6:
- result = ssh1.ping_host(srv2['accessIPv6'])
- self.assertIn('0% packet loss', result)
- result = ssh2.ping_host(srv1['accessIPv6'])
- self.assertIn('0% packet loss', result)
+ for i in range(n_subnets6):
+ result = sshv4_1.ping_host(ips_from_api_2['6'][i])
+ self.assertIn('0% packet loss', result)
+ result = sshv4_2.ping_host(ips_from_api_1['6'][i])
+ self.assertIn('0% packet loss', result)
else:
LOG.warning('Ping6 is not available, skipping')
@@ -168,3 +171,13 @@
@test.services('compute', 'network')
def test_dhcp6_stateless_from_os(self):
self._prepare_and_test(address6_mode='dhcpv6-stateless')
+
+ @test.idempotent_id('7ab23f41-833b-4a16-a7c9-5b42fe6d4123')
+ @test.services('compute', 'network')
+ def test_multi_prefix_dhcpv6_stateless(self):
+ self._prepare_and_test(address6_mode='dhcpv6-stateless', n_subnets6=2)
+
+ @test.idempotent_id('dec222b1-180c-4098-b8c5-cc1b8342d611')
+ @test.services('compute', 'network')
+ def test_multi_prefix_slaac(self):
+ self._prepare_and_test(address6_mode='slaac', n_subnets6=2)
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..3809831 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
@@ -106,8 +106,7 @@
floating_ip['ip'], server['id'])
ip = floating_ip['ip']
else:
- network_name_for_ssh = CONF.compute.network_for_ssh
- ip = server.networks[network_name_for_ssh][0]
+ ip = server
return self.get_remote_client(ip, private_key=keypair['private_key'],
log_console_of_servers=[server])
@@ -134,12 +133,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 +150,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 +162,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 +176,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 f8d9dd4..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
@@ -65,7 +65,7 @@
def is_flavor_enough(self, flavor_id, image_id):
_image = self.images_client.show_image(image_id)
- _flavor = self.flavors_client.get_flavor_details(flavor_id)
+ _flavor = self.flavors_client.show_flavor(flavor_id)
return self._is_flavor_enough(_flavor, _image)
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 7ba424f..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 get_fixed_ip_details(self, fixed_ip):
- url = "os-fixed-ips/%s" % (fixed_ip)
+ def show_fixed_ip(self, fixed_ip):
+ url = "os-fixed-ips/%s" % fixed_ip
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.get_fixed_ip, resp, body)
return service_client.ResponseBody(resp, body['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 7938d8e..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,30 +24,25 @@
from tempest.common import service_client
-class FlavorsClientJSON(service_client.ServiceClient):
+class FlavorsClient(service_client.ServiceClient):
- def list_flavors(self, params=None):
+ def list_flavors(self, detail=False, **params):
url = 'flavors'
+ _schema = schema.list_flavors
+
+ if detail:
+ url += '/detail'
+ _schema = schema.list_flavors_details
if params:
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
- self.validate_response(schema.list_flavors, resp, body)
+ self.validate_response(_schema, resp, body)
return service_client.ResponseBodyList(resp, body['flavors'])
- def list_flavors_with_detail(self, params=None):
- url = 'flavors/detail'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_flavors_details, resp, body)
- return service_client.ResponseBodyList(resp, body['flavors'])
-
- def get_flavor_details(self, flavor_id):
- resp, body = self.get("flavors/%s" % str(flavor_id))
+ def show_flavor(self, flavor_id):
+ resp, body = self.get("flavors/%s" % flavor_id)
body = json.loads(body)
self.validate_response(schema.create_get_flavor_details, resp, body)
return service_client.ResponseBody(resp, body['flavor'])
@@ -84,10 +78,10 @@
return service_client.ResponseBody(resp, body)
def is_resource_deleted(self, id):
- # Did not use get_flavor_details(id) for verification as it gives
+ # Did not use show_flavor(id) for verification as it gives
# 200 ok even for deleted id. LP #981263
# we can remove the loop here and use get by ID when bug gets sortedout
- flavors = self.list_flavors_with_detail()
+ flavors = self.list_flavors(detail=True)
for flavor in flavors:
if flavor['id'] == id:
return False
@@ -108,7 +102,7 @@
resp, body)
return service_client.ResponseBody(resp, body['extra_specs'])
- def get_flavor_extra_spec(self, flavor_id):
+ def list_flavor_extra_specs(self, flavor_id):
"""Gets extra Specs details of the mentioned flavor."""
resp, body = self.get('flavors/%s/os-extra_specs' % flavor_id)
body = json.loads(body)
@@ -116,9 +110,9 @@
resp, body)
return service_client.ResponseBody(resp, body['extra_specs'])
- def get_flavor_extra_spec_with_key(self, flavor_id, key):
+ 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(
@@ -139,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..1e2133b
--- /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..8b1c5a9
--- /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 f30bfdb..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:
@@ -35,9 +34,9 @@
self.validate_response(schema.list_floating_ips, resp, body)
return service_client.ResponseBodyList(resp, body['floating_ips'])
- def get_floating_ip_details(self, floating_ip_id):
+ 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,
@@ -90,7 +89,7 @@
def is_resource_deleted(self, id):
try:
- self.get_floating_ip_details(id)
+ self.show_floating_ip(id)
except lib_exc.NotFound:
return True
return False
@@ -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 287482f..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'
@@ -34,10 +33,10 @@
self.validate_response(schema.list_hosts, resp, body)
return service_client.ResponseBodyList(resp, body['hosts'])
- def show_host_detail(self, hostname):
+ 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 49ac266..e894a5c 100644
--- a/tempest/services/compute/json/hypervisor_client.py
+++ b/tempest/services/compute/json/hypervisor_client.py
@@ -13,59 +13,58 @@
# 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 get_hypervisor_list(self):
+ def list_hypervisors(self, detail=False):
"""List hypervisors information."""
- resp, body = self.get('os-hypervisors')
+ url = 'os-hypervisors'
+ _schema = schema.list_search_hypervisors
+ if detail:
+ url += '/detail'
+ _schema = schema.list_hypervisors_detail
+
+ resp, body = self.get(url)
body = json.loads(body)
- self.validate_response(schema.list_search_hypervisors, resp, body)
+ self.validate_response(_schema, resp, body)
return service_client.ResponseBodyList(resp, body['hypervisors'])
- def get_hypervisor_list_details(self):
- """Show detailed hypervisors information."""
- resp, body = self.get('os-hypervisors/detail')
- body = json.loads(body)
- self.validate_response(schema.list_hypervisors_detail, resp, body)
- return service_client.ResponseBodyList(resp, body['hypervisors'])
-
- def get_hypervisor_show_details(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 get_hypervisor_servers(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'])
- def get_hypervisor_stats(self):
+ def show_hypervisor_statistics(self):
"""Get hypervisor statistics over all compute nodes."""
resp, body = self.get('os-hypervisors/statistics')
body = json.loads(body)
self.validate_response(schema.get_hypervisor_statistics, resp, body)
return service_client.ResponseBody(resp, body['hypervisor_statistics'])
- def get_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 30aa962..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,36 +36,30 @@
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)
- def list_images(self, params=None):
+ def list_images(self, detail=False, **params):
"""Returns a list of all images filtered by any parameters."""
url = 'images'
+ _schema = schema.list_images
+ if detail:
+ url += '/detail'
+ _schema = schema.list_images_details
+
if params:
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
- self.validate_response(schema.list_images, resp, body)
- return service_client.ResponseBodyList(resp, body['images'])
-
- def list_images_with_detail(self, params=None):
- """Returns a detailed list of images filtered by any parameters."""
- url = 'images/detail'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_images_details, resp, body)
+ self.validate_response(_schema, resp, body)
return service_client.ResponseBodyList(resp, body['images'])
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)
@@ -75,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'])
@@ -93,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'])
@@ -101,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 get_image_metadata_item(self, image_id, key):
+ 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'])
@@ -116,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)
@@ -125,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 33ba76f..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'
@@ -31,7 +31,7 @@
return service_client.ResponseBody(resp,
body["instance_usage_audit_logs"])
- def get_instance_usage_audit_log(self, time_before):
+ def show_instance_usage_audit_log(self, time_before):
url = 'os-instance_usage_audit_log/%s' % time_before
resp, body = self.get(url)
body = json.loads(body)
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 7fe335b..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 get_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 d2aaec6..4287619 100644
--- a/tempest/services/compute/json/limits_client.py
+++ b/tempest/services/compute/json/limits_client.py
@@ -13,25 +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 limits as schema
from tempest.common import service_client
-class LimitsClientJSON(service_client.ServiceClient):
+class LimitsClient(service_client.ServiceClient):
- def get_absolute_limits(self):
+ def show_limits(self):
resp, body = self.get("limits")
body = json.loads(body)
self.validate_response(schema.get_limit, resp, body)
- return service_client.ResponseBody(resp, body['limits']['absolute'])
-
- def get_specific_absolute_limit(self, absolute_limit):
- resp, body = self.get("limits")
- body = json.loads(body)
- self.validate_response(schema.get_limit, resp, body)
- if absolute_limit not in body['limits']['absolute']:
- return None
- else:
- return body['limits']['absolute'][absolute_limit]
+ return service_client.ResponseBody(resp, body['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 0ae0920..6373f01 100644
--- a/tempest/services/compute/json/networks_client.py
+++ b/tempest/services/compute/json/networks_client.py
@@ -13,25 +13,21 @@
# 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, name=None):
+ def list_networks(self):
resp, body = self.get("os-networks")
body = json.loads(body)
self.expected_success(200, resp.status)
- if name:
- networks = [n for n in body['networks'] if n['label'] == name]
- else:
- networks = body['networks']
- return service_client.ResponseBodyList(resp, networks)
+ return service_client.ResponseBodyList(resp, body['networks'])
- def get_network(self, network_id):
- resp, body = self.get("os-networks/%s" % str(network_id))
+ def show_network(self, network_id):
+ resp, body = self.get("os-networks/%s" % network_id)
body = json.loads(body)
self.expected_success(200, resp.status)
return service_client.ResponseBody(resp, body['network'])
diff --git a/tempest/services/compute/json/quota_classes_client.py b/tempest/services/compute/json/quota_classes_client.py
new file mode 100644
index 0000000..30d3501
--- /dev/null
+++ b/tempest/services/compute/json/quota_classes_client.py
@@ -0,0 +1,46 @@
+# Copyright 2012 NTT Data
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from oslo_serialization import jsonutils as json
+
+from tempest.api_schema.response.compute.v2_1\
+ import quota_classes as classes_schema
+from tempest.common import service_client
+
+
+class QuotaClassesClient(service_client.ServiceClient):
+
+ def show_quota_class_set(self, quota_class_id):
+ """List the quota class set for a quota class."""
+
+ url = 'os-quota-class-sets/%s' % quota_class_id
+ resp, body = self.get(url)
+ body = json.loads(body)
+ self.validate_response(classes_schema.get_quota_class_set, resp, body)
+ return service_client.ResponseBody(resp, body['quota_class_set'])
+
+ def update_quota_class_set(self, quota_class_id, **kwargs):
+ """
+ Updates the quota class's limits for one or more resources.
+ """
+ post_body = json.dumps({'quota_class_set': kwargs})
+
+ resp, body = self.put('os-quota-class-sets/%s' % quota_class_id,
+ post_body)
+
+ body = json.loads(body)
+ self.validate_response(classes_schema.update_quota_class_set,
+ resp, body)
+ return service_client.ResponseBody(resp, body['quota_class_set'])
diff --git a/tempest/services/compute/json/quotas_client.py b/tempest/services/compute/json/quotas_client.py
index 6e38c47..88d0567 100644
--- a/tempest/services/compute/json/quotas_client.py
+++ b/tempest/services/compute/json/quotas_client.py
@@ -13,95 +13,45 @@
# 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.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 get_quota_set(self, tenant_id, user_id=None):
+ def show_quota_set(self, tenant_id, user_id=None):
"""List the quota set for a tenant."""
- url = 'os-quota-sets/%s' % str(tenant_id)
+ url = 'os-quota-sets/%s' % tenant_id
if user_id:
- url += '?user_id=%s' % str(user_id)
+ url += '?user_id=%s' % user_id
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.get_quota_set, resp, body)
return service_client.ResponseBody(resp, body['quota_set'])
- def get_default_quota_set(self, tenant_id):
+ def show_default_quota_set(self, tenant_id):
"""List the default quota set for a tenant."""
- url = 'os-quota-sets/%s/defaults' % str(tenant_id)
+ url = 'os-quota-sets/%s/defaults' % tenant_id
resp, body = self.get(url)
body = json.loads(body)
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' %
- (str(tenant_id), str(user_id)), post_body)
+ (tenant_id, user_id), post_body)
else:
- resp, body = self.put('os-quota-sets/%s' % str(tenant_id),
+ resp, body = self.put('os-quota-sets/%s' % tenant_id,
post_body)
body = json.loads(body)
@@ -110,32 +60,6 @@
def delete_quota_set(self, tenant_id):
"""Delete the tenant's quota set."""
- resp, body = self.delete('os-quota-sets/%s' % str(tenant_id))
+ resp, body = self.delete('os-quota-sets/%s' % tenant_id)
self.validate_response(schema.delete_quota, resp, body)
return service_client.ResponseBody(resp, body)
-
-
-class QuotaClassesClientJSON(service_client.ServiceClient):
-
- def get_quota_class_set(self, quota_class_id):
- """List the quota class set for a quota class."""
-
- url = 'os-quota-class-sets/%s' % str(quota_class_id)
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(classes_schema.get_quota_class_set, resp, body)
- return service_client.ResponseBody(resp, body['quota_class_set'])
-
- def update_quota_class_set(self, quota_class_id, **kwargs):
- """
- Updates the quota class's limits for one or more resources.
- """
- post_body = json.dumps({'quota_class_set': kwargs})
-
- resp, body = self.put('os-quota-class-sets/%s' % str(quota_class_id),
- post_body)
-
- body = json.loads(body)
- self.validate_response(classes_schema.update_quota_class_set,
- resp, body)
- return service_client.ResponseBody(resp, body['quota_class_set'])
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 039f9bb..1076fca 100644
--- a/tempest/services/identity/v2/json/identity_client.py
+++ b/tempest/services/identity/v2/json/identity_client.py
@@ -10,13 +10,21 @@
# 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"""
+ url = ''
+ resp, body = self.get(url)
+ self.expected_success([200, 203], resp.status)
+ return service_client.ResponseBody(resp, self._parse_resp(body))
def has_admin_extensions(self):
"""
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 f3d02a8..87d4b79 100644
--- a/tempest/services/identity/v3/json/identity_client.py
+++ b/tempest/services/identity/v3/json/identity_client.py
@@ -13,16 +13,22 @@
# 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):
+ """Retrieves info about the v3 Identity API"""
+ url = ''
+ resp, body = self.get(url)
+ self.expected_success(200, resp.status)
+ return service_client.ResponseBody(resp, self._parse_resp(body))
+
def create_user(self, user_name, password=None, project_id=None,
email=None, domain_id='default', **kwargs):
"""Creates a user."""
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 7c58f01..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,
@@ -201,20 +201,12 @@
self.expected_success(200, resp.status)
return service_client.ResponseBody(resp, body)
- def list_images(self, **kwargs):
+ def list_images(self, detail=False, properties=dict(),
+ changes_since=None, **kwargs):
url = 'v1/images'
- if len(kwargs) > 0:
- url += '?%s' % urllib.urlencode(kwargs)
-
- resp, body = self.get(url)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBodyList(resp, body['images'])
-
- def image_list_detail(self, properties=dict(), changes_since=None,
- **kwargs):
- url = 'v1/images/detail'
+ if detail:
+ url += '/detail'
params = {}
for key, value in properties.items():
@@ -265,8 +257,9 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def get_shared_images(self, member_id):
- url = 'v1/shared-images/%s' % member_id
+ def list_shared_images(self, tenant_id):
+ """List shared images with the specified tenant"""
+ url = 'v1/shared-images/%s' % tenant_id
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
diff --git a/tempest/services/image/v2/json/image_client.py b/tempest/services/image/v2/json/image_client.py
index a4cb48c..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,
@@ -52,7 +51,7 @@
def _validate_schema(self, body, type='image'):
if type in ['image', 'images']:
- schema = self.get_schema(type)
+ schema = self.show_schema(type)
else:
raise ValueError("%s is not a valid schema type" % type)
@@ -96,6 +95,18 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
+ def deactivate_image(self, image_id):
+ url = 'v2/images/%s/actions/deactivate' % image_id
+ resp, body = self.post(url, None)
+ self.expected_success(204, resp.status)
+ return service_client.ResponseBody(resp, body)
+
+ def reactivate_image(self, image_id):
+ url = 'v2/images/%s/actions/reactivate' % image_id
+ resp, body = self.post(url, None)
+ self.expected_success(204, resp.status)
+ return service_client.ResponseBody(resp, body)
+
def delete_image(self, image_id):
url = 'v2/images/%s' % image_id
resp, _ = self.delete(url)
@@ -133,7 +144,7 @@
"""Returns the primary type of resource this client works with."""
return 'image'
- def store_image(self, image_id, data):
+ def store_image_file(self, image_id, data):
url = 'v2/images/%s/file' % image_id
headers = {'Content-Type': 'application/octet-stream'}
resp, body = self.http.raw_request('PUT', url, headers=headers,
@@ -141,7 +152,7 @@
self.expected_success(204, resp.status)
return service_client.ResponseBody(resp, body)
- def get_image_file(self, image_id):
+ def load_image_file(self, image_id):
url = 'v2/images/%s/file' % image_id
resp, body = self.get(url)
self.expected_success(200, resp.status)
@@ -166,7 +177,7 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def add_member(self, image_id, member_id):
+ def add_image_member(self, image_id, member_id):
url = 'v2/images/%s/members' % image_id
data = json.dumps({'member': member_id})
resp, body = self.post(url, data)
@@ -174,28 +185,27 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def update_member_status(self, image_id, member_id, status):
- """Valid status are: ``pending``, ``accepted``, ``rejected``."""
+ def update_image_member(self, image_id, member_id, body):
url = 'v2/images/%s/members/%s' % (image_id, member_id)
- data = json.dumps({'status': status})
+ data = json.dumps(body)
resp, body = self.put(url, data)
self.expected_success(200, resp.status)
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def get_member(self, image_id, member_id):
+ def show_image_member(self, image_id, member_id):
url = 'v2/images/%s/members/%s' % (image_id, member_id)
resp, body = self.get(url)
self.expected_success(200, resp.status)
return service_client.ResponseBody(resp, json.loads(body))
- def remove_member(self, image_id, member_id):
+ def remove_image_member(self, image_id, member_id):
url = 'v2/images/%s/members/%s' % (image_id, member_id)
resp, _ = self.delete(url)
self.expected_success(204, resp.status)
return service_client.ResponseBody(resp)
- def get_schema(self, schema):
+ def show_schema(self, schema):
url = 'v2/schemas/%s' % schema
resp, body = self.get(url)
self.expected_success(200, resp.status)
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 e93cc47..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,163 +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 list represents resource names that do not require
- # changing underscore to a hyphen
- hyphen_exceptions = ["health_monitors", "firewall_rules",
- "firewall_policies"]
- # the following map is used to construct proper URI
- # for the given neutron resource
- service_resource_prefix_map = {
- 'networks': '',
- 'subnets': '',
- 'ports': '',
- 'pools': 'lb',
- 'vips': 'lb',
- 'health_monitors': 'lb',
- 'members': 'lb',
- 'ipsecpolicies': 'vpn',
- 'vpnservices': 'vpn',
- 'ikepolicies': 'vpn',
- 'ipsec-site-connections': 'vpn',
- 'metering_labels': 'metering',
- 'metering_label_rules': 'metering',
- 'firewall_rules': 'fw',
- 'firewall_policies': 'fw',
- 'firewalls': 'fw'
- }
- service_prefix = service_resource_prefix_map.get(
- plural_name)
- if plural_name not in hyphen_exceptions:
- 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'
+ 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)
- # 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',
- 'ipsecpolicy': 'ipsecpolicies',
- 'ikepolicy': 'ikepolicies',
- 'ipsec_site_connection': 'ipsec-site-connections',
- 'quotas': 'quotas',
- 'firewall_policy': 'firewall_policies'
- }
- return resource_plural_map.get(resource_name, resource_name + 's')
+ def _create_resource(self, uri, post_data):
+ req_uri = self.uri_prefix + uri
+ req_post_data = json.dumps(post_data)
+ resp, body = self.post(req_uri, req_post_data)
+ body = json.loads(body)
+ self.expected_success(201, resp.status)
+ return service_client.ResponseBody(resp, body)
- 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)
+ 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)
- return _list
+ def create_network(self, **kwargs):
+ uri = '/networks'
+ post_data = {'network': kwargs}
+ return self._create_resource(uri, post_data)
- 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)
+ def update_network(self, network_id, **kwargs):
+ uri = '/networks/%s' % network_id
+ post_data = {'network': kwargs}
+ return self._update_resource(uri, post_data)
- return _delete
+ def show_network(self, network_id, **fields):
+ uri = '/networks/%s' % network_id
+ return self._show_resource(uri, **fields)
- 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)
+ def delete_network(self, network_id):
+ uri = '/networks/%s' % network_id
+ return self._delete_resource(uri)
- return _show
+ def list_networks(self, **filters):
+ uri = '/networks'
+ return self._list_resources(uri, **filters)
- def _creater(self, resource_name):
- def _create(**kwargs):
- plural = self.pluralize(resource_name)
- uri = self.get_uri(plural)
- post_data = self.serialize({resource_name: kwargs})
- resp, body = self.post(uri, post_data)
- body = self.deserialize_single(body)
- self.expected_success(201, resp.status)
- return service_client.ResponseBody(resp, body)
+ def create_subnet(self, **kwargs):
+ uri = '/subnets'
+ post_data = {'subnet': kwargs}
+ return self._create_resource(uri, post_data)
- return _create
+ def update_subnet(self, subnet_id, **kwargs):
+ uri = '/subnets/%s' % subnet_id
+ post_data = {'subnet': kwargs}
+ return self._update_resource(uri, post_data)
- 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)
+ def show_subnet(self, subnet_id, **fields):
+ uri = '/subnets/%s' % subnet_id
+ return self._show_resource(uri, **fields)
- return _update
+ def delete_subnet(self, subnet_id):
+ uri = '/subnets/%s' % subnet_id
+ return self._delete_resource(uri)
- def __getattr__(self, name):
- method_prefixes = ["list_", "delete_", "show_", "create_", "update_"]
- method_functors = [self._lister,
- self._deleter,
- self._shower,
- self._creater,
- 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 list_subnets(self, **filters):
+ uri = '/subnets'
+ return self._list_resources(uri, **filters)
- # Common methods that are hard to automate
+ 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)
+
+ 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."""
@@ -254,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(
@@ -322,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."""
@@ -337,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.
@@ -346,236 +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)
-
- def associate_health_monitor_with_pool(self, health_monitor_id,
- pool_id):
- post_body = {
- "health_monitor": {
- "id": health_monitor_id,
- }
- }
- body = json.dumps(post_body)
- uri = '%s/lb/pools/%s/health_monitors' % (self.uri_prefix,
- pool_id)
- resp, body = self.post(uri, body)
- self.expected_success(201, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
- def disassociate_health_monitor_with_pool(self, health_monitor_id,
- pool_id):
- uri = '%s/lb/pools/%s/health_monitors/%s' % (self.uri_prefix, pool_id,
- health_monitor_id)
- resp, body = self.delete(uri)
- self.expected_success(204, resp.status)
- 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 list_pools_hosted_by_one_lbaas_agent(self, agent_id):
- uri = '%s/agents/%s/loadbalancer-pools' % (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)
+ def show_agent(self, agent_id, **fields):
+ uri = '/agents/%s' % agent_id
+ return self._show_resource(uri, **fields)
- def show_lbaas_agent_hosting_pool(self, pool_id):
- uri = ('%s/lb/pools/%s/loadbalancer-agent' %
- (self.uri_prefix, pool_id))
- resp, body = self.get(uri)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
+ 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 create_ikepolicy(self, name, **kwargs):
- post_body = {
- "ikepolicy": {
- "name": name,
- }
- }
- for key, val in kwargs.items():
- post_body['ikepolicy'][key] = val
- body = json.dumps(post_body)
- uri = '%s/vpn/ikepolicies' % (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)
-
- 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)
-
- def list_lb_pool_stats(self, pool_id):
- uri = '%s/lb/pools/%s/stats' % (self.uri_prefix, pool_id)
- resp, body = self.get(uri)
- 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)
-
- def insert_firewall_rule_in_policy(self, firewall_policy_id,
- firewall_rule_id, insert_after="",
- insert_before=""):
- uri = '%s/fw/firewall_policies/%s/insert_rule' % (self.uri_prefix,
- firewall_policy_id)
- body = {
- "firewall_rule_id": firewall_rule_id,
- "insert_after": insert_after,
- "insert_before": insert_before
- }
- body = json.dumps(body)
- resp, body = self.put(uri, body)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
- def remove_firewall_rule_from_policy(self, firewall_policy_id,
- firewall_rule_id):
- uri = '%s/fw/firewall_policies/%s/remove_rule' % (self.uri_prefix,
- firewall_policy_id)
- update_body = {"firewall_rule_id": firewall_rule_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)
+ 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 554f574..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"
@@ -84,6 +84,10 @@
uri = '%s/meters/%s' % (self.uri_prefix, meter_id)
return self._helper_list(uri, query)
+ def list_events(self, query=None):
+ uri = '%s/events' % self.uri_prefix
+ return self._helper_list(uri, query)
+
def show_resource(self, resource_id):
uri = '%s/resources/%s' % (self.uri_prefix, resource_id)
resp, body = self.get(uri)
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 0df2eb1..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)
@@ -91,8 +91,8 @@
def _create_sec_group(self):
sec_grp_cli = self.manager.security_groups_client
- s_name = data_utils.rand_name('sec_grp-')
- s_description = data_utils.rand_name('desc-')
+ s_name = data_utils.rand_name('sec_grp')
+ s_description = data_utils.rand_name('desc')
self.sec_grp = sec_grp_cli.create_security_group(s_name,
s_description)
create_rule = sec_grp_cli.create_security_group_rule
@@ -145,7 +145,7 @@
cli = self.manager.floating_ips_client
def func():
- floating = cli.get_floating_ip_details(self.floating['id'])
+ floating = cli.show_floating_ip(self.floating['id'])
return floating['instance_id'] is None
if not tempest.test.call_until_true(func, self.check_timeout,
@@ -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 c8d9f06..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)
@@ -96,7 +96,7 @@
cli = self.manager.floating_ips_client
def func():
- floating = cli.get_floating_ip_details(self.floating['id'])
+ floating = cli.show_floating_ip(self.floating['id'])
return floating['instance_id'] is None
if not tempest.test.call_until_true(func, CONF.compute.build_timeout,
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_javelin.py b/tempest/tests/cmd/test_javelin.py
index f98f8ba..f0921d5 100644
--- a/tempest/tests/cmd/test_javelin.py
+++ b/tempest/tests/cmd/test_javelin.py
@@ -61,6 +61,26 @@
javelin.client_for_user(fake_non_existing_user['name'])
self.assertFalse(javelin.OSClient.called)
+ def test_attach_volumes(self):
+ self.useFixture(mockpatch.PatchObject(javelin, "client_for_user",
+ return_value=self.fake_client))
+
+ self.useFixture(mockpatch.PatchObject(
+ javelin, "_get_volume_by_name",
+ return_value=self.fake_object.volume))
+
+ self.useFixture(mockpatch.PatchObject(
+ javelin, "_get_server_by_name",
+ return_value=self.fake_object.server))
+
+ javelin.attach_volumes([self.fake_object])
+
+ mocked_function = self.fake_client.volumes.attach_volume
+ mocked_function.assert_called_once_with(
+ self.fake_object.volume['id'],
+ self.fake_object.server['id'],
+ self.fake_object['device'])
+
class TestCreateResources(JavelinUnitTest):
def test_create_tenants(self):
@@ -89,7 +109,7 @@
self.fake_client.identity.get_tenant_by_name.return_value = \
self.fake_object['tenant']
self.fake_client.identity.get_user_by_username.side_effect = \
- lib_exc.NotFound()
+ lib_exc.NotFound("user is not found")
self.useFixture(mockpatch.PatchObject(javelin, "keystone_admin",
return_value=self.fake_client))
@@ -106,7 +126,7 @@
def test_create_user_missing_tenant(self):
self.fake_client.identity.get_tenant_by_name.side_effect = \
- lib_exc.NotFound()
+ lib_exc.NotFound("tenant is not found")
self.useFixture(mockpatch.PatchObject(javelin, "keystone_admin",
return_value=self.fake_client))
@@ -152,7 +172,7 @@
self.fake_object['format'],
self.fake_object['format'])
- mocked_function = self.fake_client.images.store_image
+ mocked_function = self.fake_client.images.store_image_file
fake_image_id = self.fake_object['body'].get('id')
mocked_function.assert_called_once_with(fake_image_id, open_mock())
@@ -190,14 +210,84 @@
name=self.fake_object['name'],
ip_version=fake_version)
+ def test_create_volumes(self):
+
+ self.useFixture(mockpatch.PatchObject(javelin, "client_for_user",
+ return_value=self.fake_client))
+ self.useFixture(mockpatch.PatchObject(javelin, "_get_volume_by_name",
+ return_value=None))
+ self.fake_client.volumes.create_volume.return_value = \
+ self.fake_object.body
+
+ javelin.create_volumes([self.fake_object])
+
+ mocked_function = self.fake_client.volumes.create_volume
+ mocked_function.assert_called_once_with(
+ size=self.fake_object['gb'],
+ display_name=self.fake_object['name'])
+ mocked_function = self.fake_client.volumes.wait_for_volume_status
+ mocked_function.assert_called_once_with(
+ self.fake_object.body['id'],
+ 'available')
+
+ def test_create_volume_existing(self):
+ self.useFixture(mockpatch.PatchObject(javelin, "client_for_user",
+ return_value=self.fake_client))
+ self.useFixture(mockpatch.PatchObject(javelin, "_get_volume_by_name",
+ return_value=self.fake_object))
+ self.fake_client.volumes.create_volume.return_value = \
+ self.fake_object.body
+
+ javelin.create_volumes([self.fake_object])
+
+ mocked_function = self.fake_client.volumes.create_volume
+ self.assertFalse(mocked_function.called)
+ mocked_function = self.fake_client.volumes.wait_for_volume_status
+ self.assertFalse(mocked_function.called)
+
+ def test_create_router(self):
+
+ self.fake_client.networks.list_routers.return_value = {'routers': []}
+ self.useFixture(mockpatch.PatchObject(javelin, "client_for_user",
+ return_value=self.fake_client))
+
+ javelin.create_routers([self.fake_object])
+
+ mocked_function = self.fake_client.networks.create_router
+ mocked_function.assert_called_once_with(self.fake_object['name'])
+
+ def test_create_router_existing(self):
+ self.fake_client.networks.list_routers.return_value = {
+ 'routers': [self.fake_object]}
+ self.useFixture(mockpatch.PatchObject(javelin, "client_for_user",
+ return_value=self.fake_client))
+
+ javelin.create_routers([self.fake_object])
+
+ mocked_function = self.fake_client.networks.create_router
+ self.assertFalse(mocked_function.called)
+
+ def test_create_secgroup(self):
+ self.useFixture(mockpatch.PatchObject(javelin, "client_for_user",
+ return_value=self.fake_client))
+ self.fake_client.secgroups.list_security_groups.return_value = []
+ self.fake_client.secgroups.create_security_group.return_value = \
+ {'id': self.fake_object['secgroup_id']}
+
+ javelin.create_secgroups([self.fake_object])
+
+ mocked_function = self.fake_client.secgroups.create_security_group
+ mocked_function.assert_called_once_with(
+ self.fake_object['name'],
+ self.fake_object['description'])
+
class TestDestroyResources(JavelinUnitTest):
def test_destroy_tenants(self):
fake_tenant = self.fake_object['tenant']
-
- fake_auth = mock.MagicMock()
+ fake_auth = self.fake_client
fake_auth.identity.get_tenant_by_name.return_value = fake_tenant
self.useFixture(mockpatch.PatchObject(javelin, "keystone_admin",
@@ -212,7 +302,7 @@
fake_user = self.fake_object['user']
fake_tenant = self.fake_object['tenant']
- fake_auth = mock.MagicMock()
+ fake_auth = self.fake_client
fake_auth.identity.get_tenant_by_name.return_value = fake_tenant
fake_auth.identity.get_user_by_username.return_value = fake_user
@@ -226,41 +316,98 @@
def test_destroy_objects(self):
- fake_client = mock.MagicMock()
- fake_client.objects.delete_object.return_value = {'status': "200"}, ""
+ self.fake_client.objects.delete_object.return_value = \
+ {'status': "200"}, ""
self.useFixture(mockpatch.PatchObject(javelin, "client_for_user",
- return_value=fake_client))
+ return_value=self.fake_client))
javelin.destroy_objects([self.fake_object])
- mocked_function = fake_client.objects.delete_object
+ mocked_function = self.fake_client.objects.delete_object
mocked_function.asswert_called_once(self.fake_object['container'],
self.fake_object['name'])
def test_destroy_images(self):
- fake_client = mock.MagicMock()
self.useFixture(mockpatch.PatchObject(javelin, "client_for_user",
- return_value=fake_client))
+ return_value=self.fake_client))
self.useFixture(mockpatch.PatchObject(javelin, "_get_image_by_name",
return_value=self.fake_object['image']))
javelin.destroy_images([self.fake_object])
- mocked_function = fake_client.images.delete_image
+ mocked_function = self.fake_client.images.delete_image
mocked_function.assert_called_once_with(
self.fake_object['image']['id'])
def test_destroy_networks(self):
- fake_client = mock.MagicMock()
self.useFixture(mockpatch.PatchObject(javelin, "client_for_user",
- return_value=fake_client))
+ return_value=self.fake_client))
self.useFixture(mockpatch.PatchObject(
javelin, "_get_resource_by_name",
return_value=self.fake_object['resource']))
javelin.destroy_networks([self.fake_object])
- mocked_function = fake_client.networks.delete_network
+ mocked_function = self.fake_client.networks.delete_network
mocked_function.assert_called_once_with(
self.fake_object['resource']['id'])
+
+ def test_destroy_volumes(self):
+ self.useFixture(mockpatch.PatchObject(javelin, "client_for_user",
+ return_value=self.fake_client))
+
+ self.useFixture(mockpatch.PatchObject(
+ javelin, "_get_volume_by_name",
+ return_value=self.fake_object.volume))
+
+ javelin.destroy_volumes([self.fake_object])
+
+ mocked_function = self.fake_client.volumes.detach_volume
+ mocked_function.assert_called_once_with(self.fake_object.volume['id'])
+ mocked_function = self.fake_client.volumes.delete_volume
+ mocked_function.assert_called_once_with(self.fake_object.volume['id'])
+
+ def test_destroy_subnets(self):
+
+ self.useFixture(mockpatch.PatchObject(javelin, "client_for_user",
+ return_value=self.fake_client))
+ fake_subnet_id = self.fake_object['subnet_id']
+ self.useFixture(mockpatch.PatchObject(javelin, "_get_resource_by_name",
+ return_value={
+ 'id': fake_subnet_id}))
+
+ javelin.destroy_subnets([self.fake_object])
+
+ mocked_function = self.fake_client.networks.delete_subnet
+ mocked_function.assert_called_once_with(fake_subnet_id)
+
+ def test_destroy_routers(self):
+ self.useFixture(mockpatch.PatchObject(javelin, "client_for_user",
+ return_value=self.fake_client))
+
+ # this function is used on 2 different occasions in the code
+ def _fake_get_resource_by_name(*args):
+ if args[1] == "routers":
+ return {"id": self.fake_object['router_id']}
+ elif args[1] == "subnets":
+ return {"id": self.fake_object['subnet_id']}
+ javelin._get_resource_by_name = _fake_get_resource_by_name
+
+ javelin.destroy_routers([self.fake_object])
+
+ mocked_function = self.fake_client.networks.delete_router
+ mocked_function.assert_called_once_with(
+ self.fake_object['router_id'])
+
+ def test_destroy_secgroup(self):
+ self.useFixture(mockpatch.PatchObject(javelin, "client_for_user",
+ return_value=self.fake_client))
+ fake_secgroup = {'id': self.fake_object['id']}
+ self.useFixture(mockpatch.PatchObject(javelin, "_get_resource_by_name",
+ return_value=fake_secgroup))
+
+ javelin.destroy_secgroups([self.fake_object])
+
+ mocked_function = self.fake_client.secgroups.delete_security_group
+ mocked_function.assert_called_once_with(self.fake_object['id'])
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 b9afd5e..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
@@ -164,7 +164,7 @@
def test_verify_glance_version_no_v2_with_v1_1(self):
def fake_get_versions():
- return (['v1.1'])
+ return (None, ['v1.1'])
fake_os = mock.MagicMock()
fake_os.image_client.get_versions = fake_get_versions
with mock.patch.object(verify_tempest_config,
@@ -175,7 +175,7 @@
def test_verify_glance_version_no_v2_with_v1_0(self):
def fake_get_versions():
- return (['v1.0'])
+ return (None, ['v1.0'])
fake_os = mock.MagicMock()
fake_os.image_client.get_versions = fake_get_versions
with mock.patch.object(verify_tempest_config,
@@ -186,7 +186,7 @@
def test_verify_glance_version_no_v1(self):
def fake_get_versions():
- return (['v2.0'])
+ return (None, ['v2.0'])
fake_os = mock.MagicMock()
fake_os.image_client.get_versions = fake_get_versions
with mock.patch.object(verify_tempest_config,
diff --git a/tempest/tests/common/test_accounts.py b/tempest/tests/common/test_accounts.py
index 596e811..8fc3745 100644
--- a/tempest/tests/common/test_accounts.py
+++ b/tempest/tests/common/test_accounts.py
@@ -291,15 +291,14 @@
{'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',
- return_value=[{'name': 'network-2', 'id': 'fake-id'}]):
+ 'NetworksClient.list_networks',
+ return_value=[{'name': 'network-2', 'id': 'fake-id',
+ 'label': 'network-2'}]):
creds = test_accounts_class.get_creds_by_roles(['role-7'])
self.assertTrue(isinstance(creds, cred_provider.TestResources))
network = creds.network
diff --git a/tempest/tests/common/test_service_clients.py b/tempest/tests/common/test_service_clients.py
index 9bb58b0..00b8470 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
@@ -34,10 +36,13 @@
from tempest.services.compute.json import limits_client
from tempest.services.compute.json import migrations_client
from tempest.services.compute.json import networks_client as nova_net_client
+from tempest.services.compute.json import quota_classes_client
from tempest.services.compute.json import quotas_client
from tempest.services.compute.json import security_group_default_rules_client \
as nova_secgrop_default_client
+from tempest.services.compute.json import security_group_rules_client
from tempest.services.compute.json import security_groups_client
+from tempest.services.compute.json import server_groups_client
from tempest.services.compute.json import servers_client
from tempest.services.compute.json import services_client
from tempest.services.compute.json import tenant_usages_client
@@ -103,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,
- quotas_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_hacking.py b/tempest/tests/test_hacking.py
index fd01887..9bc9cfe 100644
--- a/tempest/tests/test_hacking.py
+++ b/tempest/tests/test_hacking.py
@@ -119,6 +119,13 @@
self.assertFalse(checks.service_tags_not_in_module_path(
"@test.services('compute')", './tempest/api/image/fake_test.py'))
+ def test_no_hyphen_at_end_of_rand_name(self):
+ self.assertIsNone(checks.no_hyphen_at_end_of_rand_name(
+ 'data_utils.rand_name("fake-resource")', './tempest/test_foo.py'))
+ self.assertEqual(2, len(list(checks.no_hyphen_at_end_of_rand_name(
+ 'data_utils.rand_name("fake-resource-")', './tempest/test_foo.py')
+ )))
+
def test_no_mutable_default_args(self):
self.assertEqual(1, len(list(checks.no_mutable_default_args(
" def function1(para={}):"))))
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 32f33bc..2ea30ec 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -3,11 +3,10 @@
# process, which may cause wedges in the gate later.
hacking<0.11,>=0.10.0
# needed for doc build
-sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
+sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
python-subunit>=0.0.18
-oslosphinx>=2.5.0 # Apache-2.0
+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.3.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 4bb5df6..389fee2 100644
--- a/tox.ini
+++ b/tox.ini
@@ -13,6 +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 http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
usedevelop = True
install_command = pip install -U {opts} {packages}
whitelist_externals = *
@@ -39,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}