Merge "Add negative test in test_quotas.py."
diff --git a/cli/__init__.py b/cli/__init__.py
index cea0b62..e97fe3e 100644
--- a/cli/__init__.py
+++ b/cli/__init__.py
@@ -16,8 +16,11 @@
# under the License.
import logging
+import shlex
+import subprocess
from tempest.openstack.common import cfg
+import tempest.test
LOG = logging.getLogger(__name__)
@@ -34,3 +37,45 @@
cli_group = cfg.OptGroup(name='cli', title="cli Configuration Options")
CONF.register_group(cli_group)
CONF.register_opts(cli_opts, group=cli_group)
+
+
+class ClientTestBase(tempest.test.BaseTestCase):
+ @classmethod
+ def setUpClass(cls):
+ if not CONF.cli.enabled:
+ msg = "cli testing disabled"
+ raise cls.skipException(msg)
+ cls.identity = cls.config.identity
+ super(ClientTestBase, cls).setUpClass()
+
+ def __init__(self, *args, **kwargs):
+ super(ClientTestBase, self).__init__(*args, **kwargs)
+
+ def nova(self, action, flags='', params='', admin=True, fail_ok=False):
+ """Executes nova command for the given action."""
+ return self.cmd_with_auth(
+ 'nova', action, flags, params, admin, fail_ok)
+
+ def cmd_with_auth(self, cmd, action, flags='', params='',
+ admin=True, fail_ok=False):
+ """Executes given command with auth attributes appended."""
+ #TODO(jogo) make admin=False work
+ creds = ('--os-username %s --os-tenant-name %s --os-password %s '
+ '--os-auth-url %s ' % (self.identity.admin_username,
+ self.identity.admin_tenant_name, self.identity.admin_password,
+ self.identity.uri))
+ flags = creds + ' ' + flags
+ return self.cmd(cmd, action, flags, params, fail_ok)
+
+ def cmd(self, cmd, action, flags='', params='', fail_ok=False):
+ """Executes specified command for the given action."""
+ cmd = ' '.join([CONF.cli.cli_dir + cmd,
+ flags, action, params])
+ LOG.info("running: '%s'" % cmd)
+ cmd = shlex.split(cmd)
+ try:
+ result = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError, e:
+ LOG.error("command output:\n%s" % e.output)
+ raise
+ return result
diff --git a/cli/simple_read_only/test_compute.py b/cli/simple_read_only/test_compute.py
index 742b5a4..849ed6f 100644
--- a/cli/simple_read_only/test_compute.py
+++ b/cli/simple_read_only/test_compute.py
@@ -16,14 +16,12 @@
# under the License.
import logging
-import shlex
import subprocess
import testtools
import cli
-from tempest import config
from tempest.openstack.common import cfg
@@ -33,7 +31,7 @@
LOG = logging.getLogger(__name__)
-class SimpleReadOnlyNovaCLientTest(testtools.TestCase):
+class SimpleReadOnlyNovaClientTest(cli.ClientTestBase):
"""
This is a first pass at a simple read only python-novaclient test. This
@@ -47,58 +45,137 @@
"""
- @classmethod
- def setUpClass(cls):
- if not CONF.cli.enabled:
- msg = "cli testing disabled"
- raise cls.skipException(msg)
- cls.identity = config.TempestConfig().identity
- super(SimpleReadOnlyNovaCLientTest, cls).setUpClass()
-
- def nova(self, action, flags='', params='', admin=True, fail_ok=False):
- """Executes nova command for the given action."""
- #TODO(jogo) make admin=False work
- creds = ('--os-username %s --os-tenant-name %s --os-password %s '
- '--os-auth-url %s ' % (self.identity.admin_username,
- self.identity.admin_tenant_name, self.identity.admin_password,
- self.identity.uri))
- flags = creds + ' ' + flags
- cmd = ' '.join([CONF.cli.cli_dir + 'nova', flags, action, params])
- LOG.info("running: '%s'" % cmd)
- cmd = shlex.split(cmd)
- result = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- return result
-
- def test_admin_version(self):
- self.nova('', flags='--version')
-
- def test_admin_timing(self):
- self.nova('list', flags='--timing')
-
- def test_admin_timeout(self):
- self.nova('list', flags='--timeout 2')
-
- def test_admin_debug_list(self):
- self.nova('list', flags='--debug')
-
def test_admin_fake_action(self):
self.assertRaises(subprocess.CalledProcessError,
self.nova,
'this-does-nova-exist')
+ #NOTE(jogo): Commands in order listed in 'nova help'
+
+ # Positional arguments:
+
+ def test_admin_absolute_limites(self):
+ self.nova('absolute-limits')
+
def test_admin_aggregate_list(self):
self.nova('aggregate-list')
+ def test_admin_availability_zone_list(self):
+ self.nova('availability-zone-list')
+
def test_admin_cloudpipe_list(self):
self.nova('cloudpipe-list')
- def test_admin_image_list(self):
- self.nova('image-list')
+ def test_admin_credentials(self):
+ self.nova('credentials')
def test_admin_dns_domains(self):
self.nova('dns-domains')
+ @testtools.skip("needs parameters")
+ def test_admin_dns_list(self):
+ self.nova('dns-list')
+
+ def test_admin_endpoints(self):
+ self.nova('endpoints')
+
+ def test_admin_flavor_acces_list(self):
+ self.assertRaises(subprocess.CalledProcessError,
+ self.nova,
+ 'flavor-access-list')
+ # Failed to get access list for public flavor type
+ self.assertRaises(subprocess.CalledProcessError,
+ self.nova,
+ 'flavor-access-list',
+ params='--flavor m1.tiny')
+
def test_admin_flavor_list(self):
self.nova('flavor-list')
- #TODO(jogo) add more tests
+ def test_admin_floating_ip_bulk_list(self):
+ self.nova('floating-ip-bulk-list')
+
+ def test_admin_floating_ip_list(self):
+ self.nova('floating-ip-list')
+
+ def test_admin_floating_ip_pool_list(self):
+ self.nova('floating-ip-pool-list')
+
+ def test_admin_host_list(self):
+ self.nova('host-list')
+
+ def test_admin_hypervisor_list(self):
+ self.nova('hypervisor-list')
+
+ def test_admin_image_list(self):
+ self.nova('image-list')
+
+ @testtools.skip("needs parameters")
+ def test_admin_interface_list(self):
+ self.nova('interface-list')
+
+ def test_admin_keypair_list(self):
+ self.nova('keypair-list')
+
+ def test_admin_list(self):
+ self.nova('list')
+ self.nova('list', params='--all-tenants 1')
+ self.nova('list', params='--all-tenants 0')
+ self.assertRaises(subprocess.CalledProcessError,
+ self.nova,
+ 'list',
+ params='--all-tenants bad')
+
+ def test_admin_network_list(self):
+ self.nova('network-list')
+
+ def test_admin_rate_limits(self):
+ self.nova('rate-limits')
+
+ def test_admin_secgroup_list(self):
+ self.nova('secgroup-list')
+
+ @testtools.skip("needs parameters")
+ def test_admin_secgroup_list_rules(self):
+ self.nova('secgroup-list-rules')
+
+ def test_admin_servce_list(self):
+ self.nova('service-list')
+
+ def test_admin_usage(self):
+ self.nova('usage')
+
+ def test_admin_usage_list(self):
+ self.nova('usage-list')
+
+ def test_admin_volume_list(self):
+ self.nova('volume-list')
+
+ def test_admin_volume_snapshot_list(self):
+ self.nova('volume-snapshot-list')
+
+ def test_admin_volume_type_list(self):
+ self.nova('volume-type-list')
+
+ def test_admin_help(self):
+ self.nova('help')
+
+ def test_admin_list_extensions(self):
+ self.nova('list-extensions')
+
+ def test_admin_net_list(self):
+ self.nova('net-list')
+
+ # Optional arguments:
+
+ def test_admin_version(self):
+ self.nova('', flags='--version')
+
+ def test_admin_debug_list(self):
+ self.nova('list', flags='--debug')
+
+ def test_admin_timeout(self):
+ self.nova('list', flags='--timeout 2')
+
+ def test_admin_timing(self):
+ self.nova('list', flags='--timing')
diff --git a/stress/config.py b/stress/config.py
index ca86ce5..25cb910 100755
--- a/stress/config.py
+++ b/stress/config.py
@@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import ConfigParser
-
class StressConfig(object):
"""Provides configuration information for whitebox stress tests."""
@@ -21,33 +19,27 @@
def __init__(self, conf):
self.conf = conf
- def get(self, item_name, default_value=None):
- try:
- return self.conf.get("stress", item_name)
- except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
- return default_value
-
@property
def host_private_key_path(self):
"""Path to ssh key for logging into compute nodes."""
- return self.get("host_private_key_path", None)
+ return self.conf.compute.path_to_private_key
@property
def host_admin_user(self):
"""Username for logging into compute nodes."""
- return self.get("host_admin_user", None)
+ return self.conf.compute.ssh_user
@property
def nova_logdir(self):
"""Directory containing log files on the compute nodes."""
- return self.get("nova_logdir", None)
+ return self.conf.stress.nova_logdir
@property
def controller(self):
"""Controller host."""
- return self.get("controller", None)
+ return self.conf.stress.controller
@property
def max_instances(self):
"""Maximum number of instances to create during test."""
- return self.get("max_instances", 16)
+ return self.conf.stress.max_instances
diff --git a/stress/driver.py b/stress/driver.py
index 8dc88cf..f80e765 100644
--- a/stress/driver.py
+++ b/stress/driver.py
@@ -18,6 +18,7 @@
import datetime
import random
import time
+from urlparse import urlparse
from config import StressConfig
from state import ClusterState
@@ -162,7 +163,7 @@
(default: 32)
`seed` = random seed (default: None)
"""
- stress_config = StressConfig(manager.config._conf)
+ stress_config = StressConfig(manager.config)
# get keyword arguments
duration = kwargs.get('duration', datetime.timedelta(seconds=10))
seed = kwargs.get('seed', None)
@@ -173,7 +174,8 @@
keypath = stress_config.host_private_key_path
user = stress_config.host_admin_user
logdir = stress_config.nova_logdir
- computes = _get_compute_nodes(keypath, user, manager.config.identity.host)
+ host = urlparse(manager.config.identity.uri).hostname
+ computes = _get_compute_nodes(keypath, user, host)
stress.utils.execute_on_all(keypath, user, computes,
"rm -f %s/*.log" % logdir)
random.seed(seed)
diff --git a/tempest/clients.py b/tempest/clients.py
index 7d314f3..ef07d9c 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -25,6 +25,7 @@
from tempest.services.compute.json.flavors_client import FlavorsClientJSON
from tempest.services.compute.json.floating_ips_client import \
FloatingIPsClientJSON
+from tempest.services.compute.json.hosts_client import HostsClientJSON
from tempest.services.compute.json.images_client import ImagesClientJSON
from tempest.services.compute.json.keypairs_client import KeyPairsClientJSON
from tempest.services.compute.json.limits_client import LimitsClientJSON
@@ -211,6 +212,7 @@
msg = "Unsupported interface type `%s'" % interface
raise exceptions.InvalidConfiguration(msg)
self.network_client = NetworkClient(*client_args)
+ self.hosts_client = HostsClientJSON(*client_args)
self.account_client = AccountClient(*client_args)
self.image_client = ImageClientJSON(*client_args)
self.container_client = ContainerClient(*client_args)
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 170a137..c582826 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -338,6 +338,11 @@
return self.check_over_limit(resp_body, method, url, headers, body,
depth, wait)
+ if resp.status == 422:
+ if parse_resp:
+ resp_body = self._parse_resp(resp_body)
+ raise exceptions.UnprocessableEntity(resp_body)
+
if resp.status in (500, 501):
message = resp_body
if parse_resp:
diff --git a/tempest/config.py b/tempest/config.py
index c982dee..c0e25c7 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -382,6 +382,26 @@
for opt in BotoConfig:
conf.register_opt(opt, group='boto')
+stress_group = cfg.OptGroup(name='stress', title='Stress Test Options')
+
+StressGroup = [
+ cfg.StrOpt('nova_logdir',
+ default=None,
+ help='Directory containing log files on the compute nodes'),
+ cfg.IntOpt('max_instances',
+ default=16,
+ help='Maximum number of instances to create during test.'),
+ cfg.StrOpt('controller',
+ default=None,
+ help='Controller host.')
+]
+
+
+def register_stress_opts(conf):
+ conf.register_group(stress_group)
+ for opt in StressGroup:
+ conf.register_opt(opt, group='stress')
+
@singleton
class TempestConfig:
@@ -426,6 +446,7 @@
register_object_storage_opts(cfg.CONF)
register_boto_opts(cfg.CONF)
register_compute_admin_opts(cfg.CONF)
+ register_stress_opts(cfg.CONF)
self.compute = cfg.CONF.compute
self.whitebox = cfg.CONF.whitebox
self.identity = cfg.CONF.identity
@@ -435,6 +456,7 @@
self.object_storage = cfg.CONF['object-storage']
self.boto = cfg.CONF.boto
self.compute_admin = cfg.CONF['compute-admin']
+ self.stress = cfg.CONF.stress
if not self.compute_admin.username:
self.compute_admin.username = self.identity.admin_username
self.compute_admin.password = self.identity.admin_password
diff --git a/tempest/exceptions.py b/tempest/exceptions.py
index 577aa13..235a2e7 100644
--- a/tempest/exceptions.py
+++ b/tempest/exceptions.py
@@ -94,6 +94,10 @@
message = "Bad request"
+class UnprocessableEntity(RestClientException):
+ message = "Unprocessable entity"
+
+
class AuthenticationFailure(RestClientException):
message = ("Authentication with user %(user)s and password "
"%(password)s failed")
diff --git a/tempest/services/botoclients.py b/tempest/services/botoclients.py
index 143257a..0870c96 100644
--- a/tempest/services/botoclients.py
+++ b/tempest/services/botoclients.py
@@ -17,7 +17,6 @@
import ConfigParser
import contextlib
-import re
import types
import urlparse
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index ecff7be..e8d1153 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -195,108 +195,50 @@
body = json.loads(body)
return resp, body
- def change_password(self, server_id, password):
- """Changes the root password for the server."""
- post_body = {
- 'changePassword': {
- 'adminPass': password,
- }
- }
+ def action(self, server_id, action_name, response_key, **kwargs):
+ post_body = json.dumps({action_name: kwargs})
+ resp, body = self.post('servers/%s/action' % str(server_id),
+ post_body, self.headers)
+ if response_key is not None:
+ body = json.loads(body)[response_key]
+ return resp, body
- post_body = json.dumps(post_body)
- return self.post('servers/%s/action' % str(server_id),
- post_body, self.headers)
+ def change_password(self, server_id, adminPass):
+ """Changes the root password for the server."""
+ return self.action(server_id, 'changePassword', None,
+ adminPass=adminPass)
def reboot(self, server_id, reboot_type):
"""Reboots a server."""
- post_body = {
- 'reboot': {
- 'type': reboot_type,
- }
- }
+ return self.action(server_id, 'reboot', None, type=reboot_type)
- post_body = json.dumps(post_body)
- return self.post('servers/%s/action' % str(server_id),
- post_body, self.headers)
-
- def rebuild(self, server_id, image_ref, name=None, meta=None,
- personality=None, adminPass=None, disk_config=None):
+ def rebuild(self, server_id, image_ref, **kwargs):
"""Rebuilds a server with a new image."""
- post_body = {
- 'imageRef': image_ref,
- }
+ kwargs['imageRef'] = image_ref
+ if 'disk_config' in kwargs:
+ kwargs['OS-DCF:diskConfig'] = kwargs['disk_config']
+ del kwargs['disk_config']
+ return self.action(server_id, 'rebuild', 'server', **kwargs)
- if name is not None:
- post_body['name'] = name
-
- if adminPass is not None:
- post_body['adminPass'] = adminPass
-
- if meta is not None:
- post_body['metadata'] = meta
-
- if personality is not None:
- post_body['personality'] = personality
-
- if disk_config is not None:
- post_body['OS-DCF:diskConfig'] = disk_config
-
- post_body = json.dumps({'rebuild': post_body})
- resp, body = self.post('servers/%s/action' % str(server_id),
- post_body, self.headers)
- body = json.loads(body)
- return resp, body['server']
-
- def resize(self, server_id, flavor_ref, disk_config=None):
+ def resize(self, server_id, flavor_ref, **kwargs):
"""Changes the flavor of a server."""
- post_body = {
- 'resize': {
- 'flavorRef': flavor_ref,
- }
- }
+ kwargs['flavorRef'] = flavor_ref
+ if 'disk_config' in kwargs:
+ kwargs['OS-DCF:diskConfig'] = kwargs['disk_config']
+ del kwargs['disk_config']
+ return self.action(server_id, 'resize', None, **kwargs)
- if disk_config is not None:
- post_body['resize']['OS-DCF:diskConfig'] = disk_config
-
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % str(server_id),
- post_body, self.headers)
- return resp, body
-
- def confirm_resize(self, server_id):
+ def confirm_resize(self, server_id, **kwargs):
"""Confirms the flavor change for a server."""
- post_body = {
- 'confirmResize': None,
- }
+ return self.action(server_id, 'confirmResize', None, **kwargs)
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % str(server_id),
- post_body, self.headers)
- return resp, body
-
- def revert_resize(self, server_id):
+ def revert_resize(self, server_id, **kwargs):
"""Reverts a server back to its original flavor."""
- post_body = {
- 'revertResize': None,
- }
+ return self.action(server_id, 'revertResize', None, **kwargs)
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % str(server_id),
- post_body, self.headers)
- return resp, body
-
- def create_image(self, server_id, image_name):
+ def create_image(self, server_id, name):
"""Creates an image of the given server."""
- post_body = {
- 'createImage': {
- 'name': image_name,
- }
- }
-
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % str(server_id),
- post_body, self.headers)
- return resp, body
+ return self.action(server_id, 'createImage', None, name=name)
def list_server_metadata(self, server_id):
resp, body = self.get("servers/%s/metadata" % str(server_id))
@@ -334,15 +276,11 @@
(str(server_id), key))
return resp, body
- def stop(self, server_id):
- post_body = json.dumps({'os-stop': None})
- resp, body = self.post('servers/%s/action' % server_id,
- post_body, self.headers)
+ def stop(self, server_id, **kwargs):
+ return self.action(server_id, 'os-stop', None, **kwargs)
- def start(self, server_id):
- post_body = json.dumps({'os-start': None})
- resp, body = self.post('servers/%s/action' % server_id,
- post_body, self.headers)
+ def start(self, server_id, **kwargs):
+ return self.action(server_id, 'os-start', None, **kwargs)
def attach_volume(self, server_id, volume_id, device='/dev/vdz'):
"""Attaches a volume to a server instance."""
@@ -362,27 +300,13 @@
(server_id, volume_id))
return resp, body
- def add_security_group(self, server_id, security_group_name):
+ def add_security_group(self, server_id, name):
"""Adds a security group to the server."""
- post_body = {
- 'addSecurityGroup': {
- 'name': security_group_name
- }
- }
- post_body = json.dumps(post_body)
- return self.post('servers/%s/action' % server_id,
- post_body, self.headers)
+ return self.action(server_id, 'addSecurityGroup', None, name=name)
- def remove_security_group(self, server_id, security_group_name):
+ def remove_security_group(self, server_id, name):
"""Removes a security group from the server."""
- post_body = {
- 'removeSecurityGroup': {
- 'name': security_group_name
- }
- }
- post_body = json.dumps(post_body)
- return self.post('servers/%s/action' % server_id,
- post_body, self.headers)
+ return self.action(server_id, 'removeSecurityGroup', None, name=name)
def live_migrate_server(self, server_id, dest_host, use_block_migration):
"""This should be called with administrator privileges ."""
@@ -408,96 +332,41 @@
body = json.loads(body)
return resp, body['servers']
- def migrate_server(self, server_id):
+ def migrate_server(self, server_id, **kwargs):
"""Migrates a server to a new host."""
- post_body = {'migrate': 'null'}
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % server_id,
- post_body, self.headers)
- return resp, body
+ return self.action(server_id, 'migrate', None, **kwargs)
- def confirm_migration(self, server_id):
- """Confirms the migration of a server."""
- post_body = {'confirmResize': 'null'}
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % server_id,
- post_body, self.headers)
- return resp, body
-
- def lock_server(self, server_id):
+ def lock_server(self, server_id, **kwargs):
"""Locks the given server."""
- post_body = {'lock': 'null'}
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % server_id,
- post_body, self.headers)
+ return self.action(server_id, 'lock', None, **kwargs)
- def unlock_server(self, server_id):
+ def unlock_server(self, server_id, **kwargs):
"""UNlocks the given server."""
- post_body = {'unlock': 'null'}
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % server_id,
- post_body, self.headers)
+ return self.action(server_id, 'unlock', None, **kwargs)
- def start_server(self, server_id):
- """Starts the given server."""
- post_body = {'os-start': 'null'}
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % server_id,
- post_body, self.headers)
-
- def stop_server(self, server_id):
- """Stops the given server."""
- post_body = {'os-stop': 'null'}
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % server_id,
- post_body, self.headers)
-
- def suspend_server(self, server_id):
+ def suspend_server(self, server_id, **kwargs):
"""Suspends the provded server."""
- post_body = {'suspend': 'null'}
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % server_id,
- post_body, self.headers)
+ return self.action(server_id, 'suspend', None, **kwargs)
- def resume_server(self, server_id):
+ def resume_server(self, server_id, **kwargs):
"""Un-suspends the provded server."""
- post_body = {'resume': 'null'}
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % server_id,
- post_body, self.headers)
+ return self.action(server_id, 'resume', None, **kwargs)
- def pause_server(self, server_id):
+ def pause_server(self, server_id, **kwargs):
"""Pauses the provded server."""
- post_body = {'pause': 'null'}
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % server_id,
- post_body, self.headers)
+ return self.action(server_id, 'pause', None, **kwargs)
- def unpause_server(self, server_id):
+ def unpause_server(self, server_id, **kwargs):
"""Un-pauses the provded server."""
- post_body = {'unpause': 'null'}
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % server_id,
- post_body, self.headers)
+ return self.action(server_id, 'unpause', None, **kwargs)
- def reset_state(self, server_id, new_state='error'):
+ def reset_state(self, server_id, state='error'):
"""Resets the state of a server to active/error."""
- post_body = {
- 'os-resetState': {
- 'state': new_state
- }
- }
- resp, body = self.post('servers/%s/action' % server_id,
- post_body, self.headers)
- return resp, body
+ return self.action(server_id, 'os-resetState', None, state=state)
def get_console_output(self, server_id, length):
- post_body = {'os-getConsoleOutput': {'length': length}}
- url = "/servers/%s/action" % server_id
- post_body = json.dumps(post_body)
- resp, body = self.post(url, post_body, self.headers)
- body = json.loads(body)
- return resp, body['output']
+ return self.action(server_id, 'os-getConsoleOutput', 'output',
+ length=length)
def list_virtual_interfaces(self, server_id):
"""
diff --git a/tempest/services/compute/xml/servers_client.py b/tempest/services/compute/xml/servers_client.py
index 3abf0c3..efb28e6 100644
--- a/tempest/services/compute/xml/servers_client.py
+++ b/tempest/services/compute/xml/servers_client.py
@@ -131,6 +131,17 @@
self._parse_links(body, json[sub])
return json
+ def _parse_xml_virtual_interfaces(self, xml_dom):
+ """
+ Return server's virtual interfaces XML as JSON.
+ """
+ data = {"virtual_interfaces": []}
+ for iface in xml_dom.getchildren():
+ data["virtual_interfaces"].append(
+ {"id": iface.get("id"),
+ "mac_address": iface.get("mac_address")})
+ return data
+
def get_server(self, server_id):
"""Returns the details of an existing server."""
resp, body = self.get("servers/%s" % str(server_id), self.headers)
@@ -309,34 +320,38 @@
return resp, network
+ def action(self, server_id, action_name, response_key, **kwargs):
+ if 'xmlns' not in kwargs:
+ kwargs['xmlns'] = XMLNS_11
+ doc = Document((Element(action_name, **kwargs)))
+ resp, body = self.post("servers/%s/action" % server_id,
+ str(doc), self.headers)
+ if response_key is not None:
+ body = xml_to_json(etree.fromstring(body))
+ return resp, body
+
def change_password(self, server_id, password):
- cpw = Element("changePassword",
- xmlns=XMLNS_11,
- adminPass=password)
- return self.post("servers/%s/action" % server_id,
- str(Document(cpw)), self.headers)
+ return self.action(server_id, "changePassword", None,
+ adminPass=password)
def reboot(self, server_id, reboot_type):
- reboot = Element("reboot",
- xmlns=XMLNS_11,
- type=reboot_type)
- return self.post("servers/%s/action" % server_id,
- str(Document(reboot)), self.headers)
+ return self.action(server_id, "reboot", None, type=reboot_type)
- def rebuild(self, server_id, image_ref, name=None, meta=None,
- personality=None, adminPass=None, disk_config=None):
+ def rebuild(self, server_id, image_ref, **kwargs):
+ kwargs['imageRef'] = image_ref
+ if 'xmlns' not in kwargs:
+ kwargs['xmlns'] = XMLNS_11
+
+ attrs = kwargs.copy()
+ if 'metadata' in attrs:
+ del attrs['metadata']
rebuild = Element("rebuild",
- xmlns=XMLNS_11,
- imageRef=image_ref)
+ **attrs)
- if name:
- rebuild.add_attr("name", name)
- if adminPass:
- rebuild.add_attr("adminPass", adminPass)
- if meta:
+ if 'metadata' in kwargs:
metadata = Element("metadata")
rebuild.append(metadata)
- for k, v in meta.items():
+ for k, v in kwargs['metadata'].items():
meta = Element("meta", key=k)
meta.append(Text(v))
metadata.append(meta)
@@ -346,53 +361,31 @@
server = self._parse_server(etree.fromstring(body))
return resp, server
- def resize(self, server_id, flavor_ref, disk_config=None):
- resize = Element("resize",
- xmlns=XMLNS_11,
- flavorRef=flavor_ref)
+ def resize(self, server_id, flavor_ref, **kwargs):
+ if 'disk_config' in kwargs:
+ raise NotImplementedError("Sorry, disk_config not "
+ "supported via XML yet")
+ kwargs['flavorRef'] = flavor_ref
+ return self.action(server_id, 'resize', None, **kwargs)
- if disk_config is not None:
- raise Exception("Sorry, disk_config not supported via XML yet")
+ def confirm_resize(self, server_id, **kwargs):
+ return self.action(server_id, 'confirmResize', None, **kwargs)
- return self.post('servers/%s/action' % server_id,
- str(Document(resize)), self.headers)
+ def revert_resize(self, server_id, **kwargs):
+ return self.action(server_id, 'revertResize', None, **kwargs)
- def confirm_resize(self, server_id):
- conf = Element('confirmResize')
- return self.post('servers/%s/action' % server_id,
- str(Document(conf)), self.headers)
+ def create_image(self, server_id, name):
+ return self.action(server_id, 'createImage', None, name=name)
- def revert_resize(self, server_id):
- revert = Element('revertResize')
- return self.post('servers/%s/action' % server_id,
- str(Document(revert)), self.headers)
+ def add_security_group(self, server_id, name):
+ return self.action(server_id, 'addSecurityGroup', None, name=name)
- def create_image(self, server_id, image_name):
- metadata = Element('metadata')
- image = Element('createImage',
- metadata,
- xmlns=XMLNS_11,
- name=image_name)
- return self.post('servers/%s/action' % server_id,
- str(Document(image)), self.headers)
-
- def add_security_group(self, server_id, security_group_name):
- secgrp = Element('addSecurityGroup', name=security_group_name)
- return self.post('servers/%s/action' % server_id,
- str(Document(secgrp)), self.headers)
-
- def remove_security_group(self, server_id, security_group_name):
- secgrp = Element('removeSecurityGroup', name=security_group_name)
- return self.post('servers/%s/action' % server_id,
- str(Document(secgrp)), self.headers)
+ def remove_security_group(self, server_id, name):
+ return self.action(server_id, 'removeSecurityGroup', None, name=name)
def get_console_output(self, server_id, length):
- post_body = Element("os-getConsoleOutput", length=length)
- resp, body = self.post("/servers/%s/action" % server_id,
- headers=self.headers,
- body=str(Document(post_body)))
- body = xml_to_json(etree.fromstring(body))
- return resp, body
+ return self.action(server_id, 'os-getConsoleOutput', 'output',
+ length=length)
def list_virtual_interfaces(self, server_id):
"""
@@ -400,5 +393,5 @@
"""
resp, body = self.get('/'.join(['servers', server_id,
'os-virtual-interfaces']), self.headers)
- server = self._parse_server(etree.fromstring(body))
- return resp, server
+ virt_int = self._parse_xml_virtual_interfaces(etree.fromstring(body))
+ return resp, virt_int
diff --git a/tempest/services/identity/json/identity_client.py b/tempest/services/identity/json/identity_client.py
index 68e7d4b..5b6eaa0 100644
--- a/tempest/services/identity/json/identity_client.py
+++ b/tempest/services/identity/json/identity_client.py
@@ -44,7 +44,7 @@
post_body = {
'name': name,
'description': kwargs.get('description', ''),
- 'enabled': kwargs.get('enabled', 'true'),
+ 'enabled': kwargs.get('enabled', True),
}
post_body = json.dumps({'tenant': post_body})
resp, body = self.post('tenants', post_body, self.headers)
diff --git a/tempest/services/image/json/image_client.py b/tempest/services/image/json/image_client.py
index e9276aa..f119664 100644
--- a/tempest/services/image/json/image_client.py
+++ b/tempest/services/image/json/image_client.py
@@ -176,11 +176,21 @@
url = '/' + url
self.http.raw_request('DELETE', url)
- def image_list(self, params=None):
+ def image_list(self, **kwargs):
url = 'v1/images'
- if params:
- url += '?%s' % urllib.urlencode(params)
+ if len(kwargs) > 0:
+ url += '?%s' % urllib.urlencode(kwargs)
+
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['images']
+
+ def image_list_detail(self, **kwargs):
+ url = 'v1/images/detail'
+
+ if len(kwargs) > 0:
+ url += '?%s' % urllib.urlencode(kwargs)
resp, body = self.get(url)
body = json.loads(body)
diff --git a/tempest/smoke.py b/tempest/smoke.py
index 1e7da8e..0d4043f 100644
--- a/tempest/smoke.py
+++ b/tempest/smoke.py
@@ -51,8 +51,8 @@
# order, and because test methods in smoke tests generally create
# resources in a particular order, we destroy resources in the reverse
# order in which resources are added to the smoke test class object
- while cls.resources:
- thing = cls.resources.pop()
+ while cls.os_resources:
+ thing = cls.os_resources.pop()
LOG.debug("Deleting %r from shared resources of %s" %
(thing, cls.__name__))
diff --git a/tempest/test.py b/tempest/test.py
index 616a866..e0639b6 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -19,8 +19,10 @@
import time
import nose.plugins.attrib
+import testresources
import testtools
+from tempest import config
from tempest import manager
LOG = logging.getLogger(__name__)
@@ -46,19 +48,26 @@
return decorator
-class TestCase(testtools.TestCase):
+class BaseTestCase(testtools.TestCase,
+ testtools.testcase.WithAttributes,
+ testresources.ResourcedTestCase):
+ def __init__(self, *args, **kwargs):
+ super(BaseTestCase, self).__init__(*args, **kwargs)
+ #NOTE(afazekas): inspection workaround
+ BaseTestCase.config = config.TempestConfig()
- """
- Base test case class for all Tempest tests
+
+class TestCase(BaseTestCase):
+ """Base test case class for all Tempest tests
Contains basic setup and convenience methods
"""
+
manager_class = None
@classmethod
def setUpClass(cls):
cls.manager = cls.manager_class()
- cls.config = cls.manager.config
for attr_name in cls.manager.client_attr_names:
# Ensure that pre-existing class attributes won't be
# accidentally overriden.
@@ -66,20 +75,20 @@
client = getattr(cls.manager, attr_name)
setattr(cls, attr_name, client)
cls.resource_keys = {}
- cls.resources = []
+ cls.os_resources = []
def set_resource(self, key, thing):
LOG.debug("Adding %r to shared resources of %s" %
(thing, self.__class__.__name__))
self.resource_keys[key] = thing
- self.resources.append(thing)
+ self.os_resources.append(thing)
def get_resource(self, key):
return self.resource_keys[key]
def remove_resource(self, key):
thing = self.resource_keys[key]
- self.resources.remove(thing)
+ self.os_resources.remove(thing)
del self.resource_keys[key]
diff --git a/tempest/testboto.py b/tempest/testboto.py
index 30c7e93..cee8843 100644
--- a/tempest/testboto.py
+++ b/tempest/testboto.py
@@ -17,17 +17,21 @@
from contextlib import closing
import logging
+import os
import re
+import urlparse
import boto
from boto import ec2
from boto import exception
from boto import s3
-import testresources
-import testtools
+import keystoneclient.exceptions
+import tempest.clients
+from tempest.common.utils.file_utils import have_effective_read_access
+import tempest.config
from tempest import exceptions
-import tempest.tests.boto
+import tempest.test
from tempest.tests.boto.utils.wait import re_search_wait
from tempest.tests.boto.utils.wait import state_wait
from tempest.tests.boto.utils.wait import wait_exception
@@ -35,6 +39,71 @@
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(have_effective_read_access, args))
+
+ config = tempest.config.TempestConfig()
+ materials_path = config.boto.s3_materials_path
+ ami_path = materials_path + os.sep + config.boto.ami_manifest
+ aki_path = materials_path + os.sep + config.boto.aki_manifest
+ ari_path = materials_path + os.sep + config.boto.ari_manifest
+
+ A_I_IMAGES_READY = all_read(ami_path, aki_path, ari_path)
+ boto_logger = logging.getLogger('boto')
+ level = boto_logger.level
+ boto_logger.setLevel(logging.CRITICAL) # suppress logging for these
+
+ 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")
+ openstack = tempest.clients.Manager()
+ try:
+ if urlparse.urlparse(config.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 keystoneclient.exceptions.Unauthorized:
+ EC2_CAN_CONNECT_ERROR = "AWS credentials not set," +\
+ " faild to get them even by keystoneclient"
+ except Exception as exc:
+ EC2_CAN_CONNECT_ERROR = str(exc)
+
+ try:
+ if urlparse.urlparse(config.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 keystoneclient.exceptions.Unauthorized:
+ S3_CAN_CONNECT_ERROR = "AWS credentials not set," +\
+ " faild to get them even by keystoneclient"
+ boto_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
@@ -119,12 +188,10 @@
return string + ")"
-class BotoTestCase(testtools.testcase.WithAttributes,
- testtools.TestCase,
- testresources.ResourcedTestCase):
+class BotoTestCase(tempest.test.BaseTestCase):
"""Recommended to use as base class for boto related test."""
- conclusion = tempest.tests.boto.generic_setup_package()
+ conclusion = decision_maker()
@classmethod
def setUpClass(cls):
@@ -133,13 +200,13 @@
cls._resource_trash_bin = {}
cls._sequence = -1
if (hasattr(cls, "EC2") and
- tempest.tests.boto.EC2_CAN_CONNECT_ERROR is not None):
+ cls.conclusion['EC2_CAN_CONNECT_ERROR'] is not None):
raise cls.skipException("EC2 " + cls.__name__ + ": " +
- tempest.tests.boto.EC2_CAN_CONNECT_ERROR)
+ cls.conclusion['EC2_CAN_CONNECT_ERROR'])
if (hasattr(cls, "S3") and
- tempest.tests.boto.S3_CAN_CONNECT_ERROR is not None):
+ cls.conclusion['S3_CAN_CONNECT_ERROR'] is not None):
raise cls.skipException("S3 " + cls.__name__ + ": " +
- tempest.tests.boto.S3_CAN_CONNECT_ERROR)
+ cls.conclusion['S3_CAN_CONNECT_ERROR'])
@classmethod
def addResourceCleanUp(cls, function, *args, **kwargs):
diff --git a/tempest/tests/boto/__init__.py b/tempest/tests/boto/__init__.py
index dd224d6..e69de29 100644
--- a/tempest/tests/boto/__init__.py
+++ b/tempest/tests/boto/__init__.py
@@ -1,94 +0,0 @@
-# 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 logging
-import os
-import re
-import urlparse
-
-import boto.exception
-import keystoneclient.exceptions
-
-import tempest.clients
-from tempest.common.utils.file_utils import have_effective_read_access
-import tempest.config
-
-A_I_IMAGES_READY = True # ari,ami,aki
-S3_CAN_CONNECT_ERROR = None
-EC2_CAN_CONNECT_ERROR = None
-
-
-def generic_setup_package():
- global A_I_IMAGES_READY
- global S3_CAN_CONNECT_ERROR
- global EC2_CAN_CONNECT_ERROR
- 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(have_effective_read_access, args))
-
- config = tempest.config.TempestConfig()
- materials_path = config.boto.s3_materials_path
- ami_path = materials_path + os.sep + config.boto.ami_manifest
- aki_path = materials_path + os.sep + config.boto.aki_manifest
- ari_path = materials_path + os.sep + config.boto.ari_manifest
-
- A_I_IMAGES_READY = all_read(ami_path, aki_path, ari_path)
- boto_logger = logging.getLogger('boto')
- level = boto_logger.level
- boto_logger.setLevel(logging.CRITICAL) # suppress logging for these
-
- 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")
- openstack = tempest.clients.Manager()
- try:
- if urlparse.urlparse(config.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 boto.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 keystoneclient.exceptions.Unauthorized:
- EC2_CAN_CONNECT_ERROR = "AWS credentials not set," +\
- " faild to get them even by keystoneclient"
- except Exception as exc:
- EC2_CAN_CONNECT_ERROR = str(exc)
-
- try:
- if urlparse.urlparse(config.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 boto.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 keystoneclient.exceptions.Unauthorized:
- S3_CAN_CONNECT_ERROR = "AWS credentials not set," +\
- " faild to get them even by keystoneclient"
- boto_logger.setLevel(level)
diff --git a/tempest/tests/boto/test_ec2_instance_run.py b/tempest/tests/boto/test_ec2_instance_run.py
index b0a7fcd..98fdc8b 100644
--- a/tempest/tests/boto/test_ec2_instance_run.py
+++ b/tempest/tests/boto/test_ec2_instance_run.py
@@ -17,15 +17,15 @@
import logging
-from boto.exception import EC2ResponseError
+from boto import exception
import testtools
from tempest import clients
from tempest.common.utils.data_utils import rand_name
from tempest.common.utils.linux.remote_client import RemoteClient
+from tempest import exceptions
from tempest.test import attr
from tempest.testboto import BotoTestCase
-import tempest.tests.boto
from tempest.tests.boto.utils.s3 import s3_upload_dir
from tempest.tests.boto.utils.wait import re_search_wait
from tempest.tests.boto.utils.wait import state_wait
@@ -39,14 +39,14 @@
@classmethod
def setUpClass(cls):
super(InstanceRunTest, cls).setUpClass()
- if not tempest.tests.boto.A_I_IMAGES_READY:
+ if not cls.conclusion['A_I_IMAGES_READY']:
raise cls.skipException("".join(("EC2 ", cls.__name__,
": requires ami/aki/ari manifest")))
cls.os = clients.Manager()
cls.s3_client = cls.os.s3_client
cls.ec2_client = cls.os.ec2api_client
- config = cls.os.config
cls.zone = cls.ec2_client.get_good_zone()
+ config = cls.config
cls.materials_path = config.boto.s3_materials_path
ami_manifest = config.boto.ami_manifest
aki_manifest = config.boto.aki_manifest
@@ -86,7 +86,8 @@
if state != "available":
for _image in cls.images.itervalues():
cls.ec2_client.deregister_image(_image["image_id"])
- raise EC2RegisterImageException(image_id=image["image_id"])
+ raise exceptions.EC2RegisterImageException(image_id=
+ image["image_id"])
@attr(type='smoke')
def test_run_stop_terminate_instance(self):
@@ -129,7 +130,7 @@
instance.update(validate=True)
except ValueError:
pass
- except EC2ResponseError as exc:
+ except exception.EC2ResponseError as exc:
if self.ec2_error_code.\
client.InvalidInstanceID.NotFound.match(exc):
pass
diff --git a/tempest/tests/boto/test_s3_buckets.py b/tempest/tests/boto/test_s3_buckets.py
index a4d1927..0a05ae0 100644
--- a/tempest/tests/boto/test_s3_buckets.py
+++ b/tempest/tests/boto/test_s3_buckets.py
@@ -31,7 +31,6 @@
super(S3BucketsTest, cls).setUpClass()
cls.os = clients.Manager()
cls.client = cls.os.s3_client
- cls.config = cls.os.config
@testtools.skip("Skipped until the Bug #1076965 is resolved")
@attr(type='smoke')
diff --git a/tempest/tests/boto/test_s3_ec2_images.py b/tempest/tests/boto/test_s3_ec2_images.py
index 0f7628b..4068aba 100644
--- a/tempest/tests/boto/test_s3_ec2_images.py
+++ b/tempest/tests/boto/test_s3_ec2_images.py
@@ -23,7 +23,6 @@
from tempest.common.utils.data_utils import rand_name
from tempest.test import attr
from tempest.testboto import BotoTestCase
-import tempest.tests.boto
from tempest.tests.boto.utils.s3 import s3_upload_dir
from tempest.tests.boto.utils.wait import state_wait
@@ -34,13 +33,13 @@
@classmethod
def setUpClass(cls):
super(S3ImagesTest, cls).setUpClass()
- if not tempest.tests.boto.A_I_IMAGES_READY:
+ if not cls.conclusion['A_I_IMAGES_READY']:
raise cls.skipException("".join(("EC2 ", cls.__name__,
": requires ami/aki/ari manifest")))
cls.os = clients.Manager()
cls.s3_client = cls.os.s3_client
cls.images_client = cls.os.ec2api_client
- config = cls.os.config
+ config = cls.config
cls.materials_path = config.boto.s3_materials_path
cls.ami_manifest = config.boto.ami_manifest
cls.aki_manifest = config.boto.aki_manifest
diff --git a/tempest/tests/boto/test_s3_objects.py b/tempest/tests/boto/test_s3_objects.py
index 8334b07..d50dc45 100644
--- a/tempest/tests/boto/test_s3_objects.py
+++ b/tempest/tests/boto/test_s3_objects.py
@@ -34,7 +34,6 @@
super(S3BucketsTest, cls).setUpClass()
cls.os = clients.Manager()
cls.client = cls.os.s3_client
- cls.config = cls.os.config
@testtools.skip("Skipped until the Bug #1076534 is resolved")
@attr(type='smoke')
diff --git a/tempest/tests/compute/admin/test_flavors.py b/tempest/tests/compute/admin/test_flavors.py
index 30c3d59..7fabf7a 100644
--- a/tempest/tests/compute/admin/test_flavors.py
+++ b/tempest/tests/compute/admin/test_flavors.py
@@ -23,14 +23,17 @@
from tempest.tests.compute import base
-class FlavorsAdminTestBase(object):
+class FlavorsAdminTestJSON(base.BaseComputeAdminTest):
"""
Tests Flavors API Create and Delete that require admin privileges
"""
+ _interface = 'json'
+
@classmethod
- def setUpClass(self, cls):
+ def setUpClass(cls):
+ super(FlavorsAdminTestJSON, cls).setUpClass()
if not compute.FLAVOR_EXTRA_DATA_ENABLED:
msg = "FlavorExtraData extension not enabled."
raise cls.skipException(msg)
@@ -315,23 +318,5 @@
#TODO(afazekas): Negative tests with regular user
-class FlavorsAdminTestXML(base.BaseComputeAdminTestXML,
- base.BaseComputeTestXML,
- FlavorsAdminTestBase):
-
- @classmethod
- def setUpClass(cls):
- super(FlavorsAdminTestXML, cls).setUpClass()
- base.BaseComputeTestXML.setUpClass()
- FlavorsAdminTestBase.setUpClass(cls)
-
-
-class FlavorsAdminTestJSON(base.BaseComputeAdminTestJSON,
- base.BaseComputeTestJSON,
- FlavorsAdminTestBase):
-
- @classmethod
- def setUpClass(cls):
- super(FlavorsAdminTestJSON, cls).setUpClass()
- base.BaseComputeTestJSON.setUpClass()
- FlavorsAdminTestBase.setUpClass(cls)
+class FlavorsAdminTestXML(FlavorsAdminTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/admin/test_flavors_extra_specs.py b/tempest/tests/compute/admin/test_flavors_extra_specs.py
index 968603d..711b73f 100644
--- a/tempest/tests/compute/admin/test_flavors_extra_specs.py
+++ b/tempest/tests/compute/admin/test_flavors_extra_specs.py
@@ -21,7 +21,7 @@
import testtools
-class FlavorsExtraSpecsTestBase(object):
+class FlavorsExtraSpecsTestJSON(base.BaseComputeAdminTest):
"""
Tests Flavor Extra Spec API extension.
@@ -29,8 +29,11 @@
GET Flavor Extra specs can be performed even by without admin privileges.
"""
+ _interface = 'json'
+
@classmethod
- def setUpClass(self, cls):
+ def setUpClass(cls):
+ super(FlavorsExtraSpecsTestJSON, cls).setUpClass()
if not compute.FLAVOR_EXTRA_DATA_ENABLED:
msg = "FlavorExtraData extension not enabled."
raise cls.skipException(msg)
@@ -53,8 +56,9 @@
swap=swap, rxtx=rxtx)
@classmethod
- def tearDownClass(self, cls):
+ def tearDownClass(cls):
resp, body = cls.client.delete_flavor(cls.flavor['id'])
+ super(FlavorsExtraSpecsTestJSON, cls).tearDownClass()
def test_flavor_set_get_unset_keys(self):
#Test to SET, GET UNSET flavor extra spec as a user
@@ -123,33 +127,5 @@
self.fail(msg)
-class FlavorsExtraSpecsTestXML(base.BaseComputeAdminTestXML,
- base.BaseComputeTestXML,
- FlavorsExtraSpecsTestBase):
-
- @classmethod
- def setUpClass(cls):
- super(FlavorsExtraSpecsTestXML, cls).setUpClass()
- base.BaseComputeTestXML.setUpClass()
- FlavorsExtraSpecsTestBase.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- FlavorsExtraSpecsTestBase.tearDownClass(cls)
- super(FlavorsExtraSpecsTestXML, cls).tearDownClass()
-
-
-class FlavorsExtraSpecsTestJSON(base.BaseComputeAdminTestJSON,
- base.BaseComputeTestJSON,
- FlavorsExtraSpecsTestBase):
-
- @classmethod
- def setUpClass(cls):
- super(FlavorsExtraSpecsTestJSON, cls).setUpClass()
- base.BaseComputeTestJSON.setUpClass()
- FlavorsExtraSpecsTestBase.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- FlavorsExtraSpecsTestBase.tearDownClass(cls)
- super(FlavorsExtraSpecsTestJSON, cls).tearDownClass()
+class FlavorsExtraSpecsTestXML(FlavorsExtraSpecsTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/admin/test_quotas.py b/tempest/tests/compute/admin/test_quotas.py
index 9fff2fa..7430a7c 100644
--- a/tempest/tests/compute/admin/test_quotas.py
+++ b/tempest/tests/compute/admin/test_quotas.py
@@ -20,10 +20,12 @@
from tempest.tests.compute import base
-class QuotasAdminTestBase(object):
+class QuotasAdminTestJSON(base.BaseComputeAdminTest):
+ _interface = 'json'
@classmethod
def setUpClass(cls):
+ super(QuotasAdminTestJSON, cls).setUpClass()
cls.auth_url = cls.config.identity.uri
cls.client = cls.os.quotas_client
cls.adm_client = cls.os_adm.quotas_client
@@ -54,6 +56,7 @@
cls.servers_client.delete_server(server['id'])
except exceptions.NotFound:
continue
+ super(QuotasAdminTestJSON, cls).tearDownClass()
@attr(type='smoke')
def test_get_default_quotas(self):
@@ -163,31 +166,5 @@
self.assertRaises(exceptions.OverLimit, self.create_server)
-class QuotasAdminTestJSON(QuotasAdminTestBase, base.BaseComputeAdminTestJSON,
- base.BaseComputeTest):
-
- @classmethod
- def setUpClass(cls):
- base.BaseComputeAdminTestJSON.setUpClass()
- base.BaseComputeTest.setUpClass()
- super(QuotasAdminTestJSON, cls).setUpClass()
-
- @classmethod
- def tearDownClass(cls):
- super(QuotasAdminTestJSON, cls).tearDownClass()
- base.BaseComputeTest.tearDownClass()
-
-
-class QuotasAdminTestXML(QuotasAdminTestBase, base.BaseComputeAdminTestXML,
- base.BaseComputeTest):
-
- @classmethod
- def setUpClass(cls):
- base.BaseComputeAdminTestXML.setUpClass()
- base.BaseComputeTest.setUpClass()
- super(QuotasAdminTestXML, cls).setUpClass()
-
- @classmethod
- def tearDownClass(cls):
- super(QuotasAdminTestXML, cls).tearDownClass()
- base.BaseComputeTest.tearDownClass()
+class QuotasAdminTestXML(QuotasAdminTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/base.py b/tempest/tests/compute/base.py
index 2c6b861..94fff13 100644
--- a/tempest/tests/compute/base.py
+++ b/tempest/tests/compute/base.py
@@ -18,31 +18,23 @@
import logging
import time
-import testresources
-import testtools
-
from tempest import clients
from tempest.common.utils.data_utils import rand_name
-from tempest import config
from tempest import exceptions
+import tempest.test
from tempest.tests import compute
-__all__ = ['BaseComputeTest', 'BaseComputeTestJSON', 'BaseComputeTestXML',
- 'BaseComputeAdminTestJSON', 'BaseComputeAdminTestXML']
LOG = logging.getLogger(__name__)
-class BaseCompTest(testtools.testcase.WithAttributes,
- testtools.TestCase,
- testresources.ResourcedTestCase):
+class BaseComputeTest(tempest.test.BaseTestCase):
"""Base test case class for all Compute API tests."""
conclusion = compute.generic_setup_package()
@classmethod
def setUpClass(cls):
- cls.config = config.TempestConfig()
cls.isolated_creds = []
if cls.config.compute.allow_tenant_isolation:
@@ -181,36 +173,21 @@
cls.clear_isolated_creds()
@classmethod
- def create_server(cls, image_id=None, flavor=None):
+ def create_server(cls, **kwargs):
"""Wrapper utility that returns a test server."""
- server_name = rand_name(cls.__name__ + "-instance")
-
- if not flavor:
- flavor = cls.flavor_ref
- if not image_id:
- image_id = cls.image_ref
+ name = rand_name(cls.__name__ + "-instance")
+ if 'name' in kwargs:
+ name = kwargs.pop('name')
+ flavor = kwargs.get('flavor', cls.flavor_ref)
+ image_id = kwargs.get('image_id', cls.image_ref)
resp, server = cls.servers_client.create_server(
- server_name, image_id, flavor)
- cls.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
- cls.servers.append(server)
- return server
+ name, image_id, flavor, **kwargs)
- @classmethod
- def create_server_with_extras(cls, name, image_id=None,
- flavor=None, **kwargs):
- # TODO(sdague) transitional function because many
- # server tests were using extra args and resp so can't
- # easily be ported to create_server. Will be merged
- # later
- if not flavor:
- flavor = cls.flavor_ref
- if not image_id:
- image_id = cls.image_ref
+ if 'wait_until' in kwargs:
+ cls.servers_client.wait_for_server_status(
+ server['id'], kwargs['wait_until'])
- resp, server = cls.servers_client.create_server(name,
- image_id, flavor,
- **kwargs)
cls.servers.append(server)
return resp, server
@@ -230,25 +207,7 @@
time.sleep(self.build_interval)
-class BaseComputeTestJSON(BaseCompTest):
- @classmethod
- def setUpClass(cls):
- cls._interface = "json"
- super(BaseComputeTestJSON, cls).setUpClass()
-
-# NOTE(danms): For transition, keep the old name active as JSON
-BaseComputeTest = BaseComputeTestJSON
-
-
-class BaseComputeTestXML(BaseCompTest):
- @classmethod
- def setUpClass(cls):
- cls._interface = "xml"
- super(BaseComputeTestXML, cls).setUpClass()
-
-
-class BaseComputeAdminTest(BaseCompTest):
-
+class BaseComputeAdminTest(BaseComputeTest):
"""Base test case class for all Compute Admin API tests."""
@classmethod
@@ -264,17 +223,3 @@
raise cls.skipException(msg)
cls.os_adm = clients.ComputeAdminManager(interface=cls._interface)
-
-
-class BaseComputeAdminTestJSON(BaseComputeAdminTest):
- @classmethod
- def setUpClass(cls):
- cls._interface = "json"
- super(BaseComputeAdminTestJSON, cls).setUpClass()
-
-
-class BaseComputeAdminTestXML(BaseComputeAdminTest):
- @classmethod
- def setUpClass(cls):
- cls._interface = "xml"
- super(BaseComputeAdminTestXML, cls).setUpClass()
diff --git a/tempest/tests/compute/flavors/test_flavors.py b/tempest/tests/compute/flavors/test_flavors.py
index 8b49390..95244df 100644
--- a/tempest/tests/compute/flavors/test_flavors.py
+++ b/tempest/tests/compute/flavors/test_flavors.py
@@ -20,7 +20,13 @@
from tempest.tests.compute import base
-class FlavorsTestBase(object):
+class FlavorsTestJSON(base.BaseComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(FlavorsTestJSON, cls).setUpClass()
+ cls.client = cls.flavors_client
@attr(type='smoke')
def test_list_flavors(self):
@@ -149,19 +155,5 @@
9999)
-class FlavorsTestXML(base.BaseComputeTestXML,
- FlavorsTestBase):
-
- @classmethod
- def setUpClass(cls):
- super(FlavorsTestXML, cls).setUpClass()
- cls.client = cls.flavors_client
-
-
-class FlavorsTestJSON(base.BaseComputeTestJSON,
- FlavorsTestBase):
-
- @classmethod
- def setUpClass(cls):
- super(FlavorsTestJSON, cls).setUpClass()
- cls.client = cls.flavors_client
+class FlavorsTestXML(FlavorsTestJSON):
+ _interface = 'xml'
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 165cf79..0ff81e1 100644
--- a/tempest/tests/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/tests/compute/floating_ips/test_floating_ips_actions.py
@@ -21,12 +21,14 @@
from tempest.tests.compute import base
-class FloatingIPsTestBase(object):
+class FloatingIPsTestJSON(base.BaseComputeTest):
+ _interface = 'json'
server_id = None
floating_ip = None
- @staticmethod
+ @classmethod
def setUpClass(cls):
+ super(FloatingIPsTestJSON, cls).setUpClass()
cls.client = cls.floating_ips_client
cls.servers_client = cls.servers_client
@@ -51,8 +53,9 @@
if cls.non_exist_id not in cls.floating_ip_ids:
break
- @staticmethod
+ @classmethod
def tearDownClass(cls):
+ super(FloatingIPsTestJSON, cls).tearDownClass()
#Deleting the server which is created in this method
resp, body = cls.servers_client.delete_server(cls.server_id)
#Deleting the floating IP which is created in this method
@@ -111,42 +114,26 @@
# Negative test:Deletion of a nonexistent floating IP
# from project should fail
- #Deleting the non existent floating IP
- try:
- resp, body = self.client.delete_floating_ip(self.non_exist_id)
- except Exception:
- pass
- else:
- self.fail('Should not be able to delete a nonexistent floating IP')
+ # Deleting the non existent floating IP
+ self.assertRaises(exceptions.NotFound, self.client.delete_floating_ip,
+ self.non_exist_id)
@attr(type='negative')
def test_associate_nonexistant_floating_ip(self):
# Negative test:Association of a non existent floating IP
# to specific server should fail
- #Associating non existent floating IP
- try:
- resp, body = \
- self.client.associate_floating_ip_to_server("0.0.0.0",
- self.server_id)
- except exceptions.NotFound:
- pass
- else:
- self.fail('Should not be able to associate'
- ' a nonexistent floating IP')
+ # Associating non existent floating IP
+ self.assertRaises(exceptions.NotFound,
+ self.client.associate_floating_ip_to_server,
+ "0.0.0.0", self.server_id)
@attr(type='negative')
def test_dissociate_nonexistant_floating_ip(self):
# Negative test:Dissociation of a non existent floating IP should fail
- #Dissociating non existent floating IP
- try:
- resp, body = \
- self.client.disassociate_floating_ip_from_server("0.0.0.0",
- self.server_id)
- except exceptions.NotFound:
- pass
- else:
- self.fail('Should not be able to dissociate'
- ' a nonexistent floating IP')
+ # Dissociating non existent floating IP
+ self.assertRaises(exceptions.NotFound,
+ self.client.disassociate_floating_ip_from_server,
+ "0.0.0.0", self.server_id)
@attr(type='positive')
def test_associate_already_associated_floating_ip(self):
@@ -168,59 +155,26 @@
self.client.associate_floating_ip_to_server(self.floating_ip,
self.new_server_id)
- #Make sure no longer associated with old server
- try:
- self.client.disassociate_floating_ip_from_server(
- self.floating_ip,
- self.server_id)
- except exceptions.NotFound:
- pass
- else:
- self.fail('The floating IP should be associated to the second '
- 'server')
+ self.addCleanup(self.servers_client.delete_server, self.new_server_id)
if (resp['status'] is not None):
- #Dissociation of the floating IP associated in this method
- resp, _ = \
- self.client.disassociate_floating_ip_from_server(
- self.floating_ip,
- self.new_server_id)
- #Deletion of server created in this method
- resp, body = self.servers_client.delete_server(self.new_server_id)
+ self.addCleanup(self.client.disassociate_floating_ip_from_server,
+ self.floating_ip,
+ self.new_server_id)
+
+ # Make sure no longer associated with old server
+ self.assertRaises((exceptions.NotFound,
+ exceptions.UnprocessableEntity),
+ self.client.disassociate_floating_ip_from_server,
+ self.floating_ip, self.server_id)
@attr(type='negative')
def test_associate_ip_to_server_without_passing_floating_ip(self):
# Negative test:Association of empty floating IP to specific server
# should raise NotFound exception
- try:
- resp, body =\
- self.client.associate_floating_ip_to_server('',
- self.server_id)
- except exceptions.NotFound:
- pass
- else:
- self.fail('Association of floating IP to specific server'
- ' with out passing floating IP should raise BadRequest')
+ self.assertRaises(exceptions.NotFound,
+ self.client.associate_floating_ip_to_server,
+ '', self.server_id)
-class FloatingIPsTestJSON(base.BaseComputeTestJSON, FloatingIPsTestBase):
- @classmethod
- def setUpClass(cls):
- super(FloatingIPsTestJSON, cls).setUpClass()
- FloatingIPsTestBase.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- FloatingIPsTestBase.tearDownClass(cls)
- super(FloatingIPsTestJSON, cls).tearDownClass()
-
-
-class FloatingIPsTestXML(base.BaseComputeTestXML, FloatingIPsTestBase):
- @classmethod
- def setUpClass(cls):
- super(FloatingIPsTestXML, cls).setUpClass()
- FloatingIPsTestBase.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- FloatingIPsTestBase.tearDownClass(cls)
- super(FloatingIPsTestXML, cls).tearDownClass()
+class FloatingIPsTestXML(FloatingIPsTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/floating_ips/test_list_floating_ips.py b/tempest/tests/compute/floating_ips/test_list_floating_ips.py
index 42befd0..b795909 100644
--- a/tempest/tests/compute/floating_ips/test_list_floating_ips.py
+++ b/tempest/tests/compute/floating_ips/test_list_floating_ips.py
@@ -21,10 +21,12 @@
from tempest.tests.compute import base
-class FloatingIPDetailsTestBase(object):
+class FloatingIPDetailsTestJSON(base.BaseComputeTest):
+ _interface = 'json'
- @staticmethod
+ @classmethod
def setUpClass(cls):
+ super(FloatingIPDetailsTestJSON, cls).setUpClass()
cls.client = cls.floating_ips_client
cls.floating_ip = []
cls.floating_ip_id = []
@@ -34,10 +36,11 @@
cls.floating_ip.append(body)
cls.floating_ip_id.append(body['id'])
- @staticmethod
+ @classmethod
def tearDownClass(cls):
for i in range(3):
cls.client.delete_floating_ip(cls.floating_ip_id[i])
+ super(FloatingIPDetailsTestJSON, cls).tearDownClass()
@attr(type='positive')
def test_list_floating_ips(self):
@@ -87,37 +90,9 @@
non_exist_id = rand_name('999')
if non_exist_id not in floating_ip_id:
break
- try:
- resp, body = \
- self.client.get_floating_ip_details(non_exist_id)
- except exceptions.NotFound:
- pass
- else:
- self.fail('Should not be able to GET the details from a'
- 'nonexistant floating IP')
+ self.assertRaises(exceptions.NotFound,
+ self.client.get_floating_ip_details, non_exist_id)
-class FloatingIPDetailsTestJSON(base.BaseComputeTestJSON,
- FloatingIPDetailsTestBase):
- @classmethod
- def setUpClass(cls):
- super(FloatingIPDetailsTestJSON, cls).setUpClass()
- FloatingIPDetailsTestBase.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- FloatingIPDetailsTestBase.tearDownClass(cls)
- super(FloatingIPDetailsTestJSON, cls).tearDownClass()
-
-
-class FloatingIPDetailsTestXML(base.BaseComputeTestXML,
- FloatingIPDetailsTestBase):
- @classmethod
- def setUpClass(cls):
- super(FloatingIPDetailsTestXML, cls).setUpClass()
- FloatingIPDetailsTestBase.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- FloatingIPDetailsTestBase.tearDownClass(cls)
- super(FloatingIPDetailsTestXML, cls).tearDownClass()
+class FloatingIPDetailsTestXML(FloatingIPDetailsTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/images/test_image_metadata.py b/tempest/tests/compute/images/test_image_metadata.py
index 7119a8e..311ee8e 100644
--- a/tempest/tests/compute/images/test_image_metadata.py
+++ b/tempest/tests/compute/images/test_image_metadata.py
@@ -18,10 +18,11 @@
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
-from tempest.tests.compute.base import BaseComputeTest
+from tempest.tests.compute import base
-class ImagesMetadataTest(BaseComputeTest):
+class ImagesMetadataTest(base.BaseComputeTest):
+ _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -110,68 +111,41 @@
def test_list_nonexistant_image_metadata(self):
# Negative test: List on nonexistant image
# metadata should not happen
- try:
- resp, resp_metadata = self.client.list_image_metadata(999)
- except exceptions.NotFound:
- pass
- else:
- self.fail('List on nonexistant image metadata should'
- 'not happen')
+ self.assertRaises(exceptions.NotFound, self.client.list_image_metadata,
+ 999)
@attr(type='negative')
def test_update_nonexistant_image_metadata(self):
# Negative test:An update should not happen for a nonexistant image
meta = {'key1': 'alt1', 'key2': 'alt2'}
- try:
- resp, metadata = self.client.update_image_metadata(999, meta)
- except exceptions.NotFound:
- pass
- else:
- self.fail('An update shouldnt happen for nonexistant image')
+ self.assertRaises(exceptions.NotFound,
+ self.client.update_image_metadata, 999, meta)
@attr(type='negative')
def test_get_nonexistant_image_metadata_item(self):
# Negative test: Get on nonexistant image should not happen
- try:
- resp, metadata = self.client.get_image_metadata_item(999, 'key2')
- except exceptions.NotFound:
- pass
- else:
- self.fail('Get on nonexistant image should not happen')
+ self.assertRaises(exceptions.NotFound,
+ self.client.get_image_metadata_item, 999, 'key2')
@attr(type='negative')
def test_set_nonexistant_image_metadata(self):
# Negative test: Metadata should not be set to a nonexistant image
meta = {'key1': 'alt1', 'key2': 'alt2'}
- try:
- resp, meta = self.client.set_image_metadata(999, meta)
- except exceptions.NotFound:
- pass
- else:
- self.fail('Metadata should not be set to a nonexistant image')
+ self.assertRaises(exceptions.NotFound, self.client.set_image_metadata,
+ 999, meta)
@attr(type='negative')
def test_set_nonexistant_image_metadata_item(self):
# Negative test: Metadata item should not be set to a
# nonexistant image
meta = {'key1': 'alt'}
- try:
- resp, body = self.client.set_image_metadata_item(999, 'key1', meta)
- resp, metadata = self.client.list_image_metadata(999)
- except exceptions.NotFound:
- pass
- else:
- self.fail('Metadata item should not be set to a nonexistant image')
+ self.assertRaises(exceptions.NotFound,
+ self.client.set_image_metadata_item, 999, 'key1',
+ meta)
@attr(type='negative')
def test_delete_nonexistant_image_metadata_item(self):
# Negative test: Shouldnt be able to delete metadata
- # item from nonexistant image
- try:
- resp, body = self.client.delete_image_metadata_item(999, 'key1')
- resp, metadata = self.client.list_image_metadata(999)
- except exceptions.NotFound:
- pass
- else:
- self.fail('Should not be able to delete metadata item from a'
- 'nonexistant image')
+ # item from nonexistant image
+ self.assertRaises(exceptions.NotFound,
+ self.client.delete_image_metadata_item, 999, 'key1')
diff --git a/tempest/tests/compute/images/test_images.py b/tempest/tests/compute/images/test_images.py
index edc58e7..a61cef6 100644
--- a/tempest/tests/compute/images/test_images.py
+++ b/tempest/tests/compute/images/test_images.py
@@ -26,28 +26,40 @@
from tempest.tests.compute import base
-class ImagesTestBase(object):
+class ImagesTestJSON(base.BaseComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ImagesTestJSON, cls).setUpClass()
+ cls.client = cls.images_client
+ cls.servers_client = cls.servers_client
+
+ cls.image_ids = []
+
+ if compute.MULTI_USER:
+ if cls.config.compute.allow_tenant_isolation:
+ creds = cls._get_isolated_creds()
+ username, tenant_name, password = creds
+ cls.alt_manager = clients.Manager(username=username,
+ password=password,
+ tenant_name=tenant_name)
+ else:
+ # Use the alt_XXX credentials in the config file
+ cls.alt_manager = clients.AltManager()
+ cls.alt_client = cls.alt_manager.images_client
def tearDown(self):
"""Terminate test instances created after a test is executed."""
- for server in self.servers:
- resp, body = self.servers_client.delete_server(server['id'])
- if resp['status'] == '204':
- self.servers.remove(server)
- self.servers_client.wait_for_server_termination(server['id'])
-
for image_id in self.image_ids:
self.client.delete_image(image_id)
self.image_ids.remove(image_id)
+ super(ImagesTestJSON, self).tearDown()
@attr(type='negative')
def test_create_image_from_deleted_server(self):
# An image should not be created if the server instance is removed
- server_name = rand_name('server')
- resp, server = self.servers_client.create_server(server_name,
- self.image_ref,
- self.flavor_ref)
- self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+ resp, server = self.create_server(wait_until='ACTIVE')
# Delete server before trying to create server
self.servers_client.delete_server(server['id'])
@@ -92,7 +104,7 @@
@attr(type='negative')
def test_create_image_when_server_is_terminating(self):
# Return an error when creating image of server that is terminating
- server = self.create_server()
+ resp, server = self.create_server(wait_until='ACTIVE')
self.servers_client.delete_server(server['id'])
snapshot_name = rand_name('test-snap-')
@@ -102,11 +114,7 @@
@attr(type='negative')
def test_create_image_when_server_is_building(self):
# Return error when creating an image of a server that is building
- server_name = rand_name('test-vm-')
- resp, server = self.servers_client.create_server(server_name,
- self.image_ref,
- self.flavor_ref)
- self.servers.append(server)
+ resp, server = self.create_server(wait_until='BUILD')
snapshot_name = rand_name('test-snap-')
self.assertRaises(exceptions.Duplicate, self.client.create_image,
server['id'], snapshot_name)
@@ -115,7 +123,7 @@
@attr(type='negative')
def test_create_image_when_server_is_rebooting(self):
# Return error when creating an image of server that is rebooting
- server = self.create_server()
+ resp, server = self.create_server()
self.servers_client.reboot(server['id'], 'HARD')
snapshot_name = rand_name('test-snap-')
@@ -125,40 +133,24 @@
@attr(type='negative')
def test_create_image_specify_uuid_35_characters_or_less(self):
# Return an error if Image ID passed is 35 characters or less
- try:
- snapshot_name = rand_name('test-snap-')
- test_uuid = ('a' * 35)
- self.assertRaises(exceptions.NotFound, self.client.create_image,
- test_uuid, snapshot_name)
- except Exception:
- self.fail("Should return 404 Not Found if server uuid is 35"
- " characters or less")
+ snapshot_name = rand_name('test-snap-')
+ test_uuid = ('a' * 35)
+ self.assertRaises(exceptions.NotFound, self.client.create_image,
+ test_uuid, snapshot_name)
@attr(type='negative')
def test_create_image_specify_uuid_37_characters_or_more(self):
# Return an error if Image ID passed is 37 characters or more
- try:
- snapshot_name = rand_name('test-snap-')
- test_uuid = ('a' * 37)
- self.assertRaises(exceptions.NotFound, self.client.create_image,
- test_uuid, snapshot_name)
- except Exception:
- self.fail("Should return 404 Not Found if server uuid is 37"
- " characters or more")
+ snapshot_name = rand_name('test-snap-')
+ test_uuid = ('a' * 37)
+ self.assertRaises(exceptions.NotFound, self.client.create_image,
+ test_uuid, snapshot_name)
@attr(type='negative')
def test_delete_image_with_invalid_image_id(self):
# An image should not be deleted with invalid image id
- try:
- # Delete an image with invalid image id
- resp, _ = self.client.delete_image('!@$%^&*()')
-
- except exceptions.NotFound:
- pass
-
- else:
- self.fail("DELETE image request should rasie NotFound exception "
- "when requested with invalid image")
+ self.assertRaises(exceptions.NotFound, self.client.delete_image,
+ '!@$%^&*()')
@attr(type='negative')
def test_delete_non_existent_image(self):
@@ -171,95 +163,26 @@
@attr(type='negative')
def test_delete_image_blank_id(self):
# Return an error while trying to delete an image with blank Id
-
- try:
- self.assertRaises(exceptions.NotFound, self.client.delete_image,
- '')
- except Exception:
- self.fail("Did not return HTTP 404 NotFound for blank image id")
+ self.assertRaises(exceptions.NotFound, self.client.delete_image, '')
@attr(type='negative')
def test_delete_image_non_hex_string_id(self):
# Return an error while trying to delete an image with non hex id
-
image_id = '11a22b9-120q-5555-cc11-00ab112223gj'
- try:
- self.assertRaises(exceptions.NotFound, self.client.delete_image,
- image_id)
- except Exception:
- self.fail("Did not return HTTP 404 NotFound for non hex image")
+ self.assertRaises(exceptions.NotFound, self.client.delete_image,
+ image_id)
@attr(type='negative')
def test_delete_image_negative_image_id(self):
# Return an error while trying to delete an image with negative id
-
- try:
- self.assertRaises(exceptions.NotFound, self.client.delete_image,
- -1)
- except Exception:
- self.fail("Did not return HTTP 404 NotFound for negative image id")
+ self.assertRaises(exceptions.NotFound, self.client.delete_image, -1)
@attr(type='negative')
def test_delete_image_id_is_over_35_character_limit(self):
# Return an error while trying to delete image with id over limit
-
- try:
- self.assertRaises(exceptions.NotFound, self.client.delete_image,
- '11a22b9-120q-5555-cc11-00ab112223gj-3fac')
- except Exception:
- self.fail("Did not return HTTP 404 NotFound for image id that "
- "exceeds 35 character ID length limit")
+ self.assertRaises(exceptions.NotFound, self.client.delete_image,
+ '11a22b9-120q-5555-cc11-00ab112223gj-3fac')
-class ImagesTestJSON(base.BaseComputeTestJSON,
- ImagesTestBase):
- def tearDown(self):
- ImagesTestBase.tearDown(self)
- base.BaseComputeTestJSON.tearDown(self)
-
- @classmethod
- def setUpClass(cls):
- super(ImagesTestJSON, cls).setUpClass()
- cls.client = cls.images_client
- cls.servers_client = cls.servers_client
-
- cls.image_ids = []
-
- if compute.MULTI_USER:
- if cls.config.compute.allow_tenant_isolation:
- creds = cls._get_isolated_creds()
- username, tenant_name, password = creds
- cls.alt_manager = clients.Manager(username=username,
- password=password,
- tenant_name=tenant_name)
- else:
- # Use the alt_XXX credentials in the config file
- cls.alt_manager = clients.AltManager()
- cls.alt_client = cls.alt_manager.images_client
-
-
-class ImagesTestXML(base.BaseComputeTestXML,
- ImagesTestBase):
- def tearDown(self):
- ImagesTestBase.tearDown(self)
- base.BaseComputeTestXML.tearDown(self)
-
- @classmethod
- def setUpClass(cls):
- super(ImagesTestXML, cls).setUpClass()
- cls.client = cls.images_client
- cls.servers_client = cls.servers_client
-
- cls.image_ids = []
-
- if compute.MULTI_USER:
- if cls.config.compute.allow_tenant_isolation:
- creds = cls._get_isolated_creds()
- username, tenant_name, password = creds
- cls.alt_manager = clients.Manager(username=username,
- password=password,
- tenant_name=tenant_name)
- else:
- # Use the alt_XXX credentials in the config file
- cls.alt_manager = clients.AltManager()
- cls.alt_client = cls.alt_manager.images_client
+class ImagesTestXML(ImagesTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/images/test_images_oneserver.py b/tempest/tests/compute/images/test_images_oneserver.py
index 08966fd..d89b6dd 100644
--- a/tempest/tests/compute/images/test_images_oneserver.py
+++ b/tempest/tests/compute/images/test_images_oneserver.py
@@ -26,51 +26,63 @@
from tempest.tests.compute import base
-class ImagesOneServerTestBase(object):
+class ImagesOneServerTestJSON(base.BaseComputeTest):
+ _interface = 'json'
+
def tearDown(self):
"""Terminate test instances created after a test is executed."""
for image_id in self.image_ids:
self.client.delete_image(image_id)
self.image_ids.remove(image_id)
+ super(ImagesOneServerTestJSON, self).tearDown()
+
+ @classmethod
+ def setUpClass(cls):
+ super(ImagesOneServerTestJSON, cls).setUpClass()
+ cls.client = cls.images_client
+ cls.servers_client = cls.servers_client
+ resp, cls.server = cls.create_server(wait_until='ACTIVE')
+
+ cls.image_ids = []
+
+ if compute.MULTI_USER:
+ if cls.config.compute.allow_tenant_isolation:
+ creds = cls._get_isolated_creds()
+ username, tenant_name, password = creds
+ cls.alt_manager = clients.Manager(username=username,
+ password=password,
+ tenant_name=tenant_name)
+ else:
+ # Use the alt_XXX credentials in the config file
+ cls.alt_manager = clients.AltManager()
+ cls.alt_client = cls.alt_manager.images_client
@attr(type='negative')
@testtools.skip("Until Bug 1006725 is fixed")
def test_create_image_specify_multibyte_character_image_name(self):
# Return an error if the image name has multi-byte characters
- try:
- snapshot_name = rand_name('\xef\xbb\xbf')
- self.assertRaises(exceptions.BadRequest,
- self.client.create_image, self.server['id'],
- snapshot_name)
- except Exception:
- self.fail("Should return 400 Bad Request if multi byte characters"
- " are used for image name")
+ snapshot_name = rand_name('\xef\xbb\xbf')
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_image, self.server['id'],
+ snapshot_name)
@attr(type='negative')
@testtools.skip("Until Bug 1005423 is fixed")
def test_create_image_specify_invalid_metadata(self):
# Return an error when creating image with invalid metadata
- try:
- snapshot_name = rand_name('test-snap-')
- meta = {'': ''}
- self.assertRaises(exceptions.BadRequest, self.client.create_image,
- self.server['id'], snapshot_name, meta)
-
- except Exception:
- self.fail("Should raise 400 Bad Request if meta data is invalid")
+ snapshot_name = rand_name('test-snap-')
+ meta = {'': ''}
+ self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ self.server['id'], snapshot_name, meta)
@attr(type='negative')
@testtools.skip("Until Bug 1005423 is fixed")
def test_create_image_specify_metadata_over_limits(self):
# Return an error when creating image with meta data over 256 chars
- try:
- snapshot_name = rand_name('test-snap-')
- meta = {'a' * 260: 'b' * 260}
- self.assertRaises(exceptions.OverLimit, self.client.create_image,
- self.server['id'], snapshot_name, meta)
-
- except Exception:
- self.fail("Should raise 413 Over Limit if meta data was too long")
+ snapshot_name = rand_name('test-snap-')
+ meta = {'a' * 260: 'b' * 260}
+ self.assertRaises(exceptions.OverLimit, self.client.create_image,
+ self.server['id'], snapshot_name, meta)
@attr(type='negative')
@testtools.skipUnless(compute.MULTI_USER,
@@ -127,38 +139,28 @@
def test_create_second_image_when_first_image_is_being_saved(self):
# Disallow creating another image when first image is being saved
- try:
- # Create first snapshot
- snapshot_name = rand_name('test-snap-')
- resp, body = self.client.create_image(self.server['id'],
- snapshot_name)
- self.assertEqual(202, resp.status)
- image_id = parse_image_id(resp['location'])
- self.image_ids.append(image_id)
+ # Create first snapshot
+ snapshot_name = rand_name('test-snap-')
+ resp, body = self.client.create_image(self.server['id'],
+ snapshot_name)
+ self.assertEqual(202, resp.status)
+ image_id = parse_image_id(resp['location'])
+ self.image_ids.append(image_id)
- # Create second snapshot
- alt_snapshot_name = rand_name('test-snap-')
- self.client.create_image(self.server['id'],
- alt_snapshot_name)
- except exceptions.Duplicate:
- self.client.wait_for_image_status(image_id, 'ACTIVE')
-
- else:
- self.fail("Should not allow creating an image when another image "
- "of the server is still being saved")
+ # Create second snapshot
+ alt_snapshot_name = rand_name('test-snap-')
+ self.assertRaises(exceptions.Duplicate, self.client.create_image,
+ self.server['id'], alt_snapshot_name)
+ self.client.wait_for_image_status(image_id, 'ACTIVE')
@attr(type='negative')
@testtools.skip("Until Bug 1004564 is fixed")
def test_create_image_specify_name_over_256_chars(self):
# Return an error if snapshot name over 256 characters is passed
- try:
- snapshot_name = rand_name('a' * 260)
- self.assertRaises(exceptions.BadRequest, self.client.create_image,
- self.server['id'], snapshot_name)
- except Exception:
- self.fail("Should return 400 Bad Request if image name is over 256"
- " characters")
+ snapshot_name = rand_name('a' * 260)
+ self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ self.server['id'], snapshot_name)
@attr(type='negative')
def test_delete_image_that_is_not_yet_active(self):
@@ -178,59 +180,5 @@
self.assertRaises(exceptions.NotFound, self.client.get_image, image_id)
-class ImagesOneServerTestJSON(base.BaseComputeTestJSON,
- ImagesOneServerTestBase):
-
- def tearDown(self):
- ImagesOneServerTestBase.tearDown(self)
- base.BaseComputeTestJSON.tearDown(self)
-
- @classmethod
- def setUpClass(cls):
- super(ImagesOneServerTestJSON, cls).setUpClass()
- cls.client = cls.images_client
- cls.servers_client = cls.servers_client
- cls.server = cls.create_server()
-
- cls.image_ids = []
-
- if compute.MULTI_USER:
- if cls.config.compute.allow_tenant_isolation:
- creds = cls._get_isolated_creds()
- username, tenant_name, password = creds
- cls.alt_manager = clients.Manager(username=username,
- password=password,
- tenant_name=tenant_name)
- else:
- # Use the alt_XXX credentials in the config file
- cls.alt_manager = clients.AltManager()
- cls.alt_client = cls.alt_manager.images_client
-
-
-class ImagesOneServerTestXML(base.BaseComputeTestXML,
- ImagesOneServerTestBase):
-
- def tearDown(self):
- ImagesOneServerTestBase.tearDown(self)
- base.BaseComputeTestXML.tearDown(self)
-
- @classmethod
- def setUpClass(cls):
- super(ImagesOneServerTestXML, cls).setUpClass()
- cls.client = cls.images_client
- cls.servers_client = cls.servers_client
- cls.server = cls.create_server()
-
- cls.image_ids = []
-
- if compute.MULTI_USER:
- if cls.config.compute.allow_tenant_isolation:
- creds = cls._get_isolated_creds()
- username, tenant_name, password = creds
- cls.alt_manager = clients.Manager(username=username,
- password=password,
- tenant_name=tenant_name)
- else:
- # Use the alt_XXX credentials in the config file
- cls.alt_manager = clients.AltManager()
- cls.alt_client = cls.alt_manager.images_client
+class ImagesOneServerTestXML(ImagesOneServerTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/images/test_images_whitebox.py b/tempest/tests/compute/images/test_images_whitebox.py
index 88f3b53..8af812c 100644
--- a/tempest/tests/compute/images/test_images_whitebox.py
+++ b/tempest/tests/compute/images/test_images_whitebox.py
@@ -24,6 +24,7 @@
@attr(type='whitebox')
class ImagesWhiteboxTest(whitebox.ComputeWhiteboxTest, base.BaseComputeTest):
+ _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/tests/compute/images/test_list_image_filters.py b/tempest/tests/compute/images/test_list_image_filters.py
index 316d90a..472f7fb 100644
--- a/tempest/tests/compute/images/test_list_image_filters.py
+++ b/tempest/tests/compute/images/test_list_image_filters.py
@@ -19,26 +19,21 @@
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
-from tempest.tests.compute.base import BaseComputeTest
+from tempest.tests.compute import base
-class ListImageFiltersTest(BaseComputeTest):
+class ListImageFiltersTest(base.BaseComputeTest):
+ _interface = 'json'
@classmethod
def setUpClass(cls):
super(ListImageFiltersTest, cls).setUpClass()
cls.client = cls.images_client
- name = rand_name('server')
- resp, cls.server1 = cls.servers_client.create_server(name,
- cls.image_ref,
- cls.flavor_ref)
- name = rand_name('server')
- resp, cls.server2 = cls.servers_client.create_server(name,
- cls.image_ref,
- cls.flavor_ref)
+ resp, cls.server1 = cls.create_server()
+ resp, cls.server2 = cls.create_server(wait_until='ACTIVE')
+ # NOTE(sdague) this is faster than doing the sync wait_util on both
cls.servers_client.wait_for_server_status(cls.server1['id'], 'ACTIVE')
- cls.servers_client.wait_for_server_status(cls.server2['id'], 'ACTIVE')
# Create images to be used in the filter tests
image1_name = rand_name('image')
@@ -70,8 +65,6 @@
cls.client.delete_image(cls.image1_id)
cls.client.delete_image(cls.image2_id)
cls.client.delete_image(cls.image3_id)
- cls.servers_client.delete_server(cls.server1['id'])
- cls.servers_client.delete_server(cls.server2['id'])
super(ListImageFiltersTest, cls).tearDownClass()
@attr(type='negative')
@@ -232,9 +225,4 @@
@attr(type='negative')
def test_get_nonexistant_image(self):
# Negative test: GET on non existant image should fail
- try:
- resp, image = self.client.get_image(999)
- except Exception:
- pass
- else:
- self.fail('GET on non existant image should fail')
+ self.assertRaises(exceptions.NotFound, self.client.get_image, 999)
diff --git a/tempest/tests/compute/images/test_list_images.py b/tempest/tests/compute/images/test_list_images.py
index 0f661b7..d583a95 100644
--- a/tempest/tests/compute/images/test_list_images.py
+++ b/tempest/tests/compute/images/test_list_images.py
@@ -16,10 +16,11 @@
# under the License.
from tempest.test import attr
-from tempest.tests.compute.base import BaseComputeTest
+from tempest.tests.compute import base
-class ListImagesTest(BaseComputeTest):
+class ListImagesTest(base.BaseComputeTest):
+ _interface = 'json'
@classmethod
def setUpClass(cls):
diff --git a/tempest/tests/compute/keypairs/test_keypairs.py b/tempest/tests/compute/keypairs/test_keypairs.py
index 6f4569b..b48b439 100644
--- a/tempest/tests/compute/keypairs/test_keypairs.py
+++ b/tempest/tests/compute/keypairs/test_keypairs.py
@@ -20,11 +20,16 @@
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
-from tempest.tests.compute.base import BaseComputeTestJSON
-from tempest.tests.compute.base import BaseComputeTestXML
+from tempest.tests.compute import base
-class KeyPairsTestBase(object):
+class KeyPairsTestJSON(base.BaseComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(KeyPairsTestJSON, cls).setUpClass()
+ cls.client = cls.keypairs_client
@attr(type='positive')
def test_keypairs_create_list_delete(self):
@@ -129,48 +134,32 @@
# Keypair should not be created with a non RSA public key
k_name = rand_name('keypair-')
pub_key = "ssh-rsa JUNK nova@ubuntu"
- try:
- resp, _ = self.client.create_keypair(k_name, pub_key)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Expected BadRequest for invalid public key')
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_keypair, k_name, pub_key)
@attr(type='negative')
@testtools.skip("Skipped until the Bug #1086980 is resolved")
def test_keypair_delete_nonexistant_key(self):
# Non-existant key deletion should throw a proper error
k_name = rand_name("keypair-non-existant-")
- try:
- resp, _ = self.client.delete_keypair(k_name)
- except exceptions.NotFound:
- pass
- else:
- self.fail('nonexistent key')
+ self.assertRaises(exceptions.NotFound, self.client.delete_keypair,
+ k_name)
@attr(type='negative')
def test_create_keypair_with_empty_public_key(self):
# Keypair should not be created with an empty public key
k_name = rand_name("keypair-")
pub_key = ' '
- try:
- resp, _ = self.client.create_keypair(k_name, pub_key)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Expected BadRequest for empty public key')
+ self.assertRaises(exceptions.BadRequest, self.client.create_keypair,
+ k_name, pub_key)
@attr(type='negative')
def test_create_keypair_when_public_key_bits_exceeds_maximum(self):
# Keypair should not be created when public key bits are too long
k_name = rand_name("keypair-")
pub_key = 'ssh-rsa ' + 'A' * 2048 + ' openstack@ubuntu'
- try:
- resp, _ = self.client.create_keypair(k_name, pub_key)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Expected BadRequest for too long public key')
+ self.assertRaises(exceptions.BadRequest, self.client.create_keypair,
+ k_name, pub_key)
@attr(type='negative')
def test_create_keypair_with_duplicate_name(self):
@@ -179,58 +168,31 @@
resp, _ = self.client.create_keypair(k_name)
self.assertEqual(200, resp.status)
#Now try the same keyname to ceate another key
- try:
- resp, _ = self.client.create_keypair(k_name)
- #Expect a HTTP 409 Conflict Error
- except exceptions.Duplicate:
- pass
- else:
- self.fail('duplicate name')
+ self.assertRaises(exceptions.Duplicate, self.client.create_keypair,
+ k_name)
resp, _ = self.client.delete_keypair(k_name)
self.assertEqual(202, resp.status)
@attr(type='negative')
def test_create_keypair_with_empty_name_string(self):
# Keypairs with name being an empty string should not be created
- try:
- resp, _ = self.client.create_keypair('')
- except exceptions.BadRequest:
- pass
- else:
- self.fail('empty string')
+ self.assertRaises(exceptions.BadRequest, self.client.create_keypair,
+ '')
@attr(type='negative')
def test_create_keypair_with_long_keynames(self):
# Keypairs with name longer than 255 chars should not be created
k_name = 'keypair-'.ljust(260, '0')
- try:
- resp, _ = self.client.create_keypair(k_name)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('too long')
+ self.assertRaises(exceptions.BadRequest, self.client.create_keypair,
+ k_name)
@attr(type='negative')
def test_create_keypair_invalid_name(self):
# Keypairs with name being an invalid name should not be created
k_name = 'key_/.\@:'
- try:
- resp, _ = self.client.create_keypair(k_name)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('invalid name')
+ self.assertRaises(exceptions.BadRequest, self.client.create_keypair,
+ k_name)
-class KeyPairsTestXML(BaseComputeTestXML, KeyPairsTestBase):
- @classmethod
- def setUpClass(cls):
- super(KeyPairsTestXML, cls).setUpClass()
- cls.client = cls.keypairs_client
-
-
-class KeyPairsTestJSON(BaseComputeTestJSON, KeyPairsTestBase):
- @classmethod
- def setUpClass(cls):
- super(KeyPairsTestJSON, cls).setUpClass()
- cls.client = cls.keypairs_client
+class KeyPairsTestXML(KeyPairsTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/limits/test_absolute_limits.py b/tempest/tests/compute/limits/test_absolute_limits.py
index 4b17af9..129339c 100644
--- a/tempest/tests/compute/limits/test_absolute_limits.py
+++ b/tempest/tests/compute/limits/test_absolute_limits.py
@@ -20,10 +20,12 @@
from tempest.tests.compute import base
-class AbsoluteLimitsTest(object):
+class AbsoluteLimitsTestJSON(base.BaseComputeTest):
+ _interface = 'json'
- @staticmethod
+ @classmethod
def setUpClass(cls):
+ super(AbsoluteLimitsTestJSON, cls).setUpClass()
cls.client = cls.limits_client
def test_absLimits_get(self):
@@ -46,17 +48,5 @@
% ', '.join(ele for ele in missing_elements))
-class AbsoluteLimitsTestJSON(base.BaseComputeTestJSON,
- AbsoluteLimitsTest):
- @classmethod
- def setUpClass(cls):
- super(AbsoluteLimitsTestJSON, cls).setUpClass()
- AbsoluteLimitsTest.setUpClass(cls)
-
-
-class AbsoluteLimitsTestXML(base.BaseComputeTestXML,
- AbsoluteLimitsTest):
- @classmethod
- def setUpClass(cls):
- super(AbsoluteLimitsTestXML, cls).setUpClass()
- AbsoluteLimitsTest.setUpClass(cls)
+class AbsoluteLimitsTestXML(AbsoluteLimitsTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/security_groups/test_security_group_rules.py b/tempest/tests/compute/security_groups/test_security_group_rules.py
index 41ad2c8..32ac52b 100644
--- a/tempest/tests/compute/security_groups/test_security_group_rules.py
+++ b/tempest/tests/compute/security_groups/test_security_group_rules.py
@@ -21,10 +21,12 @@
from tempest.tests.compute import base
-class SecurityGroupRulesTest(object):
+class SecurityGroupRulesTestJSON(base.BaseComputeTest):
+ _interface = 'json'
- @staticmethod
+ @classmethod
def setUpClass(cls):
+ super(SecurityGroupRulesTestJSON, cls).setUpClass()
cls.client = cls.security_groups_client
@attr(type='positive')
@@ -133,21 +135,14 @@
def test_security_group_rules_create_with_invalid_id(self):
# Negative test: Creation of Security Group rule should FAIL
# with invalid Parent group id
- #Adding rules to the invalid Security Group id
+ # Adding rules to the invalid Security Group id
parent_group_id = rand_name('999')
ip_protocol = 'tcp'
from_port = 22
to_port = 22
- try:
- resp, rule =\
- self.client.create_security_group_rule(parent_group_id,
- ip_protocol,
- from_port, to_port)
- except exceptions.NotFound:
- pass
- else:
- self.fail('Security Group rule should not be created '
- 'with invalid parent group id')
+ self.assertRaises(exceptions.NotFound,
+ self.client.create_security_group_rule,
+ parent_group_id, ip_protocol, from_port, to_port)
@attr(type='negative')
def test_security_group_rules_create_with_invalid_ip_protocol(self):
@@ -163,18 +158,11 @@
ip_protocol = rand_name('999')
from_port = 22
to_port = 22
- try:
- resp, rule =\
- self.client.create_security_group_rule(parent_group_id,
- ip_protocol,
- from_port, to_port)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Security Group rule should not be created '
- 'with invalid ip_protocol')
- #Deleting the Security Group created in this method
- resp, _ = self.client.delete_security_group(securitygroup['id'])
+
+ self.addCleanup(self.client.delete_security_group, securitygroup['id'])
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group_rule,
+ parent_group_id, ip_protocol, from_port, to_port)
@attr(type='negative')
def test_security_group_rules_create_with_invalid_from_port(self):
@@ -190,18 +178,10 @@
ip_protocol = 'tcp'
from_port = rand_name('999')
to_port = 22
- try:
- resp, rule =\
- self.client.create_security_group_rule(parent_group_id,
- ip_protocol,
- from_port, to_port)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Security Group rule should not be created'
- 'with invalid from_port')
- #Deleting the Security Group created in this method
- resp, _ = self.client.delete_security_group(securitygroup['id'])
+ self.addCleanup(self.client.delete_security_group, securitygroup['id'])
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group_rule,
+ parent_group_id, ip_protocol, from_port, to_port)
@attr(type='negative')
def test_security_group_rules_create_with_invalid_to_port(self):
@@ -217,43 +197,19 @@
ip_protocol = 'tcp'
from_port = 22
to_port = rand_name('999')
- try:
- resp, rule =\
- self.client.create_security_group_rule(parent_group_id,
- ip_protocol,
- from_port, to_port)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Security Group rule should not be created'
- 'with invalid from_port')
- #Deleting the Security Group created in this method
- resp, _ = self.client.delete_security_group(securitygroup['id'])
+ self.addCleanup(self.client.delete_security_group, securitygroup['id'])
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group_rule,
+ parent_group_id, ip_protocol, from_port, to_port)
@attr(type='negative')
def test_security_group_rules_delete_with_invalid_id(self):
# Negative test: Deletion of Security Group rule should be FAIL
# with invalid rule id
- try:
- self.client.delete_security_group_rule(rand_name('999'))
- except exceptions.NotFound:
- pass
- else:
- self.fail('Security Group Rule should not be deleted '
- 'with nonexistant rule id')
+ self.assertRaises(exceptions.NotFound,
+ self.client.delete_security_group_rule,
+ rand_name('999'))
-class SecurityGroupRulesTestJSON(base.BaseComputeTestJSON,
- SecurityGroupRulesTest):
- @classmethod
- def setUpClass(cls):
- super(SecurityGroupRulesTestJSON, cls).setUpClass()
- SecurityGroupRulesTest.setUpClass(cls)
-
-
-class SecurityGroupRulesTestXML(base.BaseComputeTestXML,
- SecurityGroupRulesTest):
- @classmethod
- def setUpClass(cls):
- super(SecurityGroupRulesTestXML, cls).setUpClass()
- SecurityGroupRulesTest.setUpClass(cls)
+class SecurityGroupRulesTestXML(SecurityGroupRulesTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/security_groups/test_security_groups.py b/tempest/tests/compute/security_groups/test_security_groups.py
index f6caf2b..e5b0380 100644
--- a/tempest/tests/compute/security_groups/test_security_groups.py
+++ b/tempest/tests/compute/security_groups/test_security_groups.py
@@ -21,10 +21,12 @@
from tempest.tests.compute import base
-class SecurityGroupsTest(object):
+class SecurityGroupsTestJSON(base.BaseComputeTest):
+ _interface = 'json'
- @staticmethod
+ @classmethod
def setUpClass(cls):
+ super(SecurityGroupsTestJSON, cls).setUpClass()
cls.client = cls.security_groups_client
@attr(type='positive')
@@ -114,100 +116,60 @@
non_exist_id = rand_name('999')
if non_exist_id not in security_group_id:
break
- try:
- resp, body = \
- self.client.get_security_group(non_exist_id)
- except exceptions.NotFound:
- pass
- else:
- self.fail('Should not be able to GET the details from a '
- 'nonexistant Security Group')
+ self.assertRaises(exceptions.NotFound, self.client.get_security_group,
+ non_exist_id)
@attr(type='negative')
def test_security_group_create_with_invalid_group_name(self):
# Negative test: Security Group should not be created with group name
# as an empty string/with white spaces/chars more than 255
s_description = rand_name('description-')
- #Create Security Group with empty string as group name
- try:
- resp, _ = self.client.create_security_group("", s_description)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Security Group should not be created '
- 'with EMPTY Name')
- #Create Security Group with white space in group name
- try:
- resp, _ = self.client.create_security_group(" ", s_description)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Security Group should not be created '
- 'with WHITE SPACE in Name')
- #Create Security Group with group name longer than 255 chars
+ # Create Security Group with empty string as group name
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group, "", s_description)
+ # Create Security Group with white space in group name
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group, " ",
+ s_description)
+ # Create Security Group with group name longer than 255 chars
s_name = 'securitygroup-'.ljust(260, '0')
- try:
- resp, _ = self.client.create_security_group(s_name, s_description)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Security Group should not be created '
- 'with more than 255 chars in Name')
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group, s_name,
+ s_description)
@attr(type='negative')
def test_security_group_create_with_invalid_group_description(self):
# Negative test:Security Group should not be created with description
# as an empty string/with white spaces/chars more than 255
s_name = rand_name('securitygroup-')
- #Create Security Group with empty string as description
- try:
- resp, _ = self.client.create_security_group(s_name, "")
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Security Group should not be created '
- 'with EMPTY Description')
- #Create Security Group with white space in description
- try:
- resp, _ = self.client.create_security_group(s_name, " ")
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Security Group should not be created '
- 'with WHITE SPACE in Description')
- #Create Security Group with group description longer than 255 chars
+ # Create Security Group with empty string as description
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group, s_name, "")
+ # Create Security Group with white space in description
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group, s_name, " ")
+ # Create Security Group with group description longer than 255 chars
s_description = 'description-'.ljust(260, '0')
- try:
- resp, _ = self.client.create_security_group(s_name, s_description)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Security Group should not be created '
- 'with more than 255 chars in Description')
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group, s_name,
+ s_description)
@attr(type='negative')
def test_security_group_create_with_duplicate_name(self):
# Negative test:Security Group with duplicate name should not
# be created
- try:
- s_name = rand_name('securitygroup-')
- s_description = rand_name('description-')
- resp, security_group =\
+ s_name = rand_name('securitygroup-')
+ s_description = rand_name('description-')
+ resp, security_group =\
self.client.create_security_group(s_name, s_description)
- self.assertEqual(200, resp.status)
- #Now try the Security Group with the same 'Name'
- try:
- resp, _ =\
- self.client.create_security_group(s_name, s_description)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Security Group should not be created '
- 'with duplicate Group Name')
- finally:
- #Delete the Security Group created in this method
- resp, _ = self.client.delete_security_group(security_group['id'])
- self.assertEqual(202, resp.status)
+ self.assertEqual(200, resp.status)
+
+ self.addCleanup(self.client.delete_security_group,
+ security_group['id'])
+ # Now try the Security Group with the same 'Name'
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group, s_name,
+ s_description)
@attr(type='negative')
def test_delete_nonexistant_security_group(self):
@@ -221,25 +183,15 @@
non_exist_id = rand_name('999')
if non_exist_id not in security_group_id:
break
- try:
- resp, body = self.client.delete_security_group(non_exist_id)
- except exceptions.NotFound:
- pass
- else:
- self.fail('Should not be able to delete a nonexistant '
- 'Security Group')
+ self.assertRaises(exceptions.NotFound,
+ self.client.delete_security_group, non_exist_id)
@attr(type='negative')
def test_delete_security_group_without_passing_id(self):
# Negative test:Deletion of a Security Group with out passing ID
# should Fail
- try:
- resp, body = self.client.delete_security_group('')
- except exceptions.NotFound:
- pass
- else:
- self.fail('Should not be able to delete a Security Group'
- 'with out passing ID')
+ self.assertRaises(exceptions.NotFound,
+ self.client.delete_security_group, '')
def test_server_security_groups(self):
# Checks that security groups may be added and linked to a server
@@ -297,17 +249,5 @@
self.assertEqual(202, resp.status)
-class SecurityGroupsTestJSON(base.BaseComputeTestJSON,
- SecurityGroupsTest):
- @classmethod
- def setUpClass(cls):
- super(SecurityGroupsTestJSON, cls).setUpClass()
- SecurityGroupsTest.setUpClass(cls)
-
-
-class SecurityGroupsTestXML(base.BaseComputeTestXML,
- SecurityGroupsTest):
- @classmethod
- def setUpClass(cls):
- super(SecurityGroupsTestXML, cls).setUpClass()
- SecurityGroupsTest.setUpClass(cls)
+class SecurityGroupsTestXML(SecurityGroupsTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/servers/test_console_output.py b/tempest/tests/compute/servers/test_console_output.py
deleted file mode 100644
index bdf449d..0000000
--- a/tempest/tests/compute/servers/test_console_output.py
+++ /dev/null
@@ -1,114 +0,0 @@
-# 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 testtools
-
-from tempest.common.utils.data_utils import rand_name
-from tempest import exceptions
-from tempest.test import attr
-from tempest.tests.compute import base
-
-
-class ConsoleOutputTest(object):
-
- @classmethod
- def setUpClass(self, cls):
- cls.name = rand_name('server')
- resp, server = cls.servers_client.create_server(cls.name,
- cls.image_ref,
- cls.flavor_ref)
- cls.server_id = server['id']
-
- cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE')
-
- @classmethod
- def tearDownClass(self, cls):
- cls.servers_client.delete_server(cls.server_id)
-
- @attr(type='positive')
- def test_get_console_output(self):
- # Positive test:Should be able to GET the console output
- # for a given server_id and number of lines
- def get_output():
- resp, output = self.servers_client.get_console_output(
- self.server_id, 10)
- self.assertEqual(200, resp.status)
- self.assertNotEqual(output, None)
- lines = len(output.split('\n'))
- self.assertEqual(lines, 10)
- self.wait_for(get_output)
-
- @attr(type='negative')
- def test_get_console_output_invalid_server_id(self):
- # Negative test: Should not be able to get the console output
- # for an invalid server_id
- try:
- resp, output = self.servers_client.get_console_output(
- '!@#$%^&*()', 10)
- except exceptions.NotFound:
- pass
-
- @attr(type='positive')
- @testtools.skip('Until tempest bug 1014683 is fixed.')
- def test_get_console_output_server_id_in_reboot_status(self):
- # Positive test:Should be able to GET the console output
- # for a given server_id in reboot status
- try:
- resp, output = self.servers_client.reboot(self.server_id, 'SOFT')
- self.servers_client.wait_for_server_status(self.server_id,
- 'REBOOT')
- resp, server = self.servers_client.get_server(self.server_id)
- if (server['status'] == 'REBOOT'):
- resp, output = self.servers_client.get_console_output(
- self.server_id, 10)
- self.assertEqual(200, resp.status)
- self.assertNotEqual(output, None)
- lines = len(output.split('\n'))
- self.assertEqual(lines, 10)
- else:
- self.fail("Could not capture instance in Reboot status")
- finally:
- self.servers_client.wait_for_server_status(self.server_id,
- 'ACTIVE')
-
-
-@attr(type='smoke')
-class ConsoleOutputTestJSON(base.BaseComputeTestJSON,
- ConsoleOutputTest):
- @classmethod
- def setUpClass(cls):
- super(ConsoleOutputTestJSON, cls).setUpClass()
- ConsoleOutputTest.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- ConsoleOutputTest.tearDownClass(cls)
- super(ConsoleOutputTestJSON, cls).tearDownClass()
-
-
-@attr(type='smoke')
-class ConsoleOutputTestXML(base.BaseComputeTestXML,
- ConsoleOutputTest):
- @classmethod
- def setUpClass(cls):
- super(ConsoleOutputTestXML, cls).setUpClass()
- ConsoleOutputTest.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- ConsoleOutputTest.tearDownClass(cls)
- super(ConsoleOutputTestXML, cls).tearDownClass()
diff --git a/tempest/tests/compute/servers/test_create_server.py b/tempest/tests/compute/servers/test_create_server.py
index 838b382..aaab9fa 100644
--- a/tempest/tests/compute/servers/test_create_server.py
+++ b/tempest/tests/compute/servers/test_create_server.py
@@ -29,12 +29,15 @@
from tempest.tests.compute import base
-class ServersTest(object):
-
+@attr(type='smoke')
+class ServersTestJSON(base.BaseComputeTest):
+ _interface = 'json'
run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ disk_config = None
- @staticmethod
+ @classmethod
def setUpClass(cls):
+ super(ServersTestJSON, cls).setUpClass()
cls.meta = {'hello': 'world'}
cls.accessIPv4 = '1.1.1.1'
cls.accessIPv6 = '0000:0000:0000:0000:0000:babe:220.12.22.2'
@@ -43,23 +46,17 @@
personality = [{'path': '/test.txt',
'contents': base64.b64encode(file_contents)}]
cls.client = cls.servers_client
- cli_resp = cls.client.create_server(cls.name,
- cls.image_ref,
- cls.flavor_ref,
- meta=cls.meta,
- accessIPv4=cls.accessIPv4,
- accessIPv6=cls.accessIPv6,
- personality=personality,
- disk_config=cls.disk_config)
+ cli_resp = cls.create_server(name=cls.name,
+ meta=cls.meta,
+ accessIPv4=cls.accessIPv4,
+ accessIPv6=cls.accessIPv6,
+ personality=personality,
+ disk_config=cls.disk_config)
cls.resp, cls.server_initial = cli_resp
cls.password = cls.server_initial['adminPass']
cls.client.wait_for_server_status(cls.server_initial['id'], 'ACTIVE')
resp, cls.server = cls.client.get_server(cls.server_initial['id'])
- @staticmethod
- def tearDownClass(cls):
- cls.client.delete_server(cls.server_initial['id'])
-
@attr(type='smoke')
def test_create_server_response(self):
# Check that the required fields are returned with values
@@ -121,66 +118,28 @@
@attr(type='positive')
-class ServersTestAutoDisk(base.BaseComputeTestJSON,
- ServersTest):
+class ServersTestAutoDisk(ServersTestJSON):
+ disk_config = 'AUTO'
+
@classmethod
def setUpClass(cls):
if not compute.DISK_CONFIG_ENABLED:
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
super(ServersTestAutoDisk, cls).setUpClass()
- cls.disk_config = 'AUTO'
- ServersTest.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- ServersTest.tearDownClass(cls)
- super(ServersTestAutoDisk, cls).tearDownClass()
@attr(type='positive')
-class ServersTestManualDisk(base.BaseComputeTestJSON,
- ServersTest):
+class ServersTestManualDisk(ServersTestJSON):
+ disk_config = 'MANUAL'
+
@classmethod
def setUpClass(cls):
if not compute.DISK_CONFIG_ENABLED:
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
super(ServersTestManualDisk, cls).setUpClass()
- cls.disk_config = 'MANUAL'
- ServersTest.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- ServersTest.tearDownClass(cls)
- super(ServersTestManualDisk, cls).tearDownClass()
-@attr(type='smoke')
-class ServersTestJSON(base.BaseComputeTestJSON,
- ServersTest):
- @classmethod
- def setUpClass(cls):
- super(ServersTestJSON, cls).setUpClass()
- cls.disk_config = None
- ServersTest.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- ServersTest.tearDownClass(cls)
- super(ServersTestJSON, cls).tearDownClass()
-
-
-@attr(type='smoke')
-class ServersTestXML(base.BaseComputeTestXML,
- ServersTest):
- @classmethod
- def setUpClass(cls):
- super(ServersTestXML, cls).setUpClass()
- cls.disk_config = None
- ServersTest.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- ServersTest.tearDownClass(cls)
- super(ServersTestXML, cls).tearDownClass()
+class ServersTestXML(ServersTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/servers/test_disk_config.py b/tempest/tests/compute/servers/test_disk_config.py
index 57b95f2..3a1ec20 100644
--- a/tempest/tests/compute/servers/test_disk_config.py
+++ b/tempest/tests/compute/servers/test_disk_config.py
@@ -20,10 +20,11 @@
from tempest.common.utils.data_utils import rand_name
from tempest.test import attr
from tempest.tests import compute
-from tempest.tests.compute.base import BaseComputeTest
+from tempest.tests.compute import base
-class TestServerDiskConfig(BaseComputeTest):
+class TestServerDiskConfig(base.BaseComputeTest):
+ _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -36,14 +37,8 @@
@attr(type='positive')
def test_rebuild_server_with_manual_disk_config(self):
# A server should be rebuilt using the manual disk config option
- name = rand_name('server')
- resp, server = self.create_server_with_extras(name,
- self.image_ref,
- self.flavor_ref,
- disk_config='AUTO')
-
- #Wait for the server to become active
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
+ resp, server = self.create_server(disk_config='AUTO',
+ wait_until='ACTIVE')
#Verify the specified attributes are set correctly
resp, server = self.client.get_server(server['id'])
@@ -66,14 +61,8 @@
@attr(type='positive')
def test_rebuild_server_with_auto_disk_config(self):
# A server should be rebuilt using the auto disk config option
- name = rand_name('server')
- resp, server = self.create_server_with_extras(name,
- self.image_ref,
- self.flavor_ref,
- disk_config='MANUAL')
-
- #Wait for the server to become active
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
+ resp, server = self.create_server(disk_config='MANUAL',
+ wait_until='ACTIVE')
#Verify the specified attributes are set correctly
resp, server = self.client.get_server(server['id'])
@@ -97,14 +86,8 @@
@testtools.skipUnless(compute.RESIZE_AVAILABLE, 'Resize not available.')
def test_resize_server_from_manual_to_auto(self):
# A server should be resized from manual to auto disk config
- name = rand_name('server')
- resp, server = self.create_server_with_extras(name,
- self.image_ref,
- self.flavor_ref,
- disk_config='MANUAL')
-
- #Wait for the server to become active
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
+ resp, server = self.create_server(disk_config='MANUAL',
+ wait_until='ACTIVE')
#Resize with auto option
self.client.resize(server['id'], self.flavor_ref_alt,
@@ -123,14 +106,8 @@
@testtools.skipUnless(compute.RESIZE_AVAILABLE, 'Resize not available.')
def test_resize_server_from_auto_to_manual(self):
# A server should be resized from auto to manual disk config
- name = rand_name('server')
- resp, server = self.create_server_with_extras(name,
- self.image_ref,
- self.flavor_ref,
- disk_config='AUTO')
-
- #Wait for the server to become active
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
+ resp, server = self.create_server(disk_config='AUTO',
+ wait_until='ACTIVE')
#Resize with manual option
self.client.resize(server['id'], self.flavor_ref_alt,
diff --git a/tempest/tests/compute/servers/test_list_server_filters.py b/tempest/tests/compute/servers/test_list_server_filters.py
index 9b061b5..897ca34 100644
--- a/tempest/tests/compute/servers/test_list_server_filters.py
+++ b/tempest/tests/compute/servers/test_list_server_filters.py
@@ -23,10 +23,12 @@
from tempest.tests import utils
-class ListServerFiltersTest(object):
+class ListServerFiltersTestJSON(base.BaseComputeTest):
+ _interface = 'json'
- @staticmethod
+ @classmethod
def setUpClass(cls):
+ super(ListServerFiltersTestJSON, cls).setUpClass()
cls.client = cls.servers_client
# Check to see if the alternate image ref actually exists...
@@ -77,11 +79,12 @@
cls.s2_min = cls._convert_to_min_details(cls.s2)
cls.s3_min = cls._convert_to_min_details(cls.s3)
- @staticmethod
+ @classmethod
def tearDownClass(cls):
cls.client.delete_server(cls.s1['id'])
cls.client.delete_server(cls.s2['id'])
cls.client.delete_server(cls.s3['id'])
+ super(ListServerFiltersTestJSON, cls).tearDownClass()
def _server_id_in_results(self, server_id, results):
ids = [row['id'] for row in results]
@@ -200,27 +203,5 @@
return min_detail
-class ListServerFiltersTestJSON(base.BaseComputeTestJSON,
- ListServerFiltersTest):
- @classmethod
- def setUpClass(cls):
- super(ListServerFiltersTestJSON, cls).setUpClass()
- ListServerFiltersTest.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- super(ListServerFiltersTestJSON, cls).tearDownClass()
- ListServerFiltersTest.tearDownClass(cls)
-
-
-class ListServerFiltersTestXML(base.BaseComputeTestXML,
- ListServerFiltersTest):
- @classmethod
- def setUpClass(cls):
- super(ListServerFiltersTestXML, cls).setUpClass()
- ListServerFiltersTest.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- super(ListServerFiltersTestXML, cls).tearDownClass()
- ListServerFiltersTest.tearDownClass(cls)
+class ListServerFiltersTestXML(ListServerFiltersTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/servers/test_list_servers_negative.py b/tempest/tests/compute/servers/test_list_servers_negative.py
index f93bebf..01b11e0 100644
--- a/tempest/tests/compute/servers/test_list_servers_negative.py
+++ b/tempest/tests/compute/servers/test_list_servers_negative.py
@@ -19,10 +19,11 @@
from tempest import clients
from tempest import exceptions
from tempest.tests import compute
-from tempest.tests.compute.base import BaseComputeTest
+from tempest.tests.compute import base
-class ListServersNegativeTest(BaseComputeTest):
+class ListServersNegativeTest(base.BaseComputeTest):
+ _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -77,10 +78,10 @@
cls.existing_fixtures = []
cls.deleted_fixtures = []
for x in xrange(2):
- srv = cls.create_server()
+ resp, srv = cls.create_server()
cls.existing_fixtures.append(srv)
- srv = cls.create_server()
+ resp, srv = cls.create_server()
cls.client.delete_server(srv['id'])
# We ignore errors on termination because the server may
# be put into ERROR status on a quick spawn, then delete,
diff --git a/tempest/tests/compute/servers/test_server_actions.py b/tempest/tests/compute/servers/test_server_actions.py
index 06e441a..5046ec2 100644
--- a/tempest/tests/compute/servers/test_server_actions.py
+++ b/tempest/tests/compute/servers/test_server_actions.py
@@ -29,11 +29,28 @@
from tempest.tests.compute import base
-class ServerActionsTestBase(object):
-
+class ServerActionsTestJSON(base.BaseComputeTest):
+ _interface = 'json'
resize_available = tempest.config.TempestConfig().compute.resize_available
run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ def setUp(self):
+ #NOTE(afazekas): Normally we use the same server with all test cases,
+ # but if it has an issue, we build a new one
+ super(ServerActionsTestJSON, self).setUp()
+ # Check if the server is in a clean state after test
+ try:
+ self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ except exceptions:
+ # Rebuild server if something happened to it during a test
+ self.rebuild_servers()
+
+ @classmethod
+ def setUpClass(cls):
+ super(ServerActionsTestJSON, cls).setUpClass()
+ cls.client = cls.servers_client
+ cls.rebuild_servers()
+
@attr(type='smoke')
@testtools.skipUnless(compute.CHANGE_PASSWORD_AVAILABLE,
'Change password not available.')
@@ -193,63 +210,57 @@
file_contents = 'Test server rebuild.'
personality = [{'path': '/etc/rebuild.txt',
'contents': base64.b64encode(file_contents)}]
- try:
- resp, rebuilt_server = self.client.rebuild(999,
- self.image_ref_alt,
- name=new_name,
- meta=meta,
- personality=personality,
- adminPass='rebuild')
- except exceptions.NotFound:
- pass
- else:
- self.fail('The server rebuild for a non existing server should not'
- ' be allowed')
+ self.assertRaises(exceptions.NotFound,
+ self.client.rebuild,
+ 999, self.image_ref_alt,
+ name=new_name, meta=meta,
+ personality=personality,
+ adminPass='rebuild')
+
+ @attr(type='positive')
+ def test_get_console_output(self):
+ # Positive test:Should be able to GET the console output
+ # for a given server_id and number of lines
+ def get_output():
+ resp, output = self.servers_client.get_console_output(
+ self.server_id, 10)
+ self.assertEqual(200, resp.status)
+ self.assertNotEqual(output, None)
+ lines = len(output.split('\n'))
+ self.assertEqual(lines, 10)
+ self.wait_for(get_output)
+
+ @attr(type='negative')
+ def test_get_console_output_invalid_server_id(self):
+ # Negative test: Should not be able to get the console output
+ # for an invalid server_id
+ self.assertRaises(exceptions.NotFound,
+ self.servers_client.get_console_output,
+ '!@#$%^&*()', 10)
+
+ @attr(type='positive')
+ @testtools.skip('Until tempest bug 1014683 is fixed.')
+ def test_get_console_output_server_id_in_reboot_status(self):
+ # Positive test:Should be able to GET the console output
+ # for a given server_id in reboot status
+ resp, output = self.servers_client.reboot(self.server_id, 'SOFT')
+ self.servers_client.wait_for_server_status(self.server_id,
+ 'REBOOT')
+ resp, output = self.servers_client.get_console_output(self.server_id,
+ 10)
+ self.assertEqual(200, resp.status)
+ self.assertNotEqual(output, None)
+ lines = len(output.split('\n'))
+ self.assertEqual(lines, 10)
@classmethod
def rebuild_servers(cls):
# Destroy any existing server and creates a new one
cls.clear_servers()
- cls.name = rand_name('server')
- resp, server = cls.create_server_with_extras(cls.name,
- cls.image_ref,
- cls.flavor_ref)
+ resp, server = cls.create_server(wait_until='ACTIVE')
cls.server_id = server['id']
cls.password = server['adminPass']
- cls.client.wait_for_server_status(cls.server_id, 'ACTIVE')
-class ServerActionsTestXML(base.BaseComputeTestXML,
- ServerActionsTestBase):
- def setUp(self):
- super(ServerActionsTestXML, self).setUp()
- # Check if the server is in a clean state after test
- try:
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
- except exceptions:
- # Rebuild server if something happened to it during a test
- self.rebuild_servers()
-
- @classmethod
- def setUpClass(cls):
- super(ServerActionsTestXML, cls).setUpClass()
- cls.client = cls.servers_client
- cls.rebuild_servers()
-
-
-class ServerActionsTestJSON(base.BaseComputeTestJSON,
- ServerActionsTestBase):
- def setUp(self):
- super(ServerActionsTestJSON, self).setUp()
- # Check if the server is in a clean state after test
- try:
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
- except exceptions:
- # Rebuild server if something happened to it during a test
- self.rebuild_servers()
-
- @classmethod
- def setUpClass(cls):
- super(ServerActionsTestJSON, cls).setUpClass()
- cls.client = cls.servers_client
- cls.rebuild_servers()
+class ServerActionsTestXML(ServerActionsTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/servers/test_server_addresses.py b/tempest/tests/compute/servers/test_server_addresses.py
index 8888281..c69f68d 100644
--- a/tempest/tests/compute/servers/test_server_addresses.py
+++ b/tempest/tests/compute/servers/test_server_addresses.py
@@ -18,10 +18,11 @@
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
-from tempest.tests.compute.base import BaseComputeTest
+from tempest.tests.compute import base
-class ServerAddressesTest(BaseComputeTest):
+class ServerAddressesTest(base.BaseComputeTest):
+ _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -42,26 +43,15 @@
@attr(type='negative', category='server-addresses')
def test_list_server_addresses_invalid_server_id(self):
# List addresses request should fail if server id not in system
-
- try:
- self.client.list_addresses('999')
- except exceptions.NotFound:
- pass
- else:
- self.fail('The server rebuild for a non existing server should not'
- ' be allowed')
+ self.assertRaises(exceptions.NotFound, self.client.list_addresses,
+ '999')
@attr(type='negative', category='server-addresses')
def test_list_server_addresses_by_network_neg(self):
# List addresses by network should fail if network name not valid
-
- try:
- self.client.list_addresses_by_network(self.server['id'], 'invalid')
- except exceptions.NotFound:
- pass
- else:
- self.fail('The server rebuild for a non existing server should not'
- ' be allowed')
+ self.assertRaises(exceptions.NotFound,
+ self.client.list_addresses_by_network,
+ self.server['id'], 'invalid')
@attr(type='smoke', category='server-addresses')
def test_list_server_addresses(self):
diff --git a/tempest/tests/compute/servers/test_server_metadata.py b/tempest/tests/compute/servers/test_server_metadata.py
index ce7a6a8..4b17fa2 100644
--- a/tempest/tests/compute/servers/test_server_metadata.py
+++ b/tempest/tests/compute/servers/test_server_metadata.py
@@ -18,16 +18,21 @@
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
-from tempest.tests.compute.base import BaseComputeTest
+from tempest.tests.compute import base
-class ServerMetadataTest(BaseComputeTest):
+class ServerMetadataTest(base.BaseComputeTest):
+ _interface = 'json'
@classmethod
def setUpClass(cls):
super(ServerMetadataTest, cls).setUpClass()
cls.client = cls.servers_client
-
+ cls.quotas = cls.quotas_client
+ cls.admin_client = cls._get_identity_admin_client()
+ resp, tenants = cls.admin_client.list_tenants()
+ cls.tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
+ cls.client.tenant_name][0]
#Create a server to be used for all read only tests
name = rand_name('server')
resp, server = cls.client.create_server(name, cls.image_ref,
@@ -78,11 +83,9 @@
for sz in [256, 257, 511, 1023]:
key = "k" * sz
meta = {key: 'data1'}
- name = rand_name('server')
self.assertRaises(exceptions.OverLimit,
- self.create_server_with_extras,
- name, self.image_ref,
- self.flavor_ref, meta=meta)
+ self.create_server,
+ meta=meta)
# no teardown - all creates should fail
@@ -90,11 +93,9 @@
def test_create_metadata_key_error(self):
# Blank key should trigger an error.
meta = {'': 'data1'}
- name = rand_name('server')
self.assertRaises(exceptions.BadRequest,
- self.create_server_with_extras,
- name, self.image_ref,
- self.flavor_ref, meta=meta)
+ self.create_server,
+ meta=meta)
def test_update_server_metadata(self):
# The server's metadata values should be updated to the
@@ -109,6 +110,15 @@
expected = {'key1': 'alt1', 'key2': 'value2', 'key3': 'value3'}
self.assertEqual(expected, resp_metadata)
+ def test_update_metadata_empty_body(self):
+ # The original metadata should not be lost if empty metadata body is
+ # passed
+ meta = {}
+ _, metadata = self.client.update_server_metadata(self.server_id, meta)
+ resp, resp_metadata = self.client.list_server_metadata(self.server_id)
+ expected = {'key1': 'value1', 'key2': 'value2'}
+ self.assertEqual(expected, resp_metadata)
+
def test_get_server_metadata_item(self):
# The value for a specic metadata key should be returned
resp, meta = self.client.get_server_metadata_item(self.server_id,
@@ -142,63 +152,40 @@
@attr(type='negative')
def test_get_nonexistant_server_metadata_item(self):
# Negative test: GET on nonexistant server should not succeed
- try:
- resp, meta = self.client.get_server_metadata_item(999, 'test2')
- except Exception:
- pass
- else:
- self.fail('GET on nonexistant server should not succeed')
+ self.assertRaises(exceptions.NotFound,
+ self.client.get_server_metadata_item, 999, 'test2')
@attr(type='negative')
def test_list_nonexistant_server_metadata(self):
# Negative test:List metadata on a non existant server should
# not succeed
- try:
- resp, metadata = self.client.list_server_metadata(999)
- except Exception:
- pass
- else:
- self.fail('List metadata on a non existant server should'
- 'not succeed')
+ self.assertRaises(exceptions.NotFound,
+ self.client.list_server_metadata, 999)
@attr(type='negative')
def test_set_server_metadata_item_incorrect_uri_key(self):
- #Raise BadRequest if key in uri does not match
- #the key passed in body.
+ # Raise BadRequest if key in uri does not match
+ # the key passed in body.
meta = {'testkey': 'testvalue'}
- try:
- resp, metadata = self.client.set_server_metadata_item(
- self.server_id, 'key', meta)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Should raise BadRequest if URI key does not match key'
- 'passed in the body')
+ self.assertRaises(exceptions.BadRequest,
+ self.client.set_server_metadata_item,
+ self.server_id, 'key', meta)
@attr(type='negative')
def test_set_nonexistant_server_metadata(self):
# Negative test: Set metadata on a non existant server should not
# succeed
meta = {'meta1': 'data1'}
- try:
- resp, metadata = self.client.set_server_metadata(999, meta)
- except Exception:
- pass
- else:
- self.fail('Set metadata on a non existant server should'
- 'not succeed')
+ self.assertRaises(exceptions.NotFound,
+ self.client.set_server_metadata, 999, meta)
@attr(type='negative')
def test_update_nonexistant_server_metadata(self):
# Negative test: An update should not happen for a nonexistant image
meta = {'key1': 'value1', 'key2': 'value2'}
- try:
- resp, metadata = self.client.update_server_metadata(999, meta)
- except Exception:
- pass
- else:
- self.fail('An update should not happen for a nonexistant image')
+ self.assertRaises(exceptions.NotFound,
+ self.client.update_server_metadata, 999, meta)
@attr(type='negative')
def test_update_metadata_key_error(self):
@@ -211,12 +198,43 @@
@attr(type='negative')
def test_delete_nonexistant_server_metadata_item(self):
# Negative test: Should not be able to delete metadata item from a
- # nonexistant server
+ # nonexistant server
#Delete the metadata item
- try:
- resp, metadata = self.client.delete_server_metadata_item(999, 'd')
- except Exception:
- pass
- else:
- self.fail('A delete should not happen for a nonexistant image')
+ self.assertRaises(exceptions.NotFound,
+ self.client.delete_server_metadata_item, 999, 'd')
+
+ @attr(type='negative')
+ def test_set_server_metadata_too_long(self):
+ # Raise a 413 OverLimit exception while exceeding metadata items limit
+ # for tenant.
+ _, quota_set = self.quotas.get_quota_set(self.tenant_id)
+ quota_metadata = quota_set['metadata_items']
+ req_metadata = {}
+ for num in range(1, quota_metadata + 2):
+ req_metadata['key' + str(num)] = 'val' + str(num)
+ self.assertRaises(exceptions.OverLimit,
+ self.client.set_server_metadata,
+ self.server_id, req_metadata)
+
+ @attr(type='negative')
+ def test_update_server_metadata_too_long(self):
+ # Raise a 413 OverLimit exception while exceeding metadata items limit
+ # for tenant.
+ _, quota_set = self.quotas.get_quota_set(self.tenant_id)
+ quota_metadata = quota_set['metadata_items']
+ req_metadata = {}
+ for num in range(1, quota_metadata + 2):
+ req_metadata['key' + str(num)] = 'val' + str(num)
+ self.assertRaises(exceptions.OverLimit,
+ self.client.update_server_metadata,
+ self.server_id, req_metadata)
+
+ @attr(type='negative')
+ def test_update_all_metadata_field_error(self):
+ # Raise a bad request error for blank key.
+ # set_server_metadata will replace all metadata with new value
+ meta = {'': 'data1'}
+ self.assertRaises(exceptions.BadRequest,
+ self.client.set_server_metadata,
+ self.server_id, meta=meta)
diff --git a/tempest/tests/compute/servers/test_server_personality.py b/tempest/tests/compute/servers/test_server_personality.py
index 862cfb2..0bafc2c 100644
--- a/tempest/tests/compute/servers/test_server_personality.py
+++ b/tempest/tests/compute/servers/test_server_personality.py
@@ -23,12 +23,18 @@
from tempest.tests.compute import base
-class ServerPersonalityTestBase(object):
+class ServerPersonalityTestJSON(base.BaseComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ServerPersonalityTestJSON, cls).setUpClass()
+ cls.client = cls.servers_client
+ cls.user_client = cls.limits_client
def test_personality_files_exceed_limit(self):
# Server creation should fail if greater than the maximum allowed
# number of files are injected into the server.
- name = rand_name('server')
file_contents = 'This is a test file.'
personality = []
max_file_limit = \
@@ -38,9 +44,7 @@
personality.append({'path': path,
'contents': base64.b64encode(file_contents)})
try:
- self.create_server_with_extras(name, self.image_ref,
- self.flavor_ref,
- personality=personality)
+ self.create_server(personality=personality)
except exceptions.OverLimit:
pass
else:
@@ -51,7 +55,6 @@
# Server should be created successfully if maximum allowed number of
# files is injected into the server during creation.
try:
- name = rand_name('server')
file_contents = 'This is a test file.'
max_file_limit = \
@@ -64,9 +67,7 @@
'path': path,
'contents': base64.b64encode(file_contents),
})
- resp, server = self.create_server_with_extras(name, self.image_ref,
- self.flavor_ref,
- personality=person)
+ resp, server = self.create_server(personality=person)
self.assertEqual('202', resp['status'])
#Teardown
@@ -74,21 +75,5 @@
self.client.delete_server(server['id'])
-class ServerPersonalityTestXML(base.BaseComputeTestXML,
- ServerPersonalityTestBase):
- @classmethod
- def setUpClass(cls):
- cls._interface = "xml"
- super(ServerPersonalityTestXML, cls).setUpClass()
- cls.client = cls.servers_client
- cls.user_client = cls.limits_client
-
-
-class ServerPersonalityTestJSON(base.BaseComputeTestJSON,
- ServerPersonalityTestBase):
- @classmethod
- def setUpClass(cls):
- cls._interface = "json"
- super(ServerPersonalityTestJSON, cls).setUpClass()
- cls.client = cls.servers_client
- cls.user_client = cls.limits_client
+class ServerPersonalityTestXML(ServerPersonalityTestJSON):
+ _interface = "xml"
diff --git a/tempest/tests/compute/servers/test_servers.py b/tempest/tests/compute/servers/test_servers.py
index caf0679..a8d28df 100644
--- a/tempest/tests/compute/servers/test_servers.py
+++ b/tempest/tests/compute/servers/test_servers.py
@@ -20,7 +20,13 @@
from tempest.tests.compute import base
-class ServersTestBase(object):
+class ServersTestJSON(base.BaseComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ServersTestJSON, cls).setUpClass()
+ cls.client = cls.servers_client
@attr(type='positive')
def test_create_server_with_admin_password(self):
@@ -29,11 +35,7 @@
try:
server = None
- name = rand_name('server')
- resp, server = self.create_server_with_extras(name, self.image_ref,
- self.flavor_ref,
- adminPass='test'
- 'password')
+ resp, server = self.create_server(adminPass='testpassword')
#Verify the password is set correctly in the response
self.assertEqual('testpassword', server['adminPass'])
@@ -46,19 +48,16 @@
def test_create_with_existing_server_name(self):
# Creating a server with a name that already exists is allowed
+ # TODO(sdague): clear out try, we do cleanup one layer up
try:
id1 = None
id2 = None
server_name = rand_name('server')
- resp, server = self.create_server_with_extras(server_name,
- self.image_ref,
- self.flavor_ref)
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
+ resp, server = self.create_server(name=server_name,
+ wait_until='ACTIVE')
id1 = server['id']
- resp, server = self.create_server_with_extras(server_name,
- self.image_ref,
- self.flavor_ref)
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
+ resp, server = self.create_server(name=server_name,
+ wait_until='ACTIVE')
id2 = server['id']
self.assertNotEqual(id1, id2, "Did not create a new server")
resp, server = self.client.get_server(id1)
@@ -80,11 +79,7 @@
key_name = rand_name('key')
resp, keypair = self.keypairs_client.create_keypair(key_name)
resp, body = self.keypairs_client.list_keypairs()
- server_name = rand_name('server')
- resp, server = self.create_server_with_extras(server_name,
- self.image_ref,
- self.flavor_ref,
- key_name=key_name)
+ resp, server = self.create_server(key_name=key_name)
self.assertEqual('202', resp['status'])
self.client.wait_for_server_status(server['id'], 'ACTIVE')
resp, server = self.client.get_server(server['id'])
@@ -98,10 +93,7 @@
# The server name should be changed to the the provided value
try:
server = None
- name = rand_name('server')
- resp, server = self.create_server_with_extras(name, self.image_ref,
- self.flavor_ref)
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
+ resp, server = self.create_server(wait_until='ACTIVE')
#Update the server with a new name
resp, server = self.client.update_server(server['id'],
@@ -123,10 +115,7 @@
# The server's access addresses should reflect the provided values
try:
server = None
- name = rand_name('server')
- resp, server = self.create_server_with_extras(name, self.image_ref,
- self.flavor_ref)
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
+ resp, server = self.create_server(wait_until='ACTIVE')
#Update the IPv4 and IPv6 access addresses
resp, body = self.client.update_server(server['id'],
@@ -147,23 +136,10 @@
def test_delete_server_while_in_building_state(self):
# Delete a server while it's VM state is Building
- name = rand_name('server')
- resp, server = self.create_server_with_extras(name, self.image_ref,
- self.flavor_ref)
- self.client.wait_for_server_status(server['id'], 'BUILD')
+ resp, server = self.create_server(wait_until='BUILD')
resp, _ = self.client.delete_server(server['id'])
self.assertEqual('204', resp['status'])
-class ServersTestJSON(base.BaseComputeTestJSON, ServersTestBase):
- @classmethod
- def setUpClass(cls):
- super(ServersTestJSON, cls).setUpClass()
- cls.client = cls.servers_client
-
-
-class ServersTestXML(base.BaseComputeTestXML, ServersTestBase):
- @classmethod
- def setUpClass(cls):
- super(ServersTestXML, cls).setUpClass()
- cls.client = cls.servers_client
+class ServersTestXML(ServersTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/servers/test_servers_negative.py b/tempest/tests/compute/servers/test_servers_negative.py
index 553af78..366b630 100644
--- a/tempest/tests/compute/servers/test_servers_negative.py
+++ b/tempest/tests/compute/servers/test_servers_negative.py
@@ -21,10 +21,11 @@
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
-from tempest.tests.compute.base import BaseComputeTest
+from tempest.tests.compute import base
-class ServersNegativeTest(BaseComputeTest):
+class ServersNegativeTest(base.BaseComputeTest):
+ _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -38,117 +39,78 @@
@attr(type='negative')
def test_server_name_blank(self):
# Create a server with name parameter empty
- try:
- resp, server = self.create_server_with_extras('',
- self.image_ref,
- self.flavor_ref)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Server name cannot be blank')
+
+ self.assertRaises(exceptions.BadRequest,
+ self.create_server,
+ name='')
@attr(type='negative')
def test_personality_file_contents_not_encoded(self):
# Use an unencoded file when creating a server with personality
+
file_contents = 'This is a test file.'
person = [{'path': '/etc/testfile.txt',
'contents': file_contents}]
- try:
- resp, server = self.create_server_with_extras('test',
- self.image_ref,
- self.flavor_ref,
- personality=person)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Unencoded file contents should not be accepted')
+ self.assertRaises(exceptions.BadRequest,
+ self.create_server,
+ personality=person)
@attr(type='negative')
def test_create_with_invalid_image(self):
# Create a server with an unknown image
- try:
- resp, server = self.create_server_with_extras('fail', -1,
- self.flavor_ref)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Cannot create a server with an invalid image')
+
+ self.assertRaises(exceptions.BadRequest,
+ self.create_server,
+ image_id=-1)
@attr(type='negative')
def test_create_with_invalid_flavor(self):
# Create a server with an unknown flavor
- try:
- self.create_server_with_extras('fail', self.image_ref, -1)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Cannot create a server with an invalid flavor')
+
+ self.assertRaises(exceptions.BadRequest,
+ self.create_server,
+ flavor=-1,)
@attr(type='negative')
def test_invalid_access_ip_v4_address(self):
# An access IPv4 address must match a valid address pattern
+
IPv4 = '1.1.1.1.1.1'
- name = rand_name('server')
- try:
- resp, server = self.create_server_with_extras(name,
- self.image_ref,
- self.flavor_ref,
- accessIPv4=IPv4)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Access IPv4 address must match the correct format')
+ self.assertRaises(exceptions.BadRequest,
+ self.create_server, accessIPv4=IPv4)
@attr(type='negative')
def test_invalid_ip_v6_address(self):
# An access IPv6 address must match a valid address pattern
+
IPv6 = 'notvalid'
- name = rand_name('server')
- try:
- resp, server = self.create_server_with_extras(name,
- self.image_ref,
- self.flavor_ref,
- accessIPv6=IPv6)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Access IPv6 address must match the correct format')
+
+ self.assertRaises(exceptions.BadRequest,
+ self.create_server, accessIPv6=IPv6)
@attr(type='negative')
def test_reboot_deleted_server(self):
# Reboot a deleted server
- self.name = rand_name('server')
- resp, create_server = self.create_server_with_extras(self.name,
- self.image_ref,
- self.flavor_ref)
- self.server_id = create_server['id']
+ resp, server = self.create_server()
+ self.server_id = server['id']
self.client.delete_server(self.server_id)
self.client.wait_for_server_termination(self.server_id)
- try:
- resp1, reboot_server = self.client.reboot(self.server_id, 'SOFT')
- except exceptions.NotFound:
- pass
- else:
- self.fail('Should not be able to reboot a deleted server')
+ self.assertRaises(exceptions.NotFound, self.client.reboot,
+ self.server_id, 'SOFT')
@attr(type='negative')
def test_rebuild_deleted_server(self):
# Rebuild a deleted server
- self.name = rand_name('server')
- resp, create_server = self.create_server_with_extras(self.name,
- self.image_ref,
- self.flavor_ref)
- self.server_id = create_server['id']
+
+ resp, server = self.create_server()
+ self.server_id = server['id']
self.client.delete_server(self.server_id)
self.client.wait_for_server_termination(self.server_id)
- try:
- resp1, rebuild_server = self.client.rebuild(self.server_id,
- self.image_ref_alt)
- except exceptions.NotFound:
- pass
- else:
- self.fail('Should not be able to rebuild a deleted server')
+
+ self.assertRaises(exceptions.NotFound,
+ self.client.rebuild,
+ self.server_id, self.image_ref_alt)
@attr(type='negative')
def test_create_numeric_server_name(self):
@@ -156,8 +118,8 @@
server_name = 12345
self.assertRaises(exceptions.BadRequest,
- self.create_server_with_extras,
- server_name, self.image_ref, self.flavor_ref)
+ self.create_server,
+ name=server_name)
@attr(type='negative')
def test_create_server_name_length_exceeds_256(self):
@@ -165,19 +127,17 @@
server_name = 'a' * 256
self.assertRaises(exceptions.BadRequest,
- self.create_server_with_extras,
- server_name, self.image_ref, self.flavor_ref)
+ self.create_server,
+ name=server_name)
@attr(type='negative')
def test_create_with_invalid_network_uuid(self):
# Pass invalid network uuid while creating a server
- server_name = rand_name('server')
networks = [{'fixed_ip': '10.0.1.1', 'uuid': 'a-b-c-d-e-f-g-h-i-j'}]
self.assertRaises(exceptions.BadRequest,
- self.create_server_with_extras,
- server_name, self.image_ref, self.flavor_ref,
+ self.create_server,
networks=networks)
@attr(type='negative')
@@ -185,21 +145,17 @@
# Pass a non existant keypair while creating a server
key_name = rand_name('key')
- server_name = rand_name('server')
self.assertRaises(exceptions.BadRequest,
- self.create_server_with_extras,
- server_name, self.image_ref, self.flavor_ref,
+ self.create_server,
key_name=key_name)
@attr(type='negative')
def test_create_server_metadata_exceeds_length_limit(self):
# Pass really long metadata while creating a server
- server_name = rand_name('server')
metadata = {'a': 'b' * 260}
self.assertRaises(exceptions.OverLimit,
- self.create_server_with_extras,
- server_name, self.image_ref, self.flavor_ref,
+ self.create_server,
meta=metadata)
@attr(type='negative')
@@ -277,19 +233,15 @@
@attr(type='negative')
def test_create_with_nonexistent_security_group(self):
# Create a server with a nonexistent security group
- try:
- security_groups = [{'name': 'does_not_exist'}]
- self.create_server_with_extras('fail',
- self.image_ref,
- self.flavor_ref,
- security_groups=security_groups)
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Server was created with nonexistent security group')
+
+ security_groups = [{'name': 'does_not_exist'}]
+ self.assertRaises(exceptions.BadRequest,
+ self.create_server,
+ security_groups=security_groups)
@attr(type='negative')
def test_get_non_existent_server(self):
# Get a non existent server details
+
self.assertRaises(exceptions.NotFound, self.client.get_server,
'999erra43')
diff --git a/tempest/tests/compute/servers/test_servers_whitebox.py b/tempest/tests/compute/servers/test_servers_whitebox.py
index 94502c3..9b75cd5 100644
--- a/tempest/tests/compute/servers/test_servers_whitebox.py
+++ b/tempest/tests/compute/servers/test_servers_whitebox.py
@@ -23,11 +23,13 @@
@attr(type='whitebox')
class ServersWhiteboxTest(whitebox.ComputeWhiteboxTest):
+ _interface = 'json'
@classmethod
def setUpClass(cls):
raise cls.skipException("Until Bug 1034129 is fixed")
super(ServersWhiteboxTest, cls).setUpClass()
+ #NOTE(afazekas): Strange relationship
BaseIdentityAdminTest.setUpClass()
cls.client = cls.servers_client
cls.img_client = cls.images_client
diff --git a/tempest/tests/compute/servers/test_virtual_interfaces.py b/tempest/tests/compute/servers/test_virtual_interfaces.py
index 6198526..4c48366 100644
--- a/tempest/tests/compute/servers/test_virtual_interfaces.py
+++ b/tempest/tests/compute/servers/test_virtual_interfaces.py
@@ -15,16 +15,21 @@
# License for the specific language governing permissions and limitations
# under the License.
+import netaddr
+
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
from tempest.tests.compute import base
-class VirtualInterfacesTest(object):
+@attr(type='smoke')
+class VirtualInterfacesTestJSON(base.BaseComputeTest):
+ _interface = 'json'
@classmethod
- def setUpClass(self, cls):
+ def setUpClass(cls):
+ super(VirtualInterfacesTestJSON, cls).setUpClass()
cls.name = rand_name('server')
cls.client = cls.servers_client
resp, server = cls.servers_client.create_server(cls.name,
@@ -35,8 +40,9 @@
cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE')
@classmethod
- def tearDownClass(self, cls):
+ def tearDownClass(cls):
cls.servers_client.delete_server(cls.server_id)
+ super(VirtualInterfacesTestJSON, cls).tearDownClass()
@attr(type='positive')
def test_list_virtual_interfaces(self):
@@ -45,43 +51,24 @@
resp, output = self.client.list_virtual_interfaces(self.server_id)
self.assertEqual(200, resp.status)
self.assertNotEqual(output, None)
- virtual_interfaces = output
- self.assertNotEqual(0, len(virtual_interfaces),
- 'Expected virtual interfaces, got zero.')
+ virt_ifaces = output
+ self.assertNotEqual(0, len(virt_ifaces['virtual_interfaces']),
+ 'Expected virtual interfaces, got 0 interfaces.')
+ for virt_iface in virt_ifaces['virtual_interfaces']:
+ mac_address = virt_iface['mac_address']
+ self.assertTrue(netaddr.valid_mac(mac_address),
+ "Invalid mac address detected.")
@attr(type='negative')
def test_list_virtual_interfaces_invalid_server_id(self):
# Negative test: Should not be able to GET virtual interfaces
# for an invalid server_id
- try:
- resp, output = self.client.list_virtual_interfaces('!@#$%^&*()')
- except exceptions.NotFound:
- pass
+ invalid_server_id = rand_name('!@#$%^&*()')
+ self.assertRaises(exceptions.NotFound,
+ self.client.list_virtual_interfaces,
+ invalid_server_id)
@attr(type='smoke')
-class VirtualInterfacesTestJSON(base.BaseComputeTestJSON,
- VirtualInterfacesTest):
- @classmethod
- def setUpClass(cls):
- super(VirtualInterfacesTestJSON, cls).setUpClass()
- VirtualInterfacesTest.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- VirtualInterfacesTest.tearDownClass(cls)
- super(VirtualInterfacesTestJSON, cls).tearDownClass()
-
-
-@attr(type='smoke')
-class VirtualInterfacesTestXML(base.BaseComputeTestXML,
- VirtualInterfacesTest):
- @classmethod
- def setUpClass(cls):
- super(VirtualInterfacesTestXML, cls).setUpClass()
- VirtualInterfacesTest.setUpClass(cls)
-
- @classmethod
- def tearDownClass(cls):
- VirtualInterfacesTest.tearDownClass(cls)
- super(VirtualInterfacesTestXML, cls).tearDownClass()
+class VirtualInterfacesTestXML(VirtualInterfacesTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/test_authorization.py b/tempest/tests/compute/test_authorization.py
index d826d40..52e457d 100644
--- a/tempest/tests/compute/test_authorization.py
+++ b/tempest/tests/compute/test_authorization.py
@@ -22,10 +22,11 @@
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.tests import compute
-from tempest.tests.compute.base import BaseComputeTest
+from tempest.tests.compute import base
-class AuthorizationTest(BaseComputeTest):
+class AuthorizationTest(base.BaseComputeTest):
+ _interface = 'json'
@classmethod
def setUpClass(cls):
@@ -243,6 +244,7 @@
# Reset the base_url...
self.alt_security_client.base_url = self.saved_base_url
if resp['status'] is not None:
+ #TODO(afazekas): body not defined
self.alt_security_client.delete_security_group(body['id'])
self.fail("Create Security Group request should not happen if"
"the tenant id does not match the current user")
@@ -283,7 +285,7 @@
self.alt_security_client.base_url = self.saved_base_url
if resp['status'] is not None:
self.alt_security_client.delete_security_group_rule(
- body['id'])
+ body['id']) # BUG
self.fail("Create security group rule request should not "
"happen if the tenant id does not match the"
" current user")
diff --git a/tempest/tests/compute/test_extensions.py b/tempest/tests/compute/test_extensions.py
index 36a04d2..2c13fb9 100644
--- a/tempest/tests/compute/test_extensions.py
+++ b/tempest/tests/compute/test_extensions.py
@@ -20,27 +20,16 @@
from tempest.tests.compute import base
-class ExtensionsTestBase(object):
+class ExtensionsTestJSON(base.BaseComputeTest):
+ _interface = 'json'
@attr(type='positive')
def test_list_extensions(self):
# List of all extensions
- resp, extensions = self.client.list_extensions()
+ resp, extensions = self.extensions_client.list_extensions()
self.assertTrue("extensions" in extensions)
self.assertEqual(200, resp.status)
-class ExtensionsTestJSON(base.BaseComputeTest, ExtensionsTestBase):
-
- @classmethod
- def setUpClass(cls):
- super(ExtensionsTestJSON, cls).setUpClass()
- cls.client = cls.extensions_client
-
-
-class ExtensionsTestXML(base.BaseComputeTestXML, ExtensionsTestBase):
-
- @classmethod
- def setUpClass(cls):
- super(ExtensionsTestXML, cls).setUpClass()
- cls.client = cls.extensions_client
+class ExtensionsTestXML(ExtensionsTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/test_live_block_migration.py b/tempest/tests/compute/test_live_block_migration.py
index 6449ddc..dcd6a78 100644
--- a/tempest/tests/compute/test_live_block_migration.py
+++ b/tempest/tests/compute/test_live_block_migration.py
@@ -22,14 +22,13 @@
from tempest import config
from tempest import exceptions
-from tempest.services.compute.json.hosts_client import HostsClientJSON
-from tempest.services.compute.json.servers_client import ServersClientJSON
from tempest.test import attr
from tempest.tests.compute import base
@attr(category='live-migration')
-class LiveBlockMigrationTest(base.BaseComputeTest):
+class LiveBlockMigrationTest(base.BaseComputeAdminTest):
+ _interface = 'json'
live_migration_available = (
config.TempestConfig().compute.live_migration_available)
@@ -41,12 +40,8 @@
def setUpClass(cls):
super(LiveBlockMigrationTest, cls).setUpClass()
- tenant_name = cls.config.compute_admin.tenant_name
- cls.admin_hosts_client = HostsClientJSON(
- *cls._get_client_args(), tenant_name=tenant_name)
-
- cls.admin_servers_client = ServersClientJSON(
- *cls._get_client_args(), tenant_name=tenant_name)
+ cls.admin_hosts_client = cls.os_adm.hosts_client
+ cls.admin_servers_client = cls.os_adm.servers_client
cls.created_server_ids = []
@@ -101,7 +96,7 @@
@attr(type='positive')
@testtools.skipIf(not live_migration_available,
'Block Live migration not available')
- def test_001_live_block_migration(self):
+ def test_live_block_migration(self):
# Live block migrate an instance to another host
if len(self._get_compute_hostnames()) < 2:
raise self.skipTest(
@@ -113,11 +108,10 @@
self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
self.assertEquals(target_host, self._get_host_for_server(server_id))
- @attr(type='positive', bug='lp1051881')
@testtools.skip('Until bug 1051881 is dealt with.')
@testtools.skipIf(not live_migration_available,
'Block Live migration not available')
- def test_002_invalid_host_for_migration(self):
+ def test_invalid_host_for_migration(self):
# Migrating to an invalid host should not change the status
server_id = self._get_an_active_server()
diff --git a/tempest/tests/compute/test_quotas.py b/tempest/tests/compute/test_quotas.py
index c2ad358..dbff275 100644
--- a/tempest/tests/compute/test_quotas.py
+++ b/tempest/tests/compute/test_quotas.py
@@ -19,10 +19,12 @@
from tempest.tests.compute import base
-class QuotasTestBase(object):
+class QuotasTestJSON(base.BaseComputeTest):
+ _interface = 'json'
@classmethod
def setUpClass(cls):
+ super(QuotasTestJSON, cls).setUpClass()
cls.client = cls.quotas_client
cls.admin_client = cls._get_identity_admin_client()
resp, tenants = cls.admin_client.list_tenants()
@@ -47,17 +49,5 @@
self.fail("Quota set for tenant did not have default limits")
-class QuotasTestJSON(QuotasTestBase, base.BaseComputeTestJSON):
-
- @classmethod
- def setUpClass(cls):
- base.BaseComputeTestJSON.setUpClass()
- super(QuotasTestJSON, cls).setUpClass()
-
-
-class QuotasTestXML(QuotasTestBase, base.BaseComputeTestXML):
-
- @classmethod
- def setUpClass(cls):
- base.BaseComputeTestXML.setUpClass()
- super(QuotasTestXML, cls).setUpClass()
+class QuotasTestXML(QuotasTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/volumes/test_attach_volume.py b/tempest/tests/compute/volumes/test_attach_volume.py
index 1aed833..2679312 100644
--- a/tempest/tests/compute/volumes/test_attach_volume.py
+++ b/tempest/tests/compute/volumes/test_attach_volume.py
@@ -24,12 +24,13 @@
from tempest.tests.compute import base
-class AttachVolumeTest(object):
-
+class AttachVolumeTestJSON(base.BaseComputeTest):
+ _interface = 'json'
run_ssh = tempest.config.TempestConfig().compute.run_ssh
- @staticmethod
+ @classmethod
def setUpClass(cls):
+ super(AttachVolumeTestJSON, cls).setUpClass()
cls.device = 'vdb'
def _detach(self, server_id, volume_id):
@@ -106,17 +107,5 @@
self._delete(server['id'], volume['id'])
-class TestAttachVolumeJSON(base.BaseComputeTestJSON,
- AttachVolumeTest):
- @classmethod
- def setUpClass(cls):
- super(TestAttachVolumeJSON, cls).setUpClass()
- AttachVolumeTest.setUpClass(cls)
-
-
-class TestAttachVolumeXML(base.BaseComputeTestXML,
- AttachVolumeTest):
- @classmethod
- def setUpClass(cls):
- super(TestAttachVolumeXML, cls).setUpClass()
- AttachVolumeTest.setUpClass(cls)
+class AttachVolumeTestXML(AttachVolumeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/volumes/test_volumes_get.py b/tempest/tests/compute/volumes/test_volumes_get.py
index edbfc32..65d2d45 100644
--- a/tempest/tests/compute/volumes/test_volumes_get.py
+++ b/tempest/tests/compute/volumes/test_volumes_get.py
@@ -20,7 +20,14 @@
from tempest.tests.compute import base
-class VolumesGetTestBase(object):
+class VolumesGetTestJSON(base.BaseComputeTest):
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(VolumesGetTestJSON, cls).setUpClass()
+ cls.client = cls.volumes_extensions_client
@attr(type='smoke')
def test_volume_create_get_delete(self):
@@ -94,17 +101,5 @@
self.client.wait_for_resource_deletion(volume['id'])
-class VolumesGetTestXML(base.BaseComputeTestXML, VolumesGetTestBase):
- @classmethod
- def setUpClass(cls):
- cls._interface = "xml"
- super(VolumesGetTestXML, cls).setUpClass()
- cls.client = cls.volumes_extensions_client
-
-
-class VolumesGetTestJSON(base.BaseComputeTestJSON, VolumesGetTestBase):
- @classmethod
- def setUpClass(cls):
- cls._interface = "json"
- super(VolumesGetTestJSON, cls).setUpClass()
- cls.client = cls.volumes_extensions_client
+class VolumesGetTestXML(VolumesGetTestJSON):
+ _interface = "xml"
diff --git a/tempest/tests/compute/volumes/test_volumes_list.py b/tempest/tests/compute/volumes/test_volumes_list.py
index cc690a5..ffd6a8c 100644
--- a/tempest/tests/compute/volumes/test_volumes_list.py
+++ b/tempest/tests/compute/volumes/test_volumes_list.py
@@ -20,7 +20,7 @@
from tempest.tests.compute import base
-class VolumesTestBase(object):
+class VolumesTestJSON(base.BaseComputeTest):
"""
This test creates a number of 1G volumes. To run successfully,
@@ -30,87 +30,10 @@
VOLUME_BACKING_FILE_SIZE is atleast 4G in your localrc
"""
- def test_volume_list(self):
- # Should return the list of Volumes
- # Fetch all Volumes
- resp, fetched_list = self.client.list_volumes()
- self.assertEqual(200, resp.status)
- # Now check if all the Volumes created in setup are in fetched list
- missing_volumes = [
- v for v in self.volume_list if v not in fetched_list
- ]
+ _interface = 'json'
- self.assertFalse(missing_volumes,
- "Failed to find volume %s in fetched list" %
- ', '.join(m_vol['displayName']
- for m_vol in missing_volumes))
-
- def test_volume_list_with_details(self):
- # Should return the list of Volumes with details
- #Fetch all Volumes
- resp, fetched_list = self.client.list_volumes_with_detail()
- self.assertEqual(200, resp.status)
- #Now check if all the Volumes created in setup are in fetched list
- missing_volumes = [
- v for v in self.volume_list if v not in fetched_list
- ]
-
- self.assertFalse(missing_volumes,
- "Failed to find volume %s in fetched list" %
- ', '.join(m_vol['displayName']
- for m_vol in missing_volumes))
-
-
-class VolumesTestXML(base.BaseComputeTestXML, VolumesTestBase):
@classmethod
def setUpClass(cls):
- cls._interface = 'xml'
- super(VolumesTestXML, cls).setUpClass()
- cls.client = cls.volumes_extensions_client
- # Create 3 Volumes
- cls.volume_list = list()
- cls.volume_id_list = list()
- for i in range(3):
- v_name = rand_name('volume')
- metadata = {'Type': 'work'}
- v_name += cls._interface
- try:
- resp, volume = cls.client.create_volume(size=1,
- display_name=v_name,
- metadata=metadata)
- cls.client.wait_for_volume_status(volume['id'], 'available')
- resp, volume = cls.client.get_volume(volume['id'])
- cls.volume_list.append(volume)
- cls.volume_id_list.append(volume['id'])
- except Exception:
- if cls.volume_list:
- # We could not create all the volumes, though we were able
- # to create *some* of the volumes. This is typically
- # because the backing file size of the volume group is
- # too small. So, here, we clean up whatever we did manage
- # to create and raise a SkipTest
- for volume in cls.volume_list:
- cls.client.delete_volume(volume)
- msg = ("Failed to create ALL necessary volumes to run "
- "test. This typically means that the backing file "
- "size of the nova-volumes group is too small to "
- "create the 3 volumes needed by this test case")
- raise cls.skipException(msg)
- raise
-
- @classmethod
- def tearDownClass(cls):
- # Delete the created Volumes
- for volume in cls.volume_list:
- resp, _ = cls.client.delete_volume(volume['id'])
- cls.client.wait_for_resource_deletion(volume['id'])
- super(VolumesTestXML, cls).tearDownClass()
-
-
-class VolumesTestJSON(base.BaseComputeTestJSON, VolumesTestBase):
- @classmethod
- def setUpClass(cls):
- cls._interface = 'json'
super(VolumesTestJSON, cls).setUpClass()
cls.client = cls.volumes_extensions_client
# Create 3 Volumes
@@ -151,3 +74,37 @@
resp, _ = cls.client.delete_volume(volume['id'])
cls.client.wait_for_resource_deletion(volume['id'])
super(VolumesTestJSON, cls).tearDownClass()
+
+ def test_volume_list(self):
+ # Should return the list of Volumes
+ # Fetch all Volumes
+ resp, fetched_list = self.client.list_volumes()
+ self.assertEqual(200, resp.status)
+ # Now check if all the Volumes created in setup are in fetched list
+ missing_volumes = [
+ v for v in self.volume_list if v not in fetched_list
+ ]
+
+ self.assertFalse(missing_volumes,
+ "Failed to find volume %s in fetched list" %
+ ', '.join(m_vol['displayName']
+ for m_vol in missing_volumes))
+
+ def test_volume_list_with_details(self):
+ # Should return the list of Volumes with details
+ #Fetch all Volumes
+ resp, fetched_list = self.client.list_volumes_with_detail()
+ self.assertEqual(200, resp.status)
+ #Now check if all the Volumes created in setup are in fetched list
+ missing_volumes = [
+ v for v in self.volume_list if v not in fetched_list
+ ]
+
+ self.assertFalse(missing_volumes,
+ "Failed to find volume %s in fetched list" %
+ ', '.join(m_vol['displayName']
+ for m_vol in missing_volumes))
+
+
+class VolumesTestXML(VolumesTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/compute/volumes/test_volumes_negative.py b/tempest/tests/compute/volumes/test_volumes_negative.py
index b24c240..306b93b 100644
--- a/tempest/tests/compute/volumes/test_volumes_negative.py
+++ b/tempest/tests/compute/volumes/test_volumes_negative.py
@@ -20,7 +20,13 @@
from tempest.tests.compute import base
-class VolumesNegativeTestBase(object):
+class VolumesNegativeTest(base.BaseComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(VolumesNegativeTest, cls).setUpClass()
+ cls.client = cls.volumes_extensions_client
def test_volume_get_nonexistant_volume_id(self):
# Negative: Should not be able to get details of nonexistant volume
@@ -33,18 +39,13 @@
non_exist_id = rand_name('999')
if non_exist_id not in volume_id_list:
break
- #Trying to GET a non existant volume
- try:
- resp, body = self.client.get_volume(non_exist_id)
- except exceptions.NotFound:
- pass
- else:
- self.fail('Should not be able to GET the details from a '
- 'nonexistant volume')
+ # Trying to GET a non existant volume
+ self.assertRaises(exceptions.NotFound, self.client.get_volume,
+ non_exist_id)
def test_volume_delete_nonexistant_volume_id(self):
# Negative: Should not be able to delete nonexistant Volume
- #Creating nonexistant volume id
+ # Creating nonexistant volume id
volume_id_list = list()
resp, body = self.client.list_volumes()
for i in range(len(body)):
@@ -53,13 +54,9 @@
non_exist_id = rand_name('999')
if non_exist_id not in volume_id_list:
break
- #Trying to DELETE a non existant volume
- try:
- resp, body = self.client.delete_volume(non_exist_id)
- except exceptions.NotFound:
- pass
- else:
- self.fail('Should not be able to DELETE a nonexistant volume')
+ # Trying to DELETE a non existant volume
+ self.assertRaises(exceptions.NotFound, self.client.delete_volume,
+ non_exist_id)
def test_create_volume_with_invalid_size(self):
# Negative: Should not be able to create volume with invalid size
@@ -104,19 +101,5 @@
self.assertRaises(exceptions.NotFound, self.client.delete_volume, '')
-class VolumesNegativeTestXML(base.BaseComputeTestXML,
- VolumesNegativeTestBase):
- @classmethod
- def setUpClass(cls):
- cls._interface = "xml"
- super(VolumesNegativeTestXML, cls).setUpClass()
- cls.client = cls.volumes_extensions_client
-
-
-class VolumesNegativeTestJSON(base.BaseComputeTestJSON,
- VolumesNegativeTestBase):
- @classmethod
- def setUpClass(cls):
- cls._interface = "json"
- super(VolumesNegativeTestJSON, cls).setUpClass()
- cls.client = cls.volumes_extensions_client
+class VolumesNegativeTestXML(VolumesNegativeTest):
+ _interface = "xml"
diff --git a/tempest/tests/identity/admin/test_roles.py b/tempest/tests/identity/admin/test_roles.py
index 46db4fb..f71bed0 100644
--- a/tempest/tests/identity/admin/test_roles.py
+++ b/tempest/tests/identity/admin/test_roles.py
@@ -20,11 +20,12 @@
from tempest.tests.identity import base
-class RolesTestBase(object):
+class RolesTestJSON(base.BaseIdentityAdminTest):
+ _interface = 'json'
- @staticmethod
+ @classmethod
def setUpClass(cls):
-
+ super(RolesTestJSON, cls).setUpClass()
for _ in xrange(5):
resp, role = cls.client.create_role(rand_name('role-'))
cls.data.roles.append(role)
@@ -37,6 +38,13 @@
role = self.get_role_by_name(self.data.test_role)
return (user, tenant, role)
+ def assert_role_in_role_list(self, role, roles):
+ found = False
+ for user_role in roles:
+ if user_role['id'] == role['id']:
+ found = True
+ self.assertTrue(found, "assigned role was not in list")
+
def test_list_roles(self):
# Return a list of all roles
resp, body = self.client.list_roles()
@@ -87,43 +95,9 @@
role1_id = body.get('id')
self.assertTrue('status' in resp)
self.assertTrue(resp['status'].startswith('2'))
-
- try:
- resp, body = self.client.create_role(role_name)
- # this should raise an exception
- self.fail('Should not be able to create a duplicate role name.'
- ' %s' % role_name)
- except exceptions.Duplicate:
- pass
- self.client.delete_role(role1_id)
-
-
-class RolesTestJSON(base.BaseIdentityAdminTestJSON,
- RolesTestBase):
-
- @classmethod
- def setUpClass(cls):
- super(RolesTestJSON, cls).setUpClass()
- RolesTestBase.setUpClass(cls)
-
-
-class RolesTestXML(base.BaseIdentityAdminTestXML,
- RolesTestBase):
-
- @classmethod
- def setUpClass(cls):
- super(RolesTestXML, cls).setUpClass()
- RolesTestBase.setUpClass(cls)
-
-
-class UserRolesTestBase(RolesTestBase):
-
- def assert_role_in_role_list(self, role, roles):
- found = False
- for user_role in roles:
- if user_role['id'] == role['id']:
- found = True
- self.assertTrue(found, "assigned role was not in list")
+ self.addCleanup(self.client.delete_role, role1_id)
+ self.assertRaises(exceptions.Duplicate, self.client.create_role,
+ role_name)
def test_assign_user_role(self):
# Assign a role to a user on a tenant
@@ -267,17 +241,5 @@
tenant['id'], 'junk-role-aabbcc11')
-class UserRolesTestJSON(RolesTestJSON,
- UserRolesTestBase):
-
- @classmethod
- def setUpClass(cls):
- super(UserRolesTestJSON, cls).setUpClass()
-
-
-class UserRolesTestXML(RolesTestXML,
- UserRolesTestBase):
-
- @classmethod
- def setUpClass(cls):
- super(UserRolesTestXML, cls).setUpClass()
+class RolesTestXML(RolesTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/identity/admin/test_services.py b/tempest/tests/identity/admin/test_services.py
index 9ac102a..caf57bd 100644
--- a/tempest/tests/identity/admin/test_services.py
+++ b/tempest/tests/identity/admin/test_services.py
@@ -21,7 +21,8 @@
from tempest.tests.identity import base
-class ServicesTestBase(object):
+class ServicesTestJSON(base.BaseIdentityAdminTest):
+ _interface = 'json'
def test_create_get_delete_service(self):
# GET Service
@@ -56,12 +57,13 @@
self.assertEqual(fetched_service['description'],
service_data['description'])
finally:
- #Deleting the service created in this method
- resp, _ = self.client.delete_service(service_data['id'])
- self.assertTrue(resp['status'].startswith('2'))
- #Checking whether service is deleted successfully
- self.assertRaises(exceptions.NotFound, self.client.get_service,
- service_data['id'])
+ if 'service_data' in locals():
+ # Deleting the service created in this method
+ resp, _ = self.client.delete_service(service_data['id'])
+ self.assertEqual(resp['status'], '204')
+ # Checking whether service is deleted successfully
+ self.assertRaises(exceptions.NotFound, self.client.get_service,
+ service_data['id'])
def test_list_services(self):
# Create, List, Verify and Delete Services
@@ -90,14 +92,5 @@
self.assertFalse(any(found), 'Services failed to delete')
-class ServicesTestJSON(base.BaseIdentityAdminTestJSON, ServicesTestBase):
- @classmethod
- def setUpClass(cls):
- super(ServicesTestJSON, cls).setUpClass()
-
-
-class ServicesTestXML(base.BaseIdentityAdminTestXML,
- ServicesTestBase):
- @classmethod
- def setUpClass(cls):
- super(ServicesTestXML, cls).setUpClass()
+class ServicesTestXML(ServicesTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/identity/admin/test_tenants.py b/tempest/tests/identity/admin/test_tenants.py
index 594afe8..8155eb5 100644
--- a/tempest/tests/identity/admin/test_tenants.py
+++ b/tempest/tests/identity/admin/test_tenants.py
@@ -21,7 +21,8 @@
from tempest.tests.identity import base
-class TenantsTestBase(object):
+class TenantsTestJSON(base.BaseIdentityAdminTest):
+ _interface = 'json'
def test_list_tenants_by_unauthorized_user(self):
# Non-admin user should not be able to list tenants
@@ -150,14 +151,10 @@
self.data.tenants.append(tenant)
tenant1_id = body.get('id')
- try:
- resp, body = self.client.create_tenant(tenant_name)
- # this should have raised an exception
- self.fail('Should not be able to create a duplicate tenant name')
- except exceptions.Duplicate:
- pass
- self.client.delete_tenant(tenant1_id)
- self.data.tenants.remove(tenant)
+ self.addCleanup(self.client.delete_tenant, tenant1_id)
+ self.addCleanup(self.data.tenants.remove, tenant)
+ self.assertRaises(exceptions.Duplicate, self.client.create_tenant,
+ tenant_name)
@attr(type='negative')
def test_create_tenant_by_unauthorized_user(self):
@@ -229,7 +226,7 @@
t_desc2 = rand_name('desc2-')
resp, body = self.client.update_tenant(t_id, description=t_desc2)
st2 = resp['status']
- resp2_desc = body['extra']['description']
+ resp2_desc = body['description']
self.assertTrue(st2.startswith('2'))
self.assertNotEqual(resp1_desc, resp2_desc)
@@ -257,7 +254,7 @@
t_en2 = True
resp, body = self.client.update_tenant(t_id, enabled=t_en2)
st2 = resp['status']
- resp2_en = body['extra']['enabled']
+ resp2_en = body['enabled']
self.assertTrue(st2.startswith('2'))
self.assertNotEqual(resp1_en, resp2_en)
@@ -272,16 +269,5 @@
self.data.tenants.remove(tenant)
-class TenantsTestJSON(base.BaseIdentityAdminTestJSON,
- TenantsTestBase):
-
- @classmethod
- def setUpClass(cls):
- super(TenantsTestJSON, cls).setUpClass()
-
-
-class TenantsTestXML(base.BaseIdentityAdminTestXML, TenantsTestBase):
-
- @classmethod
- def setUpClass(cls):
- super(TenantsTestXML, cls).setUpClass()
+class TenantsTestXML(TenantsTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/identity/admin/test_users.py b/tempest/tests/identity/admin/test_users.py
index 8396b91..224272e 100644
--- a/tempest/tests/identity/admin/test_users.py
+++ b/tempest/tests/identity/admin/test_users.py
@@ -23,7 +23,8 @@
from testtools.matchers._basic import Contains
-class UsersTestBase(object):
+class UsersTestJSON(base.BaseIdentityAdminTest):
+ _interface = 'json'
alt_user = rand_name('test_user_')
alt_password = rand_name('pass_')
@@ -130,6 +131,7 @@
resp, user = self.client.create_user('user_1234', self.alt_password,
self.data.tenant['id'],
self.alt_email)
+ self.assertEquals('200', resp['status'])
resp, body = self.client.delete_user(user['id'])
self.assertEquals('204', resp['status'])
@@ -255,16 +257,18 @@
resp, user1 = self.client.create_user('tenant_user1', 'password1',
self.data.tenant['id'],
'user1@123')
+ self.assertEquals('200', resp['status'])
user_ids.append(user1['id'])
self.data.users.append(user1)
resp, user2 = self.client.create_user('tenant_user2', 'password2',
self.data.tenant['id'],
'user2@123')
+ self.assertEquals('200', resp['status'])
user_ids.append(user2['id'])
self.data.users.append(user2)
#List of users for the respective tenant ID
resp, body = self.client.list_users_for_tenant(self.data.tenant['id'])
- self.assertTrue(resp['status'].startswith('2'))
+ self.assertTrue(resp['status'] in ('200', '203'))
for i in body:
fetched_user_ids.append(i['id'])
#verifying the user Id in the list
@@ -286,17 +290,22 @@
user_ids = list()
fetched_user_ids = list()
user_ids.append(user['id'])
- self.client.assign_user_role(tenant['id'], user['id'], role['id'])
+ resp, role = self.client.assign_user_role(tenant['id'], user['id'],
+ role['id'])
+ self.assertEquals('200', resp['status'])
resp, second_user = self.client.create_user('second_user', 'password1',
self.data.tenant['id'],
'user1@123')
+ self.assertEquals('200', resp['status'])
user_ids.append(second_user['id'])
self.data.users.append(second_user)
- self.client.assign_user_role(tenant['id'], second_user['id'],
- role['id'])
+ resp, role = self.client.assign_user_role(tenant['id'],
+ second_user['id'],
+ role['id'])
+ self.assertEquals('200', resp['status'])
#List of users with roles for the respective tenant ID
resp, body = self.client.list_users_for_tenant(self.data.tenant['id'])
- self.assertTrue(resp['status'].startswith('2'))
+ self.assertEquals('200', resp['status'])
for i in body:
fetched_user_ids.append(i['id'])
#verifying the user Id in the list
@@ -330,14 +339,5 @@
'tenant ids %s' % fail)
-class UsersTestJSON(base.BaseIdentityAdminTestJSON,
- UsersTestBase):
- @classmethod
- def setUpClass(cls):
- super(UsersTestJSON, cls).setUpClass()
-
-
-class UsersTestXML(base.BaseIdentityAdminTestXML, UsersTestBase):
- @classmethod
- def setUpClass(cls):
- super(UsersTestXML, cls).setUpClass()
+class UsersTestXML(UsersTestJSON):
+ _interface = 'xml'
diff --git a/tempest/tests/identity/base.py b/tempest/tests/identity/base.py
index fbff88f..168b2ff 100644
--- a/tempest/tests/identity/base.py
+++ b/tempest/tests/identity/base.py
@@ -15,14 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
from tempest import clients
from tempest.common.utils.data_utils import rand_name
+import tempest.test
-class BaseIdAdminTest(testtools.testcase.WithAttributes,
- testtools.TestCase):
+class BaseIdentityAdminTest(tempest.test.BaseTestCase):
@classmethod
def setUpClass(cls):
@@ -69,22 +68,6 @@
return role[0]
-class BaseIdentityAdminTestJSON(BaseIdAdminTest):
- @classmethod
- def setUpClass(cls):
- cls._interface = "json"
- super(BaseIdentityAdminTestJSON, cls).setUpClass()
-
-BaseIdentityAdminTest = BaseIdentityAdminTestJSON
-
-
-class BaseIdentityAdminTestXML(BaseIdAdminTest):
- @classmethod
- def setUpClass(cls):
- cls._interface = "xml"
- super(BaseIdentityAdminTestXML, cls).setUpClass()
-
-
class DataGenerator(object):
def __init__(self, client):
diff --git a/tempest/tests/image/test_images.py b/tempest/tests/image/test_images.py
index 511f8b0..84bb650 100644
--- a/tempest/tests/image/test_images.py
+++ b/tempest/tests/image/test_images.py
@@ -16,19 +16,14 @@
# under the License.
import cStringIO as StringIO
-import random
-
-import testtools
-
-from tempest.test import attr
-
from tempest import clients
from tempest import exceptions
+import tempest.test
+from tempest.test import attr
-class CreateRegisterImagesTest(testtools.testcase.WithAttributes,
- testtools.TestCase):
+class CreateRegisterImagesTest(tempest.test.BaseTestCase):
"""
Here we test the registration and creation of images
@@ -48,21 +43,13 @@
@attr(type='negative')
def test_register_with_invalid_container_format(self):
# Negative tests for invalid data supplied to POST /images
- try:
- resp, body = self.client.create_image('test', 'wrong', 'vhd')
- except exceptions.BadRequest:
- pass
- else:
- self.fail('Invalid container format should not be accepted')
+ self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ 'test', 'wrong', 'vhd')
@attr(type='negative')
def test_register_with_invalid_disk_format(self):
- try:
- resp, body = self.client.create_image('test', 'bare', 'wrong')
- except exceptions.BadRequest:
- pass
- else:
- self.fail("Invalid disk format should not be accepted")
+ self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ 'test', 'bare', 'wrong')
@attr(type='image')
def test_register_then_upload(self):
@@ -108,8 +95,7 @@
self.assertEqual('active', body.get('status'))
-class ListImagesTest(testtools.testcase.WithAttributes,
- testtools.TestCase):
+class ListImagesTest(tempest.test.BaseTestCase):
"""
Here we test the listing of image information
@@ -123,12 +109,27 @@
# We add a few images here to test the listing functionality of
# the images API
- for x in xrange(0, 10):
- # We make even images remote and odd images standard
- if x % 2 == 0:
- cls.created_images.append(cls._create_remote_image(x))
- else:
- cls.created_images.append(cls._create_standard_image(x))
+ img1 = cls._create_remote_image('one', 'bare', 'raw')
+ img2 = cls._create_remote_image('two', 'ami', 'ami')
+ img3 = cls._create_remote_image('dup', 'bare', 'raw')
+ img4 = cls._create_remote_image('dup', 'bare', 'raw')
+ img5 = cls._create_standard_image('1', 'ami', 'ami', 42)
+ img6 = cls._create_standard_image('2', 'ami', 'ami', 142)
+ img7 = cls._create_standard_image('33', 'bare', 'raw', 142)
+ img8 = cls._create_standard_image('33', 'bare', 'raw', 142)
+ cls.created_set = set(cls.created_images)
+ # 4x-4x remote image
+ cls.remote_set = set((img1, img2, img3, img4))
+ cls.standard_set = set((img5, img6, img7, img8))
+ # 5x bare, 3x ami
+ cls.bare_set = set((img1, img3, img4, img7, img8))
+ cls.ami_set = set((img2, img5, img6))
+ # 1x with size 42
+ cls.size42_set = set((img5,))
+ # 3x with size 142
+ cls.size142_set = set((img6, img7, img8))
+ # dup named
+ cls.dup_set = set((img3, img4))
@classmethod
def tearDownClass(cls):
@@ -137,31 +138,36 @@
cls.client.wait_for_resource_deletion(image_id)
@classmethod
- def _create_remote_image(cls, x):
+ def _create_remote_image(cls, name, container_format, disk_format):
"""
Create a new remote image and return the ID of the newly-registered
image
"""
- name = 'New Remote Image %s' % x
- location = 'http://example.com/someimage_%s.iso' % x
- resp, body = cls.client.create_image(name, 'bare', 'raw',
- is_public=True,
- location=location)
- image_id = body['id']
+ name = 'New Remote Image %s' % name
+ location = 'http://example.com/someimage_%s.iso' % name
+ resp, image = cls.client.create_image(name,
+ container_format, disk_format,
+ is_public=True,
+ location=location)
+ image_id = image['id']
+ cls.created_images.append(image_id)
return image_id
@classmethod
- def _create_standard_image(cls, x):
+ def _create_standard_image(cls, name, container_format,
+ disk_format, size):
"""
Create a new standard image and return the ID of the newly-registered
image. Note that the size of the new image is a random number between
1024 and 4096
"""
- image_file = StringIO.StringIO('*' * random.randint(1024, 4096))
- name = 'New Standard Image %s' % x
- resp, body = cls.client.create_image(name, 'bare', 'raw',
- is_public=True, data=image_file)
- image_id = body['id']
+ image_file = StringIO.StringIO('*' * size)
+ name = 'New Standard Image %s' % name
+ resp, image = cls.client.create_image(name,
+ container_format, disk_format,
+ is_public=True, data=image_file)
+ image_id = image['id']
+ cls.created_images.append(image_id)
return image_id
@attr(type='image')
@@ -170,5 +176,69 @@
resp, images_list = self.client.image_list()
self.assertEqual(resp['status'], '200')
image_list = map(lambda x: x['id'], images_list)
- for image in self.created_images:
- self.assertTrue(image in image_list)
+ for image_id in self.created_images:
+ self.assertTrue(image_id in image_list)
+
+ @attr(type='image')
+ def test_index_disk_format(self):
+ resp, images_list = self.client.image_list(disk_format='ami')
+ self.assertEqual(resp['status'], '200')
+ for image in images_list:
+ self.assertEqual(image['disk_format'], 'ami')
+ result_set = set(map(lambda x: x['id'], images_list))
+ self.assertTrue(self.ami_set <= result_set)
+ self.assertFalse(self.created_set - self.ami_set <= result_set)
+
+ @attr(type='image')
+ def test_index_container_format(self):
+ resp, images_list = self.client.image_list(container_format='bare')
+ self.assertEqual(resp['status'], '200')
+ for image in images_list:
+ self.assertEqual(image['container_format'], 'bare')
+ result_set = set(map(lambda x: x['id'], images_list))
+ self.assertTrue(self.bare_set <= result_set)
+ self.assertFalse(self.created_set - self.bare_set <= result_set)
+
+ @attr(type='image')
+ def test_index_max_size(self):
+ resp, images_list = self.client.image_list(size_max=42)
+ self.assertEqual(resp['status'], '200')
+ for image in images_list:
+ self.assertTrue(image['size'] <= 42)
+ result_set = set(map(lambda x: x['id'], images_list))
+ self.assertTrue(self.size42_set <= result_set)
+ self.assertFalse(self.created_set - self.size42_set <= result_set)
+
+ @attr(type='image')
+ def test_index_min_size(self):
+ resp, images_list = self.client.image_list(size_min=142)
+ self.assertEqual(resp['status'], '200')
+ for image in images_list:
+ self.assertTrue(image['size'] >= 142)
+ result_set = set(map(lambda x: x['id'], images_list))
+ self.assertTrue(self.size142_set <= result_set)
+ self.assertFalse(self.size42_set <= result_set)
+
+ @attr(type='image')
+ def test_index_status_active_detail(self):
+ resp, images_list = self.client.image_list_detail(status='active',
+ sort_key='size',
+ sort_dir='desc')
+ self.assertEqual(resp['status'], '200')
+ top_size = images_list[0]['size'] # We have non-zero sized images
+ for image in images_list:
+ size = image['size']
+ self.assertTrue(size <= top_size)
+ top_size = size
+ self.assertEqual(image['status'], 'active')
+
+ @attr(type='image')
+ def test_index_name(self):
+ resp, images_list = self.client.image_list_detail(
+ name='New Remote Image dup')
+ self.assertEqual(resp['status'], '200')
+ result_set = set(map(lambda x: x['id'], images_list))
+ for image in images_list:
+ self.assertEqual(image['name'], 'New Remote Image dup')
+ self.assertTrue(self.dup_set <= result_set)
+ self.assertFalse(self.created_set - self.dup_set <= result_set)
diff --git a/tempest/tests/network/base.py b/tempest/tests/network/base.py
index 8606079..4cc8b29 100644
--- a/tempest/tests/network/base.py
+++ b/tempest/tests/network/base.py
@@ -15,28 +15,25 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
from tempest import clients
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
+import tempest.test
-class BaseNetworkTest(testtools.testcase.WithAttributes,
- testtools.TestCase):
+class BaseNetworkTest(tempest.test.BaseTestCase):
@classmethod
def setUpClass(cls):
os = clients.Manager()
client = os.network_client
- enabled = True
# Validate that there is even an endpoint configured
# for networks, and mark the attr for skipping if not
try:
client.list_networks()
except exceptions.EndpointNotFound:
- enabled = False
skip_msg = "No OpenStack Network API endpoint"
raise cls.skipException(skip_msg)
diff --git a/tempest/tests/object_storage/base.py b/tempest/tests/object_storage/base.py
index 2492d8b..5bfe1a3 100644
--- a/tempest/tests/object_storage/base.py
+++ b/tempest/tests/object_storage/base.py
@@ -15,15 +15,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
from tempest import clients
from tempest import exceptions
+import tempest.test
from tempest.tests.identity.base import DataGenerator
-class BaseObjectTest(testtools.testcase.WithAttributes,
- testtools.TestCase):
+class BaseObjectTest(tempest.test.BaseTestCase):
@classmethod
def setUpClass(cls):
@@ -31,7 +30,6 @@
cls.object_client = cls.os.object_client
cls.container_client = cls.os.container_client
cls.account_client = cls.os.account_client
- cls.config = cls.os.config
cls.custom_object_client = cls.os.custom_object_client
cls.os_admin = clients.AdminManager()
cls.token_client = cls.os_admin.token_client
diff --git a/tempest/tests/volume/base.py b/tempest/tests/volume/base.py
index 4ddd670..00e8668 100644
--- a/tempest/tests/volume/base.py
+++ b/tempest/tests/volume/base.py
@@ -18,24 +18,20 @@
import logging
import time
-import testtools
-
from tempest import clients
from tempest.common.utils.data_utils import rand_name
-from tempest import config
from tempest import exceptions
+import tempest.test
LOG = logging.getLogger(__name__)
-class BaseVolumeTest(testtools.testcase.WithAttributes,
- testtools.TestCase):
+class BaseVolumeTest(tempest.test.BaseTestCase):
"""Base test case class for all Cinder API tests."""
@classmethod
def setUpClass(cls):
- cls.config = config.TempestConfig()
cls.isolated_creds = []
if cls.config.compute.allow_tenant_isolation:
diff --git a/tempest/whitebox.py b/tempest/whitebox.py
index d5fa023..bfcc373 100644
--- a/tempest/whitebox.py
+++ b/tempest/whitebox.py
@@ -89,18 +89,18 @@
# NOTE(jaypipes): Tests often add things in a particular order
# so we destroy resources in the reverse order in which resources
# are added to the test class object
- if not cls.resources:
+ if not cls.os_resources:
return
- thing = cls.resources.pop()
+ thing = cls.os_resources.pop()
while True:
LOG.debug("Deleting %r from shared resources of %s" %
(thing, cls.__name__))
# Resources in novaclient all have a delete() method
# which destroys the resource...
thing.delete()
- if not cls.resources:
+ if not cls.os_resources:
return
- thing = cls.resources.pop()
+ thing = cls.os_resources.pop()
@classmethod
def create_server(cls, image_id=None):
diff --git a/tools/pip-requires b/tools/pip-requires
index 5c45a49..220f1a6 100644
--- a/tools/pip-requires
+++ b/tools/pip-requires
@@ -1,7 +1,7 @@
anyjson
nose
httplib2>=0.7.0
-testtools
+testtools>=0.9.29
lxml
boto>=2.2.1
paramiko
diff --git a/tools/test-requires b/tools/test-requires
index d3c7a1e..4801391 100644
--- a/tools/test-requires
+++ b/tools/test-requires
@@ -2,3 +2,5 @@
pylint==0.19
# Needed for whitebox testing
sqlalchemy
+MySQL-python
+psycopg2