Merge "create_server cleanup"
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/servers/test_console_output.py b/tempest/tests/compute/servers/test_console_output.py
deleted file mode 100644
index 4ddbc2f..0000000
--- a/tempest/tests/compute/servers/test_console_output.py
+++ /dev/null
@@ -1,96 +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
-
-
-#TODO(afazekas): move these to the server actions test
-@attr(type='smoke')
-class ConsoleOutputTestJSON(base.BaseComputeTest):
- _interface = 'json'
-
- @classmethod
- def setUpClass(cls):
- super(ConsoleOutputTestJSON, cls).setUpClass()
- 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(cls):
- cls.servers_client.delete_server(cls.server_id)
- super(ConsoleOutputTestJSON, cls).tearDownClass()
-
- @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 ConsoleOutputTestXML(ConsoleOutputTestJSON):
- _interface = 'xml'
diff --git a/tempest/tests/compute/servers/test_server_actions.py b/tempest/tests/compute/servers/test_server_actions.py
index 5da8210..5046ec2 100644
--- a/tempest/tests/compute/servers/test_server_actions.py
+++ b/tempest/tests/compute/servers/test_server_actions.py
@@ -35,6 +35,8 @@
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:
@@ -208,18 +210,48 @@
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):
diff --git a/tempest/tests/compute/servers/test_server_metadata.py b/tempest/tests/compute/servers/test_server_metadata.py
index 95d1e8c..4b17fa2 100644
--- a/tempest/tests/compute/servers/test_server_metadata.py
+++ b/tempest/tests/compute/servers/test_server_metadata.py
@@ -229,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/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):