Merge "Sync latest install_venv_common from oslo."
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 43277d6..9dca609 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -104,10 +104,6 @@
# Does the compute API support changing the admin password?
change_password_available=true
-# Level to log Compute API request/response details.
-log_level = ERROR
-
-
# Run live migration tests (requires 2 hosts)
live_migration_available = false
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index fa2ea75..5af4a40 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -15,10 +15,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+import hashlib
import httplib2
import json
import logging
from lxml import etree
+import re
import time
from tempest import exceptions
@@ -26,14 +28,14 @@
# redrive rate limited calls at most twice
MAX_RECURSION_DEPTH = 2
+TOKEN_CHARS_RE = re.compile('^[-A-Za-z0-9+/=]*$')
class RestClient(object):
TYPE = "json"
+ LOG = logging.getLogger(__name__)
def __init__(self, config, user, password, auth_url, tenant_name=None):
- self.log = logging.getLogger(__name__)
- self.log.setLevel(getattr(logging, config.compute.log_level))
self.config = config
self.user = user
self.password = password
@@ -189,11 +191,38 @@
def copy(self, url, headers=None):
return self.request('COPY', url, headers)
- def _log(self, req_url, body, resp, resp_body):
- self.log.error('Request URL: ' + req_url)
- self.log.error('Request Body: ' + str(body))
- self.log.error('Response Headers: ' + str(resp))
- self.log.error('Response Body: ' + str(resp_body))
+ def _log_request(self, method, req_url, headers, body):
+ self.LOG.info('Request: ' + method + ' ' + req_url)
+ if headers:
+ print_headers = headers
+ if 'X-Auth-Token' in headers and headers['X-Auth-Token']:
+ token = headers['X-Auth-Token']
+ if len(token) > 64 and TOKEN_CHARS_RE.match(token):
+ print_headers = headers.copy()
+ print_headers['X-Auth-Token'] = "<Token omitted>"
+ self.LOG.debug('Request Headers: ' + str(print_headers))
+ if body:
+ str_body = str(body)
+ length = len(str_body)
+ self.LOG.debug('Request Body: ' + str_body[:2048])
+ if length >= 2048:
+ self.LOG.debug("Large body (%d) md5 summary: %s", length,
+ hashlib.md5(str_body).hexdigest())
+
+ def _log_response(self, resp, resp_body):
+ status = resp['status']
+ self.LOG.info("Response Status: " + status)
+ headers = resp.copy()
+ del headers['status']
+ if len(headers):
+ self.LOG.debug('Response Headers: ' + str(headers))
+ if resp_body:
+ str_body = str(resp_body)
+ length = len(str_body)
+ self.LOG.debug('Response Body: ' + str_body[:2048])
+ if length >= 2048:
+ self.LOG.debug("Large body (%d) md5 summary: %s", length,
+ hashlib.md5(str_body).hexdigest())
def _parse_resp(self, body):
return json.loads(body)
@@ -224,7 +253,7 @@
# Likely it will cause error
if not body and resp.status >= 400:
- self.log.warning("status >= 400 response with empty body")
+ self.LOG.warning("status >= 400 response with empty body")
def request(self, method, url,
headers=None, body=None, depth=0, wait=None):
@@ -240,39 +269,34 @@
headers['X-Auth-Token'] = self.token
req_url = "%s/%s" % (self.base_url, url)
+ self._log_request(method, req_url, headers, body)
resp, resp_body = self.http_obj.request(req_url, method,
headers=headers, body=body)
+ self._log_response(resp, resp_body)
self.response_checker(method, url, headers, body, resp, resp_body)
if resp.status == 401 or resp.status == 403:
- self._log(req_url, body, resp, resp_body)
raise exceptions.Unauthorized()
if resp.status == 404:
- if not wait:
- self._log(req_url, body, resp, resp_body)
raise exceptions.NotFound(resp_body)
if resp.status == 400:
resp_body = self._parse_resp(resp_body)
- self._log(req_url, body, resp, resp_body)
raise exceptions.BadRequest(resp_body)
if resp.status == 409:
resp_body = self._parse_resp(resp_body)
- self._log(req_url, body, resp, resp_body)
raise exceptions.Duplicate(resp_body)
if resp.status == 413:
resp_body = self._parse_resp(resp_body)
- self._log(req_url, body, resp, resp_body)
#Checking whether Absolute/Rate limit
return self.check_over_limit(resp_body, method, url, headers, body,
depth, wait)
if resp.status in (500, 501):
resp_body = self._parse_resp(resp_body)
- self._log(req_url, body, resp, resp_body)
#I'm seeing both computeFault and cloudServersFault come back.
#Will file a bug to fix, but leave as is for now.
@@ -292,7 +316,6 @@
if resp.status >= 400:
resp_body = self._parse_resp(resp_body)
- self._log(req_url, body, resp, resp_body)
raise exceptions.RestClientException(str(resp.status))
return resp, resp_body
diff --git a/tempest/config.py b/tempest/config.py
index 38f3535..ec48f67 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -161,9 +161,6 @@
cfg.StrOpt('catalog_type',
default='compute',
help="Catalog type of the Compute service."),
- cfg.StrOpt('log_level',
- default="ERROR",
- help="Level for logging compute API calls."),
cfg.StrOpt('path_to_private_key',
default=None,
help="Path to a private key file for SSH access to remote "
diff --git a/tempest/services/object_storage/account_client.py b/tempest/services/object_storage/account_client.py
index 734307c..fec273c 100644
--- a/tempest/services/object_storage/account_client.py
+++ b/tempest/services/object_storage/account_client.py
@@ -112,11 +112,13 @@
self._set_auth()
req_url = "%s/%s" % (self.base_url, url)
+
+ self._log_request(method, req_url, headers, body)
resp, resp_body = self.http_obj.request(req_url, method,
headers=headers, body=body)
+ self._log_response(resp, resp_body)
if resp.status == 401 or resp.status == 403:
- self._log(req_url, body, resp, resp_body)
raise exceptions.Unauthorized()
return resp, resp_body
diff --git a/tempest/services/object_storage/object_client.py b/tempest/services/object_storage/object_client.py
index edfb234..187e80d 100644
--- a/tempest/services/object_storage/object_client.py
+++ b/tempest/services/object_storage/object_client.py
@@ -167,11 +167,11 @@
self._set_auth()
req_url = "%s/%s" % (self.base_url, url)
+ self._log_request(method, req_url, headers, body)
resp, resp_body = self.http_obj.request(req_url, method,
headers=headers, body=body)
-
+ self._log_response(resp, resp_body)
if resp.status == 401 or resp.status == 403:
- self._log(req_url, body, resp, resp_body)
raise exceptions.Unauthorized()
return resp, resp_body
diff --git a/tempest/tests/compute/admin/test_flavors.py b/tempest/tests/compute/admin/test_flavors.py
index eb2392c..2967666 100644
--- a/tempest/tests/compute/admin/test_flavors.py
+++ b/tempest/tests/compute/admin/test_flavors.py
@@ -258,6 +258,55 @@
self.assertEqual(resp.status, 202)
self.client.wait_for_resource_deletion(new_flavor_id)
+ @attr(type='positive')
+ def test_is_public_string_variations(self):
+ try:
+ flavor_id_not_public = rand_int_id(start=1000)
+ flavor_name_not_public = rand_name(self.flavor_name_prefix)
+ flavor_id_public = rand_int_id(start=1000)
+ flavor_name_public = rand_name(self.flavor_name_prefix)
+
+ # Create a non public flavor
+ resp, flavor = self.client.create_flavor(flavor_name_not_public,
+ self.ram, self.vcpus,
+ self.disk,
+ flavor_id_not_public,
+ is_public="False")
+
+ # Create a public flavor
+ resp, flavor = self.client.create_flavor(flavor_name_public,
+ self.ram, self.vcpus,
+ self.disk,
+ flavor_id_public,
+ is_public="True")
+
+ def _flavor_lookup(flavors, flavor_name):
+ for flavor in flavors:
+ if flavor['name'] == flavor_name:
+ return flavor
+ return None
+
+ def _test_string_variations(variations, flavor_name):
+ for string in variations:
+ params = {'is_public': string}
+ r, flavors = self.client.list_flavors_with_detail(params)
+ self.assertEqual(r.status, 200)
+ flavor = _flavor_lookup(flavors, flavor_name)
+ self.assertNotEqual(flavor, None)
+
+ _test_string_variations(['f', 'false', 'no', '0'],
+ flavor_name_not_public)
+
+ _test_string_variations(['t', 'true', 'yes', '1'],
+ flavor_name_public)
+
+ finally:
+ # Delete flavors
+ for flavor_id in [flavor_id_not_public, flavor_id_public]:
+ resp, body = self.client.delete_flavor(flavor_id)
+ self.assertEqual(resp.status, 202)
+ self.client.wait_for_resource_deletion(flavor_id)
+
class FlavorsAdminTestXML(base.BaseComputeAdminTestXML,
base.BaseComputeTestXML,
diff --git a/tempest/tests/compute/admin/test_flavors_extra_specs.py b/tempest/tests/compute/admin/test_flavors_extra_specs.py
index 5dd38d4..ef4c20e 100644
--- a/tempest/tests/compute/admin/test_flavors_extra_specs.py
+++ b/tempest/tests/compute/admin/test_flavors_extra_specs.py
@@ -15,9 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import nose
-from nose.plugins.attrib import attr
-
from tempest import exceptions
from tempest.tests import compute
from tempest.tests.compute import base
@@ -36,7 +33,7 @@
def setUpClass(self, cls):
if not compute.FLAVOR_EXTRA_DATA_ENABLED:
msg = "FlavorExtraData extension not enabled."
- raise nose.SkipTest(msg)
+ raise cls.skipException(msg)
cls.client = cls.os.flavors_client
flavor_name = 'test_flavor2'
diff --git a/tempest/tests/compute/images/test_images_oneserver.py b/tempest/tests/compute/images/test_images_oneserver.py
index f3b1e01..232d5d3 100644
--- a/tempest/tests/compute/images/test_images_oneserver.py
+++ b/tempest/tests/compute/images/test_images_oneserver.py
@@ -28,13 +28,6 @@
class ImagesOneServerTestBase(object):
- def tearDownClass(cls):
- """Terminate test instances created after a test is executed."""
- resp, body = self.servers_client.delete_server(cls.server['id'])
- if resp['status'] == '204':
- self.servers.remove(server)
- self.servers_client.wait_for_server_termination(cls.server['id'])
-
def tearDown(self):
"""Terminate test instances created after a test is executed."""
for image_id in self.image_ids:
diff --git a/tempest/tests/compute/servers/test_server_personality.py b/tempest/tests/compute/servers/test_server_personality.py
index 6ea0959..e98e559 100644
--- a/tempest/tests/compute/servers/test_server_personality.py
+++ b/tempest/tests/compute/servers/test_server_personality.py
@@ -70,9 +70,6 @@
personality=person)
self.assertEqual('202', resp['status'])
- except Exception:
- raise Error(resp['message'])
-
#Teardown
finally:
self.client.delete_server(server['id'])
diff --git a/tempest/tests/compute/test_authorization.py b/tempest/tests/compute/test_authorization.py
index fdc97ea..8f4ad50 100644
--- a/tempest/tests/compute/test_authorization.py
+++ b/tempest/tests/compute/test_authorization.py
@@ -15,8 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from nose.plugins.attrib import attr
-from nose.tools import raises
import testtools
from tempest import clients
@@ -99,36 +97,32 @@
cls.security_client.delete_security_group(cls.security_group['id'])
super(AuthorizationTest, cls).tearDownClass()
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_get_server_for_alt_account_fails(self):
# A GET request for a server on another user's account should fail
- self.alt_client.get_server(self.server['id'])
+ self.assertRaises(exceptions.NotFound, self.alt_client.get_server,
+ self.server['id'])
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_delete_server_for_alt_account_fails(self):
# A DELETE request for another user's server should fail
- self.alt_client.delete_server(self.server['id'])
+ self.assertRaises(exceptions.NotFound, self.alt_client.delete_server,
+ self.server['id'])
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_update_server_for_alt_account_fails(self):
# An update server request for another user's server should fail
- self.alt_client.update_server(self.server['id'], name='test')
+ self.assertRaises(exceptions.NotFound, self.alt_client.update_server,
+ self.server['id'], name='test')
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_list_server_addresses_for_alt_account_fails(self):
# A list addresses request for another user's server should fail
- self.alt_client.list_addresses(self.server['id'])
+ self.assertRaises(exceptions.NotFound, self.alt_client.list_addresses,
+ self.server['id'])
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_list_server_addresses_by_network_for_alt_account_fails(self):
# A list address/network request for another user's server should fail
server_id = self.server['id']
- self.alt_client.list_addresses_by_network(server_id, 'public')
+ self.assertRaises(exceptions.NotFound,
+ self.alt_client.list_addresses_by_network, server_id,
+ 'public')
def test_list_servers_with_alternate_tenant(self):
# A list on servers from one tenant should not
@@ -139,45 +133,37 @@
alt_server_ids = [s['id'] for s in body['servers']]
self.assertNotIn(self.server['id'], alt_server_ids)
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_change_password_for_alt_account_fails(self):
# A change password request for another user's server should fail
- self.alt_client.change_password(self.server['id'], 'newpass')
+ self.assertRaises(exceptions.NotFound, self.alt_client.change_password,
+ self.server['id'], 'newpass')
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_reboot_server_for_alt_account_fails(self):
# A reboot request for another user's server should fail
- self.alt_client.reboot(self.server['id'], 'HARD')
+ self.assertRaises(exceptions.NotFound, self.alt_client.reboot,
+ self.server['id'], 'HARD')
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_rebuild_server_for_alt_account_fails(self):
# A rebuild request for another user's server should fail
- self.alt_client.rebuild(self.server['id'], self.image_ref_alt)
+ self.assertRaises(exceptions.NotFound, self.alt_client.rebuild,
+ self.server['id'], self.image_ref_alt)
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_resize_server_for_alt_account_fails(self):
# A resize request for another user's server should fail
- self.alt_client.resize(self.server['id'], self.flavor_ref_alt)
+ self.assertRaises(exceptions.NotFound, self.alt_client.resize,
+ self.server['id'], self.flavor_ref_alt)
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_create_image_for_alt_account_fails(self):
# A create image request for another user's server should fail
- self.alt_images_client.create_image(self.server['id'], 'testImage')
+ self.assertRaises(exceptions.NotFound,
+ self.alt_images_client.create_image,
+ self.server['id'], 'testImage')
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_create_server_with_unauthorized_image(self):
# Server creation with another user's image should fail
- self.alt_client.create_server('test', self.image['id'],
- self.flavor_ref)
+ self.assertRaises(exceptions.BadRequest, self.alt_client.create_server,
+ 'test', self.image['id'], self.flavor_ref)
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_create_server_fails_when_tenant_incorrect(self):
# A create server request should fail if the tenant id does not match
# the current user
@@ -185,14 +171,13 @@
try:
# Change the base URL to impersonate another user
self.alt_client.base_url = self.client.base_url
- self.alt_client.create_server('test', self.image['id'],
- self.flavor_ref)
+ self.assertRaises(exceptions.BadRequest,
+ self.alt_client.create_server, 'test',
+ self.image['id'], self.flavor_ref)
finally:
# Reset the base_url...
self.alt_client.base_url = saved_base_url
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_create_keypair_in_analt_user_tenant(self):
# A create keypair request should fail if the tenant id does not match
# the current user
@@ -205,7 +190,8 @@
self.alt_keypairs_client.base_url = self.keypairs_client.base_url
resp = {}
resp['status'] = None
- resp, _ = self.alt_keypairs_client.create_keypair(k_name)
+ self.assertRaises(exceptions.BadRequest,
+ self.alt_keypairs_client.create_keypair, k_name)
finally:
# Reset the base_url...
self.alt_keypairs_client.base_url = self.saved_base_url
@@ -214,33 +200,30 @@
self.fail("Create keypair request should not happen "
"if the tenant id does not match the current user")
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_get_keypair_of_alt_account_fails(self):
# A GET request for another user's keypair should fail
- self.alt_keypairs_client.get_keypair(self.keypairname)
+ self.assertRaises(exceptions.NotFound,
+ self.alt_keypairs_client.get_keypair,
+ self.keypairname)
- @raises(exceptions.NotFound)
- @attr(type='negative')
@testtools.skip("Skipped until the Bug #1086980 is resolved")
def test_delete_keypair_of_alt_account_fails(self):
# A DELETE request for another user's keypair should fail
- self.alt_keypairs_client.delete_keypair(self.keypairname)
+ self.assertRaises(exceptions.NotFound,
+ self.alt_keypairs_client.delete_keypair,
+ self.keypairname)
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_get_image_for_alt_account_fails(self):
# A GET request for an image on another user's account should fail
- self.alt_images_client.get_image(self.image['id'])
+ self.assertRaises(exceptions.NotFound,
+ self.alt_images_client.get_image, self.image['id'])
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_delete_image_for_alt_account_fails(self):
# A DELETE request for another user's image should fail
- self.alt_images_client.delete_image(self.image['id'])
+ self.assertRaises(exceptions.NotFound,
+ self.alt_images_client.delete_image,
+ self.image['id'])
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_create_security_group_in_analt_user_tenant(self):
# A create security group request should fail if the tenant id does not
# match the current user
@@ -253,9 +236,9 @@
self.alt_security_client.base_url = self.security_client.base_url
resp = {}
resp['status'] = None
- resp, body = self.alt_security_client.create_security_group(
- s_name,
- s_description)
+ self.assertRaises(exceptions.BadRequest,
+ self.alt_security_client.create_security_group,
+ s_name, s_description)
finally:
# Reset the base_url...
self.alt_security_client.base_url = self.saved_base_url
@@ -265,21 +248,18 @@
self.fail("Create Security Group request should not happen if"
"the tenant id does not match the current user")
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_get_security_group_of_alt_account_fails(self):
# A GET request for another user's security group should fail
- self.alt_security_client.get_security_group(self.security_group['id'])
+ self.assertRaises(exceptions.NotFound,
+ self.alt_security_client.get_security_group,
+ self.security_group['id'])
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_delete_security_group_of_alt_account_fails(self):
# A DELETE request for another user's security group should fail
- self.alt_security_client.delete_security_group(
- self.security_group['id'])
+ self.assertRaises(exceptions.NotFound,
+ self.alt_security_client.delete_security_group,
+ self.security_group['id'])
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_create_security_group_rule_in_analt_user_tenant(self):
# A create security group rule request should fail if the tenant id
# does not match the current user
@@ -294,11 +274,11 @@
self.alt_security_client.base_url = self.security_client.base_url
resp = {}
resp['status'] = None
- resp, body = \
- self.alt_security_client.create_security_group_rule(
- parent_group_id,
- ip_protocol, from_port,
- to_port)
+ self.assertRaises(exceptions.BadRequest,
+ self.alt_security_client.
+ create_security_group_rule,
+ parent_group_id, ip_protocol, from_port,
+ to_port)
finally:
# Reset the base_url...
self.alt_security_client.base_url = self.saved_base_url
@@ -310,29 +290,28 @@
"happen if the tenant id does not match the"
" current user")
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_delete_security_group_rule_of_alt_account_fails(self):
# A DELETE request for another user's security group rule
# should fail
- self.alt_security_client.delete_security_group_rule(self.rule['id'])
+ self.assertRaises(exceptions.NotFound,
+ self.alt_security_client.delete_security_group_rule,
+ self.rule['id'])
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_set_metadata_of_alt_account_server_fails(self):
# A set metadata for another user's server should fail
req_metadata = {'meta1': 'data1', 'meta2': 'data2'}
- self.alt_client.set_server_metadata(self.server['id'], req_metadata)
+ self.assertRaises(exceptions.NotFound,
+ self.alt_client.set_server_metadata,
+ self.server['id'],
+ req_metadata)
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_set_metadata_of_alt_account_image_fails(self):
# A set metadata for another user's image should fail
req_metadata = {'meta1': 'value1', 'meta2': 'value2'}
- self.alt_images_client.set_image_metadata(self.image['id'],
- req_metadata)
+ self.assertRaises(exceptions.NotFound,
+ self.alt_images_client.set_image_metadata,
+ self.image['id'], req_metadata)
- @attr(type='negative')
def test_get_metadata_of_alt_account_server_fails(self):
# A get metadata for another user's server should fail
req_metadata = {'meta1': 'data1'}
@@ -347,7 +326,6 @@
resp, body = \
self.client.delete_server_metadata_item(self.server['id'], 'meta1')
- @attr(type='negative')
def test_get_metadata_of_alt_account_image_fails(self):
# A get metadata for another user's image should fail
req_metadata = {'meta1': 'value1'}
@@ -363,7 +341,6 @@
resp, body = self.images_client.delete_image_metadata_item(
self.image['id'], 'meta1')
- @attr(type='negative')
def test_delete_metadata_of_alt_account_server_fails(self):
# A delete metadata for another user's server should fail
req_metadata = {'meta1': 'data1'}
@@ -378,7 +355,6 @@
resp, body = \
self.client.delete_server_metadata_item(self.server['id'], 'meta1')
- @attr(type='negative')
def test_delete_metadata_of_alt_account_image_fails(self):
# A delete metadata for another user's image should fail
req_metadata = {'meta1': 'data1'}
@@ -395,8 +371,8 @@
self.images_client.delete_image_metadata_item(self.image['id'],
'meta1')
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_get_console_output_of_alt_account_server_fails(self):
# A Get Console Output for another user's server should fail
- self.alt_client.get_console_output(self.server['id'], 10)
+ self.assertRaises(exceptions.NotFound,
+ self.alt_client.get_console_output,
+ self.server['id'], 10)
diff --git a/tempest/tests/compute/volumes/test_volumes_negative.py b/tempest/tests/compute/volumes/test_volumes_negative.py
index d2ad30e..b24c240 100644
--- a/tempest/tests/compute/volumes/test_volumes_negative.py
+++ b/tempest/tests/compute/volumes/test_volumes_negative.py
@@ -15,9 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from nose.plugins.attrib import attr
-from nose.tools import raises
-
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.tests.compute import base
@@ -25,7 +22,6 @@
class VolumesNegativeTestBase(object):
- @attr(type='negative')
def test_volume_get_nonexistant_volume_id(self):
# Negative: Should not be able to get details of nonexistant volume
#Creating a nonexistant volume id
@@ -46,7 +42,6 @@
self.fail('Should not be able to GET the details from a '
'nonexistant volume')
- @attr(type='negative')
def test_volume_delete_nonexistant_volume_id(self):
# Negative: Should not be able to delete nonexistant Volume
#Creating nonexistant volume id
@@ -66,62 +61,47 @@
else:
self.fail('Should not be able to DELETE a nonexistant volume')
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_create_volume_with_invalid_size(self):
# Negative: Should not be able to create volume with invalid size
# in request
v_name = rand_name('Volume-')
metadata = {'Type': 'work'}
- resp, volume = self.client.create_volume(size='#$%',
- display_name=v_name,
- metadata=metadata)
+ self.assertRaises(exceptions.BadRequest, self.client.create_volume,
+ size='#$%', display_name=v_name, metadata=metadata)
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_create_volume_with_out_passing_size(self):
# Negative: Should not be able to create volume without passing size
# in request
v_name = rand_name('Volume-')
metadata = {'Type': 'work'}
- resp, volume = self.client.create_volume(size='',
- display_name=v_name,
- metadata=metadata)
+ self.assertRaises(exceptions.BadRequest, self.client.create_volume,
+ size='', display_name=v_name, metadata=metadata)
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_create_volume_with_size_zero(self):
# Negative: Should not be able to create volume with size zero
v_name = rand_name('Volume-')
metadata = {'Type': 'work'}
- resp, volume = self.client.create_volume(size='0',
- display_name=v_name,
- metadata=metadata)
+ self.assertRaises(exceptions.BadRequest, self.client.create_volume,
+ size='0', display_name=v_name, metadata=metadata)
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_get_invalid_volume_id(self):
# Negative: Should not be able to get volume with invalid id
- resp, volume = self.client.get_volume('#$%%&^&^')
+ self.assertRaises(exceptions.NotFound,
+ self.client.get_volume, '#$%%&^&^')
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_get_volume_without_passing_volume_id(self):
# Negative: Should not be able to get volume when empty ID is passed
- resp, volume = self.client.get_volume('')
+ self.assertRaises(exceptions.NotFound, self.client.get_volume, '')
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_delete_invalid_volume_id(self):
# Negative: Should not be able to delete volume when invalid ID is
# passed
- resp, volume = self.client.delete_volume('!@#$%^&*()')
+ self.assertRaises(exceptions.NotFound,
+ self.client.delete_volume, '!@#$%^&*()')
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_delete_volume_without_passing_volume_id(self):
# Negative: Should not be able to delete volume when empty ID is passed
- resp, volume = self.client.delete_volume('')
+ self.assertRaises(exceptions.NotFound, self.client.delete_volume, '')
class VolumesNegativeTestXML(base.BaseComputeTestXML,
diff --git a/tempest/tests/object_storage/test_container_sync.py b/tempest/tests/object_storage/test_container_sync.py
index d612880..f156f45 100644
--- a/tempest/tests/object_storage/test_container_sync.py
+++ b/tempest/tests/object_storage/test_container_sync.py
@@ -20,6 +20,7 @@
from tempest.common.utils.data_utils import rand_name
from tempest.tests.object_storage import base
import testtools
+import time
class ContainerSyncTest(base.BaseObjectTest):
diff --git a/tempest/tests/volume/admin/test_volume_types_extra_specs_negative.py b/tempest/tests/volume/admin/test_volume_types_extra_specs_negative.py
index e7fe701..9aa8409 100644
--- a/tempest/tests/volume/admin/test_volume_types_extra_specs_negative.py
+++ b/tempest/tests/volume/admin/test_volume_types_extra_specs_negative.py
@@ -18,9 +18,6 @@
import testtools
import uuid
-from nose.plugins.attrib import attr
-from nose.tools import raises
-
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.tests.volume.admin.base import BaseVolumeAdminTestJSON
@@ -43,97 +40,86 @@
cls.client.delete_volume_type(cls.volume_type['id'])
@testtools.skip('Until bug 1090320 is fixed')
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_update_no_body(self):
# Should not update volume type extra specs with no body
extra_spec = {"spec1": "val2"}
- self.client.update_volume_type_extra_specs(self.volume_type['id'],
- extra_spec.keys()[0],
- None)
+ self.assertRaises(exceptions.BadRequest,
+ self.client.update_volume_type_extra_specs,
+ self.volume_type['id'], extra_spec.keys()[0], None)
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_update_nonexistent_extra_spec_id(self):
# Should not update volume type extra specs with nonexistent id.
extra_spec = {"spec1": "val2"}
- self.client.update_volume_type_extra_specs(self.volume_type['id'],
- str(uuid.uuid4()),
- extra_spec)
+ self.assertRaises(exceptions.BadRequest,
+ self.client.update_volume_type_extra_specs,
+ self.volume_type['id'], str(uuid.uuid4()),
+ extra_spec)
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_update_none_extra_spec_id(self):
# Should not update volume type extra specs with none id.
extra_spec = {"spec1": "val2"}
- self.client.update_volume_type_extra_specs(self.volume_type['id'],
- None, extra_spec)
+ self.assertRaises(exceptions.BadRequest,
+ self.client.update_volume_type_extra_specs,
+ self.volume_type['id'], None, extra_spec)
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_update_multiple_extra_spec(self):
# Should not update volume type extra specs with multiple specs as
# body.
extra_spec = {"spec1": "val2", 'spec2': 'val1'}
- self.client.update_volume_type_extra_specs(self.volume_type['id'],
- extra_spec.keys()[0],
- extra_spec)
+ self.assertRaises(exceptions.BadRequest,
+ self.client.update_volume_type_extra_specs,
+ self.volume_type['id'], extra_spec.keys()[0],
+ extra_spec)
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_create_nonexistent_type_id(self):
# Should not create volume type extra spec for nonexistent volume
# type id.
extra_specs = {"spec2": "val1"}
- self.client.create_volume_type_extra_specs(str(uuid.uuid4()),
- extra_specs)
+ self.assertRaises(exceptions.NotFound,
+ self.client.create_volume_type_extra_specs,
+ str(uuid.uuid4()), extra_specs)
@testtools.skip('Until bug 1090322 is fixed')
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_create_none_body(self):
# Should not create volume type extra spec for none POST body.
- self.client.create_volume_type_extra_specs(self.volume_type['id'],
- None)
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_volume_type_extra_specs,
+ self.volume_type['id'], None)
@testtools.skip('Until bug 1090322 is fixed')
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_create_invalid_body(self):
# Should not create volume type extra spec for invalid POST body.
- self.client.create_volume_type_extra_specs(self.volume_type['id'],
- ['invalid'])
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_volume_type_extra_specs,
+ self.volume_type['id'], ['invalid'])
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_delete_nonexistent_volume_type_id(self):
# Should not delete volume type extra spec for nonexistent
# type id.
extra_specs = {"spec1": "val1"}
- self.client.delete_volume_type_extra_specs(str(uuid.uuid4()),
- extra_specs.keys()[0])
+ self.assertRaises(exceptions.NotFound,
+ self.client.delete_volume_type_extra_specs,
+ str(uuid.uuid4()), extra_specs.keys()[0])
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_list_nonexistent_volume_type_id(self):
# Should not list volume type extra spec for nonexistent type id.
- self.client.list_volume_types_extra_specs(str(uuid.uuid4()))
+ self.assertRaises(exceptions.NotFound,
+ self.client.list_volume_types_extra_specs,
+ str(uuid.uuid4()))
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_get_nonexistent_volume_type_id(self):
# Should not get volume type extra spec for nonexistent type id.
extra_specs = {"spec1": "val1"}
- self.client.get_volume_type_extra_specs(str(uuid.uuid4()),
- extra_specs.keys()[0])
+ self.assertRaises(exceptions.NotFound,
+ self.client.get_volume_type_extra_specs,
+ str(uuid.uuid4()), extra_specs.keys()[0])
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_get_nonexistent_extra_spec_id(self):
# Should not get volume type extra spec for nonexistent extra spec
# id.
- self.client.get_volume_type_extra_specs(self.volume_type['id'],
- str(uuid.uuid4()))
+ self.assertRaises(exceptions.NotFound,
+ self.client.get_volume_type_extra_specs,
+ self.volume_type['id'], str(uuid.uuid4()))
class ExtraSpecsNegativeTestXML(BaseVolumeAdminTestXML,
diff --git a/tempest/tests/volume/admin/test_volume_types_negative.py b/tempest/tests/volume/admin/test_volume_types_negative.py
index f53e33c..8e7fa23 100644
--- a/tempest/tests/volume/admin/test_volume_types_negative.py
+++ b/tempest/tests/volume/admin/test_volume_types_negative.py
@@ -18,9 +18,6 @@
import testtools
import uuid
-from nose.plugins.attrib import attr
-from nose.tools import raises
-
from tempest import exceptions
from tempest.tests.volume.admin.base import BaseVolumeAdminTestJSON
from tempest.tests.volume.admin.base import BaseVolumeAdminTestXML
@@ -32,32 +29,28 @@
def setUpClass(cls):
cls.client = cls.client
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_create_with_nonexistent_volume_type(self):
# Should not be able to create volume with nonexistent volume_type.
- self.volumes_client.create_volume(size=1,
- display_name=str(uuid.uuid4()),
- volume_type=str(uuid.uuid4()))
+ self.assertRaises(exceptions.NotFound,
+ self.volumes_client.create_volume, size=1,
+ display_name=str(uuid.uuid4()),
+ volume_type=str(uuid.uuid4()))
@testtools.skip('Until bug 1090356 is fixed')
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_create_with_empty_name(self):
# Should not be able to create volume type with an empty name.
- self.client.create_volume_type('')
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_volume_type, '')
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_get_nonexistent_type_id(self):
# Should not be able to get volume type with nonexistent type id.
- self.client.get_volume_type(str(uuid.uuid4()))
+ self.assertRaises(exceptions.NotFound, self.client.get_volume_type,
+ str(uuid.uuid4()))
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_delete_nonexistent_type_id(self):
# Should not be able to delete volume type with nonexistent type id.
- self.client.delete_volume_type(str(uuid.uuid4()))
+ self.assertRaises(exceptions.NotFound, self.client.delete_volume_type,
+ str(uuid.uuid4()))
class VolumesTypesNegativeTestXML(BaseVolumeAdminTestXML,
diff --git a/tempest/tests/volume/base.py b/tempest/tests/volume/base.py
index 37664ec..efa74b5 100644
--- a/tempest/tests/volume/base.py
+++ b/tempest/tests/volume/base.py
@@ -18,7 +18,6 @@
import logging
import time
-import nose
import testtools
from tempest import clients
diff --git a/tempest/tests/volume/test_volumes_negative.py b/tempest/tests/volume/test_volumes_negative.py
index 6bd7002..dc1fad0 100644
--- a/tempest/tests/volume/test_volumes_negative.py
+++ b/tempest/tests/volume/test_volumes_negative.py
@@ -15,9 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from nose.plugins.attrib import attr
-from nose.tools import raises
-
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.tests.volume import base
@@ -25,8 +22,6 @@
class VolumesNegativeTestBase(object):
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_volume_get_nonexistant_volume_id(self):
# Should not be able to get a nonexistant volume
#Creating a nonexistant volume id
@@ -39,10 +34,9 @@
if non_exist_id not in volume_id_list:
break
#Trying to Get a non existant volume
- resp, volume = self.client.get_volume(non_exist_id)
+ self.assertRaises(exceptions.NotFound, self.client.get_volume,
+ non_exist_id)
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_volume_delete_nonexistant_volume_id(self):
# Should not be able to delete a nonexistant Volume
# Creating nonexistant volume id
@@ -55,63 +49,49 @@
if non_exist_id not in volume_id_list:
break
# Try to Delete a non existant volume
- resp, body = self.client.delete_volume(non_exist_id)
+ self.assertRaises(exceptions.NotFound, self.client.delete_volume,
+ non_exist_id)
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_create_volume_with_invalid_size(self):
# Should not be able to create volume with invalid size
# in request
v_name = rand_name('Volume-')
metadata = {'Type': 'work'}
- resp, volume = self.client.create_volume(size='#$%',
- display_name=v_name,
- metadata=metadata)
+ self.assertRaises(exceptions.BadRequest, self.client.create_volume,
+ size='#$%', display_name=v_name, metadata=metadata)
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_create_volume_with_out_passing_size(self):
# Should not be able to create volume without passing size
# in request
v_name = rand_name('Volume-')
metadata = {'Type': 'work'}
- resp, volume = self.client.create_volume(size='',
- display_name=v_name,
- metadata=metadata)
+ self.assertRaises(exceptions.BadRequest, self.client.create_volume,
+ size='', display_name=v_name, metadata=metadata)
- @raises(exceptions.BadRequest)
- @attr(type='negative')
def test_create_volume_with_size_zero(self):
# Should not be able to create volume with size zero
v_name = rand_name('Volume-')
metadata = {'Type': 'work'}
- resp, volume = self.client.create_volume(size='0',
- display_name=v_name,
- metadata=metadata)
+ self.assertRaises(exceptions.BadRequest, self.client.create_volume,
+ size='0', display_name=v_name, metadata=metadata)
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_get_invalid_volume_id(self):
# Should not be able to get volume with invalid id
- resp, volume = self.client.get_volume('#$%%&^&^')
+ self.assertRaises(exceptions.NotFound, self.client.get_volume,
+ '#$%%&^&^')
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_get_volume_without_passing_volume_id(self):
# Should not be able to get volume when empty ID is passed
- resp, volume = self.client.get_volume('')
+ self.assertRaises(exceptions.NotFound, self.client.get_volume, '')
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_delete_invalid_volume_id(self):
# Should not be able to delete volume when invalid ID is passed
- resp, volume = self.client.delete_volume('!@#$%^&*()')
+ self.assertRaises(exceptions.NotFound, self.client.delete_volume,
+ '!@#$%^&*()')
- @raises(exceptions.NotFound)
- @attr(type='negative')
def test_delete_volume_without_passing_volume_id(self):
# Should not be able to delete volume when empty ID is passed
- resp, volume = self.client.delete_volume('')
+ self.assertRaises(exceptions.NotFound, self.client.delete_volume, '')
class VolumesNegativeTestXML(base.BaseVolumeTestXML, VolumesNegativeTestBase):