Merge "Fix pep8 violations in stress tests"
diff --git a/tempest/services/volume/json/admin/__init__.py b/tempest/services/volume/json/admin/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/volume/json/admin/__init__.py
diff --git a/tempest/services/volume/json/admin/volume_types_client.py b/tempest/services/volume/json/admin/volume_types_client.py
new file mode 100644
index 0000000..fc8897f
--- /dev/null
+++ b/tempest/services/volume/json/admin/volume_types_client.py
@@ -0,0 +1,124 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012 OpenStack, LLC
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import json
+import urllib
+
+from tempest.common.rest_client import RestClient
+
+
+class VolumeTypesClientJSON(RestClient):
+ """
+ Client class to send CRUD Volume Types API requests to a Cinder endpoint
+ """
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(VolumeTypesClientJSON, self).__init__(config, username, password,
+ auth_url, tenant_name)
+
+ self.service = self.config.volume.catalog_type
+ self.build_interval = self.config.volume.build_interval
+ self.build_timeout = self.config.volume.build_timeout
+
+ def list_volume_types(self, params=None):
+ """List all the volume_types created"""
+ url = 'types'
+ if params is not None:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['volume_types']
+
+ def get_volume_type(self, volume_id):
+ """Returns the details of a single volume_type"""
+ url = "types/%s" % str(volume_id)
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['volume_type']
+
+ def create_volume_type(self, name, **kwargs):
+ """
+ Creates a new Volume_type.
+ name(Required): Name of volume_type.
+ Following optional keyword arguments are accepted:
+ extra_specs: A dictionary of values to be used as extra_specs.
+ """
+ post_body = {
+ 'name': name,
+ 'extra_specs': kwargs.get('extra_specs'),
+ }
+
+ post_body = json.dumps({'volume_type': post_body})
+ resp, body = self.post('types', post_body, self.headers)
+ body = json.loads(body)
+ return resp, body['volume_type']
+
+ def delete_volume_type(self, volume_id):
+ """Deletes the Specified Volume_type"""
+ return self.delete("types/%s" % str(volume_id))
+
+ def list_volume_types_extra_specs(self, vol_type_id, params=None):
+ """List all the volume_types extra specs created"""
+ url = 'types/%s/extra_specs' % str(vol_type_id)
+ if params is not None:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['extra_specs']
+
+ def get_volume_type_extra_specs(self, vol_type_id, extra_spec_name):
+ """Returns the details of a single volume_type extra spec"""
+ url = "types/%s/extra_specs/%s" % (str(vol_type_id),
+ str(extra_spec_name))
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body
+
+ def create_volume_type_extra_specs(self, vol_type_id, extra_spec):
+ """
+ Creates a new Volume_type extra spec.
+ vol_type_id: Id of volume_type.
+ extra_specs: A dictionary of values to be used as extra_specs.
+ """
+ url = "types/%s/extra_specs" % str(vol_type_id)
+ post_body = json.dumps({'extra_specs': extra_spec})
+ resp, body = self.post(url, post_body, self.headers)
+ body = json.loads(body)
+ return resp, body['extra_specs']
+
+ def delete_volume_type_extra_specs(self, vol_id, extra_spec_name):
+ """Deletes the Specified Volume_type extra spec"""
+ return self.delete("types/%s/extra_specs/%s" % ((str(vol_id)),
+ str(extra_spec_name)))
+
+ def update_volume_type_extra_specs(self, vol_type_id, extra_spec_name,
+ extra_spec):
+ """
+ Update a volume_type extra spec.
+ vol_type_id: Id of volume_type.
+ extra_spec_name: Name of the extra spec to be updated.
+ extra_spec: A dictionary of with key as extra_spec_name and the
+ updated value.
+ """
+ url = "types/%s/extra_specs/%s" % (str(vol_type_id),
+ str(extra_spec_name))
+ put_body = json.dumps(extra_spec)
+ resp, body = self.put(url, put_body, self.headers)
+ body = json.loads(body)
+ return resp, body
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index 2045f3c..962fe72 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -70,11 +70,13 @@
Following optional keyword arguments are accepted:
display_name: Optional Volume Name.
metadata: A dictionary of values to be used as metadata.
+ volume_type: Optional Name of volume_type for the volume
"""
post_body = {
'size': size,
'display_name': kwargs.get('display_name'),
'metadata': kwargs.get('metadata'),
+ 'volume_type': kwargs.get('volume_type')
}
post_body = json.dumps({'volume': post_body})
diff --git a/tempest/tests/compute/floating_ips/test_floating_ips_actions.py b/tempest/tests/compute/floating_ips/test_floating_ips_actions.py
index 540d9f4..de6eca3 100644
--- a/tempest/tests/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/tests/compute/floating_ips/test_floating_ips_actions.py
@@ -129,7 +129,6 @@
else:
self.fail('Should not be able to delete a nonexistent floating IP')
- @unittest.skip("Skipped until the Bug #957706 is resolved")
@attr(type='negative')
def test_associate_nonexistant_floating_ip(self):
"""
@@ -204,7 +203,6 @@
#Deletion of server created in this method
resp, body = self.servers_client.delete_server(self.new_server_id)
- @unittest.skip("Skipped until the Bug #957706 is resolved")
@attr(type='negative')
def test_associate_ip_to_server_without_passing_floating_ip(self):
"""
diff --git a/tempest/tests/compute/test_authorization.py b/tempest/tests/compute/test_authorization.py
index beff07f..a31ee49 100644
--- a/tempest/tests/compute/test_authorization.py
+++ b/tempest/tests/compute/test_authorization.py
@@ -325,7 +325,6 @@
"happen if the tenant id does not match the"
" current user")
- @unittest.skip("Skipped until the Bug #1001118 is resolved")
@raises(exceptions.NotFound)
@attr(type='negative')
def test_delete_security_group_rule_of_alt_account_fails(self):
diff --git a/tempest/tests/volume/admin/__init__.py b/tempest/tests/volume/admin/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/tests/volume/admin/__init__.py
diff --git a/tempest/tests/volume/admin/test_volume_types.py b/tempest/tests/volume/admin/test_volume_types.py
new file mode 100644
index 0000000..a065891
--- /dev/null
+++ b/tempest/tests/volume/admin/test_volume_types.py
@@ -0,0 +1,156 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012 OpenStack, LLC
+# 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.data_utils import rand_name
+from tempest.services.volume.json.admin import volume_types_client
+from tempest.tests.volume.base import BaseVolumeTest
+
+
+class VolumeTypesTest(BaseVolumeTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(VolumeTypesTest, cls).setUpClass()
+ adm_user = cls.config.compute_admin.username
+ adm_pass = cls.config.compute_admin.password
+ adm_tenant = cls.config.compute_admin.tenant_name
+ auth_url = cls.config.identity.auth_url
+
+ cls.client = volume_types_client.VolumeTypesClientJSON(cls.config,
+ adm_user,
+ adm_pass,
+ auth_url,
+ adm_tenant)
+
+ @classmethod
+ def tearDownClass(cls):
+ super(VolumeTypesTest, cls).tearDownClass()
+
+ def test_volume_type_list(self):
+ """List Volume types."""
+ try:
+ resp, body = self.client.list_volume_types()
+ self.assertEqual(200, resp.status)
+ self.assertTrue(type(body), list)
+ except:
+ self.fail("Could not list volume types")
+
+ def test_create_get_delete_volume_with_volume_type_and_extra_specs(self):
+ """ Create/get/delete volume with volume_type and extra spec. """
+ try:
+ volume = {}
+ vol_name = rand_name("volume-")
+ vol_type_name = rand_name("volume-type-")
+ extra_specs = {"Spec1": "Val1", "Spec2": "Val2"}
+ body = {}
+ resp, body = self.client.create_volume_type(vol_type_name,
+ extra_specs=
+ extra_specs)
+ self.assertEqual(200, resp.status)
+ self.assertTrue('id' in body)
+ self.assertTrue('name' in body)
+ resp, volume = self.volumes_client.\
+ create_volume(size=1, display_name=vol_name,
+ volume_type=vol_type_name)
+ self.assertEqual(200, resp.status)
+ self.assertTrue('id' in volume)
+ self.assertTrue('display_name' in volume)
+ self.assertEqual(volume['display_name'], vol_name,
+ "The created volume name is not equal "
+ "to the requested name")
+ self.assertTrue(volume['id'] is not None,
+ "Field volume id is empty or not found.")
+ self.volumes_client.wait_for_volume_status(volume['id'],
+ 'available')
+ resp, fetched_volume = self.volumes_client.\
+ get_volume(volume['id'])
+ self.assertEqual(200, resp.status)
+ self.assertEqual(vol_name, fetched_volume['display_name'],
+ 'The fetched Volume is different '
+ 'from the created Volume')
+ self.assertEqual(volume['id'], fetched_volume['id'],
+ 'The fetched Volume is different '
+ 'from the created Volume')
+ self.assertEqual(vol_type_name, fetched_volume['volume_type'],
+ 'The fetched Volume is different '
+ 'from the created Volume')
+ except:
+ self.fail("Could not create correct volume with volume_type")
+ finally:
+ if volume:
+ # Delete the Volume if it was created
+ resp, _ = self.volumes_client.delete_volume(volume['id'])
+ self.assertEqual(202, resp.status)
+
+ if body:
+ resp, _ = self.client.delete_volume_type(body['id'])
+ self.assertEqual(202, resp.status)
+
+ def test_volume_type_create_delete(self):
+ """ Create/Delete volume type."""
+ try:
+ name = rand_name("volume-type-")
+ extra_specs = {"Spec1": "Val1", "Spec2": "Val2"}
+ resp, body = self.client.\
+ create_volume_type(name, extra_specs=extra_specs)
+ self.assertEqual(200, resp.status)
+ self.assertTrue('id' in body)
+ self.assertTrue('name' in body)
+ self.assertEqual(body['name'], name,
+ "The created volume_type name is not equal "
+ "to the requested name")
+ self.assertTrue(body['id'] is not None,
+ "Field volume_type id is empty or not found.")
+ resp, fetched_volume_type = self.client.\
+ delete_volume_type(body['id'])
+ self.assertEqual(202, resp.status)
+ except:
+ self.fail("Could not create a volume_type")
+
+ def test_volume_type_create_get(self):
+ """ Create/get volume type."""
+ try:
+ body = {}
+ name = rand_name("volume-type-")
+ extra_specs = {"Spec1": "Val1", "Spec2": "Val2"}
+ resp, body = self.client.\
+ create_volume_type(name, extra_specs=extra_specs)
+ self.assertEqual(200, resp.status)
+ self.assertTrue('id' in body)
+ self.assertTrue('name' in body)
+ self.assertEqual(body['name'], name,
+ "The created volume_type name is not equal "
+ "to the requested name")
+ self.assertTrue(body['id'] is not None,
+ "Field volume_type id is empty or not found.")
+ resp, fetched_volume_type = self.client.get_volume_type(body['id'])
+ self.assertEqual(200, resp.status)
+ self.assertEqual(name, fetched_volume_type['name'],
+ 'The fetched Volume_type is different '
+ 'from the created Volume_type')
+ self.assertEqual(str(body['id']), fetched_volume_type['id'],
+ 'The fetched Volume_type is different '
+ 'from the created Volume_type')
+ self.assertEqual(extra_specs, fetched_volume_type['extra_specs'],
+ 'The fetched Volume_type is different '
+ 'from the created Volume_type')
+ except:
+ self.fail("Could not create a volume_type")
+ finally:
+ if body:
+ resp, _ = self.client.delete_volume_type(body['id'])
+ self.assertEqual(202, resp.status)
diff --git a/tempest/tests/volume/admin/test_volume_types_extra_specs.py b/tempest/tests/volume/admin/test_volume_types_extra_specs.py
new file mode 100644
index 0000000..3f06c85
--- /dev/null
+++ b/tempest/tests/volume/admin/test_volume_types_extra_specs.py
@@ -0,0 +1,109 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012 OpenStack, LLC
+# 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.data_utils import rand_name
+from tempest.tests.volume.base import BaseVolumeTest
+from tempest.services.volume.json.admin import volume_types_client
+
+
+class VolumeTypesExtraSpecsTest(BaseVolumeTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(VolumeTypesExtraSpecsTest, cls).setUpClass()
+
+ adm_user = cls.config.compute_admin.username
+ adm_pass = cls.config.compute_admin.password
+ adm_tenant = cls.config.compute_admin.tenant_name
+ auth_url = cls.config.identity.auth_url
+
+ cls.client = volume_types_client.VolumeTypesClientJSON(cls.config,
+ adm_user,
+ adm_pass,
+ auth_url,
+ adm_tenant)
+
+ vol_type_name = rand_name('Volume-type-')
+ cls.extra_spec = {"spec1": "val1"}
+ resp, cls.volume_type = cls.client.create_volume_type(vol_type_name)
+
+ @classmethod
+ def tearDownClass(cls):
+ super(VolumeTypesExtraSpecsTest, cls).tearDownClass()
+ cls.client.delete_volume_type(cls.volume_type['id'])
+
+ def test_volume_type_extra_specs_list(self):
+ """List Volume types extra specs."""
+ try:
+ resp, body = self.client.\
+ list_volume_types_extra_specs(self.volume_type['id'])
+ self.assertEqual(200, resp.status)
+ self.assertTrue(type(body), dict)
+ self.assertTrue('spec1' in body, "Incorrect volume type extra"
+ " spec returned")
+ except:
+ self.fail("Could not list volume types extra specs")
+
+ def test_volume_type_extra_specs_update(self):
+ """ Update volume type extra specs"""
+ try:
+ extra_spec = {"spec1": "val2"}
+ resp, body = self.client.\
+ update_volume_type_extra_specs(self.volume_type['id'],
+ extra_spec.keys()[0],
+ extra_spec)
+ self.assertEqual(200, resp.status)
+ self.assertTrue('spec1' in body,
+ "Volume type extra spec incorrectly updated")
+ self.assertEqual(extra_spec['spec1'], body['spec1'],
+ "Volume type extra spec incorrectly updated")
+ except:
+ self.fail("Couldnt update volume type extra spec")
+
+ def test_volume_type_extra_spec_create_delete(self):
+ """ Create/Delete volume type extra spec."""
+ try:
+ extra_specs = {"spec2": "val1"}
+ resp, body = self.client.\
+ create_volume_type_extra_specs(self.volume_type['id'], extra_specs)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(extra_specs, body,
+ "Volume type extra spec incorrectly created")
+ resp, _ = self.client.\
+ delete_volume_type_extra_specs(self.volume_type['id'],
+ extra_specs.keys()[0])
+ self.assertEqual(202, resp.status)
+ except:
+ self.fail("Could not create a volume_type extra spec")
+
+ def test_volume_type_extra_spec_create_get(self):
+ """ Create/get volume type extra spec"""
+ try:
+ extra_specs = {"spec1": "val1"}
+ resp, body = self.client.\
+ create_volume_type_extra_specs(self.volume_type['id'], extra_specs)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(extra_specs, body,
+ "Volume type extra spec incorrectly created")
+ resp, fetched_vol_type_extra_spec = self.client.\
+ get_volume_type_extra_specs(self.volume_type['id'],
+ extra_specs.keys()[0])
+ self.assertEqual(200, resp.status)
+ self.assertEqual(extra_specs, body,
+ "Volume type extra spec incorrectly fetched")
+ except:
+ self.fail("Could not create a volume_type extra spec")