Merge "Exclude heartbeat timestamp from agent list checks"
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/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_servers.py b/tempest/api/compute/v3/admin/test_servers.py
index 2db128e..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)
diff --git a/tempest/api/compute/v3/servers/test_server_actions.py b/tempest/api/compute/v3/servers/test_server_actions.py
index 9bb287a..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']))
diff --git a/tempest/api/compute/v3/servers/test_servers.py b/tempest/api/compute/v3/servers/test_servers.py
index 72c91b0..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')
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/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/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/services/object_storage/account_client.py b/tempest/services/object_storage/account_client.py
index eec5a05..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]
@@ -135,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)