Merge "Make volume_types_client use **kwargs"
diff --git a/README.rst b/README.rst
index 45cb4c0..71e185f 100644
--- a/README.rst
+++ b/README.rst
@@ -87,7 +87,7 @@
be done with testr directly or any `testr`_ based test runner, like
`ostestr`_. For example, from the working dir running::
- $ ostestr --regex '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty))'
+ $ ostestr --regex '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario))'
will run the same set of tests as the default gate jobs.
diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst
index 1b2b6d2..a16f3b7 100644
--- a/doc/source/configuration.rst
+++ b/doc/source/configuration.rst
@@ -9,16 +9,6 @@
config file which explains the purpose of each individual option. You can see
the sample config file here: :ref:`tempest-sampleconf`
-Lock Path
----------
-
-There are some tests and operations inside of tempest that need to be
-externally locked when running in parallel to prevent them from running at
-the same time. This is a mandatory step for configuring tempest and is still
-needed even when running serially. All that is needed to do this is:
-
- #. Set the lock_path option in the oslo_concurrency group
-
Auth/Credentials
----------------
diff --git a/doc/source/field_guide/thirdparty.rst b/doc/source/field_guide/thirdparty.rst
deleted file mode 120000
index 3fd6a51..0000000
--- a/doc/source/field_guide/thirdparty.rst
+++ /dev/null
@@ -1 +0,0 @@
-../../../tempest/thirdparty/README.rst
\ No newline at end of file
diff --git a/doc/source/index.rst b/doc/source/index.rst
index fe6074f..32e6e51 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -26,7 +26,6 @@
field_guide/api
field_guide/scenario
field_guide/stress
- field_guide/thirdparty
field_guide/unit_tests
---------------------------
diff --git a/requirements.txt b/requirements.txt
index d470c30..1f225c3 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -7,7 +7,6 @@
httplib2>=0.7.5
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.16,>=0.7.12
testrepository>=0.0.18
@@ -22,6 +21,6 @@
iso8601>=0.1.9
fixtures>=1.3.1
testscenarios>=0.4
-tempest-lib>=0.11.0
+tempest-lib>=0.12.0
PyYAML>=3.1.0
stevedore>=1.5.0 # Apache-2.0
diff --git a/run_tempest.sh b/run_tempest.sh
index a704684..8c8f25f 100755
--- a/run_tempest.sh
+++ b/run_tempest.sh
@@ -14,8 +14,6 @@
echo " -C, --config Config file location"
echo " -h, --help Print this usage message"
echo " -d, --debug Run tests with testtools instead of testr. This allows you to use PDB"
- echo " -l, --logging Enable logging"
- echo " -L, --logging-config Logging config file location. Default is etc/logging.conf"
echo " -- [TESTROPTIONS] After the first '--' you can pass arbitrary arguments to testr "
}
@@ -31,10 +29,8 @@
wrapper=""
config_file=""
update=0
-logging=0
-logging_config=etc/logging.conf
-if ! options=$(getopt -o VNnfusthdC:lL: -l virtual-env,no-virtual-env,no-site-packages,force,update,smoke,serial,help,debug,config:,logging,logging-config: -- "$@")
+if ! options=$(getopt -o VNnfusthdC:lL: -l virtual-env,no-virtual-env,no-site-packages,force,update,smoke,serial,help,debug,config: -- "$@")
then
# parse error
usage
@@ -55,8 +51,6 @@
-C|--config) config_file=$2; shift;;
-s|--smoke) testrargs+="smoke";;
-t|--serial) serial=1;;
- -l|--logging) logging=1;;
- -L|--logging-config) logging_config=$2; shift;;
--) [ "yes" == "$first_uu" ] || testrargs="$testrargs $1"; first_uu=no ;;
*) testrargs="$testrargs $1";;
esac
@@ -69,16 +63,6 @@
export TEMPEST_CONFIG=`basename "$config_file"`
fi
-if [ $logging -eq 1 ]; then
- if [ ! -f "$logging_config" ]; then
- echo "No such logging config file: $logging_config"
- exit 1
- fi
- logging_config=`readlink -f "$logging_config"`
- export TEMPEST_LOG_CONFIG_DIR=`dirname "$logging_config"`
- export TEMPEST_LOG_CONFIG=`basename "$logging_config"`
-fi
-
cd `dirname "$0"`
if [ $no_site_packages -eq 1 ]; then
diff --git a/setup.cfg b/setup.cfg
index ee61788..4415063 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -35,6 +35,7 @@
tempest.cm =
init = tempest.cmd.init:TempestInit
cleanup = tempest.cmd.cleanup:TempestCleanup
+ run-stress = tempest.cmd.run_stress:TempestRunStress
oslo.config.opts =
tempest.config = tempest.config:list_opts
diff --git a/tempest/README.rst b/tempest/README.rst
index f93a173..113b191 100644
--- a/tempest/README.rst
+++ b/tempest/README.rst
@@ -16,7 +16,6 @@
| api/ - API tests
| scenario/ - complex scenario tests
| stress/ - stress tests
-| thirdparty/ - 3rd party api tests
Each of these directories contains different types of tests. What
belongs in each directory, the rules and examples for good tests, are
@@ -56,14 +55,6 @@
several test jobs in parallel and can run any existing test in Tempest as a
stress job.
-:ref:`third_party_field_guide`
-------------------------------
-
-Many openstack components include 3rdparty API support. It is
-completely legitimate for Tempest to include tests of 3rdparty APIs,
-but those should be kept separate from the normal OpenStack
-validation.
-
:ref:`unit_tests_field_guide`
-----------------------------
diff --git a/tempest/api/compute/admin/test_floating_ips_bulk.py b/tempest/api/compute/admin/test_floating_ips_bulk.py
index fe05ddb..456363c 100644
--- a/tempest/api/compute/admin/test_floating_ips_bulk.py
+++ b/tempest/api/compute/admin/test_floating_ips_bulk.py
@@ -38,7 +38,7 @@
@classmethod
def resource_setup(cls):
super(FloatingIPsBulkAdminTestJSON, cls).resource_setup()
- cls.ip_range = CONF.compute.floating_ip_range
+ cls.ip_range = CONF.validation.floating_ip_range
cls.verify_unallocated_floating_ip_range(cls.ip_range)
@classmethod
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index fa1c666..2907e26 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -111,7 +111,7 @@
# Verify that GET shows the updated quota set of user
user_name = data_utils.rand_name('cpu_quota_user')
- password = data_utils.rand_name('password')
+ password = data_utils.rand_password()
email = user_name + '@testmail.tm'
user = self.identity_utils.create_user(username=user_name,
password=password,
diff --git a/tempest/api/compute/admin/test_security_groups.py b/tempest/api/compute/admin/test_security_groups.py
index b0a3086..e31129b 100644
--- a/tempest/api/compute/admin/test_security_groups.py
+++ b/tempest/api/compute/admin/test_security_groups.py
@@ -28,7 +28,7 @@
@classmethod
def setup_clients(cls):
super(SecurityGroupsTestAdminJSON, cls).setup_clients()
- cls.adm_client = cls.os_adm.security_groups_client
+ cls.adm_client = cls.os_adm.compute_security_groups_client
cls.client = cls.security_groups_client
def _delete_security_group(self, securitygroup_id, admin=True):
diff --git a/tempest/api/compute/admin/test_servers.py b/tempest/api/compute/admin/test_servers.py
index b038c6b..fd6f105 100644
--- a/tempest/api/compute/admin/test_servers.py
+++ b/tempest/api/compute/admin/test_servers.py
@@ -130,7 +130,7 @@
@test.idempotent_id('ee8ae470-db70-474d-b752-690b7892cab1')
def test_reset_state_server(self):
# Reset server's state to 'error'
- self.client.reset_state(self.s1_id)
+ self.client.reset_state(self.s1_id, state='error')
# Verify server's state
server = self.client.show_server(self.s1_id)['server']
diff --git a/tempest/api/compute/admin/test_servers_negative.py b/tempest/api/compute/admin/test_servers_negative.py
index 7c5e8d0..055dc1b 100644
--- a/tempest/api/compute/admin/test_servers_negative.py
+++ b/tempest/api/compute/admin/test_servers_negative.py
@@ -123,7 +123,7 @@
@test.idempotent_id('e741298b-8df2-46f0-81cb-8f814ff2504c')
def test_reset_state_server_nonexistent_server(self):
self.assertRaises(lib_exc.NotFound,
- self.client.reset_state, '999')
+ self.client.reset_state, '999', state='error')
@test.attr(type=['negative'])
@test.idempotent_id('e84e2234-60d2-42fa-8b30-e2d3049724ac')
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 5bc0769..aa8ee3f 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -69,7 +69,7 @@
cls.floating_ips_client = cls.os.compute_floating_ips_client
cls.keypairs_client = cls.os.keypairs_client
cls.security_group_rules_client = cls.os.security_group_rules_client
- cls.security_groups_client = cls.os.security_groups_client
+ cls.security_groups_client = cls.os.compute_security_groups_client
cls.quotas_client = cls.os.quotas_client
cls.quota_classes_client = cls.os.quota_classes_client
cls.compute_networks_client = cls.os.compute_networks_client
@@ -101,13 +101,13 @@
super(BaseV2ComputeTest, cls).resource_setup()
cls.build_interval = CONF.compute.build_interval
cls.build_timeout = CONF.compute.build_timeout
- cls.ssh_user = CONF.compute.ssh_user
cls.image_ref = CONF.compute.image_ref
cls.image_ref_alt = CONF.compute.image_ref_alt
cls.flavor_ref = CONF.compute.flavor_ref
cls.flavor_ref_alt = CONF.compute.flavor_ref_alt
- cls.image_ssh_user = CONF.compute.image_ssh_user
- cls.image_ssh_password = CONF.compute.image_ssh_password
+ cls.ssh_user = CONF.validation.image_ssh_user
+ cls.image_ssh_user = CONF.validation.image_ssh_user
+ cls.image_ssh_password = CONF.validation.image_ssh_password
cls.servers = []
cls.images = []
cls.security_groups = []
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index dbbeb70..81a02be 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -100,7 +100,7 @@
server_id = server['id']
waiters.wait_for_server_status(self.servers_client, server_id,
'ACTIVE')
- self.servers_client.add_security_group(server_id, sg['name'])
+ self.servers_client.add_security_group(server_id, name=sg['name'])
# Check that we are not able to delete the security
# group since it is in use by an active server
@@ -109,10 +109,10 @@
sg['id'])
# Reboot and add the other security group
- self.servers_client.reboot_server(server_id, 'HARD')
+ self.servers_client.reboot_server(server_id, type='HARD')
waiters.wait_for_server_status(self.servers_client, server_id,
'ACTIVE')
- self.servers_client.add_security_group(server_id, sg2['name'])
+ self.servers_client.add_security_group(server_id, name=sg2['name'])
# Check that we are not able to delete the other security
# group since it is in use by an active server
diff --git a/tempest/api/compute/servers/test_instance_actions.py b/tempest/api/compute/servers/test_instance_actions.py
index 814aec7..1367629 100644
--- a/tempest/api/compute/servers/test_instance_actions.py
+++ b/tempest/api/compute/servers/test_instance_actions.py
@@ -35,7 +35,7 @@
@test.idempotent_id('77ca5cc5-9990-45e0-ab98-1de8fead201a')
def test_list_instance_actions(self):
# List actions of the provided server
- self.client.reboot_server(self.server_id, 'HARD')
+ self.client.reboot_server(self.server_id, type='HARD')
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
body = (self.client.list_instance_actions(self.server_id)
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 0754d27..71dfd96 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -81,7 +81,7 @@
def test_change_server_password(self):
# 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.change_password(self.server_id, adminPass=new_password)
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
if CONF.validation.run_validation:
@@ -104,7 +104,7 @@
self.validation_resources['keypair']['private_key'])
boot_time = linux_client.get_boot_time()
- self.client.reboot_server(self.server_id, reboot_type)
+ self.client.reboot_server(self.server_id, type=reboot_type)
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
if CONF.validation.run_validation:
@@ -279,9 +279,9 @@
# create the first and the second backup
backup1 = data_utils.rand_name('backup-1')
resp = self.client.create_backup(self.server_id,
- 'daily',
- 2,
- backup1).response
+ backup_type='daily',
+ rotation=2,
+ name=backup1).response
oldest_backup_exist = True
# the oldest one should be deleted automatically in this test
@@ -303,9 +303,9 @@
backup2 = data_utils.rand_name('backup-2')
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
resp = self.client.create_backup(self.server_id,
- 'daily',
- 2,
- backup2).response
+ backup_type='daily',
+ rotation=2,
+ name=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')
@@ -331,9 +331,9 @@
backup3 = data_utils.rand_name('backup-3')
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
resp = self.client.create_backup(self.server_id,
- 'daily',
- 2,
- backup3).response
+ backup_type='daily',
+ rotation=2,
+ name=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
@@ -356,7 +356,7 @@
def _get_output(self):
output = self.client.get_console_output(
- self.server_id, 10)['output']
+ self.server_id, length=10)['output']
self.assertTrue(output, "Console output was empty.")
lines = len(output.split('\n'))
self.assertEqual(lines, 10)
@@ -373,7 +373,7 @@
# 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.client.reboot_server(self.server_id, 'HARD')
+ self.client.reboot_server(self.server_id, type='HARD')
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
self.wait_for(self._get_output)
@@ -384,8 +384,7 @@
server = self.create_test_server(wait_until='ACTIVE')
def _check_full_length_console_log():
- output = self.client.get_console_output(server['id'],
- None)['output']
+ output = self.client.get_console_output(server['id'])['output']
self.assertTrue(output, "Console output was empty.")
lines = len(output.split('\n'))
@@ -499,7 +498,7 @@
console_types = ['novnc', 'xvpvnc']
for console_type in console_types:
body = self.client.get_vnc_console(self.server_id,
- console_type)['console']
+ type=console_type)['console']
self.assertEqual(console_type, body['type'])
self.assertNotEqual('', body['url'])
self._validate_url(body['url'])
diff --git a/tempest/api/compute/servers/test_server_personality.py b/tempest/api/compute/servers/test_server_personality.py
index 77af509..58d26d3 100644
--- a/tempest/api/compute/servers/test_server_personality.py
+++ b/tempest/api/compute/servers/test_server_personality.py
@@ -17,6 +17,8 @@
from tempest_lib import exceptions as lib_exc
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
@@ -26,6 +28,16 @@
class ServerPersonalityTestJSON(base.BaseV2ComputeTest):
@classmethod
+ def setup_credentials(cls):
+ cls.prepare_instance_network()
+ super(ServerPersonalityTestJSON, cls).setup_credentials()
+
+ @classmethod
+ def resource_setup(cls):
+ cls.set_validation_resources()
+ super(ServerPersonalityTestJSON, cls).resource_setup()
+
+ @classmethod
def skip_checks(cls):
super(ServerPersonalityTestJSON, cls).skip_checks()
if not CONF.compute_feature_enabled.personality:
@@ -40,18 +52,34 @@
@test.idempotent_id('3cfe87fd-115b-4a02-b942-7dc36a337fdf')
def test_create_server_with_personality(self):
file_contents = 'This is a test file.'
- personality = [{'path': '/test.txt',
+ file_path = '/test.txt'
+ personality = [{'path': file_path,
'contents': base64.b64encode(file_contents)}]
- self.create_test_server(personality=personality)
+ server = self.create_test_server(personality=personality,
+ wait_until='ACTIVE',
+ validatable=True)
+ if CONF.validation.run_validation:
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(server),
+ self.ssh_user, server['adminPass'],
+ self.validation_resources['keypair']['private_key'])
+ self.assertEqual(file_contents,
+ linux_client.exec_command(
+ 'sudo cat %s' % file_path))
@test.idempotent_id('128966d8-71fc-443c-8cab-08e24114ecc9')
def test_rebuild_server_with_personality(self):
- server_id = self.rebuild_server(None)
+ server = self.create_test_server(wait_until='ACTIVE', validatable=True)
+ server_id = server['id']
file_contents = 'Test server rebuild.'
personality = [{'path': 'rebuild.txt',
'contents': base64.b64encode(file_contents)}]
- self.client.rebuild_server(server_id, self.image_ref_alt,
- personality=personality)
+ rebuilt_server = self.client.rebuild_server(server_id,
+ self.image_ref_alt,
+ personality=personality)
+ waiters.wait_for_server_status(self.client, server_id, 'ACTIVE')
+ self.assertEqual(self.image_ref_alt,
+ rebuilt_server['server']['image']['id'])
@test.idempotent_id('176cd8c9-b9e8-48ee-a480-180beab292bf')
def test_personality_files_exceed_limit(self):
@@ -83,9 +111,20 @@
raise self.skipException("No limit for personality files")
person = []
for i in range(0, int(max_file_limit)):
- path = 'etc/test' + str(i) + '.txt'
+ path = '/etc/test' + str(i) + '.txt'
person.append({
'path': path,
'contents': base64.b64encode(file_contents),
})
- self.create_test_server(personality=person)
+ server = self.create_test_server(personality=person,
+ wait_until='ACTIVE',
+ validatable=True)
+ if CONF.validation.run_validation:
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(server),
+ self.ssh_user, server['adminPass'],
+ self.validation_resources['keypair']['private_key'])
+ for i in person:
+ self.assertEqual(base64.b64decode(i['contents']),
+ linux_client.exec_command(
+ 'sudo cat %s' % i['path']))
diff --git a/tempest/api/compute/servers/test_server_rescue.py b/tempest/api/compute/servers/test_server_rescue.py
index 96ce45e..2296980 100644
--- a/tempest/api/compute/servers/test_server_rescue.py
+++ b/tempest/api/compute/servers/test_server_rescue.py
@@ -116,8 +116,9 @@
self.addCleanup(self._unrescue, self.server_id)
# Add Security group
- self.servers_client.add_security_group(self.server_id, self.sg_name)
+ self.servers_client.add_security_group(self.server_id,
+ name=self.sg_name)
# Delete Security group
self.servers_client.remove_security_group(self.server_id,
- self.sg_name)
+ name=self.sg_name)
diff --git a/tempest/api/compute/servers/test_server_rescue_negative.py b/tempest/api/compute/servers/test_server_rescue_negative.py
index f8567cf..65ad2f5 100644
--- a/tempest/api/compute/servers/test_server_rescue_negative.py
+++ b/tempest/api/compute/servers/test_server_rescue_negative.py
@@ -101,7 +101,7 @@
@test.idempotent_id('db22b618-f157-4566-a317-1b6d467a8094')
def test_rescued_vm_reboot(self):
self.assertRaises(lib_exc.Conflict, self.servers_client.reboot_server,
- self.rescue_id, 'HARD')
+ self.rescue_id, type='HARD')
@test.attr(type=['negative'])
@test.idempotent_id('6dfc0a55-3a77-4564-a144-1587b7971dde')
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index a5e9afd..ed8484e 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -152,7 +152,7 @@
# Reboot a non existent server
nonexistent_server = data_utils.rand_uuid()
self.assertRaises(lib_exc.NotFound, self.client.reboot_server,
- nonexistent_server, 'SOFT')
+ nonexistent_server, type='SOFT')
@test.idempotent_id('d1417e7f-a509-41b5-a102-d5eed8613369')
@testtools.skipUnless(CONF.compute_feature_enabled.pause,
@@ -188,7 +188,7 @@
waiters.wait_for_server_termination(self.client, server['id'])
self.assertRaises(lib_exc.NotFound, self.client.reboot_server,
- server['id'], 'SOFT')
+ server['id'], type='SOFT')
@test.attr(type=['negative'])
@test.idempotent_id('d86141a7-906e-4731-b187-d64a2ea61422')
@@ -430,7 +430,7 @@
nonexistent_server = data_utils.rand_uuid()
self.assertRaises(lib_exc.NotFound,
self.client.get_console_output,
- nonexistent_server, 10)
+ nonexistent_server, length=10)
@test.attr(type=['negative'])
@test.idempotent_id('6f47992b-5144-4250-9f8b-f00aa33950f3')
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index 436ed2f..e363fc4 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -51,13 +51,14 @@
cls.images_client = cls.os.images_client
cls.glance_client = cls.os.image_client
cls.keypairs_client = cls.os.keypairs_client
- cls.security_client = cls.os.security_groups_client
+ cls.security_client = cls.os.compute_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_security_client = (
+ cls.alt_manager.compute_security_groups_client)
cls.alt_rule_client = cls.alt_manager.security_group_rules_client
@classmethod
@@ -150,13 +151,13 @@
def test_change_password_for_alt_account_fails(self):
# A change password request for another user's server should fail
self.assertRaises(lib_exc.NotFound, self.alt_client.change_password,
- self.server['id'], 'newpass')
+ self.server['id'], adminPass='newpass')
@test.idempotent_id('14cb5ff5-f646-45ca-8f51-09081d6c0c24')
def test_reboot_server_for_alt_account_fails(self):
# A reboot request for another user's server should fail
self.assertRaises(lib_exc.NotFound, self.alt_client.reboot_server,
- self.server['id'], 'HARD')
+ self.server['id'], type='HARD')
@test.idempotent_id('8a0bce51-cd00-480b-88ba-dbc7d8408a37')
def test_rebuild_server_for_alt_account_fails(self):
@@ -443,4 +444,4 @@
# A Get Console Output for another user's server should fail
self.assertRaises(lib_exc.NotFound,
self.alt_client.get_console_output,
- self.server['id'], 10)
+ self.server['id'], length=10)
diff --git a/tempest/api/database/flavors/test_flavors.py b/tempest/api/database/flavors/test_flavors.py
index 62c1e05..f75b867 100644
--- a/tempest/api/database/flavors/test_flavors.py
+++ b/tempest/api/database/flavors/test_flavors.py
@@ -28,7 +28,7 @@
@test.idempotent_id('c94b825e-0132-4686-8049-8a4a2bc09525')
def test_get_db_flavor(self):
# The expected flavor details should be returned
- flavor = (self.client.get_db_flavor_details(self.db_flavor_ref)
+ flavor = (self.client.show_db_flavor(self.db_flavor_ref)
['flavor'])
self.assertEqual(self.db_flavor_ref, str(flavor['id']))
self.assertIn('ram', flavor)
@@ -38,7 +38,7 @@
@test.attr(type='smoke')
@test.idempotent_id('685025d6-0cec-4673-8a8d-995cb8e0d3bb')
def test_list_db_flavors(self):
- flavor = (self.client.get_db_flavor_details(self.db_flavor_ref)
+ flavor = (self.client.show_db_flavor(self.db_flavor_ref)
['flavor'])
# List of all flavors should contain the expected flavor
flavors = self.client.list_db_flavors()['flavors']
@@ -67,7 +67,7 @@
(os_flavors, db_flavors))
for os_flavor in os_flavors:
db_flavor =\
- self.client.get_db_flavor_details(os_flavor['id'])['flavor']
+ self.client.show_db_flavor(os_flavor['id'])['flavor']
self._check_values(['id', 'name', 'ram'], db_flavor, os_flavor)
self._check_values(['disk', 'vcpus', 'swap'], db_flavor, os_flavor,
in_db=False)
diff --git a/tempest/api/database/flavors/test_flavors_negative.py b/tempest/api/database/flavors/test_flavors_negative.py
index 68cb7d6..3dee96f 100644
--- a/tempest/api/database/flavors/test_flavors_negative.py
+++ b/tempest/api/database/flavors/test_flavors_negative.py
@@ -31,4 +31,4 @@
def test_get_non_existent_db_flavor(self):
# flavor details are not returned for non-existent flavors
self.assertRaises(lib_exc.NotFound,
- self.client.get_db_flavor_details, -1)
+ self.client.show_db_flavor, -1)
diff --git a/tempest/api/identity/admin/v2/test_roles.py b/tempest/api/identity/admin/v2/test_roles.py
index 8702db7..e547bdd 100644
--- a/tempest/api/identity/admin/v2/test_roles.py
+++ b/tempest/api/identity/admin/v2/test_roles.py
@@ -27,7 +27,7 @@
super(RolesTestJSON, cls).resource_setup()
for _ in moves.xrange(5):
role_name = data_utils.rand_name(name='role')
- role = cls.client.create_role(role_name)['role']
+ role = cls.roles_client.create_role(role_name)['role']
cls.data.roles.append(role)
def _get_role_params(self):
@@ -48,7 +48,7 @@
@test.idempotent_id('75d9593f-50b7-4fcf-bd64-e3fb4a278e23')
def test_list_roles(self):
"""Return a list of all roles."""
- body = self.client.list_roles()['roles']
+ body = self.roles_client.list_roles()['roles']
found = [role for role in body if role in self.data.roles]
self.assertTrue(any(found))
self.assertEqual(len(found), len(self.data.roles))
@@ -57,16 +57,16 @@
def test_role_create_delete(self):
"""Role should be created, verified, and deleted."""
role_name = data_utils.rand_name(name='role-test')
- body = self.client.create_role(role_name)['role']
+ body = self.roles_client.create_role(role_name)['role']
self.assertEqual(role_name, body['name'])
- body = self.client.list_roles()['roles']
+ body = self.roles_client.list_roles()['roles']
found = [role for role in body if role['name'] == role_name]
self.assertTrue(any(found))
- body = self.client.delete_role(found[0]['id'])
+ body = self.roles_client.delete_role(found[0]['id'])
- body = self.client.list_roles()['roles']
+ body = self.roles_client.list_roles()['roles']
found = [role for role in body if role['name'] == role_name]
self.assertFalse(any(found))
@@ -76,7 +76,7 @@
self.data.setup_test_role()
role_id = self.data.role['id']
role_name = self.data.role['name']
- body = self.client.show_role(role_id)['role']
+ body = self.roles_client.show_role(role_id)['role']
self.assertEqual(role_id, body['id'])
self.assertEqual(role_name, body['name'])
@@ -84,24 +84,28 @@
def test_assign_user_role(self):
"""Assign a role to a user on a tenant."""
(user, tenant, role) = self._get_role_params()
- self.client.assign_user_role(tenant['id'], user['id'], role['id'])
- roles = self.client.list_user_roles(tenant['id'], user['id'])['roles']
+ self.roles_client.assign_user_role(tenant['id'], user['id'],
+ role['id'])
+ roles = self.roles_client.list_user_roles(tenant['id'],
+ user['id'])['roles']
self.assert_role_in_role_list(role, roles)
@test.idempotent_id('f0b9292c-d3ba-4082-aa6c-440489beef69')
def test_remove_user_role(self):
"""Remove a role assigned to a user on a tenant."""
(user, tenant, role) = self._get_role_params()
- user_role = self.client.assign_user_role(tenant['id'],
- user['id'],
- role['id'])['role']
- self.client.delete_user_role(tenant['id'], user['id'],
- user_role['id'])
+ user_role = self.roles_client.assign_user_role(tenant['id'],
+ user['id'],
+ role['id'])['role']
+ self.roles_client.delete_user_role(tenant['id'], user['id'],
+ user_role['id'])
@test.idempotent_id('262e1e3e-ed71-4edd-a0e5-d64e83d66d05')
def test_list_user_roles(self):
"""List roles assigned to a user on tenant."""
(user, tenant, role) = self._get_role_params()
- self.client.assign_user_role(tenant['id'], user['id'], role['id'])
- roles = self.client.list_user_roles(tenant['id'], user['id'])['roles']
+ self.roles_client.assign_user_role(tenant['id'], user['id'],
+ role['id'])
+ roles = self.roles_client.list_user_roles(tenant['id'],
+ user['id'])['roles']
self.assert_role_in_role_list(role, roles)
diff --git a/tempest/api/identity/admin/v2/test_roles_negative.py b/tempest/api/identity/admin/v2/test_roles_negative.py
index 45c95df..a57163d 100644
--- a/tempest/api/identity/admin/v2/test_roles_negative.py
+++ b/tempest/api/identity/admin/v2/test_roles_negative.py
@@ -37,7 +37,7 @@
def test_list_roles_by_unauthorized_user(self):
# Non-administrator user should not be able to list roles
self.assertRaises(lib_exc.Forbidden,
- self.non_admin_client.list_roles)
+ self.non_admin_roles_client.list_roles)
@test.attr(type=['negative'])
@test.idempotent_id('11a3c7da-df6c-40c2-abc2-badd682edf9f')
@@ -45,14 +45,15 @@
# Request to list roles without a valid token should fail
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
- self.assertRaises(lib_exc.Unauthorized, self.client.list_roles)
+ self.assertRaises(lib_exc.Unauthorized, self.roles_client.list_roles)
self.client.auth_provider.clear_auth()
@test.attr(type=['negative'])
@test.idempotent_id('c0b89e56-accc-4c73-85f8-9c0f866104c1')
def test_role_create_blank_name(self):
# Should not be able to create a role with a blank name
- self.assertRaises(lib_exc.BadRequest, self.client.create_role, '')
+ self.assertRaises(lib_exc.BadRequest, self.roles_client.create_role,
+ '')
@test.attr(type=['negative'])
@test.idempotent_id('585c8998-a8a4-4641-a5dd-abef7a8ced00')
@@ -60,7 +61,7 @@
# Non-administrator user should not be able to create role
role_name = data_utils.rand_name(name='role')
self.assertRaises(lib_exc.Forbidden,
- self.non_admin_client.create_role, role_name)
+ self.non_admin_roles_client.create_role, role_name)
@test.attr(type=['negative'])
@test.idempotent_id('a7edd17a-e34a-4aab-8bb7-fa6f498645b8')
@@ -70,7 +71,7 @@
self.client.delete_token(token)
role_name = data_utils.rand_name(name='role')
self.assertRaises(lib_exc.Unauthorized,
- self.client.create_role, role_name)
+ self.roles_client.create_role, role_name)
self.client.auth_provider.clear_auth()
@test.attr(type=['negative'])
@@ -78,10 +79,10 @@
def test_role_create_duplicate(self):
# Role names should be unique
role_name = data_utils.rand_name(name='role-dup')
- body = self.client.create_role(role_name)['role']
+ body = self.roles_client.create_role(role_name)['role']
role1_id = body.get('id')
- self.addCleanup(self.client.delete_role, role1_id)
- self.assertRaises(lib_exc.Conflict, self.client.create_role,
+ self.addCleanup(self.roles_client.delete_role, role1_id)
+ self.assertRaises(lib_exc.Conflict, self.roles_client.create_role,
role_name)
@test.attr(type=['negative'])
@@ -89,24 +90,24 @@
def test_delete_role_by_unauthorized_user(self):
# Non-administrator user should not be able to delete role
role_name = data_utils.rand_name(name='role')
- body = self.client.create_role(role_name)['role']
+ body = self.roles_client.create_role(role_name)['role']
self.data.roles.append(body)
role_id = body.get('id')
self.assertRaises(lib_exc.Forbidden,
- self.non_admin_client.delete_role, role_id)
+ self.non_admin_roles_client.delete_role, role_id)
@test.attr(type=['negative'])
@test.idempotent_id('44b60b20-70de-4dac-beaf-a3fc2650a16b')
def test_delete_role_request_without_token(self):
# Request to delete role without a valid token should fail
role_name = data_utils.rand_name(name='role')
- body = self.client.create_role(role_name)['role']
+ body = self.roles_client.create_role(role_name)['role']
self.data.roles.append(body)
role_id = body.get('id')
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
self.assertRaises(lib_exc.Unauthorized,
- self.client.delete_role,
+ self.roles_client.delete_role,
role_id)
self.client.auth_provider.clear_auth()
@@ -115,7 +116,7 @@
def test_delete_role_non_existent(self):
# Attempt to delete a non existent role should fail
non_existent_role = str(uuid.uuid4().hex)
- self.assertRaises(lib_exc.NotFound, self.client.delete_role,
+ self.assertRaises(lib_exc.NotFound, self.roles_client.delete_role,
non_existent_role)
@test.attr(type=['negative'])
@@ -125,7 +126,7 @@
# assign a role to user
(user, tenant, role) = self._get_role_params()
self.assertRaises(lib_exc.Forbidden,
- self.non_admin_client.assign_user_role,
+ self.non_admin_roles_client.assign_user_role,
tenant['id'], user['id'], role['id'])
@test.attr(type=['negative'])
@@ -136,7 +137,7 @@
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
self.assertRaises(lib_exc.Unauthorized,
- self.client.assign_user_role, tenant['id'],
+ self.roles_client.assign_user_role, tenant['id'],
user['id'], role['id'])
self.client.auth_provider.clear_auth()
@@ -146,7 +147,7 @@
# Attempt to assign a non existent role to user should fail
(user, tenant, role) = self._get_role_params()
non_existent_role = str(uuid.uuid4().hex)
- self.assertRaises(lib_exc.NotFound, self.client.assign_user_role,
+ self.assertRaises(lib_exc.NotFound, self.roles_client.assign_user_role,
tenant['id'], user['id'], non_existent_role)
@test.attr(type=['negative'])
@@ -155,7 +156,7 @@
# Attempt to assign a role on a non existent tenant should fail
(user, tenant, role) = self._get_role_params()
non_existent_tenant = str(uuid.uuid4().hex)
- self.assertRaises(lib_exc.NotFound, self.client.assign_user_role,
+ self.assertRaises(lib_exc.NotFound, self.roles_client.assign_user_role,
non_existent_tenant, user['id'], role['id'])
@test.attr(type=['negative'])
@@ -163,8 +164,9 @@
def test_assign_duplicate_user_role(self):
# Duplicate user role should not get assigned
(user, tenant, role) = self._get_role_params()
- self.client.assign_user_role(tenant['id'], user['id'], role['id'])
- self.assertRaises(lib_exc.Conflict, self.client.assign_user_role,
+ self.roles_client.assign_user_role(tenant['id'], user['id'],
+ role['id'])
+ self.assertRaises(lib_exc.Conflict, self.roles_client.assign_user_role,
tenant['id'], user['id'], role['id'])
@test.attr(type=['negative'])
@@ -173,11 +175,11 @@
# Non-administrator user should not be authorized to
# remove a user's role
(user, tenant, role) = self._get_role_params()
- self.client.assign_user_role(tenant['id'],
- user['id'],
- role['id'])
+ self.roles_client.assign_user_role(tenant['id'],
+ user['id'],
+ role['id'])
self.assertRaises(lib_exc.Forbidden,
- self.non_admin_client.delete_user_role,
+ self.non_admin_roles_client.delete_user_role,
tenant['id'], user['id'], role['id'])
@test.attr(type=['negative'])
@@ -185,13 +187,13 @@
def test_remove_user_role_request_without_token(self):
# Request to remove a user's role without a valid token
(user, tenant, role) = self._get_role_params()
- self.client.assign_user_role(tenant['id'],
- user['id'],
- role['id'])
+ self.roles_client.assign_user_role(tenant['id'],
+ user['id'],
+ role['id'])
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
self.assertRaises(lib_exc.Unauthorized,
- self.client.delete_user_role, tenant['id'],
+ self.roles_client.delete_user_role, tenant['id'],
user['id'], role['id'])
self.client.auth_provider.clear_auth()
@@ -200,11 +202,11 @@
def test_remove_user_role_non_existent_role(self):
# Attempt to delete a non existent role from a user should fail
(user, tenant, role) = self._get_role_params()
- self.client.assign_user_role(tenant['id'],
- user['id'],
- role['id'])
+ self.roles_client.assign_user_role(tenant['id'],
+ user['id'],
+ role['id'])
non_existent_role = str(uuid.uuid4().hex)
- self.assertRaises(lib_exc.NotFound, self.client.delete_user_role,
+ self.assertRaises(lib_exc.NotFound, self.roles_client.delete_user_role,
tenant['id'], user['id'], non_existent_role)
@test.attr(type=['negative'])
@@ -212,11 +214,11 @@
def test_remove_user_role_non_existent_tenant(self):
# Attempt to remove a role from a non existent tenant should fail
(user, tenant, role) = self._get_role_params()
- self.client.assign_user_role(tenant['id'],
- user['id'],
- role['id'])
+ self.roles_client.assign_user_role(tenant['id'],
+ user['id'],
+ role['id'])
non_existent_tenant = str(uuid.uuid4().hex)
- self.assertRaises(lib_exc.NotFound, self.client.delete_user_role,
+ self.assertRaises(lib_exc.NotFound, self.roles_client.delete_user_role,
non_existent_tenant, user['id'], role['id'])
@test.attr(type=['negative'])
@@ -225,10 +227,11 @@
# Non-administrator user should not be authorized to list
# a user's roles
(user, tenant, role) = self._get_role_params()
- self.client.assign_user_role(tenant['id'], user['id'], role['id'])
+ self.roles_client.assign_user_role(tenant['id'], user['id'],
+ role['id'])
self.assertRaises(lib_exc.Forbidden,
- self.non_admin_client.list_user_roles, tenant['id'],
- user['id'])
+ self.non_admin_roles_client.list_user_roles,
+ tenant['id'], user['id'])
@test.attr(type=['negative'])
@test.idempotent_id('682adfb2-fd5f-4b0a-a9ca-322e9bebb907')
@@ -239,7 +242,7 @@
self.client.delete_token(token)
try:
self.assertRaises(lib_exc.Unauthorized,
- self.client.list_user_roles, tenant['id'],
+ self.roles_client.list_user_roles, tenant['id'],
user['id'])
finally:
self.client.auth_provider.clear_auth()
diff --git a/tempest/api/identity/admin/v2/test_tenant_negative.py b/tempest/api/identity/admin/v2/test_tenant_negative.py
index 74558d1..a02dbc1 100644
--- a/tempest/api/identity/admin/v2/test_tenant_negative.py
+++ b/tempest/api/identity/admin/v2/test_tenant_negative.py
@@ -29,7 +29,7 @@
def test_list_tenants_by_unauthorized_user(self):
# Non-administrator user should not be able to list tenants
self.assertRaises(lib_exc.Forbidden,
- self.non_admin_client.list_tenants)
+ self.non_admin_tenants_client.list_tenants)
@test.attr(type=['negative'])
@test.idempotent_id('df33926c-1c96-4d8d-a762-79cc6b0c3cf4')
@@ -37,7 +37,8 @@
# Request to list tenants without a valid token should fail
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
- self.assertRaises(lib_exc.Unauthorized, self.client.list_tenants)
+ self.assertRaises(lib_exc.Unauthorized,
+ self.tenants_client.list_tenants)
self.client.auth_provider.clear_auth()
@test.attr(type=['negative'])
@@ -45,21 +46,23 @@
def test_tenant_delete_by_unauthorized_user(self):
# Non-administrator user should not be able to delete a tenant
tenant_name = data_utils.rand_name(name='tenant')
- tenant = self.client.create_tenant(tenant_name)['tenant']
+ tenant = self.tenants_client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
self.assertRaises(lib_exc.Forbidden,
- self.non_admin_client.delete_tenant, tenant['id'])
+ self.non_admin_tenants_client.delete_tenant,
+ tenant['id'])
@test.attr(type=['negative'])
@test.idempotent_id('e450db62-2e9d-418f-893a-54772d6386b1')
def test_tenant_delete_request_without_token(self):
# Request to delete a tenant without a valid token should fail
tenant_name = data_utils.rand_name(name='tenant')
- tenant = self.client.create_tenant(tenant_name)['tenant']
+ tenant = self.tenants_client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
- self.assertRaises(lib_exc.Unauthorized, self.client.delete_tenant,
+ self.assertRaises(lib_exc.Unauthorized,
+ self.tenants_client.delete_tenant,
tenant['id'])
self.client.auth_provider.clear_auth()
@@ -67,7 +70,7 @@
@test.idempotent_id('9c9a2aed-6e3c-467a-8f5c-89da9d1b516b')
def test_delete_non_existent_tenant(self):
# Attempt to delete a non existent tenant should fail
- self.assertRaises(lib_exc.NotFound, self.client.delete_tenant,
+ self.assertRaises(lib_exc.NotFound, self.tenants_client.delete_tenant,
str(uuid.uuid4().hex))
@test.attr(type=['negative'])
@@ -75,14 +78,14 @@
def test_tenant_create_duplicate(self):
# Tenant names should be unique
tenant_name = data_utils.rand_name(name='tenant')
- body = self.client.create_tenant(tenant_name)['tenant']
+ body = self.tenants_client.create_tenant(tenant_name)['tenant']
tenant = body
self.data.tenants.append(tenant)
tenant1_id = body.get('id')
- self.addCleanup(self.client.delete_tenant, tenant1_id)
+ self.addCleanup(self.tenants_client.delete_tenant, tenant1_id)
self.addCleanup(self.data.tenants.remove, tenant)
- self.assertRaises(lib_exc.Conflict, self.client.create_tenant,
+ self.assertRaises(lib_exc.Conflict, self.tenants_client.create_tenant,
tenant_name)
@test.attr(type=['negative'])
@@ -91,7 +94,8 @@
# Non-administrator user should not be authorized to create a tenant
tenant_name = data_utils.rand_name(name='tenant')
self.assertRaises(lib_exc.Forbidden,
- self.non_admin_client.create_tenant, tenant_name)
+ self.non_admin_tenants_client.create_tenant,
+ tenant_name)
@test.attr(type=['negative'])
@test.idempotent_id('a3ee9d7e-6920-4dd5-9321-d4b2b7f0a638')
@@ -100,7 +104,8 @@
tenant_name = data_utils.rand_name(name='tenant')
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
- self.assertRaises(lib_exc.Unauthorized, self.client.create_tenant,
+ self.assertRaises(lib_exc.Unauthorized,
+ self.tenants_client.create_tenant,
tenant_name)
self.client.auth_provider.clear_auth()
@@ -108,7 +113,8 @@
@test.idempotent_id('5a2e4ca9-b0c0-486c-9c48-64a94fba2395')
def test_create_tenant_with_empty_name(self):
# Tenant name should not be empty
- self.assertRaises(lib_exc.BadRequest, self.client.create_tenant,
+ self.assertRaises(lib_exc.BadRequest,
+ self.tenants_client.create_tenant,
name='')
@test.attr(type=['negative'])
@@ -116,14 +122,15 @@
def test_create_tenants_name_length_over_64(self):
# Tenant name length should not be greater than 64 characters
tenant_name = 'a' * 65
- self.assertRaises(lib_exc.BadRequest, self.client.create_tenant,
+ self.assertRaises(lib_exc.BadRequest,
+ self.tenants_client.create_tenant,
tenant_name)
@test.attr(type=['negative'])
@test.idempotent_id('bd20dc2a-9557-4db7-b755-f48d952ad706')
def test_update_non_existent_tenant(self):
# Attempt to update a non existent tenant should fail
- self.assertRaises(lib_exc.NotFound, self.client.update_tenant,
+ self.assertRaises(lib_exc.NotFound, self.tenants_client.update_tenant,
str(uuid.uuid4().hex))
@test.attr(type=['negative'])
@@ -131,20 +138,22 @@
def test_tenant_update_by_unauthorized_user(self):
# Non-administrator user should not be able to update a tenant
tenant_name = data_utils.rand_name(name='tenant')
- tenant = self.client.create_tenant(tenant_name)['tenant']
+ tenant = self.tenants_client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
self.assertRaises(lib_exc.Forbidden,
- self.non_admin_client.update_tenant, tenant['id'])
+ self.non_admin_tenants_client.update_tenant,
+ tenant['id'])
@test.attr(type=['negative'])
@test.idempotent_id('7a421573-72c7-4c22-a98e-ce539219c657')
def test_tenant_update_request_without_token(self):
# Request to update a tenant without a valid token should fail
tenant_name = data_utils.rand_name(name='tenant')
- tenant = self.client.create_tenant(tenant_name)['tenant']
+ tenant = self.tenants_client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
- self.assertRaises(lib_exc.Unauthorized, self.client.update_tenant,
+ self.assertRaises(lib_exc.Unauthorized,
+ self.tenants_client.update_tenant,
tenant['id'])
self.client.auth_provider.clear_auth()
diff --git a/tempest/api/identity/admin/v2/test_tenants.py b/tempest/api/identity/admin/v2/test_tenants.py
index 4632b1e..8d0b9b1 100644
--- a/tempest/api/identity/admin/v2/test_tenants.py
+++ b/tempest/api/identity/admin/v2/test_tenants.py
@@ -28,19 +28,19 @@
tenants = []
for _ in moves.xrange(3):
tenant_name = data_utils.rand_name(name='tenant-new')
- tenant = self.client.create_tenant(tenant_name)['tenant']
+ tenant = self.tenants_client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
tenants.append(tenant)
tenant_ids = map(lambda x: x['id'], tenants)
- body = self.client.list_tenants()['tenants']
+ body = self.tenants_client.list_tenants()['tenants']
found = [t for t in body if t['id'] in tenant_ids]
self.assertEqual(len(found), len(tenants), 'Tenants not created')
for tenant in tenants:
- self.client.delete_tenant(tenant['id'])
+ self.tenants_client.delete_tenant(tenant['id'])
self.data.tenants.remove(tenant)
- body = self.client.list_tenants()['tenants']
+ body = self.tenants_client.list_tenants()['tenants']
found = [tenant for tenant in body if tenant['id'] in tenant_ids]
self.assertFalse(any(found), 'Tenants failed to delete')
@@ -49,60 +49,60 @@
# Create tenant with a description
tenant_name = data_utils.rand_name(name='tenant')
tenant_desc = data_utils.rand_name(name='desc')
- body = self.client.create_tenant(tenant_name,
- description=tenant_desc)['tenant']
- tenant = body
+ body = self.tenants_client.create_tenant(tenant_name,
+ description=tenant_desc)
+ tenant = body['tenant']
self.data.tenants.append(tenant)
- tenant_id = body['id']
- desc1 = body['description']
+ tenant_id = tenant['id']
+ desc1 = tenant['description']
self.assertEqual(desc1, tenant_desc, 'Description should have '
'been sent in response for create')
- body = self.client.show_tenant(tenant_id)['tenant']
+ body = self.tenants_client.show_tenant(tenant_id)['tenant']
desc2 = body['description']
self.assertEqual(desc2, tenant_desc, 'Description does not appear'
'to be set')
- self.client.delete_tenant(tenant_id)
+ self.tenants_client.delete_tenant(tenant_id)
self.data.tenants.remove(tenant)
@test.idempotent_id('670bdddc-1cd7-41c7-b8e2-751cfb67df50')
def test_tenant_create_enabled(self):
# Create a tenant that is enabled
tenant_name = data_utils.rand_name(name='tenant')
- body = self.client.create_tenant(tenant_name, enabled=True)['tenant']
- tenant = body
+ body = self.tenants_client.create_tenant(tenant_name, enabled=True)
+ tenant = body['tenant']
self.data.tenants.append(tenant)
- tenant_id = body['id']
- en1 = body['enabled']
+ tenant_id = tenant['id']
+ en1 = tenant['enabled']
self.assertTrue(en1, 'Enable should be True in response')
- body = self.client.show_tenant(tenant_id)['tenant']
+ body = self.tenants_client.show_tenant(tenant_id)['tenant']
en2 = body['enabled']
self.assertTrue(en2, 'Enable should be True in lookup')
- self.client.delete_tenant(tenant_id)
+ self.tenants_client.delete_tenant(tenant_id)
self.data.tenants.remove(tenant)
@test.idempotent_id('3be22093-b30f-499d-b772-38340e5e16fb')
def test_tenant_create_not_enabled(self):
# Create a tenant that is not enabled
tenant_name = data_utils.rand_name(name='tenant')
- body = self.client.create_tenant(tenant_name, enabled=False)['tenant']
- tenant = body
+ body = self.tenants_client.create_tenant(tenant_name, enabled=False)
+ tenant = body['tenant']
self.data.tenants.append(tenant)
- tenant_id = body['id']
- en1 = body['enabled']
+ tenant_id = tenant['id']
+ en1 = tenant['enabled']
self.assertEqual('false', str(en1).lower(),
'Enable should be False in response')
- body = self.client.show_tenant(tenant_id)['tenant']
+ body = self.tenants_client.show_tenant(tenant_id)['tenant']
en2 = body['enabled']
self.assertEqual('false', str(en2).lower(),
'Enable should be False in lookup')
- self.client.delete_tenant(tenant_id)
+ self.tenants_client.delete_tenant(tenant_id)
self.data.tenants.remove(tenant)
@test.idempotent_id('781f2266-d128-47f3-8bdb-f70970add238')
def test_tenant_update_name(self):
# Update name attribute of a tenant
t_name1 = data_utils.rand_name(name='tenant')
- body = self.client.create_tenant(t_name1)['tenant']
+ body = self.tenants_client.create_tenant(t_name1)['tenant']
tenant = body
self.data.tenants.append(tenant)
@@ -110,18 +110,18 @@
resp1_name = body['name']
t_name2 = data_utils.rand_name(name='tenant2')
- body = self.client.update_tenant(t_id, name=t_name2)['tenant']
+ body = self.tenants_client.update_tenant(t_id, name=t_name2)['tenant']
resp2_name = body['name']
self.assertNotEqual(resp1_name, resp2_name)
- body = self.client.show_tenant(t_id)['tenant']
+ body = self.tenants_client.show_tenant(t_id)['tenant']
resp3_name = body['name']
self.assertNotEqual(resp1_name, resp3_name)
self.assertEqual(t_name1, resp1_name)
self.assertEqual(resp2_name, resp3_name)
- self.client.delete_tenant(t_id)
+ self.tenants_client.delete_tenant(t_id)
self.data.tenants.remove(tenant)
@test.idempotent_id('859fcfe1-3a03-41ef-86f9-b19a47d1cd87')
@@ -129,26 +129,27 @@
# Update description attribute of a tenant
t_name = data_utils.rand_name(name='tenant')
t_desc = data_utils.rand_name(name='desc')
- body = self.client.create_tenant(t_name, description=t_desc)['tenant']
- tenant = body
+ body = self.tenants_client.create_tenant(t_name, description=t_desc)
+ tenant = body['tenant']
self.data.tenants.append(tenant)
- t_id = body['id']
- resp1_desc = body['description']
+ t_id = tenant['id']
+ resp1_desc = tenant['description']
t_desc2 = data_utils.rand_name(name='desc2')
- body = self.client.update_tenant(t_id, description=t_desc2)['tenant']
- resp2_desc = body['description']
+ body = self.tenants_client.update_tenant(t_id, description=t_desc2)
+ updated_tenant = body['tenant']
+ resp2_desc = updated_tenant['description']
self.assertNotEqual(resp1_desc, resp2_desc)
- body = self.client.show_tenant(t_id)['tenant']
+ body = self.tenants_client.show_tenant(t_id)['tenant']
resp3_desc = body['description']
self.assertNotEqual(resp1_desc, resp3_desc)
self.assertEqual(t_desc, resp1_desc)
self.assertEqual(resp2_desc, resp3_desc)
- self.client.delete_tenant(t_id)
+ self.tenants_client.delete_tenant(t_id)
self.data.tenants.remove(tenant)
@test.idempotent_id('8fc8981f-f12d-4c66-9972-2bdcf2bc2e1a')
@@ -156,24 +157,25 @@
# Update the enabled attribute of a tenant
t_name = data_utils.rand_name(name='tenant')
t_en = False
- body = self.client.create_tenant(t_name, enabled=t_en)['tenant']
- tenant = body
+ body = self.tenants_client.create_tenant(t_name, enabled=t_en)
+ tenant = body['tenant']
self.data.tenants.append(tenant)
- t_id = body['id']
- resp1_en = body['enabled']
+ t_id = tenant['id']
+ resp1_en = tenant['enabled']
t_en2 = True
- body = self.client.update_tenant(t_id, enabled=t_en2)['tenant']
- resp2_en = body['enabled']
+ body = self.tenants_client.update_tenant(t_id, enabled=t_en2)
+ updated_tenant = body['tenant']
+ resp2_en = updated_tenant['enabled']
self.assertNotEqual(resp1_en, resp2_en)
- body = self.client.show_tenant(t_id)['tenant']
+ body = self.tenants_client.show_tenant(t_id)['tenant']
resp3_en = body['enabled']
self.assertNotEqual(resp1_en, resp3_en)
self.assertEqual('false', str(resp1_en).lower())
self.assertEqual(resp2_en, resp3_en)
- self.client.delete_tenant(t_id)
+ self.tenants_client.delete_tenant(t_id)
self.data.tenants.remove(tenant)
diff --git a/tempest/api/identity/admin/v2/test_tokens.py b/tempest/api/identity/admin/v2/test_tokens.py
index 0e7a480..e752b02 100644
--- a/tempest/api/identity/admin/v2/test_tokens.py
+++ b/tempest/api/identity/admin/v2/test_tokens.py
@@ -24,10 +24,10 @@
def test_create_get_delete_token(self):
# get a token by username and password
user_name = data_utils.rand_name(name='user')
- user_password = data_utils.rand_name(name='pass')
+ user_password = data_utils.rand_password()
# first:create a tenant
tenant_name = data_utils.rand_name(name='tenant')
- tenant = self.client.create_tenant(tenant_name)['tenant']
+ tenant = self.tenants_client.create_tenant(tenant_name)['tenant']
self.data.tenants.append(tenant)
# second:create a user
user = self.client.create_user(user_name, user_password,
@@ -59,7 +59,7 @@
# Create a user.
user_name = data_utils.rand_name(name='user')
- user_password = data_utils.rand_name(name='pass')
+ user_password = data_utils.rand_password()
tenant_id = None # No default tenant so will get unscoped token.
email = ''
user = self.client.create_user(user_name, user_password,
@@ -68,24 +68,24 @@
# Create a couple tenants.
tenant1_name = data_utils.rand_name(name='tenant')
- tenant1 = self.client.create_tenant(tenant1_name)['tenant']
+ tenant1 = self.tenants_client.create_tenant(tenant1_name)['tenant']
self.data.tenants.append(tenant1)
tenant2_name = data_utils.rand_name(name='tenant')
- tenant2 = self.client.create_tenant(tenant2_name)['tenant']
+ tenant2 = self.tenants_client.create_tenant(tenant2_name)['tenant']
self.data.tenants.append(tenant2)
# Create a role
role_name = data_utils.rand_name(name='role')
- role = self.client.create_role(role_name)['role']
+ role = self.roles_client.create_role(role_name)['role']
self.data.roles.append(role)
# Grant the user the role on the tenants.
- self.client.assign_user_role(tenant1['id'], user['id'],
- role['id'])
+ self.roles_client.assign_user_role(tenant1['id'], user['id'],
+ role['id'])
- self.client.assign_user_role(tenant2['id'], user['id'],
- role['id'])
+ self.roles_client.assign_user_role(tenant2['id'], user['id'],
+ role['id'])
# Get an unscoped token.
body = self.token_client.auth(user_name, user_password)
diff --git a/tempest/api/identity/admin/v2/test_users.py b/tempest/api/identity/admin/v2/test_users.py
index 6341106..2e9714e 100644
--- a/tempest/api/identity/admin/v2/test_users.py
+++ b/tempest/api/identity/admin/v2/test_users.py
@@ -26,7 +26,7 @@
def resource_setup(cls):
super(UsersTestJSON, cls).resource_setup()
cls.alt_user = data_utils.rand_name('test_user')
- cls.alt_password = data_utils.rand_name('pass')
+ cls.alt_password = data_utils.rand_password()
cls.alt_email = cls.alt_user + '@testmail.tm'
@test.attr(type='smoke')
@@ -132,21 +132,22 @@
self.data.setup_test_tenant()
user_ids = list()
fetched_user_ids = list()
+ password1 = data_utils.rand_password()
alt_tenant_user1 = data_utils.rand_name('tenant_user1')
- user1 = self.client.create_user(alt_tenant_user1, 'password1',
+ user1 = self.client.create_user(alt_tenant_user1, password1,
self.data.tenant['id'],
'user1@123')['user']
user_ids.append(user1['id'])
self.data.users.append(user1)
-
+ password2 = data_utils.rand_password()
alt_tenant_user2 = data_utils.rand_name('tenant_user2')
- user2 = self.client.create_user(alt_tenant_user2, 'password2',
+ user2 = self.client.create_user(alt_tenant_user2, password2,
self.data.tenant['id'],
'user2@123')['user']
user_ids.append(user2['id'])
self.data.users.append(user2)
# List of users for the respective tenant ID
- body = (self.client.list_tenant_users(self.data.tenant['id'])
+ body = (self.tenants_client.list_tenant_users(self.data.tenant['id'])
['users'])
for i in body:
fetched_user_ids.append(i['id'])
@@ -169,20 +170,21 @@
user_ids = list()
fetched_user_ids = list()
user_ids.append(user['id'])
- role = self.client.assign_user_role(tenant['id'], user['id'],
- role['id'])['role']
+ role = self.roles_client.assign_user_role(tenant['id'], user['id'],
+ role['id'])['role']
alt_user2 = data_utils.rand_name('second_user')
- second_user = self.client.create_user(alt_user2, 'password1',
+ alt_password2 = data_utils.rand_password()
+ second_user = self.client.create_user(alt_user2, alt_password2,
self.data.tenant['id'],
'user2@123')['user']
user_ids.append(second_user['id'])
self.data.users.append(second_user)
- role = self.client.assign_user_role(tenant['id'],
- second_user['id'],
- role['id'])['role']
+ role = self.roles_client.assign_user_role(tenant['id'],
+ second_user['id'],
+ role['id'])['role']
# List of users with roles for the respective tenant ID
- body = (self.client.list_tenant_users(self.data.tenant['id'])
+ body = (self.tenants_client.list_tenant_users(self.data.tenant['id'])
['users'])
for i in body:
fetched_user_ids.append(i['id'])
@@ -198,7 +200,7 @@
# Test case to check if updating of user password is successful.
self.data.setup_test_user()
# Updating the user with new password
- new_pass = data_utils.rand_name('pass')
+ new_pass = data_utils.rand_password()
update_user = self.client.update_user_password(
self.data.user['id'], new_pass)['user']
self.assertEqual(update_user['id'], self.data.user['id'])
diff --git a/tempest/api/identity/admin/v2/test_users_negative.py b/tempest/api/identity/admin/v2/test_users_negative.py
index a88053d..8fa5a36 100644
--- a/tempest/api/identity/admin/v2/test_users_negative.py
+++ b/tempest/api/identity/admin/v2/test_users_negative.py
@@ -28,7 +28,7 @@
def resource_setup(cls):
super(UsersNegativeTestJSON, cls).resource_setup()
cls.alt_user = data_utils.rand_name('test_user')
- cls.alt_password = data_utils.rand_name('pass')
+ cls.alt_password = data_utils.rand_password()
cls.alt_email = cls.alt_user + '@testmail.tm'
@test.attr(type=['negative'])
@@ -247,4 +247,4 @@
# List the users with invalid tenant id
for invalid in invalid_id:
self.assertRaises(lib_exc.NotFound,
- self.client.list_tenant_users, invalid)
+ self.tenants_client.list_tenant_users, invalid)
diff --git a/tempest/api/identity/admin/v3/test_credentials.py b/tempest/api/identity/admin/v3/test_credentials.py
index 048c53a..b81bff7 100644
--- a/tempest/api/identity/admin/v3/test_credentials.py
+++ b/tempest/api/identity/admin/v3/test_credentials.py
@@ -29,7 +29,7 @@
u_name = data_utils.rand_name('user')
u_desc = '%s description' % u_name
u_email = '%s@testmail.tm' % u_name
- u_password = data_utils.rand_name('pass')
+ u_password = data_utils.rand_password()
for i in range(2):
cls.project = cls.client.create_project(
data_utils.rand_name('project'),
@@ -76,7 +76,7 @@
self.assertEqual(update_body['blob']['access'], new_keys[0])
self.assertEqual(update_body['blob']['secret'], new_keys[1])
- get_body = self.creds_client.get_credential(cred['id'])['credential']
+ get_body = self.creds_client.show_credential(cred['id'])['credential']
for value1 in self.creds_list[0]:
self.assertEqual(update_body[value1],
get_body[value1])
diff --git a/tempest/api/identity/admin/v3/test_endpoints.py b/tempest/api/identity/admin/v3/test_endpoints.py
index 429e2e3..2ac832e 100644
--- a/tempest/api/identity/admin/v3/test_endpoints.py
+++ b/tempest/api/identity/admin/v3/test_endpoints.py
@@ -34,8 +34,8 @@
s_type = data_utils.rand_name('type')
s_description = data_utils.rand_name('description')
cls.service_data = (
- cls.service_client.create_service(name=s_name, type=s_type,
- description=s_description))
+ cls.services_client.create_service(name=s_name, type=s_type,
+ description=s_description))
cls.service_data = cls.service_data['service']
cls.service_id = cls.service_data['id']
cls.service_ids.append(cls.service_id)
@@ -56,7 +56,7 @@
for e in cls.setup_endpoints:
cls.client.delete_endpoint(e['id'])
for s in cls.service_ids:
- cls.service_client.delete_service(s)
+ cls.services_client.delete_service(s)
super(EndPointsTestJSON, cls).resource_cleanup()
@test.idempotent_id('c19ecf90-240e-4e23-9966-21cee3f6a618')
@@ -113,8 +113,8 @@
s_type = data_utils.rand_name('type')
s_description = data_utils.rand_name('description')
service2 = (
- self.service_client.create_service(name=s_name, type=s_type,
- description=s_description))
+ self.services_client.create_service(name=s_name, type=s_type,
+ description=s_description))
service2 = service2['service']
self.service_ids.append(service2['id'])
# Updating endpoint with new values
diff --git a/tempest/api/identity/admin/v3/test_endpoints_negative.py b/tempest/api/identity/admin/v3/test_endpoints_negative.py
index 8f9bf2a..372254f 100644
--- a/tempest/api/identity/admin/v3/test_endpoints_negative.py
+++ b/tempest/api/identity/admin/v3/test_endpoints_negative.py
@@ -37,8 +37,8 @@
s_type = data_utils.rand_name('type')
s_description = data_utils.rand_name('description')
cls.service_data = (
- cls.service_client.create_service(name=s_name, type=s_type,
- description=s_description)
+ cls.services_client.create_service(name=s_name, type=s_type,
+ description=s_description)
['service'])
cls.service_id = cls.service_data['id']
cls.service_ids.append(cls.service_id)
@@ -46,7 +46,7 @@
@classmethod
def resource_cleanup(cls):
for s in cls.service_ids:
- cls.service_client.delete_service(s)
+ cls.services_client.delete_service(s)
super(EndpointsNegativeTestJSON, cls).resource_cleanup()
@test.attr(type=['negative'])
diff --git a/tempest/api/identity/admin/v3/test_groups.py b/tempest/api/identity/admin/v3/test_groups.py
index 260ea54..e022023 100644
--- a/tempest/api/identity/admin/v3/test_groups.py
+++ b/tempest/api/identity/admin/v3/test_groups.py
@@ -67,7 +67,8 @@
users = []
for i in range(3):
name = data_utils.rand_name('User')
- user = self.client.create_user(name)['user']
+ password = data_utils.rand_password()
+ user = self.client.create_user(name, password)['user']
users.append(user)
self.addCleanup(self.client.delete_user, user['id'])
self.groups_client.add_group_user(group['id'], user['id'])
diff --git a/tempest/api/identity/admin/v3/test_list_users.py b/tempest/api/identity/admin/v3/test_list_users.py
index b7f37d4..ca91ce5 100644
--- a/tempest/api/identity/admin/v3/test_list_users.py
+++ b/tempest/api/identity/admin/v3/test_list_users.py
@@ -34,7 +34,7 @@
def resource_setup(cls):
super(UsersV3TestJSON, cls).resource_setup()
alt_user = data_utils.rand_name('test_user')
- alt_password = data_utils.rand_name('pass')
+ alt_password = data_utils.rand_password()
cls.alt_email = alt_user + '@testmail.tm'
cls.data.setup_test_domain()
# Create user with Domain
diff --git a/tempest/api/identity/admin/v3/test_policies.py b/tempest/api/identity/admin/v3/test_policies.py
index 44e5c7b..f38d25d 100644
--- a/tempest/api/identity/admin/v3/test_policies.py
+++ b/tempest/api/identity/admin/v3/test_policies.py
@@ -64,7 +64,7 @@
policy['id'], type=update_type)['policy']
self.assertIn('type', data)
# Assertion for updated value with fetched value
- fetched_policy = self.policy_client.get_policy(policy['id'])['policy']
+ fetched_policy = self.policy_client.show_policy(policy['id'])['policy']
self.assertIn('id', fetched_policy)
self.assertIn('blob', fetched_policy)
self.assertIn('type', fetched_policy)
diff --git a/tempest/api/identity/admin/v3/test_projects.py b/tempest/api/identity/admin/v3/test_projects.py
index d39fd5f..af9497c 100644
--- a/tempest/api/identity/admin/v3/test_projects.py
+++ b/tempest/api/identity/admin/v3/test_projects.py
@@ -161,7 +161,7 @@
u_name = data_utils.rand_name('user')
u_desc = u_name + 'description'
u_email = u_name + '@testmail.tm'
- u_password = data_utils.rand_name('pass')
+ u_password = data_utils.rand_password()
user = self.client.create_user(
u_name, description=u_desc, password=u_password,
email=u_email, project_id=project['id'])['user']
diff --git a/tempest/api/identity/admin/v3/test_regions.py b/tempest/api/identity/admin/v3/test_regions.py
index 0dbbae0..ec1b12e 100644
--- a/tempest/api/identity/admin/v3/test_regions.py
+++ b/tempest/api/identity/admin/v3/test_regions.py
@@ -46,7 +46,7 @@
def _delete_region(self, region_id):
self.client.delete_region(region_id)
self.assertRaises(lib_exc.NotFound,
- self.client.get_region, region_id)
+ self.client.show_region, region_id)
@test.idempotent_id('56186092-82e4-43f2-b954-91013218ba42')
def test_create_update_get_delete_region(self):
@@ -68,7 +68,7 @@
self.assertEqual(self.setup_regions[1]['id'],
region['parent_region_id'])
# Get the details of region
- region = self.client.get_region(region['id'])['region']
+ region = self.client.show_region(region['id'])['region']
self.assertEqual(r_alt_description, region['description'])
self.assertEqual(self.setup_regions[1]['id'],
region['parent_region_id'])
diff --git a/tempest/api/identity/admin/v3/test_roles.py b/tempest/api/identity/admin/v3/test_roles.py
index 3be2643..f194d9c 100644
--- a/tempest/api/identity/admin/v3/test_roles.py
+++ b/tempest/api/identity/admin/v3/test_roles.py
@@ -31,7 +31,7 @@
u_name = data_utils.rand_name('user')
u_desc = '%s description' % u_name
u_email = '%s@testmail.tm' % u_name
- cls.u_password = data_utils.rand_name('pass')
+ cls.u_password = data_utils.rand_password()
cls.domain = cls.client.create_domain(
data_utils.rand_name('domain'),
description=data_utils.rand_name('domain-desc'))['domain']
diff --git a/tempest/api/identity/admin/v3/test_services.py b/tempest/api/identity/admin/v3/test_services.py
index d1595dd..c6e3df4 100644
--- a/tempest/api/identity/admin/v3/test_services.py
+++ b/tempest/api/identity/admin/v3/test_services.py
@@ -24,9 +24,9 @@
def _del_service(self, service_id):
# Used for deleting the services created in this class
- self.service_client.delete_service(service_id)
+ self.services_client.delete_service(service_id)
# Checking whether service is deleted successfully
- self.assertRaises(lib_exc.NotFound, self.service_client.show_service,
+ self.assertRaises(lib_exc.NotFound, self.services_client.show_service,
service_id)
@test.attr(type='smoke')
@@ -36,7 +36,7 @@
name = data_utils.rand_name('service')
serv_type = data_utils.rand_name('type')
desc = data_utils.rand_name('description')
- create_service = self.service_client.create_service(
+ create_service = self.services_client.create_service(
type=serv_type, name=name, description=desc)['service']
self.addCleanup(self._del_service, create_service['id'])
self.assertIsNotNone(create_service['id'])
@@ -49,14 +49,14 @@
s_id = create_service['id']
resp1_desc = create_service['description']
s_desc2 = data_utils.rand_name('desc2')
- update_service = self.service_client.update_service(
+ update_service = self.services_client.update_service(
s_id, description=s_desc2)['service']
resp2_desc = update_service['description']
self.assertNotEqual(resp1_desc, resp2_desc)
# Get service
- fetched_service = self.service_client.show_service(s_id)['service']
+ fetched_service = self.services_client.show_service(s_id)['service']
resp3_desc = fetched_service['description']
self.assertEqual(resp2_desc, resp3_desc)
@@ -67,9 +67,9 @@
# Create a service only with name and type
name = data_utils.rand_name('service')
serv_type = data_utils.rand_name('type')
- service = self.service_client.create_service(
+ service = self.services_client.create_service(
type=serv_type, name=name)['service']
- self.addCleanup(self.service_client.delete_service, service['id'])
+ self.addCleanup(self.services_client.delete_service, service['id'])
self.assertIn('id', service)
expected_data = {'name': name, 'type': serv_type}
self.assertDictContainsSubset(expected_data, service)
@@ -81,14 +81,14 @@
for _ in range(3):
name = data_utils.rand_name('service')
serv_type = data_utils.rand_name('type')
- create_service = self.service_client.create_service(
+ create_service = self.services_client.create_service(
type=serv_type, name=name)['service']
- self.addCleanup(self.service_client.delete_service,
+ self.addCleanup(self.services_client.delete_service,
create_service['id'])
service_ids.append(create_service['id'])
# List and Verify Services
- services = self.service_client.list_services()['services']
+ services = self.services_client.list_services()['services']
fetched_ids = [service['id'] for service in services]
found = [s for s in fetched_ids if s in service_ids]
self.assertEqual(len(found), len(service_ids))
diff --git a/tempest/api/identity/admin/v3/test_tokens.py b/tempest/api/identity/admin/v3/test_tokens.py
index 7d33d4a..f5b20d5 100644
--- a/tempest/api/identity/admin/v3/test_tokens.py
+++ b/tempest/api/identity/admin/v3/test_tokens.py
@@ -29,7 +29,7 @@
u_name = data_utils.rand_name('user')
u_desc = '%s-description' % u_name
u_email = '%s@testmail.tm' % u_name
- u_password = data_utils.rand_name('pass')
+ u_password = data_utils.rand_password()
user = self.client.create_user(
u_name, description=u_desc, password=u_password,
email=u_email)['user']
@@ -60,7 +60,7 @@
# Create a user.
user_name = data_utils.rand_name(name='user')
- user_password = data_utils.rand_name(name='pass')
+ user_password = data_utils.rand_password()
user = self.client.create_user(user_name,
password=user_password)['user']
self.addCleanup(self.client.delete_user, user['id'])
diff --git a/tempest/api/identity/admin/v3/test_trusts.py b/tempest/api/identity/admin/v3/test_trusts.py
index a8b0af9..bf7ad71 100644
--- a/tempest/api/identity/admin/v3/test_trusts.py
+++ b/tempest/api/identity/admin/v3/test_trusts.py
@@ -55,7 +55,7 @@
self.trustor_username = data_utils.rand_name('user')
u_desc = self.trustor_username + 'description'
u_email = self.trustor_username + '@testmail.xx'
- self.trustor_password = data_utils.rand_name('pass')
+ self.trustor_password = data_utils.rand_password()
user = self.client.create_user(
self.trustor_username,
description=u_desc,
@@ -115,7 +115,7 @@
trustor_user_id=self.trustor_user_id,
trustee_user_id=self.trustee_user_id,
project_id=self.trustor_project_id,
- role_names=[self.delegated_role],
+ roles=[{'name': self.delegated_role}],
impersonation=impersonate,
expires_at=expires)['trust']
self.trust_id = trust_create['id']
diff --git a/tempest/api/identity/admin/v3/test_users.py b/tempest/api/identity/admin/v3/test_users.py
index b56c9e6..6dbd443 100644
--- a/tempest/api/identity/admin/v3/test_users.py
+++ b/tempest/api/identity/admin/v3/test_users.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import time
+
from tempest.api.identity import base
from tempest.common.utils import data_utils
from tempest import test
@@ -27,7 +29,7 @@
u_name = data_utils.rand_name('user')
u_desc = u_name + 'description'
u_email = u_name + '@testmail.tm'
- u_password = data_utils.rand_name('pass')
+ u_password = data_utils.rand_password()
user = self.client.create_user(
u_name, description=u_desc, password=u_password,
email=u_email, enabled=False)['user']
@@ -67,15 +69,23 @@
def test_update_user_password(self):
# Creating User to check password updation
u_name = data_utils.rand_name('user')
- original_password = data_utils.rand_name('pass')
+ original_password = data_utils.rand_password()
user = self.client.create_user(
u_name, password=original_password)['user']
# Delete the User at the end all test methods
self.addCleanup(self.client.delete_user, user['id'])
# Update user with new password
- new_password = data_utils.rand_name('pass1')
- self.client.update_user_password(user['id'], new_password,
- original_password)
+ new_password = data_utils.rand_password()
+ self.client.update_user_password(user['id'], password=new_password,
+ original_password=original_password)
+ # TODO(lbragstad): Sleeping after the response status has been checked
+ # and the body loaded as JSON allows requests to fail-fast. The sleep
+ # is necessary because keystone will err on the side of security and
+ # invalidate tokens within a small margin of error (within the same
+ # wall clock second) after a revocation event is issued (such as a
+ # password change). Remove this once keystone and Fernet support
+ # sub-second precision, see bug 1517697 for more details.
+ time.sleep(1)
resp = self.token.auth(user_id=user['id'],
password=new_password).response
subject_token = resp['x-subject-token']
@@ -99,7 +109,7 @@
u_name = data_utils.rand_name('user')
u_desc = u_name + 'description'
u_email = u_name + '@testmail.tm'
- u_password = data_utils.rand_name('pass')
+ u_password = data_utils.rand_password()
user_body = self.client.create_user(
u_name, description=u_desc, password=u_password,
email=u_email, enabled=False, project_id=u_project['id'])['user']
diff --git a/tempest/api/identity/admin/v3/test_users_negative.py b/tempest/api/identity/admin/v3/test_users_negative.py
index d40a5b9..4c80bda 100644
--- a/tempest/api/identity/admin/v3/test_users_negative.py
+++ b/tempest/api/identity/admin/v3/test_users_negative.py
@@ -28,7 +28,7 @@
# Attempt to create a user in a non-existent domain should fail
u_name = data_utils.rand_name('user')
u_email = u_name + '@testmail.tm'
- u_password = data_utils.rand_name('pass')
+ u_password = data_utils.rand_password()
self.assertRaises(lib_exc.NotFound, self.client.create_user,
u_name, u_password,
email=u_email,
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index 0364f3a..d98e3b1 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -35,7 +35,7 @@
@classmethod
def disable_tenant(cls, tenant_name):
tenant = cls.get_tenant_by_name(tenant_name)
- cls.client.update_tenant(tenant['id'], enabled=False)
+ cls.tenants_client.update_tenant(tenant['id'], enabled=False)
@classmethod
def get_user_by_name(cls, name):
@@ -47,7 +47,7 @@
@classmethod
def get_tenant_by_name(cls, name):
try:
- tenants = cls.client.list_tenants()['tenants']
+ tenants = cls.tenants_client.list_tenants()['tenants']
except AttributeError:
tenants = cls.client.list_projects()['projects']
tenant = [t for t in tenants if t['name'] == name]
@@ -56,7 +56,7 @@
@classmethod
def get_role_by_name(cls, name):
- roles = cls.client.list_roles()['roles']
+ roles = cls.roles_client.list_roles()['roles']
role = [r for r in roles if r['name'] == name]
if len(role) > 0:
return role[0]
@@ -75,6 +75,8 @@
super(BaseIdentityV2Test, cls).setup_clients()
cls.non_admin_client = cls.os.identity_public_client
cls.non_admin_token_client = cls.os.token_client
+ cls.non_admin_tenants_client = cls.os.tenants_public_client
+ cls.non_admin_roles_client = cls.os.roles_public_client
@classmethod
def resource_setup(cls):
@@ -95,11 +97,16 @@
cls.client = cls.os_adm.identity_client
cls.non_admin_client = cls.os.identity_client
cls.token_client = cls.os_adm.token_client
+ cls.tenants_client = cls.os_adm.tenants_client
+ cls.non_admin_tenants_client = cls.os.tenants_client
+ cls.roles_client = cls.os_adm.roles_client
+ cls.non_admin_roles_client = cls.os.roles_client
@classmethod
def resource_setup(cls):
super(BaseIdentityV2AdminTest, cls).resource_setup()
- cls.data = DataGenerator(cls.client)
+ cls.data = DataGenerator(cls.client, cls.tenants_client,
+ cls.roles_client)
@classmethod
def resource_cleanup(cls):
@@ -137,7 +144,7 @@
cls.token = cls.os_adm.token_v3_client
cls.endpoints_client = cls.os_adm.endpoints_client
cls.region_client = cls.os_adm.region_client
- cls.service_client = cls.os_adm.service_client
+ cls.services_client = cls.os_adm.identity_services_client
cls.policy_client = cls.os_adm.policy_client
cls.creds_client = cls.os_adm.credentials_client
cls.groups_client = cls.os_adm.groups_client
@@ -184,8 +191,11 @@
class DataGenerator(object):
- def __init__(self, client):
+ def __init__(self, client, tenants_client=None, roles_client=None):
self.client = client
+ # TODO(dmellado) split Datagenerator for v2 and v3
+ self.tenants_client = tenants_client
+ self.roles_client = roles_client
self.users = []
self.tenants = []
self.roles = []
@@ -207,7 +217,7 @@
"""Set up a test user."""
self.setup_test_tenant()
self.test_user = data_utils.rand_name('test_user')
- self.test_password = data_utils.rand_name('pass')
+ self.test_password = data_utils.rand_password()
self.test_email = self.test_user + '@testmail.tm'
self.user = self.client.create_user(self.test_user,
self.test_password,
@@ -219,7 +229,7 @@
"""Set up a test tenant."""
self.test_tenant = data_utils.rand_name('test_tenant')
self.test_description = data_utils.rand_name('desc')
- self.tenant = self.client.create_tenant(
+ self.tenant = self.tenants_client.create_tenant(
name=self.test_tenant,
description=self.test_description)['tenant']
self.tenants.append(self.tenant)
@@ -227,14 +237,14 @@
def setup_test_role(self):
"""Set up a test role."""
self.test_role = data_utils.rand_name('role')
- self.role = self.client.create_role(self.test_role)['role']
+ self.role = self.roles_client.create_role(self.test_role)['role']
self.roles.append(self.role)
def setup_test_v3_user(self):
"""Set up a test v3 user."""
self.setup_test_project()
self.test_user = data_utils.rand_name('test_user')
- self.test_password = data_utils.rand_name('pass')
+ self.test_password = data_utils.rand_password()
self.test_email = self.test_user + '@testmail.tm'
self.v3_user = self.client.create_user(
self.test_user,
@@ -287,9 +297,9 @@
for user in self.users:
self._try_wrapper(self.client.delete_user, user)
for tenant in self.tenants:
- self._try_wrapper(self.client.delete_tenant, tenant)
+ self._try_wrapper(self.tenants_client.delete_tenant, tenant)
for role in self.roles:
- self._try_wrapper(self.client.delete_role, role)
+ self._try_wrapper(self.roles_client.delete_role, role)
for v3_user in self.v3_users:
self._try_wrapper(self.client.delete_user, v3_user)
for v3_project in self.projects:
diff --git a/tempest/api/identity/v2/test_ec2_credentials.py b/tempest/api/identity/v2/test_ec2_credentials.py
index 763d8de..88161a3 100644
--- a/tempest/api/identity/v2/test_ec2_credentials.py
+++ b/tempest/api/identity/v2/test_ec2_credentials.py
@@ -38,7 +38,7 @@
"""Create user ec2 credentials."""
resp = self.non_admin_client.create_user_ec2_credentials(
self.creds.credentials.user_id,
- self.creds.credentials.tenant_id)["credential"]
+ tenant_id=self.creds.credentials.tenant_id)["credential"]
access = resp['access']
self.addCleanup(
self.non_admin_client.delete_user_ec2_credentials,
@@ -56,12 +56,12 @@
# create first ec2 credentials
creds1 = self.non_admin_client.create_user_ec2_credentials(
self.creds.credentials.user_id,
- self.creds.credentials.tenant_id)["credential"]
+ tenant_id=self.creds.credentials.tenant_id)["credential"]
created_creds.append(creds1['access'])
# create second ec2 credentials
creds2 = self.non_admin_client.create_user_ec2_credentials(
self.creds.credentials.user_id,
- self.creds.credentials.tenant_id)["credential"]
+ tenant_id=self.creds.credentials.tenant_id)["credential"]
created_creds.append(creds2['access'])
# add credentials to be cleaned up
self.addCleanup(
@@ -86,7 +86,7 @@
"""Get the definite user ec2 credentials."""
resp = self.non_admin_client.create_user_ec2_credentials(
self.creds.credentials.user_id,
- self.creds.credentials.tenant_id)["credential"]
+ tenant_id=self.creds.credentials.tenant_id)["credential"]
self.addCleanup(
self.non_admin_client.delete_user_ec2_credentials,
self.creds.credentials.user_id, resp['access'])
@@ -102,7 +102,7 @@
"""Delete user ec2 credentials."""
resp = self.non_admin_client.create_user_ec2_credentials(
self.creds.credentials.user_id,
- self.creds.credentials.tenant_id)["credential"]
+ tenant_id=self.creds.credentials.tenant_id)["credential"]
access = resp['access']
self.non_admin_client.delete_user_ec2_credentials(
self.creds.credentials.user_id, access)
diff --git a/tempest/api/identity/v2/test_tenants.py b/tempest/api/identity/v2/test_tenants.py
index 1fcff8d..4e31557 100644
--- a/tempest/api/identity/v2/test_tenants.py
+++ b/tempest/api/identity/v2/test_tenants.py
@@ -26,7 +26,7 @@
@test.idempotent_id('ecae2459-243d-4ba1-ad02-65f15dc82b78')
def test_list_tenants_returns_only_authorized_tenants(self):
alt_tenant_name = self.alt_manager.credentials.credentials.tenant_name
- resp = self.non_admin_client.list_tenants()
+ resp = self.non_admin_tenants_client.list_tenants()
# check that user can see only that tenants that he presents in so user
# can successfully authenticate using his credentials and tenant name
diff --git a/tempest/api/identity/v2/test_users.py b/tempest/api/identity/v2/test_users.py
index 03c6621..5f2a8c4 100644
--- a/tempest/api/identity/v2/test_users.py
+++ b/tempest/api/identity/v2/test_users.py
@@ -56,8 +56,8 @@
old_pass=new_pass)
# user updates own password
- resp = self.non_admin_client.update_user_own_password(
- user_id=user_id, new_pass=new_pass, old_pass=old_pass)['access']
+ self.non_admin_client.update_user_own_password(
+ user_id=user_id, new_pass=new_pass, old_pass=old_pass)
# TODO(lbragstad): Sleeping after the response status has been checked
# and the body loaded as JSON allows requests to fail-fast. The sleep
@@ -68,8 +68,6 @@
# sub-second precision.
time.sleep(1)
- # check authorization with new token
- self.non_admin_token_client.auth_token(resp['token']['id'])
# check authorization with new password
self.non_admin_token_client.auth(self.username,
new_pass,
diff --git a/tempest/api/identity/v3/test_users.py b/tempest/api/identity/v3/test_users.py
index 2bab5d1..93814d3 100644
--- a/tempest/api/identity/v3/test_users.py
+++ b/tempest/api/identity/v3/test_users.py
@@ -50,13 +50,13 @@
# to change password back. important for allow_tenant_isolation = false
self.addCleanup(
self.non_admin_client_for_cleanup.update_user_password,
- user_id=user_id,
+ user_id,
password=old_pass,
original_password=new_pass)
# user updates own password
self.non_admin_client.update_user_password(
- user_id=user_id, password=new_pass, original_password=old_pass)
+ user_id, password=new_pass, original_password=old_pass)
# TODO(lbragstad): Sleeping after the response status has been checked
# and the body loaded as JSON allows requests to fail-fast. The sleep
diff --git a/tempest/api/image/base.py b/tempest/api/image/base.py
index da0ce83..c3205ce 100644
--- a/tempest/api/image/base.py
+++ b/tempest/api/image/base.py
@@ -70,8 +70,10 @@
container_format = kwargs.pop('container_format')
disk_format = kwargs.pop('disk_format')
- image = cls.client.create_image(name, container_format,
- disk_format, **kwargs)
+ image = cls.client.create_image(name=name,
+ container_format=container_format,
+ disk_format=disk_format,
+ **kwargs)
# Image objects returned by the v1 client have the image
# data inside a dict that is keyed against 'image'.
if 'image' in image:
@@ -156,7 +158,7 @@
def _create_image(self):
name = data_utils.rand_name('image')
- image = self.os_img_client.create_image(name,
+ image = self.os_img_client.create_image(name=name,
container_format='bare',
disk_format='raw')
image_id = image['id']
diff --git a/tempest/api/image/v2/test_images_member.py b/tempest/api/image/v2/test_images_member.py
index 98ff64b..bb73318 100644
--- a/tempest/api/image/v2/test_images_member.py
+++ b/tempest/api/image/v2/test_images_member.py
@@ -19,8 +19,8 @@
@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_image_member(image_id,
- member=self.alt_tenant_id)
+ member = self.os_img_client.create_image_member(
+ image_id, member=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')
@@ -40,8 +40,8 @@
@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_image_member(image_id,
- member=self.alt_tenant_id)
+ member = self.os_img_client.create_image_member(
+ image_id, member=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')
@@ -54,8 +54,8 @@
@test.idempotent_id('a6ee18b9-4378-465e-9ad9-9a6de58a3287')
def test_get_image_member(self):
image_id = self._create_image()
- self.os_img_client.add_image_member(image_id,
- member=self.alt_tenant_id)
+ self.os_img_client.create_image_member(
+ image_id, member=self.alt_tenant_id)
self.alt_img_client.update_image_member(image_id,
self.alt_tenant_id,
status='accepted')
@@ -70,8 +70,8 @@
@test.idempotent_id('72989bc7-2268-48ed-af22-8821e835c914')
def test_remove_image_member(self):
image_id = self._create_image()
- self.os_img_client.add_image_member(image_id,
- member=self.alt_tenant_id)
+ self.os_img_client.create_image_member(
+ image_id, member=self.alt_tenant_id)
self.alt_img_client.update_image_member(image_id,
self.alt_tenant_id,
status='accepted')
@@ -93,8 +93,8 @@
@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,
- member=self.alt_tenant_id)
+ member = self.os_img_client.create_image_member(
+ image_id, member=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')
diff --git a/tempest/api/image/v2/test_images_member_negative.py b/tempest/api/image/v2/test_images_member_negative.py
index d5ea291..eb90719 100644
--- a/tempest/api/image/v2/test_images_member_negative.py
+++ b/tempest/api/image/v2/test_images_member_negative.py
@@ -22,8 +22,8 @@
@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_image_member(image_id,
- member=self.alt_tenant_id)
+ member = self.os_img_client.create_image_member(
+ image_id, member=self.alt_tenant_id)
self.assertEqual(member['status'], 'pending')
self.assertRaises(lib_exc.BadRequest,
self.alt_img_client.update_image_member,
@@ -34,8 +34,8 @@
@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_image_member(image_id,
- member=self.alt_tenant_id)
+ member = self.os_img_client.create_image_member(
+ image_id, member=self.alt_tenant_id)
self.assertEqual(member['status'], 'pending')
self.assertNotIn(image_id, self._list_image_ids_as_alt())
self.assertRaises(lib_exc.Forbidden,
diff --git a/tempest/api/image/v2/test_images_negative.py b/tempest/api/image/v2/test_images_negative.py
index 71c8c7a..485942e 100644
--- a/tempest/api/image/v2/test_images_negative.py
+++ b/tempest/api/image/v2/test_images_negative.py
@@ -90,10 +90,12 @@
def test_register_with_invalid_container_format(self):
# Negative tests for invalid data supplied to POST /images
self.assertRaises(lib_exc.BadRequest, self.client.create_image,
- 'test', 'wrong', 'vhd')
+ name='test', container_format='wrong',
+ disk_format='vhd')
@test.attr(type=['negative'])
@test.idempotent_id('70c6040c-5a97-4111-9e13-e73665264ce1')
def test_register_with_invalid_disk_format(self):
self.assertRaises(lib_exc.BadRequest, self.client.create_image,
- 'test', 'bare', 'wrong')
+ name='test', container_format='bare',
+ disk_format='wrong')
diff --git a/tempest/api/network/admin/test_agent_management.py b/tempest/api/network/admin/test_agent_management.py
index c5d0d57..64802aa 100644
--- a/tempest/api/network/admin/test_agent_management.py
+++ b/tempest/api/network/admin/test_agent_management.py
@@ -63,7 +63,7 @@
# one to avoid the negative effect.
agent_status = {'admin_state_up': origin_status}
body = self.admin_client.update_agent(agent_id=self.agent['id'],
- agent_info=agent_status)
+ agent=agent_status)
updated_status = body['agent']['admin_state_up']
self.assertEqual(origin_status, updated_status)
@@ -73,7 +73,7 @@
description = 'description for update agent.'
agent_description = {'description': description}
body = self.admin_client.update_agent(agent_id=self.agent['id'],
- agent_info=agent_description)
+ agent=agent_description)
self.addCleanup(self._restore_agent)
updated_description = body['agent']['description']
self.assertEqual(updated_description, description)
@@ -84,4 +84,4 @@
description = self.agent['description'] or ''
origin_agent = {'description': description}
self.admin_client.update_agent(agent_id=self.agent['id'],
- agent_info=origin_agent)
+ agent=origin_agent)
diff --git a/tempest/api/network/admin/test_dhcp_agent_scheduler.py b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
index 7692b56..f186b36 100644
--- a/tempest/api/network/admin/test_dhcp_agent_scheduler.py
+++ b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
@@ -92,6 +92,6 @@
def _add_dhcp_agent_to_network(self, network_id, agent):
self.admin_client.add_dhcp_agent_to_network(agent['id'],
- network_id)
+ network_id=network_id)
self.assertTrue(self._check_network_in_dhcp_agent(
network_id, agent))
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
index d5556b8..36747a3 100644
--- a/tempest/api/network/admin/test_l3_agent_scheduler.py
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -97,7 +97,7 @@
l3_agent_ids = list()
self.admin_client.add_router_to_l3_agent(
self.agent['id'],
- self.router['id'])
+ router_id=self.router['id'])
body = (
self.admin_client.list_l3_agents_hosting_router(self.router['id']))
for agent in body['agents']:
diff --git a/tempest/api/network/admin/test_negative_quotas.py b/tempest/api/network/admin/test_negative_quotas.py
index 5c4c421..47da08c 100644
--- a/tempest/api/network/admin/test_negative_quotas.py
+++ b/tempest/api/network/admin/test_negative_quotas.py
@@ -29,6 +29,7 @@
quota_driver = neutron.db.quota_db.DbQuotaDriver
"""
+ force_tenant_isolation = True
@classmethod
def skip_checks(cls):
@@ -45,9 +46,9 @@
@test.idempotent_id('644f4e1b-1bf9-4af0-9fd8-eb56ac0f51cf')
def test_network_quota_exceeding(self):
# Set the network quota to two
- self.admin_client.update_quotas(self.networks_client.tenant_id,
- network=2)
- self.addCleanup(self.admin_client.reset_quotas,
+ self.admin_quotas_client.update_quotas(self.networks_client.tenant_id,
+ network=2)
+ self.addCleanup(self.admin_quotas_client.reset_quotas,
self.networks_client.tenant_id)
# Create two networks
diff --git a/tempest/api/network/admin/test_quotas.py b/tempest/api/network/admin/test_quotas.py
index 4a25206..45d35cf 100644
--- a/tempest/api/network/admin/test_quotas.py
+++ b/tempest/api/network/admin/test_quotas.py
@@ -57,14 +57,14 @@
self.addCleanup(self.identity_utils.delete_project, project_id)
# Change quotas for tenant
- quota_set = self.admin_client.update_quotas(project_id,
- **new_quotas)['quota']
- self.addCleanup(self.admin_client.reset_quotas, project_id)
+ quota_set = self.admin_quotas_client.update_quotas(
+ project_id, **new_quotas)['quota']
+ self.addCleanup(self.admin_quotas_client.reset_quotas, project_id)
for key, value in six.iteritems(new_quotas):
self.assertEqual(value, quota_set[key])
# Confirm our tenant is listed among tenants with non default quotas
- non_default_quotas = self.admin_client.list_quotas()
+ non_default_quotas = self.admin_quotas_client.list_quotas()
found = False
for qs in non_default_quotas['quotas']:
if qs['tenant_id'] == project_id:
@@ -72,14 +72,14 @@
self.assertTrue(found)
# Confirm from API quotas were changed as requested for tenant
- quota_set = self.admin_client.show_quotas(project_id)
+ quota_set = self.admin_quotas_client.show_quotas(project_id)
quota_set = quota_set['quota']
for key, value in six.iteritems(new_quotas):
self.assertEqual(value, quota_set[key])
# Reset quotas to default and confirm
- self.admin_client.reset_quotas(project_id)
- non_default_quotas = self.admin_client.list_quotas()
+ self.admin_quotas_client.reset_quotas(project_id)
+ non_default_quotas = self.admin_quotas_client.list_quotas()
for q in non_default_quotas['quotas']:
self.assertNotEqual(project_id, q['tenant_id'])
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index b4ea29b..f1fd3e9 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -74,6 +74,7 @@
cls.networks_client = cls.os.networks_client
cls.subnets_client = cls.os.subnets_client
cls.ports_client = cls.os.ports_client
+ cls.quotas_client = cls.os.network_quotas_client
cls.floating_ips_client = cls.os.floating_ips_client
@classmethod
@@ -98,9 +99,12 @@
floating_ip['id'])
# Clean up metering label rules
+ # Not all classes in the hierarchy have the client class variable
+ if len(cls.metering_label_rules) > 0:
+ label_rules_client = cls.admin_metering_label_rules_client
for metering_label_rule in cls.metering_label_rules:
cls._try_delete_resource(
- cls.admin_client.delete_metering_label_rule,
+ label_rules_client.delete_metering_label_rule,
metering_label_rule['id'])
# Clean up metering labels
for metering_label in cls.metering_labels:
@@ -271,8 +275,11 @@
cls.admin_networks_client = cls.os_adm.networks_client
cls.admin_subnets_client = cls.os_adm.subnets_client
cls.admin_ports_client = cls.os_adm.ports_client
+ cls.admin_quotas_client = cls.os_adm.network_quotas_client
cls.admin_floating_ips_client = cls.os_adm.floating_ips_client
cls.admin_metering_labels_client = cls.os_adm.metering_labels_client
+ cls.admin_metering_label_rules_client = (
+ cls.os_adm.metering_label_rules_client)
@classmethod
def create_metering_label(cls, name, description):
@@ -288,7 +295,8 @@
def create_metering_label_rule(cls, remote_ip_prefix, direction,
metering_label_id):
"""Wrapper utility that returns a test metering label rule."""
- body = cls.admin_client.create_metering_label_rule(
+ client = cls.admin_metering_label_rules_client
+ body = client.create_metering_label_rule(
remote_ip_prefix=remote_ip_prefix, direction=direction,
metering_label_id=metering_label_id)
metering_label_rule = body['metering_label_rule']
diff --git a/tempest/api/network/test_metering_extensions.py b/tempest/api/network/test_metering_extensions.py
index c4021b4..007ba3b 100644
--- a/tempest/api/network/test_metering_extensions.py
+++ b/tempest/api/network/test_metering_extensions.py
@@ -59,12 +59,11 @@
self.assertEqual(len(labels['metering_labels']), 0)
def _delete_metering_label_rule(self, metering_label_rule_id):
+ client = self.admin_metering_label_rules_client
# Deletes a rule and verifies if it is deleted or not
- self.admin_client.delete_metering_label_rule(
- metering_label_rule_id)
+ client.delete_metering_label_rule(metering_label_rule_id)
# Asserting that the rule is not found in list after deletion
- rules = (self.admin_client.list_metering_label_rules(
- id=metering_label_rule_id))
+ rules = client.list_metering_label_rules(id=metering_label_rule_id)
self.assertEqual(len(rules['metering_label_rules']), 0)
@test.idempotent_id('e2fb2f8c-45bf-429a-9f17-171c70444612')
@@ -105,8 +104,9 @@
@test.idempotent_id('cc832399-6681-493b-9d79-0202831a1281')
def test_list_metering_label_rules(self):
+ client = self.admin_metering_label_rules_client
# Verify rule filtering
- body = self.admin_client.list_metering_label_rules(id=33)
+ body = client.list_metering_label_rules(id=33)
metering_label_rules = body['metering_label_rules']
self.assertEqual(0, len(metering_label_rules))
@@ -115,7 +115,8 @@
# Creates a rule
remote_ip_prefix = ("10.0.1.0/24" if self._ip_version == 4
else "fd03::/64")
- body = (self.admin_client.create_metering_label_rule(
+ client = self.admin_metering_label_rules_client
+ body = (client.create_metering_label_rule(
remote_ip_prefix=remote_ip_prefix,
direction="ingress",
metering_label_id=self.metering_label['id']))
@@ -124,14 +125,14 @@
metering_label_rule['id'])
# Assert whether created rules are found in rules list or fail
# if created rules are not found in rules list
- rules = (self.admin_client.list_metering_label_rules(
- id=metering_label_rule['id']))
+ rules = client.list_metering_label_rules(id=metering_label_rule['id'])
self.assertEqual(len(rules['metering_label_rules']), 1)
@test.idempotent_id('b7354489-96ea-41f3-9452-bace120fb4a7')
def test_show_metering_label_rule(self):
# Verifies the details of a rule
- body = (self.admin_client.show_metering_label_rule(
+ client = self.admin_metering_label_rules_client
+ body = (client.show_metering_label_rule(
self.metering_label_rule['id']))
metering_label_rule = body['metering_label_rule']
self.assertEqual(self.metering_label_rule['id'],
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index ed191b6..406ad44 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -301,7 +301,7 @@
test_routes.sort(key=lambda x: x['destination'])
extra_route = self.client.update_extra_routes(router['id'],
- test_routes)
+ routes=test_routes)
show_body = self.client.show_router(router['id'])
# Assert the number of routes
self.assertEqual(routes_num, len(extra_route['router']['routes']))
diff --git a/tempest/api/orchestration/stacks/test_neutron_resources.py b/tempest/api/orchestration/stacks/test_neutron_resources.py
index a614c76..8466e11 100644
--- a/tempest/api/orchestration/stacks/test_neutron_resources.py
+++ b/tempest/api/orchestration/stacks/test_neutron_resources.py
@@ -89,7 +89,7 @@
server_id = body['physical_resource_id']
LOG.debug('Console output for %s', server_id)
output = cls.servers_client.get_console_output(
- server_id, None)['output']
+ server_id)['output']
LOG.debug(output)
raise e
diff --git a/tempest/api/telemetry/base.py b/tempest/api/telemetry/base.py
index bbd01f0..bbf6db2 100644
--- a/tempest/api/telemetry/base.py
+++ b/tempest/api/telemetry/base.py
@@ -75,10 +75,11 @@
return body
@classmethod
- def create_image(cls, client):
- body = client.create_image(
- data_utils.rand_name('image'), container_format='bare',
- disk_format='raw', visibility='private')
+ def create_image(cls, client, **kwargs):
+ body = client.create_image(name=data_utils.rand_name('image'),
+ container_format='bare',
+ disk_format='raw',
+ **kwargs)
# TODO(jswarren) Move ['image'] up to initial body value assignment
# once both v1 and v2 glance clients include the full response
# object.
diff --git a/tempest/api/telemetry/test_telemetry_notification_api.py b/tempest/api/telemetry/test_telemetry_notification_api.py
index 7511505..a575125 100644
--- a/tempest/api/telemetry/test_telemetry_notification_api.py
+++ b/tempest/api/telemetry/test_telemetry_notification_api.py
@@ -39,7 +39,7 @@
@testtools.skipIf(not CONF.image_feature_enabled.api_v1,
"Glance api v1 is disabled")
def test_check_glance_v1_notifications(self):
- body = self.create_image(self.image_client)
+ body = self.create_image(self.image_client, is_public=False)
self.image_client.update_image(body['id'], data='data')
query = 'resource', 'eq', body['id']
@@ -55,7 +55,7 @@
@testtools.skipIf(not CONF.image_feature_enabled.api_v2,
"Glance api v2 is disabled")
def test_check_glance_v2_notifications(self):
- body = self.create_image(self.image_client_v2)
+ body = self.create_image(self.image_client_v2, visibility='private')
self.image_client_v2.store_image_file(body['id'], "file")
self.image_client_v2.show_image_file(body['id'])
diff --git a/tempest/api/volume/admin/test_volume_services.py b/tempest/api/volume/admin/test_volume_services.py
index 6692594..2b7ee45 100644
--- a/tempest/api/volume/admin/test_volume_services.py
+++ b/tempest/api/volume/admin/test_volume_services.py
@@ -39,9 +39,8 @@
@test.idempotent_id('63a3e1ca-37ee-4983-826d-83276a370d25')
def test_get_service_by_service_binary_name(self):
- params = {'binary': self.binary_name}
- services = (self.admin_volume_services_client.list_services(params)
- ['services'])
+ services = (self.admin_volume_services_client.list_services(
+ binary=self.binary_name)['services'])
self.assertNotEqual(0, len(services))
for service in services:
self.assertEqual(self.binary_name, service['binary'])
@@ -50,10 +49,9 @@
def test_get_service_by_host_name(self):
services_on_host = [service for service in self.services if
service['host'] == self.host_name]
- params = {'host': self.host_name}
- services = (self.admin_volume_services_client.list_services(params)
- ['services'])
+ services = (self.admin_volume_services_client.list_services(
+ host=self.host_name)['services'])
# we could have a periodic job checkin between the 2 service
# lookups, so only compare binary lists.
@@ -65,10 +63,10 @@
@test.idempotent_id('ffa6167c-4497-4944-a464-226bbdb53908')
def test_get_service_by_service_and_host_name(self):
- params = {'host': self.host_name, 'binary': self.binary_name}
- services = (self.admin_volume_services_client.list_services(params)
- ['services'])
+ services = (self.admin_volume_services_client.list_services(
+ host=self.host_name, binary=self.binary_name))['services']
+
self.assertEqual(1, len(services))
self.assertEqual(self.host_name, services[0]['host'])
self.assertEqual(self.binary_name, services[0]['binary'])
diff --git a/tempest/api/volume/admin/test_volume_types.py b/tempest/api/volume/admin/test_volume_types.py
index b45c7c5..acb591d 100644
--- a/tempest/api/volume/admin/test_volume_types.py
+++ b/tempest/api/volume/admin/test_volume_types.py
@@ -32,7 +32,7 @@
@test.idempotent_id('9d9b28e3-1b2e-4483-a2cc-24aa0ea1de54')
def test_volume_type_list(self):
- # List Volume types.
+ # List volume types.
body = self.volume_types_client.list_volume_types()['volume_types']
self.assertIsInstance(body, list)
diff --git a/tempest/api/volume/admin/test_volumes_backup.py b/tempest/api/volume/admin/test_volumes_backup.py
index 0399413..ed34a9b 100644
--- a/tempest/api/volume/admin/test_volumes_backup.py
+++ b/tempest/api/volume/admin/test_volumes_backup.py
@@ -48,7 +48,7 @@
# Create backup
backup_name = data_utils.rand_name('Backup')
create_backup = self.backups_adm_client.create_backup
- backup = create_backup(self.volume['id'],
+ backup = create_backup(volume_id=self.volume['id'],
name=backup_name)['backup']
self.addCleanup(self.backups_adm_client.delete_backup,
backup['id'])
@@ -85,9 +85,8 @@
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)
- ['backup'])
+ backup = (self.backups_adm_client.create_backup(
+ volume_id=self.volume['id'], name=backup_name)['backup'])
self.addCleanup(self._delete_backup, backup['id'])
self.assertEqual(backup_name, backup['name'])
self.backups_adm_client.wait_for_backup_status(backup['id'],
diff --git a/tempest/api_schema/response/compute/v2_1/floating_ips.py b/tempest/api_schema/response/compute/v2_1/floating_ips.py
deleted file mode 100644
index 3551681..0000000
--- a/tempest/api_schema/response/compute/v2_1/floating_ips.py
+++ /dev/null
@@ -1,148 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api_schema.response.compute.v2_1 import parameter_types
-
-common_floating_ip_info = {
- 'type': 'object',
- 'properties': {
- # NOTE: Now the type of 'id' is integer, but
- # here allows 'string' also because we will be
- # able to change it to 'uuid' in the future.
- 'id': {'type': ['integer', 'string']},
- 'pool': {'type': ['string', 'null']},
- 'instance_id': {'type': ['string', 'null']},
- 'ip': parameter_types.ip_address,
- 'fixed_ip': parameter_types.ip_address
- },
- 'additionalProperties': False,
- 'required': ['id', 'pool', 'instance_id',
- 'ip', 'fixed_ip'],
-
-}
-list_floating_ips = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'floating_ips': {
- 'type': 'array',
- 'items': common_floating_ip_info
- },
- },
- 'additionalProperties': False,
- 'required': ['floating_ips'],
- }
-}
-
-create_get_floating_ip = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'floating_ip': common_floating_ip_info
- },
- 'additionalProperties': False,
- 'required': ['floating_ip'],
- }
-}
-
-list_floating_ip_pools = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'floating_ip_pools': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'name': {'type': 'string'}
- },
- 'additionalProperties': False,
- 'required': ['name'],
- }
- }
- },
- 'additionalProperties': False,
- 'required': ['floating_ip_pools'],
- }
-}
-
-add_remove_floating_ip = {
- 'status_code': [202]
-}
-
-create_floating_ips_bulk = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'floating_ips_bulk_create': {
- 'type': 'object',
- 'properties': {
- 'interface': {'type': ['string', 'null']},
- 'ip_range': {'type': 'string'},
- 'pool': {'type': ['string', 'null']},
- },
- 'additionalProperties': False,
- 'required': ['interface', 'ip_range', 'pool'],
- }
- },
- 'additionalProperties': False,
- 'required': ['floating_ips_bulk_create'],
- }
-}
-
-delete_floating_ips_bulk = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'floating_ips_bulk_delete': {'type': 'string'}
- },
- 'additionalProperties': False,
- 'required': ['floating_ips_bulk_delete'],
- }
-}
-
-list_floating_ips_bulk = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'floating_ip_info': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- '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': 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',
- 'pool', 'project_id'],
- }
- }
- },
- 'additionalProperties': False,
- 'required': ['floating_ip_info'],
- }
-}
diff --git a/tempest/api_schema/response/compute/v2_1/interfaces.py b/tempest/api_schema/response/compute/v2_1/interfaces.py
deleted file mode 100644
index 130775b..0000000
--- a/tempest/api_schema/response/compute/v2_1/interfaces.py
+++ /dev/null
@@ -1,73 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api_schema.response.compute.v2_1 import parameter_types
-
-interface_common_info = {
- 'type': 'object',
- 'properties': {
- 'port_state': {'type': 'string'},
- 'fixed_ips': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'subnet_id': {
- 'type': 'string',
- 'format': 'uuid'
- },
- 'ip_address': parameter_types.ip_address
- },
- 'additionalProperties': False,
- 'required': ['subnet_id', 'ip_address']
- }
- },
- 'port_id': {'type': 'string', 'format': 'uuid'},
- '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']
-}
-
-get_create_interfaces = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'interfaceAttachment': interface_common_info
- },
- 'additionalProperties': False,
- 'required': ['interfaceAttachment']
- }
-}
-
-list_interfaces = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'interfaceAttachments': {
- 'type': 'array',
- 'items': interface_common_info
- }
- },
- 'additionalProperties': False,
- 'required': ['interfaceAttachments']
- }
-}
-
-delete_interface = {
- 'status_code': [202]
-}
diff --git a/tempest/api_schema/response/compute/v2_1/security_groups.py b/tempest/api_schema/response/compute/v2_1/security_groups.py
deleted file mode 100644
index 5ed5a5c..0000000
--- a/tempest/api_schema/response/compute/v2_1/security_groups.py
+++ /dev/null
@@ -1,113 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-common_security_group_rule = {
- 'from_port': {'type': ['integer', 'null']},
- 'to_port': {'type': ['integer', 'null']},
- 'group': {
- 'type': 'object',
- '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.
- 'parent_group_id': {'type': ['string', 'integer', 'null']},
- 'ip_range': {
- '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'.
- },
- 'id': {'type': ['string', 'integer']}
-}
-
-common_security_group = {
- 'type': 'object',
- 'properties': {
- 'id': {'type': ['integer', 'string']},
- 'name': {'type': 'string'},
- 'tenant_id': {'type': 'string'},
- 'rules': {
- 'type': 'array',
- 'items': {
- 'type': ['object', 'null'],
- 'properties': common_security_group_rule,
- 'additionalProperties': False,
- }
- },
- 'description': {'type': 'string'},
- },
- 'additionalProperties': False,
- 'required': ['id', 'name', 'tenant_id', 'rules', 'description'],
-}
-
-list_security_groups = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'security_groups': {
- 'type': 'array',
- 'items': common_security_group
- }
- },
- 'additionalProperties': False,
- 'required': ['security_groups']
- }
-}
-
-get_security_group = create_security_group = update_security_group = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'security_group': common_security_group
- },
- 'additionalProperties': False,
- 'required': ['security_group']
- }
-}
-
-delete_security_group = {
- 'status_code': [202]
-}
-
-create_security_group_rule = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- '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']
- }
-}
-
-delete_security_group_rule = {
- 'status_code': [202]
-}
diff --git a/tempest/api_schema/response/compute/v2_1/volumes.py b/tempest/api_schema/response/compute/v2_1/volumes.py
deleted file mode 100644
index bb34acb..0000000
--- a/tempest/api_schema/response/compute/v2_1/volumes.py
+++ /dev/null
@@ -1,120 +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.
-
-create_get_volume = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'volume': {
- 'type': 'object',
- 'properties': {
- 'id': {'type': 'string'},
- 'status': {'type': 'string'},
- 'displayName': {'type': ['string', 'null']},
- 'availabilityZone': {'type': 'string'},
- 'createdAt': {'type': 'string'},
- 'displayDescription': {'type': ['string', 'null']},
- 'volumeType': {'type': ['string', 'null']},
- 'snapshotId': {'type': ['string', 'null']},
- 'metadata': {'type': 'object'},
- 'size': {'type': 'integer'},
- 'attachments': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'id': {'type': 'string'},
- '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
- # of 'attachments' cannot defined as 'required'.
- # If it would come as empty array "[]" then,
- # those elements can be defined as 'required'.
- }
- }
- },
- 'additionalProperties': False,
- 'required': ['id', 'status', 'displayName', 'availabilityZone',
- 'createdAt', 'displayDescription', 'volumeType',
- 'snapshotId', 'metadata', 'size', 'attachments']
- }
- },
- 'additionalProperties': False,
- 'required': ['volume']
- }
-}
-
-list_volumes = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'volumes': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'id': {'type': 'string'},
- 'status': {'type': 'string'},
- 'displayName': {'type': ['string', 'null']},
- 'availabilityZone': {'type': 'string'},
- 'createdAt': {'type': 'string'},
- 'displayDescription': {'type': ['string', 'null']},
- 'volumeType': {'type': ['string', 'null']},
- 'snapshotId': {'type': ['string', 'null']},
- 'metadata': {'type': 'object'},
- 'size': {'type': 'integer'},
- 'attachments': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'id': {'type': 'string'},
- '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
- # of 'attachments' cannot defined as 'required'
- # If it would come as empty array "[]" then,
- # those elements can be defined as 'required'.
- }
- }
- },
- 'additionalProperties': False,
- 'required': ['id', 'status', 'displayName',
- 'availabilityZone', 'createdAt',
- 'displayDescription', 'volumeType',
- 'snapshotId', 'metadata', 'size',
- 'attachments']
- }
- }
- },
- 'additionalProperties': False,
- 'required': ['volumes']
- }
-}
-
-delete_volume = {
- 'status_code': [202]
-}
diff --git a/tempest/clients.py b/tempest/clients.py
index 24cb721..35838a1 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -32,6 +32,8 @@
FloatingIPPoolsClient
from tempest_lib.services.compute.floating_ips_bulk_client import \
FloatingIPsBulkClient
+from tempest_lib.services.compute.floating_ips_client import \
+ FloatingIPsClient as ComputeFloatingIPsClient
from tempest_lib.services.compute.hosts_client import HostsClient
from tempest_lib.services.compute.hypervisor_client import \
HypervisorClient
@@ -39,6 +41,7 @@
as ComputeImagesClient
from tempest_lib.services.compute.instance_usage_audit_log_client import \
InstanceUsagesAuditLogClient
+from tempest_lib.services.compute.interfaces_client import InterfacesClient
from tempest_lib.services.compute.limits_client import LimitsClient
from tempest_lib.services.compute.migrations_client import MigrationsClient
from tempest_lib.services.compute.networks_client import NetworksClient \
@@ -48,8 +51,12 @@
from tempest_lib.services.compute.quotas_client import QuotasClient
from tempest_lib.services.compute.security_group_default_rules_client import \
SecurityGroupDefaultRulesClient
+from tempest_lib.services.compute.security_group_rules_client import \
+ SecurityGroupRulesClient
from tempest_lib.services.compute.security_groups_client import \
- SecurityGroupsClient
+ SecurityGroupsClient as ComputeSecurityGroupsClient
+from tempest_lib.services.compute.server_groups_client import \
+ ServerGroupsClient
from tempest_lib.services.compute.services_client import ServicesClient
from tempest_lib.services.compute.snapshots_client import \
SnapshotsClient as ComputeSnapshotsClient
@@ -58,6 +65,8 @@
from tempest_lib.services.compute.tenant_usages_client import \
TenantUsagesClient
from tempest_lib.services.compute.versions_client import VersionsClient
+from tempest_lib.services.compute.volumes_client import \
+ VolumesClient as ComputeVolumesClient
from tempest_lib.services.identity.v2.token_client import TokenClient
from tempest_lib.services.identity.v3.token_client import V3TokenClient
@@ -67,19 +76,8 @@
from tempest import manager
from tempest.services.baremetal.v1.json.baremetal_client import \
BaremetalClient
-from tempest.services import botoclients
-from tempest.services.compute.json.floating_ips_client import \
- FloatingIPsClient as ComputeFloatingIPsClient
-from tempest.services.compute.json.interfaces_client import \
- InterfacesClient
from tempest.services.compute.json.keypairs_client import KeyPairsClient
-from tempest.services.compute.json.security_group_rules_client import \
- SecurityGroupRulesClient
-from tempest.services.compute.json.server_groups_client import \
- ServerGroupsClient
from tempest.services.compute.json.servers_client import ServersClient
-from tempest.services.compute.json.volumes_client import \
- VolumesClient as ComputeVolumesClient
from tempest.services.data_processing.v1_1.data_processing_client import \
DataProcessingClient
from tempest.services.database.json.flavors_client import \
@@ -90,6 +88,10 @@
DatabaseVersionsClient
from tempest.services.identity.v2.json.identity_client import \
IdentityClient
+from tempest.services.identity.v2.json.roles_client import \
+ RolesClient
+from tempest.services.identity.v2.json.tenants_client import \
+ TenantsClient
from tempest.services.identity.v3.json.credentials_client import \
CredentialsClient as CredentialsV3Client
from tempest.services.identity.v3.json.endpoints_client import \
@@ -101,18 +103,22 @@
PolicyClient as PolicyV3Client
from tempest.services.identity.v3.json.region_client import \
RegionClient as RegionV3Client
-from tempest.services.identity.v3.json.service_client import \
- ServiceClient as ServiceV3Client
+from tempest.services.identity.v3.json.services_client import \
+ ServicesClient as IdentityServicesV3Client
from tempest.services.image.v1.json.images_client import ImagesClient
from tempest.services.image.v2.json.images_client import ImagesClientV2
from tempest.services.messaging.json.messaging_client import \
MessagingClient
from tempest.services.network.json.floating_ips_client import FloatingIPsClient
+from tempest.services.network.json.metering_label_rules_client import \
+ MeteringLabelRulesClient
from tempest.services.network.json.metering_labels_client import \
MeteringLabelsClient
from tempest.services.network.json.network_client import NetworkClient
from tempest.services.network.json.networks_client import NetworksClient
from tempest.services.network.json.ports_client import PortsClient
+from tempest.services.network.json.quotas_client import QuotasClient \
+ as NetworkQuotasClient
from tempest.services.network.json.subnets_client import SubnetsClient
from tempest.services.object_storage.account_client import AccountClient
from tempest.services.object_storage.container_client import ContainerClient
@@ -123,38 +129,41 @@
from tempest.services.telemetry.json.telemetry_client import \
TelemetryClient
from tempest.services.volume.v1.json.admin.hosts_client import \
- VolumeHostsClient
+ HostsClient as VolumeHostsClient
from tempest.services.volume.v1.json.admin.quotas_client import \
- VolumeQuotasClient
+ QuotasClient as VolumeQuotasClient
from tempest.services.volume.v1.json.admin.services_client import \
- VolumesServicesClient
+ ServicesClient as VolumeServicesClient
from tempest.services.volume.v1.json.admin.types_client import \
- VolumeTypesClient
+ TypesClient as VolumeTypesClient
from tempest.services.volume.v1.json.availability_zone_client import \
- VolumeAvailabilityZoneClient
+ AvailabilityZoneClient as VolumeAvailabilityZoneClient
from tempest.services.volume.v1.json.backups_client import BackupsClient
from tempest.services.volume.v1.json.extensions_client import \
- ExtensionsClient as VolumeExtensionClient
+ ExtensionsClient as VolumeExtensionsClient
from tempest.services.volume.v1.json.qos_client import QosSpecsClient
from tempest.services.volume.v1.json.snapshots_client import SnapshotsClient
from tempest.services.volume.v1.json.volumes_client import VolumesClient
from tempest.services.volume.v2.json.admin.hosts_client import \
- VolumeHostsV2Client
+ HostsClient as VolumeHostsV2Client
from tempest.services.volume.v2.json.admin.quotas_client import \
- VolumeQuotasV2Client
+ QuotasClient as VolumeQuotasV2Client
from tempest.services.volume.v2.json.admin.services_client import \
- VolumesServicesV2Client
+ ServicesClient as VolumeServicesV2Client
from tempest.services.volume.v2.json.admin.types_client import \
- VolumeTypesV2Client
+ TypesClient as VolumeTypesV2Client
from tempest.services.volume.v2.json.availability_zone_client import \
- VolumeV2AvailabilityZoneClient
-from tempest.services.volume.v2.json.backups_client import BackupsClientV2
+ AvailabilityZoneClient as VolumeAvailabilityZoneV2Client
+from tempest.services.volume.v2.json.backups_client import \
+ BackupsClient as BackupsV2Client
from tempest.services.volume.v2.json.extensions_client import \
- ExtensionsV2Client as VolumeV2ExtensionClient
-from tempest.services.volume.v2.json.qos_client import QosSpecsV2Client
+ ExtensionsClient as VolumeExtensionsV2Client
+from tempest.services.volume.v2.json.qos_client import \
+ QosSpecsClient as QosSpecsV2Client
from tempest.services.volume.v2.json.snapshots_client import \
- SnapshotsV2Client
-from tempest.services.volume.v2.json.volumes_client import VolumesV2Client
+ SnapshotsClient as SnapshotsV2Client
+from tempest.services.volume.v2.json.volumes_client import \
+ VolumesClient as VolumesV2Client
CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -225,6 +234,14 @@
build_interval=CONF.network.build_interval,
build_timeout=CONF.network.build_timeout,
**self.default_params)
+ self.network_quotas_client = NetworkQuotasClient(
+ self.auth_provider,
+ CONF.network.catalog_type,
+ CONF.network.region or CONF.identity.region,
+ endpoint_type=CONF.network.endpoint_type,
+ build_interval=CONF.network.build_interval,
+ build_timeout=CONF.network.build_timeout,
+ **self.default_params)
self.floating_ips_client = FloatingIPsClient(
self.auth_provider,
CONF.network.catalog_type,
@@ -241,6 +258,14 @@
build_interval=CONF.network.build_interval,
build_timeout=CONF.network.build_timeout,
**self.default_params)
+ self.metering_label_rules_client = MeteringLabelRulesClient(
+ self.auth_provider,
+ CONF.network.catalog_type,
+ CONF.network.region or CONF.identity.region,
+ endpoint_type=CONF.network.endpoint_type,
+ build_interval=CONF.network.build_interval,
+ build_timeout=CONF.network.build_timeout,
+ **self.default_params)
self.messaging_client = MessagingClient(
self.auth_provider,
CONF.messaging.catalog_type,
@@ -294,15 +319,6 @@
self.negative_client = negative_rest_client.NegativeRestClient(
self.auth_provider, service, **self.default_params)
- # Generating EC2 credentials in tempest is only supported
- # with identity v2
- if CONF.identity_feature_enabled.api_v2 and \
- CONF.identity.auth_version == 'v2':
- # EC2 and S3 clients, if used, will check configured AWS
- # credentials and generate new ones if needed
- self.ec2api_client = botoclients.APIClientEC2(self.identity_client)
- self.s3_client = botoclients.ObjectClientS3(self.identity_client)
-
def _set_compute_clients(self):
params = {
'service': CONF.compute.catalog_type,
@@ -346,7 +362,7 @@
self.auth_provider, **params)
self.security_group_rules_client = SecurityGroupRulesClient(
self.auth_provider, **params)
- self.security_groups_client = SecurityGroupsClient(
+ self.compute_security_groups_client = ComputeSecurityGroupsClient(
self.auth_provider, **params)
self.interfaces_client = InterfacesClient(self.auth_provider,
**params)
@@ -411,12 +427,20 @@
# Client uses admin endpoint type of Keystone API v2
self.identity_client = IdentityClient(self.auth_provider,
**params_v2_admin)
+ self.tenants_client = TenantsClient(self.auth_provider,
+ **params_v2_admin)
+ self.roles_client = RolesClient(self.auth_provider,
+ **params_v2_admin)
params_v2_public = params.copy()
params_v2_public['endpoint_type'] = (
CONF.identity.v2_public_endpoint_type)
# Client uses public endpoint type of Keystone API v2
self.identity_public_client = IdentityClient(self.auth_provider,
**params_v2_public)
+ self.tenants_public_client = TenantsClient(self.auth_provider,
+ **params_v2_public)
+ self.roles_public_client = RolesClient(self.auth_provider,
+ **params_v2_public)
params_v3 = params.copy()
params_v3['endpoint_type'] = CONF.identity.v3_endpoint_type
# Clients below use the endpoint type of Keystone API v3
@@ -424,7 +448,8 @@
**params_v3)
self.endpoints_client = EndPointV3Client(self.auth_provider,
**params_v3)
- self.service_client = ServiceV3Client(self.auth_provider, **params_v3)
+ self.identity_services_client = IdentityServicesV3Client(
+ self.auth_provider, **params_v3)
self.policy_client = PolicyV3Client(self.auth_provider, **params_v3)
self.region_client = RegionV3Client(self.auth_provider, **params_v3)
self.credentials_client = CredentialsV3Client(self.auth_provider,
@@ -462,10 +487,12 @@
**params)
self.volume_qos_v2_client = QosSpecsV2Client(
self.auth_provider, **params)
- self.volume_services_v2_client = VolumesServicesV2Client(
+ self.volume_services_client = VolumeServicesClient(
+ self.auth_provider, **params)
+ self.volume_services_v2_client = VolumeServicesV2Client(
self.auth_provider, **params)
self.backups_client = BackupsClient(self.auth_provider, **params)
- self.backups_v2_client = BackupsClientV2(self.auth_provider,
+ self.backups_v2_client = BackupsV2Client(self.auth_provider,
**params)
self.snapshots_client = SnapshotsClient(self.auth_provider,
**params)
@@ -479,7 +506,7 @@
**params)
self.volume_types_client = VolumeTypesClient(self.auth_provider,
**params)
- self.volume_services_client = VolumesServicesClient(
+ self.volume_types_v2_client = VolumeTypesV2Client(
self.auth_provider, **params)
self.volume_hosts_client = VolumeHostsClient(self.auth_provider,
**params)
@@ -489,16 +516,14 @@
**params)
self.volume_quotas_v2_client = VolumeQuotasV2Client(self.auth_provider,
**params)
- self.volumes_extension_client = VolumeExtensionClient(
+ self.volumes_extension_client = VolumeExtensionsClient(
self.auth_provider, **params)
- self.volumes_v2_extension_client = VolumeV2ExtensionClient(
+ self.volumes_v2_extension_client = VolumeExtensionsV2Client(
self.auth_provider, **params)
self.volume_availability_zone_client = \
VolumeAvailabilityZoneClient(self.auth_provider, **params)
self.volume_v2_availability_zone_client = \
- VolumeV2AvailabilityZoneClient(self.auth_provider, **params)
- self.volume_types_v2_client = VolumeTypesV2Client(
- self.auth_provider, **params)
+ VolumeAvailabilityZoneV2Client(self.auth_provider, **params)
def _set_object_storage_clients(self):
params = {
diff --git a/tempest/cmd/account_generator.py b/tempest/cmd/account_generator.py
index 613fb26..b90ee04 100755
--- a/tempest/cmd/account_generator.py
+++ b/tempest/cmd/account_generator.py
@@ -93,6 +93,8 @@
from tempest import config
from tempest import exceptions as exc
from tempest.services.identity.v2.json import identity_client
+from tempest.services.identity.v2.json import roles_client
+from tempest.services.identity.v2.json import tenants_client
from tempest.services.network.json import network_client
from tempest.services.network.json import networks_client
from tempest.services.network.json import subnets_client
@@ -138,6 +140,20 @@
endpoint_type='adminURL',
**params
)
+ tenants_admin = tenants_client.TenantsClient(
+ _auth,
+ CONF.identity.catalog_type,
+ CONF.identity.region,
+ endpoint_type='adminURL',
+ **params
+ )
+ roles_admin = roles_client.RolesClient(
+ _auth,
+ CONF.identity.catalog_type,
+ CONF.identity.region,
+ endpoint_type='adminURL',
+ **params
+ )
network_admin = None
networks_admin = None
subnets_admin = None
@@ -163,14 +179,14 @@
CONF.network.region or CONF.identity.region,
endpoint_type='adminURL',
**params)
- return (identity_admin, neutron_iso_networks, network_admin,
- networks_admin, subnets_admin)
+ return (identity_admin, tenants_admin, roles_admin, neutron_iso_networks,
+ network_admin, networks_admin, subnets_admin)
def create_resources(opts, resources):
- (identity_admin, neutron_iso_networks,
+ (identity_admin, tenants_admin, roles_admin, neutron_iso_networks,
network_admin, networks_admin, subnets_admin) = get_admin_clients(opts)
- roles = identity_admin.list_roles()['roles']
+ roles = roles_admin.list_roles()['roles']
for u in resources['users']:
u['role_ids'] = []
for r in u.get('roles', ()):
@@ -180,22 +196,22 @@
msg = "Role: %s doesn't exist" % r
raise exc.InvalidConfiguration(msg)
u['role_ids'] += [role['id']]
- existing = [x['name'] for x in identity_admin.list_tenants()['tenants']]
+ existing = [x['name'] for x in tenants_admin.list_tenants()['tenants']]
for tenant in resources['tenants']:
if tenant not in existing:
- identity_admin.create_tenant(tenant)
+ tenants_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 = identity.get_tenant_by_name(identity_admin, u['tenant'])
+ tenant = identity.get_tenant_by_name(tenants_admin, u['tenant'])
except tempest_lib.exceptions.NotFound:
LOG.error("Tenant: %s - not found" % u['tenant'])
continue
while True:
try:
- identity.get_user_by_username(identity_admin,
+ identity.get_user_by_username(tenants_admin,
tenant['id'], u['name'])
except tempest_lib.exceptions.NotFound:
identity_admin.create_user(
@@ -211,7 +227,7 @@
LOG.info('Users created')
if neutron_iso_networks:
for u in resources['users']:
- tenant = identity.get_tenant_by_name(identity_admin, u['tenant'])
+ tenant = identity.get_tenant_by_name(tenants_admin, u['tenant'])
network_name, router_name = create_network_resources(
network_admin, networks_admin, subnets_admin, tenant['id'],
u['name'])
@@ -220,19 +236,19 @@
LOG.info('Networks created')
for u in resources['users']:
try:
- tenant = identity.get_tenant_by_name(identity_admin, u['tenant'])
+ tenant = identity.get_tenant_by_name(tenants_admin, u['tenant'])
except tempest_lib.exceptions.NotFound:
LOG.error("Tenant: %s - not found" % u['tenant'])
continue
try:
- user = identity.get_user_by_username(identity_admin,
+ user = identity.get_user_by_username(tenants_admin,
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:
- identity_admin.assign_user_role(tenant['id'], user['id'], r)
+ roles_admin.assign_user_role(tenant['id'], user['id'], r)
except tempest_lib.exceptions.Conflict:
# don't care if it's already assigned
pass
@@ -341,7 +357,7 @@
resources['users'].append({
'tenant': tenant,
'name': user,
- 'pass': data_utils.rand_name(),
+ 'pass': data_utils.rand_password(),
'prefix': user_group['prefix'],
'roles': user_group['roles']
})
diff --git a/tempest/cmd/cleanup.py b/tempest/cmd/cleanup.py
index 1c8ddcb..b79bff4 100644
--- a/tempest/cmd/cleanup.py
+++ b/tempest/cmd/cleanup.py
@@ -176,17 +176,18 @@
svc.run()
def _init_admin_ids(self):
- id_cl = self.admin_mgr.identity_client
+ tn_cl = self.admin_mgr.tenants_client
+ rl_cl = self.admin_mgr.roles_client
- tenant = identity.get_tenant_by_name(id_cl,
+ tenant = identity.get_tenant_by_name(tn_cl,
CONF.auth.admin_tenant_name)
self.admin_tenant_id = tenant['id']
- user = identity.get_user_by_username(id_cl, self.admin_tenant_id,
+ user = identity.get_user_by_username(tn_cl, self.admin_tenant_id,
CONF.auth.admin_username)
self.admin_id = user['id']
- roles = id_cl.list_roles()['roles']
+ roles = rl_cl.list_roles()['roles']
for role in roles:
if role['name'] == CONF.identity.admin_role:
self.admin_role_id = role['id']
@@ -221,8 +222,9 @@
def _add_admin(self, tenant_id):
id_cl = self.admin_mgr.identity_client
+ rl_cl = self.admin_mgr.roles_client
needs_role = True
- roles = id_cl.list_user_roles(tenant_id, self.admin_id)['roles']
+ roles = rl_cl.list_user_roles(tenant_id, self.admin_id)['roles']
for role in roles:
if role['id'] == self.admin_role_id:
needs_role = False
@@ -247,9 +249,9 @@
"exists, exception: %s" % ex)
def _tenant_exists(self, tenant_id):
- id_cl = self.admin_mgr.identity_client
+ tn_cl = self.admin_mgr.tenants_client
try:
- t = id_cl.show_tenant(tenant_id)
+ t = tn_cl.show_tenant(tenant_id)
LOG.debug("Tenant is: %s" % str(t))
return True
except Exception as ex:
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index f2dd7af..c2f3885 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -85,10 +85,10 @@
def _get_network_id(net_name, tenant_name):
am = credentials.AdminManager()
net_cl = am.networks_client
- id_cl = am.identity_client
+ tn_cl = am.tenants_client
networks = net_cl.list_networks()
- tenant = identity.get_tenant_by_name(id_cl, tenant_name)
+ tenant = identity.get_tenant_by_name(tn_cl, tenant_name)
t_id = tenant['id']
n_id = None
for net in networks['networks']:
@@ -269,7 +269,7 @@
class SecurityGroupService(BaseService):
def __init__(self, manager, **kwargs):
super(SecurityGroupService, self).__init__(kwargs)
- self.client = manager.security_groups_client
+ self.client = manager.compute_security_groups_client
def list(self):
client = self.client
@@ -388,6 +388,7 @@
self.ports_client = manager.ports_client
self.floating_ips_client = manager.floating_ips_client
self.metering_labels_client = manager.metering_labels_client
+ self.metering_label_rules_client = manager.metering_label_rules_client
def _filter_by_conf_networks(self, item_list):
if not item_list or not all(('network_id' in i for i in item_list)):
@@ -577,7 +578,7 @@
class NetworkMeteringLabelRuleService(NetworkService):
def list(self):
- client = self.client
+ client = self.metering_label_rules_client
rules = client.list_metering_label_rules()
rules = rules['metering_label_rules']
rules = self._filter_by_tenant_id(rules)
@@ -585,7 +586,7 @@
return rules
def delete(self):
- client = self.client
+ client = self.metering_label_rules_client
rules = self.list()
for rule in rules:
try:
@@ -854,12 +855,15 @@
self.data['users'][user['id']] = user['name']
-class RoleService(IdentityService):
+class RoleService(BaseService):
+
+ def __init__(self, manager, **kwargs):
+ super(RoleService, self).__init__(kwargs)
+ self.client = manager.roles_client
def list(self):
- client = self.client
try:
- roles = client.list_roles()['roles']
+ roles = self.client.list_roles()['roles']
# reconcile roles with saved state and never list admin role
if not self.is_save_state:
roles = [role for role in roles if
@@ -873,11 +877,10 @@
return []
def delete(self):
- client = self.client
roles = self.list()
for role in roles:
try:
- client.delete_role(role['id'])
+ self.client.delete_role(role['id'])
except Exception:
LOG.exception("Delete Role exception.")
@@ -892,11 +895,14 @@
self.data['roles'][role['id']] = role['name']
-class TenantService(IdentityService):
+class TenantService(BaseService):
+
+ def __init__(self, manager, **kwargs):
+ super(TenantService, self).__init__(kwargs)
+ self.client = manager.tenants_client
def list(self):
- client = self.client
- tenants = client.list_tenants()['tenants']
+ tenants = self.client.list_tenants()['tenants']
if not self.is_save_state:
tenants = [tenant for tenant in tenants if (tenant['id']
not in self.saved_state_json['tenants'].keys()
@@ -910,11 +916,10 @@
return tenants
def delete(self):
- client = self.client
tenants = self.list()
for tenant in tenants:
try:
- client.delete_tenant(tenant['id'])
+ self.client.delete_tenant(tenant['id'])
except Exception:
LOG.exception("Delete Tenant exception.")
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index c5e4a7e..c0c645c 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -118,16 +118,18 @@
from tempest_lib import auth
from tempest_lib import exceptions as lib_exc
from tempest_lib.services.compute import flavors_client
+from tempest_lib.services.compute import floating_ips_client
+from tempest_lib.services.compute import security_group_rules_client
from tempest_lib.services.compute import security_groups_client
import yaml
from tempest.common import identity
from tempest.common import waiters
from tempest import config
-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 servers_client
from tempest.services.identity.v2.json import identity_client
+from tempest.services.identity.v2.json import roles_client
+from tempest.services.identity.v2.json import tenants_client
from tempest.services.image.v2.json import images_client
from tempest.services.network.json import network_client
from tempest.services.network.json import subnets_client
@@ -199,6 +201,18 @@
CONF.identity.region,
endpoint_type='adminURL',
**default_params_with_timeout_values)
+ self.tenants = tenants_client.TenantsClient(
+ _auth,
+ CONF.identity.catalog_type,
+ CONF.identity.region,
+ endpoint_type='adminURL',
+ **default_params_with_timeout_values)
+ self.roles = roles_client.RolesClient(
+ _auth,
+ CONF.identity.catalog_type,
+ CONF.identity.region,
+ endpoint_type='adminURL',
+ **default_params_with_timeout_values)
self.servers = servers_client.ServersClient(_auth,
**compute_params)
self.flavors = flavors_client.FlavorsClient(_auth,
@@ -291,11 +305,11 @@
Don't create the tenants if they already exist.
"""
admin = keystone_admin()
- body = admin.identity.list_tenants()['tenants']
+ body = admin.tenants.list_tenants()['tenants']
existing = [x['name'] for x in body]
for tenant in tenants:
if tenant not in existing:
- admin.identity.create_tenant(tenant)['tenant']
+ admin.tenants.create_tenant(tenant)['tenant']
else:
LOG.warn("Tenant '%s' already exists in this environment" % tenant)
@@ -303,8 +317,8 @@
def destroy_tenants(tenants):
admin = keystone_admin()
for tenant in tenants:
- tenant_id = identity.get_tenant_by_name(admin.identity, tenant)['id']
- admin.identity.delete_tenant(tenant_id)
+ tenant_id = identity.get_tenant_by_name(admin.tenant, tenant)['id']
+ admin.tenants.delete_tenant(tenant_id)
##############
#
@@ -332,11 +346,11 @@
def _assign_swift_role(user, swift_role):
admin = keystone_admin()
- roles = admin.identity.list_roles()
+ roles = admin.roles.list_roles()
role = next(r for r in roles if r['name'] == swift_role)
LOG.debug(USERS[user])
try:
- admin.identity.assign_user_role(
+ admin.roles.assign_user_role(
USERS[user]['tenant_id'],
USERS[user]['id'],
role['id'])
@@ -355,7 +369,7 @@
admin = keystone_admin()
for u in users:
try:
- tenant = identity.get_tenant_by_name(admin.identity, u['tenant'])
+ tenant = identity.get_tenant_by_name(admin.tenants, u['tenant'])
except lib_exc.NotFound:
LOG.error("Tenant: %s - not found" % u['tenant'])
continue
@@ -374,7 +388,7 @@
def destroy_users(users):
admin = keystone_admin()
for user in users:
- tenant_id = identity.get_tenant_by_name(admin.identity,
+ tenant_id = identity.get_tenant_by_name(admin.tenants,
user['tenant'])['id']
user_id = identity.get_user_by_username(admin.identity,
tenant_id, user['name'])['id']
@@ -386,7 +400,7 @@
LOG.info("Collecting users")
admin = keystone_admin()
for u in users:
- tenant = identity.get_tenant_by_name(admin.identity, u['tenant'])
+ tenant = identity.get_tenant_by_name(admin.tenants, u['tenant'])
u['tenant_id'] = tenant['id']
USERS[u['name']] = u
body = identity.get_user_by_username(admin.identity,
@@ -485,24 +499,26 @@
for network_name, body in found['addresses'].items():
for addr in body:
ip = addr['addr']
- # If floatingip_for_ssh is at True, it's assumed
- # you want to use the floating IP to reach the server,
- # fallback to fixed IP, then other type.
+ # Use floating IP, fixed IP or other type to
+ # reach the server.
# This is useful in multi-node environment.
- if CONF.compute.use_floatingip_for_ssh:
+ if CONF.validation.connect_method == 'floating':
if addr.get('OS-EXT-IPS:type',
'floating') == 'floating':
self._ping_ip(ip, 60)
_floating_is_alive = True
- elif addr.get('OS-EXT-IPS:type', 'fixed') == 'fixed':
- namespace = _get_router_namespace(client,
- network_name)
- self._ping_ip(ip, 60, namespace)
+ elif CONF.validation.connect_method == 'fixed':
+ if addr.get('OS-EXT-IPS:type',
+ 'fixed') == 'fixed':
+ namespace = _get_router_namespace(client,
+ network_name)
+ self._ping_ip(ip, 60, namespace)
else:
self._ping_ip(ip, 60)
- # if floatingip_for_ssh is at True, validate found a
- # floating IP and ping worked.
- if CONF.compute.use_floatingip_for_ssh:
+ # If CONF.validation.connect_method is floating, validate
+ # that the floating IP is attached to the server and the
+ # the server is pingable.
+ if CONF.validation.connect_method == 'floating':
self.assertTrue(_floating_is_alive,
"Server %s has no floating IP." %
server['name'])
@@ -895,8 +911,8 @@
client.servers.wait_for_server_status(server_id, 'ACTIVE')
# create security group(s) after server spawning
for secgroup in server['secgroups']:
- client.servers.add_security_group(server_id, secgroup)
- if CONF.compute.use_floatingip_for_ssh:
+ client.servers.add_security_group(server_id, name=secgroup)
+ if CONF.validation.connect_method == 'floating':
floating_ip_pool = server.get('floating_ip_pool')
floating_ip = client.floating_ips.create_floating_ip(
pool_name=floating_ip_pool)['floating_ip']
diff --git a/tempest/cmd/run_stress.py b/tempest/cmd/run_stress.py
old mode 100755
new mode 100644
index 80f1b85..5c6f200
--- a/tempest/cmd/run_stress.py
+++ b/tempest/cmd/run_stress.py
@@ -23,6 +23,7 @@
# unittest in python 2.6 does not contain loader, so uses unittest2
from unittest2 import loader
+from cliff import command
from oslo_log import log as logging
from oslo_serialization import jsonutils as json
from testtools import testsuite
@@ -70,29 +71,45 @@
return tests
-parser = argparse.ArgumentParser(description='Run stress tests')
-parser.add_argument('-d', '--duration', default=300, type=int,
- help="Duration of test in secs")
-parser.add_argument('-s', '--serial', action='store_true',
- help="Trigger running tests serially")
-parser.add_argument('-S', '--stop', action='store_true',
- default=False, help="Stop on first error")
-parser.add_argument('-n', '--number', type=int,
- help="How often an action is executed for each process")
-group = parser.add_mutually_exclusive_group(required=True)
-group.add_argument('-a', '--all', action='store_true',
- help="Execute all stress tests")
-parser.add_argument('-T', '--type',
- help="Filters tests of a certain type (e.g. gate)")
-parser.add_argument('-i', '--call-inherited', action='store_true',
- default=False,
- help="Call also inherited function with stress attribute")
-group.add_argument('-t', "--tests", nargs='?',
- help="Name of the file with test description")
+class TempestRunStress(command.Command):
+
+ def get_parser(self, prog_name):
+ pa = super(TempestRunStress, self).get_parser(prog_name)
+ pa = add_arguments(pa)
+ return pa
+
+ def take_action(self, pa):
+ return action(pa)
+
+ def get_description(self):
+ return 'Run tempest stress tests'
-def main():
- ns = parser.parse_args()
+def add_arguments(parser):
+ parser.add_argument('-d', '--duration', default=300, type=int,
+ help="Duration of test in secs")
+ parser.add_argument('-s', '--serial', action='store_true',
+ help="Trigger running tests serially")
+ parser.add_argument('-S', '--stop', action='store_true',
+ default=False, help="Stop on first error")
+ parser.add_argument('-n', '--number', type=int,
+ help="How often an action is executed for each "
+ "process")
+ group = parser.add_mutually_exclusive_group(required=True)
+ group.add_argument('-a', '--all', action='store_true',
+ help="Execute all stress tests")
+ parser.add_argument('-T', '--type',
+ help="Filters tests of a certain type (e.g. gate)")
+ parser.add_argument('-i', '--call-inherited', action='store_true',
+ default=False,
+ help="Call also inherited function with stress "
+ "attribute")
+ group.add_argument('-t', "--tests", nargs='?',
+ help="Name of the file with test description")
+ return parser
+
+
+def action(ns):
result = 0
if not ns.all:
tests = json.load(open(ns.tests, 'r'))
@@ -121,6 +138,15 @@
return result
+def main():
+ LOG.warning("Deprecated: Use 'tempest run-stress' instead. "
+ "The old entrypoint will be removed in a future release.")
+ parser = argparse.ArgumentParser(description='Run stress tests')
+ pa = add_arguments(parser)
+ ns = pa.parse_args()
+ return action(ns)
+
+
if __name__ == "__main__":
try:
sys.exit(main())
diff --git a/tempest/common/api_version_request.py b/tempest/common/api_version_request.py
index 72a11ea..d8a5b56 100644
--- a/tempest/common/api_version_request.py
+++ b/tempest/common/api_version_request.py
@@ -54,6 +54,8 @@
None value should be used to create Null APIVersionRequest,
which is equal to 0.0
"""
+ # NOTE(gmann): 'version_string' as String "None" will be considered as
+ # invalid version string.
self.ver_major = 0
self.ver_minor = 0
diff --git a/tempest/common/cred_client.py b/tempest/common/cred_client.py
index 13baafb..a33732e 100644
--- a/tempest/common/cred_client.py
+++ b/tempest/common/cred_client.py
@@ -31,9 +31,14 @@
admin credentials used for generating credentials.
"""
- def __init__(self, identity_client):
+ def __init__(self, identity_client, projects_client=None,
+ roles_client=None):
# The client implies version and credentials
self.identity_client = identity_client
+ # this is temporary until the v3 project client is
+ # separated, then projects_client will become mandatory
+ self.projects_client = projects_client or identity_client
+ self.roles_client = roles_client or identity_client
def create_user(self, username, password, project, email):
user = self.identity_client.create_user(
@@ -56,7 +61,7 @@
def create_user_role(self, role_name):
if not self._check_role_exists(role_name):
- self.identity_client.create_role(role_name)
+ self.roles_client.create_role(role_name)
def assign_user_role(self, user, project, role_name):
role = self._check_role_exists(role_name)
@@ -64,8 +69,8 @@
msg = 'No "%s" role found' % role_name
raise lib_exc.NotFound(msg)
try:
- self.identity_client.assign_user_role(project['id'], user['id'],
- role['id'])
+ self.roles_client.assign_user_role(project['id'], user['id'],
+ role['id'])
except lib_exc.Conflict:
LOG.debug("Role %s already assigned on project %s for user %s" % (
role['id'], project['id'], user['id']))
@@ -85,14 +90,19 @@
self.identity_client.delete_user(user_id)
def _list_roles(self):
- roles = self.identity_client.list_roles()['roles']
+ roles = self.roles_client.list_roles()['roles']
return roles
class V2CredsClient(CredsClient):
+ def __init__(self, identity_client, projects_client, roles_client):
+ super(V2CredsClient, self).__init__(identity_client,
+ projects_client,
+ roles_client)
+
def create_project(self, name, description):
- tenant = self.identity_client.create_tenant(
+ tenant = self.projects_client.create_tenant(
name=name, description=description)['tenant']
return tenant
@@ -108,7 +118,7 @@
password=password)
def delete_project(self, project_id):
- self.identity_client.delete_tenant(project_id)
+ self.projects_client.delete_tenant(project_id)
class V3CredsClient(CredsClient):
@@ -152,8 +162,11 @@
return roles
-def get_creds_client(identity_client, project_domain_name=None):
+def get_creds_client(identity_client,
+ projects_client=None,
+ roles_client=None,
+ project_domain_name=None):
if isinstance(identity_client, v2_identity.IdentityClient):
- return V2CredsClient(identity_client)
+ return V2CredsClient(identity_client, projects_client, roles_client)
else:
return V3CredsClient(identity_client, project_domain_name)
diff --git a/tempest/common/credentials_factory.py b/tempest/common/credentials_factory.py
index 95dcafc..5d290d4 100644
--- a/tempest/common/credentials_factory.py
+++ b/tempest/common/credentials_factory.py
@@ -11,8 +11,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import os
-
from oslo_concurrency import lockutils
from oslo_log import log as logging
from tempest_lib import auth
@@ -170,8 +168,7 @@
admin_creds=admin_creds,
**_get_dynamic_provider_params())
else:
- if (CONF.auth.test_accounts_file and
- os.path.isfile(CONF.auth.test_accounts_file)):
+ if CONF.auth.test_accounts_file:
# Most params are not relevant for pre-created accounts
return preprov_creds.PreProvisionedCredentialProvider(
name=name, identity_version=identity_version,
@@ -193,8 +190,7 @@
if CONF.auth.use_dynamic_credentials:
return is_admin
# Check whether test accounts file has the admin specified or not
- elif (CONF.auth.test_accounts_file and
- os.path.isfile(CONF.auth.test_accounts_file)):
+ elif CONF.auth.test_accounts_file:
check_accounts = preprov_creds.PreProvisionedCredentialProvider(
identity_version=identity_version, name='check_admin',
**_get_preprov_provider_params())
@@ -219,8 +215,7 @@
if CONF.auth.use_dynamic_credentials:
return True
# Check whether test accounts file has the admin specified or not
- if (CONF.auth.test_accounts_file and
- os.path.isfile(CONF.auth.test_accounts_file)):
+ if CONF.auth.test_accounts_file:
check_accounts = preprov_creds.PreProvisionedCredentialProvider(
identity_version=identity_version, name='check_alt',
**_get_preprov_provider_params())
diff --git a/tempest/common/dynamic_creds.py b/tempest/common/dynamic_creds.py
index e950c3e..c52aa41 100644
--- a/tempest/common/dynamic_creds.py
+++ b/tempest/common/dynamic_creds.py
@@ -57,7 +57,9 @@
self._creds = {}
self.ports = []
self.default_admin_creds = admin_creds
- (self.identity_admin_client, self.network_admin_client,
+ (self.identity_admin_client, self.tenants_admin_client,
+ self.roles_admin_client,
+ self.network_admin_client,
self.networks_admin_client,
self.subnets_admin_client,
self.ports_admin_client) = self._get_admin_clients()
@@ -69,7 +71,10 @@
self.default_admin_creds.project_domain_name or
self.credentials_domain)
self.creds_client = cred_client.get_creds_client(
- self.identity_admin_client, self.creds_domain_name)
+ self.identity_admin_client,
+ self.tenants_admin_client,
+ self.roles_admin_client,
+ self.creds_domain_name)
def _get_admin_clients(self):
"""Returns a tuple with instances of the following admin clients
@@ -80,10 +85,11 @@
"""
os = clients.Manager(self.default_admin_creds)
if self.identity_version == 'v2':
- return (os.identity_client, os.network_client, os.networks_client,
- os.subnets_client, os.ports_client)
+ return (os.identity_client, os.tenants_client, os.roles_client,
+ os.network_client, os.networks_client, os.subnets_client,
+ os.ports_client)
else:
- return (os.identity_v3_client, os.network_client,
+ return (os.identity_v3_client, None, None, os.network_client,
os.networks_client, os.subnets_client, os.ports_client)
def _create_creds(self, suffix="", admin=False, roles=None):
diff --git a/tempest/common/preprov_creds.py b/tempest/common/preprov_creds.py
index 74cc3f0..34af31e 100644
--- a/tempest/common/preprov_creds.py
+++ b/tempest/common/preprov_creds.py
@@ -31,8 +31,13 @@
def read_accounts_yaml(path):
- with open(path, 'r') as yaml_file:
- accounts = yaml.load(yaml_file)
+ try:
+ with open(path, 'r') as yaml_file:
+ accounts = yaml.load(yaml_file)
+ except IOError:
+ raise exceptions.InvalidConfiguration(
+ 'The path for the test accounts file: %s '
+ 'could not be found' % path)
return accounts
@@ -74,7 +79,7 @@
identity_version=identity_version, name=name,
admin_role=admin_role, credentials_domain=credentials_domain)
self.test_accounts_file = test_accounts_file
- if test_accounts_file and os.path.isfile(test_accounts_file):
+ if test_accounts_file:
accounts = read_accounts_yaml(self.test_accounts_file)
self.use_default_creds = False
else:
diff --git a/tempest/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py
index 025b79f..b76c356 100644
--- a/tempest/common/utils/linux/remote_client.py
+++ b/tempest/common/utils/linux/remote_client.py
@@ -31,7 +31,7 @@
# NOTE(afazekas): It should always get an address instead of server
def __init__(self, server, username, password=None, pkey=None):
ssh_timeout = CONF.validation.ssh_timeout
- network = CONF.compute.network_for_ssh
+ network = CONF.validation.network_for_ssh
ip_version = CONF.validation.ip_version_for_ssh
connect_timeout = CONF.validation.connect_timeout
if isinstance(server, six.string_types):
@@ -51,7 +51,7 @@
def exec_command(self, cmd):
# Shell options below add more clearness on failures,
# path is extended for some non-cirros guest oses (centos7)
- cmd = CONF.compute.ssh_shell_prologue + " " + cmd
+ cmd = CONF.validation.ssh_shell_prologue + " " + cmd
LOG.debug("Remote command: %s" % cmd)
return self.ssh_client.exec_command(cmd)
@@ -73,7 +73,7 @@
return output.split()[1]
def get_number_of_vcpus(self):
- output = self.exec_command('grep -c processor /proc/cpuinfo')
+ output = self.exec_command('grep -c ^processor /proc/cpuinfo')
return int(output)
def get_partitions(self):
@@ -94,8 +94,8 @@
cmd = 'sudo sh -c "echo \\"%s\\" >/dev/console"' % message
return self.exec_command(cmd)
- def ping_host(self, host, count=CONF.compute.ping_count,
- size=CONF.compute.ping_size, nic=None):
+ def ping_host(self, host, count=CONF.validation.ping_count,
+ size=CONF.validation.ping_size, nic=None):
addr = netaddr.IPAddress(host)
cmd = 'ping6' if addr.version == 6 else 'ping'
if nic:
diff --git a/tempest/common/validation_resources.py b/tempest/common/validation_resources.py
index 1908b68..f526299 100644
--- a/tempest/common/validation_resources.py
+++ b/tempest/common/validation_resources.py
@@ -23,7 +23,7 @@
def create_ssh_security_group(os, add_rule=False):
- security_groups_client = os.security_groups_client
+ security_groups_client = os.compute_security_groups_client
security_group_rules_client = os.security_group_rules_client
sg_name = data_utils.rand_name('securitygroup-')
sg_description = data_utils.rand_name('description-')
@@ -81,7 +81,7 @@
if not has_exception:
has_exception = exc
if 'security_group' in validation_data:
- security_group_client = os.security_groups_client
+ security_group_client = os.compute_security_groups_client
sec_id = validation_data['security_group']['id']
try:
security_group_client.delete_security_group(sec_id)
diff --git a/tempest/config.py b/tempest/config.py
index 26dda2d..8f2ca4b 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -17,9 +17,10 @@
import logging as std_logging
import os
+import tempfile
+from oslo_concurrency import lockutils
from oslo_config import cfg
-
from oslo_log import log as logging
from tempest.test_discover import plugins
@@ -231,12 +232,6 @@
cfg.StrOpt('flavor_ref_alt',
default="2",
help='Valid secondary flavor to be used in tests.'),
- cfg.StrOpt('image_ssh_user',
- default="root",
- help="User name used to authenticate to an instance."),
- cfg.StrOpt('image_ssh_password',
- default="password",
- help="Password used to authenticate to an instance."),
cfg.IntOpt('build_interval',
default=1,
help="Time in seconds between build status checks."),
@@ -245,41 +240,6 @@
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',
- choices=('keypair', 'configured', 'adminpass', 'disabled'),
- help="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 password. "
- "Adminpass: use the injected adminPass. "
- "Disabled: avoid using ssh when it is an option."),
- cfg.StrOpt('ssh_connect_method',
- default='floating',
- choices=('fixed', 'floating'),
- help="How to connect to the instance? "
- "fixed: using the first ip belongs the fixed network "
- "floating: creating and using a floating ip."),
- cfg.StrOpt('ssh_user',
- default='root',
- help="User name used to authenticate to an instance."),
- cfg.IntOpt('ping_timeout',
- default=120,
- help="Timeout in seconds to wait for ping to "
- "succeed."),
- cfg.IntOpt('ping_size',
- default=56,
- help="The packet size for ping packets originating "
- "from remote linux hosts"),
- cfg.IntOpt('ping_count',
- default=1,
- help="The number of ping packets originating from remote "
- "linux hosts"),
cfg.IntOpt('ready_wait',
default=0,
help="Additional wait time for clean state, when there is "
@@ -291,13 +251,6 @@
"servers if tempest does not create a network or a "
"network is not specified elsewhere. It may be used for "
"ssh validation only if floating IPs are disabled."),
- cfg.StrOpt('network_for_ssh',
- default='public',
- help="Network used for SSH connections. Ignored if "
- "use_floatingip_for_ssh=true or run_validation=false."),
- cfg.BoolOpt('use_floatingip_for_ssh',
- default=True,
- help="Does SSH use Floating IPs?"),
cfg.StrOpt('catalog_type',
default='compute',
help="Catalog type of the Compute service."),
@@ -323,12 +276,6 @@
'when shelved. This time should be the same as the time '
'of nova.conf, and some tests will run for as long as the '
'time.'),
- cfg.StrOpt('floating_ip_range',
- default='10.0.0.0/29',
- help='Unallocated floating IP range, which will be used to '
- 'test the floating IP bulk feature for CRUD operation. '
- 'This block must not overlap an existing floating IP '
- 'pool.'),
cfg.IntOpt('min_compute_nodes',
default=1,
help=('The minimum number of compute nodes expected. This will '
@@ -347,16 +294,18 @@
"The format is 'X.Y', where 'X' and 'Y' are int values. "
"Tempest selects tests based on the range between "
"min_microversion and max_microversion. "
- "If both values are None, Tempest avoids tests which "
- "require a microversion."),
+ "If both values are not specified, Tempest avoids tests "
+ "which require a microversion. Valid values are string "
+ "with format 'X.Y' or string 'latest'"),
cfg.StrOpt('max_microversion',
default=None,
help="Upper version of the test target microversion range. "
"The format is 'X.Y', where 'X' and 'Y' are int values. "
"Tempest selects tests based on the range between "
"min_microversion and max_microversion. "
- "If both values are None, Tempest avoids tests which "
- "require a microversion."),
+ "If both values are not specified, Tempest avoids tests "
+ "which require a microversion. Valid values are string "
+ "with format 'X.Y' or string 'latest'"),
cfg.BoolOpt('disk_config',
default=True,
help="If false, skip disk config tests"),
@@ -439,9 +388,6 @@
default=True,
help='Does the test environment support creating snapshot '
'images of running instances?'),
- cfg.BoolOpt('ec2_api',
- default=True,
- help='Does the test environment have the ec2 api running?'),
cfg.BoolOpt('nova_cert',
default=True,
help='Does the test environment have the nova cert running?'),
@@ -670,9 +616,7 @@
cfg.BoolOpt('run_validation',
default=False,
help='Enable ssh on created servers and creation of additional'
- ' validation resources to enable remote access',
- deprecated_opts=[cfg.DeprecatedOpt('run_ssh',
- group='compute')]),
+ ' validation resources to enable remote access'),
cfg.BoolOpt('security_group',
default=True,
help='Enable/disable security groups.'),
@@ -684,31 +628,77 @@
choices=['fixed', 'floating'],
help='Default IP type used for validation: '
'-fixed: uses the first IP belonging to the fixed network '
- '-floating: creates and uses a floating IP'),
+ '-floating: creates and uses a floating IP',
+ deprecated_opts=[cfg.DeprecatedOpt('use_floatingip_for_ssh',
+ group='compute')]),
cfg.StrOpt('auth_method',
default='keypair',
choices=['keypair'],
help='Default authentication method to the instance. '
'Only ssh via keypair is supported for now. '
- 'Additional methods will be handled in a separate spec.'),
+ 'Additional methods will be handled in a separate spec.',
+ deprecated_opts=[cfg.DeprecatedOpt('ssh_auth_method',
+ group='compute')]),
cfg.IntOpt('ip_version_for_ssh',
default=4,
- help='Default IP version for ssh connections.',
- deprecated_opts=[cfg.DeprecatedOpt('ip_version_for_ssh',
- group='compute')]),
+ help='Default IP version for ssh connections.'),
cfg.IntOpt('ping_timeout',
default=120,
- help='Timeout in seconds to wait for ping to succeed.'),
+ help='Timeout in seconds to wait for ping to succeed.',
+ deprecated_opts=[cfg.DeprecatedOpt('ping_timeout',
+ group='compute')]),
cfg.IntOpt('connect_timeout',
default=60,
help='Timeout in seconds to wait for the TCP connection to be '
- 'successful.',
- deprecated_opts=[cfg.DeprecatedOpt('ssh_channel_timeout',
- group='compute')]),
+ 'successful.'),
cfg.IntOpt('ssh_timeout',
default=300,
- help='Timeout in seconds to wait for the ssh banner.',
- deprecated_opts=[cfg.DeprecatedOpt('ssh_timeout',
+ help='Timeout in seconds to wait for the ssh banner.'),
+ cfg.StrOpt('image_ssh_user',
+ default="root",
+ help="User name used to authenticate to an instance.",
+ deprecated_opts=[cfg.DeprecatedOpt('image_ssh_user',
+ group='compute'),
+ cfg.DeprecatedOpt('ssh_user',
+ group='compute'),
+ cfg.DeprecatedOpt('ssh_user',
+ group='scenario')]),
+ cfg.StrOpt('image_ssh_password',
+ default="password",
+ help="Password used to authenticate to an instance.",
+ deprecated_opts=[cfg.DeprecatedOpt('image_ssh_password',
+ group='compute')]),
+ 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.",
+ deprecated_opts=[cfg.DeprecatedOpt('ssh_shell_prologue',
+ group='compute')]),
+ cfg.IntOpt('ping_size',
+ default=56,
+ help="The packet size for ping packets originating "
+ "from remote linux hosts",
+ deprecated_opts=[cfg.DeprecatedOpt('ping_size',
+ group='compute')]),
+ cfg.IntOpt('ping_count',
+ default=1,
+ help="The number of ping packets originating from remote "
+ "linux hosts",
+ deprecated_opts=[cfg.DeprecatedOpt('ping_count',
+ group='compute')]),
+ cfg.StrOpt('floating_ip_range',
+ default='10.0.0.0/29',
+ help='Unallocated floating IP range, which will be used to '
+ 'test the floating IP bulk feature for CRUD operation. '
+ 'This block must not overlap an existing floating IP '
+ 'pool.',
+ deprecated_opts=[cfg.DeprecatedOpt('floating_ip_range',
+ group='compute')]),
+ cfg.StrOpt('network_for_ssh',
+ default='public',
+ help="Network used for SSH connections. Ignored if "
+ "use_floatingip_for_ssh=true or run_validation=false.",
+ deprecated_opts=[cfg.DeprecatedOpt('network_for_ssh',
group='compute')]),
]
@@ -1011,54 +1001,6 @@
help="List of enabled data processing plugins")
]
-
-boto_group = cfg.OptGroup(name='boto',
- title='EC2/S3 options')
-BotoGroup = [
- cfg.StrOpt('ec2_url',
- default="http://localhost:8773/services/Cloud",
- help="EC2 URL"),
- cfg.StrOpt('s3_url',
- default="http://localhost:8080",
- help="S3 URL"),
- cfg.StrOpt('aws_secret',
- help="AWS Secret Key",
- secret=True),
- cfg.StrOpt('aws_access',
- help="AWS Access Key"),
- cfg.StrOpt('aws_zone',
- default="nova",
- help="AWS Zone for EC2 tests"),
- cfg.StrOpt('s3_materials_path',
- default="/opt/stack/devstack/files/images/"
- "s3-materials/cirros-0.3.0",
- help="S3 Materials Path"),
- cfg.StrOpt('ari_manifest',
- default="cirros-0.3.0-x86_64-initrd.manifest.xml",
- help="ARI Ramdisk Image manifest"),
- cfg.StrOpt('ami_manifest',
- default="cirros-0.3.0-x86_64-blank.img.manifest.xml",
- help="AMI Machine Image manifest"),
- cfg.StrOpt('aki_manifest',
- default="cirros-0.3.0-x86_64-vmlinuz.manifest.xml",
- help="AKI Kernel Image manifest"),
- cfg.StrOpt('instance_type',
- default="m1.tiny",
- help="Instance type"),
- cfg.IntOpt('http_socket_timeout',
- default=3,
- help="boto Http socket timeout"),
- cfg.IntOpt('num_retries',
- default=1,
- help="boto num_retries on error"),
- cfg.IntOpt('build_timeout',
- default=60,
- help="Status Change Timeout"),
- cfg.IntOpt('build_interval',
- default=1,
- help="Status Change Test Interval"),
-]
-
stress_group = cfg.OptGroup(name='stress', title='Stress Test Options')
StressGroup = [
@@ -1124,9 +1066,6 @@
cfg.StrOpt('aki_img_file',
default='cirros-0.3.1-x86_64-vmlinuz',
help='AKI image file name'),
- cfg.StrOpt('ssh_user',
- default='cirros',
- help='ssh username for the image file'),
cfg.IntOpt(
'large_ops_number',
default=0,
@@ -1320,7 +1259,6 @@
(dashboard_group, DashboardGroup),
(data_processing_group, DataProcessingGroup),
(data_processing_feature_group, DataProcessingFeaturesGroup),
- (boto_group, BotoGroup),
(stress_group, StressGroup),
(scenario_group, ScenarioGroup),
(service_available_group, ServiceAvailableGroup),
@@ -1390,7 +1328,6 @@
self.data_processing = _CONF['data-processing']
self.data_processing_feature_enabled = _CONF[
'data-processing-feature-enabled']
- self.boto = _CONF.boto
self.stress = _CONF.stress
self.scenario = _CONF.scenario
self.service_available = _CONF.service_available
@@ -1404,6 +1341,7 @@
_CONF.set_default('alt_domain_name',
self.auth.default_credentials_domain_name,
group='identity')
+ logging.tempest_set_log_file('tempest.log')
def __init__(self, parse_conf=True, config_path=None):
"""Initialize a configuration from a conf directory and conf file."""
@@ -1434,6 +1372,13 @@
_CONF([], project='tempest', default_config_files=config_files)
else:
_CONF([], project='tempest')
+
+ logging_cfg_path = "%s/logging.conf" % os.path.dirname(path)
+ if (not hasattr(_CONF, 'log_config_append') and
+ os.path.isfile(logging_cfg_path)):
+ # if logging conf is in place we need to set log_config_append
+ _CONF.log_config_append = logging_cfg_path
+
logging.setup(_CONF, 'tempest')
LOG = logging.getLogger('tempest')
LOG.info("Using tempest config file %s" % path)
@@ -1460,6 +1405,8 @@
def __getattr__(self, attr):
if not self._config:
self._fix_log_levels()
+ lock_dir = os.path.join(tempfile.gettempdir(), 'tempest-lock')
+ lockutils.set_defaults(lock_dir)
self._config = TempestConfigPrivate(config_path=self._path)
return getattr(self._config, attr)
diff --git a/tempest/exceptions.py b/tempest/exceptions.py
index 8537898..1d725af 100644
--- a/tempest/exceptions.py
+++ b/tempest/exceptions.py
@@ -177,8 +177,8 @@
class InvalidAPIVersionString(TempestException):
- msg_fmt = ("API Version String %(version)s is of invalid format. Must "
- "be of format MajorNum.MinorNum.")
+ message = ("API Version String %(version)s is of invalid format. Must "
+ "be of format MajorNum.MinorNum or string 'latest'.")
class CommandFailed(Exception):
diff --git a/tempest/hacking/ignored_list_T110.txt b/tempest/hacking/ignored_list_T110.txt
index 211a7d6..8de3151 100644
--- a/tempest/hacking/ignored_list_T110.txt
+++ b/tempest/hacking/ignored_list_T110.txt
@@ -1,8 +1,4 @@
-./tempest/services/database/json/flavors_client.py
-./tempest/services/identity/v3/json/credentials_client.py
./tempest/services/identity/v3/json/identity_client.py
-./tempest/services/identity/v3/json/policy_client.py
-./tempest/services/identity/v3/json/region_client.py
./tempest/services/messaging/json/messaging_client.py
./tempest/services/object_storage/object_client.py
./tempest/services/telemetry/json/alarming_client.py
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index eff97da..7e8fb7a 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -55,7 +55,8 @@
cls.images_client = cls.manager.images_client
cls.keypairs_client = cls.manager.keypairs_client
# Nova security groups client
- cls.security_groups_client = cls.manager.security_groups_client
+ cls.compute_security_groups_client = (
+ cls.manager.compute_security_groups_client)
cls.security_group_rules_client = (
cls.manager.security_group_rules_client)
cls.servers_client = cls.manager.servers_client
@@ -286,7 +287,7 @@
return volume
def _create_loginable_secgroup_rule(self, secgroup_id=None):
- _client = self.security_groups_client
+ _client = self.compute_security_groups_client
_client_rules = self.security_group_rules_client
if secgroup_id is None:
sgs = _client.list_security_groups()['security_groups']
@@ -328,13 +329,14 @@
# Create security group
sg_name = data_utils.rand_name(self.__class__.__name__)
sg_desc = sg_name + " description"
- secgroup = self.security_groups_client.create_security_group(
+ secgroup = self.compute_security_groups_client.create_security_group(
name=sg_name, description=sg_desc)['security_group']
self.assertEqual(secgroup['name'], sg_name)
self.assertEqual(secgroup['description'], sg_desc)
- self.addCleanup(self.delete_wrapper,
- self.security_groups_client.delete_security_group,
- secgroup['id'])
+ self.addCleanup(
+ self.delete_wrapper,
+ self.compute_security_groups_client.delete_security_group,
+ secgroup['id'])
# Add rules to the security group
self._create_loginable_secgroup_rule(secgroup['id'])
@@ -357,7 +359,7 @@
if isinstance(server_or_ip, six.string_types):
ip = server_or_ip
else:
- addrs = server_or_ip['addresses'][CONF.compute.network_for_ssh]
+ addrs = server_or_ip['addresses'][CONF.validation.network_for_ssh]
try:
ip = (addr['addr'] for addr in addrs if
netaddr.valid_ipv4(addr['addr'])).next()
@@ -366,7 +368,7 @@
"remote server.")
if username is None:
- username = CONF.scenario.ssh_user
+ username = CONF.validation.image_ssh_user
# Set this with 'keypair' or others to log in with keypair or
# username/password.
if CONF.validation.auth_method == 'keypair':
@@ -374,7 +376,7 @@
if private_key is None:
private_key = self.keypair['private_key']
else:
- password = CONF.compute.image_ssh_password
+ password = CONF.validation.image_ssh_password
private_key = None
linux_client = remote_client.RemoteClient(ip, username,
pkey=private_key,
@@ -455,7 +457,7 @@
servers = servers['servers']
for server in servers:
console_output = self.servers_client.get_console_output(
- server['id'], length=None)['output']
+ server['id'])['output']
LOG.debug('Console output for %s\nbody=\n%s',
server['id'], console_output)
@@ -810,8 +812,9 @@
def _get_server_port_id_and_ip4(self, server, ip_addr=None):
ports = self._list_ports(device_id=server['id'], status='ACTIVE',
fixed_ip=ip_addr)
- # it might happen here that this port has more then one ip address
- # as in case of dual stack- when this port is created on 2 subnets
+ # A port can have more then one IP address in some cases.
+ # If the network is dual-stack (IPv4 + IPv6), this port is associated
+ # with 2 subnets
port_map = [(p["id"], fxip["ip_address"])
for p in ports
for fxip in p["fixed_ips"]
@@ -1093,7 +1096,7 @@
return rules
def _ssh_to_server(self, server, private_key):
- ssh_login = CONF.compute.image_ssh_user
+ ssh_login = CONF.validation.image_ssh_user
return self.get_remote_client(server,
username=ssh_login,
private_key=private_key)
diff --git a/tempest/scenario/test_large_ops.py b/tempest/scenario/test_large_ops.py
index f45fb3a..b549ecb 100644
--- a/tempest/scenario/test_large_ops.py
+++ b/tempest/scenario/test_large_ops.py
@@ -85,11 +85,12 @@
# Explicitly create secgroup to avoid cleanup at the end of testcases.
# Since no traffic is tested, we don't need to actually add rules to
# secgroup
- secgroup = self.security_groups_client.create_security_group(
+ secgroup = self.compute_security_groups_client.create_security_group(
name='secgroup-%s' % name,
description='secgroup-desc-%s' % name)['security_group']
- self.addCleanupClass(self.security_groups_client.delete_security_group,
- secgroup['id'])
+ self.addCleanupClass(
+ self.compute_security_groups_client.delete_security_group,
+ secgroup['id'])
create_kwargs = {
'min_count': CONF.scenario.large_ops_number,
'security_groups': [{'name': secgroup['name']}]
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index 25e3e6f..2ef3cee 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -84,7 +84,7 @@
self.assertEqual(volume, got_volume)
def nova_reboot(self, server):
- self.servers_client.reboot_server(server['id'], 'SOFT')
+ self.servers_client.reboot_server(server['id'], type='SOFT')
self._wait_for_server_status(server, 'ACTIVE')
def check_partitions(self):
@@ -95,9 +95,9 @@
def create_and_add_security_group_to_server(self, server):
secgroup = self._create_security_group()
self.servers_client.add_security_group(server['id'],
- secgroup['name'])
+ name=secgroup['name'])
self.addCleanup(self.servers_client.remove_security_group,
- server['id'], secgroup['name'])
+ server['id'], name=secgroup['name'])
def wait_for_secgroup_add():
body = (self.servers_client.show_server(server['id'])
diff --git a/tempest/scenario/test_network_advanced_server_ops.py b/tempest/scenario/test_network_advanced_server_ops.py
index a45a730..d6dd6f3 100644
--- a/tempest/scenario/test_network_advanced_server_ops.py
+++ b/tempest/scenario/test_network_advanced_server_ops.py
@@ -74,7 +74,7 @@
def _check_network_connectivity(self, server, keypair, floating_ip,
should_connect=True):
- username = CONF.compute.image_ssh_user
+ username = CONF.validation.image_ssh_user
private_key = keypair['private_key']
self._check_tenant_network_connectivity(
server, username, private_key,
@@ -112,7 +112,7 @@
@test.services('compute', 'network')
def test_server_connectivity_reboot(self):
server, keypair, floating_ip = self._setup_network_and_servers()
- self.servers_client.reboot_server(server['id'], reboot_type='SOFT')
+ self.servers_client.reboot_server(server['id'], type='SOFT')
self._wait_server_status_and_check_network_connectivity(
server, keypair, floating_ip)
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index 41d13fe..44942b0 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -172,7 +172,7 @@
return self.keypairs[server['key_name']]['private_key']
def _check_tenant_network_connectivity(self):
- ssh_login = CONF.compute.image_ssh_user
+ ssh_login = CONF.validation.image_ssh_user
for server in self.servers:
# call the common method in the parent class
super(TestNetworkBasicOps, self).\
@@ -195,7 +195,7 @@
:param should_check_floating_ip_status: bool. should status of
floating_ip be checked or not
"""
- ssh_login = CONF.compute.image_ssh_user
+ ssh_login = CONF.validation.image_ssh_user
floating_ip, server = self.floating_ip_tuple
ip_address = floating_ip.floating_ip_address
private_key = None
@@ -726,7 +726,7 @@
target_agent = list(hosting_agents if no_migration else
agent_list - hosting_agents)[0]
schedule_router(target_agent,
- self.router['id'])
+ router_id=self.router['id'])
self.assertEqual(
target_agent,
list_hosts(self.router.id)['agents'][0]['id'],
@@ -744,20 +744,28 @@
def test_port_security_macspoofing_port(self):
"""Tests port_security extension enforces mac spoofing
- 1. create a new network
- 2. connect VM to new network
- 4. check VM can ping new network DHCP port
- 5. spoof mac on new new network interface
- 6. check Neutron enforces mac spoofing and blocks pings via spoofed
- interface
- 7. disable port-security on the spoofed port
- 8. check Neutron allows pings via spoofed interface
+ Neutron security groups always apply anti-spoof rules on the VMs. This
+ allows traffic to originate and terminate at the VM as expected, but
+ prevents traffic to pass through the VM. Anti-spoof rules are not
+ required in cases where the VM routes traffic through it.
+
+ The test steps are :
+ 1. Create a new network.
+ 2. Connect (hotplug) the VM to a new network.
+ 3. Check the VM can ping the DHCP interface of this network.
+ 4. Spoof the mac address of the new VM interface.
+ 5. Check the Security Group enforces mac spoofing and blocks pings via
+ spoofed interface (VM cannot ping the DHCP interface).
+ 6. Disable port-security of the spoofed port- set the flag to false.
+ 7. Retest 3rd step and check that the Security Group allows pings via
+ the spoofed interface.
"""
+
spoof_mac = "00:00:00:00:00:01"
# Create server
self._setup_network_and_servers()
- self.check_public_network_connectivity(should_connect=False)
+ self.check_public_network_connectivity(should_connect=True)
self._create_new_network()
self._hotplug_server()
fip, server = self.floating_ip_tuple
diff --git a/tempest/scenario/test_network_v6.py b/tempest/scenario/test_network_v6.py
index d6ad46a..40c7680 100644
--- a/tempest/scenario/test_network_v6.py
+++ b/tempest/scenario/test_network_v6.py
@@ -114,7 +114,7 @@
return ips
def prepare_server(self, networks=None):
- username = CONF.compute.image_ssh_user
+ username = CONF.validation.image_ssh_user
networks = networks or [self.network]
diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py
index e266dc2..4e5a1e0 100644
--- a/tempest/scenario/test_security_groups_basic_ops.py
+++ b/tempest/scenario/test_security_groups_basic_ops.py
@@ -512,7 +512,7 @@
tenant = self.primary_tenant
ip = self._get_server_ip(tenant.access_point,
floating=self.floating_ip_access)
- ssh_login = CONF.compute.image_ssh_user
+ ssh_login = CONF.validation.image_ssh_user
private_key = tenant.keypair['private_key']
self.check_vm_connectivity(ip,
should_connect=False)
diff --git a/tempest/services/baremetal/base.py b/tempest/services/baremetal/base.py
index 004c0de..d8cb99d 100644
--- a/tempest/services/baremetal/base.py
+++ b/tempest/services/baremetal/base.py
@@ -59,7 +59,7 @@
:param resource_name: The name of the REST resource, e.g., 'nodes'.
:param uuid: The unique identifier of an object in UUID format.
- :return: Relative URI for the resource or object.
+ :returns: Relative URI for the resource or object.
"""
prefix = self.uri_prefix if not permanent else ''
@@ -68,18 +68,18 @@
res=resource_name,
uuid='/%s' % uuid if uuid else '')
- def _make_patch(self, allowed_attributes, **kw):
+ def _make_patch(self, allowed_attributes, **kwargs):
"""Create a JSON patch according to RFC 6902.
:param allowed_attributes: An iterable object that contains a set of
allowed attributes for an object.
- :param **kw: Attributes and new values for them.
- :return: A JSON path that sets values of the specified attributes to
+ :param **kwargs: Attributes and new values for them.
+ :returns: A JSON path that sets values of the specified attributes to
the new ones.
"""
- def get_change(kw, path='/'):
- for name, value in six.iteritems(kw):
+ def get_change(kwargs, path='/'):
+ for name, value in six.iteritems(kwargs):
if isinstance(value, dict):
for ch in get_change(value, path + '%s/' % name):
yield ch
@@ -92,7 +92,7 @@
'value': value,
'op': 'replace'}
- patch = [ch for ch in get_change(kw)
+ patch = [ch for ch in get_change(kwargs)
if ch['path'].lstrip('/') in allowed_attributes]
return patch
@@ -101,8 +101,8 @@
"""Get the list of objects of the specified type.
:param resource: The name of the REST resource, e.g., 'nodes'.
- "param **kw: Parameters for the request.
- :return: A tuple with the server response and deserialized JSON list
+ :param **kwargs: Parameters for the request.
+ :returns: A tuple with the server response and deserialized JSON list
of objects
"""
@@ -119,7 +119,7 @@
"""Gets a specific object of the specified type.
:param uuid: Unique identifier of the object in UUID format.
- :return: Serialized object as a dictionary.
+ :returns: Serialized object as a dictionary.
"""
if 'uri' in kwargs:
@@ -137,7 +137,7 @@
:param resource: The name of the REST resource, e.g., 'nodes'.
:param object_dict: A Python dict that represents an object of the
specified type.
- :return: A tuple with the server response and the deserialized created
+ :returns: A tuple with the server response and the deserialized created
object.
"""
@@ -154,7 +154,7 @@
:param resource: The name of the REST resource, e.g., 'nodes'.
:param uuid: The unique identifier of an object in UUID format.
- :return: A tuple with the server response and the response body.
+ :returns: A tuple with the server response and the response body.
"""
uri = self._get_uri(resource, uuid)
@@ -168,7 +168,7 @@
:param resource: The name of the REST resource, e.g., 'nodes'.
:param uuid: The unique identifier of an object in UUID format.
- :return: A tuple with the server response and the serialized patched
+ :returns: A tuple with the server response and the serialized patched
object.
"""
@@ -190,7 +190,7 @@
"""Retrieves the desctription of the API.
:param version: The version of the API. Default: 'v1'.
- :return: Serialized description of API resources.
+ :returns: Serialized description of API resources.
"""
return self._list_request(version, permanent=True)
diff --git a/tempest/services/botoclients.py b/tempest/services/botoclients.py
deleted file mode 100644
index e117719..0000000
--- a/tempest/services/botoclients.py
+++ /dev/null
@@ -1,217 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import contextlib
-import types
-
-import boto
-import boto.ec2
-import boto.s3.connection
-from six.moves import configparser as ConfigParser
-from six.moves.urllib import parse as urlparse
-from tempest_lib import exceptions as lib_exc
-
-from tempest import config
-
-CONF = config.CONF
-
-
-class BotoClientBase(object):
-
- ALLOWED_METHODS = set()
-
- def __init__(self, identity_client):
- self.identity_client = identity_client
-
- self.ca_cert = CONF.identity.ca_certificates_file
- self.connection_timeout = str(CONF.boto.http_socket_timeout)
- self.num_retries = str(CONF.boto.num_retries)
- self.build_timeout = CONF.boto.build_timeout
-
- self.connection_data = {}
-
- def _config_boto_timeout(self, timeout, retries):
- try:
- boto.config.add_section("Boto")
- except ConfigParser.DuplicateSectionError:
- pass
- boto.config.set("Boto", "http_socket_timeout", timeout)
- boto.config.set("Boto", "num_retries", retries)
-
- def _config_boto_ca_certificates_file(self, ca_cert):
- if ca_cert is None:
- return
-
- try:
- boto.config.add_section("Boto")
- except ConfigParser.DuplicateSectionError:
- pass
- boto.config.set("Boto", "ca_certificates_file", ca_cert)
-
- def __getattr__(self, name):
- """Automatically creates methods for the allowed methods set."""
- if name in self.ALLOWED_METHODS:
- def func(self, *args, **kwargs):
- with contextlib.closing(self.get_connection()) as conn:
- return getattr(conn, name)(*args, **kwargs)
-
- func.__name__ = name
- setattr(self, name, types.MethodType(func, self, self.__class__))
- setattr(self.__class__, name,
- types.MethodType(func, None, self.__class__))
- return getattr(self, name)
- else:
- raise AttributeError(name)
-
- def get_connection(self):
- self._config_boto_timeout(self.connection_timeout, self.num_retries)
- self._config_boto_ca_certificates_file(self.ca_cert)
-
- ec2_client_args = {'aws_access_key_id': CONF.boto.aws_access,
- 'aws_secret_access_key': CONF.boto.aws_secret}
- if not all(ec2_client_args.values()):
- ec2_client_args = self.get_aws_credentials(self.identity_client)
-
- self.connection_data.update(ec2_client_args)
- return self.connect_method(**self.connection_data)
-
- def get_aws_credentials(self, identity_client):
- """Obtain existing, or create new AWS credentials
-
- :param identity_client: identity client with embedded credentials
- :return: EC2 credentials
- """
- ec2_cred_list = identity_client.list_user_ec2_credentials(
- identity_client.user_id)['credentials']
- for cred in ec2_cred_list:
- if cred['tenant_id'] == identity_client.tenant_id:
- ec2_cred = cred
- break
- else:
- ec2_cred = (identity_client.create_user_ec2_credentials(
- identity_client.user_id, identity_client.tenant_id)
- ['credential'])
- if not all((ec2_cred, ec2_cred['access'], ec2_cred['secret'])):
- raise lib_exc.NotFound("Unable to get access and secret keys")
- else:
- ec2_cred_aws = {}
- ec2_cred_aws['aws_access_key_id'] = ec2_cred['access']
- ec2_cred_aws['aws_secret_access_key'] = ec2_cred['secret']
- return ec2_cred_aws
-
-
-class APIClientEC2(BotoClientBase):
-
- def connect_method(self, *args, **kwargs):
- return boto.connect_ec2(*args, **kwargs)
-
- def __init__(self, identity_client):
- super(APIClientEC2, self).__init__(identity_client)
- insecure_ssl = CONF.identity.disable_ssl_certificate_validation
- purl = urlparse.urlparse(CONF.boto.ec2_url)
-
- region_name = CONF.compute.region
- if not region_name:
- region_name = CONF.identity.region
- region = boto.ec2.regioninfo.RegionInfo(name=region_name,
- endpoint=purl.hostname)
- port = purl.port
- if port is None:
- if purl.scheme is not "https":
- port = 80
- else:
- port = 443
- else:
- port = int(port)
- self.connection_data.update({"is_secure": purl.scheme == "https",
- "validate_certs": not insecure_ssl,
- "region": region,
- "host": purl.hostname,
- "port": port,
- "path": purl.path})
-
- ALLOWED_METHODS = set(('create_key_pair', 'get_key_pair',
- 'delete_key_pair', 'import_key_pair',
- 'get_all_key_pairs',
- 'get_all_tags',
- 'create_image', 'get_image',
- 'register_image', 'deregister_image',
- 'get_all_images', 'get_image_attribute',
- 'modify_image_attribute', 'reset_image_attribute',
- 'get_all_kernels',
- 'create_volume', 'delete_volume',
- 'get_all_volume_status', 'get_all_volumes',
- 'get_volume_attribute', 'modify_volume_attribute'
- 'bundle_instance', 'cancel_spot_instance_requests',
- 'confirm_product_instanc',
- 'get_all_instance_status', 'get_all_instances',
- 'get_all_reserved_instances',
- 'get_all_spot_instance_requests',
- 'get_instance_attribute', 'monitor_instance',
- 'monitor_instances', 'unmonitor_instance',
- 'unmonitor_instances',
- 'purchase_reserved_instance_offering',
- 'reboot_instances', 'request_spot_instances',
- 'reset_instance_attribute', 'run_instances',
- 'start_instances', 'stop_instances',
- 'terminate_instances',
- 'attach_network_interface', 'attach_volume',
- 'detach_network_interface', 'detach_volume',
- 'get_console_output',
- 'delete_network_interface', 'create_subnet',
- 'create_network_interface', 'delete_subnet',
- 'get_all_network_interfaces',
- 'allocate_address', 'associate_address',
- 'disassociate_address', 'get_all_addresses',
- 'release_address',
- 'create_snapshot', 'delete_snapshot',
- 'get_all_snapshots', 'get_snapshot_attribute',
- 'modify_snapshot_attribute',
- 'reset_snapshot_attribute', 'trim_snapshots',
- 'get_all_regions', 'get_all_zones',
- 'get_all_security_groups', 'create_security_group',
- 'delete_security_group', 'authorize_security_group',
- 'authorize_security_group_egress',
- 'revoke_security_group',
- 'revoke_security_group_egress'))
-
-
-class ObjectClientS3(BotoClientBase):
-
- def connect_method(self, *args, **kwargs):
- return boto.connect_s3(*args, **kwargs)
-
- def __init__(self, identity_client):
- super(ObjectClientS3, self).__init__(identity_client)
- insecure_ssl = CONF.identity.disable_ssl_certificate_validation
- purl = urlparse.urlparse(CONF.boto.s3_url)
- port = purl.port
- if port is None:
- if purl.scheme is not "https":
- port = 80
- else:
- port = 443
- else:
- port = int(port)
- self.connection_data.update({"is_secure": purl.scheme == "https",
- "validate_certs": not insecure_ssl,
- "host": purl.hostname,
- "port": port,
- "calling_format": boto.s3.connection.
- OrdinaryCallingFormat()})
-
- ALLOWED_METHODS = set(('create_bucket', 'delete_bucket', 'generate_url',
- 'get_all_buckets', 'get_bucket', 'delete_key',
- 'lookup'))
diff --git a/tempest/services/compute/json/base.py b/tempest/services/compute/json/base.py
new file mode 100644
index 0000000..02e9f8b
--- /dev/null
+++ b/tempest/services/compute/json/base.py
@@ -0,0 +1,25 @@
+# Copyright 2015 NEC Corporation. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.common import service_client
+
+
+class BaseComputeClient(service_client.ServiceClient):
+ api_microversion = None
+
+ def get_headers(self):
+ headers = super(BaseComputeClient, self).get_headers()
+ if self.api_microversion:
+ headers['X-OpenStack-Nova-API-Version'] = self.api_microversion
+ return headers
diff --git a/tempest/services/compute/json/floating_ips_client.py b/tempest/services/compute/json/floating_ips_client.py
deleted file mode 100644
index b3e2f2f..0000000
--- a/tempest/services/compute/json/floating_ips_client.py
+++ /dev/null
@@ -1,103 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from oslo_serialization import jsonutils as json
-from six.moves.urllib import parse as urllib
-from tempest_lib import exceptions as lib_exc
-
-from tempest.api_schema.response.compute.v2_1 import floating_ips as schema
-from tempest.common import service_client
-
-
-class FloatingIPsClient(service_client.ServiceClient):
-
- def list_floating_ips(self, **params):
- """Returns a list of all floating IPs filtered by any parameters."""
- url = 'os-floating-ips'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_floating_ips, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def show_floating_ip(self, floating_ip_id):
- """Get the details of a floating IP."""
- 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)
- return service_client.ResponseBody(resp, body)
-
- def create_floating_ip(self, **kwargs):
- """Allocate a floating IP to the project.
-
- Available params: see http://developer.openstack.org/
- api-ref-compute-v2.1.html#createFloatingIP
- """
- url = 'os-floating-ips'
- post_body = json.dumps(kwargs)
- resp, body = self.post(url, post_body)
- body = json.loads(body)
- self.validate_response(schema.create_get_floating_ip, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def delete_floating_ip(self, floating_ip_id):
- """Deletes the provided floating IP from the project."""
- 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" % server_id
- post_body = {
- 'addFloatingIp': {
- 'address': floating_ip,
- }
- }
-
- post_body = json.dumps(post_body)
- resp, body = self.post(url, post_body)
- self.validate_response(schema.add_remove_floating_ip, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def disassociate_floating_ip_from_server(self, floating_ip, server_id):
- """Disassociate the provided floating IP from a specific server."""
- url = "servers/%s/action" % server_id
- post_body = {
- 'removeFloatingIp': {
- 'address': floating_ip,
- }
- }
-
- post_body = json.dumps(post_body)
- resp, body = self.post(url, post_body)
- self.validate_response(schema.add_remove_floating_ip, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def is_resource_deleted(self, id):
- try:
- self.show_floating_ip(id)
- except lib_exc.NotFound:
- return True
- return False
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'floating_ip'
diff --git a/tempest/services/compute/json/interfaces_client.py b/tempest/services/compute/json/interfaces_client.py
deleted file mode 100644
index fe076d8..0000000
--- a/tempest/services/compute/json/interfaces_client.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright 2013 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from oslo_serialization import jsonutils as json
-
-from tempest.api_schema.response.compute.v2_1 import interfaces as schema
-from tempest.common import service_client
-
-
-class InterfacesClient(service_client.ServiceClient):
-
- 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.ResponseBody(resp, body)
-
- 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_id,
- body=post_body)
- body = json.loads(body)
- self.validate_response(schema.get_create_interfaces, resp, body)
- return service_client.ResponseBody(resp, body)
-
- 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)
-
- 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)
diff --git a/tempest/services/compute/json/security_group_rules_client.py b/tempest/services/compute/json/security_group_rules_client.py
deleted file mode 100644
index 314b1ed..0000000
--- a/tempest/services/compute/json/security_group_rules_client.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from oslo_serialization import jsonutils as json
-
-from tempest.api_schema.response.compute.v2_1 import security_groups as schema
-from tempest.common import service_client
-
-
-class SecurityGroupRulesClient(service_client.ServiceClient):
-
- def create_security_group_rule(self, **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 = json.dumps({'security_group_rule': kwargs})
- 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)
-
- 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)
diff --git a/tempest/services/compute/json/server_groups_client.py b/tempest/services/compute/json/server_groups_client.py
deleted file mode 100644
index 44ac015..0000000
--- a/tempest/services/compute/json/server_groups_client.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# 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.
-
-from oslo_serialization import jsonutils as 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, **kwargs):
- """Create the server group
-
- name : Name of the server-group
- policies : List of the policies - affinity/anti-affinity)
- """
- post_body = json.dumps({'server_group': kwargs})
- resp, body = self.post('os-server-groups', post_body)
-
- body = json.loads(body)
- self.validate_response(schema.create_show_server_group, resp, body)
- return service_client.ResponseBody(resp, body)
-
- 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.ResponseBody(resp, body)
-
- def show_server_group(self, server_group_id):
- """Get the details of given server_group."""
- resp, body = self.get("os-server-groups/%s" % server_group_id)
- body = json.loads(body)
- self.validate_response(schema.create_show_server_group, resp, body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index a0251f1..c20295b 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -32,7 +32,10 @@
self.enable_instance_password = enable_instance_password
def create_server(self, **kwargs):
- """Create server
+ """Create server.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-compute-v2.1.html#createServer
Most parameters except the following are passed to the API without
any changes.
@@ -69,7 +72,10 @@
return service_client.ResponseBody(resp, body)
def update_server(self, server_id, **kwargs):
- """Update server
+ """Update server.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-compute-v2.1.html#updateServer
Most parameters except the following are passed to the API without
any changes.
@@ -85,20 +91,26 @@
return service_client.ResponseBody(resp, body)
def show_server(self, server_id):
- """Get server details"""
+ """Get server details."""
resp, body = self.get("servers/%s" % server_id)
body = json.loads(body)
self.validate_response(schema.get_server, resp, body)
return service_client.ResponseBody(resp, body)
def delete_server(self, server_id):
- """Delete server"""
+ """Delete server."""
resp, body = self.delete("servers/%s" % server_id)
self.validate_response(schema.delete_server, resp, body)
return service_client.ResponseBody(resp, body)
def list_servers(self, detail=False, **params):
- """List servers"""
+ """List servers.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-compute-v2.1.html#listServers
+ and http://developer.openstack.org/
+ api-ref-compute-v2.1.html#listDetailServers
+ """
url = 'servers'
_schema = schema.list_servers
@@ -140,17 +152,21 @@
self.validate_response(schema, resp, body)
return service_client.ResponseBody(resp, body)
- def create_backup(self, server_id, backup_type, rotation, name):
- """Backup a server instance."""
- return self.action(server_id, "createBackup",
- backup_type=backup_type,
- rotation=rotation,
- name=name)
+ def create_backup(self, server_id, **kwargs):
+ """Backup a server instance.
- def change_password(self, server_id, adminPass):
- """Changes the root password for the server."""
- return self.action(server_id, 'changePassword',
- adminPass=adminPass)
+ Available params: see http://developer.openstack.org/
+ api-ref-compute-v2.1.html#createBackup
+ """
+ return self.action(server_id, "createBackup", **kwargs)
+
+ def change_password(self, server_id, **kwargs):
+ """Change the root password for the server.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-compute-v2.1.html#changePassword
+ """
+ return self.action(server_id, 'changePassword', **kwargs)
def show_password(self, server_id):
resp, body = self.get("servers/%s/os-server-password" %
@@ -171,12 +187,19 @@
resp, body)
return service_client.ResponseBody(resp, body)
- def reboot_server(self, server_id, reboot_type):
- """Reboots a server."""
- return self.action(server_id, 'reboot', type=reboot_type)
+ def reboot_server(self, server_id, **kwargs):
+ """Reboot a server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#reboot
+ """
+ return self.action(server_id, 'reboot', **kwargs)
def rebuild_server(self, server_id, image_ref, **kwargs):
- """Rebuilds a server with a new image.
+ """Rebuild a server with a new image.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#rebuild
Most parameters except the following are passed to the API without
any changes.
@@ -193,7 +216,10 @@
rebuild_schema, **kwargs)
def resize_server(self, server_id, flavor_ref, **kwargs):
- """Changes the flavor of a server.
+ """Change the flavor of a server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#resize
Most parameters except the following are passed to the API without
any changes.
@@ -205,13 +231,21 @@
return self.action(server_id, 'resize', **kwargs)
def confirm_resize_server(self, server_id, **kwargs):
- """Confirms the flavor change for a server."""
+ """Confirm the flavor change for a server.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-compute-v2.1.html#confirmResize
+ """
return self.action(server_id, 'confirmResize',
schema.server_actions_confirm_resize,
**kwargs)
def revert_resize_server(self, server_id, **kwargs):
- """Reverts a server back to its original flavor."""
+ """Revert a server back to its original flavor.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-compute-v2.1.html#revertResize
+ """
return self.action(server_id, 'revertResize', **kwargs)
def list_server_metadata(self, server_id):
@@ -301,73 +335,132 @@
self.validate_response(schema.list_volume_attachments, resp, body)
return service_client.ResponseBody(resp, body)
- def add_security_group(self, server_id, name):
- """Adds a security group to the server."""
- return self.action(server_id, 'addSecurityGroup', name=name)
+ def add_security_group(self, server_id, **kwargs):
+ """Add a security group to the server.
- def remove_security_group(self, server_id, name):
- """Removes a security group from the server."""
- return self.action(server_id, 'removeSecurityGroup', name=name)
+ Available params: TODO
+ """
+ # TODO(oomichi): The api-site doesn't contain this API description.
+ # So the above should be changed to the api-site link after
+ # adding the description on the api-site.
+ # LP: https://bugs.launchpad.net/openstack-api-site/+bug/1524199
+ return self.action(server_id, 'addSecurityGroup', **kwargs)
+
+ def remove_security_group(self, server_id, **kwargs):
+ """Remove a security group from the server.
+
+ Available params: TODO
+ """
+ # TODO(oomichi): The api-site doesn't contain this API description.
+ # So the above should be changed to the api-site link after
+ # adding the description on the api-site.
+ # LP: https://bugs.launchpad.net/openstack-api-site/+bug/1524199
+ return self.action(server_id, 'removeSecurityGroup', **kwargs)
def live_migrate_server(self, server_id, **kwargs):
- """This should be called with administrator privileges ."""
+ """This should be called with administrator privileges.
- req_body = json.dumps({'os-migrateLive': kwargs})
-
- 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)
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#migrateLive
+ """
+ return self.action(server_id, 'os-migrateLive', **kwargs)
def migrate_server(self, server_id, **kwargs):
- """Migrates a server to a new host."""
+ """Migrate a server to a new host.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#migrate
+ """
return self.action(server_id, 'migrate', **kwargs)
def lock_server(self, server_id, **kwargs):
- """Locks the given server."""
+ """Lock the given server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#lock
+ """
return self.action(server_id, 'lock', **kwargs)
def unlock_server(self, server_id, **kwargs):
- """UNlocks the given server."""
+ """UNlock the given server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#unlock
+ """
return self.action(server_id, 'unlock', **kwargs)
def suspend_server(self, server_id, **kwargs):
- """Suspends the provided server."""
+ """Suspend the provided server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#suspend
+ """
return self.action(server_id, 'suspend', **kwargs)
def resume_server(self, server_id, **kwargs):
- """Un-suspends the provided server."""
+ """Un-suspend the provided server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#resume
+ """
return self.action(server_id, 'resume', **kwargs)
def pause_server(self, server_id, **kwargs):
- """Pauses the provided server."""
+ """Pause the provided server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#pause
+ """
return self.action(server_id, 'pause', **kwargs)
def unpause_server(self, server_id, **kwargs):
- """Un-pauses the provided server."""
+ """Un-pause the provided server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#unpause
+ """
return self.action(server_id, 'unpause', **kwargs)
- def reset_state(self, server_id, state='error'):
- """Resets the state of a server to active/error."""
- return self.action(server_id, 'os-resetState', state=state)
+ def reset_state(self, server_id, **kwargs):
+ """Reset the state of a server to active/error.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#resetState
+ """
+ return self.action(server_id, 'os-resetState', **kwargs)
def shelve_server(self, server_id, **kwargs):
- """Shelves the provided server."""
+ """Shelve the provided server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#shelve
+ """
return self.action(server_id, 'shelve', **kwargs)
def unshelve_server(self, server_id, **kwargs):
- """Un-shelves the provided server."""
+ """Un-shelve the provided server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#unshelve
+ """
return self.action(server_id, 'unshelve', **kwargs)
def shelve_offload_server(self, server_id, **kwargs):
- """Shelve-offload the provided server."""
+ """Shelve-offload the provided server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#shelveOffload
+ """
return self.action(server_id, 'shelveOffload', **kwargs)
- def get_console_output(self, server_id, length):
- kwargs = {'length': length} if length else {}
+ def get_console_output(self, server_id, **kwargs):
+ """Get console output.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#getConsoleOutput
+ """
return self.action(server_id, 'os-getConsoleOutput',
- schema.get_console_output,
- **kwargs)
+ schema.get_console_output, **kwargs)
def list_virtual_interfaces(self, server_id):
"""List the virtual interfaces used in an instance."""
@@ -378,10 +471,12 @@
return service_client.ResponseBody(resp, body)
def rescue_server(self, server_id, **kwargs):
- """Rescue the provided server."""
- return self.action(server_id, 'rescue',
- schema.rescue_server,
- **kwargs)
+ """Rescue the provided server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#rescue
+ """
+ return self.action(server_id, 'rescue', schema.rescue_server, **kwargs)
def unrescue_server(self, server_id):
"""Unrescue the provided server."""
@@ -409,31 +504,58 @@
return service_client.ResponseBody(resp, body)
def force_delete_server(self, server_id, **kwargs):
- """Force delete a server."""
+ """Force delete a server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#forceDelete
+ """
return self.action(server_id, 'forceDelete', **kwargs)
def restore_soft_deleted_server(self, server_id, **kwargs):
- """Restore a soft-deleted server."""
+ """Restore a soft-deleted server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#restore
+ """
return self.action(server_id, 'restore', **kwargs)
def reset_network(self, server_id, **kwargs):
- """Resets the Network of a server"""
+ """Reset the Network of a server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#resetNetwork
+ """
return self.action(server_id, 'resetNetwork', **kwargs)
def inject_network_info(self, server_id, **kwargs):
- """Inject the Network Info into server"""
+ """Inject the Network Info into server.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#injectNetworkInfo
+ """
return self.action(server_id, 'injectNetworkInfo', **kwargs)
- def get_vnc_console(self, server_id, console_type):
- """Get URL of VNC console."""
+ def get_vnc_console(self, server_id, **kwargs):
+ """Get URL of VNC console.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#getVNCConsole
+ """
return self.action(server_id, "os-getVNCConsole",
- schema.get_vnc_console,
- type=console_type)
+ schema.get_vnc_console, **kwargs)
def add_fixed_ip(self, server_id, **kwargs):
- """Add a fixed IP to input server instance."""
+ """Add a fixed IP to server instance.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#addFixedIp
+ """
return self.action(server_id, 'addFixedIp', **kwargs)
def remove_fixed_ip(self, server_id, **kwargs):
- """Remove input fixed IP from input server instance."""
+ """Remove input fixed IP from input server instance.
+
+ Available params: http://developer.openstack.org/
+ api-ref-compute-v2.1.html#removeFixedIp
+ """
return self.action(server_id, 'removeFixedIp', **kwargs)
diff --git a/tempest/services/compute/json/volumes_client.py b/tempest/services/compute/json/volumes_client.py
deleted file mode 100644
index 69d982e..0000000
--- a/tempest/services/compute/json/volumes_client.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from oslo_serialization import jsonutils as json
-from six.moves.urllib import parse as urllib
-from tempest_lib import exceptions as lib_exc
-
-from tempest.api_schema.response.compute.v2_1 import volumes as schema
-from tempest.common import service_client
-
-
-class VolumesClient(service_client.ServiceClient):
-
- 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)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_volumes, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def show_volume(self, volume_id):
- """Returns the details of a single volume."""
- url = "os-volumes/%s" % volume_id
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.create_get_volume, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def create_volume(self, **kwargs):
- """Creates a new Volume.
-
- size(Required): Size of volume in GB.
- Following optional keyword arguments are accepted:
- display_name: Optional Volume Name.
- metadata: A dictionary of values to be used as metadata.
- """
- post_body = json.dumps({'volume': kwargs})
- resp, body = self.post('os-volumes', post_body)
- body = json.loads(body)
- self.validate_response(schema.create_get_volume, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def delete_volume(self, volume_id):
- """Deletes the Specified Volume."""
- resp, body = self.delete("os-volumes/%s" % volume_id)
- self.validate_response(schema.delete_volume, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def is_resource_deleted(self, id):
- try:
- self.show_volume(id)
- except lib_exc.NotFound:
- return True
- return False
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'volume'
diff --git a/tempest/services/database/json/flavors_client.py b/tempest/services/database/json/flavors_client.py
index 88feb17..34a91ba 100644
--- a/tempest/services/database/json/flavors_client.py
+++ b/tempest/services/database/json/flavors_client.py
@@ -31,8 +31,8 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def get_db_flavor_details(self, db_flavor_id):
- resp, body = self.get("flavors/%s" % str(db_flavor_id))
+ def show_db_flavor(self, db_flavor_id):
+ resp, body = self.get("flavors/%s" % db_flavor_id)
self.expected_success(200, resp.status)
body = json.loads(body)
return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/identity/v2/json/identity_client.py b/tempest/services/identity/v2/json/identity_client.py
index 3f6727d..54596be 100644
--- a/tempest/services/identity/v2/json/identity_client.py
+++ b/tempest/services/identity/v2/json/identity_client.py
@@ -26,116 +26,6 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def create_role(self, name):
- """Create a role."""
- post_body = {
- 'name': name,
- }
- post_body = json.dumps({'role': post_body})
- resp, body = self.post('OS-KSADM/roles', post_body)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
- def show_role(self, role_id):
- """Get a role by its id."""
- resp, body = self.get('OS-KSADM/roles/%s' % role_id)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
- def create_tenant(self, name, **kwargs):
- """Create a tenant
-
- name (required): New tenant name
- description: Description of new tenant (default is none)
- enabled <true|false>: Initial tenant status (default is true)
- """
- post_body = {
- 'name': name,
- 'description': kwargs.get('description', ''),
- 'enabled': kwargs.get('enabled', True),
- }
- post_body = json.dumps({'tenant': post_body})
- resp, body = self.post('tenants', post_body)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
- def delete_role(self, role_id):
- """Delete a role."""
- resp, body = self.delete('OS-KSADM/roles/%s' % str(role_id))
- self.expected_success(204, resp.status)
- return resp, body
-
- def list_user_roles(self, tenant_id, user_id):
- """Returns a list of roles assigned to a user for a tenant."""
- url = '/tenants/%s/users/%s/roles' % (tenant_id, user_id)
- resp, body = self.get(url)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
- def assign_user_role(self, tenant_id, user_id, role_id):
- """Add roles to a user on a tenant."""
- resp, body = self.put('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
- (tenant_id, user_id, role_id), "")
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
- def delete_user_role(self, tenant_id, user_id, role_id):
- """Removes a role assignment for a user on a tenant."""
- resp, body = self.delete('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
- (tenant_id, user_id, role_id))
- self.expected_success(204, resp.status)
- return service_client.ResponseBody(resp, body)
-
- def delete_tenant(self, tenant_id):
- """Delete a tenant."""
- resp, body = self.delete('tenants/%s' % str(tenant_id))
- self.expected_success(204, resp.status)
- return service_client.ResponseBody(resp, body)
-
- def show_tenant(self, tenant_id):
- """Get tenant details."""
- resp, body = self.get('tenants/%s' % str(tenant_id))
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
- def list_roles(self):
- """Returns roles."""
- resp, body = self.get('OS-KSADM/roles')
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
- def list_tenants(self):
- """Returns tenants."""
- resp, body = self.get('tenants')
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
- def update_tenant(self, tenant_id, **kwargs):
- """Updates a tenant."""
- body = self.show_tenant(tenant_id)['tenant']
- name = kwargs.get('name', body['name'])
- desc = kwargs.get('description', body['description'])
- en = kwargs.get('enabled', body['enabled'])
- post_body = {
- 'id': tenant_id,
- 'name': name,
- 'description': desc,
- 'enabled': en,
- }
- post_body = json.dumps({'tenant': post_body})
- resp, body = self.post('tenants/%s' % tenant_id, post_body)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
def create_user(self, name, password, tenant_id, email, **kwargs):
"""Create a user."""
post_body = {
@@ -205,13 +95,6 @@
self.expected_success(204, resp.status)
return service_client.ResponseBody(resp, body)
- def list_tenant_users(self, tenant_id):
- """List users for a Tenant."""
- resp, body = self.get('/tenants/%s/users' % tenant_id)
- self.expected_success(200, resp.status)
- body = json.loads(body)
- return service_client.ResponseBody(resp, body)
-
def create_service(self, name, type, **kwargs):
"""Create a service."""
post_body = {
@@ -307,8 +190,11 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def create_user_ec2_credentials(self, user_id, tenant_id):
- post_body = json.dumps({'tenant_id': tenant_id})
+ def create_user_ec2_credentials(self, user_id, **kwargs):
+ # TODO(piyush): Current api-site doesn't contain this API description.
+ # After fixing the api-site, we need to fix here also for putting the
+ # link to api-site.
+ post_body = json.dumps(kwargs)
resp, body = self.post('/users/%s/credentials/OS-EC2' % user_id,
post_body)
self.expected_success(200, resp.status)
diff --git a/tempest/services/identity/v2/json/roles_client.py b/tempest/services/identity/v2/json/roles_client.py
new file mode 100644
index 0000000..de8f9cb
--- /dev/null
+++ b/tempest/services/identity/v2/json/roles_client.py
@@ -0,0 +1,73 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from oslo_serialization import jsonutils as json
+
+from tempest.common import service_client
+
+
+class RolesClient(service_client.ServiceClient):
+ api_version = "v2.0"
+
+ def create_role(self, name):
+ """Create a role."""
+ post_body = {
+ 'name': name,
+ }
+ post_body = json.dumps({'role': post_body})
+ resp, body = self.post('OS-KSADM/roles', post_body)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def show_role(self, role_id):
+ """Get a role by its id."""
+ resp, body = self.get('OS-KSADM/roles/%s' % role_id)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def delete_role(self, role_id):
+ """Delete a role."""
+ resp, body = self.delete('OS-KSADM/roles/%s' % str(role_id))
+ self.expected_success(204, resp.status)
+ return resp, body
+
+ def list_user_roles(self, tenant_id, user_id):
+ """Returns a list of roles assigned to a user for a tenant."""
+ url = '/tenants/%s/users/%s/roles' % (tenant_id, user_id)
+ resp, body = self.get(url)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def assign_user_role(self, tenant_id, user_id, role_id):
+ """Add roles to a user on a tenant."""
+ resp, body = self.put('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
+ (tenant_id, user_id, role_id), "")
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def delete_user_role(self, tenant_id, user_id, role_id):
+ """Removes a role assignment for a user on a tenant."""
+ resp, body = self.delete('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
+ (tenant_id, user_id, role_id))
+ self.expected_success(204, resp.status)
+ return service_client.ResponseBody(resp, body)
+
+ def list_roles(self):
+ """Returns roles."""
+ resp, body = self.get('OS-KSADM/roles')
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/identity/v2/json/tenants_client.py b/tempest/services/identity/v2/json/tenants_client.py
new file mode 100644
index 0000000..937ae6f
--- /dev/null
+++ b/tempest/services/identity/v2/json/tenants_client.py
@@ -0,0 +1,84 @@
+# Copyright 2015 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from oslo_serialization import jsonutils as json
+
+from tempest.common import service_client
+
+
+class TenantsClient(service_client.ServiceClient):
+ api_version = "v2.0"
+
+ def create_tenant(self, name, **kwargs):
+ """Create a tenant
+
+ name (required): New tenant name
+ description: Description of new tenant (default is none)
+ enabled <true|false>: Initial tenant status (default is true)
+ """
+ post_body = {
+ 'name': name,
+ 'description': kwargs.get('description', ''),
+ 'enabled': kwargs.get('enabled', True),
+ }
+ post_body = json.dumps({'tenant': post_body})
+ resp, body = self.post('tenants', post_body)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def delete_tenant(self, tenant_id):
+ """Delete a tenant."""
+ resp, body = self.delete('tenants/%s' % str(tenant_id))
+ self.expected_success(204, resp.status)
+ return service_client.ResponseBody(resp, body)
+
+ def show_tenant(self, tenant_id):
+ """Get tenant details."""
+ resp, body = self.get('tenants/%s' % str(tenant_id))
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def list_tenants(self):
+ """Returns tenants."""
+ resp, body = self.get('tenants')
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def update_tenant(self, tenant_id, **kwargs):
+ """Updates a tenant."""
+ body = self.show_tenant(tenant_id)['tenant']
+ name = kwargs.get('name', body['name'])
+ desc = kwargs.get('description', body['description'])
+ en = kwargs.get('enabled', body['enabled'])
+ post_body = {
+ 'id': tenant_id,
+ 'name': name,
+ 'description': desc,
+ 'enabled': en,
+ }
+ post_body = json.dumps({'tenant': post_body})
+ resp, body = self.post('tenants/%s' % tenant_id, post_body)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def list_tenant_users(self, tenant_id):
+ """List users for a Tenant."""
+ resp, body = self.get('/tenants/%s/users' % tenant_id)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/identity/v3/json/credentials_client.py b/tempest/services/identity/v3/json/credentials_client.py
index 7d4cf9a..753e960 100644
--- a/tempest/services/identity/v3/json/credentials_client.py
+++ b/tempest/services/identity/v3/json/credentials_client.py
@@ -51,7 +51,7 @@
body['credential']['blob'] = json.loads(body['credential']['blob'])
return service_client.ResponseBody(resp, body)
- def get_credential(self, credential_id):
+ def show_credential(self, credential_id):
"""To GET Details of a credential."""
resp, body = self.get('credentials/%s' % credential_id)
self.expected_success(200, resp.status)
diff --git a/tempest/services/identity/v3/json/identity_client.py b/tempest/services/identity/v3/json/identity_client.py
index bbd8804..972db99 100644
--- a/tempest/services/identity/v3/json/identity_client.py
+++ b/tempest/services/identity/v3/json/identity_client.py
@@ -81,13 +81,13 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def update_user_password(self, user_id, password, original_password):
- """Updates a user password."""
- update_user = {
- 'password': password,
- 'original_password': original_password
- }
- update_user = json.dumps({'user': update_user})
+ def update_user_password(self, user_id, **kwargs):
+ """Update a user password
+
+ Available params: see http://developer.openstack.org/
+ api-ref-identity-v3.html#changeUserPassword
+ """
+ update_user = json.dumps({'user': kwargs})
resp, _ = self.post('users/%s/password' % user_id, update_user)
self.expected_success(204, resp.status)
return service_client.ResponseBody(resp)
@@ -394,19 +394,13 @@
self.expected_success(204, resp.status)
return service_client.ResponseBody(resp, body)
- def create_trust(self, trustor_user_id, trustee_user_id, project_id,
- role_names, impersonation, expires_at):
- """Creates a trust."""
- roles = [{'name': n} for n in role_names]
- post_body = {
- 'trustor_user_id': trustor_user_id,
- 'trustee_user_id': trustee_user_id,
- 'project_id': project_id,
- 'impersonation': impersonation,
- 'roles': roles,
- 'expires_at': expires_at
- }
- post_body = json.dumps({'trust': post_body})
+ def create_trust(self, **kwargs):
+ """Creates a trust.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-identity-v3-ext.html#createTrust
+ """
+ post_body = json.dumps({'trust': kwargs})
resp, body = self.post('OS-TRUST/trusts', post_body)
self.expected_success(201, resp.status)
body = json.loads(body)
diff --git a/tempest/services/identity/v3/json/policy_client.py b/tempest/services/identity/v3/json/policy_client.py
index ecc9df7..7927ed5 100644
--- a/tempest/services/identity/v3/json/policy_client.py
+++ b/tempest/services/identity/v3/json/policy_client.py
@@ -44,7 +44,7 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def get_policy(self, policy_id):
+ def show_policy(self, policy_id):
"""Lists out the given policy."""
url = 'policies/%s' % policy_id
resp, body = self.get(url)
diff --git a/tempest/services/identity/v3/json/region_client.py b/tempest/services/identity/v3/json/region_client.py
index 6ccdc31..3595391 100644
--- a/tempest/services/identity/v3/json/region_client.py
+++ b/tempest/services/identity/v3/json/region_client.py
@@ -59,7 +59,7 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def get_region(self, region_id):
+ def show_region(self, region_id):
"""Get region."""
url = 'regions/%s' % region_id
resp, body = self.get(url)
diff --git a/tempest/services/identity/v3/json/service_client.py b/tempest/services/identity/v3/json/services_client.py
similarity index 97%
rename from tempest/services/identity/v3/json/service_client.py
rename to tempest/services/identity/v3/json/services_client.py
index 3dbfe5e..dd65f1d 100644
--- a/tempest/services/identity/v3/json/service_client.py
+++ b/tempest/services/identity/v3/json/services_client.py
@@ -22,7 +22,7 @@
from tempest.common import service_client
-class ServiceClient(service_client.ServiceClient):
+class ServicesClient(service_client.ServiceClient):
api_version = "v3"
def update_service(self, service_id, **kwargs):
diff --git a/tempest/services/image/v2/json/images_client.py b/tempest/services/image/v2/json/images_client.py
index 33bfcb8..72b203a 100644
--- a/tempest/services/image/v2/json/images_client.py
+++ b/tempest/services/image/v2/json/images_client.py
@@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-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
@@ -49,14 +48,6 @@
insecure=self.dscv,
ca_certs=self.ca_certs)
- def _validate_schema(self, body, type='image'):
- if type in ['image', 'images']:
- schema = self.show_schema(type)
- else:
- raise ValueError("%s is not a valid schema type" % type)
-
- jsonschema.validate(body, schema)
-
@property
def http(self):
if self._http is None:
@@ -64,9 +55,12 @@
return self._http
def update_image(self, image_id, patch):
- data = json.dumps(patch)
- self._validate_schema(data)
+ """Update an image.
+ Available params: see http://developer.openstack.org/
+ api-ref-image-v2.html#updateImage-v2
+ """
+ data = json.dumps(patch)
headers = {"Content-Type": "application/openstack-images-v2.0"
"-json-patch"}
resp, body = self.patch('v2/images/%s' % image_id, data, headers)
@@ -74,23 +68,13 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def create_image(self, name, container_format, disk_format, **kwargs):
- params = {
- "name": name,
- "container_format": container_format,
- "disk_format": disk_format,
- }
+ def create_image(self, **kwargs):
+ """Create an image.
- for option in kwargs:
- value = kwargs.get(option)
- if isinstance(value, dict) or isinstance(value, tuple):
- params.update(value)
- else:
- params[option] = value
-
- data = json.dumps(params)
- self._validate_schema(data)
-
+ Available params: see http://developer.openstack.org/
+ api-ref-image-v2.html#createImage-v2
+ """
+ data = json.dumps(kwargs)
resp, body = self.post('v2/images', data)
self.expected_success(201, resp.status)
body = json.loads(body)
@@ -123,7 +107,6 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
- self._validate_schema(body, type='images')
return service_client.ResponseBody(resp, body)
def show_image(self, image_id):
@@ -178,7 +161,12 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def add_image_member(self, image_id, **kwargs):
+ def create_image_member(self, image_id, **kwargs):
+ """Create an image member.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-image-v2.html#createImageMember-v2
+ """
url = 'v2/images/%s/members' % image_id
data = json.dumps(kwargs)
resp, body = self.post(url, data)
@@ -232,8 +220,6 @@
api-ref-image-v2.html#createNamespace-v2
"""
data = json.dumps(kwargs)
- self._validate_schema(data)
-
resp, body = self.post('/v2/metadefs/namespaces', data)
self.expected_success(201, resp.status)
body = json.loads(body)
@@ -257,7 +243,6 @@
params = {'namespace': namespace}
params.update(kwargs)
data = json.dumps(params)
- self._validate_schema(data)
url = '/v2/metadefs/namespaces/%s' % namespace
resp, body = self.put(url, body=data)
self.expected_success(200, resp.status)
diff --git a/tempest/services/network/json/metering_label_rules_client.py b/tempest/services/network/json/metering_label_rules_client.py
new file mode 100644
index 0000000..374a89c
--- /dev/null
+++ b/tempest/services/network/json/metering_label_rules_client.py
@@ -0,0 +1,33 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.services.network.json import base
+
+
+class MeteringLabelRulesClient(base.BaseNetworkClient):
+
+ 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)
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index b525143..cc795bb 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -35,23 +35,6 @@
quotas
"""
- 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}
@@ -174,23 +157,6 @@
message = '(%s) %s' % (caller, message)
raise exceptions.TimeoutException(message)
- def update_quotas(self, tenant_id, **kwargs):
- put_body = {'quota': kwargs}
- uri = '/quotas/%s' % tenant_id
- return self.update_resource(uri, put_body)
-
- def reset_quotas(self, tenant_id):
- 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
@@ -274,15 +240,18 @@
uri = '/ports?device_id=%s' % uuid
return self.list_resources(uri)
- def update_agent(self, agent_id, agent_info):
+ def update_agent(self, agent_id, **kwargs):
"""Update agent
:param agent_info: Agent update information.
E.g {"admin_state_up": True}
"""
+ # TODO(piyush): Current api-site doesn't contain this API description.
+ # After fixing the api-site, we need to fix here also for putting the
+ # link to api-site.
+ # LP: https://bugs.launchpad.net/openstack-api-site/+bug/1526673
uri = '/agents/%s' % agent_id
- agent = {"agent": agent_info}
- return self.update_resource(uri, agent)
+ return self.update_resource(uri, kwargs)
def show_agent(self, agent_id, **fields):
uri = '/agents/%s' % agent_id
@@ -300,10 +269,13 @@
uri = '/routers/%s/l3-agents' % router_id
return self.list_resources(uri)
- def add_router_to_l3_agent(self, agent_id, router_id):
+ def add_router_to_l3_agent(self, agent_id, **kwargs):
+ # TODO(piyush): Current api-site doesn't contain this API description.
+ # After fixing the api-site, we need to fix here also for putting the
+ # link to api-site.
+ # LP: https://bugs.launchpad.net/openstack-api-site/+bug/1526670
uri = '/agents/%s/l3-routers' % agent_id
- post_body = {"router_id": router_id}
- return self.create_resource(uri, post_body)
+ return self.create_resource(uri, kwargs)
def remove_router_from_l3_agent(self, agent_id, router_id):
uri = '/agents/%s/l3-routers/%s' % (agent_id, router_id)
@@ -322,13 +294,14 @@
network_id)
return self.delete_resource(uri)
- def update_extra_routes(self, router_id, routes):
+ def update_extra_routes(self, router_id, **kwargs):
+ """Update Extra routes.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-networking-v2-ext.html#updateExtraRoutes
+ """
uri = '/routers/%s' % router_id
- put_body = {
- 'router': {
- 'routes': routes
- }
- }
+ put_body = {'router': kwargs}
return self.update_resource(uri, put_body)
def delete_extra_routes(self, router_id):
@@ -340,10 +313,13 @@
}
return self.update_resource(uri, put_body)
- def add_dhcp_agent_to_network(self, agent_id, network_id):
- post_body = {'network_id': network_id}
+ def add_dhcp_agent_to_network(self, agent_id, **kwargs):
+ # TODO(piyush): Current api-site doesn't contain this API description.
+ # After fixing the api-site, we need to fix here also for putting the
+ # link to api-site.
+ # LP: https://bugs.launchpad.net/openstack-api-site/+bug/1526212
uri = '/agents/%s/dhcp-networks' % agent_id
- return self.create_resource(uri, post_body)
+ return self.create_resource(uri, kwargs)
def list_subnetpools(self, **filters):
uri = '/subnetpools'
diff --git a/tempest/services/network/json/quotas_client.py b/tempest/services/network/json/quotas_client.py
new file mode 100644
index 0000000..9b65a54
--- /dev/null
+++ b/tempest/services/network/json/quotas_client.py
@@ -0,0 +1,35 @@
+# Copyright 2015 NEC Corporation. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.services.network.json import base
+
+
+class QuotasClient(base.BaseNetworkClient):
+
+ def update_quotas(self, tenant_id, **kwargs):
+ put_body = {'quota': kwargs}
+ uri = '/quotas/%s' % tenant_id
+ return self.update_resource(uri, put_body)
+
+ def reset_quotas(self, tenant_id):
+ 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)
diff --git a/tempest/services/telemetry/json/telemetry_client.py b/tempest/services/telemetry/json/telemetry_client.py
index 05530b1..abdeba2 100644
--- a/tempest/services/telemetry/json/telemetry_client.py
+++ b/tempest/services/telemetry/json/telemetry_client.py
@@ -30,17 +30,6 @@
def serialize(self, body):
return json.dumps(body)
- def add_sample(self, sample_list, meter_name, meter_unit, volume,
- sample_type, resource_id, **kwargs):
- sample = {"counter_name": meter_name, "counter_unit": meter_unit,
- "counter_volume": volume, "counter_type": sample_type,
- "resource_id": resource_id}
- for key in kwargs:
- sample[key] = kwargs[key]
-
- sample_list.append(self.serialize(sample))
- return sample_list
-
def create_sample(self, meter_name, sample_list):
uri = "%s/meters/%s" % (self.uri_prefix, meter_name)
body = self.serialize(sample_list)
diff --git a/tempest/services/volume/base/admin/base_hosts_client.py b/tempest/services/volume/base/admin/base_hosts_client.py
index 97bb007..074f87f 100644
--- a/tempest/services/volume/base/admin/base_hosts_client.py
+++ b/tempest/services/volume/base/admin/base_hosts_client.py
@@ -19,7 +19,7 @@
from tempest.common import service_client
-class BaseVolumeHostsClient(service_client.ServiceClient):
+class BaseHostsClient(service_client.ServiceClient):
"""Client class to send CRUD Volume Hosts API requests"""
def list_hosts(self, **params):
diff --git a/tempest/services/volume/base/admin/base_quotas_client.py b/tempest/services/volume/base/admin/base_quotas_client.py
index ad8ba03..e063a31 100644
--- a/tempest/services/volume/base/admin/base_quotas_client.py
+++ b/tempest/services/volume/base/admin/base_quotas_client.py
@@ -18,7 +18,7 @@
from tempest.common import service_client
-class BaseVolumeQuotasClient(service_client.ServiceClient):
+class BaseQuotasClient(service_client.ServiceClient):
"""Client class to send CRUD Volume Quotas API requests"""
TYPE = "json"
diff --git a/tempest/services/volume/base/admin/base_services_client.py b/tempest/services/volume/base/admin/base_services_client.py
index 1790421..3626469 100644
--- a/tempest/services/volume/base/admin/base_services_client.py
+++ b/tempest/services/volume/base/admin/base_services_client.py
@@ -19,9 +19,9 @@
from tempest.common import service_client
-class BaseVolumesServicesClient(service_client.ServiceClient):
+class BaseServicesClient(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/volume/base/admin/base_types_client.py b/tempest/services/volume/base/admin/base_types_client.py
index 3a0dcfe..867273e 100644
--- a/tempest/services/volume/base/admin/base_types_client.py
+++ b/tempest/services/volume/base/admin/base_types_client.py
@@ -20,7 +20,7 @@
from tempest.common import service_client
-class BaseVolumeTypesClient(service_client.ServiceClient):
+class BaseTypesClient(service_client.ServiceClient):
"""Client class to send CRUD Volume Types API requests"""
def is_resource_deleted(self, resource):
diff --git a/tempest/services/volume/base/base_availability_zone_client.py b/tempest/services/volume/base/base_availability_zone_client.py
index d5a2fda..b63fdc2 100644
--- a/tempest/services/volume/base/base_availability_zone_client.py
+++ b/tempest/services/volume/base/base_availability_zone_client.py
@@ -18,7 +18,7 @@
from tempest.common import service_client
-class BaseVolumeAvailabilityZoneClient(service_client.ServiceClient):
+class BaseAvailabilityZoneClient(service_client.ServiceClient):
def list_availability_zones(self):
resp, body = self.get('os-availability-zone')
diff --git a/tempest/services/volume/base/base_backups_client.py b/tempest/services/volume/base/base_backups_client.py
index be926e6..fc9a40a 100644
--- a/tempest/services/volume/base/base_backups_client.py
+++ b/tempest/services/volume/base/base_backups_client.py
@@ -25,26 +25,17 @@
class BaseBackupsClient(service_client.ServiceClient):
"""Client class to send CRUD Volume backup API requests"""
- def create_backup(self, volume_id, container=None, name=None,
- description=None):
+ def create_backup(self, **kwargs):
"""Creates a backup of volume."""
- post_body = {'volume_id': volume_id}
- if container:
- post_body['container'] = container
- if name:
- post_body['name'] = name
- if description:
- post_body['description'] = description
- post_body = json.dumps({'backup': post_body})
+ post_body = json.dumps({'backup': kwargs})
resp, body = self.post('backups', post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
return service_client.ResponseBody(resp, body)
- def restore_backup(self, backup_id, volume_id=None):
+ def restore_backup(self, backup_id, **kwargs):
"""Restore volume from backup."""
- post_body = {'volume_id': volume_id}
- post_body = json.dumps({'restore': post_body})
+ post_body = json.dumps({'restore': kwargs})
resp, body = self.post('backups/%s/restore' % (backup_id), post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
@@ -82,11 +73,9 @@
self.expected_success(200, resp.status)
return service_client.ResponseBody(resp, body)
- def import_backup(self, backup_service, backup_url):
+ def import_backup(self, **kwargs):
"""Import backup metadata record."""
- post_body = {'backup_service': backup_service,
- 'backup_url': backup_url}
- post_body = json.dumps({'backup-record': post_body})
+ post_body = json.dumps({'backup-record': kwargs})
resp, body = self.post("backups/import_record", post_body)
body = json.loads(body)
self.expected_success(201, resp.status)
diff --git a/tempest/services/volume/v1/json/admin/hosts_client.py b/tempest/services/volume/v1/json/admin/hosts_client.py
index 1b685bd..3b52968 100644
--- a/tempest/services/volume/v1/json/admin/hosts_client.py
+++ b/tempest/services/volume/v1/json/admin/hosts_client.py
@@ -16,5 +16,5 @@
from tempest.services.volume.base.admin import base_hosts_client
-class VolumeHostsClient(base_hosts_client.BaseVolumeHostsClient):
+class HostsClient(base_hosts_client.BaseHostsClient):
"""Client class to send CRUD Volume Host API V1 requests"""
diff --git a/tempest/services/volume/v1/json/admin/quotas_client.py b/tempest/services/volume/v1/json/admin/quotas_client.py
index 5ca074e..27fc301 100644
--- a/tempest/services/volume/v1/json/admin/quotas_client.py
+++ b/tempest/services/volume/v1/json/admin/quotas_client.py
@@ -15,5 +15,5 @@
from tempest.services.volume.base.admin import base_quotas_client
-class VolumeQuotasClient(base_quotas_client.BaseVolumeQuotasClient):
+class QuotasClient(base_quotas_client.BaseQuotasClient):
"""Client class to send CRUD Volume Type API V1 requests"""
diff --git a/tempest/services/volume/v1/json/admin/services_client.py b/tempest/services/volume/v1/json/admin/services_client.py
index efe02d8..2bffd55 100644
--- a/tempest/services/volume/v1/json/admin/services_client.py
+++ b/tempest/services/volume/v1/json/admin/services_client.py
@@ -16,5 +16,5 @@
from tempest.services.volume.base.admin import base_services_client
-class VolumesServicesClient(base_services_client.BaseVolumesServicesClient):
+class ServicesClient(base_services_client.BaseServicesClient):
"""Volume V1 volume services client"""
diff --git a/tempest/services/volume/v1/json/admin/types_client.py b/tempest/services/volume/v1/json/admin/types_client.py
index 4bd1579..0e84296 100644
--- a/tempest/services/volume/v1/json/admin/types_client.py
+++ b/tempest/services/volume/v1/json/admin/types_client.py
@@ -16,5 +16,5 @@
from tempest.services.volume.base.admin import base_types_client
-class VolumeTypesClient(base_types_client.BaseVolumeTypesClient):
+class TypesClient(base_types_client.BaseTypesClient):
"""Volume V1 Volume Types client"""
diff --git a/tempest/services/volume/v1/json/availability_zone_client.py b/tempest/services/volume/v1/json/availability_zone_client.py
index d8180fa..3a27027 100644
--- a/tempest/services/volume/v1/json/availability_zone_client.py
+++ b/tempest/services/volume/v1/json/availability_zone_client.py
@@ -16,6 +16,6 @@
from tempest.services.volume.base import base_availability_zone_client
-class VolumeAvailabilityZoneClient(
- base_availability_zone_client.BaseVolumeAvailabilityZoneClient):
+class AvailabilityZoneClient(
+ base_availability_zone_client.BaseAvailabilityZoneClient):
"""Volume V1 availability zone client."""
diff --git a/tempest/services/volume/v2/json/admin/hosts_client.py b/tempest/services/volume/v2/json/admin/hosts_client.py
index 7bdc6f7..e092c6a 100644
--- a/tempest/services/volume/v2/json/admin/hosts_client.py
+++ b/tempest/services/volume/v2/json/admin/hosts_client.py
@@ -16,6 +16,6 @@
from tempest.services.volume.base.admin import base_hosts_client
-class VolumeHostsV2Client(base_hosts_client.BaseVolumeHostsClient):
+class HostsClient(base_hosts_client.BaseHostsClient):
"""Client class to send CRUD Volume V2 API requests"""
api_version = "v2"
diff --git a/tempest/services/volume/v2/json/admin/quotas_client.py b/tempest/services/volume/v2/json/admin/quotas_client.py
index b2d3604..11e0e22 100644
--- a/tempest/services/volume/v2/json/admin/quotas_client.py
+++ b/tempest/services/volume/v2/json/admin/quotas_client.py
@@ -16,6 +16,6 @@
from tempest.services.volume.base.admin import base_quotas_client
-class VolumeQuotasV2Client(base_quotas_client.BaseVolumeQuotasClient):
+class QuotasClient(base_quotas_client.BaseQuotasClient):
"""Client class to send CRUD Volume V2 API requests"""
api_version = "v2"
diff --git a/tempest/services/volume/v2/json/admin/services_client.py b/tempest/services/volume/v2/json/admin/services_client.py
index 3912c9d..db19ba9 100644
--- a/tempest/services/volume/v2/json/admin/services_client.py
+++ b/tempest/services/volume/v2/json/admin/services_client.py
@@ -16,6 +16,6 @@
from tempest.services.volume.base.admin import base_services_client
-class VolumesServicesV2Client(base_services_client.BaseVolumesServicesClient):
+class ServicesClient(base_services_client.BaseServicesClient):
"""Client class to send CRUD Volume V2 API requests"""
api_version = "v2"
diff --git a/tempest/services/volume/v2/json/admin/types_client.py b/tempest/services/volume/v2/json/admin/types_client.py
index d9eba7e..ecf5131 100644
--- a/tempest/services/volume/v2/json/admin/types_client.py
+++ b/tempest/services/volume/v2/json/admin/types_client.py
@@ -16,6 +16,6 @@
from tempest.services.volume.base.admin import base_types_client
-class VolumeTypesV2Client(base_types_client.BaseVolumeTypesClient):
+class TypesClient(base_types_client.BaseTypesClient):
"""Client class to send CRUD Volume V2 API requests"""
api_version = "v2"
diff --git a/tempest/services/volume/v2/json/availability_zone_client.py b/tempest/services/volume/v2/json/availability_zone_client.py
index a4fc9fe..905ebdc 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.base import base_availability_zone_client
-class VolumeV2AvailabilityZoneClient(
- base_availability_zone_client.BaseVolumeAvailabilityZoneClient):
+class AvailabilityZoneClient(
+ base_availability_zone_client.BaseAvailabilityZoneClient):
api_version = "v2"
diff --git a/tempest/services/volume/v2/json/backups_client.py b/tempest/services/volume/v2/json/backups_client.py
index 15d363b..78bab82 100644
--- a/tempest/services/volume/v2/json/backups_client.py
+++ b/tempest/services/volume/v2/json/backups_client.py
@@ -16,6 +16,6 @@
from tempest.services.volume.base import base_backups_client
-class BackupsClientV2(base_backups_client.BaseBackupsClient):
+class BackupsClient(base_backups_client.BaseBackupsClient):
"""Client class to send CRUD Volume V2 API requests"""
api_version = "v2"
diff --git a/tempest/services/volume/v2/json/extensions_client.py b/tempest/services/volume/v2/json/extensions_client.py
index 004b232..245906f 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.base import base_extensions_client
-class ExtensionsV2Client(base_extensions_client.BaseExtensionsClient):
+class ExtensionsClient(base_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 e8b680a..3c0f74f 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.base import base_qos_client
-class QosSpecsV2Client(base_qos_client.BaseQosSpecsClient):
+class QosSpecsClient(base_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 28a9e98..a2d415f 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.base import base_snapshots_client
-class SnapshotsV2Client(base_snapshots_client.BaseSnapshotsClient):
+class SnapshotsClient(base_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 51daa94..b7d9dfb 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.base import base_volumes_client
-class VolumesV2Client(base_volumes_client.BaseVolumesClient):
+class VolumesClient(base_volumes_client.BaseVolumesClient):
"""Client class to send CRUD Volume V2 API requests"""
api_version = "v2"
create_resp = 202
diff --git a/tempest/stress/README.rst b/tempest/stress/README.rst
index 4f1f56c..33842fd 100644
--- a/tempest/stress/README.rst
+++ b/tempest/stress/README.rst
@@ -33,17 +33,17 @@
The stress test framework can automatically discover test inside the tempest
test suite. All test flag with the `@stresstest` decorator will be executed.
-In order to use this discovery you have to be in the tempest root directory
-and execute the following:
+In order to use this discovery you have to install tempest CLI, be in the
+tempest root directory and execute the following:
- run-tempest-stress -a -d 30
+ tempest run-stress -a -d 30
Running the sample test
-----------------------
To test installation, do the following:
- run-tempest-stress -t tempest/stress/etc/server-create-destroy-test.json -d 30
+ tempest run-stress -t tempest/stress/etc/server-create-destroy-test.json -d 30
This sample test tries to create a few VMs and kill a few VMs.
diff --git a/tempest/stress/actions/ssh_floating.py b/tempest/stress/actions/ssh_floating.py
index 6bac570..4f8c6bd 100644
--- a/tempest/stress/actions/ssh_floating.py
+++ b/tempest/stress/actions/ssh_floating.py
@@ -91,7 +91,7 @@
self.logger.info("deleted %s" % self.server_id)
def _create_sec_group(self):
- sec_grp_cli = self.manager.security_groups_client
+ sec_grp_cli = self.manager.compute_security_groups_client
s_name = data_utils.rand_name('sec_grp')
s_description = data_utils.rand_name('desc')
self.sec_grp = sec_grp_cli.create_security_group(
@@ -103,7 +103,7 @@
from_port=-1, to_port=-1)
def _destroy_sec_grp(self):
- sec_grp_cli = self.manager.security_groups_client
+ sec_grp_cli = self.manager.compute_security_groups_client
sec_grp_cli.delete_security_group(self.sec_grp['id'])
def _create_floating_ip(self):
diff --git a/tempest/stress/actions/volume_attach_verify.py b/tempest/stress/actions/volume_attach_verify.py
index fa0bb8b..8bbbfc4 100644
--- a/tempest/stress/actions/volume_attach_verify.py
+++ b/tempest/stress/actions/volume_attach_verify.py
@@ -54,7 +54,7 @@
self.logger.info("deleted server: %s" % self.server_id)
def _create_sec_group(self):
- sec_grp_cli = self.manager.security_groups_client
+ sec_grp_cli = self.manager.compute_security_groups_client
s_name = data_utils.rand_name('sec_grp')
s_description = data_utils.rand_name('desc')
self.sec_grp = sec_grp_cli.create_security_group(
@@ -66,7 +66,7 @@
from_port=-1, to_port=-1)
def _destroy_sec_grp(self):
- sec_grp_cli = self.manager.security_groups_client
+ sec_grp_cli = self.manager.compute_security_groups_client
sec_grp_cli.delete_security_group(self.sec_grp['id'])
def _create_floating_ip(self):
@@ -161,7 +161,7 @@
self._create_sec_group()
self._create_keypair()
private_key = self.key['private_key']
- username = CONF.compute.image_ssh_user
+ username = CONF.validation.image_ssh_user
self.remote_client = remote_client.RemoteClient(self.floating['ip'],
username,
pkey=private_key)
diff --git a/tempest/stress/cleanup.py b/tempest/stress/cleanup.py
index 993359d..5c25e32 100644
--- a/tempest/stress/cleanup.py
+++ b/tempest/stress/cleanup.py
@@ -48,7 +48,7 @@
except Exception:
pass
- secgrp_client = admin_manager.security_groups_client
+ secgrp_client = admin_manager.compute_security_groups_client
secgrp = (secgrp_client.list_security_groups(all_tenants=True)
['security_groups'])
secgrp_del = [grp for grp in secgrp if grp['name'] != 'default']
@@ -74,12 +74,11 @@
for user in users:
if user['name'].startswith("stress_user"):
admin_manager.identity_client.delete_user(user['id'])
-
- tenants = admin_manager.identity_client.list_tenants()['tenants']
+ tenants = admin_manager.tenants_client.list_tenants()['tenants']
LOG.info("Cleanup::remove %s tenants" % len(tenants))
for tenant in tenants:
if tenant['name'].startswith("stress_tenant"):
- admin_manager.identity_client.delete_tenant(tenant['id'])
+ admin_manager.tenants_client.delete_tenant(tenant['id'])
# We have to delete snapshots first or
# volume deletion may block
diff --git a/tempest/stress/driver.py b/tempest/stress/driver.py
index 8359efd..a550d71 100644
--- a/tempest/stress/driver.py
+++ b/tempest/stress/driver.py
@@ -146,14 +146,18 @@
password = "pass"
if CONF.identity.auth_version == 'v2':
identity_client = admin_manager.identity_client
+ projects_client = admin_manager.tenants_client
+ roles_client = admin_manager.roles_client
else:
identity_client = admin_manager.identity_v3_client
+ projects_client = None
+ roles_client = None
credentials_client = cred_client.get_creds_client(
- identity_client)
+ identity_client, projects_client, roles_client)
project = credentials_client.create_project(
name=tenant_name, description=tenant_name)
user = credentials_client.create_user(username, password,
- project['id'], "email")
+ project, "email")
# Add roles specified in config file
for conf_role in CONF.auth.tempest_roles:
credentials_client.assign_user_role(user, project,
diff --git a/tempest/test.py b/tempest/test.py
index 30eb93d..407df3b 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -436,15 +436,21 @@
"""
if CONF.identity.auth_version == 'v2':
client = self.os_admin.identity_client
+ project_client = self.os_admin.tenants_client
+ roles_client = self.os_admin.roles_client
else:
client = self.os_admin.identity_v3_client
+ project_client = None
+ roles_client = None
try:
domain = client.auth_provider.credentials.project_domain_name
except AttributeError:
domain = 'Default'
- return cred_client.get_creds_client(client, domain)
+ return cred_client.get_creds_client(client, project_client,
+ roles_client,
+ project_domain_name=domain)
@classmethod
def get_identity_version(cls):
diff --git a/tempest/test_discover/test_discover.py b/tempest/test_discover/test_discover.py
index dac7d91..330f370 100644
--- a/tempest/test_discover/test_discover.py
+++ b/tempest/test_discover/test_discover.py
@@ -30,8 +30,7 @@
base_path = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
base_path = os.path.split(base_path)[0]
# Load local tempest tests
- for test_dir in ['tempest/api', 'tempest/scenario',
- 'tempest/thirdparty']:
+ for test_dir in ['tempest/api', 'tempest/scenario']:
full_test_dir = os.path.join(base_path, test_dir)
if not pattern:
suite.addTests(loader.discover(full_test_dir,
diff --git a/tempest/tests/cmd/test_javelin.py b/tempest/tests/cmd/test_javelin.py
index d328d56..56bc96c 100644
--- a/tempest/tests/cmd/test_javelin.py
+++ b/tempest/tests/cmd/test_javelin.py
@@ -85,24 +85,24 @@
class TestCreateResources(JavelinUnitTest):
def test_create_tenants(self):
- self.fake_client.identity.list_tenants.return_value = {'tenants': []}
+ self.fake_client.tenants.list_tenants.return_value = {'tenants': []}
self.useFixture(mockpatch.PatchObject(javelin, "keystone_admin",
return_value=self.fake_client))
javelin.create_tenants([self.fake_object['name']])
- mocked_function = self.fake_client.identity.create_tenant
+ mocked_function = self.fake_client.tenants.create_tenant
mocked_function.assert_called_once_with(self.fake_object['name'])
def test_create_duplicate_tenant(self):
- self.fake_client.identity.list_tenants.return_value = {'tenants': [
+ self.fake_client.tenants.list_tenants.return_value = {'tenants': [
{'name': self.fake_object['name']}]}
self.useFixture(mockpatch.PatchObject(javelin, "keystone_admin",
return_value=self.fake_client))
javelin.create_tenants([self.fake_object['name']])
- mocked_function = self.fake_client.identity.create_tenant
+ mocked_function = self.fake_client.tenants.create_tenant
self.assertFalse(mocked_function.called)
def test_create_users(self):
@@ -299,7 +299,7 @@
return_value=fake_auth))
javelin.destroy_tenants([fake_tenant])
- mocked_function = fake_auth.identity.delete_tenant
+ mocked_function = fake_auth.tenants.delete_tenant
mocked_function.assert_called_once_with(fake_tenant['id'])
def test_destroy_users(self):
@@ -308,7 +308,7 @@
fake_tenant = self.fake_object['tenant']
fake_auth = self.fake_client
- fake_auth.identity.list_tenants.return_value = \
+ fake_auth.tenants.list_tenants.return_value = \
{'tenants': [fake_tenant]}
fake_auth.identity.list_users.return_value = {'users': [fake_user]}
diff --git a/tempest/tests/common/test_dynamic_creds.py b/tempest/tests/common/test_dynamic_creds.py
index 78064a7..d520985 100644
--- a/tempest/tests/common/test_dynamic_creds.py
+++ b/tempest/tests/common/test_dynamic_creds.py
@@ -24,6 +24,10 @@
from tempest import exceptions
from tempest.services.identity.v2.json import identity_client as \
json_iden_client
+from tempest.services.identity.v2.json import roles_client as \
+ json_roles_client
+from tempest.services.identity.v2.json import tenants_client as \
+ json_tenants_client
from tempest.services.network.json import network_client as json_network_client
from tempest.tests import base
from tempest.tests import fake_config
@@ -74,7 +78,7 @@
def _mock_tenant_create(self, id, name):
tenant_fix = self.useFixture(mockpatch.PatchObject(
- json_iden_client.IdentityClient,
+ json_tenants_client.TenantsClient,
'create_tenant',
return_value=(service_client.ResponseBody
(200, {'tenant': {'id': id, 'name': name}}))))
@@ -82,7 +86,7 @@
def _mock_list_roles(self, id, name):
roles_fix = self.useFixture(mockpatch.PatchObject(
- json_iden_client.IdentityClient,
+ json_roles_client.RolesClient,
'list_roles',
return_value=(service_client.ResponseBody
(200,
@@ -93,7 +97,7 @@
def _mock_list_2_roles(self):
roles_fix = self.useFixture(mockpatch.PatchObject(
- json_iden_client.IdentityClient,
+ json_roles_client.RolesClient,
'list_roles',
return_value=(service_client.ResponseBody
(200,
@@ -104,7 +108,7 @@
def _mock_assign_user_role(self):
tenant_fix = self.useFixture(mockpatch.PatchObject(
- json_iden_client.IdentityClient,
+ json_roles_client.RolesClient,
'assign_user_role',
return_value=(service_client.ResponseBody
(200, {}))))
@@ -112,7 +116,7 @@
def _mock_list_role(self):
roles_fix = self.useFixture(mockpatch.PatchObject(
- json_iden_client.IdentityClient,
+ json_roles_client.RolesClient,
'list_roles',
return_value=(service_client.ResponseBody
(200, {'roles': [{'id': '1',
@@ -176,11 +180,11 @@
self._mock_user_create('1234', 'fake_admin_user')
self._mock_tenant_create('1234', 'fake_admin_tenant')
- user_mock = mock.patch.object(json_iden_client.IdentityClient,
+ user_mock = mock.patch.object(json_roles_client.RolesClient,
'assign_user_role')
user_mock.start()
self.addCleanup(user_mock.stop)
- with mock.patch.object(json_iden_client.IdentityClient,
+ with mock.patch.object(json_roles_client.RolesClient,
'assign_user_role') as user_mock:
admin_creds = creds.get_admin_creds()
user_mock.assert_has_calls([
@@ -199,11 +203,11 @@
self._mock_user_create('1234', 'fake_role_user')
self._mock_tenant_create('1234', 'fake_role_tenant')
- user_mock = mock.patch.object(json_iden_client.IdentityClient,
+ user_mock = mock.patch.object(json_roles_client.RolesClient,
'assign_user_role')
user_mock.start()
self.addCleanup(user_mock.stop)
- with mock.patch.object(json_iden_client.IdentityClient,
+ with mock.patch.object(json_roles_client.RolesClient,
'assign_user_role') as user_mock:
role_creds = creds.get_creds_by_roles(
roles=['role1', 'role2'])
@@ -240,8 +244,8 @@
'tempest.services.identity.v2.json.identity_client.'
'IdentityClient.delete_user')
tenant_mock = self.patch(
- 'tempest.services.identity.v2.json.identity_client.'
- 'IdentityClient.delete_tenant')
+ 'tempest.services.identity.v2.json.tenants_client.'
+ 'TenantsClient.delete_tenant')
creds.clear_creds()
# Verify user delete calls
calls = user_mock.mock_calls
@@ -371,8 +375,8 @@
creds.get_admin_creds()
self.patch('tempest.services.identity.v2.json.identity_client.'
'IdentityClient.delete_user')
- self.patch('tempest.services.identity.v2.json.identity_client.'
- 'IdentityClient.delete_tenant')
+ self.patch('tempest.services.identity.v2.json.tenants_client.'
+ 'TenantsClient.delete_tenant')
net = mock.patch.object(creds.networks_admin_client,
'delete_network')
net_mock = net.start()
diff --git a/tempest/tests/common/test_service_clients.py b/tempest/tests/common/test_service_clients.py
index f82e09c..430ef0d 100644
--- a/tempest/tests/common/test_service_clients.py
+++ b/tempest/tests/common/test_service_clients.py
@@ -17,13 +17,7 @@
import six
from tempest.services.baremetal.v1.json import baremetal_client
-from tempest.services.compute.json import floating_ips_client
-from tempest.services.compute.json import interfaces_client
-from tempest.services.compute.json import security_group_rules_client
-from tempest.services.compute.json import server_groups_client
from tempest.services.compute.json import servers_client
-from tempest.services.compute.json import volumes_client \
- as compute_volumes_client
from tempest.services.data_processing.v1_1 import data_processing_client
from tempest.services.database.json import flavors_client as db_flavor_client
from tempest.services.database.json import versions_client as db_version_client
@@ -35,7 +29,7 @@
identity_v3_identity_client
from tempest.services.identity.v3.json import policy_client
from tempest.services.identity.v3.json import region_client
-from tempest.services.identity.v3.json import service_client
+from tempest.services.identity.v3.json import services_client
from tempest.services.image.v1.json import images_client
from tempest.services.image.v2.json import images_client as images_v2_client
from tempest.services.messaging.json import messaging_client
@@ -90,12 +84,7 @@
def test_service_client_creations_with_specified_args(self, mock_init):
test_clients = [
baremetal_client.BaremetalClient,
- floating_ips_client.FloatingIPsClient,
- interfaces_client.InterfacesClient,
- security_group_rules_client.SecurityGroupRulesClient,
- server_groups_client.ServerGroupsClient,
servers_client.ServersClient,
- compute_volumes_client.VolumesClient,
data_processing_client.DataProcessingClient,
db_flavor_client.DatabaseFlavorsClient,
db_version_client.DatabaseVersionsClient,
@@ -108,32 +97,32 @@
telemetry_client.TelemetryClient,
alarming_client.AlarmingClient,
qos_client.QosSpecsClient,
- volume_hosts_client.VolumeHostsClient,
- volume_quotas_client.VolumeQuotasClient,
- volume_services_client.VolumesServicesClient,
- volume_types_client.VolumeTypesClient,
- volume_az_client.VolumeAvailabilityZoneClient,
+ volume_hosts_client.HostsClient,
+ volume_quotas_client.QuotasClient,
+ volume_services_client.ServicesClient,
+ volume_types_client.TypesClient,
+ volume_az_client.AvailabilityZoneClient,
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.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,
+ volume_v2_hosts_client.HostsClient,
+ volume_v2_quotas_client.QuotasClient,
+ volume_v2_services_client.ServicesClient,
+ volume_v2_types_client.TypesClient,
+ volume_v2_az_client.AvailabilityZoneClient,
+ volume_v2_backups_client.BackupsClient,
+ volume_v2_extensions_client.ExtensionsClient,
+ volume_v2_qos_client.QosSpecsClient,
+ volume_v2_snapshots_client.SnapshotsClient,
+ volume_v2_volumes_client.VolumesClient,
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,
+ services_client.ServicesClient,
images_client.ImagesClient,
images_v2_client.ImagesClientV2
]
diff --git a/tempest/tests/common/utils/linux/test_remote_client.py b/tempest/tests/common/utils/linux/test_remote_client.py
index e596aab..9c2b99e 100644
--- a/tempest/tests/common/utils/linux/test_remote_client.py
+++ b/tempest/tests/common/utils/linux/test_remote_client.py
@@ -29,7 +29,7 @@
self.useFixture(fake_config.ConfigFixture())
self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
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('network_for_ssh', 'public', group='validation')
cfg.CONF.set_default('connect_timeout', 1, group='validation')
self.conn = remote_client.RemoteClient('127.0.0.1', 'user', 'pass')
@@ -79,7 +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('grep -c processor /proc/cpuinfo')
+ 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/services/compute/test_base_compute_client.py b/tempest/tests/services/compute/test_base_compute_client.py
new file mode 100644
index 0000000..13461e4
--- /dev/null
+++ b/tempest/tests/services/compute/test_base_compute_client.py
@@ -0,0 +1,72 @@
+# 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
+import mock
+from tempest_lib.common import rest_client
+
+from tempest.services.compute.json import base as base_compute_client
+from tempest.tests import fake_auth_provider
+from tempest.tests.services.compute import base
+
+
+class TestClientWithoutMicroversionHeader(base.BaseComputeServiceTest):
+
+ def setUp(self):
+ super(TestClientWithoutMicroversionHeader, self).setUp()
+ fake_auth = fake_auth_provider.FakeAuthProvider()
+ self.client = base_compute_client.BaseComputeClient(
+ fake_auth, 'compute', 'regionOne')
+
+ def test_no_microverion_header(self):
+ header = self.client.get_headers()
+ self.assertNotIn('X-OpenStack-Nova-API-Version', header)
+
+ def test_no_microverion_header_in_raw_request(self):
+ def raw_request(*args, **kwargs):
+ self.assertNotIn('X-OpenStack-Nova-API-Version', kwargs['headers'])
+ return (httplib2.Response({'status': 200}), {})
+
+ with mock.patch.object(rest_client.RestClient,
+ 'raw_request') as mock_get:
+ mock_get.side_effect = raw_request
+ self.client.get('fake_url')
+
+
+class TestClientWithMicroversionHeader(base.BaseComputeServiceTest):
+
+ def setUp(self):
+ super(TestClientWithMicroversionHeader, self).setUp()
+ fake_auth = fake_auth_provider.FakeAuthProvider()
+ self.client = base_compute_client.BaseComputeClient(
+ fake_auth, 'compute', 'regionOne')
+ self.client.api_microversion = '2.2'
+
+ def test_microverion_header(self):
+ header = self.client.get_headers()
+ self.assertIn('X-OpenStack-Nova-API-Version', header)
+ self.assertEqual(self.client.api_microversion,
+ header['X-OpenStack-Nova-API-Version'])
+
+ def test_microverion_header_in_raw_request(self):
+ def raw_request(*args, **kwargs):
+ self.assertIn('X-OpenStack-Nova-API-Version', kwargs['headers'])
+ self.assertEqual(self.client.api_microversion,
+ kwargs['headers']['X-OpenStack-Nova-API-Version'])
+ return (httplib2.Response({'status': 200}), {})
+
+ with mock.patch.object(rest_client.RestClient,
+ 'raw_request') as mock_get:
+ mock_get.side_effect = raw_request
+ self.client.get('fake_url')
diff --git a/tempest/tests/services/compute/test_floating_ips_client.py b/tempest/tests/services/compute/test_floating_ips_client.py
deleted file mode 100644
index ee22004..0000000
--- a/tempest/tests/services/compute/test_floating_ips_client.py
+++ /dev/null
@@ -1,113 +0,0 @@
-# Copyright 2015 IBM Corp.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from oslotest import mockpatch
-from tempest_lib import exceptions as lib_exc
-
-from tempest.services.compute.json import floating_ips_client
-from tempest.tests import fake_auth_provider
-from tempest.tests.services.compute import base
-
-
-class TestFloatingIpsClient(base.BaseComputeServiceTest):
-
- floating_ip = {"fixed_ip": None,
- "id": "46d61064-13ba-4bf0-9557-69de824c3d6f",
- "instance_id": "a1daa443-a6bb-463e-aea2-104b7d912eb8",
- "ip": "10.10.10.1",
- "pool": "nova"}
-
- def setUp(self):
- super(TestFloatingIpsClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = floating_ips_client.FloatingIPsClient(
- fake_auth, 'compute', 'regionOne')
-
- def _test_list_floating_ips(self, bytes_body=False):
- expected = {'floating_ips': [TestFloatingIpsClient.floating_ip]}
- self.check_service_client_function(
- self.client.list_floating_ips,
- 'tempest.common.service_client.ServiceClient.get',
- expected,
- bytes_body)
-
- def test_list_floating_ips_str_body(self):
- self._test_list_floating_ips(bytes_body=False)
-
- def test_list_floating_ips_byte_body(self):
- self._test_list_floating_ips(bytes_body=True)
-
- def _test_show_floating_ip(self, bytes_body=False):
- expected = {"floating_ip": TestFloatingIpsClient.floating_ip}
- self.check_service_client_function(
- self.client.show_floating_ip,
- 'tempest.common.service_client.ServiceClient.get',
- expected,
- bytes_body,
- floating_ip_id='a1daa443-a6bb-463e-aea2-104b7d912eb8')
-
- def test_show_floating_ip_str_body(self):
- self._test_show_floating_ip(bytes_body=False)
-
- def test_show_floating_ip_byte_body(self):
- self._test_show_floating_ip(bytes_body=True)
-
- def _test_create_floating_ip(self, bytes_body=False):
- expected = {"floating_ip": TestFloatingIpsClient.floating_ip}
- self.check_service_client_function(
- self.client.create_floating_ip,
- 'tempest.common.service_client.ServiceClient.post',
- expected,
- bytes_body,
- pool_name='nova')
-
- def test_create_floating_ip_str_body(self):
- self._test_create_floating_ip(bytes_body=False)
-
- def test_create_floating_ip_byte_body(self):
- self._test_create_floating_ip(bytes_body=True)
-
- def test_delete_floating_ip(self):
- self.check_service_client_function(
- self.client.delete_floating_ip,
- 'tempest.common.service_client.ServiceClient.delete',
- {}, status=202, floating_ip_id='fake-id')
-
- def test_associate_floating_ip_to_server(self):
- self.check_service_client_function(
- self.client.associate_floating_ip_to_server,
- 'tempest.common.service_client.ServiceClient.post',
- {}, status=202, floating_ip='10.10.10.1',
- server_id='c782b7a9-33cd-45f0-b795-7f87f456408b')
-
- def test_disassociate_floating_ip_from_server(self):
- self.check_service_client_function(
- self.client.disassociate_floating_ip_from_server,
- 'tempest.common.service_client.ServiceClient.post',
- {}, status=202, floating_ip='10.10.10.1',
- server_id='c782b7a9-33cd-45f0-b795-7f87f456408b')
-
- def test_is_resource_deleted_true(self):
- self.useFixture(mockpatch.Patch(
- 'tempest.services.compute.json.floating_ips_client.'
- 'FloatingIPsClient.show_floating_ip',
- side_effect=lib_exc.NotFound()))
- self.assertTrue(self.client.is_resource_deleted('fake-id'))
-
- def test_is_resource_deleted_false(self):
- self.useFixture(mockpatch.Patch(
- 'tempest.services.compute.json.floating_ips_client.'
- 'FloatingIPsClient.show_floating_ip',
- return_value={"floating_ip": TestFloatingIpsClient.floating_ip}))
- self.assertFalse(self.client.is_resource_deleted('fake-id'))
diff --git a/tempest/tests/services/compute/test_interfaces_client.py b/tempest/tests/services/compute/test_interfaces_client.py
deleted file mode 100644
index 235585a..0000000
--- a/tempest/tests/services/compute/test_interfaces_client.py
+++ /dev/null
@@ -1,98 +0,0 @@
-# Copyright 2015 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.services.compute.json import interfaces_client
-from tempest.tests import fake_auth_provider
-from tempest.tests.services.compute import base
-
-
-class TestInterfacesClient(base.BaseComputeServiceTest):
- # Data Values to be used for testing #
- FAKE_INTERFACE_DATA = {
- "fixed_ips": [{
- "ip_address": "192.168.1.1",
- "subnet_id": "f8a6e8f8-c2ec-497c-9f23-da9616de54ef"
- }],
- "mac_addr": "fa:16:3e:4c:2c:30",
- "net_id": "3cb9bc59-5699-4588-a4b1-b87f96708bc6",
- "port_id": "ce531f90-199f-48c0-816c-13e38010b442",
- "port_state": "ACTIVE"}
-
- FAKE_SHOW_DATA = {
- "interfaceAttachment": FAKE_INTERFACE_DATA}
- FAKE_LIST_DATA = {
- "interfaceAttachments": [FAKE_INTERFACE_DATA]}
-
- FAKE_SERVER_ID = "ec14c864-096e-4e27-bb8a-2c2b4dc6f3f5"
- FAKE_PORT_ID = FAKE_SHOW_DATA['interfaceAttachment']['port_id']
- func2mock = {
- 'delete': 'tempest.common.service_client.ServiceClient.delete',
- 'get': 'tempest.common.service_client.ServiceClient.get',
- 'post': 'tempest.common.service_client.ServiceClient.post'}
-
- def setUp(self):
- super(TestInterfacesClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = interfaces_client.InterfacesClient(fake_auth,
- "compute",
- "regionOne")
-
- def _test_interface_operation(self, operation="create", bytes_body=False):
- response_code = 200
- expected_op = self.FAKE_SHOW_DATA
- mock_operation = self.func2mock['get']
- params = {'server_id': self.FAKE_SERVER_ID,
- 'port_id': self.FAKE_PORT_ID}
- if operation == 'list':
- expected_op = self.FAKE_LIST_DATA
- function = self.client.list_interfaces
- params = {'server_id': self.FAKE_SERVER_ID}
- elif operation == 'show':
- function = self.client.show_interface
- elif operation == 'delete':
- expected_op = {}
- mock_operation = self.func2mock['delete']
- function = self.client.delete_interface
- response_code = 202
- else:
- function = self.client.create_interface
- mock_operation = self.func2mock['post']
-
- self.check_service_client_function(
- function, mock_operation, expected_op,
- bytes_body, response_code, **params)
-
- def test_list_interfaces_with_str_body(self):
- self._test_interface_operation('list')
-
- def test_list_interfaces_with_bytes_body(self):
- self._test_interface_operation('list', True)
-
- def test_show_interface_with_str_body(self):
- self._test_interface_operation('show')
-
- def test_show_interface_with_bytes_body(self):
- self._test_interface_operation('show', True)
-
- def test_delete_interface_with_str_body(self):
- self._test_interface_operation('delete')
-
- def test_delete_interface_with_bytes_body(self):
- self._test_interface_operation('delete', True)
-
- def test_create_interface_with_str_body(self):
- self._test_interface_operation()
-
- def test_create_interface_with_bytes_body(self):
- self._test_interface_operation(bytes_body=True)
diff --git a/tempest/tests/services/compute/test_security_group_rules_client.py b/tempest/tests/services/compute/test_security_group_rules_client.py
deleted file mode 100644
index c182742..0000000
--- a/tempest/tests/services/compute/test_security_group_rules_client.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# Copyright 2015 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.services.compute.json import security_group_rules_client
-from tempest.tests import fake_auth_provider
-from tempest.tests.services.compute import base
-
-
-class TestSecurityGroupRulesClient(base.BaseComputeServiceTest):
-
- FAKE_SECURITY_GROUP_RULE = {
- "security_group_rule": {
- "id": "2d021cf1-ce4b-4292-994f-7a785d62a144",
- "ip_range": {
- "cidr": "0.0.0.0/0"
- },
- "parent_group_id": "48700ff3-30b8-4e63-845f-a79c9633e9fb",
- "to_port": 443,
- "ip_protocol": "tcp",
- "group": {},
- "from_port": 443
- }
- }
-
- def setUp(self):
- super(TestSecurityGroupRulesClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = security_group_rules_client.SecurityGroupRulesClient(
- fake_auth, 'compute', 'regionOne')
-
- def _test_create_security_group_rule(self, bytes_body=False):
- req_body = {
- "from_port": "443",
- "ip_protocol": "tcp",
- "to_port": "443",
- "cidr": "0.0.0.0/0",
- "parent_group_id": "48700ff3-30b8-4e63-845f-a79c9633e9fb"
- }
- self.check_service_client_function(
- self.client.create_security_group_rule,
- 'tempest.common.service_client.ServiceClient.post',
- self.FAKE_SECURITY_GROUP_RULE,
- to_utf=bytes_body, **req_body)
-
- def test_create_security_group_rule_with_str_body(self):
- self._test_create_security_group_rule()
-
- def test_create_security_group_rule_with_bytes_body(self):
- self._test_create_security_group_rule(bytes_body=True)
-
- def test_delete_security_group_rule(self):
- self.check_service_client_function(
- self.client.delete_security_group_rule,
- 'tempest.common.service_client.ServiceClient.delete',
- {}, status=202, group_rule_id='group-id')
diff --git a/tempest/tests/services/compute/test_server_groups_client.py b/tempest/tests/services/compute/test_server_groups_client.py
deleted file mode 100644
index e531e2f..0000000
--- a/tempest/tests/services/compute/test_server_groups_client.py
+++ /dev/null
@@ -1,84 +0,0 @@
-# Copyright 2015 IBM Corp.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import httplib2
-
-from oslotest import mockpatch
-from tempest_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import server_groups_client
-from tempest.tests.services.compute import base
-
-
-class TestServerGroupsClient(base.BaseComputeServiceTest):
-
- server_group = {
- "id": "5bbcc3c4-1da2-4437-a48a-66f15b1b13f9",
- "name": "test",
- "policies": ["anti-affinity"],
- "members": [],
- "metadata": {}}
-
- def setUp(self):
- super(TestServerGroupsClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = server_groups_client.ServerGroupsClient(
- fake_auth, 'compute', 'regionOne')
-
- def _test_create_server_group(self, bytes_body=False):
- expected = {"server_group": TestServerGroupsClient.server_group}
- self.check_service_client_function(
- self.client.create_server_group,
- 'tempest.common.service_client.ServiceClient.post', expected,
- bytes_body, name='fake-group', policies=['affinity'])
-
- def test_create_server_group_str_body(self):
- self._test_create_server_group(bytes_body=False)
-
- def test_create_server_group_byte_body(self):
- self._test_create_server_group(bytes_body=True)
-
- def test_delete_server_group(self):
- response = (httplib2.Response({'status': 204}), None)
- self.useFixture(mockpatch.Patch(
- 'tempest.common.service_client.ServiceClient.delete',
- return_value=response))
- self.client.delete_server_group('fake-group')
-
- def _test_list_server_groups(self, bytes_body=False):
- expected = {"server_groups": [TestServerGroupsClient.server_group]}
- self.check_service_client_function(
- self.client.list_server_groups,
- 'tempest.common.service_client.ServiceClient.get',
- expected, bytes_body)
-
- def test_list_server_groups_str_body(self):
- self._test_list_server_groups(bytes_body=False)
-
- def test_list_server_groups_byte_body(self):
- self._test_list_server_groups(bytes_body=True)
-
- def _test_show_server_group(self, bytes_body=False):
- expected = {"server_group": TestServerGroupsClient.server_group}
- self.check_service_client_function(
- self.client.show_server_group,
- 'tempest.common.service_client.ServiceClient.get',
- expected, bytes_body,
- server_group_id='5bbcc3c4-1da2-4437-a48a-66f15b1b13f9')
-
- def test_show_server_group_str_body(self):
- self._test_show_server_group(bytes_body=False)
-
- def test_show_server_group_byte_body(self):
- self._test_show_server_group(bytes_body=True)
diff --git a/tempest/tests/services/compute/test_servers_client.py b/tempest/tests/services/compute/test_servers_client.py
index 95b81c1..1fd0740 100644
--- a/tempest/tests/services/compute/test_servers_client.py
+++ b/tempest/tests/services/compute/test_servers_client.py
@@ -363,7 +363,7 @@
{},
status=202,
server_id=self.server_id,
- reboot_type='fake-reboot-type'
+ type='fake-reboot-type'
)
def test_rebuild_server_with_str_body(self):
@@ -995,5 +995,5 @@
'tempest.common.service_client.ServiceClient.post',
{'console': self.FAKE_VNC_CONSOLE},
server_id=self.server_id,
- console_type='fake-console-type'
+ type='fake-console-type'
)
diff --git a/tempest/tests/services/compute/test_volumes_client.py b/tempest/tests/services/compute/test_volumes_client.py
deleted file mode 100644
index 33d4bad..0000000
--- a/tempest/tests/services/compute/test_volumes_client.py
+++ /dev/null
@@ -1,114 +0,0 @@
-# Copyright 2015 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import copy
-
-from oslotest import mockpatch
-from tempest_lib import exceptions as lib_exc
-
-from tempest.services.compute.json import volumes_client
-from tempest.tests import fake_auth_provider
-from tempest.tests.services.compute import base
-
-
-class TestVolumesClient(base.BaseComputeServiceTest):
-
- FAKE_VOLUME = {
- "id": "521752a6-acf6-4b2d-bc7a-119f9148cd8c",
- "displayName": u"v\u12345ol-001",
- "displayDescription": u"Another \u1234volume.",
- "size": 30,
- "status": "Active",
- "volumeType": "289da7f8-6440-407c-9fb4-7db01ec49164",
- "metadata": {
- "contents": "junk"
- },
- "availabilityZone": "us-east1",
- "snapshotId": None,
- "attachments": [],
- "createdAt": "2012-02-14T20:53:07Z"
- }
-
- FAKE_VOLUMES = {"volumes": [FAKE_VOLUME]}
-
- def setUp(self):
- super(TestVolumesClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = volumes_client.VolumesClient(
- fake_auth, 'compute', 'regionOne')
-
- def _test_list_volumes(self, bytes_body=False, **params):
- self.check_service_client_function(
- self.client.list_volumes,
- 'tempest.common.service_client.ServiceClient.get',
- self.FAKE_VOLUMES, to_utf=bytes_body, **params)
-
- def test_list_volumes_with_str_body(self):
- self._test_list_volumes()
-
- def test_list_volumes_with_byte_body(self):
- self._test_list_volumes(bytes_body=True)
-
- def test_list_volumes_with_params(self):
- self._test_list_volumes(name='fake')
-
- def _test_show_volume(self, bytes_body=False):
- self.check_service_client_function(
- self.client.show_volume,
- 'tempest.common.service_client.ServiceClient.get',
- {"volume": self.FAKE_VOLUME},
- to_utf=bytes_body, volume_id=self.FAKE_VOLUME['id'])
-
- def test_show_volume_with_str_body(self):
- self._test_show_volume()
-
- def test_show_volume_with_bytes_body(self):
- self._test_show_volume(bytes_body=True)
-
- def _test_create_volume(self, bytes_body=False):
- post_body = copy.deepcopy(self.FAKE_VOLUME)
- del post_body['id']
- del post_body['createdAt']
- del post_body['status']
- self.check_service_client_function(
- self.client.create_volume,
- 'tempest.common.service_client.ServiceClient.post',
- {"volume": self.FAKE_VOLUME},
- to_utf=bytes_body, status=200, **post_body)
-
- def test_create_volume_with_str_body(self):
- self._test_create_volume()
-
- def test_create_volume_with_bytes_body(self):
- self._test_create_volume(bytes_body=True)
-
- def test_delete_volume(self):
- self.check_service_client_function(
- self.client.delete_volume,
- 'tempest.common.service_client.ServiceClient.delete',
- {}, status=202, volume_id=self.FAKE_VOLUME['id'])
-
- def test_is_resource_deleted_true(self):
- module = ('tempest.services.compute.json.volumes_client.'
- 'VolumesClient.show_volume')
- self.useFixture(mockpatch.Patch(
- module, side_effect=lib_exc.NotFound))
- self.assertTrue(self.client.is_resource_deleted('fake-id'))
-
- def test_is_resource_deleted_false(self):
- module = ('tempest.services.compute.json.volumes_client.'
- 'VolumesClient.show_volume')
- self.useFixture(mockpatch.Patch(
- module, return_value={}))
- self.assertFalse(self.client.is_resource_deleted('fake-id'))
diff --git a/tempest/tests/test_glance_http.py b/tempest/tests/test_glance_http.py
index ed886da..db9db34 100644
--- a/tempest/tests/test_glance_http.py
+++ b/tempest/tests/test_glance_http.py
@@ -123,9 +123,9 @@
def test_get_connection_kwargs_default_for_https(self):
kwargs = self.client._get_connection_kwargs('https')
self.assertEqual(600, kwargs['timeout'])
- self.assertEqual(None, kwargs['ca_certs'])
- self.assertEqual(None, kwargs['cert_file'])
- self.assertEqual(None, kwargs['key_file'])
+ self.assertIsNone(kwargs['ca_certs'])
+ self.assertIsNone(kwargs['cert_file'])
+ self.assertIsNone(kwargs['key_file'])
self.assertEqual(False, kwargs['insecure'])
self.assertEqual(True, kwargs['ssl_compression'])
self.assertEqual(6, len(kwargs.keys()))
diff --git a/tempest/thirdparty/README.rst b/tempest/thirdparty/README.rst
deleted file mode 100644
index b0bfdf7..0000000
--- a/tempest/thirdparty/README.rst
+++ /dev/null
@@ -1,35 +0,0 @@
-.. _third_party_field_guide:
-
-Tempest Field Guide to Third Party API tests
-============================================
-
-
-What are these tests?
----------------------
-
-Third party tests are tests for non native OpenStack APIs that are
-part of OpenStack projects. If we ship an API, we're really required
-to ensure that it's working.
-
-An example is that Nova Compute currently has EC2 API support in tree,
-which should be tested as part of normal process.
-
-
-Why are these tests in tempest?
--------------------------------
-
-If we ship an API in an OpenStack component, there should be tests in
-tempest to exercise it in some way.
-
-
-Scope of these tests
---------------------
-
-Third party API testing should be limited to the functional testing of
-third party API compliance. Complex scenarios should be avoided, and
-instead exercised with the OpenStack API, unless the third party API
-can't be tested without those scenarios.
-
-Whenever possible third party API testing should use a client as close
-to the third party API as possible. The point of these tests is API
-validation.
diff --git a/tempest/thirdparty/__init__.py b/tempest/thirdparty/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/thirdparty/__init__.py
+++ /dev/null
diff --git a/tempest/thirdparty/boto/__init__.py b/tempest/thirdparty/boto/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/thirdparty/boto/__init__.py
+++ /dev/null
diff --git a/tempest/thirdparty/boto/test.py b/tempest/thirdparty/boto/test.py
deleted file mode 100644
index cfd3747..0000000
--- a/tempest/thirdparty/boto/test.py
+++ /dev/null
@@ -1,694 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import contextlib
-import logging as orig_logging
-import os
-import re
-
-import boto
-from boto import ec2
-from boto import exception
-from boto import s3
-from oslo_log import log as logging
-import six
-from six.moves.urllib import parse as urlparse
-from tempest_lib import exceptions as lib_exc
-
-from tempest.common import credentials_factory as credentials
-from tempest.common.utils import file_utils
-from tempest import config
-from tempest import exceptions
-import tempest.test
-from tempest.thirdparty.boto.utils import wait
-
-CONF = config.CONF
-LOG = logging.getLogger(__name__)
-
-
-def decision_maker():
- A_I_IMAGES_READY = True # ari,ami,aki
- S3_CAN_CONNECT_ERROR = None
- EC2_CAN_CONNECT_ERROR = None
- secret_matcher = re.compile("[A-Za-z0-9+/]{32,}") # 40 in other system
- id_matcher = re.compile("[A-Za-z0-9]{20,}")
-
- def all_read(*args):
- return all(map(file_utils.have_effective_read_access, args))
-
- materials_path = CONF.boto.s3_materials_path
- ami_path = materials_path + os.sep + CONF.boto.ami_manifest
- aki_path = materials_path + os.sep + CONF.boto.aki_manifest
- ari_path = materials_path + os.sep + CONF.boto.ari_manifest
-
- A_I_IMAGES_READY = all_read(ami_path, aki_path, ari_path)
- boto_logger = logging.getLogger('boto')
- level = boto_logger.logger.level
- # suppress logging for boto
- boto_logger.logger.setLevel(orig_logging.CRITICAL)
-
- def _cred_sub_check(connection_data):
- if not id_matcher.match(connection_data["aws_access_key_id"]):
- raise Exception("Invalid AWS access Key")
- if not secret_matcher.match(connection_data["aws_secret_access_key"]):
- raise Exception("Invalid AWS secret Key")
- raise Exception("Unknown (Authentication?) Error")
- # NOTE(andreaf) Setting up an extra manager here is redundant,
- # and should be removed.
- openstack = credentials.ConfiguredUserManager()
- try:
- if urlparse.urlparse(CONF.boto.ec2_url).hostname is None:
- raise Exception("Failed to get hostname from the ec2_url")
- ec2client = openstack.ec2api_client
- try:
- ec2client.get_all_regions()
- except exception.BotoServerError as exc:
- if exc.error_code is None:
- raise Exception("EC2 target does not looks EC2 service")
- _cred_sub_check(ec2client.connection_data)
-
- except lib_exc.Unauthorized:
- EC2_CAN_CONNECT_ERROR = "AWS credentials not set," +\
- " also failed to get it from keystone"
- except Exception as exc:
- EC2_CAN_CONNECT_ERROR = str(exc)
-
- try:
- if urlparse.urlparse(CONF.boto.s3_url).hostname is None:
- raise Exception("Failed to get hostname from the s3_url")
- s3client = openstack.s3_client
- try:
- s3client.get_bucket("^INVALID*#()@INVALID.")
- except exception.BotoServerError as exc:
- if exc.status == 403:
- _cred_sub_check(s3client.connection_data)
- except Exception as exc:
- S3_CAN_CONNECT_ERROR = str(exc)
- except lib_exc.Unauthorized:
- S3_CAN_CONNECT_ERROR = "AWS credentials not set," +\
- " failed to get them even by keystoneclient"
- boto_logger.logger.setLevel(level)
- return {'A_I_IMAGES_READY': A_I_IMAGES_READY,
- 'S3_CAN_CONNECT_ERROR': S3_CAN_CONNECT_ERROR,
- 'EC2_CAN_CONNECT_ERROR': EC2_CAN_CONNECT_ERROR}
-
-
-class BotoExceptionMatcher(object):
- STATUS_RE = r'[45]\d\d'
- CODE_RE = '.*' # regexp makes sense in group match
-
- def match(self, exc):
- """Check boto exception
-
- :returns: Returns with an error string if it does not match,
- returns with None when it matches.
- """
- if not isinstance(exc, exception.BotoServerError):
- return "%r not an BotoServerError instance" % exc
- LOG.info("Status: %s , error_code: %s", exc.status, exc.error_code)
- if re.match(self.STATUS_RE, str(exc.status)) is None:
- return ("Status code (%s) does not match"
- "the expected re pattern \"%s\""
- % (exc.status, self.STATUS_RE))
- if re.match(self.CODE_RE, str(exc.error_code)) is None:
- return ("Error code (%s) does not match" +
- "the expected re pattern \"%s\"") %\
- (exc.error_code, self.CODE_RE)
- return None
-
-
-class ClientError(BotoExceptionMatcher):
- STATUS_RE = r'4\d\d'
-
-
-class ServerError(BotoExceptionMatcher):
- STATUS_RE = r'5\d\d'
-
-
-def _add_matcher_class(error_cls, error_data, base=BotoExceptionMatcher):
- """Usable for adding an ExceptionMatcher(s) into the exception tree.
-
- The not leaf elements does wildcard match
- """
- # in error_code just literal and '.' characters expected
- if not isinstance(error_data, six.string_types):
- (error_code, status_code) = map(str, error_data)
- else:
- status_code = None
- error_code = error_data
- parts = error_code.split('.')
- basematch = ""
- num_parts = len(parts)
- max_index = num_parts - 1
- add_cls = error_cls
- for i_part in six.moves.xrange(num_parts):
- part = parts[i_part]
- leaf = i_part == max_index
- if not leaf:
- match = basematch + part + "[.].*"
- else:
- match = basematch + part
-
- basematch += part + "[.]"
- if not hasattr(add_cls, part):
- cls_dict = {"CODE_RE": match}
- if leaf and status_code is not None:
- cls_dict["STATUS_RE"] = status_code
- cls = type(part, (base, ), cls_dict)
- setattr(add_cls, part, cls())
- add_cls = cls
- elif leaf:
- raise LookupError("Tries to redefine an error code \"%s\"" % part)
- else:
- add_cls = getattr(add_cls, part)
-
-
-# TODO(afazekas): classmethod handling
-def friendly_function_name_simple(call_able):
- name = ""
- if hasattr(call_able, "im_class"):
- name += call_able.im_class.__name__ + "."
- name += call_able.__name__
- return name
-
-
-def friendly_function_call_str(call_able, *args, **kwargs):
- string = friendly_function_name_simple(call_able)
- string += "(" + ", ".join(map(str, args))
- if len(kwargs):
- if len(args):
- string += ", "
- string += ", ".join("=".join(map(str, (key, value)))
- for (key, value) in kwargs.items())
- return string + ")"
-
-
-class BotoTestCase(tempest.test.BaseTestCase):
- """Recommended to use as base class for boto related test."""
-
- credentials = ['primary']
-
- @classmethod
- def skip_checks(cls):
- super(BotoTestCase, cls).skip_checks()
- if not CONF.compute_feature_enabled.ec2_api:
- raise cls.skipException("The EC2 API is not available")
- if not CONF.identity_feature_enabled.api_v2 or \
- not CONF.identity.auth_version == 'v2':
- raise cls.skipException("Identity v2 is not available")
-
- @classmethod
- def resource_setup(cls):
- super(BotoTestCase, cls).resource_setup()
- cls.conclusion = decision_maker()
- # The trash contains cleanup functions and parameters in tuples
- # (function, *args, **kwargs)
- cls._resource_trash_bin = {}
- cls._sequence = -1
- if (hasattr(cls, "EC2") and
- cls.conclusion['EC2_CAN_CONNECT_ERROR'] is not None):
- raise cls.skipException("EC2 " + cls.__name__ + ": " +
- cls.conclusion['EC2_CAN_CONNECT_ERROR'])
- if (hasattr(cls, "S3") and
- cls.conclusion['S3_CAN_CONNECT_ERROR'] is not None):
- raise cls.skipException("S3 " + cls.__name__ + ": " +
- cls.conclusion['S3_CAN_CONNECT_ERROR'])
-
- @classmethod
- def addResourceCleanUp(cls, function, *args, **kwargs):
- """Adds CleanUp callable, used by tearDownClass.
-
- Recommended to a use (deep)copy on the mutable args.
- """
- cls._sequence = cls._sequence + 1
- cls._resource_trash_bin[cls._sequence] = (function, args, kwargs)
- return cls._sequence
-
- @classmethod
- def cancelResourceCleanUp(cls, key):
- """Cancel Clean up request."""
- del cls._resource_trash_bin[key]
-
- # TODO(afazekas): Add "with" context handling
- def assertBotoError(self, excMatcher, callableObj,
- *args, **kwargs):
- """Example usage:
-
- self.assertBotoError(self.ec2_error_code.client.
- InvalidKeyPair.Duplicate,
- self.client.create_keypair,
- key_name)
- """
- try:
- callableObj(*args, **kwargs)
- except exception.BotoServerError as exc:
- error_msg = excMatcher.match(exc)
- if error_msg is not None:
- raise self.failureException(error_msg)
- else:
- raise self.failureException("BotoServerError not raised")
-
- @classmethod
- def resource_cleanup(cls):
- """Calls the callables added by addResourceCleanUp
-
- when you overwrite this function don't forget to call this too.
- """
- fail_count = 0
- trash_keys = sorted(cls._resource_trash_bin, reverse=True)
- for key in trash_keys:
- (function, pos_args, kw_args) = cls._resource_trash_bin[key]
- try:
- func_name = friendly_function_call_str(function, *pos_args,
- **kw_args)
- LOG.debug("Cleaning up: %s" % func_name)
- function(*pos_args, **kw_args)
- except BaseException:
- fail_count += 1
- LOG.exception("Cleanup failed %s" % func_name)
- finally:
- del cls._resource_trash_bin[key]
- super(BotoTestCase, cls).resource_cleanup()
- # NOTE(afazekas): let the super called even on exceptions
- # The real exceptions already logged, if the super throws another,
- # does not causes hidden issues
- if fail_count:
- raise exceptions.TearDownException(num=fail_count)
-
- ec2_error_code = BotoExceptionMatcher()
- # InsufficientInstanceCapacity can be both server and client error
- ec2_error_code.server = ServerError()
- ec2_error_code.client = ClientError()
- s3_error_code = BotoExceptionMatcher()
- s3_error_code.server = ServerError()
- s3_error_code.client = ClientError()
- valid_image_state = set(('available', 'pending', 'failed'))
- # NOTE(afazekas): 'paused' is not valid status in EC2, but it does not have
- # a good mapping, because it uses memory, but not really a running machine
- valid_instance_state = set(('pending', 'running', 'shutting-down',
- 'terminated', 'stopping', 'stopped', 'paused'))
- valid_volume_status = set(('creating', 'available', 'in-use',
- 'deleting', 'deleted', 'error'))
- valid_snapshot_status = set(('pending', 'completed', 'error'))
-
- gone_set = set(('_GONE',))
-
- @classmethod
- def get_lfunction_gone(cls, obj):
- # NOTE: If the object is instance of a well know type returns back with
- # with the corresponding function otherwise it assumes the obj itself
- # is the function.
- ec = cls.ec2_error_code
- if isinstance(obj, ec2.instance.Instance):
- colusure_matcher = ec.client.InvalidInstanceID.NotFound
- status_attr = "state"
- elif isinstance(obj, ec2.image.Image):
- colusure_matcher = ec.client.InvalidAMIID.NotFound
- status_attr = "state"
- elif isinstance(obj, ec2.snapshot.Snapshot):
- colusure_matcher = ec.client.InvalidSnapshot.NotFound
- status_attr = "status"
- elif isinstance(obj, ec2.volume.Volume):
- colusure_matcher = ec.client.InvalidVolume.NotFound
- status_attr = "status"
- else:
- return obj
-
- def _status():
- try:
- obj.update(validate=True)
- except ValueError:
- return "_GONE"
- except exception.EC2ResponseError as exc:
- if colusure_matcher.match(exc) is None:
- return "_GONE"
- else:
- raise
- return getattr(obj, status_attr)
-
- return _status
-
- def state_wait_gone(self, lfunction, final_set, valid_set):
- if not isinstance(final_set, set):
- final_set = set((final_set,))
- final_set |= self.gone_set
- lfunction = self.get_lfunction_gone(lfunction)
- state = wait.state_wait(lfunction, final_set, valid_set)
- self.assertIn(state, valid_set | self.gone_set)
- return state
-
- def waitImageState(self, lfunction, wait_for):
- return self.state_wait_gone(lfunction, wait_for,
- self.valid_image_state)
-
- def waitInstanceState(self, lfunction, wait_for):
- return self.state_wait_gone(lfunction, wait_for,
- self.valid_instance_state)
-
- def waitSnapshotStatus(self, lfunction, wait_for):
- return self.state_wait_gone(lfunction, wait_for,
- self.valid_snapshot_status)
-
- def waitVolumeStatus(self, lfunction, wait_for):
- return self.state_wait_gone(lfunction, wait_for,
- self.valid_volume_status)
-
- def assertImageStateWait(self, lfunction, wait_for):
- state = self.waitImageState(lfunction, wait_for)
- self.assertIn(state, wait_for)
-
- def assertInstanceStateWait(self, lfunction, wait_for):
- state = self.waitInstanceState(lfunction, wait_for)
- self.assertIn(state, wait_for)
-
- def assertVolumeStatusWait(self, lfunction, wait_for):
- state = self.waitVolumeStatus(lfunction, wait_for)
- self.assertIn(state, wait_for)
-
- def assertSnapshotStatusWait(self, lfunction, wait_for):
- state = self.waitSnapshotStatus(lfunction, wait_for)
- self.assertIn(state, wait_for)
-
- def assertAddressDisassociatedWait(self, address):
-
- def _disassociate():
- cli = self.ec2_client
- addresses = cli.get_all_addresses(addresses=(address.public_ip,))
- if len(addresses) != 1:
- return "INVALID"
- if addresses[0].instance_id:
- LOG.info("%s associated to %s",
- address.public_ip,
- addresses[0].instance_id)
- return "ASSOCIATED"
- return "DISASSOCIATED"
-
- state = wait.state_wait(_disassociate, "DISASSOCIATED",
- set(("ASSOCIATED", "DISASSOCIATED")))
- self.assertEqual(state, "DISASSOCIATED")
-
- def assertAddressReleasedWait(self, address):
-
- def _address_delete():
- # NOTE(afazekas): the filter gives back IP
- # even if it is not associated to my tenant
- if (address.public_ip not in map(lambda a: a.public_ip,
- self.ec2_client.get_all_addresses())):
- return "DELETED"
- return "NOTDELETED"
-
- state = wait.state_wait(_address_delete, "DELETED")
- self.assertEqual(state, "DELETED")
-
- def assertReSearch(self, regexp, string):
- if re.search(regexp, string) is None:
- raise self.failureException("regexp: '%s' not found in '%s'" %
- (regexp, string))
-
- def assertNotReSearch(self, regexp, string):
- if re.search(regexp, string) is not None:
- raise self.failureException("regexp: '%s' found in '%s'" %
- (regexp, string))
-
- def assertReMatch(self, regexp, string):
- if re.match(regexp, string) is None:
- raise self.failureException("regexp: '%s' not matches on '%s'" %
- (regexp, string))
-
- def assertNotReMatch(self, regexp, string):
- if re.match(regexp, string) is not None:
- raise self.failureException("regexp: '%s' matches on '%s'" %
- (regexp, string))
-
- @classmethod
- def destroy_bucket(cls, connection_data, bucket):
- """Destroys the bucket and its content, just for teardown."""
- exc_num = 0
- try:
- with contextlib.closing(
- boto.connect_s3(**connection_data)) as conn:
- if isinstance(bucket, basestring):
- bucket = conn.lookup(bucket)
- assert isinstance(bucket, s3.bucket.Bucket)
- for obj in bucket.list():
- try:
- bucket.delete_key(obj.key)
- obj.close()
- except BaseException:
- LOG.exception("Failed to delete key %s " % obj.key)
- exc_num += 1
- conn.delete_bucket(bucket)
- except BaseException:
- LOG.exception("Failed to destroy bucket %s " % bucket)
- exc_num += 1
- if exc_num:
- raise exceptions.TearDownException(num=exc_num)
-
- @classmethod
- def destroy_reservation(cls, reservation):
- """Terminate instances in a reservation, just for teardown."""
- exc_num = 0
-
- def _instance_state():
- try:
- instance.update(validate=True)
- except ValueError:
- return "_GONE"
- except exception.EC2ResponseError as exc:
- if cls.ec2_error_code.\
- client.InvalidInstanceID.NotFound.match(exc) is None:
- return "_GONE"
- # NOTE(afazekas): incorrect code,
- # but the resource must be destroyed
- if exc.error_code == "InstanceNotFound":
- return "_GONE"
-
- return instance.state
-
- for instance in reservation.instances:
- try:
- instance.terminate()
- wait.re_search_wait(_instance_state, "_GONE")
- except BaseException:
- LOG.exception("Failed to terminate instance %s " % instance)
- exc_num += 1
- if exc_num:
- raise exceptions.TearDownException(num=exc_num)
-
- # NOTE(afazekas): The incorrect ErrorCodes makes very, very difficult
- # to write better teardown
-
- @classmethod
- def destroy_security_group_wait(cls, group):
- """Delete group.
-
- Use just for teardown!
- """
- # NOTE(afazekas): should wait/try until all related instance terminates
- group.delete()
-
- @classmethod
- def destroy_volume_wait(cls, volume):
- """Delete volume, tries to detach first.
-
- Use just for teardown!
- """
- exc_num = 0
- snaps = volume.snapshots()
- if len(snaps):
- LOG.critical("%s Volume has %s snapshot(s)", volume.id,
- map(snaps.id, snaps))
-
- # NOTE(afazekas): detaching/attaching not valid EC2 status
- def _volume_state():
- volume.update(validate=True)
- try:
- # NOTE(gmann): Make sure volume is attached.
- # Checking status as 'not "available"' is not enough to make
- # sure volume is attached as it can be in "error" state
- if volume.status == "in-use":
- volume.detach(force=True)
- except BaseException:
- LOG.exception("Failed to detach volume %s" % volume)
- # exc_num += 1 "nonlocal" not in python2
- return volume.status
-
- try:
- wait.re_search_wait(_volume_state, "available")
- # not validates status
- LOG.info(_volume_state())
- volume.delete()
- except BaseException:
- LOG.exception("Failed to delete volume %s" % volume)
- exc_num += 1
- if exc_num:
- raise exceptions.TearDownException(num=exc_num)
-
- @classmethod
- def destroy_snapshot_wait(cls, snapshot):
- """delete snapshot, wait until it ceases to exist."""
- snapshot.delete()
-
- def _update():
- snapshot.update(validate=True)
-
- wait.wait_exception(_update)
-
-
-# you can specify tuples if you want to specify the status pattern
-for code in ('AddressLimitExceeded', 'AttachmentLimitExceeded', 'AuthFailure',
- 'Blocked', 'CustomerGatewayLimitExceeded', 'DependencyViolation',
- 'DiskImageSizeTooLarge', 'FilterLimitExceeded',
- 'Gateway.NotAttached', 'IdempotentParameterMismatch',
- 'IncorrectInstanceState', 'IncorrectState',
- 'InstanceLimitExceeded', 'InsufficientInstanceCapacity',
- 'InsufficientReservedInstancesCapacity',
- 'InternetGatewayLimitExceeded', 'InvalidAMIAttributeItemValue',
- 'InvalidAMIID.Malformed', 'InvalidAMIID.NotFound',
- 'InvalidAMIID.Unavailable', 'InvalidAssociationID.NotFound',
- 'InvalidAttachment.NotFound', 'InvalidConversionTaskId',
- 'InvalidCustomerGateway.DuplicateIpAddress',
- 'InvalidCustomerGatewayID.NotFound', 'InvalidDevice.InUse',
- 'InvalidDhcpOptionsID.NotFound', 'InvalidFormat',
- 'InvalidFilter', 'InvalidGatewayID.NotFound',
- 'InvalidGroup.Duplicate', 'InvalidGroupId.Malformed',
- 'InvalidGroup.InUse', 'InvalidGroup.NotFound',
- 'InvalidGroup.Reserved', 'InvalidInstanceID.Malformed',
- 'InvalidInstanceID.NotFound',
- 'InvalidInternetGatewayID.NotFound', 'InvalidIPAddress.InUse',
- 'InvalidKeyPair.Duplicate', 'InvalidKeyPair.Format',
- 'InvalidKeyPair.NotFound', 'InvalidManifest',
- 'InvalidNetworkAclEntry.NotFound',
- 'InvalidNetworkAclID.NotFound', 'InvalidParameterCombination',
- 'InvalidParameterValue', 'InvalidPermission.Duplicate',
- 'InvalidPermission.Malformed', 'InvalidReservationID.Malformed',
- 'InvalidReservationID.NotFound', 'InvalidRoute.NotFound',
- 'InvalidRouteTableID.NotFound',
- 'InvalidSecurity.RequestHasExpired',
- 'InvalidSnapshotID.Malformed', 'InvalidSnapshot.NotFound',
- 'InvalidUserID.Malformed', 'InvalidReservedInstancesId',
- 'InvalidReservedInstancesOfferingId',
- 'InvalidSubnetID.NotFound', 'InvalidVolumeID.Duplicate',
- 'InvalidVolumeID.Malformed', 'InvalidVolumeID.ZoneMismatch',
- 'InvalidVolume.NotFound', 'InvalidVpcID.NotFound',
- 'InvalidVpnConnectionID.NotFound',
- 'InvalidVpnGatewayID.NotFound',
- 'InvalidZone.NotFound', 'LegacySecurityGroup',
- 'MissingParameter', 'NetworkAclEntryAlreadyExists',
- 'NetworkAclEntryLimitExceeded', 'NetworkAclLimitExceeded',
- 'NonEBSInstance', 'PendingSnapshotLimitExceeded',
- 'PendingVerification', 'OptInRequired', 'RequestLimitExceeded',
- 'ReservedInstancesLimitExceeded', 'Resource.AlreadyAssociated',
- 'ResourceLimitExceeded', 'RouteAlreadyExists',
- 'RouteLimitExceeded', 'RouteTableLimitExceeded',
- 'RulesPerSecurityGroupLimitExceeded',
- 'SecurityGroupLimitExceeded',
- 'SecurityGroupsPerInstanceLimitExceeded',
- 'SnapshotLimitExceeded', 'SubnetLimitExceeded',
- 'UnknownParameter', 'UnsupportedOperation',
- 'VolumeLimitExceeded', 'VpcLimitExceeded',
- 'VpnConnectionLimitExceeded',
- 'VpnGatewayAttachmentLimitExceeded', 'VpnGatewayLimitExceeded'):
- _add_matcher_class(BotoTestCase.ec2_error_code.client,
- code, base=ClientError)
-
-for code in ('InsufficientAddressCapacity', 'InsufficientInstanceCapacity',
- 'InsufficientReservedInstanceCapacity', 'InternalError',
- 'Unavailable'):
- _add_matcher_class(BotoTestCase.ec2_error_code.server,
- code, base=ServerError)
-
-
-for code in (('AccessDenied', 403),
- ('AccountProblem', 403),
- ('AmbiguousGrantByEmailAddress', 400),
- ('BadDigest', 400),
- ('BucketAlreadyExists', 409),
- ('BucketAlreadyOwnedByYou', 409),
- ('BucketNotEmpty', 409),
- ('CredentialsNotSupported', 400),
- ('CrossLocationLoggingProhibited', 403),
- ('EntityTooSmall', 400),
- ('EntityTooLarge', 400),
- ('ExpiredToken', 400),
- ('IllegalVersioningConfigurationException', 400),
- ('IncompleteBody', 400),
- ('IncorrectNumberOfFilesInPostRequest', 400),
- ('InlineDataTooLarge', 400),
- ('InvalidAccessKeyId', 403),
- 'InvalidAddressingHeader',
- ('InvalidArgument', 400),
- ('InvalidBucketName', 400),
- ('InvalidBucketState', 409),
- ('InvalidDigest', 400),
- ('InvalidLocationConstraint', 400),
- ('InvalidPart', 400),
- ('InvalidPartOrder', 400),
- ('InvalidPayer', 403),
- ('InvalidPolicyDocument', 400),
- ('InvalidRange', 416),
- ('InvalidRequest', 400),
- ('InvalidSecurity', 403),
- ('InvalidSOAPRequest', 400),
- ('InvalidStorageClass', 400),
- ('InvalidTargetBucketForLogging', 400),
- ('InvalidToken', 400),
- ('InvalidURI', 400),
- ('KeyTooLong', 400),
- ('MalformedACLError', 400),
- ('MalformedPOSTRequest', 400),
- ('MalformedXML', 400),
- ('MaxMessageLengthExceeded', 400),
- ('MaxPostPreDataLengthExceededError', 400),
- ('MetadataTooLarge', 400),
- ('MethodNotAllowed', 405),
- ('MissingAttachment'),
- ('MissingContentLength', 411),
- ('MissingRequestBodyError', 400),
- ('MissingSecurityElement', 400),
- ('MissingSecurityHeader', 400),
- ('NoLoggingStatusForKey', 400),
- ('NoSuchBucket', 404),
- ('NoSuchKey', 404),
- ('NoSuchLifecycleConfiguration', 404),
- ('NoSuchUpload', 404),
- ('NoSuchVersion', 404),
- ('NotSignedUp', 403),
- ('NotSuchBucketPolicy', 404),
- ('OperationAborted', 409),
- ('PermanentRedirect', 301),
- ('PreconditionFailed', 412),
- ('Redirect', 307),
- ('RequestIsNotMultiPartContent', 400),
- ('RequestTimeout', 400),
- ('RequestTimeTooSkewed', 403),
- ('RequestTorrentOfBucketError', 400),
- ('SignatureDoesNotMatch', 403),
- ('TemporaryRedirect', 307),
- ('TokenRefreshRequired', 400),
- ('TooManyBuckets', 400),
- ('UnexpectedContent', 400),
- ('UnresolvableGrantByEmailAddress', 400),
- ('UserKeyMustBeSpecified', 400)):
- _add_matcher_class(BotoTestCase.s3_error_code.client,
- code, base=ClientError)
-
-
-for code in (('InternalError', 500),
- ('NotImplemented', 501),
- ('ServiceUnavailable', 503),
- ('SlowDown', 503)):
- _add_matcher_class(BotoTestCase.s3_error_code.server,
- code, base=ServerError)
diff --git a/tempest/thirdparty/boto/test_ec2_instance_run.py b/tempest/thirdparty/boto/test_ec2_instance_run.py
deleted file mode 100644
index 6c1b362..0000000
--- a/tempest/thirdparty/boto/test_ec2_instance_run.py
+++ /dev/null
@@ -1,363 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from oslo_log import log as logging
-
-from tempest.common.utils import data_utils
-from tempest.common.utils.linux import remote_client
-from tempest import config
-from tempest import exceptions
-from tempest import test
-from tempest.thirdparty.boto import test as boto_test
-from tempest.thirdparty.boto.utils import s3
-from tempest.thirdparty.boto.utils import wait
-
-CONF = config.CONF
-
-LOG = logging.getLogger(__name__)
-
-
-class InstanceRunTest(boto_test.BotoTestCase):
-
- @classmethod
- def setup_clients(cls):
- super(InstanceRunTest, cls).setup_clients()
- cls.s3_client = cls.os.s3_client
- cls.ec2_client = cls.os.ec2api_client
-
- @classmethod
- def resource_setup(cls):
- super(InstanceRunTest, cls).resource_setup()
- if not cls.conclusion['A_I_IMAGES_READY']:
- raise cls.skipException("".join(("EC2 ", cls.__name__,
- ": requires ami/aki/ari manifest")))
- cls.zone = CONF.boto.aws_zone
- cls.materials_path = CONF.boto.s3_materials_path
- ami_manifest = CONF.boto.ami_manifest
- aki_manifest = CONF.boto.aki_manifest
- ari_manifest = CONF.boto.ari_manifest
- cls.instance_type = CONF.boto.instance_type
- cls.bucket_name = data_utils.rand_name("s3bucket")
- cls.keypair_name = data_utils.rand_name("keypair")
- cls.keypair = cls.ec2_client.create_key_pair(cls.keypair_name)
- cls.addResourceCleanUp(cls.ec2_client.delete_key_pair,
- cls.keypair_name)
- bucket = cls.s3_client.create_bucket(cls.bucket_name)
- cls.addResourceCleanUp(cls.destroy_bucket,
- cls.s3_client.connection_data,
- cls.bucket_name)
- s3.s3_upload_dir(bucket, cls.materials_path)
- cls.images = {"ami":
- {"name": data_utils.rand_name("ami-name"),
- "location": cls.bucket_name + "/" + ami_manifest},
- "aki":
- {"name": data_utils.rand_name("aki-name"),
- "location": cls.bucket_name + "/" + aki_manifest},
- "ari":
- {"name": data_utils.rand_name("ari-name"),
- "location": cls.bucket_name + "/" + ari_manifest}}
- for image_type in ("aki", "ari"):
- image = cls.images[image_type]
- image["image_id"] = cls.ec2_client.register_image(
- name=image["name"],
- image_location=image["location"])
- cls.addResourceCleanUp(cls.ec2_client.deregister_image,
- image["image_id"])
- image = cls.images["ami"]
- image["image_id"] = cls.ec2_client.register_image(
- name=image["name"],
- image_location=image["location"],
- kernel_id=cls.images["aki"]["image_id"],
- ramdisk_id=cls.images["ari"]["image_id"])
- cls.addResourceCleanUp(cls.ec2_client.deregister_image,
- image["image_id"])
-
- for image in cls.images.itervalues():
- def _state():
- retr = cls.ec2_client.get_image(image["image_id"])
- return retr.state
- state = wait.state_wait(_state, "available")
- if state != "available":
- for _image in cls.images.itervalues():
- cls.ec2_client.deregister_image(_image["image_id"])
- raise exceptions.EC2RegisterImageException(
- image_id=image["image_id"])
-
- def _terminate_reservation(self, reservation, rcuk):
- for instance in reservation.instances:
- instance.terminate()
- for instance in reservation.instances:
- self.assertInstanceStateWait(instance, '_GONE')
- self.cancelResourceCleanUp(rcuk)
-
- @test.idempotent_id('c881fbb7-d56e-4054-9d76-1c3a60a207b0')
- def test_run_idempotent_instances(self):
- # EC2 run instances idempotently
-
- def _run_instance(client_token):
- reservation = self.ec2_client.run_instances(
- image_id=self.images["ami"]["image_id"],
- kernel_id=self.images["aki"]["image_id"],
- ramdisk_id=self.images["ari"]["image_id"],
- instance_type=self.instance_type,
- client_token=client_token)
- rcuk = self.addResourceCleanUp(self.destroy_reservation,
- reservation)
- return (reservation, rcuk)
-
- reservation_1, rcuk_1 = _run_instance('token_1')
- reservation_2, rcuk_2 = _run_instance('token_2')
- reservation_1a, rcuk_1a = _run_instance('token_1')
-
- self.assertIsNotNone(reservation_1)
- self.assertIsNotNone(reservation_2)
- self.assertIsNotNone(reservation_1a)
-
- # same reservation for token_1
- self.assertEqual(reservation_1.id, reservation_1a.id)
-
- # Cancel cleanup -- since it's a duplicate, it's
- # handled by rcuk1
- self.cancelResourceCleanUp(rcuk_1a)
-
- self._terminate_reservation(reservation_1, rcuk_1)
- self._terminate_reservation(reservation_2, rcuk_2)
-
- @test.idempotent_id('2ea26a39-f96c-48fc-8374-5c10ec184c67')
- def test_run_stop_terminate_instance(self):
- # EC2 run, stop and terminate instance
- image_ami = self.ec2_client.get_image(self.images["ami"]
- ["image_id"])
- reservation = image_ami.run(kernel_id=self.images["aki"]["image_id"],
- ramdisk_id=self.images["ari"]["image_id"],
- instance_type=self.instance_type)
- rcuk = self.addResourceCleanUp(self.destroy_reservation, reservation)
-
- for instance in reservation.instances:
- LOG.info("state: %s", instance.state)
- if instance.state != "running":
- self.assertInstanceStateWait(instance, "running")
-
- for instance in reservation.instances:
- instance.stop()
- LOG.info("state: %s", instance.state)
- if instance.state != "stopped":
- self.assertInstanceStateWait(instance, "stopped")
-
- self._terminate_reservation(reservation, rcuk)
-
- @test.idempotent_id('3d77225a-5cec-4e54-a017-9ebf11a266e6')
- def test_run_stop_terminate_instance_with_tags(self):
- # EC2 run, stop and terminate instance with tags
- image_ami = self.ec2_client.get_image(self.images["ami"]
- ["image_id"])
- reservation = image_ami.run(kernel_id=self.images["aki"]["image_id"],
- ramdisk_id=self.images["ari"]["image_id"],
- instance_type=self.instance_type)
- rcuk = self.addResourceCleanUp(self.destroy_reservation, reservation)
-
- for instance in reservation.instances:
- LOG.info("state: %s", instance.state)
- if instance.state != "running":
- self.assertInstanceStateWait(instance, "running")
- instance.add_tag('key1', value='value1')
-
- tags = self.ec2_client.get_all_tags()
- td = dict((item.name, item.value) for item in tags)
-
- self.assertIn('key1', td)
- self.assertEqual('value1', td['key1'])
-
- tags = self.ec2_client.get_all_tags(filters={'key': 'key1'})
- td = dict((item.name, item.value) for item in tags)
- self.assertIn('key1', td)
- self.assertEqual('value1', td['key1'])
-
- tags = self.ec2_client.get_all_tags(filters={'value': 'value1'})
- td = dict((item.name, item.value) for item in tags)
- self.assertIn('key1', td)
- self.assertEqual('value1', td['key1'])
-
- tags = self.ec2_client.get_all_tags(filters={'key': 'value2'})
- td = dict((item.name, item.value) for item in tags)
- self.assertNotIn('key1', td)
-
- for instance in reservation.instances:
- instance.remove_tag('key1', value='value1')
-
- tags = self.ec2_client.get_all_tags()
-
- # NOTE: Volume-attach and detach causes metadata (tags) to be created
- # for the volume. So exclude them while asserting.
- self.assertNotIn('key1', tags)
-
- for instance in reservation.instances:
- instance.stop()
- LOG.info("state: %s", instance.state)
- if instance.state != "stopped":
- self.assertInstanceStateWait(instance, "stopped")
-
- self._terminate_reservation(reservation, rcuk)
-
- @test.idempotent_id('252945b5-3294-4fda-ae21-928a42f63f76')
- def test_run_terminate_instance(self):
- # EC2 run, terminate immediately
- image_ami = self.ec2_client.get_image(self.images["ami"]
- ["image_id"])
- reservation = image_ami.run(kernel_id=self.images["aki"]["image_id"],
- ramdisk_id=self.images["ari"]["image_id"],
- instance_type=self.instance_type)
-
- for instance in reservation.instances:
- instance.terminate()
- self.assertInstanceStateWait(instance, '_GONE')
-
- @test.idempotent_id('ab836c29-737b-4101-9fb9-87045eaf89e9')
- def test_compute_with_volumes(self):
- # EC2 1. integration test (not strict)
- image_ami = self.ec2_client.get_image(self.images["ami"]["image_id"])
- sec_group_name = data_utils.rand_name("securitygroup")
- group_desc = sec_group_name + " security group description "
- security_group = self.ec2_client.create_security_group(sec_group_name,
- group_desc)
- self.addResourceCleanUp(self.destroy_security_group_wait,
- security_group)
- self.assertTrue(
- self.ec2_client.authorize_security_group(
- sec_group_name,
- ip_protocol="icmp",
- cidr_ip="0.0.0.0/0",
- from_port=-1,
- to_port=-1))
- self.assertTrue(
- self.ec2_client.authorize_security_group(
- sec_group_name,
- ip_protocol="tcp",
- cidr_ip="0.0.0.0/0",
- from_port=22,
- to_port=22))
- reservation = image_ami.run(kernel_id=self.images["aki"]["image_id"],
- ramdisk_id=self.images["ari"]["image_id"],
- instance_type=self.instance_type,
- key_name=self.keypair_name,
- security_groups=(sec_group_name,))
-
- LOG.debug("Instance booted - state: %s",
- reservation.instances[0].state)
-
- self.addResourceCleanUp(self.destroy_reservation,
- reservation)
- volume = self.ec2_client.create_volume(CONF.volume.volume_size,
- self.zone)
- LOG.debug("Volume created - status: %s", volume.status)
-
- self.addResourceCleanUp(self.destroy_volume_wait, volume)
- instance = reservation.instances[0]
- if instance.state != "running":
- self.assertInstanceStateWait(instance, "running")
- LOG.debug("Instance now running - state: %s", instance.state)
-
- address = self.ec2_client.allocate_address()
- rcuk_a = self.addResourceCleanUp(address.delete)
- self.assertTrue(address.associate(instance.id))
-
- rcuk_da = self.addResourceCleanUp(address.disassociate)
- # TODO(afazekas): ping test. dependecy/permission ?
-
- self.assertVolumeStatusWait(volume, "available")
- # NOTE(afazekas): it may be reports available before it is available
-
- ssh = remote_client.RemoteClient(address.public_ip,
- CONF.compute.ssh_user,
- pkey=self.keypair.material)
- text = data_utils.rand_name("Pattern text for console output")
- try:
- resp = ssh.write_to_console(text)
- except Exception:
- if not CONF.compute_feature_enabled.console_output:
- LOG.debug('Console output not supported, cannot log')
- else:
- console_output = instance.get_console_output().output
- LOG.debug('Console output for %s\nbody=\n%s',
- instance.id, console_output)
- raise
-
- self.assertFalse(resp)
-
- def _output():
- output = instance.get_console_output()
- return output.output
-
- wait.re_search_wait(_output, text)
- part_lines = ssh.get_partitions().split('\n')
- volume.attach(instance.id, "/dev/vdh")
-
- def _volume_state():
- """Return volume state realizing that 'in-use' is overloaded."""
- volume.update(validate=True)
- status = volume.status
- attached = volume.attach_data.status
- LOG.debug("Volume %s is in status: %s, attach_status: %s",
- volume.id, status, attached)
- # Nova reports 'in-use' on 'attaching' volumes because we
- # have a single volume status, and EC2 has 2. Ensure that
- # if we aren't attached yet we return something other than
- # 'in-use'
- if status == 'in-use' and attached != 'attached':
- return 'attaching'
- else:
- return status
-
- wait.re_search_wait(_volume_state, "in-use")
-
- # NOTE(afazekas): Different Hypervisor backends names
- # differently the devices,
- # now we just test is the partition number increased/decrised
-
- def _part_state():
- current = ssh.get_partitions().split('\n')
- LOG.debug("Partition map for instance: %s", current)
- if current > part_lines:
- return 'INCREASE'
- if current < part_lines:
- return 'DECREASE'
- return 'EQUAL'
-
- wait.state_wait(_part_state, 'INCREASE')
- part_lines = ssh.get_partitions().split('\n')
-
- # TODO(afazekas): Resource compare to the flavor settings
-
- volume.detach()
-
- self.assertVolumeStatusWait(volume, "available")
-
- wait.state_wait(_part_state, 'DECREASE')
-
- instance.stop()
- address.disassociate()
- self.assertAddressDisassociatedWait(address)
- self.cancelResourceCleanUp(rcuk_da)
- address.release()
- self.assertAddressReleasedWait(address)
- self.cancelResourceCleanUp(rcuk_a)
-
- LOG.debug("Instance %s state: %s", instance.id, instance.state)
- if instance.state != "stopped":
- self.assertInstanceStateWait(instance, "stopped")
- # TODO(afazekas): move steps from teardown to the test case
-
-
-# TODO(afazekas): Snapshot/volume read/write test case
diff --git a/tempest/thirdparty/boto/test_ec2_keys.py b/tempest/thirdparty/boto/test_ec2_keys.py
deleted file mode 100644
index 1b58cb4..0000000
--- a/tempest/thirdparty/boto/test_ec2_keys.py
+++ /dev/null
@@ -1,75 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.common.utils import data_utils
-from tempest import test
-from tempest.thirdparty.boto import test as boto_test
-
-
-def compare_key_pairs(a, b):
- return (a.name == b.name and
- a.fingerprint == b.fingerprint)
-
-
-class EC2KeysTest(boto_test.BotoTestCase):
-
- @classmethod
- def setup_clients(cls):
- super(EC2KeysTest, cls).setup_clients()
- cls.client = cls.os.ec2api_client
-
- @classmethod
- def resource_setup(cls):
- super(EC2KeysTest, cls).resource_setup()
- cls.ec = cls.ec2_error_code
-
-# TODO(afazekas): merge create, delete, get test cases
- @test.idempotent_id('54236804-01b7-4cfe-a6f9-bce1340feec8')
- def test_create_ec2_keypair(self):
- # EC2 create KeyPair
- key_name = data_utils.rand_name("keypair")
- self.addResourceCleanUp(self.client.delete_key_pair, key_name)
- keypair = self.client.create_key_pair(key_name)
- self.assertTrue(compare_key_pairs(keypair,
- self.client.get_key_pair(key_name)))
-
- @test.idempotent_id('3283b898-f90c-4952-b238-3e42b8c3f34f')
- def test_delete_ec2_keypair(self):
- # EC2 delete KeyPair
- key_name = data_utils.rand_name("keypair")
- self.client.create_key_pair(key_name)
- self.client.delete_key_pair(key_name)
- self.assertIsNone(self.client.get_key_pair(key_name))
-
- @test.idempotent_id('fd89bd26-4d4d-4cf3-a303-65dd9158fcdc')
- def test_get_ec2_keypair(self):
- # EC2 get KeyPair
- key_name = data_utils.rand_name("keypair")
- self.addResourceCleanUp(self.client.delete_key_pair, key_name)
- keypair = self.client.create_key_pair(key_name)
- self.assertTrue(compare_key_pairs(keypair,
- self.client.get_key_pair(key_name)))
-
- @test.idempotent_id('daa73da1-e11c-4558-8d76-a716be79a401')
- def test_duplicate_ec2_keypair(self):
- # EC2 duplicate KeyPair
- key_name = data_utils.rand_name("keypair")
- self.addResourceCleanUp(self.client.delete_key_pair, key_name)
- keypair = self.client.create_key_pair(key_name)
- self.assertBotoError(self.ec.client.InvalidKeyPair.Duplicate,
- self.client.create_key_pair,
- key_name)
- self.assertTrue(compare_key_pairs(keypair,
- self.client.get_key_pair(key_name)))
diff --git a/tempest/thirdparty/boto/test_ec2_security_groups.py b/tempest/thirdparty/boto/test_ec2_security_groups.py
deleted file mode 100644
index 594dc8b..0000000
--- a/tempest/thirdparty/boto/test_ec2_security_groups.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.common.utils import data_utils
-from tempest import test
-from tempest.thirdparty.boto import test as boto_test
-
-
-class EC2SecurityGroupTest(boto_test.BotoTestCase):
-
- @classmethod
- def setup_clients(cls):
- super(EC2SecurityGroupTest, cls).setup_clients()
- cls.client = cls.os.ec2api_client
-
- @test.idempotent_id('519b566e-0c38-4629-905e-7d6b6355f524')
- def test_create_authorize_security_group(self):
- # EC2 Create, authorize/revoke security group
- group_name = data_utils.rand_name("securty_group")
- group_description = group_name + " security group description "
- group = self.client.create_security_group(group_name,
- group_description)
- self.addResourceCleanUp(self.client.delete_security_group, group_name)
- groups_get = self.client.get_all_security_groups(
- groupnames=(group_name,))
- self.assertEqual(len(groups_get), 1)
- group_get = groups_get[0]
- self.assertEqual(group.name, group_get.name)
- self.assertEqual(group.name, group_get.name)
- # ping (icmp_echo) and other icmp allowed from everywhere
- # from_port and to_port act as icmp type
- success = self.client.authorize_security_group(group_name,
- ip_protocol="icmp",
- cidr_ip="0.0.0.0/0",
- from_port=-1,
- to_port=-1)
- self.assertTrue(success)
- # allow standard ssh port from anywhere
- success = self.client.authorize_security_group(group_name,
- ip_protocol="tcp",
- cidr_ip="0.0.0.0/0",
- from_port=22,
- to_port=22)
- self.assertTrue(success)
- # TODO(afazekas): Duplicate tests
- group_get = self.client.get_all_security_groups(
- groupnames=(group_name,))[0]
- # remove listed rules
- for ip_permission in group_get.rules:
- for cidr in ip_permission.grants:
- self.assertTrue(self.client.revoke_security_group(group_name,
- ip_protocol=ip_permission.ip_protocol,
- cidr_ip=cidr,
- from_port=ip_permission.from_port,
- to_port=ip_permission.to_port))
-
- group_get = self.client.get_all_security_groups(
- groupnames=(group_name,))[0]
- # all rules should be removed now
- self.assertEqual(0, len(group_get.rules))
diff --git a/tempest/thirdparty/boto/test_ec2_volumes.py b/tempest/thirdparty/boto/test_ec2_volumes.py
deleted file mode 100644
index 483d4c3..0000000
--- a/tempest/thirdparty/boto/test_ec2_volumes.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from oslo_log import log as logging
-
-from tempest import config
-from tempest import test
-from tempest.thirdparty.boto import test as boto_test
-
-CONF = config.CONF
-LOG = logging.getLogger(__name__)
-
-
-def compare_volumes(a, b):
- return (a.id == b.id and
- a.size == b.size)
-
-
-class EC2VolumesTest(boto_test.BotoTestCase):
-
- @classmethod
- def skip_checks(cls):
- super(EC2VolumesTest, cls).skip_checks()
- if not CONF.service_available.cinder:
- skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
- raise cls.skipException(skip_msg)
-
- @classmethod
- def setup_clients(cls):
- super(EC2VolumesTest, cls).setup_clients()
- cls.client = cls.os.ec2api_client
-
- @classmethod
- def resource_setup(cls):
- super(EC2VolumesTest, cls).resource_setup()
- cls.zone = CONF.boto.aws_zone
-
- @test.idempotent_id('663f0077-c743-48ad-8ae0-46821cbc0918')
- def test_create_get_delete(self):
- # EC2 Create, get, delete Volume
- volume = self.client.create_volume(CONF.volume.volume_size, self.zone)
- cuk = self.addResourceCleanUp(self.client.delete_volume, volume.id)
- self.assertIn(volume.status, self.valid_volume_status)
- retrieved = self.client.get_all_volumes((volume.id,))
- self.assertEqual(1, len(retrieved))
- self.assertTrue(compare_volumes(volume, retrieved[0]))
- self.assertVolumeStatusWait(volume, "available")
- self.client.delete_volume(volume.id)
- self.cancelResourceCleanUp(cuk)
-
- @test.idempotent_id('c6b60d7a-1af7-4f8e-af21-d539d9496149')
- def test_create_volume_from_snapshot(self):
- # EC2 Create volume from snapshot
- volume = self.client.create_volume(CONF.volume.volume_size, self.zone)
- self.addResourceCleanUp(self.client.delete_volume, volume.id)
- self.assertVolumeStatusWait(volume, "available")
- snap = self.client.create_snapshot(volume.id)
- self.addResourceCleanUp(self.destroy_snapshot_wait, snap)
- self.assertSnapshotStatusWait(snap, "completed")
-
- svol = self.client.create_volume(CONF.volume.volume_size, self.zone,
- snapshot=snap)
- cuk = self.addResourceCleanUp(svol.delete)
- self.assertVolumeStatusWait(svol, "available")
- svol.delete()
- self.cancelResourceCleanUp(cuk)
diff --git a/tempest/thirdparty/boto/test_s3_buckets.py b/tempest/thirdparty/boto/test_s3_buckets.py
deleted file mode 100644
index f008973..0000000
--- a/tempest/thirdparty/boto/test_s3_buckets.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.common.utils import data_utils
-from tempest import test
-from tempest.thirdparty.boto import test as boto_test
-
-
-class S3BucketsTest(boto_test.BotoTestCase):
-
- @classmethod
- def setup_clients(cls):
- super(S3BucketsTest, cls).setup_clients()
- cls.client = cls.os.s3_client
-
- @test.idempotent_id('4678525d-8da0-4518-81c1-f1f67d595b00')
- def test_create_and_get_delete_bucket(self):
- # S3 Create, get and delete bucket
- bucket_name = data_utils.rand_name("s3bucket")
- cleanup_key = self.addResourceCleanUp(self.client.delete_bucket,
- bucket_name)
- bucket = self.client.create_bucket(bucket_name)
- self.assertTrue(bucket.name == bucket_name)
- bucket = self.client.get_bucket(bucket_name)
- self.assertTrue(bucket.name == bucket_name)
- self.client.delete_bucket(bucket_name)
- self.assertBotoError(self.s3_error_code.client.NoSuchBucket,
- self.client.get_bucket, bucket_name)
- self.cancelResourceCleanUp(cleanup_key)
diff --git a/tempest/thirdparty/boto/test_s3_ec2_images.py b/tempest/thirdparty/boto/test_s3_ec2_images.py
deleted file mode 100644
index c41c7ac..0000000
--- a/tempest/thirdparty/boto/test_s3_ec2_images.py
+++ /dev/null
@@ -1,126 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import os
-
-from tempest.common.utils import data_utils
-from tempest import config
-from tempest import test
-from tempest.thirdparty.boto import test as boto_test
-from tempest.thirdparty.boto.utils import s3
-
-CONF = config.CONF
-
-
-class S3ImagesTest(boto_test.BotoTestCase):
-
- @classmethod
- def setup_clients(cls):
- super(S3ImagesTest, cls).setup_clients()
- cls.s3_client = cls.os.s3_client
- cls.images_client = cls.os.ec2api_client
-
- @classmethod
- def resource_setup(cls):
- super(S3ImagesTest, cls).resource_setup()
- if not cls.conclusion['A_I_IMAGES_READY']:
- raise cls.skipException("".join(("EC2 ", cls.__name__,
- ": requires ami/aki/ari manifest")))
- cls.materials_path = CONF.boto.s3_materials_path
- cls.ami_manifest = CONF.boto.ami_manifest
- cls.aki_manifest = CONF.boto.aki_manifest
- cls.ari_manifest = CONF.boto.ari_manifest
- cls.ami_path = cls.materials_path + os.sep + cls.ami_manifest
- cls.aki_path = cls.materials_path + os.sep + cls.aki_manifest
- cls.ari_path = cls.materials_path + os.sep + cls.ari_manifest
- cls.bucket_name = data_utils.rand_name("bucket")
- bucket = cls.s3_client.create_bucket(cls.bucket_name)
- cls.addResourceCleanUp(cls.destroy_bucket,
- cls.s3_client.connection_data,
- cls.bucket_name)
- s3.s3_upload_dir(bucket, cls.materials_path)
-
- @test.idempotent_id('f9d360a5-0188-4c77-9db2-4c34c28d12a5')
- def test_register_get_deregister_ami_image(self):
- # Register and deregister ami image
- image = {"name": data_utils.rand_name("ami-name"),
- "location": self.bucket_name + "/" + self.ami_manifest,
- "type": "ami"}
- image["image_id"] = self.images_client.register_image(
- name=image["name"],
- image_location=image["location"])
- # NOTE(afazekas): delete_snapshot=True might trigger boto lib? bug
- image["cleanUp"] = self.addResourceCleanUp(
- self.images_client.deregister_image,
- image["image_id"])
- self.assertEqual(image["image_id"][0:3], image["type"])
- retrieved_image = self.images_client.get_image(image["image_id"])
- self.assertTrue(retrieved_image.name == image["name"])
- self.assertTrue(retrieved_image.id == image["image_id"])
- if retrieved_image.state != "available":
- self.assertImageStateWait(retrieved_image, "available")
- self.images_client.deregister_image(image["image_id"])
- self.assertNotIn(image["image_id"], str(
- self.images_client.get_all_images()))
- self.cancelResourceCleanUp(image["cleanUp"])
-
- @test.idempotent_id('42cca5b0-453b-4618-b99f-dbc039db426f')
- def test_register_get_deregister_aki_image(self):
- # Register and deregister aki image
- image = {"name": data_utils.rand_name("aki-name"),
- "location": self.bucket_name + "/" + self.aki_manifest,
- "type": "aki"}
- image["image_id"] = self.images_client.register_image(
- name=image["name"],
- image_location=image["location"])
- image["cleanUp"] = self.addResourceCleanUp(
- self.images_client.deregister_image,
- image["image_id"])
- self.assertEqual(image["image_id"][0:3], image["type"])
- retrieved_image = self.images_client.get_image(image["image_id"])
- self.assertTrue(retrieved_image.name == image["name"])
- self.assertTrue(retrieved_image.id == image["image_id"])
- self.assertIn(retrieved_image.state, self.valid_image_state)
- if retrieved_image.state != "available":
- self.assertImageStateWait(retrieved_image, "available")
- self.images_client.deregister_image(image["image_id"])
- self.assertNotIn(image["image_id"], str(
- self.images_client.get_all_images()))
- self.cancelResourceCleanUp(image["cleanUp"])
-
- @test.idempotent_id('1359e860-841c-43bb-80f3-bb389cbfd81d')
- def test_register_get_deregister_ari_image(self):
- # Register and deregister ari image
- image = {"name": data_utils.rand_name("ari-name"),
- "location": "/" + self.bucket_name + "/" + self.ari_manifest,
- "type": "ari"}
- image["image_id"] = self.images_client.register_image(
- name=image["name"],
- image_location=image["location"])
- image["cleanUp"] = self.addResourceCleanUp(
- self.images_client.deregister_image,
- image["image_id"])
- self.assertEqual(image["image_id"][0:3], image["type"])
- retrieved_image = self.images_client.get_image(image["image_id"])
- self.assertIn(retrieved_image.state, self.valid_image_state)
- if retrieved_image.state != "available":
- self.assertImageStateWait(retrieved_image, "available")
- self.assertIn(retrieved_image.state, self.valid_image_state)
- self.assertTrue(retrieved_image.name == image["name"])
- self.assertTrue(retrieved_image.id == image["image_id"])
- self.images_client.deregister_image(image["image_id"])
- self.cancelResourceCleanUp(image["cleanUp"])
-
-# TODO(afazekas): less copy-paste style
diff --git a/tempest/thirdparty/boto/test_s3_objects.py b/tempest/thirdparty/boto/test_s3_objects.py
deleted file mode 100644
index c42d85c..0000000
--- a/tempest/thirdparty/boto/test_s3_objects.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import contextlib
-
-import boto.s3.key
-
-from tempest.common.utils import data_utils
-from tempest import test
-from tempest.thirdparty.boto import test as boto_test
-
-
-class S3BucketsTest(boto_test.BotoTestCase):
-
- @classmethod
- def setup_clients(cls):
- super(S3BucketsTest, cls).setup_clients()
- cls.client = cls.os.s3_client
-
- @test.idempotent_id('4eea567a-b46a-405b-a475-6097e1faebde')
- def test_create_get_delete_object(self):
- # S3 Create, get and delete object
- bucket_name = data_utils.rand_name("s3bucket")
- object_name = data_utils.rand_name("s3object")
- content = 'x' * 42
- bucket = self.client.create_bucket(bucket_name)
- self.addResourceCleanUp(self.destroy_bucket,
- self.client.connection_data,
- bucket_name)
-
- self.assertTrue(bucket.name == bucket_name)
- with contextlib.closing(boto.s3.key.Key(bucket)) as key:
- key.key = object_name
- key.set_contents_from_string(content)
- readback = key.get_contents_as_string()
- self.assertTrue(readback == content)
- bucket.delete_key(key)
- self.assertBotoError(self.s3_error_code.client.NoSuchKey,
- key.get_contents_as_string)
diff --git a/tempest/thirdparty/boto/utils/__init__.py b/tempest/thirdparty/boto/utils/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/thirdparty/boto/utils/__init__.py
+++ /dev/null
diff --git a/tempest/thirdparty/boto/utils/s3.py b/tempest/thirdparty/boto/utils/s3.py
deleted file mode 100644
index 55c1b0a..0000000
--- a/tempest/thirdparty/boto/utils/s3.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import contextlib
-import os
-import re
-
-import boto
-import boto.s3.key
-
-from oslo_log import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def s3_upload_dir(bucket, path, prefix="", connection_data=None):
- if isinstance(bucket, basestring):
- with contextlib.closing(boto.connect_s3(**connection_data)) as conn:
- bucket = conn.lookup(bucket)
- for root, dirs, files in os.walk(path):
- for fil in files:
- with contextlib.closing(boto.s3.key.Key(bucket)) as key:
- source = root + os.sep + fil
- target = re.sub("^" + re.escape(path) + "?/", prefix, source)
- if os.sep != '/':
- target = re.sub(re.escape(os.sep), '/', target)
- key.key = target
- LOG.info("Uploading %s to %s/%s", source, bucket.name, target)
- key.set_contents_from_filename(source)
diff --git a/tempest/thirdparty/boto/utils/wait.py b/tempest/thirdparty/boto/utils/wait.py
deleted file mode 100644
index 8771ed7..0000000
--- a/tempest/thirdparty/boto/utils/wait.py
+++ /dev/null
@@ -1,125 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import re
-import time
-
-import boto.exception
-from oslo_log import log as logging
-import testtools
-
-from tempest import config
-
-CONF = config.CONF
-LOG = logging.getLogger(__name__)
-
-
-def state_wait(lfunction, final_set=set(), valid_set=None):
- # TODO(afazekas): evaluate using ABC here
- if not isinstance(final_set, set):
- final_set = set((final_set,))
- if not isinstance(valid_set, set) and valid_set is not None:
- valid_set = set((valid_set,))
- start_time = time.time()
- old_status = status = lfunction()
- while True:
- if status != old_status:
- LOG.info('State transition "%s" ==> "%s" %d second', old_status,
- status, time.time() - start_time)
- if status in final_set:
- return status
- if valid_set is not None and status not in valid_set:
- return status
- dtime = time.time() - start_time
- if dtime > CONF.boto.build_timeout:
- raise testtools.TestCase\
- .failureException("State change timeout exceeded!"
- '(%ds) While waiting'
- 'for %s at "%s"' %
- (dtime, final_set, status))
- time.sleep(CONF.boto.build_interval)
- old_status = status
- status = lfunction()
-
-
-def re_search_wait(lfunction, regexp):
- """Stops waiting on success."""
- start_time = time.time()
- while True:
- text = lfunction()
- result = re.search(regexp, text)
- if result is not None:
- LOG.info('Pattern "%s" found in %d second in "%s"',
- regexp,
- time.time() - start_time,
- text)
- return result
- dtime = time.time() - start_time
- if dtime > CONF.boto.build_timeout:
- raise testtools.TestCase\
- .failureException('Pattern find timeout exceeded!'
- '(%ds) While waiting for'
- '"%s" pattern in "%s"' %
- (dtime, regexp, text))
- time.sleep(CONF.boto.build_interval)
-
-
-def wait_no_exception(lfunction, exc_class=None, exc_matcher=None):
- """Stops waiting on success."""
- start_time = time.time()
- if exc_matcher is not None:
- exc_class = boto.exception.BotoServerError
-
- if exc_class is None:
- exc_class = BaseException
- while True:
- result = None
- try:
- result = lfunction()
- LOG.info('No Exception in %d second',
- time.time() - start_time)
- return result
- except exc_class as exc:
- if exc_matcher is not None:
- res = exc_matcher.match(exc)
- if res is not None:
- LOG.info(res)
- raise exc
- # Let the other exceptions propagate
- dtime = time.time() - start_time
- if dtime > CONF.boto.build_timeout:
- raise testtools.TestCase\
- .failureException("Wait timeout exceeded! (%ds)" % dtime)
- time.sleep(CONF.boto.build_interval)
-
-
-# NOTE(afazekas): EC2/boto normally raise exception instead of empty list
-def wait_exception(lfunction):
- """Returns with the exception or raises one."""
- start_time = time.time()
- while True:
- try:
- lfunction()
- except BaseException as exc:
- LOG.info('Exception in %d second',
- time.time() - start_time)
- return exc
- dtime = time.time() - start_time
- if dtime > CONF.boto.build_timeout:
- raise testtools.TestCase\
- .failureException("Wait timeout exceeded! (%ds)" % dtime)
- time.sleep(CONF.boto.build_interval)
-
-# TODO(afazekas): consider strategy design pattern..
diff --git a/tox.ini b/tox.ini
index 41eece1..fedd04c 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = pep8,py27,py34
+envlist = pep8,py34,py27
minversion = 1.6
skipsdist = True