Merge "add database drivers for whitebox testing"
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/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/tests/compute/base.py b/tempest/tests/compute/base.py
index 2e5b4fe..94fff13 100644
--- a/tempest/tests/compute/base.py
+++ b/tempest/tests/compute/base.py
@@ -173,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
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 ffff1f7..0f63016 100644
--- a/tempest/tests/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/tests/compute/floating_ips/test_floating_ips_actions.py
@@ -176,7 +176,7 @@
self.client.disassociate_floating_ip_from_server(
self.floating_ip,
self.server_id)
- except exceptions.NotFound:
+ except (exceptions.NotFound, exceptions.BadRequest):
pass
else:
self.fail('The floating IP should be associated to the second '
diff --git a/tempest/tests/compute/images/test_images.py b/tempest/tests/compute/images/test_images.py
index d8d38aa..1e90202 100644
--- a/tempest/tests/compute/images/test_images.py
+++ b/tempest/tests/compute/images/test_images.py
@@ -51,12 +51,6 @@
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)
@@ -65,11 +59,7 @@
@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'])
@@ -114,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-')
@@ -124,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)
@@ -137,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-')
diff --git a/tempest/tests/compute/images/test_images_oneserver.py b/tempest/tests/compute/images/test_images_oneserver.py
index 34ea868..6d3f043 100644
--- a/tempest/tests/compute/images/test_images_oneserver.py
+++ b/tempest/tests/compute/images/test_images_oneserver.py
@@ -41,7 +41,7 @@
super(ImagesOneServerTestJSON, cls).setUpClass()
cls.client = cls.images_client
cls.servers_client = cls.servers_client
- cls.server = cls.create_server()
+ resp, cls.server = cls.create_server(wait_until='ACTIVE')
cls.image_ids = []
diff --git a/tempest/tests/compute/images/test_list_image_filters.py b/tempest/tests/compute/images/test_list_image_filters.py
index 56f388d..5038a65 100644
--- a/tempest/tests/compute/images/test_list_image_filters.py
+++ b/tempest/tests/compute/images/test_list_image_filters.py
@@ -30,16 +30,10 @@
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')
@@ -71,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')
diff --git a/tempest/tests/compute/servers/test_disk_config.py b/tempest/tests/compute/servers/test_disk_config.py
index 671abf9..3a1ec20 100644
--- a/tempest/tests/compute/servers/test_disk_config.py
+++ b/tempest/tests/compute/servers/test_disk_config.py
@@ -37,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'])
@@ -67,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'])
@@ -98,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,
@@ -124,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_servers_negative.py b/tempest/tests/compute/servers/test_list_servers_negative.py
index 320f920..01b11e0 100644
--- a/tempest/tests/compute/servers/test_list_servers_negative.py
+++ b/tempest/tests/compute/servers/test_list_servers_negative.py
@@ -78,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 bc8e843..5046ec2 100644
--- a/tempest/tests/compute/servers/test_server_actions.py
+++ b/tempest/tests/compute/servers/test_server_actions.py
@@ -257,13 +257,9 @@
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(ServerActionsTestJSON):
diff --git a/tempest/tests/compute/servers/test_server_metadata.py b/tempest/tests/compute/servers/test_server_metadata.py
index 7896466..4b17fa2 100644
--- a/tempest/tests/compute/servers/test_server_metadata.py
+++ b/tempest/tests/compute/servers/test_server_metadata.py
@@ -83,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
@@ -95,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
@@ -233,3 +229,12 @@
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 816ca76..0bafc2c 100644
--- a/tempest/tests/compute/servers/test_server_personality.py
+++ b/tempest/tests/compute/servers/test_server_personality.py
@@ -35,7 +35,6 @@
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 = \
@@ -45,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:
@@ -58,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 = \
@@ -71,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
diff --git a/tempest/tests/compute/servers/test_servers.py b/tempest/tests/compute/servers/test_servers.py
index a912652..a8d28df 100644
--- a/tempest/tests/compute/servers/test_servers.py
+++ b/tempest/tests/compute/servers/test_servers.py
@@ -35,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'])
@@ -52,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)
@@ -86,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'])
@@ -104,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'],
@@ -129,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'],
@@ -153,10 +136,7 @@
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'])
diff --git a/tempest/tests/compute/servers/test_servers_negative.py b/tempest/tests/compute/servers/test_servers_negative.py
index 80358ec..366b630 100644
--- a/tempest/tests/compute/servers/test_servers_negative.py
+++ b/tempest/tests/compute/servers/test_servers_negative.py
@@ -41,8 +41,8 @@
# Create a server with name parameter empty
self.assertRaises(exceptions.BadRequest,
- self.create_server_with_extras,
- '', self.image_ref, self.flavor_ref)
+ self.create_server,
+ name='')
@attr(type='negative')
def test_personality_file_contents_not_encoded(self):
@@ -53,8 +53,7 @@
'contents': file_contents}]
self.assertRaises(exceptions.BadRequest,
- self.create_server_with_extras,
- 'fail', self.image_ref, self.flavor_ref,
+ self.create_server,
personality=person)
@attr(type='negative')
@@ -62,16 +61,16 @@
# Create a server with an unknown image
self.assertRaises(exceptions.BadRequest,
- self.create_server_with_extras,
- 'fail', -1, self.flavor_ref)
+ self.create_server,
+ image_id=-1)
@attr(type='negative')
def test_create_with_invalid_flavor(self):
# Create a server with an unknown flavor
self.assertRaises(exceptions.BadRequest,
- self.create_server_with_extras,
- 'fail', self.image_ref, -1)
+ self.create_server,
+ flavor=-1,)
@attr(type='negative')
def test_invalid_access_ip_v4_address(self):
@@ -79,8 +78,7 @@
IPv4 = '1.1.1.1.1.1'
self.assertRaises(exceptions.BadRequest,
- self.create_server_with_extras, "fail",
- self.image_ref, self.flavor_ref, accessIPv4=IPv4)
+ self.create_server, accessIPv4=IPv4)
@attr(type='negative')
def test_invalid_ip_v6_address(self):
@@ -89,18 +87,13 @@
IPv6 = 'notvalid'
self.assertRaises(exceptions.BadRequest,
- self.create_server_with_extras, "fail",
- self.image_ref, self.flavor_ref, accessIPv6=IPv6)
+ 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)
self.assertRaises(exceptions.NotFound, self.client.reboot,
@@ -110,11 +103,8 @@
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)
@@ -128,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):
@@ -137,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')
@@ -157,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')
@@ -252,8 +236,7 @@
security_groups = [{'name': 'does_not_exist'}]
self.assertRaises(exceptions.BadRequest,
- self.create_server_with_extras, 'fail',
- self.image_ref, self.flavor_ref,
+ self.create_server,
security_groups=security_groups)
@attr(type='negative')
diff --git a/tempest/tests/compute/test_live_block_migration.py b/tempest/tests/compute/test_live_block_migration.py
index 078026a..dcd6a78 100644
--- a/tempest/tests/compute/test_live_block_migration.py
+++ b/tempest/tests/compute/test_live_block_migration.py
@@ -22,14 +22,12 @@
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 = (
@@ -42,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 = []
@@ -102,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(
@@ -114,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/identity/admin/test_roles.py b/tempest/tests/identity/admin/test_roles.py
index 46db4fb..53c5b0d 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()
@@ -97,34 +105,6 @@
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")
-
def test_assign_user_role(self):
# Assign a role to a user on a tenant
(user, tenant, role) = self._get_role_params()
@@ -267,17 +247,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 77c8e83..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
@@ -91,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 6385cec..a3c9246 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
@@ -272,16 +273,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 67b2517..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_')
@@ -338,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 2c4162c..168b2ff 100644
--- a/tempest/tests/identity/base.py
+++ b/tempest/tests/identity/base.py
@@ -21,7 +21,7 @@
import tempest.test
-class BaseIdAdminTest(tempest.test.BaseTestCase):
+class BaseIdentityAdminTest(tempest.test.BaseTestCase):
@classmethod
def setUpClass(cls):
@@ -68,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):