Merge "test_live_block_migration cleanup"
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 a9ada39..bc8e843 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 6958a7d..cdfe2f1 100644
--- a/tempest/tests/compute/servers/test_server_metadata.py
+++ b/tempest/tests/compute/servers/test_server_metadata.py
@@ -28,7 +28,11 @@
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,
@@ -110,6 +114,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,
@@ -143,63 +156,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):
@@ -212,12 +202,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/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):