Merge "Separate negative tests for Swift"
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index bb9a68e..21c8506 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -226,7 +226,7 @@
# Timeout in seconds to wait for ping to succeed. (integer
# value)
-#ping_timeout=60
+#ping_timeout=120
# Timeout in seconds to wait for authentication to succeed.
# (integer value)
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index dfcc6a9..d4a32e6 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -15,12 +15,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import config
-from tempest import exceptions
-from tempest.test import attr
-from tempest.test import skip_because
-
-CONF = config.CONF
+from tempest import test
class QuotasAdminTestJSON(base.BaseV2ComputeAdminTest):
@@ -30,11 +25,8 @@
@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
- cls.identity_admin_client = cls._get_identity_admin_client()
- cls.sg_client = cls.security_groups_client
# NOTE(afazekas): these test cases should always create and use a new
# tenant most of them should be skipped if we can't do that
@@ -49,7 +41,7 @@
'instances', 'security_group_rules',
'cores', 'security_groups'))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_get_default_quotas(self):
# Admin can get the default resource quota set for a tenant
expected_quota_set = self.default_quota_set | set(['id'])
@@ -60,7 +52,7 @@
sorted(quota_set.keys()))
self.assertEqual(quota_set['id'], self.demo_tenant_id)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_all_quota_resources_for_tenant(self):
# Admin can update all the resource quota limits for a tenant
resp, default_quota_set = self.client.get_default_quota_set(
@@ -84,7 +76,7 @@
self.assertEqual(new_quota_set, quota_set)
# TODO(afazekas): merge these test cases
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_updated_quotas(self):
# Verify that GET shows the updated quota set
tenant_name = data_utils.rand_name('cpu_quota_tenant_')
@@ -102,119 +94,6 @@
self.assertEqual(200, resp.status)
self.assertEqual(quota_set['ram'], 5120)
- # TODO(afazekas): Add dedicated tenant to the skiped quota tests
- # it can be moved into the setUpClass as well
- @attr(type='gate')
- def test_create_server_when_cpu_quota_is_full(self):
- # Disallow server creation when tenant's vcpu quota is full
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
- default_vcpu_quota = quota_set['cores']
- vcpu_quota = 0 # Set the quota to zero to conserve resources
-
- resp, quota_set = self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- cores=vcpu_quota)
-
- self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
- cores=default_vcpu_quota)
- self.assertRaises(exceptions.OverLimit, self.create_test_server)
-
- @attr(type='gate')
- def test_create_server_when_memory_quota_is_full(self):
- # Disallow server creation when tenant's memory quota is full
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
- default_mem_quota = quota_set['ram']
- mem_quota = 0 # Set the quota to zero to conserve resources
-
- self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- ram=mem_quota)
-
- self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
- ram=default_mem_quota)
- self.assertRaises(exceptions.OverLimit, self.create_test_server)
-
- @attr(type='gate')
- def test_update_quota_normal_user(self):
- self.assertRaises(exceptions.Unauthorized,
- self.client.update_quota_set,
- self.demo_tenant_id,
- ram=0)
-
- @attr(type=['negative', 'gate'])
- def test_create_server_when_instances_quota_is_full(self):
- # Once instances quota limit is reached, disallow server creation
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
- default_instances_quota = quota_set['instances']
- instances_quota = 0 # Set quota to zero to disallow server creation
-
- self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- instances=instances_quota)
- self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
- instances=default_instances_quota)
- self.assertRaises(exceptions.OverLimit, self.create_test_server)
-
- @skip_because(bug="1186354",
- condition=CONF.service_available.neutron)
- @attr(type=['negative', 'gate'])
- def test_security_groups_exceed_limit(self):
- # Negative test: Creation Security Groups over limit should FAIL
-
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
- default_sg_quota = quota_set['security_groups']
- sg_quota = 0 # Set the quota to zero to conserve resources
-
- resp, quota_set =\
- self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- security_groups=sg_quota)
-
- self.addCleanup(self.adm_client.update_quota_set,
- self.demo_tenant_id,
- security_groups=default_sg_quota)
-
- # Check we cannot create anymore
- self.assertRaises(exceptions.OverLimit,
- self.sg_client.create_security_group,
- "sg-overlimit", "sg-desc")
-
- @skip_because(bug="1186354",
- condition=CONF.service_available.neutron)
- @attr(type=['negative', 'gate'])
- def test_security_groups_rules_exceed_limit(self):
- # Negative test: Creation of Security Group Rules should FAIL
- # when we reach limit maxSecurityGroupRules
-
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
- default_sg_rules_quota = quota_set['security_group_rules']
- sg_rules_quota = 0 # Set the quota to zero to conserve resources
-
- resp, quota_set =\
- self.adm_client.update_quota_set(
- self.demo_tenant_id,
- force=True,
- security_group_rules=sg_rules_quota)
-
- self.addCleanup(self.adm_client.update_quota_set,
- self.demo_tenant_id,
- security_group_rules=default_sg_rules_quota)
-
- s_name = data_utils.rand_name('securitygroup-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup =\
- self.sg_client.create_security_group(s_name, s_description)
- self.addCleanup(self.sg_client.delete_security_group,
- securitygroup['id'])
-
- secgroup_id = securitygroup['id']
- ip_protocol = 'tcp'
-
- # Check we cannot create SG rule anymore
- self.assertRaises(exceptions.OverLimit,
- self.sg_client.create_security_group_rule,
- secgroup_id, ip_protocol, 1025, 1025)
-
class QuotasAdminTestXML(QuotasAdminTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py
new file mode 100644
index 0000000..d3696a1
--- /dev/null
+++ b/tempest/api/compute/admin/test_quotas_negative.py
@@ -0,0 +1,155 @@
+# Copyright 2014 NEC Corporation. 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.
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import config
+from tempest import exceptions
+from tempest import test
+
+CONF = config.CONF
+
+
+class QuotasAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
+ _interface = 'json'
+ force_tenant_isolation = True
+
+ @classmethod
+ def setUpClass(cls):
+ super(QuotasAdminNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.os.quotas_client
+ cls.adm_client = cls.os_adm.quotas_client
+ cls.sg_client = cls.security_groups_client
+
+ # NOTE(afazekas): these test cases should always create and use a new
+ # tenant most of them should be skipped if we can't do that
+ cls.demo_tenant_id = cls.isolated_creds.get_primary_user().get(
+ 'tenantId')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_update_quota_normal_user(self):
+ self.assertRaises(exceptions.Unauthorized,
+ self.client.update_quota_set,
+ self.demo_tenant_id,
+ ram=0)
+
+ # TODO(afazekas): Add dedicated tenant to the skiped quota tests
+ # it can be moved into the setUpClass as well
+ @test.attr(type=['negative', 'gate'])
+ def test_create_server_when_cpu_quota_is_full(self):
+ # Disallow server creation when tenant's vcpu quota is full
+ resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ default_vcpu_quota = quota_set['cores']
+ vcpu_quota = 0 # Set the quota to zero to conserve resources
+
+ resp, quota_set = self.adm_client.update_quota_set(self.demo_tenant_id,
+ force=True,
+ cores=vcpu_quota)
+
+ self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
+ cores=default_vcpu_quota)
+ self.assertRaises(exceptions.OverLimit, self.create_test_server)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_server_when_memory_quota_is_full(self):
+ # Disallow server creation when tenant's memory quota is full
+ resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ default_mem_quota = quota_set['ram']
+ mem_quota = 0 # Set the quota to zero to conserve resources
+
+ self.adm_client.update_quota_set(self.demo_tenant_id,
+ force=True,
+ ram=mem_quota)
+
+ self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
+ ram=default_mem_quota)
+ self.assertRaises(exceptions.OverLimit, self.create_test_server)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_server_when_instances_quota_is_full(self):
+ # Once instances quota limit is reached, disallow server creation
+ resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ default_instances_quota = quota_set['instances']
+ instances_quota = 0 # Set quota to zero to disallow server creation
+
+ self.adm_client.update_quota_set(self.demo_tenant_id,
+ force=True,
+ instances=instances_quota)
+ self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
+ instances=default_instances_quota)
+ self.assertRaises(exceptions.OverLimit, self.create_test_server)
+
+ @test.skip_because(bug="1186354",
+ condition=CONF.service_available.neutron)
+ @test.attr(type='gate')
+ def test_security_groups_exceed_limit(self):
+ # Negative test: Creation Security Groups over limit should FAIL
+
+ resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ default_sg_quota = quota_set['security_groups']
+ sg_quota = 0 # Set the quota to zero to conserve resources
+
+ resp, quota_set =\
+ self.adm_client.update_quota_set(self.demo_tenant_id,
+ force=True,
+ security_groups=sg_quota)
+
+ self.addCleanup(self.adm_client.update_quota_set,
+ self.demo_tenant_id,
+ security_groups=default_sg_quota)
+
+ # Check we cannot create anymore
+ self.assertRaises(exceptions.OverLimit,
+ self.sg_client.create_security_group,
+ "sg-overlimit", "sg-desc")
+
+ @test.skip_because(bug="1186354",
+ condition=CONF.service_available.neutron)
+ @test.attr(type=['negative', 'gate'])
+ def test_security_groups_rules_exceed_limit(self):
+ # Negative test: Creation of Security Group Rules should FAIL
+ # when we reach limit maxSecurityGroupRules
+
+ resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ default_sg_rules_quota = quota_set['security_group_rules']
+ sg_rules_quota = 0 # Set the quota to zero to conserve resources
+
+ resp, quota_set =\
+ self.adm_client.update_quota_set(
+ self.demo_tenant_id,
+ force=True,
+ security_group_rules=sg_rules_quota)
+
+ self.addCleanup(self.adm_client.update_quota_set,
+ self.demo_tenant_id,
+ security_group_rules=default_sg_rules_quota)
+
+ s_name = data_utils.rand_name('securitygroup-')
+ s_description = data_utils.rand_name('description-')
+ resp, securitygroup =\
+ self.sg_client.create_security_group(s_name, s_description)
+ self.addCleanup(self.sg_client.delete_security_group,
+ securitygroup['id'])
+
+ secgroup_id = securitygroup['id']
+ ip_protocol = 'tcp'
+
+ # Check we cannot create SG rule anymore
+ self.assertRaises(exceptions.OverLimit,
+ self.sg_client.create_security_group_rule,
+ secgroup_id, ip_protocol, 1025, 1025)
+
+
+class QuotasAdminNegativeTestXML(QuotasAdminNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_servers.py b/tempest/api/compute/admin/test_servers.py
index 10484a9..2cee78a 100644
--- a/tempest/api/compute/admin/test_servers.py
+++ b/tempest/api/compute/admin/test_servers.py
@@ -99,6 +99,18 @@
self.servers_client.wait_for_server_termination(server['id'])
@attr(type='gate')
+ def test_delete_server_while_in_error_state(self):
+ # Delete a server while it's VM state is error
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.reset_state(server['id'], state='error')
+ self.assertEqual(202, resp.status)
+ # Verify server's state
+ resp, server = self.client.get_server(server['id'])
+ self.assertEqual(server['status'], 'ERROR')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+
+ @attr(type='gate')
def test_reset_state_server(self):
# Reset server's state to 'error'
resp, server = self.client.reset_state(self.s1_id)
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 9b9eb9f..5539894 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -33,9 +33,6 @@
@classmethod
def setUpClass(cls):
super(BaseComputeTest, cls).setUpClass()
- if not cls.config.service_available.nova:
- skip_msg = ("%s skipped as nova is not available" % cls.__name__)
- raise cls.skipException(skip_msg)
os = cls.get_client_manager()
diff --git a/tempest/api/compute/floating_ips/base.py b/tempest/api/compute/floating_ips/base.py
index e2c9b04..fd76e62 100644
--- a/tempest/api/compute/floating_ips/base.py
+++ b/tempest/api/compute/floating_ips/base.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2014 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/security_groups/base.py b/tempest/api/compute/security_groups/base.py
index 66f2600..6838ce1 100644
--- a/tempest/api/compute/security_groups/base.py
+++ b/tempest/api/compute/security_groups/base.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 582faf8..49d8495 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -84,7 +84,8 @@
# Log in and verify the boot time has changed
linux_client = RemoteClient(server, self.ssh_user, self.password)
new_boot_time = linux_client.get_boot_time()
- self.assertGreater(new_boot_time, boot_time)
+ self.assertTrue(new_boot_time > boot_time,
+ '%s > %s' % (new_boot_time, boot_time))
@skip_because(bug="1014647")
@attr(type='smoke')
@@ -104,7 +105,8 @@
# Log in and verify the boot time has changed
linux_client = RemoteClient(server, self.ssh_user, self.password)
new_boot_time = linux_client.get_boot_time()
- self.assertGreater(new_boot_time, boot_time)
+ self.assertTrue(new_boot_time > boot_time,
+ '%s > %s' % (new_boot_time, boot_time))
@attr(type='smoke')
def test_rebuild_server(self):
@@ -230,7 +232,7 @@
def test_create_backup(self):
# Positive test:create backup successfully and rotate backups correctly
# create the first and the second backup
- backup1 = data_utils.rand_name('backup')
+ backup1 = data_utils.rand_name('backup-1')
resp, _ = self.servers_client.create_backup(self.server_id,
'daily',
2,
@@ -247,7 +249,7 @@
self.assertEqual(202, resp.status)
self.os.image_client.wait_for_image_status(image1_id, 'active')
- backup2 = data_utils.rand_name('backup')
+ backup2 = data_utils.rand_name('backup-2')
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
resp, _ = self.servers_client.create_backup(self.server_id,
'daily',
@@ -275,7 +277,7 @@
# create the third one, due to the rotation is 2,
# the first one will be deleted
- backup3 = data_utils.rand_name('backup')
+ backup3 = data_utils.rand_name('backup-3')
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
resp, _ = self.servers_client.create_backup(self.server_id,
'daily',
@@ -293,7 +295,11 @@
sort_key='created_at',
sort_dir='asc')
self.assertEqual(200, resp.status)
- self.assertEqual(2, len(image_list))
+ self.assertEqual(2, len(image_list),
+ 'Unexpected number of images for '
+ 'v2:test_create_backup; was the oldest backup not '
+ 'yet deleted? Image list: %s' %
+ [image['name'] for image in image_list])
self.assertEqual((backup2, backup3),
(image_list[0]['name'], image_list[1]['name']))
diff --git a/tempest/api/compute/servers/test_servers.py b/tempest/api/compute/servers/test_servers.py
index 8ae43b5..203832e 100644
--- a/tempest/api/compute/servers/test_servers.py
+++ b/tempest/api/compute/servers/test_servers.py
@@ -104,6 +104,24 @@
self.assertEqual('::babe:202:202', server['accessIPv6'])
@attr(type='gate')
+ def test_delete_server_while_in_shutoff_state(self):
+ # Delete a server while it's VM state is Shutoff
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.stop(server['id'])
+ self.client.wait_for_server_status(server['id'], 'SHUTOFF')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+
+ @attr(type='gate')
+ def test_delete_server_while_in_pause_state(self):
+ # Delete a server while it's VM state is Pause
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.pause_server(server['id'])
+ self.client.wait_for_server_status(server['id'], 'PAUSED')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+
+ @attr(type='gate')
def test_delete_server_while_in_building_state(self):
# Delete a server while it's VM state is Building
resp, server = self.create_test_server(wait_until='BUILD')
diff --git a/tempest/api/compute/v3/admin/test_aggregates.py b/tempest/api/compute/v3/admin/test_aggregates.py
index 7491742..956eddd 100644
--- a/tempest/api/compute/v3/admin/test_aggregates.py
+++ b/tempest/api/compute/v3/admin/test_aggregates.py
@@ -210,10 +210,3 @@
wait_until='ACTIVE')
resp, body = admin_servers_client.get_server(server['id'])
self.assertEqual(self.host, body[self._host_key])
-
-
-class AggregatesAdminV3TestXML(AggregatesAdminV3TestJSON):
- _host_key = (
- '{http://docs.openstack.org/compute/ext/'
- 'extended_server_attributes/api/v3}host')
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_aggregates_negative.py b/tempest/api/compute/v3/admin/test_aggregates_negative.py
index 4eb75a5..da3568a 100644
--- a/tempest/api/compute/v3/admin/test_aggregates_negative.py
+++ b/tempest/api/compute/v3/admin/test_aggregates_negative.py
@@ -188,7 +188,3 @@
self.assertRaises(exceptions.NotFound, self.client.remove_host,
aggregate['id'], non_exist_host)
-
-
-class AggregatesAdminNegativeV3TestXML(AggregatesAdminNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_availability_zone.py b/tempest/api/compute/v3/admin/test_availability_zone.py
index 2955dc8..5ced2b1 100644
--- a/tempest/api/compute/v3/admin/test_availability_zone.py
+++ b/tempest/api/compute/v3/admin/test_availability_zone.py
@@ -53,7 +53,3 @@
self.non_adm_client.get_availability_zone_list()
self.assertEqual(200, resp.status)
self.assertTrue(len(availability_zone) > 0)
-
-
-class AZAdminV3TestXML(AZAdminV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_availability_zone_negative.py b/tempest/api/compute/v3/admin/test_availability_zone_negative.py
index d69e956..60cd1d6 100644
--- a/tempest/api/compute/v3/admin/test_availability_zone_negative.py
+++ b/tempest/api/compute/v3/admin/test_availability_zone_negative.py
@@ -39,7 +39,3 @@
self.assertRaises(
exceptions.Unauthorized,
self.non_adm_client.get_availability_zone_list_detail)
-
-
-class AZAdminNegativeV3TestXML(AZAdminNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_flavors_access.py b/tempest/api/compute/v3/admin/test_flavors_access.py
index 532dc48..d668640 100644
--- a/tempest/api/compute/v3/admin/test_flavors_access.py
+++ b/tempest/api/compute/v3/admin/test_flavors_access.py
@@ -99,7 +99,3 @@
resp, flavors = self.flavors_client.list_flavors_with_detail()
self.assertEqual(resp.status, 200)
self.assertNotIn(new_flavor['id'], map(lambda x: x['id'], flavors))
-
-
-class FlavorsAdminV3TestXML(FlavorsAccessV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_flavors_access_negative.py b/tempest/api/compute/v3/admin/test_flavors_access_negative.py
index e9d811c..8595b2c 100644
--- a/tempest/api/compute/v3/admin/test_flavors_access_negative.py
+++ b/tempest/api/compute/v3/admin/test_flavors_access_negative.py
@@ -140,7 +140,3 @@
self.client.remove_flavor_access,
new_flavor['id'],
str(uuid.uuid4()))
-
-
-class FlavorsAdminNegativeV3TestXML(FlavorsAccessNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_flavors_extra_specs.py b/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
index b084157..0363fcb 100644
--- a/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
@@ -120,7 +120,3 @@
self.assertEqual(resp.status, 200)
self.assertEqual(body['key1'], 'value1')
self.assertNotIn('key2', body)
-
-
-class FlavorsExtraSpecsV3TestXML(FlavorsExtraSpecsV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py b/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
index a81edb1..0f300a1 100644
--- a/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
@@ -124,7 +124,3 @@
"key1",
key1="value",
key2="value")
-
-
-class FlavorsExtraSpecsNegativeV3TestXML(FlavorsExtraSpecsNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_hosts.py b/tempest/api/compute/v3/admin/test_hosts.py
index a110d02..8199ee8 100644
--- a/tempest/api/compute/v3/admin/test_hosts.py
+++ b/tempest/api/compute/v3/admin/test_hosts.py
@@ -86,7 +86,3 @@
self.assertIsNotNone(host_resource['memory_mb'])
self.assertIsNotNone(host_resource['project'])
self.assertEqual(hostname, host_resource['host'])
-
-
-class HostsAdminV3TestXML(HostsAdminV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_hosts_negative.py b/tempest/api/compute/v3/admin/test_hosts_negative.py
index 9841950..aa50618 100644
--- a/tempest/api/compute/v3/admin/test_hosts_negative.py
+++ b/tempest/api/compute/v3/admin/test_hosts_negative.py
@@ -168,7 +168,3 @@
self.assertRaises(exceptions.Unauthorized,
self.non_admin_client.reboot_host,
hostname)
-
-
-class HostsAdminNegativeV3TestXML(HostsAdminNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_hypervisor.py b/tempest/api/compute/v3/admin/test_hypervisor.py
index 84f6b4d..8bd4abb 100644
--- a/tempest/api/compute/v3/admin/test_hypervisor.py
+++ b/tempest/api/compute/v3/admin/test_hypervisor.py
@@ -97,7 +97,3 @@
hypers[0]['hypervisor_hostname'])
self.assertEqual(200, resp.status)
self.assertTrue(len(hypers) > 0)
-
-
-class HypervisorAdminV3TestXML(HypervisorAdminV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_hypervisor_negative.py b/tempest/api/compute/v3/admin/test_hypervisor_negative.py
index 68b0af0..63e8cae 100644
--- a/tempest/api/compute/v3/admin/test_hypervisor_negative.py
+++ b/tempest/api/compute/v3/admin/test_hypervisor_negative.py
@@ -136,7 +136,3 @@
exceptions.Unauthorized,
self.non_adm_client.search_hypervisor,
hypers[0]['hypervisor_hostname'])
-
-
-class HypervisorAdminNegativeV3TestXML(HypervisorAdminNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py b/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py
index fada98c..9651338 100644
--- a/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py
+++ b/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py
@@ -57,7 +57,3 @@
for item in expected_items:
self.assertIn(item, body)
self.assertEqual(body['period_ending'], "2012-12-23 23:00:00")
-
-
-class InstanceUsageAuditLogV3TestXML(InstanceUsageAuditLogV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_instance_usage_audit_log_negative.py b/tempest/api/compute/v3/admin/test_instance_usage_audit_log_negative.py
index 06b3711..8ed1a98 100644
--- a/tempest/api/compute/v3/admin/test_instance_usage_audit_log_negative.py
+++ b/tempest/api/compute/v3/admin/test_instance_usage_audit_log_negative.py
@@ -39,8 +39,3 @@
self.assertRaises(exceptions.BadRequest,
self.adm_client.list_instance_usage_audit_logs,
"invalid_time")
-
-
-class InstanceUsageLogNegativeV3TestXML(
- InstanceUsageLogNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_quotas.py b/tempest/api/compute/v3/admin/test_quotas.py
index ed4561d..e116734 100644
--- a/tempest/api/compute/v3/admin/test_quotas.py
+++ b/tempest/api/compute/v3/admin/test_quotas.py
@@ -147,7 +147,3 @@
self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
instances=default_instances_quota)
self.assertRaises(exceptions.OverLimit, self.create_test_server)
-
-
-class QuotasAdminV3TestXML(QuotasAdminV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_servers.py b/tempest/api/compute/v3/admin/test_servers.py
index dec573e..f6f5673 100644
--- a/tempest/api/compute/v3/admin/test_servers.py
+++ b/tempest/api/compute/v3/admin/test_servers.py
@@ -83,6 +83,18 @@
self.servers_client.wait_for_server_termination(server['id'])
@attr(type='gate')
+ def test_delete_server_while_in_error_state(self):
+ # Delete a server while it's VM state is error
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.reset_state(server['id'], state='error')
+ self.assertEqual(202, resp.status)
+ # Verify server's state
+ resp, server = self.client.get_server(server['id'])
+ self.assertEqual(server['status'], 'ERROR')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+
+ @attr(type='gate')
def test_reset_state_server(self):
# Reset server's state to 'error'
resp, server = self.client.reset_state(self.s1_id)
@@ -155,7 +167,3 @@
resp, server = self.non_admin_client.get_server(rebuilt_server['id'])
rebuilt_image_id = server['image']['id']
self.assertEqual(self.image_ref_alt, rebuilt_image_id)
-
-
-class ServersAdminV3TestXML(ServersAdminV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_servers_negative.py b/tempest/api/compute/v3/admin/test_servers_negative.py
index fb4b043..a86bdfc 100644
--- a/tempest/api/compute/v3/admin/test_servers_negative.py
+++ b/tempest/api/compute/v3/admin/test_servers_negative.py
@@ -135,7 +135,3 @@
self.assertRaises(exceptions.Conflict,
self.client.migrate_server,
server_id)
-
-
-class ServersAdminNegativeV3TestXML(ServersAdminNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_services.py b/tempest/api/compute/v3/admin/test_services.py
index ba32739..9e55e78 100644
--- a/tempest/api/compute/v3/admin/test_services.py
+++ b/tempest/api/compute/v3/admin/test_services.py
@@ -76,7 +76,3 @@
self.assertEqual(1, len(services))
self.assertEqual(host_name, services[0]['host'])
self.assertEqual(binary_name, services[0]['binary'])
-
-
-class ServicesAdminV3TestXML(ServicesAdminV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_services_negative.py b/tempest/api/compute/v3/admin/test_services_negative.py
index 6f583fa..1382347 100644
--- a/tempest/api/compute/v3/admin/test_services_negative.py
+++ b/tempest/api/compute/v3/admin/test_services_negative.py
@@ -64,7 +64,3 @@
resp, services = self.client.list_services(params)
self.assertEqual(200, resp.status)
self.assertEqual(0, len(services))
-
-
-class ServicesAdminNegativeV3TestXML(ServicesAdminNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_simple_tenant_usage.py b/tempest/api/compute/v3/admin/test_simple_tenant_usage.py
index 3a2d2e5..7ee835b 100644
--- a/tempest/api/compute/v3/admin/test_simple_tenant_usage.py
+++ b/tempest/api/compute/v3/admin/test_simple_tenant_usage.py
@@ -83,7 +83,3 @@
self.assertEqual(200, resp.status)
self.assertEqual(len(tenant_usage), 8)
-
-
-class TenantUsagesV3TestXML(TenantUsagesV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_simple_tenant_usage_negative.py b/tempest/api/compute/v3/admin/test_simple_tenant_usage_negative.py
index 58acd07..00068dc 100644
--- a/tempest/api/compute/v3/admin/test_simple_tenant_usage_negative.py
+++ b/tempest/api/compute/v3/admin/test_simple_tenant_usage_negative.py
@@ -71,7 +71,3 @@
'detailed': int(bool(True))}
self.assertRaises(exceptions.Unauthorized,
self.client.list_tenant_usages, params)
-
-
-class TenantUsagesNegativeV3TestXML(TenantUsagesNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/certificates/test_certificates.py b/tempest/api/compute/v3/certificates/test_certificates.py
index 4dfa3be..b24f4d8 100644
--- a/tempest/api/compute/v3/certificates/test_certificates.py
+++ b/tempest/api/compute/v3/certificates/test_certificates.py
@@ -32,7 +32,3 @@
self.assertEqual(200, resp.status)
self.assertIn('data', body)
self.assertIn('private_key', body)
-
-
-class CertificatesV3TestXML(CertificatesV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_image_metadata.py b/tempest/api/compute/v3/images/test_image_metadata.py
index 89a2f75..d0d2daf 100644
--- a/tempest/api/compute/v3/images/test_image_metadata.py
+++ b/tempest/api/compute/v3/images/test_image_metadata.py
@@ -106,7 +106,3 @@
resp, resp_metadata = self.client.list_image_metadata(self.image_id)
expected = {'key2': 'value2'}
self.assertEqual(expected, resp_metadata)
-
-
-class ImagesMetadataTestXML(ImagesMetadataTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_image_metadata_negative.py b/tempest/api/compute/v3/images/test_image_metadata_negative.py
index 4878936..6e7cc8f 100644
--- a/tempest/api/compute/v3/images/test_image_metadata_negative.py
+++ b/tempest/api/compute/v3/images/test_image_metadata_negative.py
@@ -73,7 +73,3 @@
self.assertRaises(exceptions.NotFound,
self.client.delete_image_metadata_item,
data_utils.rand_uuid(), 'key1')
-
-
-class ImagesMetadataTestXML(ImagesMetadataTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_images.py b/tempest/api/compute/v3/images/test_images.py
index ea097ad..52772e0 100644
--- a/tempest/api/compute/v3/images/test_images.py
+++ b/tempest/api/compute/v3/images/test_images.py
@@ -118,7 +118,3 @@
self.assertRaises(exceptions.NotFound,
self.servers_client.create_image,
test_uuid, snapshot_name)
-
-
-class ImagesV3TestXML(ImagesV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_images_oneserver.py b/tempest/api/compute/v3/images/test_images_oneserver.py
index 0cb748b..babf452 100644
--- a/tempest/api/compute/v3/images/test_images_oneserver.py
+++ b/tempest/api/compute/v3/images/test_images_oneserver.py
@@ -130,7 +130,3 @@
image_id = data_utils.parse_image_id(resp['location'])
self.addCleanup(self.client.delete_image, image_id)
self.assertEqual('202', resp['status'])
-
-
-class ImagesOneServerTestXML(ImagesOneServerTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_images_oneserver_negative.py b/tempest/api/compute/v3/images/test_images_oneserver_negative.py
index 3f93fbe..dc628dc 100644
--- a/tempest/api/compute/v3/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/v3/images/test_images_oneserver_negative.py
@@ -154,7 +154,3 @@
self.image_ids.remove(image_id)
self.assertRaises(exceptions.NotFound, self.client.get_image, image_id)
-
-
-class ImagesOneServerNegativeTestXML(ImagesOneServerNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_list_image_filters.py b/tempest/api/compute/v3/images/test_list_image_filters.py
index c04729c..ad93b3d 100644
--- a/tempest/api/compute/v3/images/test_list_image_filters.py
+++ b/tempest/api/compute/v3/images/test_list_image_filters.py
@@ -223,7 +223,3 @@
def test_get_nonexistent_image(self):
# Negative test: GET on non-existent image should fail
self.assertRaises(exceptions.NotFound, self.client.get_image, 999)
-
-
-class ListImageFiltersTestXML(ListImageFiltersTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/keypairs/test_keypairs.py b/tempest/api/compute/v3/keypairs/test_keypairs.py
index 3b449f7..4aef8b1 100644
--- a/tempest/api/compute/v3/keypairs/test_keypairs.py
+++ b/tempest/api/compute/v3/keypairs/test_keypairs.py
@@ -116,7 +116,3 @@
self.assertEqual(key_name, k_name,
"The created keypair name is not equal "
"to the requested name!")
-
-
-class KeyPairsV3TestXML(KeyPairsV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/keypairs/test_keypairs_negative.py b/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
index be7ee65..87f62b7 100644
--- a/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
@@ -93,7 +93,3 @@
k_name = 'key_/.\@:'
self.assertRaises(exceptions.BadRequest, self._create_keypair,
k_name)
-
-
-class KeyPairsNegativeV3TestXML(KeyPairsNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_attach_interfaces.py b/tempest/api/compute/v3/servers/test_attach_interfaces.py
index 8f69c54..aa85424 100644
--- a/tempest/api/compute/v3/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/v3/servers/test_attach_interfaces.py
@@ -119,7 +119,3 @@
_ifs = self._test_delete_interface(server, ifs)
self.assertEqual(len(ifs) - 1, len(_ifs))
-
-
-class AttachInterfacesV3TestXML(AttachInterfacesV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_attach_volume.py b/tempest/api/compute/v3/servers/test_attach_volume.py
index ff95ca4..2529af9 100644
--- a/tempest/api/compute/v3/servers/test_attach_volume.py
+++ b/tempest/api/compute/v3/servers/test_attach_volume.py
@@ -112,7 +112,3 @@
server['admin_password'])
partitions = linux_client.get_partitions()
self.assertNotIn(self.device, partitions)
-
-
-class AttachVolumeV3TestXML(AttachVolumeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_create_server.py b/tempest/api/compute/v3/servers/test_create_server.py
index 7c63865..cb02894 100644
--- a/tempest/api/compute/v3/servers/test_create_server.py
+++ b/tempest/api/compute/v3/servers/test_create_server.py
@@ -222,11 +222,3 @@
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
super(ServersV3TestManualDisk, cls).setUpClass()
-
-
-class ServersV3TestXML(ServersV3TestJSON):
- _interface = 'xml'
-
-
-class ServersWithSpecificFlavorV3TestXML(ServersWithSpecificFlavorV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_instance_actions.py b/tempest/api/compute/v3/servers/test_instance_actions.py
index 0b4b9bf..dd5dd30 100644
--- a/tempest/api/compute/v3/servers/test_instance_actions.py
+++ b/tempest/api/compute/v3/servers/test_instance_actions.py
@@ -61,7 +61,3 @@
# Get the action details of the provided server with invalid request
self.assertRaises(exceptions.NotFound, self.client.get_instance_action,
self.server_id, '999')
-
-
-class InstanceActionsV3TestXML(InstanceActionsV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_list_server_filters.py b/tempest/api/compute/v3/servers/test_list_server_filters.py
index 99cf8e1..15d6fa2 100644
--- a/tempest/api/compute/v3/servers/test_list_server_filters.py
+++ b/tempest/api/compute/v3/servers/test_list_server_filters.py
@@ -250,7 +250,3 @@
params = {'limit': 1}
resp, servers = self.client.list_servers_with_detail(params)
self.assertEqual(1, len(servers['servers']))
-
-
-class ListServerFiltersV3TestXML(ListServerFiltersV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_list_servers_negative.py b/tempest/api/compute/v3/servers/test_list_servers_negative.py
index 7217148..10d36bf 100644
--- a/tempest/api/compute/v3/servers/test_list_servers_negative.py
+++ b/tempest/api/compute/v3/servers/test_list_servers_negative.py
@@ -162,7 +162,3 @@
if srv['id'] in deleted_ids]
self.assertEqual('200', resp['status'])
self.assertEqual([], actual)
-
-
-class ListServersNegativeV3TestXML(ListServersNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_multiple_create.py b/tempest/api/compute/v3/servers/test_multiple_create.py
index c7377a6..429a8ba 100644
--- a/tempest/api/compute/v3/servers/test_multiple_create.py
+++ b/tempest/api/compute/v3/servers/test_multiple_create.py
@@ -87,7 +87,3 @@
return_reservation_id=True)
self.assertEqual(resp['status'], '202')
self.assertIn('reservation_id', body)
-
-
-class MultipleCreateV3TestXML(MultipleCreateV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_server_actions.py b/tempest/api/compute/v3/servers/test_server_actions.py
index eb7bc94..fdf23f8 100644
--- a/tempest/api/compute/v3/servers/test_server_actions.py
+++ b/tempest/api/compute/v3/servers/test_server_actions.py
@@ -225,7 +225,7 @@
def test_create_backup(self):
# Positive test:create backup successfully and rotate backups correctly
# create the first and the second backup
- backup1 = data_utils.rand_name('backup')
+ backup1 = data_utils.rand_name('backup-1')
resp, _ = self.servers_client.create_backup(self.server_id,
'daily',
2,
@@ -242,7 +242,7 @@
self.assertEqual(202, resp.status)
self.images_client.wait_for_image_status(image1_id, 'active')
- backup2 = data_utils.rand_name('backup')
+ backup2 = data_utils.rand_name('backup-2')
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
resp, _ = self.servers_client.create_backup(self.server_id,
'daily',
@@ -270,7 +270,7 @@
# create the third one, due to the rotation is 2,
# the first one will be deleted
- backup3 = data_utils.rand_name('backup')
+ backup3 = data_utils.rand_name('backup-3')
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
resp, _ = self.servers_client.create_backup(self.server_id,
'daily',
@@ -287,7 +287,11 @@
sort_key='created_at',
sort_dir='asc')
self.assertEqual(200, resp.status)
- self.assertEqual(2, len(image_list))
+ self.assertEqual(2, len(image_list),
+ 'Unexpected number of images for '
+ 'v3:test_create_backup; was the oldest backup not '
+ 'yet deleted? Image list: %s' %
+ [image['name'] for image in image_list])
self.assertEqual((backup2, backup3),
(image_list[0]['name'], image_list[1]['name']))
@@ -402,7 +406,3 @@
resp, server = self.servers_client.start(self.server_id)
self.assertEqual(202, resp.status)
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
-
-
-class ServerActionsV3TestXML(ServerActionsV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_server_addresses.py b/tempest/api/compute/v3/servers/test_server_addresses.py
index 6ecd28b..bffa7c4 100644
--- a/tempest/api/compute/v3/servers/test_server_addresses.py
+++ b/tempest/api/compute/v3/servers/test_server_addresses.py
@@ -78,7 +78,3 @@
addr = addr[addr_type]
for address in addresses[addr_type]:
self.assertTrue(any([a for a in addr if a == address]))
-
-
-class ServerAddressesV3TestXML(ServerAddressesV3Test):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_server_metadata.py b/tempest/api/compute/v3/servers/test_server_metadata.py
index 0571f38..1758b0b 100644
--- a/tempest/api/compute/v3/servers/test_server_metadata.py
+++ b/tempest/api/compute/v3/servers/test_server_metadata.py
@@ -209,7 +209,3 @@
self.assertRaises(exceptions.BadRequest,
self.client.set_server_metadata,
self.server_id, meta=meta, no_metadata_field=True)
-
-
-class ServerMetadataV3TestXML(ServerMetadataV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_server_rescue.py b/tempest/api/compute/v3/servers/test_server_rescue.py
index 870432b..99e8f68 100644
--- a/tempest/api/compute/v3/servers/test_server_rescue.py
+++ b/tempest/api/compute/v3/servers/test_server_rescue.py
@@ -167,7 +167,3 @@
self.servers_client.detach_volume,
self.server_id,
self.volume_to_detach['id'])
-
-
-class ServerRescueV3TestXML(ServerRescueV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_servers.py b/tempest/api/compute/v3/servers/test_servers.py
index 40ca0f0..c476b78 100644
--- a/tempest/api/compute/v3/servers/test_servers.py
+++ b/tempest/api/compute/v3/servers/test_servers.py
@@ -105,6 +105,24 @@
server['os-access-ips:access_ip_v6'])
@test.attr(type='gate')
+ def test_delete_server_while_in_shutoff_state(self):
+ # Delete a server while it's VM state is Shutoff
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.stop(server['id'])
+ self.client.wait_for_server_status(server['id'], 'SHUTOFF')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+
+ @test.attr(type='gate')
+ def test_delete_server_while_in_pause_state(self):
+ # Delete a server while it's VM state is Pause
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.pause_server(server['id'])
+ self.client.wait_for_server_status(server['id'], 'PAUSED')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+
+ @test.attr(type='gate')
def test_delete_server_while_in_building_state(self):
# Delete a server while it's VM state is Building
resp, server = self.create_test_server(wait_until='BUILD')
@@ -126,7 +144,3 @@
self.client.wait_for_server_status(server['id'], 'ACTIVE')
resp, server = self.client.get_server(server['id'])
self.assertEqual('2001:2001::3', server['os-access-ips:access_ip_v6'])
-
-
-class ServersV3TestXML(ServersV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_servers_negative.py b/tempest/api/compute/v3/servers/test_servers_negative.py
index 29cbc92..e58d33d 100644
--- a/tempest/api/compute/v3/servers/test_servers_negative.py
+++ b/tempest/api/compute/v3/servers/test_servers_negative.py
@@ -428,7 +428,3 @@
self.assertRaises(exceptions.Conflict,
self.client.unshelve_server,
self.server_id)
-
-
-class ServersNegativeV3TestXML(ServersNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/test_extensions.py b/tempest/api/compute/v3/test_extensions.py
index 8a88fca..32f62d5 100644
--- a/tempest/api/compute/v3/test_extensions.py
+++ b/tempest/api/compute/v3/test_extensions.py
@@ -49,7 +49,3 @@
resp, extension = self.extensions_client.get_extension('servers')
self.assertEqual(200, resp.status)
self.assertEqual('servers', extension['alias'])
-
-
-class ExtensionsV3TestXML(ExtensionsV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/test_live_block_migration.py b/tempest/api/compute/v3/test_live_block_migration.py
index 50a5f3c..087bffb 100644
--- a/tempest/api/compute/v3/test_live_block_migration.py
+++ b/tempest/api/compute/v3/test_live_block_migration.py
@@ -162,10 +162,3 @@
cls.servers_client.delete_server(server_id)
super(LiveBlockMigrationV3TestJSON, cls).tearDownClass()
-
-
-class LiveBlockMigrationV3TestXML(LiveBlockMigrationV3TestJSON):
- _host_key = (
- '{http://docs.openstack.org/compute/ext/'
- 'extended_server_attributes/api/v3}host')
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/test_quotas.py b/tempest/api/compute/v3/test_quotas.py
index df25249..1cbfa2b 100644
--- a/tempest/api/compute/v3/test_quotas.py
+++ b/tempest/api/compute/v3/test_quotas.py
@@ -63,7 +63,3 @@
resp, tenant_quota_set = self.client.get_quota_set(self.tenant_id)
self.assertEqual(200, resp.status)
self.assertEqual(defualt_quota_set, tenant_quota_set)
-
-
-class QuotasV3TestXML(QuotasV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/test_version.py b/tempest/api/compute/v3/test_version.py
index 166d161..6fbe794 100644
--- a/tempest/api/compute/v3/test_version.py
+++ b/tempest/api/compute/v3/test_version.py
@@ -28,7 +28,3 @@
self.assertEqual(200, resp.status)
self.assertIn("id", version)
self.assertEqual("v3.0", version["id"])
-
-
-class VersionV3TestXML(VersionV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/test_roles_negative.py b/tempest/api/identity/admin/test_roles_negative.py
index 4eaa255..e316dc7 100644
--- a/tempest/api/identity/admin/test_roles_negative.py
+++ b/tempest/api/identity/admin/test_roles_negative.py
@@ -134,14 +134,6 @@
self.client.clear_auth()
@attr(type=['negative', 'gate'])
- def test_assign_user_role_for_non_existent_user(self):
- # Attempt to assign a role to a non existent user should fail
- (user, tenant, role) = self._get_role_params()
- non_existent_user = str(uuid.uuid4().hex)
- self.assertRaises(exceptions.NotFound, self.client.assign_user_role,
- tenant['id'], non_existent_user, role['id'])
-
- @attr(type=['negative', 'gate'])
def test_assign_user_role_for_non_existent_role(self):
# Attempt to assign a non existent role to user should fail
(user, tenant, role) = self._get_role_params()
@@ -192,17 +184,6 @@
self.client.clear_auth()
@attr(type=['negative', 'gate'])
- def test_remove_user_role_non_existent_user(self):
- # Attempt to remove a role from a non existent user should fail
- (user, tenant, role) = self._get_role_params()
- resp, user_role = self.client.assign_user_role(tenant['id'],
- user['id'],
- role['id'])
- non_existent_user = str(uuid.uuid4().hex)
- self.assertRaises(exceptions.NotFound, self.client.remove_user_role,
- tenant['id'], non_existent_user, role['id'])
-
- @attr(type=['negative', 'gate'])
def test_remove_user_role_non_existent_role(self):
# Attempt to delete a non existent role from a user should fail
(user, tenant, role) = self._get_role_params()
@@ -247,14 +228,6 @@
finally:
self.client.clear_auth()
- @attr(type=['negative', 'gate'])
- def test_list_user_roles_for_non_existent_user(self):
- # Attempt to list roles of a non existent user should fail
- (user, tenant, role) = self._get_role_params()
- non_existent_user = str(uuid.uuid4().hex)
- self.assertRaises(exceptions.NotFound, self.client.list_user_roles,
- tenant['id'], non_existent_user)
-
class RolesTestXML(RolesNegativeTestJSON):
_interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_groups.py b/tempest/api/identity/admin/v3/test_groups.py
index ca8ca54..70afec7 100644
--- a/tempest/api/identity/admin/v3/test_groups.py
+++ b/tempest/api/identity/admin/v3/test_groups.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
# All Rights Reserved.
#
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index bfc2287..2a5401f 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -199,8 +199,8 @@
@attr(type='gate')
def test_list_images_param_status(self):
- # Test to get all available images
- params = {"status": "available"}
+ # Test to get all active images
+ params = {"status": "active"}
self._list_by_param_value_and_assert(params)
@attr(type='gate')
diff --git a/tempest/api/network/admin/test_agent_management.py b/tempest/api/network/admin/test_agent_management.py
index ca3bd8d..b05f275 100644
--- a/tempest/api/network/admin/test_agent_management.py
+++ b/tempest/api/network/admin/test_agent_management.py
@@ -32,6 +32,10 @@
resp, body = self.admin_client.list_agents()
self.assertEqual('200', resp['status'])
agents = body['agents']
+ # Hearthbeats must be excluded from comparison
+ self.agent.pop('heartbeat_timestamp', None)
+ for agent in agents:
+ agent.pop('heartbeat_timestamp', None)
self.assertIn(self.agent, agents)
@attr(type=['smoke'])
diff --git a/tempest/api/object_storage/test_account_services.py b/tempest/api/object_storage/test_account_services.py
index 0300ced..79fd99d 100644
--- a/tempest/api/object_storage/test_account_services.py
+++ b/tempest/api/object_storage/test_account_services.py
@@ -16,6 +16,7 @@
import random
from tempest.api.object_storage import base
+from tempest.common import custom_matchers
from tempest.common.utils import data_utils
from tempest.test import attr
from tempest.test import HTTP_SUCCESS
@@ -51,6 +52,13 @@
self.assertIn(container_name, container_names)
@attr(type='smoke')
+ def test_list_extensions(self):
+ resp, extensions = self.account_client.list_extensions()
+
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertThat(resp, custom_matchers.AreAllWellFormatted())
+
+ @attr(type='smoke')
def test_list_containers_with_limit(self):
# list containers one of them, half of them then all of them
for limit in (1, self.containers_count / 2, self.containers_count):
diff --git a/tempest/api/object_storage/test_healthcheck.py b/tempest/api/object_storage/test_healthcheck.py
index fdac12f..78bff03 100644
--- a/tempest/api/object_storage/test_healthcheck.py
+++ b/tempest/api/object_storage/test_healthcheck.py
@@ -16,7 +16,6 @@
from tempest.api.object_storage import base
-from tempest import clients
from tempest.common import custom_matchers
from tempest.test import attr
from tempest.test import HTTP_SUCCESS
@@ -28,37 +27,17 @@
def setUpClass(cls):
super(HealthcheckTest, cls).setUpClass()
- # creates a test user. The test user will set its base_url to the Swift
- # endpoint and test the healthcheck feature.
- cls.data.setup_test_user()
-
- cls.os_test_user = clients.Manager(
- cls.data.test_user,
- cls.data.test_password,
- cls.data.test_tenant)
-
- @classmethod
- def tearDownClass(cls):
- cls.data.teardown_all()
- super(HealthcheckTest, cls).tearDownClass()
-
def setUp(self):
super(HealthcheckTest, self).setUp()
- client = self.os_test_user.account_client
- client._set_auth()
-
+ self.account_client._set_auth()
# Turning http://.../v1/foobar into http://.../
- client.base_url = "/".join(client.base_url.split("/")[:-2])
-
- def tearDown(self):
- # clear the base_url for subsequent requests
- self.os_test_user.account_client.base_url = None
- super(HealthcheckTest, self).tearDown()
+ self.account_client.base_url = "/".join(
+ self.account_client.base_url.split("/")[:-2])
@attr('gate')
def test_get_healthcheck(self):
- resp, _ = self.os_test_user.account_client.get("healthcheck", {})
+ resp, _ = self.account_client.get("healthcheck", {})
# The status is expected to be 200
self.assertIn(int(resp['status']), HTTP_SUCCESS)
diff --git a/tempest/api/object_storage/test_object_services.py b/tempest/api/object_storage/test_object_services.py
index 256165b..13f197b 100644
--- a/tempest/api/object_storage/test_object_services.py
+++ b/tempest/api/object_storage/test_object_services.py
@@ -31,20 +31,9 @@
cls.container_client.create_container(cls.container_name)
cls.containers = [cls.container_name]
- cls.data.setup_test_user()
- resp, body = cls.token_client.auth(cls.data.test_user,
- cls.data.test_password,
- cls.data.test_tenant)
- cls.new_token = cls.token_client.get_token(cls.data.test_user,
- cls.data.test_password,
- cls.data.test_tenant)
- cls.custom_headers = {'X-Auth-Token': cls.new_token}
-
@classmethod
def tearDownClass(cls):
cls.delete_containers(cls.containers)
- # delete the user setup created
- cls.data.teardown_all()
super(ObjectTest, cls).tearDownClass()
@attr(type='smoke')
diff --git a/tempest/api/volume/test_volume_transfers.py b/tempest/api/volume/test_volume_transfers.py
index 8710d82..4ee7bd0 100644
--- a/tempest/api/volume/test_volume_transfers.py
+++ b/tempest/api/volume/test_volume_transfers.py
@@ -55,10 +55,17 @@
cls.alt_client = cls.os_alt.volumes_client
cls.adm_client = cls.os_adm.volumes_client
+ def _delete_volume(self, volume_id):
+ # Delete the specified volume using admin creds
+ resp, _ = self.adm_client.delete_volume(volume_id)
+ self.assertEqual(202, resp.status)
+ self.adm_client.wait_for_resource_deletion(volume_id)
+
@attr(type='gate')
def test_create_get_list_accept_volume_transfer(self):
# Create a volume first
volume = self.create_volume()
+ self.addCleanup(self._delete_volume, volume['id'])
# Create a volume transfer
resp, transfer = self.client.create_volume_transfer(volume['id'])
@@ -88,6 +95,7 @@
def test_create_list_delete_volume_transfer(self):
# Create a volume first
volume = self.create_volume()
+ self.addCleanup(self._delete_volume, volume['id'])
# Create a volume transfer
resp, body = self.client.create_volume_transfer(volume['id'])
diff --git a/tempest/clients.py b/tempest/clients.py
index 65b603b..4c40ce0 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -143,6 +143,10 @@
ObjectClientCustomizedHeader
from tempest.services.orchestration.json.orchestration_client import \
OrchestrationClient
+from tempest.services.telemetry.json.telemetry_client import \
+ TelemetryClientJSON
+from tempest.services.telemetry.xml.telemetry_client import \
+ TelemetryClientXML
from tempest.services.volume.json.admin.volume_hosts_client import \
VolumeHostsClientJSON
from tempest.services.volume.json.admin.volume_types_client import \
@@ -256,6 +260,8 @@
if client_args_v3_auth:
self.servers_client_v3_auth = ServersClientXML(
*client_args_v3_auth)
+ if CONF.service_available.ceilometer:
+ self.telemetry_client = TelemetryClientXML(*client_args)
elif interface == 'json':
self.certificates_client = CertificatesClientJSON(*client_args)
@@ -318,6 +324,8 @@
self.volumes_extension_client = VolumeExtensionClientJSON(
*client_args)
self.hosts_v3_client = HostsV3ClientJSON(*client_args)
+ if CONF.service_available.ceilometer:
+ self.telemetry_client = TelemetryClientJSON(*client_args)
if client_args_v3_auth:
self.servers_client_v3_auth = ServersClientJSON(
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 3efc710..81ebd4b 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -456,18 +456,17 @@
if resp.status < 400:
return
- JSON_ENC = ['application/json; charset=UTF-8', 'application/json',
- 'application/json; charset=utf-8']
+ JSON_ENC = ['application/json', 'application/json; charset=utf-8']
# NOTE(mtreinish): This is for compatibility with Glance and swift
# APIs. These are the return content types that Glance api v1
# (and occasionally swift) are using.
- TXT_ENC = ['text/plain', 'text/plain; charset=UTF-8',
- 'text/html; charset=UTF-8', 'text/plain; charset=utf-8']
- XML_ENC = ['application/xml', 'application/xml; charset=UTF-8']
+ TXT_ENC = ['text/plain', 'text/html', 'text/html; charset=utf-8',
+ 'text/plain; charset=utf-8']
+ XML_ENC = ['application/xml', 'application/xml; charset=utf-8']
- if ctype in JSON_ENC or ctype in XML_ENC:
+ if ctype.lower() in JSON_ENC or ctype.lower() in XML_ENC:
parse_resp = True
- elif ctype in TXT_ENC:
+ elif ctype.lower() in TXT_ENC:
parse_resp = False
else:
raise exceptions.RestClientException(str(resp.status))
diff --git a/tempest/common/ssh.py b/tempest/common/ssh.py
index 5eb7336..0ed9b82 100644
--- a/tempest/common/ssh.py
+++ b/tempest/common/ssh.py
@@ -93,20 +93,6 @@
def _is_timed_out(self, start_time):
return (time.time() - self.timeout) > start_time
- def connect_until_closed(self):
- """Connect to the server and wait until connection is lost."""
- try:
- ssh = self._get_ssh_connection()
- _transport = ssh.get_transport()
- _start_time = time.time()
- _timed_out = self._is_timed_out(_start_time)
- while _transport.is_active() and not _timed_out:
- time.sleep(5)
- _timed_out = self._is_timed_out(_start_time)
- ssh.close()
- except (EOFError, paramiko.AuthenticationException, socket.error):
- return
-
def exec_command(self, cmd):
"""
Execute the specified command on the server.
@@ -138,7 +124,7 @@
raise exceptions.TimeoutException(
"Command: '{0}' executed on host '{1}'.".format(
cmd, self.host))
- if not ready[0]: # If there is nothing to read.
+ if not ready[0]: # If there is nothing to read.
continue
out_chunk = err_chunk = None
if channel.recv_ready():
diff --git a/tempest/config.py b/tempest/config.py
index d529965..5a9199d 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -147,7 +147,7 @@
default='root',
help="User name used to authenticate to an instance."),
cfg.IntOpt('ping_timeout',
- default=60,
+ default=120,
help="Timeout in seconds to wait for ping to "
"succeed."),
cfg.IntOpt('ssh_timeout',
diff --git a/tempest/scenario/test_aggregates_basic_ops.py b/tempest/scenario/test_aggregates_basic_ops.py
index 3ae9567..7afa863 100644
--- a/tempest/scenario/test_aggregates_basic_ops.py
+++ b/tempest/scenario/test_aggregates_basic_ops.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
# All Rights Reserved.
#
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index eaca1fd..aea5874 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -186,8 +186,7 @@
key.private_key)
except Exception:
LOG.exception('Tenant connectivity check failed')
- self._log_console_output(
- servers=[server for server, _key in self.servers])
+ self._log_console_output(servers=self.servers.keys())
debug.log_ip_ns()
raise
@@ -214,8 +213,7 @@
should_connect=should_connect)
except Exception:
LOG.exception('Public network connectivity check failed')
- self._log_console_output(
- servers=[server for server, _key in self.servers])
+ self._log_console_output(servers=self.servers.keys())
debug.log_ip_ns()
raise
diff --git a/tempest/services/object_storage/account_client.py b/tempest/services/object_storage/account_client.py
index e796f9b..a6f47b7 100644
--- a/tempest/services/object_storage/account_client.py
+++ b/tempest/services/object_storage/account_client.py
@@ -33,9 +33,7 @@
HEAD on the storage URL
Returns all account metadata headers
"""
-
- headers = {"X-Storage-Token": self.token}
- resp, body = self.head('', headers=headers)
+ resp, body = self.head('')
return resp, body
def create_account_metadata(self, metadata,
@@ -54,7 +52,7 @@
Deletes an account metadata entry.
"""
- headers = {"X-Storage-Token": self.token}
+ headers = {}
for item in metadata:
headers[metadata_prefix + item] = 'x'
resp, body = self.post('', headers=headers, body=None)
@@ -63,8 +61,8 @@
def list_account_containers(self, params=None):
"""
GET on the (base) storage URL
- Given the X-Storage-URL and a valid X-Auth-Token, returns
- a list of all containers for the account.
+ Given valid X-Auth-Token, returns a list of all containers for the
+ account.
Optional Arguments:
limit=[integer value N]
@@ -93,6 +91,14 @@
body = json.loads(body)
return resp, body
+ def list_extensions(self):
+ _base_url = self.base_url
+ self.base_url = "/".join(self.base_url.split("/")[:-2])
+ resp, body = self.get('info')
+ self.base_url = _base_url
+ body = json.loads(body)
+ return resp, body
+
class AccountClientCustomizedHeader(RestClient):
@@ -127,8 +133,8 @@
def list_account_containers(self, params=None, metadata=None):
"""
GET on the (base) storage URL
- Given the X-Storage-URL and a valid X-Auth-Token, returns
- a list of all containers for the account.
+ Given a valid X-Auth-Token, returns a list of all containers for the
+ account.
Optional Arguments:
limit=[integer value N]
diff --git a/tempest/services/object_storage/container_client.py b/tempest/services/object_storage/container_client.py
index 15185bc..cbd07bf 100644
--- a/tempest/services/object_storage/container_client.py
+++ b/tempest/services/object_storage/container_client.py
@@ -82,8 +82,7 @@
Retrieves container metadata headers
"""
url = str(container_name)
- headers = {"X-Storage-Token": self.token}
- resp, body = self.head(url, headers=headers)
+ resp, body = self.head(url)
return resp, body
def list_all_container_objects(self, container, params=None):
diff --git a/tempest/services/telemetry/__init__.py b/tempest/services/telemetry/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/telemetry/__init__.py
diff --git a/tempest/services/telemetry/json/__init__.py b/tempest/services/telemetry/json/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/telemetry/json/__init__.py
diff --git a/tempest/services/telemetry/json/telemetry_client.py b/tempest/services/telemetry/json/telemetry_client.py
new file mode 100644
index 0000000..8d46bf3
--- /dev/null
+++ b/tempest/services/telemetry/json/telemetry_client.py
@@ -0,0 +1,52 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2014 OpenStack Foundation
+# 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.
+
+from tempest.common.rest_client import RestClient
+from tempest.openstack.common import jsonutils as json
+import tempest.services.telemetry.telemetry_client_base as client
+
+
+class TelemetryClientJSON(client.TelemetryClientBase):
+
+ def get_rest_client(self, config, username,
+ password, auth_url, tenant_name=None):
+ return RestClient(config, username, password, auth_url, tenant_name)
+
+ def deserialize(self, body):
+ return json.loads(body.replace("\n", ""))
+
+ def serialize(self, body):
+ return json.dumps(body)
+
+ def create_alarm(self, **kwargs):
+ uri = "%s/alarms" % self.uri_prefix
+ return self.post(uri, kwargs)
+
+ def add_sample(self, sample_list, meter_name, meter_unit, volume,
+ sample_type, resource_id, **kwargs):
+ sample = {"counter_name": meter_name, "counter_unit": meter_unit,
+ "counter_volume": volume, "counter_type": sample_type,
+ "resource_id": resource_id}
+ for key in kwargs:
+ sample[key] = kwargs[key]
+
+ sample_list.append(self.serialize(sample))
+ return sample_list
+
+ def create_sample(self, meter_name, sample_list):
+ uri = "%s/meters/%s" % (self.uri_prefix, meter_name)
+ return self.post(uri, str(sample_list))
diff --git a/tempest/services/telemetry/telemetry_client_base.py b/tempest/services/telemetry/telemetry_client_base.py
new file mode 100644
index 0000000..59127b9
--- /dev/null
+++ b/tempest/services/telemetry/telemetry_client_base.py
@@ -0,0 +1,133 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 OpenStack Foundation
+# 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 abc
+import six
+import urllib
+
+
+@six.add_metaclass(abc.ABCMeta)
+class TelemetryClientBase(object):
+
+ """
+ Tempest REST client for Ceilometer V2 API.
+ Implements the following basic Ceilometer abstractions:
+ resources
+ meters
+ alarms
+ queries
+ statistics
+ """
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ self.rest_client = self.get_rest_client(config, username, password,
+ auth_url, tenant_name)
+ self.rest_client.service = \
+ self.rest_client.config.telemetry.catalog_type
+ self.headers = self.rest_client.headers
+ self.version = '2'
+ self.uri_prefix = "v%s" % self.version
+
+ @abc.abstractmethod
+ def get_rest_client(self, config, username, password,
+ auth_url, tenant_name):
+ """
+ :param config:
+ :param username:
+ :param password:
+ :param auth_url:
+ :param tenant_name:
+ :return: RestClient
+ """
+
+ @abc.abstractmethod
+ def deserialize(self, body):
+ """
+ :param body:
+ :return: Deserialize body
+ """
+
+ @abc.abstractmethod
+ def serialize(self, body):
+ """
+ :param body:
+ :return: Serialize body
+ """
+
+ def post(self, uri, body):
+ body = self.serialize(body)
+ resp, body = self.rest_client.post(uri, body, self.headers)
+ body = self.deserialize(body)
+ return resp, body
+
+ def put(self, uri, body):
+ return self.rest_client.put(uri, body, self.headers)
+
+ def get(self, uri):
+ resp, body = self.rest_client.get(uri)
+ body = self.deserialize(body)
+ return resp, body
+
+ def delete(self, uri):
+ resp, body = self.rest_client.delete(uri)
+ if body:
+ body = self.deserialize(body)
+ return resp, body
+
+ def helper_list(self, uri, query=None, period=None):
+ uri_dict = {}
+ if query:
+ uri_dict = {'q.field': query[0],
+ 'q.op': query[1],
+ 'q.value': query[2]}
+ if period:
+ uri_dict['period'] = period
+ if uri_dict:
+ uri += "?%s" % urllib.urlencode(uri_dict)
+ return self.get(uri)
+
+ def list_resources(self):
+ uri = '%s/resources' % self.uri_prefix
+ return self.get(uri)
+
+ def list_meters(self):
+ uri = '%s/meters' % self.uri_prefix
+ return self.get(uri)
+
+ def list_alarms(self):
+ uri = '%s/alarms' % self.uri_prefix
+ return self.get(uri)
+
+ def list_statistics(self, meter, period=None, query=None):
+ uri = "%s/meters/%s/statistics" % (self.uri_prefix, meter)
+ return self.helper_list(uri, query, period)
+
+ def list_samples(self, meter_id, query=None):
+ uri = '%s/meters/%s' % (self.uri_prefix, meter_id)
+ return self.helper_list(uri, query)
+
+ def get_resource(self, resource_id):
+ uri = '%s/resources/%s' % (self.uri_prefix, resource_id)
+ return self.get(uri)
+
+ def get_alarm(self, alarm_id):
+ uri = '%s/meter/%s' % (self.uri_prefix, alarm_id)
+ return self.get(uri)
+
+ def delete_alarm(self, alarm_id):
+ uri = "%s/alarms/%s" % (self.uri_prefix, alarm_id)
+ return self.delete(uri)
diff --git a/tempest/services/telemetry/xml/__init__.py b/tempest/services/telemetry/xml/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/telemetry/xml/__init__.py
diff --git a/tempest/services/telemetry/xml/telemetry_client.py b/tempest/services/telemetry/xml/telemetry_client.py
new file mode 100644
index 0000000..245ccb5
--- /dev/null
+++ b/tempest/services/telemetry/xml/telemetry_client.py
@@ -0,0 +1,42 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2014 OpenStack Foundation
+# 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.
+
+from lxml import etree
+
+from tempest.common.rest_client import RestClientXML
+from tempest.services.compute.xml.common import Document
+from tempest.services.compute.xml.common import xml_to_json
+import tempest.services.telemetry.telemetry_client_base as client
+
+
+class TelemetryClientXML(client.TelemetryClientBase):
+
+ def get_rest_client(self, config, username,
+ password, auth_url, tenant_name=None):
+ return RestClientXML(config, username, password, auth_url, tenant_name)
+
+ def _parse_array(self, body):
+ array = []
+ for child in body.getchildren():
+ array.append(xml_to_json(child))
+ return array
+
+ def serialize(self, body):
+ return str(Document(body))
+
+ def deserialize(self, body):
+ return self._parse_array(etree.fromstring(body))
diff --git a/tempest/stress/run_stress.py b/tempest/stress/run_stress.py
index 61fb58f..76320d0 100755
--- a/tempest/stress/run_stress.py
+++ b/tempest/stress/run_stress.py
@@ -19,7 +19,11 @@
import json
import sys
from testtools.testsuite import iterate_tests
-from unittest import loader
+try:
+ from unittest import loader
+except ImportError:
+ # unittest in python 2.6 does not contain loader, so uses unittest2
+ from unittest2 import loader
from tempest.openstack.common import log as logging
from tempest.stress import driver
diff --git a/tempest/tests/base.py b/tempest/tests/base.py
index 3654f64..15e4311 100644
--- a/tempest/tests/base.py
+++ b/tempest/tests/base.py
@@ -15,6 +15,7 @@
import os
import fixtures
+import mock
import testtools
from tempest.openstack.common.fixture import moxstubout
@@ -36,3 +37,22 @@
mox_fixture = self.useFixture(moxstubout.MoxStubout())
self.mox = mox_fixture.mox
self.stubs = mox_fixture.stubs
+
+ def patch(self, target, **kwargs):
+ """
+ Returns a started `mock.patch` object for the supplied target.
+
+ The caller may then call the returned patcher to create a mock object.
+
+ The caller does not need to call stop() on the returned
+ patcher object, as this method automatically adds a cleanup
+ to the test class to stop the patcher.
+
+ :param target: String module.class or module.object expression to patch
+ :param **kwargs: Passed as-is to `mock.patch`. See mock documentation
+ for details.
+ """
+ p = mock.patch(target, **kwargs)
+ m = p.start()
+ self.addCleanup(p.stop)
+ return m
diff --git a/tempest/tests/test_ssh.py b/tempest/tests/test_ssh.py
new file mode 100644
index 0000000..09bb588
--- /dev/null
+++ b/tempest/tests/test_ssh.py
@@ -0,0 +1,200 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2014 OpenStack Foundation
+#
+# 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 contextlib
+import socket
+
+import mock
+import testtools
+
+from tempest.common import ssh
+from tempest import exceptions
+from tempest.tests import base
+
+
+class TestSshClient(base.TestCase):
+
+ def test_pkey_calls_paramiko_RSAKey(self):
+ with contextlib.nested(
+ mock.patch('paramiko.RSAKey.from_private_key'),
+ mock.patch('cStringIO.StringIO')) as (rsa_mock, cs_mock):
+ cs_mock.return_value = mock.sentinel.csio
+ pkey = 'mykey'
+ ssh.Client('localhost', 'root', pkey=pkey)
+ rsa_mock.assert_called_once_with(mock.sentinel.csio)
+ cs_mock.assert_called_once_with('mykey')
+ rsa_mock.reset_mock()
+ cs_mock.rest_mock()
+ pkey = mock.sentinel.pkey
+ # Shouldn't call out to load a file from RSAKey, since
+ # a sentinel isn't a basestring...
+ ssh.Client('localhost', 'root', pkey=pkey)
+ rsa_mock.assert_not_called()
+ cs_mock.assert_not_called()
+
+ def test_get_ssh_connection(self):
+ c_mock = self.patch('paramiko.SSHClient')
+ aa_mock = self.patch('paramiko.AutoAddPolicy')
+ s_mock = self.patch('time.sleep')
+ t_mock = self.patch('time.time')
+
+ aa_mock.return_value = mock.sentinel.aa
+
+ def reset_mocks():
+ aa_mock.reset_mock()
+ c_mock.reset_mock()
+ s_mock.reset_mock()
+ t_mock.reset_mock()
+
+ # Test normal case for successful connection on first try
+ client_mock = mock.MagicMock()
+ c_mock.return_value = client_mock
+ client_mock.connect.return_value = True
+
+ client = ssh.Client('localhost', 'root', timeout=2)
+ client._get_ssh_connection(sleep=1)
+
+ aa_mock.assert_called_once_with()
+ client_mock.set_missing_host_key_policy.assert_called_once_with(
+ mock.sentinel.aa)
+ expected_connect = [mock.call(
+ 'localhost',
+ username='root',
+ pkey=None,
+ key_filename=None,
+ look_for_keys=False,
+ timeout=10.0,
+ password=None
+ )]
+ self.assertEqual(expected_connect, client_mock.connect.mock_calls)
+ s_mock.assert_not_called()
+ t_mock.assert_called_once_with()
+
+ reset_mocks()
+
+ # Test case when connection fails on first two tries and
+ # succeeds on third try (this validates retry logic)
+ client_mock.connect.side_effect = [socket.error, socket.error, True]
+ t_mock.side_effect = [
+ 1000, # Start time
+ 1001, # Sleep loop 1
+ 1002 # Sleep loop 2
+ ]
+
+ client._get_ssh_connection(sleep=1)
+
+ expected_sleeps = [
+ mock.call(1),
+ mock.call(1.01)
+ ]
+ self.assertEqual(expected_sleeps, s_mock.mock_calls)
+
+ reset_mocks()
+
+ # Test case when connection fails on first three tries and
+ # exceeds the timeout, so expect to raise a Timeout exception
+ client_mock.connect.side_effect = [
+ socket.error,
+ socket.error,
+ socket.error
+ ]
+ t_mock.side_effect = [
+ 1000, # Start time
+ 1001, # Sleep loop 1
+ 1002, # Sleep loop 2
+ 1003, # Sleep loop 3
+ 1004 # LOG.error() calls time.time()
+ ]
+
+ with testtools.ExpectedException(exceptions.SSHTimeout):
+ client._get_ssh_connection()
+
+ def test_exec_command(self):
+ gsc_mock = self.patch('tempest.common.ssh.Client._get_ssh_connection')
+ ito_mock = self.patch('tempest.common.ssh.Client._is_timed_out')
+ select_mock = self.patch('select.poll')
+
+ client_mock = mock.MagicMock()
+ tran_mock = mock.MagicMock()
+ chan_mock = mock.MagicMock()
+ poll_mock = mock.MagicMock()
+
+ def reset_mocks():
+ gsc_mock.reset_mock()
+ ito_mock.reset_mock()
+ select_mock.reset_mock()
+ poll_mock.reset_mock()
+ client_mock.reset_mock()
+ tran_mock.reset_mock()
+ chan_mock.reset_mock()
+
+ select_mock.return_value = poll_mock
+ gsc_mock.return_value = client_mock
+ ito_mock.return_value = True
+ client_mock.get_transport.return_value = tran_mock
+ tran_mock.open_session.return_value = chan_mock
+ poll_mock.poll.side_effect = [
+ [0, 0, 0]
+ ]
+
+ # Test for a timeout condition immediately raised
+ client = ssh.Client('localhost', 'root', timeout=2)
+ with testtools.ExpectedException(exceptions.TimeoutException):
+ client.exec_command("test")
+
+ chan_mock.fileno.assert_called_once_with()
+ chan_mock.exec_command.assert_called_once_with("test")
+ chan_mock.shutdown_write.assert_called_once_with()
+
+ SELECT_POLLIN = 1
+ poll_mock.register.assert_called_once_with(chan_mock, SELECT_POLLIN)
+ poll_mock.poll.assert_called_once_with(10)
+
+ # Test for proper reading of STDOUT and STDERROR and closing
+ # of all file descriptors.
+
+ reset_mocks()
+
+ select_mock.return_value = poll_mock
+ gsc_mock.return_value = client_mock
+ ito_mock.return_value = False
+ client_mock.get_transport.return_value = tran_mock
+ tran_mock.open_session.return_value = chan_mock
+ poll_mock.poll.side_effect = [
+ [1, 0, 0]
+ ]
+ closed_prop = mock.PropertyMock(return_value=True)
+ type(chan_mock).closed = closed_prop
+ chan_mock.recv_exit_status.return_value = 0
+ chan_mock.recv.return_value = ''
+ chan_mock.recv_stderr.return_value = ''
+
+ client = ssh.Client('localhost', 'root', timeout=2)
+ client.exec_command("test")
+
+ chan_mock.fileno.assert_called_once_with()
+ chan_mock.exec_command.assert_called_once_with("test")
+ chan_mock.shutdown_write.assert_called_once_with()
+
+ SELECT_POLLIN = 1
+ poll_mock.register.assert_called_once_with(chan_mock, SELECT_POLLIN)
+ poll_mock.poll.assert_called_once_with(10)
+ chan_mock.recv_ready.assert_called_once_with()
+ chan_mock.recv.assert_called_once_with(1024)
+ chan_mock.recv_stderr_ready.assert_called_once_with()
+ chan_mock.recv_stderr.assert_called_once_with(1024)
+ chan_mock.recv_exit_status.assert_called_once_with()
+ closed_prop.assert_called_once_with()
diff --git a/tools/install_venv.py b/tools/install_venv.py
index a7fb5ee..e41ca43 100644
--- a/tools/install_venv.py
+++ b/tools/install_venv.py
@@ -1,7 +1,7 @@
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
-# flake8: noqa
+#
# Copyright 2010 OpenStack Foundation
# Copyright 2013 IBM Corp.
#
@@ -17,66 +17,55 @@
# License for the specific language governing permissions and limitations
# under the License.
-"""Installation script for Tempest's development virtualenv."""
-
import os
import sys
-import install_venv_common as install_venv
+import install_venv_common as install_venv # noqa
-class CentOS(install_venv.Fedora):
- """This covers CentOS."""
-
- def post_process(self):
- if not self.check_pkg('openssl-devel'):
- self.yum.install('openssl-devel', check_exit_code=False)
-
-
-def print_help():
- """This prints Help."""
-
+def print_help(venv, root):
help = """
- Tempest development environment setup is complete.
+ Openstack development environment setup is complete.
- Tempest development uses virtualenv to track and manage Python dependencies
- while in development and testing.
+ Openstack development uses virtualenv to track and manage Python
+ dependencies while in development and testing.
- To activate the Tempest virtualenv for the extent of your current shell
+ To activate the Openstack virtualenv for the extent of your current shell
session you can run:
- $ source .venv/bin/activate
+ $ source %s/bin/activate
Or, if you prefer, you can run commands in the virtualenv on a case by case
basis by running:
- $ tools/with_venv.sh <your command>
+ $ %s/tools/with_venv.sh <your command>
Also, make test will automatically use the virtualenv.
"""
- print(help)
+ print(help % (venv, root))
def main(argv):
root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+
+ if os.environ.get('tools_path'):
+ root = os.environ['tools_path']
venv = os.path.join(root, '.venv')
+ if os.environ.get('venv'):
+ venv = os.environ['venv']
+
pip_requires = os.path.join(root, 'requirements.txt')
test_requires = os.path.join(root, 'test-requirements.txt')
py_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
project = 'Tempest'
install = install_venv.InstallVenv(root, venv, pip_requires, test_requires,
py_version, project)
- if os.path.exists('/etc/redhat-release'):
- with open('/etc/redhat-release') as rh_release:
- if 'CentOS' in rh_release.read():
- install_venv.Fedora = CentOS
options = install.parse_args(argv)
install.check_python_version()
install.check_dependencies()
install.create_virtualenv(no_site_packages=options.no_site_packages)
install.install_dependencies()
- install.post_process()
- print_help()
+ print_help(venv, root)
if __name__ == '__main__':
main(sys.argv)
diff --git a/tools/verify_tempest_config.py b/tools/verify_tempest_config.py
index f56b475..0c21cea 100755
--- a/tools/verify_tempest_config.py
+++ b/tools/verify_tempest_config.py
@@ -22,13 +22,6 @@
CONF = config.CONF
-#Dicts matching extension names to config options
-NOVA_EXTENSIONS = {
- 'disk_config': 'DiskConfig',
- 'change_password': 'ServerPassword',
- 'flavor_extra': 'FlavorExtraSpecs'
-}
-
def verify_glance_api_versions(os):
# Check glance api versions
@@ -42,32 +35,87 @@
not CONF.image_feature_enabled.api_v2))
-def verify_extensions(os):
- results = {}
- extensions_client = os.extensions_client
+def get_extension_client(os, service):
+ extensions_client = {
+ 'nova': os.extensions_client,
+ 'nova_v3': os.extensions_v3_client,
+ 'cinder': os.volumes_extension_client,
+ 'neutron': os.network_client,
+ }
+ if service not in extensions_client:
+ print('No tempest extensions client for %s' % service)
+ exit(1)
+ return extensions_client[service]
+
+
+def get_enabled_extensions(service):
+ extensions_options = {
+ 'nova': CONF.compute_feature_enabled.api_extensions,
+ 'nova_v3': CONF.compute_feature_enabled.api_v3_extensions,
+ 'cinder': CONF.volume_feature_enabled.api_extensions,
+ 'neutron': CONF.network_feature_enabled.api_extensions,
+ }
+ if service not in extensions_options:
+ print('No supported extensions list option for %s' % service)
+ exit(1)
+ return extensions_options[service]
+
+
+def verify_extensions(os, service, results):
+ extensions_client = get_extension_client(os, service)
__, resp = extensions_client.list_extensions()
- resp = resp['extensions']
- extensions = map(lambda x: x['name'], resp)
- results['nova_features'] = {}
- for extension in NOVA_EXTENSIONS.keys():
- if NOVA_EXTENSIONS[extension] in extensions:
- results['nova_features'][extension] = True
+ if isinstance(resp, dict):
+ # Neutron's extension 'name' field has is not a single word (it has
+ # spaces in the string) Since that can't be used for list option the
+ # api_extension option in the network-feature-enabled group uses alias
+ # instead of name.
+ if service == 'neutron':
+ extensions = map(lambda x: x['alias'], resp['extensions'])
else:
- results['nova_features'][extension] = False
+ extensions = map(lambda x: x['name'], resp['extensions'])
+
+ else:
+ extensions = map(lambda x: x['name'], resp)
+ if not results.get(service):
+ results[service] = {}
+ extensions_opt = get_enabled_extensions(service)
+ if extensions_opt[0] == 'all':
+ results[service]['extensions'] = 'all'
+ return results
+ # Verify that all configured extensions are actually enabled
+ for extension in extensions_opt:
+ results[service][extension] = extension in extensions
+ # Verify that there aren't additional extensions enabled that aren't
+ # specified in the config list
+ for extension in extensions:
+ if extension not in extensions_opt:
+ results[service][extension] = False
return results
def display_results(results):
- for option in NOVA_EXTENSIONS.keys():
- config_value = getattr(CONF.compute_feature_enabled, option)
- if config_value != results['nova_features'][option]:
- print("Config option: %s should be changed to: %s" % (
- option, not config_value))
+ for service in results:
+ # If all extensions are specified as being enabled there is no way to
+ # verify this so we just assume this to be true
+ if results[service].get('extensions'):
+ continue
+ extension_list = get_enabled_extensions(service)
+ for extension in results[service]:
+ if not results[service][extension]:
+ if extension in extension_list:
+ print("%s extension: %s should not be included in the list"
+ " of enabled extensions" % (service, extension))
+ else:
+ print("%s extension: %s should be included in the list of "
+ "enabled extensions" % (service, extension))
def main(argv):
+ print('Running config verification...')
os = clients.ComputeAdminManager(interface='json')
- results = verify_extensions(os)
+ results = {}
+ for service in ['nova', 'nova_v3', 'cinder', 'neutron']:
+ results = verify_extensions(os, service, results)
verify_glance_api_versions(os)
display_results(results)