Merge "cinder v2 api tests - part1"
diff --git a/.testr.conf b/.testr.conf
index c25ebec..abaf14a 100644
--- a/.testr.conf
+++ b/.testr.conf
@@ -2,8 +2,7 @@
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-500} \
- OS_TEST_PATH=${OS_TEST_PATH:-./tempest} \
- ${PYTHON:-python} -m subunit.run discover -t ./ $OS_TEST_PATH $LISTOPT $IDOPTION
+ ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./tempest/test_discover} $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list
group_regex=([^\.]*\.)*
diff --git a/README.rst b/README.rst
index 96f6e4c..4098e32 100644
--- a/README.rst
+++ b/README.rst
@@ -67,7 +67,7 @@
To run one single test ::
- $> testr run --parallel tempest.api.compute.servers.test_server_actions.ServerActionsTestJSON.test_rebuild_nonexistent_server
+ $> testr run --parallel tempest.api.compute.servers.test_servers_negative.ServersNegativeTestJSON.test_reboot_non_existent_server
Alternatively, you can use the run_tests.sh script which will create a venv
and run the tests or use tox to do the same.
diff --git a/tempest/api/compute/__init__.py b/tempest/api/compute/__init__.py
index d20068e..e69de29 100644
--- a/tempest/api/compute/__init__.py
+++ b/tempest/api/compute/__init__.py
@@ -1,27 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 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 import config
-from tempest.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-CONFIG = config.TempestConfig()
-CREATE_IMAGE_ENABLED = CONFIG.compute_feature_enabled.create_image
-RESIZE_AVAILABLE = CONFIG.compute_feature_enabled.resize
-CHANGE_PASSWORD_AVAILABLE = CONFIG.compute_feature_enabled.change_password
-DISK_CONFIG_ENABLED = CONFIG.compute_feature_enabled.disk_config
diff --git a/tempest/api/compute/admin/test_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py
index 6b24e72..dbf7967 100644
--- a/tempest/api/compute/admin/test_hosts_negative.py
+++ b/tempest/api/compute/admin/test_hosts_negative.py
@@ -17,7 +17,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class HostsAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
@@ -41,18 +41,18 @@
hostname = hosts[0]['host_name']
return hostname
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_hosts_with_non_admin_user(self):
self.assertRaises(exceptions.Unauthorized,
self.non_admin_client.list_hosts)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_show_host_detail_with_nonexistent_hostname(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
self.assertRaises(exceptions.NotFound,
self.client.show_host_detail, nonexitent_hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_show_host_detail_with_non_admin_user(self):
hostname = self._get_host_name()
@@ -60,7 +60,7 @@
self.non_admin_client.show_host_detail,
hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_host_with_non_admin_user(self):
hostname = self._get_host_name()
@@ -68,7 +68,8 @@
self.non_admin_client.update_host,
hostname)
- @attr(type=['negative', 'gate'])
+ @test.skip_because(bug="1261964", interface="xml")
+ @test.attr(type=['negative', 'gate'])
def test_update_host_with_extra_param(self):
# only 'status' and 'maintenance_mode' are the valid params.
hostname = self._get_host_name()
@@ -80,7 +81,7 @@
maintenance_mode='enable',
param='XXX')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_host_with_invalid_status(self):
# 'status' can only be 'enable' or 'disable'
hostname = self._get_host_name()
@@ -91,7 +92,7 @@
status='invalid',
maintenance_mode='enable')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_host_with_invalid_maintenance_mode(self):
# 'maintenance_mode' can only be 'enable' or 'disable'
hostname = self._get_host_name()
@@ -102,7 +103,7 @@
status='enable',
maintenance_mode='invalid')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_host_without_param(self):
# 'status' or 'maintenance_mode' needed for host update
hostname = self._get_host_name()
@@ -111,7 +112,7 @@
self.client.update_host,
hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_nonexistent_host(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
@@ -121,7 +122,7 @@
status='enable',
maintenance_mode='enable')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_startup_nonexistent_host(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
@@ -129,7 +130,7 @@
self.client.startup_host,
nonexitent_hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_startup_host_with_non_admin_user(self):
hostname = self._get_host_name()
@@ -137,7 +138,7 @@
self.non_admin_client.startup_host,
hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_shutdown_nonexistent_host(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
@@ -145,7 +146,7 @@
self.client.shutdown_host,
nonexitent_hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_shutdown_host_with_non_admin_user(self):
hostname = self._get_host_name()
@@ -153,7 +154,7 @@
self.non_admin_client.shutdown_host,
hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_reboot_nonexistent_host(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
@@ -161,7 +162,7 @@
self.client.reboot_host,
nonexitent_hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_reboot_host_with_non_admin_user(self):
hostname = self._get_host_name()
diff --git a/tempest/api/compute/admin/test_hypervisor.py b/tempest/api/compute/admin/test_hypervisor.py
index ef4f51f..bd431d4 100644
--- a/tempest/api/compute/admin/test_hypervisor.py
+++ b/tempest/api/compute/admin/test_hypervisor.py
@@ -38,24 +38,27 @@
self.assertEqual(200, resp.status)
return hypers
+ def assertHypervisors(self, hypers):
+ self.assertTrue(len(hypers) > 0, "No hypervisors found: %s" % hypers)
+
@attr(type='gate')
def test_get_hypervisor_list(self):
# List of hypervisor and available hypervisors hostname
hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
+ self.assertHypervisors(hypers)
@attr(type='gate')
def test_get_hypervisor_list_details(self):
# Display the details of the all hypervisor
resp, hypers = self.client.get_hypervisor_list_details()
self.assertEqual(200, resp.status)
- self.assertTrue(len(hypers) > 0)
+ self.assertHypervisors(hypers)
@attr(type='gate')
def test_get_hypervisor_show_details(self):
# Display the details of the specified hypervisor
hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
+ self.assertHypervisors(hypers)
resp, details = (self.client.
get_hypervisor_show_details(hypers[0]['id']))
@@ -68,7 +71,7 @@
def test_get_hypervisor_show_servers(self):
# Show instances about the specific hypervisors
hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
+ self.assertHypervisors(hypers)
hostname = hypers[0]['hypervisor_hostname']
resp, hypervisors = self.client.get_hypervisor_servers(hostname)
@@ -87,18 +90,29 @@
# Verify that GET shows the specified hypervisor uptime
hypers = self._list_hypervisors()
- resp, uptime = self.client.get_hypervisor_uptime(hypers[0]['id'])
- self.assertEqual(200, resp.status)
- self.assertTrue(len(uptime) > 0)
+ has_valid_uptime = False
+ for hyper in hypers:
+ # because hypervisors might be disabled, this loops looking
+ # for any good hit.
+ try:
+ resp, uptime = self.client.get_hypervisor_uptime(hyper['id'])
+ if (resp.status == 200) and (len(uptime) > 0):
+ has_valid_uptime = True
+ break
+ except Exception:
+ pass
+ self.assertTrue(
+ has_valid_uptime,
+ "None of the hypervisors had a valid uptime: %s" % hypers)
@attr(type='gate')
def test_search_hypervisor(self):
hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
+ self.assertHypervisors(hypers)
resp, hypers = self.client.search_hypervisor(
hypers[0]['hypervisor_hostname'])
self.assertEqual(200, resp.status)
- self.assertTrue(len(hypers) > 0)
+ self.assertHypervisors(hypers)
class HypervisorAdminTestXML(HypervisorAdminTestJSON):
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index f49aae4..66d41b8 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -22,6 +22,8 @@
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class QuotasAdminTestJSON(base.BaseV2ComputeAdminTest):
_interface = 'json'
@@ -156,7 +158,7 @@
self.assertRaises(exceptions.OverLimit, self.create_test_server)
@skip_because(bug="1186354",
- condition=config.TempestConfig().service_available.neutron)
+ 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
@@ -180,7 +182,7 @@
"sg-overlimit", "sg-desc")
@skip_because(bug="1186354",
- condition=config.TempestConfig().service_available.neutron)
+ 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
diff --git a/tempest/api/compute/admin/test_security_groups.py b/tempest/api/compute/admin/test_security_groups.py
index 5ed4823..da2a1a1 100644
--- a/tempest/api/compute/admin/test_security_groups.py
+++ b/tempest/api/compute/admin/test_security_groups.py
@@ -22,6 +22,8 @@
from tempest import config
from tempest.test import attr
+CONF = config.CONF
+
class SecurityGroupsTestAdminJSON(base.BaseV2ComputeAdminTest):
_interface = 'json'
@@ -40,7 +42,7 @@
self.assertEqual(202, resp.status)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
+ @testtools.skipIf(CONF.service_available.neutron,
"Skipped because neutron do not support all_tenants"
"search filter.")
@attr(type='smoke')
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 9cb425a..73d274c 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -260,6 +260,7 @@
cls.servers_client = cls.os.servers_v3_client
cls.images_client = cls.os.image_client
+ cls.flavors_client = cls.os.flavors_v3_client
cls.services_client = cls.os.services_v3_client
cls.extensions_client = cls.os.extensions_v3_client
cls.availability_zone_client = cls.os.availability_zone_v3_client
@@ -268,6 +269,7 @@
cls.tenant_usages_client = cls.os.tenant_usages_v3_client
cls.volumes_client = cls.os.volumes_client
cls.certificates_client = cls.os.certificates_v3_client
+ cls.keypairs_client = cls.os.keypairs_v3_client
@classmethod
def create_image_from_server(cls, server_id, **kwargs):
@@ -332,3 +334,4 @@
cls.os_adm.availability_zone_v3_client
cls.hypervisor_admin_client = cls.os_adm.hypervisor_v3_client
cls.tenant_usages_admin_client = cls.os_adm.tenant_usages_v3_client
+ cls.flavors_admin_client = cls.os_adm.flavors_v3_client
diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index 6e4c8cb..c711bd5 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -17,13 +17,14 @@
import testtools
-from tempest.api import compute
from tempest.api.compute import base
from tempest import clients
from tempest.common.utils import data_utils
+from tempest import config
from tempest.openstack.common import log as logging
from tempest.test import attr
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -84,7 +85,7 @@
resp, flavor = self.flavors_client.get_flavor_details(flavor_id)
return flavor['disk']
- @testtools.skipUnless(compute.CREATE_IMAGE_ENABLED,
+ @testtools.skipUnless(CONF.compute_feature_enabled.create_image,
'Environment unable to create images.')
@attr(type='smoke')
def test_create_delete_image(self):
diff --git a/tempest/api/compute/security_groups/test_security_group_rules_negative.py b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
index 1c38268..c0b202d 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules_negative.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
@@ -24,6 +24,8 @@
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class SecurityGroupRulesNegativeTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
@@ -34,7 +36,7 @@
cls.client = cls.security_groups_client
@skip_because(bug="1182384",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type=['negative', 'smoke'])
def test_create_security_group_rule_with_non_existent_id(self):
# Negative test: Creation of Security Group rule should FAIL
@@ -48,7 +50,7 @@
self.client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
+ @testtools.skipIf(CONF.service_available.neutron,
"Neutron not check the security_group_id")
@attr(type=['negative', 'smoke'])
def test_create_security_group_rule_with_invalid_id(self):
@@ -168,7 +170,7 @@
secgroup_id, ip_protocol, from_port, to_port)
@skip_because(bug="1182384",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type=['negative', 'smoke'])
def test_delete_security_group_rule_with_non_existent_id(self):
# Negative test: Deletion of Security Group rule should be FAIL
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index 7cb96af..95e9171 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -25,6 +25,8 @@
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class SecurityGroupsTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
@@ -129,7 +131,7 @@
non_exist_id)
@skip_because(bug="1161411",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_group_create_with_invalid_group_name(self):
# Negative test: Security Group should not be created with group name
@@ -149,7 +151,7 @@
s_description)
@skip_because(bug="1161411",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_group_create_with_invalid_group_description(self):
# Negative test:Security Group should not be created with description
@@ -167,7 +169,7 @@
self.client.create_security_group, s_name,
s_description)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
+ @testtools.skipIf(CONF.service_available.neutron,
"Neutron allows duplicate names for security groups")
@attr(type=['negative', 'gate'])
def test_security_group_create_with_duplicate_name(self):
diff --git a/tempest/api/compute/servers/test_attach_interfaces.py b/tempest/api/compute/servers/test_attach_interfaces.py
index a177cea..dbb7d75 100644
--- a/tempest/api/compute/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/servers/test_attach_interfaces.py
@@ -92,7 +92,7 @@
self.assertEqual(sorted(list1), sorted(list2))
- @attr(type='gate')
+ @attr(type='smoke')
def test_create_list_show_delete_interfaces(self):
server, ifs = self._create_server_get_interfaces()
interface_count = len(ifs)
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index cbd0eb1..5d62e1b 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -20,17 +20,18 @@
import netaddr
import testtools
-from tempest.api import compute
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest.test import attr
+CONF = config.CONF
+
class ServersTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ run_ssh = CONF.compute.run_ssh
disk_config = 'AUTO'
@classmethod
@@ -113,7 +114,7 @@
@classmethod
def setUpClass(cls):
- if not compute.DISK_CONFIG_ENABLED:
+ if not CONF.compute_feature_enabled.disk_config:
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
super(ServersTestManualDisk, cls).setUpClass()
diff --git a/tempest/api/compute/servers/test_disk_config.py b/tempest/api/compute/servers/test_disk_config.py
index 0121c42..358728e 100644
--- a/tempest/api/compute/servers/test_disk_config.py
+++ b/tempest/api/compute/servers/test_disk_config.py
@@ -17,17 +17,19 @@
import testtools
-from tempest.api import compute
from tempest.api.compute import base
+from tempest import config
from tempest.test import attr
+CONF = config.CONF
+
class ServerDiskConfigTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
- if not compute.DISK_CONFIG_ENABLED:
+ if not CONF.compute_feature_enabled.disk_config:
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
super(ServerDiskConfigTestJSON, cls).setUpClass()
@@ -85,7 +87,8 @@
else:
return self.flavor_ref
- @testtools.skipUnless(compute.RESIZE_AVAILABLE, 'Resize not available.')
+ @testtools.skipUnless(CONF.compute_feature_enabled.resize,
+ 'Resize not available.')
@attr(type='gate')
def test_resize_server_from_manual_to_auto(self):
# A server should be resized from manual to auto disk config
@@ -101,7 +104,8 @@
resp, server = self.client.get_server(self.server_id)
self.assertEqual('AUTO', server['OS-DCF:diskConfig'])
- @testtools.skipUnless(compute.RESIZE_AVAILABLE, 'Resize not available.')
+ @testtools.skipUnless(CONF.compute_feature_enabled.resize,
+ 'Resize not available.')
@attr(type='gate')
def test_resize_server_from_auto_to_manual(self):
# A server should be resized from auto to manual disk config
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index 4cbf94d..3748e37 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -23,6 +23,8 @@
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class ListServerFiltersTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
@@ -210,7 +212,7 @@
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
@skip_because(bug="1182883",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type='gate')
def test_list_servers_filtered_by_ip_regex(self):
# Filter servers by regex ip
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index e009888..d985d2b 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -20,21 +20,21 @@
import testtools
-from tempest.api import compute
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest import exceptions
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class ServerActionsTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
- resize_available = tempest.config.TempestConfig().\
- compute_feature_enabled.resize
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ resize_available = CONF.compute_feature_enabled.resize
+ run_ssh = CONF.compute.run_ssh
def setUp(self):
# NOTE(afazekas): Normally we use the same server with all test cases,
@@ -53,7 +53,7 @@
cls.client = cls.servers_client
cls.server_id = cls.rebuild_server(None)
- @testtools.skipUnless(compute.CHANGE_PASSWORD_AVAILABLE,
+ @testtools.skipUnless(CONF.compute_feature_enabled.change_password,
'Change password not available.')
@attr(type='gate')
def test_change_server_password(self):
diff --git a/tempest/api/compute/servers/test_virtual_interfaces.py b/tempest/api/compute/servers/test_virtual_interfaces.py
index 77ada0b..968ae47 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces.py
@@ -18,17 +18,14 @@
import netaddr
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
+from tempest import test
class VirtualInterfacesTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
- CONF = config.TempestConfig()
+ CONF = config.CONF
@classmethod
def setUpClass(cls):
@@ -37,9 +34,9 @@
resp, server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
- @skip_because(bug="1183436",
- condition=CONF.service_available.neutron)
- @attr(type='gate')
+ @test.skip_because(bug="1183436",
+ condition=CONF.service_available.neutron)
+ @test.attr(type='gate')
def test_list_virtual_interfaces(self):
# Positive test:Should be able to GET the virtual interfaces list
# for a given server_id
@@ -54,15 +51,6 @@
self.assertTrue(netaddr.valid_mac(mac_address),
"Invalid mac address detected.")
- @attr(type=['negative', 'gate'])
- def test_list_virtual_interfaces_invalid_server_id(self):
- # Negative test: Should not be able to GET virtual interfaces
- # for an invalid server_id
- invalid_server_id = data_utils.rand_name('!@#$%^&*()')
- self.assertRaises(exceptions.NotFound,
- self.client.list_virtual_interfaces,
- invalid_server_id)
-
class VirtualInterfacesTestXML(VirtualInterfacesTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/servers/test_virtual_interfaces_negative.py b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
new file mode 100644
index 0000000..a2a6c11
--- /dev/null
+++ b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
@@ -0,0 +1,44 @@
+# 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 uuid
+
+from tempest.api.compute import base
+from tempest import exceptions
+from tempest import test
+
+
+class VirtualInterfacesNegativeTestJSON(base.BaseV2ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(VirtualInterfacesNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.servers_client
+
+ @test.attr(type=['negative', 'gate'])
+ def test_list_virtual_interfaces_invalid_server_id(self):
+ # Negative test: Should not be able to GET virtual interfaces
+ # for an invalid server_id
+ invalid_server_id = str(uuid.uuid4())
+ self.assertRaises(exceptions.NotFound,
+ self.client.list_virtual_interfaces,
+ invalid_server_id)
+
+
+class VirtualInterfacesNegativeTestXML(VirtualInterfacesNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/test_auth_token.py b/tempest/api/compute/test_auth_token.py
index ffeede8..e52c415 100644
--- a/tempest/api/compute/test_auth_token.py
+++ b/tempest/api/compute/test_auth_token.py
@@ -18,6 +18,8 @@
from tempest.api.compute import base
import tempest.config as config
+CONF = config.CONF
+
class AuthTokenTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
@@ -37,7 +39,7 @@
# picking list_servers because it's easy.
self.servers_v2.list_servers()
- @testtools.skipIf(not config.TempestConfig().identity.uri_v3,
+ @testtools.skipIf(not CONF.identity.uri_v3,
'v3 auth client not configured')
def test_v3_token(self):
# Can get a token using v3 of the identity API and use that to perform
diff --git a/tempest/api/compute/test_live_block_migration.py b/tempest/api/compute/test_live_block_migration.py
index a7b6cd2..d2a3d28 100644
--- a/tempest/api/compute/test_live_block_migration.py
+++ b/tempest/api/compute/test_live_block_migration.py
@@ -30,7 +30,7 @@
_host_key = 'OS-EXT-SRV-ATTR:host'
_interface = 'json'
- CONF = config.TempestConfig()
+ CONF = config.CONF
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/v3/admin/test_flavors_access.py b/tempest/api/compute/v3/admin/test_flavors_access.py
index 048312b..86194af 100644
--- a/tempest/api/compute/v3/admin/test_flavors_access.py
+++ b/tempest/api/compute/v3/admin/test_flavors_access.py
@@ -20,7 +20,7 @@
from tempest import test
-class FlavorsAccessTestJSON(base.BaseV2ComputeAdminTest):
+class FlavorsAccessV3TestJSON(base.BaseV3ComputeAdminTest):
"""
Tests Flavor Access API extension.
@@ -31,19 +31,15 @@
@classmethod
def setUpClass(cls):
- super(FlavorsAccessTestJSON, cls).setUpClass()
- if not test.is_extension_enabled('FlavorExtraData', 'compute'):
- msg = "FlavorExtraData extension not enabled."
- raise cls.skipException(msg)
+ super(FlavorsAccessV3TestJSON, cls).setUpClass()
- cls.client = cls.os_adm.flavors_client
+ cls.client = cls.flavors_admin_client
admin_client = cls._get_identity_admin_client()
cls.tenant = admin_client.get_tenant_by_name(cls.flavors_client.
tenant_name)
cls.tenant_id = cls.tenant['id']
- cls.adm_tenant = admin_client.get_tenant_by_name(cls.os_adm.
- flavors_client.
- tenant_name)
+ cls.adm_tenant = admin_client.get_tenant_by_name(
+ cls.flavors_admin_client.tenant_name)
cls.adm_tenant_id = cls.adm_tenant['id']
cls.flavor_name_prefix = 'test_flavor_access_'
cls.ram = 512
@@ -61,7 +57,7 @@
new_flavor_id,
is_public='False')
self.addCleanup(self.client.delete_flavor, new_flavor['id'])
- self.assertEqual(resp.status, 200)
+ self.assertEqual(resp.status, 201)
resp, flavor_access = self.client.list_flavor_access(new_flavor_id)
self.assertEqual(resp.status, 200)
self.assertEqual(len(flavor_access), 1, str(flavor_access))
@@ -107,5 +103,5 @@
self.assertNotIn(new_flavor['id'], map(lambda x: x['id'], flavors))
-class FlavorsAdminTestXML(FlavorsAccessTestJSON):
+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 976124e..df6557e 100644
--- a/tempest/api/compute/v3/admin/test_flavors_access_negative.py
+++ b/tempest/api/compute/v3/admin/test_flavors_access_negative.py
@@ -23,7 +23,7 @@
from tempest import test
-class FlavorsAccessNegativeTestJSON(base.BaseV2ComputeAdminTest):
+class FlavorsAccessNegativeV3TestJSON(base.BaseV3ComputeAdminTest):
"""
Tests Flavor Access API extension.
@@ -34,19 +34,15 @@
@classmethod
def setUpClass(cls):
- super(FlavorsAccessNegativeTestJSON, cls).setUpClass()
- if not test.is_extension_enabled('FlavorExtraData', 'compute'):
- msg = "FlavorExtraData extension not enabled."
- raise cls.skipException(msg)
+ super(FlavorsAccessNegativeV3TestJSON, cls).setUpClass()
- cls.client = cls.os_adm.flavors_client
+ cls.client = cls.flavors_admin_client
admin_client = cls._get_identity_admin_client()
cls.tenant = admin_client.get_tenant_by_name(cls.flavors_client.
tenant_name)
cls.tenant_id = cls.tenant['id']
- cls.adm_tenant = admin_client.get_tenant_by_name(cls.os_adm.
- flavors_client.
- tenant_name)
+ cls.adm_tenant = admin_client.get_tenant_by_name(
+ cls.flavors_admin_client.tenant_name)
cls.adm_tenant_id = cls.adm_tenant['id']
cls.flavor_name_prefix = 'test_flavor_access_'
cls.ram = 512
@@ -64,7 +60,7 @@
new_flavor_id,
is_public='True')
self.addCleanup(self.client.delete_flavor, new_flavor['id'])
- self.assertEqual(resp.status, 200)
+ self.assertEqual(resp.status, 201)
self.assertRaises(exceptions.NotFound,
self.client.list_flavor_access,
new_flavor_id)
@@ -148,5 +144,5 @@
str(uuid.uuid4()))
-class FlavorsAdminNegativeTestXML(FlavorsAccessNegativeTestJSON):
+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 875f742..d745829 100644
--- a/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
@@ -20,7 +20,7 @@
from tempest import test
-class FlavorsExtraSpecsTestJSON(base.BaseV2ComputeAdminTest):
+class FlavorsExtraSpecsV3TestJSON(base.BaseV3ComputeAdminTest):
"""
Tests Flavor Extra Spec API extension.
@@ -32,12 +32,9 @@
@classmethod
def setUpClass(cls):
- super(FlavorsExtraSpecsTestJSON, cls).setUpClass()
- if not test.is_extension_enabled('FlavorExtraData', 'compute'):
- msg = "FlavorExtraData extension not enabled."
- raise cls.skipException(msg)
+ super(FlavorsExtraSpecsV3TestJSON, cls).setUpClass()
- cls.client = cls.os_adm.flavors_client
+ cls.client = cls.flavors_admin_client
flavor_name = data_utils.rand_name('test_flavor')
ram = 512
vcpus = 1
@@ -58,7 +55,7 @@
def tearDownClass(cls):
resp, body = cls.client.delete_flavor(cls.flavor['id'])
cls.client.wait_for_resource_deletion(cls.flavor['id'])
- super(FlavorsExtraSpecsTestJSON, cls).tearDownClass()
+ super(FlavorsExtraSpecsV3TestJSON, cls).tearDownClass()
@test.attr(type='gate')
def test_flavor_set_get_update_show_unset_keys(self):
@@ -69,7 +66,7 @@
# SET extra specs to the flavor created in setUp
set_resp, set_body = \
self.client.set_flavor_extra_spec(self.flavor['id'], specs)
- self.assertEqual(set_resp.status, 200)
+ self.assertEqual(set_resp.status, 201)
self.assertEqual(set_body, specs)
# GET extra specs and verify
get_resp, get_body = \
@@ -95,10 +92,10 @@
# UNSET extra specs that were set in this test
unset_resp, _ = \
self.client.unset_flavor_extra_spec(self.flavor['id'], "key1")
- self.assertEqual(unset_resp.status, 200)
+ self.assertEqual(unset_resp.status, 204)
unset_resp, _ = \
self.client.unset_flavor_extra_spec(self.flavor['id'], "key2")
- self.assertEqual(unset_resp.status, 200)
+ self.assertEqual(unset_resp.status, 204)
@test.attr(type='gate')
def test_flavor_non_admin_get_all_keys(self):
@@ -117,7 +114,7 @@
specs = {"key1": "value1", "key2": "value2"}
resp, body = self.client.set_flavor_extra_spec(
self.flavor['id'], specs)
- self.assertEqual(resp.status, 200)
+ self.assertEqual(resp.status, 201)
self.assertEqual(body['key1'], 'value1')
self.assertIn('key2', body)
resp, body = self.flavors_client.get_flavor_extra_spec_with_key(
@@ -127,5 +124,5 @@
self.assertNotIn('key2', body)
-class FlavorsExtraSpecsTestXML(FlavorsExtraSpecsTestJSON):
+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 fb09a63..1d5e447 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
@@ -22,7 +22,7 @@
from tempest import test
-class FlavorsExtraSpecsNegativeTestJSON(base.BaseV2ComputeAdminTest):
+class FlavorsExtraSpecsNegativeV3TestJSON(base.BaseV3ComputeAdminTest):
"""
Negative Tests Flavor Extra Spec API extension.
@@ -33,12 +33,9 @@
@classmethod
def setUpClass(cls):
- super(FlavorsExtraSpecsNegativeTestJSON, cls).setUpClass()
- if not test.is_extension_enabled('FlavorExtraData', 'compute'):
- msg = "FlavorExtraData extension not enabled."
- raise cls.skipException(msg)
+ super(FlavorsExtraSpecsNegativeV3TestJSON, cls).setUpClass()
- cls.client = cls.os_adm.flavors_client
+ cls.client = cls.flavors_admin_client
flavor_name = data_utils.rand_name('test_flavor')
ram = 512
vcpus = 1
@@ -59,7 +56,7 @@
def tearDownClass(cls):
resp, body = cls.client.delete_flavor(cls.flavor['id'])
cls.client.wait_for_resource_deletion(cls.flavor['id'])
- super(FlavorsExtraSpecsNegativeTestJSON, cls).tearDownClass()
+ super(FlavorsExtraSpecsNegativeV3TestJSON, cls).tearDownClass()
@test.attr(type=['negative', 'gate'])
def test_flavor_non_admin_set_keys(self):
@@ -76,7 +73,7 @@
specs = {"key1": "value1", "key2": "value2"}
resp, body = self.client.set_flavor_extra_spec(
self.flavor['id'], specs)
- self.assertEqual(resp.status, 200)
+ self.assertEqual(resp.status, 201)
self.assertEqual(body['key1'], 'value1')
self.assertRaises(exceptions.Unauthorized,
self.flavors_client.
@@ -131,5 +128,5 @@
key2="value")
-class FlavorsExtraSpecsNegativeTestXML(FlavorsExtraSpecsNegativeTestJSON):
+class FlavorsExtraSpecsNegativeV3TestXML(FlavorsExtraSpecsNegativeV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_quotas.py b/tempest/api/compute/v3/admin/test_quotas.py
index f49aae4..66d41b8 100644
--- a/tempest/api/compute/v3/admin/test_quotas.py
+++ b/tempest/api/compute/v3/admin/test_quotas.py
@@ -22,6 +22,8 @@
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class QuotasAdminTestJSON(base.BaseV2ComputeAdminTest):
_interface = 'json'
@@ -156,7 +158,7 @@
self.assertRaises(exceptions.OverLimit, self.create_test_server)
@skip_because(bug="1186354",
- condition=config.TempestConfig().service_available.neutron)
+ 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
@@ -180,7 +182,7 @@
"sg-overlimit", "sg-desc")
@skip_because(bug="1186354",
- condition=config.TempestConfig().service_available.neutron)
+ 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
diff --git a/tempest/api/compute/v3/admin/test_services.py b/tempest/api/compute/v3/admin/test_services.py
index 64135ed..602f914 100644
--- a/tempest/api/compute/v3/admin/test_services.py
+++ b/tempest/api/compute/v3/admin/test_services.py
@@ -17,7 +17,6 @@
# under the License.
from tempest.api.compute import base
-from tempest import exceptions
from tempest.test import attr
@@ -33,7 +32,6 @@
def setUpClass(cls):
super(ServicesAdminV3TestJSON, cls).setUpClass()
cls.client = cls.services_admin_client
- cls.non_admin_client = cls.services_client
@attr(type='gate')
def test_list_services(self):
@@ -41,11 +39,6 @@
self.assertEqual(200, resp.status)
self.assertNotEqual(0, len(services))
- @attr(type=['negative', 'gate'])
- def test_list_services_with_non_admin_user(self):
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.list_services)
-
@attr(type='gate')
def test_get_service_by_service_binary_name(self):
binary_name = 'nova-compute'
@@ -74,15 +67,6 @@
# on order.
self.assertEqual(sorted(s1), sorted(s2))
- @attr(type=['negative', 'gate'])
- def test_get_service_by_invalid_params(self):
- # return all services if send the request with invalid parameter
- resp, services = self.client.list_services()
- params = {'xxx': 'nova-compute'}
- resp, services_xxx = self.client.list_services(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(len(services), len(services_xxx))
-
@attr(type='gate')
def test_get_service_by_service_and_host_name(self):
resp, services = self.client.list_services()
@@ -95,24 +79,6 @@
self.assertEqual(host_name, services[0]['host'])
self.assertEqual(binary_name, services[0]['binary'])
- @attr(type=['negative', 'gate'])
- def test_get_service_by_invalid_service_and_valid_host(self):
- resp, services = self.client.list_services()
- host_name = services[0]['host']
- params = {'host': host_name, 'binary': 'xxx'}
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(0, len(services))
-
- @attr(type=['negative', 'gate'])
- def test_get_service_with_valid_service_and_invalid_host(self):
- resp, services = self.client.list_services()
- binary_name = services[0]['binary']
- params = {'host': 'xxx', 'binary': binary_name}
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(0, len(services))
-
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
new file mode 100644
index 0000000..337c051
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_services_negative.py
@@ -0,0 +1,72 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 NEC Corporation
+# Copyright 2013 IBM Corp.
+# 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 import exceptions
+from tempest.test import attr
+
+
+class ServicesAdminNegativeV3TestJSON(base.BaseV3ComputeAdminTest):
+
+ """
+ Tests Services API. List and Enable/Disable require admin privileges.
+ """
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ServicesAdminNegativeV3TestJSON, cls).setUpClass()
+ cls.client = cls.services_admin_client
+ cls.non_admin_client = cls.services_client
+
+ @attr(type=['negative', 'gate'])
+ def test_list_services_with_non_admin_user(self):
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.list_services)
+
+ @attr(type=['negative', 'gate'])
+ def test_get_service_by_invalid_params(self):
+ # return all services if send the request with invalid parameter
+ resp, services = self.client.list_services()
+ params = {'xxx': 'nova-compute'}
+ resp, services_xxx = self.client.list_services(params)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(len(services), len(services_xxx))
+
+ @attr(type=['negative', 'gate'])
+ def test_get_service_by_invalid_service_and_valid_host(self):
+ resp, services = self.client.list_services()
+ host_name = services[0]['host']
+ params = {'host': host_name, 'binary': 'xxx'}
+ resp, services = self.client.list_services(params)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(0, len(services))
+
+ @attr(type=['negative', 'gate'])
+ def test_get_service_with_valid_service_and_invalid_host(self):
+ resp, services = self.client.list_services()
+ binary_name = services[0]['binary']
+ params = {'host': 'xxx', 'binary': binary_name}
+ 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/keypairs/test_keypairs.py b/tempest/api/compute/v3/keypairs/test_keypairs.py
index b36595c..029633f 100644
--- a/tempest/api/compute/v3/keypairs/test_keypairs.py
+++ b/tempest/api/compute/v3/keypairs/test_keypairs.py
@@ -20,17 +20,17 @@
from tempest import test
-class KeyPairsTestJSON(base.BaseV2ComputeTest):
+class KeyPairsV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
- super(KeyPairsTestJSON, cls).setUpClass()
+ super(KeyPairsV3TestJSON, cls).setUpClass()
cls.client = cls.keypairs_client
def _delete_keypair(self, keypair_name):
resp, _ = self.client.delete_keypair(keypair_name)
- self.assertEqual(202, resp.status)
+ self.assertEqual(204, resp.status)
def _create_keypair(self, keypair_name, pub_key=None):
resp, body = self.client.create_keypair(keypair_name, pub_key)
@@ -49,7 +49,7 @@
# as the keypair dicts from list API doesn't have them.
keypair.pop('private_key')
keypair.pop('user_id')
- self.assertEqual(200, resp.status)
+ self.assertEqual(201, resp.status)
key_list.append(keypair)
# Fetch all keypairs and verify the list
# has all created keypairs
@@ -72,7 +72,7 @@
# Keypair should be created, verified and deleted
k_name = data_utils.rand_name('keypair-')
resp, keypair = self._create_keypair(k_name)
- self.assertEqual(200, resp.status)
+ self.assertEqual(201, resp.status)
private_key = keypair['private_key']
key_name = keypair['name']
self.assertEqual(key_name, k_name,
@@ -111,7 +111,7 @@
"XcPojYN56tI0OlrGqojbediJYD0rUsJu4weZpbn8vilb3JuDY+jws"
"snSA8wzBx3A/8y9Pp1B nova@ubuntu")
resp, keypair = self._create_keypair(k_name, pub_key)
- self.assertEqual(200, resp.status)
+ self.assertEqual(201, resp.status)
self.assertFalse('private_key' in keypair,
"Field private_key is not empty!")
key_name = keypair['name']
@@ -120,5 +120,5 @@
"to the requested name!")
-class KeyPairsTestXML(KeyPairsTestJSON):
+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 621487c..edc0c26 100644
--- a/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
@@ -22,12 +22,12 @@
from tempest import test
-class KeyPairsNegativeTestJSON(base.BaseV2ComputeTest):
+class KeyPairsNegativeV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
- super(KeyPairsNegativeTestJSON, cls).setUpClass()
+ super(KeyPairsNegativeV3TestJSON, cls).setUpClass()
cls.client = cls.keypairs_client
def _create_keypair(self, keypair_name, pub_key=None):
@@ -70,12 +70,11 @@
# Keypairs with duplicate names should not be created
k_name = data_utils.rand_name('keypair-')
resp, _ = self.client.create_keypair(k_name)
- self.assertEqual(200, resp.status)
+ self.addCleanup(self.client.delete_keypair, k_name)
+ self.assertEqual(201, resp.status)
# Now try the same keyname to create another key
self.assertRaises(exceptions.Conflict, self._create_keypair,
k_name)
- resp, _ = self.client.delete_keypair(k_name)
- self.assertEqual(202, resp.status)
@test.attr(type=['negative', 'gate'])
def test_create_keypair_with_empty_name_string(self):
@@ -98,5 +97,5 @@
k_name)
-class KeyPairsNegativeTestXML(KeyPairsNegativeTestJSON):
+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 f208a4b..d12f708 100644
--- a/tempest/api/compute/v3/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/v3/servers/test_attach_interfaces.py
@@ -92,7 +92,7 @@
self.assertEqual(sorted(list1), sorted(list2))
- @attr(type='gate')
+ @attr(type='smoke')
def test_create_list_show_delete_interfaces(self):
server, ifs = self._create_server_get_interfaces()
interface_count = len(ifs)
diff --git a/tempest/api/compute/v3/servers/test_attach_volume.py b/tempest/api/compute/v3/servers/test_attach_volume.py
new file mode 100644
index 0000000..a030584
--- /dev/null
+++ b/tempest/api/compute/v3/servers/test_attach_volume.py
@@ -0,0 +1,120 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 IBM Corp.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import testtools
+
+from tempest.api.compute import base
+from tempest.common.utils.linux.remote_client import RemoteClient
+from tempest import config
+from tempest.test import attr
+
+CONF = config.CONF
+
+
+class AttachVolumeV3TestJSON(base.BaseV3ComputeTest):
+ _interface = 'json'
+ run_ssh = CONF.compute.run_ssh
+
+ def __init__(self, *args, **kwargs):
+ super(AttachVolumeV3TestJSON, self).__init__(*args, **kwargs)
+ self.server = None
+ self.volume = None
+ self.attached = False
+
+ @classmethod
+ def setUpClass(cls):
+ super(AttachVolumeV3TestJSON, cls).setUpClass()
+ cls.device = cls.config.compute.volume_device_name
+ if not cls.config.service_available.cinder:
+ skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ def _detach(self, server_id, volume_id):
+ if self.attached:
+ self.servers_client.detach_volume(server_id, volume_id)
+ self.volumes_client.wait_for_volume_status(volume_id, 'available')
+
+ def _delete_volume(self):
+ if self.volume:
+ self.volumes_client.delete_volume(self.volume['id'])
+ self.volume = None
+
+ def _create_and_attach(self):
+ # Start a server and wait for it to become ready
+ admin_pass = self.image_ssh_password
+ resp, server = self.create_test_server(wait_until='ACTIVE',
+ admin_password=admin_pass)
+ self.server = server
+
+ # Record addresses so that we can ssh later
+ resp, server['addresses'] = \
+ self.servers_client.list_addresses(server['id'])
+
+ # Create a volume and wait for it to become ready
+ resp, volume = self.volumes_client.create_volume(1,
+ display_name='test')
+ self.volume = volume
+ self.addCleanup(self._delete_volume)
+ self.volumes_client.wait_for_volume_status(volume['id'], 'available')
+
+ # Attach the volume to the server
+ self.servers_client.attach_volume(server['id'], volume['id'],
+ device='/dev/%s' % self.device)
+ self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
+
+ self.attached = True
+ self.addCleanup(self._detach, server['id'], volume['id'])
+
+ @testtools.skipIf(not run_ssh, 'SSH required for this test')
+ @attr(type='gate')
+ def test_attach_detach_volume(self):
+ # Stop and Start a server with an attached volume, ensuring that
+ # the volume remains attached.
+ self._create_and_attach()
+ server = self.server
+ volume = self.volume
+
+ self.servers_client.stop(server['id'])
+ self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')
+
+ self.servers_client.start(server['id'])
+ self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+
+ linux_client = RemoteClient(server,
+ self.image_ssh_user,
+ server['admin_password'])
+ partitions = linux_client.get_partitions()
+ self.assertIn(self.device, partitions)
+
+ self._detach(server['id'], volume['id'])
+ self.attached = False
+
+ self.servers_client.stop(server['id'])
+ self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')
+
+ self.servers_client.start(server['id'])
+ self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+
+ linux_client = RemoteClient(server,
+ self.image_ssh_user,
+ 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 24ade96..94175ab 100644
--- a/tempest/api/compute/v3/servers/test_create_server.py
+++ b/tempest/api/compute/v3/servers/test_create_server.py
@@ -20,17 +20,18 @@
import netaddr
import testtools
-from tempest.api import compute
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest.test import attr
+CONF = config.CONF
+
class ServersTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ run_ssh = CONF.compute.run_ssh
disk_config = 'AUTO'
@classmethod
@@ -120,7 +121,7 @@
@classmethod
def setUpClass(cls):
- if not compute.DISK_CONFIG_ENABLED:
+ if not CONF.compute_feature_enabled.disk_config:
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
super(ServersTestManualDisk, cls).setUpClass()
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 d333a1d..3dd7b0b 100644
--- a/tempest/api/compute/v3/servers/test_list_server_filters.py
+++ b/tempest/api/compute/v3/servers/test_list_server_filters.py
@@ -23,6 +23,8 @@
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class ListServerFiltersV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
@@ -211,7 +213,7 @@
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
@skip_because(bug="1182883",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type='gate')
def test_list_servers_filtered_by_ip_regex(self):
# Filter servers by regex ip
diff --git a/tempest/api/compute/v3/servers/test_server_actions.py b/tempest/api/compute/v3/servers/test_server_actions.py
index ee37502..602bd5b 100644
--- a/tempest/api/compute/v3/servers/test_server_actions.py
+++ b/tempest/api/compute/v3/servers/test_server_actions.py
@@ -20,21 +20,21 @@
import testtools
-from tempest.api import compute
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest import exceptions
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class ServerActionsV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
- resize_available = tempest.config.TempestConfig().\
- compute_feature_enabled.resize
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ resize_available = CONF.compute_feature_enabled.resize
+ run_ssh = CONF.compute.run_ssh
def setUp(self):
# NOTE(afazekas): Normally we use the same server with all test cases,
@@ -53,7 +53,7 @@
cls.client = cls.servers_client
cls.server_id = cls.rebuild_server(None)
- @testtools.skipUnless(compute.CHANGE_PASSWORD_AVAILABLE,
+ @testtools.skipUnless(CONF.compute_feature_enabled.change_password,
'Change password not available.')
@attr(type='gate')
def test_change_server_password(self):
@@ -123,6 +123,7 @@
metadata=meta,
personality=personality,
admin_password=password)
+ self.addCleanup(self.client.rebuild, self.server_id, self.image_ref)
# Verify the properties in the initial response are correct
self.assertEqual(self.server_id, rebuilt_server['id'])
@@ -142,6 +143,35 @@
linux_client = RemoteClient(server, self.ssh_user, password)
linux_client.validate_authentication()
+ @attr(type='gate')
+ def test_rebuild_server_in_stop_state(self):
+ # The server in stop state should be rebuilt using the provided
+ # image and remain in SHUTOFF state
+ resp, server = self.client.get_server(self.server_id)
+ old_image = server['image']['id']
+ new_image = self.image_ref_alt \
+ if old_image == self.image_ref else self.image_ref
+ resp, server = self.client.stop(self.server_id)
+ self.assertEqual(202, resp.status)
+ self.client.wait_for_server_status(self.server_id, 'SHUTOFF')
+ self.addCleanup(self.client.start, self.server_id)
+ resp, rebuilt_server = self.client.rebuild(self.server_id, new_image)
+ self.addCleanup(self.client.wait_for_server_status, self.server_id,
+ 'SHUTOFF')
+ self.addCleanup(self.client.rebuild, self.server_id, old_image)
+
+ # Verify the properties in the initial response are correct
+ self.assertEqual(self.server_id, rebuilt_server['id'])
+ rebuilt_image_id = rebuilt_server['image']['id']
+ self.assertEqual(new_image, rebuilt_image_id)
+ self.assertEqual(self.flavor_ref, rebuilt_server['flavor']['id'])
+
+ # Verify the server properties after the rebuild completes
+ self.client.wait_for_server_status(rebuilt_server['id'], 'SHUTOFF')
+ resp, server = self.client.get_server(rebuilt_server['id'])
+ rebuilt_image_id = server['image']['id']
+ self.assertEqual(new_image, rebuilt_image_id)
+
def _detect_server_image_flavor(self, server_id):
# Detects the current server image flavor ref.
resp, server = self.client.get_server(self.server_id)
@@ -199,32 +229,115 @@
raise exceptions.TimeoutException(message)
@attr(type='gate')
+ 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')
+ resp, _ = self.servers_client.create_backup(self.server_id,
+ 'daily',
+ 2,
+ backup1)
+ oldest_backup_exist = True
+
+ # the oldest one should be deleted automatically in this test
+ def _clean_oldest_backup(oldest_backup):
+ if oldest_backup_exist:
+ self.images_client.delete_image(oldest_backup)
+
+ image1_id = data_utils.parse_image_id(resp['location'])
+ self.addCleanup(_clean_oldest_backup, image1_id)
+ self.assertEqual(202, resp.status)
+ self.images_client.wait_for_image_status(image1_id, 'active')
+
+ backup2 = data_utils.rand_name('backup')
+ self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+ resp, _ = self.servers_client.create_backup(self.server_id,
+ 'daily',
+ 2,
+ backup2)
+ image2_id = data_utils.parse_image_id(resp['location'])
+ self.addCleanup(self.images_client.delete_image, image2_id)
+ self.assertEqual(202, resp.status)
+ self.images_client.wait_for_image_status(image2_id, 'active')
+
+ # verify they have been created
+ properties = {
+ 'image_type': 'backup',
+ 'backup_type': "daily",
+ 'instance_uuid': self.server_id,
+ }
+ resp, image_list = self.images_client.image_list_detail(
+ properties,
+ sort_key='created_at',
+ sort_dir='asc')
+ self.assertEqual(200, resp.status)
+ self.assertEqual(2, len(image_list))
+ self.assertEqual((backup1, backup2),
+ (image_list[0]['name'], image_list[1]['name']))
+
+ # create the third one, due to the rotation is 2,
+ # the first one will be deleted
+ backup3 = data_utils.rand_name('backup')
+ self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+ resp, _ = self.servers_client.create_backup(self.server_id,
+ 'daily',
+ 2,
+ backup3)
+ image3_id = data_utils.parse_image_id(resp['location'])
+ self.addCleanup(self.images_client.delete_image, image3_id)
+ self.assertEqual(202, resp.status)
+ # the first back up should be deleted
+ self.images_client.wait_for_resource_deletion(image1_id)
+ oldest_backup_exist = False
+ resp, image_list = self.images_client.image_list_detail(
+ properties,
+ sort_key='created_at',
+ sort_dir='asc')
+ self.assertEqual(200, resp.status)
+ self.assertEqual(2, len(image_list))
+ self.assertEqual((backup2, backup3),
+ (image_list[0]['name'], image_list[1]['name']))
+
+ def _get_output(self):
+ resp, output = self.servers_client.get_console_output(
+ self.server_id, 10)
+ self.assertEqual(200, resp.status)
+ self.assertTrue(output, "Console output was empty.")
+ lines = len(output.split('\n'))
+ self.assertEqual(lines, 10)
+
+ @attr(type='gate')
def test_get_console_output(self):
# Positive test:Should be able to GET the console output
# for a given server_id and number of lines
- def get_output():
- resp, output = self.servers_client.get_console_output(
- self.server_id, 10)
- self.assertEqual(200, resp.status)
- self.assertTrue(output, "Console output was empty.")
- lines = len(output.split('\n'))
- self.assertEqual(lines, 10)
- self.wait_for(get_output)
- @skip_because(bug="1014683")
+ # This reboot is necessary for outputting some console log after
+ # creating a instance backup. If a instance backup, the console
+ # log file is truncated and we cannot get any console log through
+ # "console-log" API.
+ # The detail is https://bugs.launchpad.net/nova/+bug/1251920
+ resp, body = self.servers_client.reboot(self.server_id, 'HARD')
+ self.assertEqual(202, resp.status)
+ self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+
+ self.wait_for(self._get_output)
+
@attr(type='gate')
- def test_get_console_output_server_id_in_reboot_status(self):
+ def test_get_console_output_server_id_in_shutoff_status(self):
# Positive test:Should be able to GET the console output
- # for a given server_id in reboot status
- resp, output = self.servers_client.reboot(self.server_id, 'SOFT')
- self.servers_client.wait_for_server_status(self.server_id,
- 'REBOOT')
- resp, output = self.servers_client.get_console_output(self.server_id,
- 10)
- self.assertEqual(200, resp.status)
- self.assertIsNotNone(output)
- lines = len(output.split('\n'))
- self.assertEqual(lines, 10)
+ # for a given server_id in SHUTOFF status
+
+ # NOTE: SHUTOFF is irregular status. To avoid test instability,
+ # one server is created only for this test without using
+ # the server that was created in setupClass.
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ temp_server_id = server['id']
+
+ resp, server = self.servers_client.stop(temp_server_id)
+ self.assertEqual(202, resp.status)
+ self.servers_client.wait_for_server_status(temp_server_id, 'SHUTOFF')
+
+ self.wait_for(self._get_output)
@attr(type='gate')
def test_pause_unpause_server(self):
@@ -245,6 +358,30 @@
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
@attr(type='gate')
+ def test_shelve_unshelve_server(self):
+ resp, server = self.client.shelve_server(self.server_id)
+ self.assertEqual(202, resp.status)
+
+ offload_time = self.config.compute.shelved_offload_time
+ if offload_time >= 0:
+ self.client.wait_for_server_status(self.server_id,
+ 'SHELVED_OFFLOADED',
+ extra_timeout=offload_time)
+ else:
+ self.client.wait_for_server_status(self.server_id,
+ 'SHELVED')
+
+ resp, server = self.client.get_server(self.server_id)
+ image_name = server['name'] + '-shelved'
+ resp, images = self.images_client.image_list(name=image_name)
+ self.assertEqual(1, len(images))
+ self.assertEqual(image_name, images[0]['name'])
+
+ resp, server = self.client.unshelve_server(self.server_id)
+ self.assertEqual(202, resp.status)
+ self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+
+ @attr(type='gate')
def test_stop_start_server(self):
resp, server = self.servers_client.stop(self.server_id)
self.assertEqual(202, resp.status)
diff --git a/tempest/api/compute/v3/servers/test_servers_negative.py b/tempest/api/compute/v3/servers/test_servers_negative.py
index 6532032..85fe47c 100644
--- a/tempest/api/compute/v3/servers/test_servers_negative.py
+++ b/tempest/api/compute/v3/servers/test_servers_negative.py
@@ -25,11 +25,11 @@
from tempest import test
-class ServersNegativeTestJSON(base.BaseV2ComputeTest):
+class ServersNegativeV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
def setUp(self):
- super(ServersNegativeTestJSON, self).setUp()
+ super(ServersNegativeV3TestJSON, self).setUp()
try:
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
except Exception:
@@ -37,10 +37,10 @@
@classmethod
def setUpClass(cls):
- super(ServersNegativeTestJSON, cls).setUpClass()
+ super(ServersNegativeV3TestJSON, cls).setUpClass()
cls.client = cls.servers_client
cls.alt_os = clients.AltManager()
- cls.alt_client = cls.alt_os.servers_client
+ cls.alt_client = cls.alt_os.servers_v3_client
resp, server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
@@ -53,18 +53,6 @@
name='')
@test.attr(type=['negative', 'gate'])
- def test_personality_file_contents_not_encoded(self):
- # Use an unencoded file when creating a server with personality
-
- file_contents = 'This is a test file.'
- person = [{'path': '/etc/testfile.txt',
- 'contents': file_contents}]
-
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server,
- personality=person)
-
- @test.attr(type=['negative', 'gate'])
def test_create_with_invalid_image(self):
# Create a server with an unknown image
@@ -86,7 +74,7 @@
IPv4 = '1.1.1.1.1.1'
self.assertRaises(exceptions.BadRequest,
- self.create_test_server, accessIPv4=IPv4)
+ self.create_test_server, access_ip_v4=IPv4)
@test.attr(type=['negative', 'gate'])
def test_invalid_ip_v6_address(self):
@@ -95,7 +83,7 @@
IPv6 = 'notvalid'
self.assertRaises(exceptions.BadRequest,
- self.create_test_server, accessIPv6=IPv6)
+ self.create_test_server, access_ip_v6=IPv6)
@test.attr(type=['negative', 'gate'])
def test_resize_nonexistent_server(self):
@@ -186,12 +174,12 @@
self.create_test_server,
name=server_name)
+ @test.skip_because(bug="1208743")
@test.attr(type=['negative', 'gate'])
def test_create_with_invalid_network_uuid(self):
# Pass invalid network uuid while creating a server
networks = [{'fixed_ip': '10.0.1.1', 'uuid': 'a-b-c-d-e-f-g-h-i-j'}]
-
self.assertRaises(exceptions.BadRequest,
self.create_test_server,
networks=networks)
@@ -421,8 +409,7 @@
resp, server = self.client.get_server(self.server_id)
image_name = server['name'] + '-shelved'
- params = {'name': image_name}
- resp, images = self.images_client.list_images(params)
+ resp, images = self.images_client.image_list(name=image_name)
self.assertEqual(1, len(images))
self.assertEqual(image_name, images[0]['name'])
@@ -445,5 +432,5 @@
self.server_id)
-class ServersNegativeTestXML(ServersNegativeTestJSON):
+class ServersNegativeV3TestXML(ServersNegativeV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index 660de95..c1ebc08 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -19,13 +19,15 @@
from tempest.api.compute import base
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest.test import attr
+CONF = config.CONF
+
class AttachVolumeTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ run_ssh = CONF.compute.run_ssh
def __init__(self, *args, **kwargs):
super(AttachVolumeTestJSON, self).__init__(*args, **kwargs)
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index 6408c15..090f31f 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -25,7 +25,6 @@
class BasicOperationsImagesTest(base.BaseV2ImageTest):
-
"""
Here we test the basic operations of images
"""
@@ -95,7 +94,6 @@
class ListImagesTest(base.BaseV2ImageTest):
-
"""
Here we test the listing of image information
"""
@@ -105,31 +103,114 @@
super(ListImagesTest, cls).setUpClass()
# We add a few images here to test the listing functionality of
# the images API
- for x in xrange(0, 10):
- cls._create_standard_image(x)
+ cls._create_standard_image('bare', 'raw')
+ cls._create_standard_image('bare', 'raw')
+ cls._create_standard_image('ami', 'raw')
+ # Add some more for listing
+ cls._create_standard_image('ami', 'ami')
+ cls._create_standard_image('ari', 'ari')
+ cls._create_standard_image('aki', 'aki')
@classmethod
- def _create_standard_image(cls, number):
+ def _create_standard_image(cls, container_format, disk_format):
"""
Create a new standard image and return the ID of the newly-registered
image. Note that the size of the new image is a random number between
1024 and 4096
"""
image_file = StringIO.StringIO('*' * random.randint(1024, 4096))
- name = 'New Standard Image %s' % number
- resp, body = cls.create_image(name=name, container_format='bare',
- disk_format='raw',
+ name = data_utils.rand_name('image-')
+ resp, body = cls.create_image(name=name,
+ container_format=container_format,
+ disk_format=disk_format,
visibility='public')
image_id = body['id']
resp, body = cls.client.store_image(image_id, data=image_file)
return image_id
+ def _list_by_param_value_and_assert(self, params):
+ """
+ Perform list action with given params and validates result.
+ """
+ resp, images_list = self.client.image_list(params=params)
+ self.assertEqual(200, resp.status)
+ # Validating params of fetched images
+ for image in images_list:
+ for key in params:
+ msg = "Failed to list images by %s" % key
+ self.assertEqual(params[key], image[key], msg)
+
@attr(type='gate')
def test_index_no_params(self):
# Simple test to see all fixture images returned
resp, images_list = self.client.image_list()
self.assertEqual(resp['status'], '200')
image_list = map(lambda x: x['id'], images_list)
+
for image in self.created_images:
self.assertIn(image, image_list)
+
+ @attr(type='gate')
+ def test_list_images_param_container_format(self):
+ # Test to get all images with container_format='bare'
+ params = {"container_format": "bare"}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_list_images_param_disk_format(self):
+ # Test to get all images with disk_format = raw
+ params = {"disk_format": "raw"}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_list_images_param_visibility(self):
+ # Test to get all images with visibility = public
+ params = {"visibility": "public"}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_list_images_param_size(self):
+ # Test to get all images by size
+ image_id = self.created_images[1]
+ # Get image metadata
+ resp, image = self.client.get_image(image_id)
+ self.assertEqual(resp['status'], '200')
+
+ params = {"size": image['size']}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_list_images_param_min_max_size(self):
+ # Test to get all images with size between 2000 to 3000
+ image_id = self.created_images[1]
+ # Get image metadata
+ resp, image = self.client.get_image(image_id)
+ self.assertEqual(resp['status'], '200')
+
+ size = image['size']
+ params = {"size_min": size - 500, "size_max": size + 500}
+ resp, images_list = self.client.image_list(params=params)
+ self.assertEqual(resp['status'], '200')
+ image_size_list = map(lambda x: x['size'], images_list)
+
+ for image_size in image_size_list:
+ self.assertTrue(image_size >= params['size_min'] and
+ image_size <= params['size_max'],
+ "Failed to get images by size_min and size_max")
+
+ @attr(type='gate')
+ def test_list_images_param_status(self):
+ # Test to get all available images
+ params = {"status": "available"}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_list_images_param_limit(self):
+ # Test to get images by limit
+ params = {"limit": 2}
+ resp, images_list = self.client.image_list(params=params)
+ self.assertEqual(resp['status'], '200')
+
+ self.assertEqual(len(images_list), params['limit'],
+ "Failed to get images by limit")
diff --git a/tempest/api/network/common.py b/tempest/api/network/common.py
index 528a204..ae0eda1 100644
--- a/tempest/api/network/common.py
+++ b/tempest/api/network/common.py
@@ -102,8 +102,7 @@
self.floating_ip_address)
def __str__(self):
- return '<"FloatingIP" addr="%s" id="%s">' % (self.__class__.__name__,
- self.floating_ip_address,
+ return '<"FloatingIP" addr="%s" id="%s">' % (self.floating_ip_address,
self.id)
def delete(self):
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index 3a41f4f..7ce8ca6 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -25,7 +25,7 @@
"""
Tests the following operations in the Quantum API using the REST client for
- Quantum:
+ Neutron:
Create a Floating IP
Update a Floating IP
@@ -33,7 +33,7 @@
List all Floating IPs
Show Floating IP details
- v2.0 of the Quantum API is assumed. It is also assumed that the following
+ v2.0 of the Neutron API is assumed. It is also assumed that the following
options are defined in the [network] section of etc/tempest.conf:
public_network_id which is the id for the external network present
@@ -47,24 +47,13 @@
# Create network, subnet, router and add interface
cls.network = cls.create_network()
cls.subnet = cls.create_subnet(cls.network)
- cls.router = cls.create_router(
- data_utils.rand_name('router-'),
- external_network_id=cls.network_cfg.public_network_id)
- resp, _ = cls.client.add_router_interface_with_subnet_id(
- cls.router['id'], cls.subnet['id'])
+ cls.router = cls.create_router(data_utils.rand_name('router-'),
+ external_network_id=cls.ext_net_id)
+ cls.create_router_interface(cls.router['id'], cls.subnet['id'])
cls.port = list()
# Create two ports one each for Creation and Updating of floatingIP
for i in range(2):
- resp, port = cls.client.create_port(cls.network['id'])
- cls.port.append(port['port'])
-
- @classmethod
- def tearDownClass(cls):
- cls.client.remove_router_interface_with_subnet_id(cls.router['id'],
- cls.subnet['id'])
- for i in range(2):
- cls.client.delete_port(cls.port[i]['id'])
- super(FloatingIPTestJSON, cls).tearDownClass()
+ cls.create_port(cls.network)
def _delete_floating_ip(self, floating_ip_id):
# Deletes a floating IP and verifies if it is deleted or not
@@ -81,29 +70,29 @@
def test_create_list_show_update_delete_floating_ip(self):
# Creates a floating IP
resp, floating_ip = self.client.create_floating_ip(
- self.ext_net_id, port_id=self.port[0]['id'])
+ self.ext_net_id, port_id=self.ports[0]['id'])
self.assertEqual('201', resp['status'])
- create_floating_ip = floating_ip['floatingip']
- self.assertIsNotNone(create_floating_ip['id'])
- self.assertIsNotNone(create_floating_ip['tenant_id'])
- self.assertIsNotNone(create_floating_ip['floating_ip_address'])
- self.assertEqual(create_floating_ip['port_id'], self.port[0]['id'])
- self.assertEqual(create_floating_ip['floating_network_id'],
+ created_floating_ip = floating_ip['floatingip']
+ self.assertIsNotNone(created_floating_ip['id'])
+ self.assertIsNotNone(created_floating_ip['tenant_id'])
+ self.assertIsNotNone(created_floating_ip['floating_ip_address'])
+ self.assertEqual(created_floating_ip['port_id'], self.ports[0]['id'])
+ self.assertEqual(created_floating_ip['floating_network_id'],
self.ext_net_id)
- self.addCleanup(self._delete_floating_ip, create_floating_ip['id'])
+ self.addCleanup(self._delete_floating_ip, created_floating_ip['id'])
# Verifies the details of a floating_ip
resp, floating_ip = self.client.show_floating_ip(
- create_floating_ip['id'])
+ created_floating_ip['id'])
self.assertEqual('200', resp['status'])
- show_floating_ip = floating_ip['floatingip']
- self.assertEqual(show_floating_ip['id'], create_floating_ip['id'])
- self.assertEqual(show_floating_ip['floating_network_id'],
+ shown_floating_ip = floating_ip['floatingip']
+ self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
+ self.assertEqual(shown_floating_ip['floating_network_id'],
self.ext_net_id)
- self.assertEqual(show_floating_ip['tenant_id'],
- create_floating_ip['tenant_id'])
- self.assertEqual(show_floating_ip['floating_ip_address'],
- create_floating_ip['floating_ip_address'])
- self.assertEqual(show_floating_ip['port_id'], self.port[0]['id'])
+ self.assertEqual(shown_floating_ip['tenant_id'],
+ created_floating_ip['tenant_id'])
+ self.assertEqual(shown_floating_ip['floating_ip_address'],
+ created_floating_ip['floating_ip_address'])
+ self.assertEqual(shown_floating_ip['port_id'], self.ports[0]['id'])
# Verify the floating ip exists in the list of all floating_ips
resp, floating_ips = self.client.list_floatingips()
@@ -111,25 +100,25 @@
floatingip_id_list = list()
for f in floating_ips['floatingips']:
floatingip_id_list.append(f['id'])
- self.assertIn(create_floating_ip['id'], floatingip_id_list)
-
+ self.assertIn(created_floating_ip['id'], floatingip_id_list)
# Associate floating IP to the other port
resp, floating_ip = self.client.update_floating_ip(
- create_floating_ip['id'], port_id=self.port[1]['id'])
+ created_floating_ip['id'], port_id=self.ports[1]['id'])
self.assertEqual('200', resp['status'])
- update_floating_ip = floating_ip['floatingip']
- self.assertEqual(update_floating_ip['port_id'], self.port[1]['id'])
- self.assertIsNotNone(update_floating_ip['fixed_ip_address'])
- self.assertEqual(update_floating_ip['router_id'], self.router['id'])
+ updated_floating_ip = floating_ip['floatingip']
+ self.assertEqual(updated_floating_ip['port_id'], self.ports[1]['id'])
+ self.assertEqual(updated_floating_ip['fixed_ip_address'],
+ self.ports[1]['fixed_ips'][0]['ip_address'])
+ self.assertEqual(updated_floating_ip['router_id'], self.router['id'])
# Disassociate floating IP from the port
resp, floating_ip = self.client.update_floating_ip(
- create_floating_ip['id'], port_id=None)
+ created_floating_ip['id'], port_id=None)
self.assertEqual('200', resp['status'])
- update_floating_ip = floating_ip['floatingip']
- self.assertIsNone(update_floating_ip['port_id'])
- self.assertIsNone(update_floating_ip['fixed_ip_address'])
- self.assertIsNone(update_floating_ip['router_id'])
+ updated_floating_ip = floating_ip['floatingip']
+ self.assertIsNone(updated_floating_ip['port_id'])
+ self.assertIsNone(updated_floating_ip['fixed_ip_address'])
+ self.assertIsNone(updated_floating_ip['router_id'])
class FloatingIPTestXML(FloatingIPTestJSON):
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index 06e07bb..21934f2 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -19,7 +19,7 @@
from tempest.api.network import base
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
class RoutersTest(base.BaseAdminNetworkTest):
@@ -54,7 +54,7 @@
router_id, port_id)
self.assertEqual('200', resp['status'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_show_list_update_delete_router(self):
# Create a router
# NOTE(salv-orlando): Do not invoke self.create_router
@@ -97,7 +97,7 @@
create_body['router']['id'])
self.assertEqual(show_body['router']['name'], updated_name)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_add_remove_router_interface_with_subnet_id(self):
network = self.create_network()
subnet = self.create_subnet(network)
@@ -116,7 +116,7 @@
self.assertEqual(show_port_body['port']['device_id'],
router['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_add_remove_router_interface_with_port_id(self):
network = self.create_network()
self.create_subnet(network)
@@ -160,7 +160,7 @@
public_subnet_id = public_net_body['network']['subnets'][0]
self.assertEqual(fixed_ips[0]['subnet_id'], public_subnet_id)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_router_set_gateway(self):
router = self.create_router(data_utils.rand_name('router-'))
self.client.update_router(
@@ -175,7 +175,7 @@
{'network_id': self.network_cfg.public_network_id})
self._verify_gateway_port(router['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_router_set_gateway_with_snat_explicit(self):
router = self.create_router(data_utils.rand_name('router-'))
self.admin_client.update_router_with_snat_gw_info(
@@ -189,7 +189,7 @@
'enable_snat': True})
self._verify_gateway_port(router['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_router_set_gateway_without_snat(self):
router = self.create_router(data_utils.rand_name('router-'))
self.admin_client.update_router_with_snat_gw_info(
@@ -203,7 +203,7 @@
'enable_snat': False})
self._verify_gateway_port(router['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_router_unset_gateway(self):
router = self.create_router(
data_utils.rand_name('router-'),
@@ -216,7 +216,7 @@
device_id=router['id'])
self.assertFalse(list_body['ports'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_router_reset_gateway_without_snat(self):
router = self.create_router(
data_utils.rand_name('router-'),
@@ -232,7 +232,8 @@
'enable_snat': False})
self._verify_gateway_port(router['id'])
- @attr(type='smoke')
+ @test.requires_ext(extension='extraroute', service='network')
+ @test.attr(type='smoke')
def test_update_extra_route(self):
self.network = self.create_network()
self.name = self.network['name']
diff --git a/tempest/api/network/test_service_type_management.py b/tempest/api/network/test_service_type_management.py
index ae03e96..da6800b 100644
--- a/tempest/api/network/test_service_type_management.py
+++ b/tempest/api/network/test_service_type_management.py
@@ -13,13 +13,20 @@
# under the License.
from tempest.api.network import base
-from tempest.test import attr
+from tempest import test
class ServiceTypeManagementTestJSON(base.BaseNetworkTest):
_interface = 'json'
- @attr(type='smoke')
+ @classmethod
+ def setUpClass(cls):
+ super(ServiceTypeManagementTestJSON, cls).setUpClass()
+ if not test.is_extension_enabled('service-type', 'network'):
+ msg = "Neutron Service Type Management not enabled."
+ raise cls.skipException(msg)
+
+ @test.attr(type='smoke')
def test_service_provider_list(self):
resp, body = self.client.list_service_providers()
self.assertEqual(resp['status'], '200')
diff --git a/tempest/api/object_storage/test_account_quotas.py b/tempest/api/object_storage/test_account_quotas.py
index c1b3391..ac1c7d1 100644
--- a/tempest/api/object_storage/test_account_quotas.py
+++ b/tempest/api/object_storage/test_account_quotas.py
@@ -23,10 +23,12 @@
from tempest import exceptions
from tempest.test import attr
+CONF = config.CONF
+
class AccountQuotasTest(base.BaseObjectTest):
accounts_quotas_available = \
- config.TempestConfig().object_storage_feature_enabled.accounts_quotas
+ CONF.object_storage_feature_enabled.accounts_quotas
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/object_storage/test_container_quotas.py b/tempest/api/object_storage/test_container_quotas.py
index c7b5e28..513d24a 100644
--- a/tempest/api/object_storage/test_container_quotas.py
+++ b/tempest/api/object_storage/test_container_quotas.py
@@ -24,6 +24,7 @@
from tempest.test import attr
from tempest.test import HTTP_SUCCESS
+CONF = config.CONF
QUOTA_BYTES = 10
QUOTA_COUNT = 3
SKIP_MSG = "Container quotas middleware not available."
@@ -32,7 +33,7 @@
class ContainerQuotasTest(base.BaseObjectTest):
"""Attemps to test the perfect behavior of quotas in a container."""
container_quotas_available = \
- config.TempestConfig().object_storage_feature_enabled.container_quotas
+ CONF.object_storage_feature_enabled.container_quotas
def setUp(self):
"""Creates and sets a container with quotas.
diff --git a/tempest/api/object_storage/test_crossdomain.py b/tempest/api/object_storage/test_crossdomain.py
index 51ecd16..41430c8 100644
--- a/tempest/api/object_storage/test_crossdomain.py
+++ b/tempest/api/object_storage/test_crossdomain.py
@@ -23,10 +23,12 @@
from tempest.test import attr
from tempest.test import HTTP_SUCCESS
+CONF = config.CONF
+
class CrossdomainTest(base.BaseObjectTest):
crossdomain_available = \
- config.TempestConfig().object_storage_feature_enabled.crossdomain
+ CONF.object_storage_feature_enabled.crossdomain
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/object_storage/test_object_temp_url.py b/tempest/api/object_storage/test_object_temp_url.py
index bb03932..9d5a1c0 100644
--- a/tempest/api/object_storage/test_object_temp_url.py
+++ b/tempest/api/object_storage/test_object_temp_url.py
@@ -27,11 +27,13 @@
from tempest.test import attr
from tempest.test import HTTP_SUCCESS
+CONF = config.CONF
+
class ObjectTempUrlTest(base.BaseObjectTest):
tempurl_available = \
- config.TempestConfig().object_storage_feature_enabled.tempurl
+ CONF.object_storage_feature_enabled.tempurl
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/orchestration/stacks/test_non_empty_stack.py b/tempest/api/orchestration/stacks/test_non_empty_stack.py
index b19344d..eead234 100644
--- a/tempest/api/orchestration/stacks/test_non_empty_stack.py
+++ b/tempest/api/orchestration/stacks/test_non_empty_stack.py
@@ -78,6 +78,10 @@
cls.resource_type = 'AWS::AutoScaling::LaunchConfiguration'
cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
+ def assert_fields_in_dict(self, obj, *fields):
+ for field in fields:
+ self.assertIn(field, obj)
+
@attr(type='gate')
def test_stack_list(self):
"""Created stack should be on the list of existing stacks."""
@@ -93,8 +97,19 @@
resp, stack = self.client.get_stack(self.stack_name)
self.assertEqual('200', resp['status'])
self.assertIsInstance(stack, dict)
+ self.assert_fields_in_dict(stack, 'stack_name', 'id', 'links',
+ 'parameters', 'outputs', 'disable_rollback',
+ 'stack_status_reason', 'stack_status',
+ 'creation_time', 'updated_time',
+ 'capabilities', 'notification_topics',
+ 'timeout_mins', 'template_description')
+ self.assert_fields_in_dict(stack['parameters'], 'AWS::StackId',
+ 'trigger', 'AWS::Region', 'AWS::StackName')
+ self.assertEqual(True, stack['disable_rollback'],
+ 'disable_rollback should default to True')
self.assertEqual(self.stack_name, stack['stack_name'])
self.assertEqual(self.stack_id, stack['id'])
+ self.assertEqual('fluffy', stack['outputs'][0]['output_key'])
@attr(type='gate')
def test_list_resources(self):
@@ -103,6 +118,11 @@
resp, resources = self.client.list_resources(self.stack_identifier)
self.assertEqual('200', resp['status'])
self.assertIsInstance(resources, list)
+ for res in resources:
+ self.assert_fields_in_dict(res, 'logical_resource_id',
+ 'resource_type', 'resource_status',
+ 'updated_time')
+
resources_names = map(lambda resource: resource['logical_resource_id'],
resources)
self.assertIn(self.resource_name, resources_names)
@@ -116,6 +136,11 @@
resp, resource = self.client.get_resource(self.stack_identifier,
self.resource_name)
self.assertIsInstance(resource, dict)
+ self.assert_fields_in_dict(resource, 'resource_name', 'description',
+ 'links', 'logical_resource_id',
+ 'resource_status', 'updated_time',
+ 'required_by', 'resource_status_reason',
+ 'physical_resource_id', 'resource_type')
self.assertEqual(self.resource_name, resource['logical_resource_id'])
self.assertEqual(self.resource_type, resource['resource_type'])
@@ -135,6 +160,12 @@
resp, events = self.client.list_events(self.stack_identifier)
self.assertEqual('200', resp['status'])
self.assertIsInstance(events, list)
+
+ for event in events:
+ self.assert_fields_in_dict(event, 'logical_resource_id', 'id',
+ 'resource_status_reason',
+ 'resource_status', 'event_time')
+
resource_statuses = map(lambda event: event['resource_status'], events)
self.assertIn('CREATE_IN_PROGRESS', resource_statuses)
self.assertIn('CREATE_COMPLETE', resource_statuses)
@@ -151,6 +182,11 @@
self.resource_name, event_id)
self.assertEqual('200', resp['status'])
self.assertIsInstance(event, dict)
+ self.assert_fields_in_dict(event, 'resource_name', 'event_time',
+ 'links', 'logical_resource_id',
+ 'resource_status', 'resource_status_reason',
+ 'physical_resource_id', 'id',
+ 'resource_properties', 'resource_type')
self.assertEqual(self.resource_name, event['resource_name'])
self.assertEqual('state changed', event['resource_status_reason'])
self.assertEqual(self.resource_name, event['logical_resource_id'])
diff --git a/tempest/api/orchestration/stacks/test_server_cfn_init.py b/tempest/api/orchestration/stacks/test_server_cfn_init.py
index 0480570..6fbbb5b 100644
--- a/tempest/api/orchestration/stacks/test_server_cfn_init.py
+++ b/tempest/api/orchestration/stacks/test_server_cfn_init.py
@@ -18,18 +18,17 @@
from tempest.api.orchestration import base
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest.openstack.common import log as logging
from tempest.test import attr
-
+CONF = config.CONF
LOG = logging.getLogger(__name__)
class ServerCfnInitTestJSON(base.BaseOrchestrationTest):
_interface = 'json'
- existing_keypair = (tempest.config.TempestConfig().
- orchestration.keypair_name is not None)
+ existing_keypair = CONF.orchestration.keypair_name is not None
template = """
HeatTemplateFormatVersion: '2012-12-12'
diff --git a/tempest/api/volume/test_volumes_list.py b/tempest/api/volume/test_volumes_list.py
index 38d265c..c624a3a 100644
--- a/tempest/api/volume/test_volumes_list.py
+++ b/tempest/api/volume/test_volumes_list.py
@@ -15,6 +15,7 @@
# 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 operator
from tempest.api.volume import base
from tempest.common.utils import data_utils
@@ -23,6 +24,8 @@
LOG = logging.getLogger(__name__)
+VOLUME_FIELDS = ('id', 'display_name')
+
class VolumesListTest(base.BaseVolumeV1Test):
@@ -36,7 +39,11 @@
_interface = 'json'
- def assertVolumesIn(self, fetched_list, expected_list):
+ def assertVolumesIn(self, fetched_list, expected_list, fields=None):
+ if fields:
+ expected_list = map(operator.itemgetter(*fields), expected_list)
+ fetched_list = map(operator.itemgetter(*fields), fetched_list)
+
missing_vols = [v for v in expected_list if v not in fetched_list]
if len(missing_vols) == 0:
return
@@ -113,7 +120,8 @@
# Fetch all volumes
resp, fetched_list = self.client.list_volumes()
self.assertEqual(200, resp.status)
- self.assertVolumesIn(fetched_list, self.volume_list)
+ self.assertVolumesIn(fetched_list, self.volume_list,
+ fields=VOLUME_FIELDS)
@attr(type='gate')
def test_volume_list_with_details(self):
@@ -150,7 +158,8 @@
self.assertEqual(200, resp.status)
for volume in fetched_list:
self.assertEqual('available', volume['status'])
- self.assertVolumesIn(fetched_list, self.volume_list)
+ self.assertVolumesIn(fetched_list, self.volume_list,
+ fields=VOLUME_FIELDS)
@attr(type='gate')
def test_volumes_list_details_by_status(self):
@@ -170,7 +179,8 @@
self.assertEqual(200, resp.status)
for volume in fetched_list:
self.assertEqual(zone, volume['availability_zone'])
- self.assertVolumesIn(fetched_list, self.volume_list)
+ self.assertVolumesIn(fetched_list, self.volume_list,
+ fields=VOLUME_FIELDS)
@attr(type='gate')
def test_volumes_list_details_by_availability_zone(self):
diff --git a/tempest/clients.py b/tempest/clients.py
index eeffe2a..1f2e1de 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -56,10 +56,13 @@
CertificatesV3ClientJSON
from tempest.services.compute.v3.json.extensions_client import \
ExtensionsV3ClientJSON
+from tempest.services.compute.v3.json.flavors_client import FlavorsV3ClientJSON
from tempest.services.compute.v3.json.hypervisor_client import \
HypervisorV3ClientJSON
from tempest.services.compute.v3.json.interfaces_client import \
InterfacesV3ClientJSON
+from tempest.services.compute.v3.json.keypairs_client import \
+ KeyPairsV3ClientJSON
from tempest.services.compute.v3.json.servers_client import \
ServersV3ClientJSON
from tempest.services.compute.v3.json.services_client import \
@@ -72,10 +75,12 @@
CertificatesV3ClientXML
from tempest.services.compute.v3.xml.extensions_client import \
ExtensionsV3ClientXML
+from tempest.services.compute.v3.xml.flavors_client import FlavorsV3ClientXML
from tempest.services.compute.v3.xml.hypervisor_client import \
HypervisorV3ClientXML
from tempest.services.compute.v3.xml.interfaces_client import \
InterfacesV3ClientXML
+from tempest.services.compute.v3.xml.keypairs_client import KeyPairsV3ClientXML
from tempest.services.compute.v3.xml.servers_client import ServersV3ClientXML
from tempest.services.compute.v3.xml.services_client import \
ServicesV3ClientXML
@@ -91,6 +96,7 @@
from tempest.services.compute.xml.flavors_client import FlavorsClientXML
from tempest.services.compute.xml.floating_ips_client import \
FloatingIPsClientXML
+from tempest.services.compute.xml.hosts_client import HostsClientXML
from tempest.services.compute.xml.hypervisor_client import HypervisorClientXML
from tempest.services.compute.xml.images_client import ImagesClientXML
from tempest.services.compute.xml.instance_usage_audit_log_client import \
@@ -162,6 +168,7 @@
from tempest.services.volume.xml.snapshots_client import SnapshotsClientXML
from tempest.services.volume.xml.volumes_client import VolumesClientXML
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -182,13 +189,12 @@
:param password: Override of the password
:param tenant_name: Override of the tenant name
"""
- self.config = config.TempestConfig()
-
+ self.config = CONF
# If no creds are provided, we fall back on the defaults
# in the config file for the Compute API.
- self.username = username or self.config.identity.username
- self.password = password or self.config.identity.password
- self.tenant_name = tenant_name or self.config.identity.tenant_name
+ self.username = username or CONF.identity.username
+ self.password = password or CONF.identity.password
+ self.tenant_name = tenant_name or CONF.identity.tenant_name
if None in (self.username, self.password, self.tenant_name):
msg = ("Missing required credentials. "
@@ -197,15 +203,15 @@
{'u': username, 'p': password, 't': tenant_name})
raise exceptions.InvalidConfiguration(msg)
- self.auth_url = self.config.identity.uri
- self.auth_url_v3 = self.config.identity.uri_v3
+ self.auth_url = CONF.identity.uri
+ self.auth_url_v3 = CONF.identity.uri_v3
- client_args = (self.config, self.username, self.password,
+ client_args = (CONF, self.username, self.password,
self.auth_url, self.tenant_name)
if self.auth_url_v3:
auth_version = 'v3'
- client_args_v3_auth = (self.config, self.username,
+ client_args_v3_auth = (CONF, self.username,
self.password, self.auth_url_v3,
self.tenant_name, auth_version)
else:
@@ -220,9 +226,11 @@
self.servers_v3_client = ServersV3ClientXML(*client_args)
self.limits_client = LimitsClientXML(*client_args)
self.images_client = ImagesClientXML(*client_args)
+ self.keypairs_v3_client = KeyPairsV3ClientXML(*client_args)
self.keypairs_client = KeyPairsClientXML(*client_args)
self.quotas_client = QuotasClientXML(*client_args)
self.flavors_client = FlavorsClientXML(*client_args)
+ self.flavors_v3_client = FlavorsV3ClientXML(*client_args)
self.extensions_v3_client = ExtensionsV3ClientXML(*client_args)
self.extensions_client = ExtensionsClientXML(*client_args)
self.volumes_extensions_client = VolumesExtensionsClientXML(
@@ -233,7 +241,7 @@
self.volume_types_client = VolumeTypesClientXML(*client_args)
self.identity_client = IdentityClientXML(*client_args)
self.identity_v3_client = IdentityV3ClientXML(*client_args)
- self.token_client = TokenClientXML(self.config)
+ self.token_client = TokenClientXML(CONF)
self.security_groups_client = SecurityGroupsClientXML(
*client_args)
self.interfaces_v3_client = InterfacesV3ClientXML(*client_args)
@@ -252,6 +260,7 @@
*client_args)
self.tenant_usages_client = TenantUsagesClientXML(*client_args)
self.policy_client = PolicyClientXML(*client_args)
+ self.hosts_client = HostsClientXML(*client_args)
self.hypervisor_v3_client = HypervisorV3ClientXML(*client_args)
self.hypervisor_client = HypervisorClientXML(*client_args)
self.token_v3_client = V3TokenClientXML(*client_args)
@@ -275,9 +284,11 @@
self.servers_v3_client = ServersV3ClientJSON(*client_args)
self.limits_client = LimitsClientJSON(*client_args)
self.images_client = ImagesClientJSON(*client_args)
+ self.keypairs_v3_client = KeyPairsV3ClientJSON(*client_args)
self.keypairs_client = KeyPairsClientJSON(*client_args)
self.quotas_client = QuotasClientJSON(*client_args)
self.flavors_client = FlavorsClientJSON(*client_args)
+ self.flavors_v3_client = FlavorsV3ClientJSON(*client_args)
self.extensions_v3_client = ExtensionsV3ClientJSON(*client_args)
self.extensions_client = ExtensionsClientJSON(*client_args)
self.volumes_extensions_client = VolumesExtensionsClientJSON(
@@ -288,7 +299,7 @@
self.volume_types_client = VolumeTypesClientJSON(*client_args)
self.identity_client = IdentityClientJSON(*client_args)
self.identity_v3_client = IdentityV3ClientJSON(*client_args)
- self.token_client = TokenClientJSON(self.config)
+ self.token_client = TokenClientJSON(CONF)
self.security_groups_client = SecurityGroupsClientJSON(
*client_args)
self.interfaces_v3_client = InterfacesV3ClientJSON(*client_args)
@@ -307,6 +318,7 @@
*client_args)
self.tenant_usages_client = TenantUsagesClientJSON(*client_args)
self.policy_client = PolicyClientJSON(*client_args)
+ self.hosts_client = HostsClientJSON(*client_args)
self.hypervisor_v3_client = HypervisorV3ClientJSON(*client_args)
self.hypervisor_client = HypervisorClientJSON(*client_args)
self.token_v3_client = V3TokenClientJSON(*client_args)
@@ -326,9 +338,8 @@
raise exceptions.InvalidConfiguration(msg)
# common clients
- self.hosts_client = HostsClientJSON(*client_args)
self.account_client = AccountClient(*client_args)
- if self.config.service_available.glance:
+ if CONF.service_available.glance:
self.image_client = ImageClientJSON(*client_args)
self.image_client_v2 = ImageClientV2JSON(*client_args)
self.container_client = ContainerClient(*client_args)
@@ -350,10 +361,9 @@
"""
def __init__(self, interface='json'):
- conf = config.TempestConfig()
- super(AltManager, self).__init__(conf.identity.alt_username,
- conf.identity.alt_password,
- conf.identity.alt_tenant_name,
+ super(AltManager, self).__init__(CONF.identity.alt_username,
+ CONF.identity.alt_password,
+ CONF.identity.alt_tenant_name,
interface=interface)
@@ -365,10 +375,9 @@
"""
def __init__(self, interface='json'):
- conf = config.TempestConfig()
- super(AdminManager, self).__init__(conf.identity.admin_username,
- conf.identity.admin_password,
- conf.identity.admin_tenant_name,
+ super(AdminManager, self).__init__(CONF.identity.admin_username,
+ CONF.identity.admin_password,
+ CONF.identity.admin_tenant_name,
interface=interface)
@@ -380,11 +389,10 @@
"""
def __init__(self, interface='json'):
- conf = config.TempestConfig()
base = super(ComputeAdminManager, self)
- base.__init__(conf.compute_admin.username,
- conf.compute_admin.password,
- conf.compute_admin.tenant_name,
+ base.__init__(CONF.compute_admin.username,
+ CONF.compute_admin.password,
+ CONF.compute_admin.tenant_name,
interface=interface)
@@ -394,9 +402,8 @@
so that heat templates can create users
"""
def __init__(self, interface='json'):
- conf = config.TempestConfig()
base = super(OrchestrationManager, self)
- base.__init__(conf.identity.admin_username,
- conf.identity.admin_password,
- conf.identity.tenant_name,
+ base.__init__(CONF.identity.admin_username,
+ CONF.identity.admin_password,
+ CONF.identity.tenant_name,
interface=interface)
diff --git a/tempest/common/debug.py b/tempest/common/debug.py
index 69c933c..f132f6a 100644
--- a/tempest/common/debug.py
+++ b/tempest/common/debug.py
@@ -19,13 +19,14 @@
from tempest.openstack.common import log as logging
+CONF = config.CONF
LOG = logging.getLogger(__name__)
tables = ['filter', 'nat', 'mangle']
def log_ip_ns():
- if not config.TempestConfig().debug.enable:
+ if not CONF.debug.enable:
return
LOG.info("Host Addr:\n" + commands.ip_addr_raw())
LOG.info("Host Route:\n" + commands.ip_route_raw())
diff --git a/tempest/common/generate_sample_tempest.py b/tempest/common/generate_sample_tempest.py
index 545703b..6097aa8 100644
--- a/tempest/common/generate_sample_tempest.py
+++ b/tempest/common/generate_sample_tempest.py
@@ -18,7 +18,7 @@
import sys
-from tempest import config
+import tempest.config
from tempest.openstack.common.config import generator
# NOTE(mtreinish): This hack is needed because of how oslo config is used in
@@ -31,5 +31,7 @@
# the issue by manually loading the config file (which may or may not exist)
# which will populate all the options before running the generator.
-config.TempestConfig()
-generator.generate(sys.argv[1:])
+
+if __name__ == "__main__":
+ CONF = tempest.config.TempestConfigPrivate(False)
+ generator.generate(sys.argv[1:])
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index 5dbb3a7..da60318 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -25,6 +25,7 @@
from tempest import exceptions
from tempest.openstack.common import log as logging
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -36,7 +37,7 @@
self.isolated_net_resources = {}
self.ports = []
self.name = name
- self.config = config.TempestConfig()
+ self.config = CONF
self.tempest_client = tempest_client
self.interface = interface
self.password = password
@@ -44,11 +45,11 @@
self._get_admin_clients())
def _get_official_admin_clients(self):
- username = self.config.identity.admin_username
- password = self.config.identity.admin_password
- tenant_name = self.config.identity.admin_tenant_name
- auth_url = self.config.identity.uri
- dscv = self.config.identity.disable_ssl_certificate_validation
+ username = CONF.identity.admin_username
+ password = CONF.identity.admin_password
+ tenant_name = CONF.identity.admin_tenant_name
+ auth_url = CONF.identity.uri
+ dscv = CONF.identity.disable_ssl_certificate_validation
identity_client = keystoneclient.Client(username=username,
password=password,
tenant_name=tenant_name,
@@ -164,7 +165,7 @@
role = None
try:
roles = self._list_roles()
- admin_role = self.config.identity.admin_role
+ admin_role = CONF.identity.admin_role
if self.tempest_client:
role = next(r for r in roles if r['name'] == admin_role)
else:
@@ -229,8 +230,8 @@
if not self.tempest_client:
body = {'subnet': {'name': subnet_name, 'tenant_id': tenant_id,
'network_id': network_id, 'ip_version': 4}}
- base_cidr = netaddr.IPNetwork(self.config.network.tenant_network_cidr)
- mask_bits = self.config.network.tenant_network_mask_bits
+ base_cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
+ mask_bits = CONF.network.tenant_network_mask_bits
for subnet_cidr in base_cidr.subnet(mask_bits):
try:
if self.tempest_client:
@@ -252,7 +253,7 @@
def _create_router(self, router_name, tenant_id):
external_net_id = dict(
- network_id=self.config.network.public_network_id)
+ network_id=CONF.network.public_network_id)
if self.tempest_client:
resp, resp_body = self.network_admin_client.create_router(
router_name,
@@ -328,7 +329,7 @@
self.isolated_creds['primary'] = (user, tenant)
LOG.info("Acquired isolated creds:\n user: %s, tenant: %s"
% (username, tenant_name))
- if self.config.service_available.neutron:
+ if CONF.service_available.neutron:
network, subnet, router = self._create_network_resources(
self._get_tenant_id(tenant))
self.isolated_net_resources['primary'] = (
@@ -347,7 +348,7 @@
self.isolated_creds['admin'] = (user, tenant)
LOG.info("Acquired admin isolated creds:\n user: %s, tenant: %s"
% (username, tenant_name))
- if self.config.service_available.neutron:
+ if CONF.service_available.neutron:
network, subnet, router = self._create_network_resources(
self._get_tenant_id(tenant))
self.isolated_net_resources['admin'] = (
@@ -366,7 +367,7 @@
self.isolated_creds['alt'] = (user, tenant)
LOG.info("Acquired alt isolated creds:\n user: %s, tenant: %s"
% (username, tenant_name))
- if self.config.service_available.neutron:
+ if CONF.service_available.neutron:
network, subnet, router = self._create_network_resources(
self._get_tenant_id(tenant))
self.isolated_net_resources['alt'] = (
diff --git a/tempest/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py
index 144536a..fa59e14 100644
--- a/tempest/common/utils/linux/remote_client.py
+++ b/tempest/common/utils/linux/remote_client.py
@@ -17,18 +17,20 @@
from tempest.common.ssh import Client
from tempest.common import utils
-from tempest.config import TempestConfig
+from tempest import config
from tempest.exceptions import ServerUnreachable
+CONF = config.CONF
+
class RemoteClient():
# NOTE(afazekas): It should always get an address instead of server
def __init__(self, server, username, password=None, pkey=None):
- ssh_timeout = TempestConfig().compute.ssh_timeout
- network = TempestConfig().compute.network_for_ssh
- ip_version = TempestConfig().compute.ip_version_for_ssh
- ssh_channel_timeout = TempestConfig().compute.ssh_channel_timeout
+ ssh_timeout = CONF.compute.ssh_timeout
+ network = CONF.compute.network_for_ssh
+ ip_version = CONF.compute.ip_version_for_ssh
+ ssh_channel_timeout = CONF.compute.ssh_channel_timeout
if isinstance(server, basestring):
ip_address = server
else:
diff --git a/tempest/common/waiters.py b/tempest/common/waiters.py
index d2b40c9..ce620a8 100644
--- a/tempest/common/waiters.py
+++ b/tempest/common/waiters.py
@@ -19,7 +19,7 @@
from tempest import exceptions
from tempest.openstack.common import log as logging
-CONFIG = config.TempestConfig()
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -29,7 +29,10 @@
"""Waits for a server to reach a given status."""
def _get_task_state(body):
- task_state = body.get('OS-EXT-STS:task_state', None)
+ if client.service == CONF.compute.catalog_v3_type:
+ task_state = body.get("os-extended-status:task_state", None)
+ else:
+ task_state = body.get('OS-EXT-STS:task_state', None)
return task_state
# NOTE(afazekas): UNKNOWN status possible on ERROR
@@ -55,7 +58,7 @@
# responses
if str(task_state) == "None":
# without state api extension 3 sec usually enough
- time.sleep(CONFIG.compute.ready_wait)
+ time.sleep(CONF.compute.ready_wait)
return
else:
return
diff --git a/tempest/config.py b/tempest/config.py
index 1b14c70..bf45b4b 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -18,12 +18,9 @@
from __future__ import print_function
import os
-import sys
-
from oslo.config import cfg
-from tempest.common.utils.misc import singleton
from tempest.openstack.common import log as logging
@@ -649,8 +646,8 @@
]
-@singleton
-class TempestConfig:
+# this should never be called outside of this class
+class TempestConfigPrivate(object):
"""Provides OpenStack configuration information."""
DEFAULT_CONFIG_DIR = os.path.join(
@@ -659,8 +656,9 @@
DEFAULT_CONFIG_FILE = "tempest.conf"
- def __init__(self):
+ def __init__(self, parse_conf=True):
"""Initialize a configuration from a conf directory and conf file."""
+ super(TempestConfigPrivate, self).__init__()
config_files = []
failsafe_path = "/etc/tempest/" + self.DEFAULT_CONFIG_FILE
@@ -676,10 +674,9 @@
'TEMPEST_CONFIG' in os.environ):
path = failsafe_path
- if not os.path.exists(path):
- msg = "Config file %s not found" % path
- print(RuntimeError(msg), file=sys.stderr)
- else:
+ # only parse the config file if we expect one to exist. This is needed
+ # to remove an issue with the config file up to date checker.
+ if parse_conf:
config_files.append(path)
cfg.CONF([], project='tempest', default_config_files=config_files)
@@ -738,3 +735,16 @@
self.compute_admin.username = self.identity.admin_username
self.compute_admin.password = self.identity.admin_password
self.compute_admin.tenant_name = self.identity.admin_tenant_name
+
+
+class TempestConfigProxy(object):
+ _config = None
+
+ def __getattr__(self, attr):
+ if not self._config:
+ self._config = TempestConfigPrivate()
+
+ return getattr(self._config, attr)
+
+
+CONF = TempestConfigProxy()
diff --git a/tempest/manager.py b/tempest/manager.py
index e3aeb31..42b8c8f 100644
--- a/tempest/manager.py
+++ b/tempest/manager.py
@@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-import tempest.config
+from tempest import config
from tempest import exceptions
@@ -29,7 +29,7 @@
"""
def __init__(self):
- self.config = tempest.config.TempestConfig()
+ self.config = config.CONF
self.client_attr_names = []
# we do this everywhere, have it be part of the super class
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index a3b51eb..d3d34d0 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -24,12 +24,14 @@
import cinderclient.client
import glanceclient
import heatclient.client
+import keystoneclient.apiclient.exceptions
import keystoneclient.v2_0.client
import netaddr
from neutronclient.common import exceptions as exc
import neutronclient.v2_0.client
import novaclient.client
from novaclient import exceptions as nova_exceptions
+import swiftclient
from tempest.api.network import common as net_common
from tempest.common import isolated_creds
@@ -74,6 +76,10 @@
self.volume_client = self._get_volume_client(username,
password,
tenant_name)
+ self.object_storage_client = self._get_object_storage_client(
+ username,
+ password,
+ tenant_name)
self.orchestration_client = self._get_orchestration_client(
username,
password,
@@ -122,6 +128,30 @@
region_name=region,
http_log_debug=True)
+ def _get_object_storage_client(self, username, password, tenant_name):
+ auth_url = self.config.identity.uri
+ # add current tenant to Member group.
+ keystone_admin = self._get_identity_client(
+ self.config.identity.admin_username,
+ self.config.identity.admin_password,
+ self.config.identity.admin_tenant_name)
+
+ # enable test user to operate swift by adding Member role to him.
+ roles = keystone_admin.roles.list()
+ member_role = [role for role in roles if role.name == 'Member'][0]
+ # NOTE(maurosr): This is surrounded in the try-except block cause
+ # neutron tests doesn't have tenant isolation.
+ try:
+ keystone_admin.roles.add_user_role(self.identity_client.user_id,
+ member_role.id,
+ self.identity_client.tenant_id)
+ except keystoneclient.apiclient.exceptions.Conflict:
+ pass
+
+ return swiftclient.Connection(auth_url, username, password,
+ tenant_name=tenant_name,
+ auth_version='2')
+
def _get_orchestration_client(self, username=None, password=None,
tenant_name=None):
if not username:
@@ -215,6 +245,7 @@
cls.identity_client = cls.manager.identity_client
cls.network_client = cls.manager.network_client
cls.volume_client = cls.manager.volume_client
+ cls.object_storage_client = cls.manager.object_storage_client
cls.orchestration_client = cls.manager.orchestration_client
cls.resource_keys = {}
cls.os_resources = []
@@ -261,7 +292,8 @@
except Exception as e:
# If the resource is already missing, mission accomplished.
# add status code as workaround for bug 1247568
- if e.__class__.__name__ == 'NotFound' or e.status_code == 404:
+ if (e.__class__.__name__ == 'NotFound' or
+ hasattr(e, 'status_code') and e.status_code == 404):
continue
raise
@@ -621,12 +653,15 @@
self.set_resource(name, port)
return port
- def _create_floating_ip(self, server, external_network_id):
+ def _get_server_port_id(self, server):
result = self.network_client.list_ports(device_id=server.id)
ports = result.get('ports', [])
self.assertEqual(len(ports), 1,
"Unable to determine which port to target.")
- port_id = ports[0]['id']
+ return ports[0]['id']
+
+ def _create_floating_ip(self, server, external_network_id):
+ port_id = self._get_server_port_id(server)
body = dict(
floatingip=dict(
floating_network_id=external_network_id,
@@ -641,6 +676,12 @@
self.set_resource(data_utils.rand_name('floatingip-'), floating_ip)
return floating_ip
+ def _associate_floating_ip(self, floating_ip, server):
+ port_id = self._get_server_port_id(server)
+ floating_ip.update(port_id=port_id)
+ self.assertEqual(port_id, floating_ip.port_id)
+ return floating_ip
+
def _disassociate_floating_ip(self, floating_ip):
"""
:param floating_ip: type DeletableFloatingIp
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index 54517ab..33dd6c0 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -27,6 +27,7 @@
from tempest.test import attr
from tempest.test import services
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -90,6 +91,10 @@
- detach the floating-ip from the VM and verify that it becomes
unreachable
+ - associate detached floating ip to a new VM and verify connectivity.
+ VMs are created with unique keypair so connectivity also asserts that
+ floating IP is associated with the new VM instead of the old one
+
# TODO(mnewby) - Need to implement the following:
- the Tempest host can ssh into the VM via the IP address and
successfully execute the following:
@@ -138,8 +143,6 @@
"""
- CONF = config.TempestConfig()
-
@classmethod
def check_preconditions(cls):
super(TestNetworkBasicOps, cls).check_preconditions()
@@ -156,18 +159,13 @@
cls.check_preconditions()
# TODO(mnewby) Consider looking up entities as needed instead
# of storing them as collections on the class.
- cls.keypairs = {}
cls.security_groups = {}
cls.networks = []
cls.subnets = []
cls.routers = []
- cls.servers = []
+ cls.servers = {}
cls.floating_ips = {}
- def _create_keypairs(self):
- self.keypairs[self.tenant_id] = self.create_keypair(
- name=data_utils.rand_name('keypair-smoke-'))
-
def _create_security_groups(self):
self.security_groups[self.tenant_id] =\
self._create_security_group_neutron(tenant_id=self.tenant_id)
@@ -197,39 +195,38 @@
def _create_server(self, name, network):
tenant_id = network.tenant_id
- keypair_name = self.keypairs[tenant_id].name
+ keypair = self.create_keypair(name='keypair-%s' % name)
security_groups = [self.security_groups[tenant_id].name]
create_kwargs = {
'nics': [
{'net-id': network.id},
],
- 'key_name': keypair_name,
+ 'key_name': keypair.name,
'security_groups': security_groups,
}
server = self.create_server(name=name, create_kwargs=create_kwargs)
+ self.servers[server] = keypair
return server
def _create_servers(self):
for i, network in enumerate(self.networks):
name = data_utils.rand_name('server-smoke-%d-' % i)
- server = self._create_server(name, network)
- self.servers.append(server)
+ self._create_server(name, network)
def _check_tenant_network_connectivity(self):
- if not self.config.network.tenant_networks_reachable:
+ if not CONF.network.tenant_networks_reachable:
msg = 'Tenant networks not configured to be reachable.'
LOG.info(msg)
return
# The target login is assumed to have been configured for
# key-based authentication by cloud-init.
- ssh_login = self.config.compute.image_ssh_user
- private_key = self.keypairs[self.tenant_id].private_key
+ ssh_login = CONF.compute.image_ssh_user
try:
- for server in self.servers:
+ for server, key in self.servers.items():
for net_name, ip_addresses in server.networks.iteritems():
for ip_address in ip_addresses:
self._check_vm_connectivity(ip_address, ssh_login,
- private_key)
+ key.private_key)
except Exception as exc:
LOG.exception(exc)
debug.log_ip_ns()
@@ -241,25 +238,27 @@
self.assertTrue(
tempest.test.call_until_true(
- ip_tracker.run_checks, self.config.compute.build_timeout,
- self.config.compute.build_interval),
+ ip_tracker.run_checks, CONF.compute.build_timeout,
+ CONF.compute.build_interval),
"Timed out while waiting for the floating IP assignments "
"to propagate")
def _create_and_associate_floating_ips(self):
- public_network_id = self.config.network.public_network_id
- for server in self.servers:
+ public_network_id = CONF.network.public_network_id
+ for server in self.servers.keys():
floating_ip = self._create_floating_ip(server, public_network_id)
self.floating_ips[floating_ip] = server
def _check_public_network_connectivity(self, should_connect=True):
# The target login is assumed to have been configured for
# key-based authentication by cloud-init.
- ssh_login = self.config.compute.image_ssh_user
- private_key = self.keypairs[self.tenant_id].private_key
+ ssh_login = CONF.compute.image_ssh_user
try:
for floating_ip, server in self.floating_ips.iteritems():
ip_address = floating_ip.floating_ip_address
+ private_key = None
+ if should_connect:
+ private_key = self.servers[server].private_key
self._check_vm_connectivity(ip_address,
ssh_login,
private_key,
@@ -274,10 +273,18 @@
self._disassociate_floating_ip(floating_ip)
self.floating_ips[floating_ip] = None
+ def _reassociate_floating_ips(self):
+ network = self.networks[0]
+ for floating_ip in self.floating_ips.keys():
+ name = data_utils.rand_name('new_server-smoke-')
+ # create a new server for the floating ip
+ server = self._create_server(name, network)
+ self._associate_floating_ip(floating_ip, server)
+ self.floating_ips[floating_ip] = server
+
@attr(type='smoke')
@services('compute', 'network')
def test_network_basic_ops(self):
- self._create_keypairs()
self._create_security_groups()
self._create_networks()
self._check_networks()
@@ -288,3 +295,6 @@
self._check_public_network_connectivity(should_connect=True)
self._disassociate_floating_ips()
self._check_public_network_connectivity(should_connect=False)
+ self._reassociate_floating_ips()
+ self._wait_for_floating_ip_association()
+ self._check_public_network_connectivity(should_connect=True)
diff --git a/tempest/scenario/test_swift_basic_ops.py b/tempest/scenario/test_swift_basic_ops.py
new file mode 100644
index 0000000..6763503
--- /dev/null
+++ b/tempest/scenario/test_swift_basic_ops.py
@@ -0,0 +1,101 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 IBM Corp.
+# 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.utils.data_utils import rand_name
+from tempest.openstack.common import log as logging
+from tempest.scenario import manager
+from tempest.test import services
+
+LOG = logging.getLogger(__name__)
+
+
+class TestSwiftBasicOps(manager.OfficialClientTest):
+ """
+ Test swift with the follow operations:
+ * get swift stat.
+ * create container.
+ * upload a file to the created container.
+ * list container's objects and assure that the uploaded file is present.
+ * delete object from container.
+ * list container's objects and assure that the deleted file is gone.
+ * delete a container.
+ * list containers and assure that the deleted container is gone.
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestSwiftBasicOps, cls).setUpClass()
+ if not cls.config.service_available.swift:
+ skip_msg = ("%s skipped as swift is not available" %
+ cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ def _get_swift_stat(self):
+ """get swift status for our user account."""
+ self.object_storage_client.get_account()
+ LOG.debug('Swift status information obtained successfully')
+
+ def _create_container(self, container_name=None):
+ name = container_name or rand_name('swift-scenario-container')
+ self.object_storage_client.put_container(name)
+ # look for the container to assure it is created
+ self._list_and_check_container_objects(name)
+ LOG.debug('Container %s created' % (name))
+ return name
+
+ def _delete_container(self, container_name):
+ self.object_storage_client.delete_container(container_name)
+ LOG.debug('Container %s deleted' % (container_name))
+
+ def _upload_object_to_container(self, container_name, obj_name=None):
+ obj_name = obj_name or rand_name('swift-scenario-object')
+ self.object_storage_client.put_object(container_name, obj_name,
+ rand_name('obj_data'),
+ content_type='text/plain')
+ return obj_name
+
+ def _delete_object(self, container_name, filename):
+ self.object_storage_client.delete_object(container_name, filename)
+ self._list_and_check_container_objects(container_name,
+ not_present_obj=[filename])
+
+ def _list_and_check_container_objects(self, container_name, present_obj=[],
+ not_present_obj=[]):
+ """
+ List objects for a given container and assert which are present and
+ which are not.
+ """
+ meta, response = self.object_storage_client.get_container(
+ container_name)
+ # create a list with file name only
+ object_list = [obj['name'] for obj in response]
+ if present_obj:
+ for obj in present_obj:
+ self.assertIn(obj, object_list)
+ if not_present_obj:
+ for obj in not_present_obj:
+ self.assertNotIn(obj, object_list)
+
+ @services('object')
+ def test_swift_basic_ops(self):
+ self._get_swift_stat()
+ container_name = self._create_container()
+ obj_name = self._upload_object_to_container(container_name)
+ self._list_and_check_container_objects(container_name, [obj_name])
+ self._delete_object(container_name, obj_name)
+ self._delete_container(container_name)
diff --git a/tempest/services/compute/v3/json/flavors_client.py b/tempest/services/compute/v3/json/flavors_client.py
index 00d6f8a..e99ac91 100644
--- a/tempest/services/compute/v3/json/flavors_client.py
+++ b/tempest/services/compute/v3/json/flavors_client.py
@@ -21,12 +21,12 @@
from tempest.common.rest_client import RestClient
-class FlavorsClientJSON(RestClient):
+class FlavorsV3ClientJSON(RestClient):
def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(FlavorsClientJSON, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_type
+ super(FlavorsV3ClientJSON, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
def list_flavors(self, params=None):
url = 'flavors'
@@ -67,7 +67,7 @@
if kwargs.get('rxtx'):
post_body['rxtx_factor'] = kwargs.get('rxtx')
if kwargs.get('is_public'):
- post_body['os-flavor-access:is_public'] = kwargs.get('is_public')
+ post_body['flavor-access:is_public'] = kwargs.get('is_public')
post_body = json.dumps({'flavor': post_body})
resp, body = self.post('flavors', post_body, self.headers)
@@ -91,27 +91,27 @@
def set_flavor_extra_spec(self, flavor_id, specs):
"""Sets extra Specs to the mentioned flavor."""
post_body = json.dumps({'extra_specs': specs})
- resp, body = self.post('flavors/%s/os-extra_specs' % flavor_id,
+ resp, body = self.post('flavors/%s/flavor-extra-specs' % flavor_id,
post_body, self.headers)
body = json.loads(body)
return resp, body['extra_specs']
def get_flavor_extra_spec(self, flavor_id):
"""Gets extra Specs details of the mentioned flavor."""
- resp, body = self.get('flavors/%s/os-extra_specs' % flavor_id)
+ resp, body = self.get('flavors/%s/flavor-extra-specs' % flavor_id)
body = json.loads(body)
return resp, body['extra_specs']
def get_flavor_extra_spec_with_key(self, flavor_id, key):
"""Gets extra Specs key-value of the mentioned flavor and key."""
- resp, body = self.get('flavors/%s/os-extra_specs/%s' % (str(flavor_id),
- key))
+ resp, body = self.get('flavors/%s/flavor-extra-specs/%s' %
+ (str(flavor_id), key))
body = json.loads(body)
return resp, body
def update_flavor_extra_spec(self, flavor_id, key, **kwargs):
"""Update specified extra Specs of the mentioned flavor and key."""
- resp, body = self.put('flavors/%s/os-extra_specs/%s' %
+ resp, body = self.put('flavors/%s/flavor-extra-specs/%s' %
(flavor_id, key),
json.dumps(kwargs), self.headers)
body = json.loads(body)
@@ -119,12 +119,12 @@
def unset_flavor_extra_spec(self, flavor_id, key):
"""Unsets extra Specs from the mentioned flavor."""
- return self.delete('flavors/%s/os-extra_specs/%s' % (str(flavor_id),
- key))
+ return self.delete('flavors/%s/flavor-extra-specs/%s' %
+ (str(flavor_id), key))
def list_flavor_access(self, flavor_id):
"""Gets flavor access information given the flavor id."""
- resp, body = self.get('flavors/%s/os-flavor-access' % flavor_id,
+ resp, body = self.get('flavors/%s/flavor-access' % flavor_id,
self.headers)
body = json.loads(body)
return resp, body['flavor_access']
@@ -132,8 +132,8 @@
def add_flavor_access(self, flavor_id, tenant_id):
"""Add flavor access for the specified tenant."""
post_body = {
- 'addTenantAccess': {
- 'tenant': tenant_id
+ 'add_tenant_access': {
+ 'tenant_id': tenant_id
}
}
post_body = json.dumps(post_body)
@@ -145,8 +145,8 @@
def remove_flavor_access(self, flavor_id, tenant_id):
"""Remove flavor access from the specified tenant."""
post_body = {
- 'removeTenantAccess': {
- 'tenant': tenant_id
+ 'remove_tenant_access': {
+ 'tenant_id': tenant_id
}
}
post_body = json.dumps(post_body)
diff --git a/tempest/services/compute/v3/json/keypairs_client.py b/tempest/services/compute/v3/json/keypairs_client.py
index 5e1900c..500aa0e 100644
--- a/tempest/services/compute/v3/json/keypairs_client.py
+++ b/tempest/services/compute/v3/json/keypairs_client.py
@@ -20,15 +20,15 @@
from tempest.common.rest_client import RestClient
-class KeyPairsClientJSON(RestClient):
+class KeyPairsV3ClientJSON(RestClient):
def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(KeyPairsClientJSON, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_type
+ super(KeyPairsV3ClientJSON, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
def list_keypairs(self):
- resp, body = self.get("os-keypairs")
+ resp, body = self.get("keypairs")
body = json.loads(body)
# Each returned keypair is embedded within an unnecessary 'keypair'
# element which is a deviation from other resources like floating-ips,
@@ -38,7 +38,7 @@
return resp, body['keypairs']
def get_keypair(self, key_name):
- resp, body = self.get("os-keypairs/%s" % str(key_name))
+ resp, body = self.get("keypairs/%s" % str(key_name))
body = json.loads(body)
return resp, body['keypair']
@@ -47,10 +47,10 @@
if pub_key:
post_body['keypair']['public_key'] = pub_key
post_body = json.dumps(post_body)
- resp, body = self.post("os-keypairs",
+ resp, body = self.post("keypairs",
headers=self.headers, body=post_body)
body = json.loads(body)
return resp, body['keypair']
def delete_keypair(self, key_name):
- return self.delete("os-keypairs/%s" % str(key_name))
+ return self.delete("keypairs/%s" % str(key_name))
diff --git a/tempest/services/compute/v3/json/servers_client.py b/tempest/services/compute/v3/json/servers_client.py
index a7fcc6d..a486801 100644
--- a/tempest/services/compute/v3/json/servers_client.py
+++ b/tempest/services/compute/v3/json/servers_client.py
@@ -64,12 +64,14 @@
'flavor_ref': flavor_ref
}
- for option in ['personality', 'admin_password', 'key_name',
- 'security_groups', 'networks',
+ for option in ['personality', 'admin_password', 'key_name', 'networks',
+ ('os-security-groups:security_groups',
+ 'security_groups'),
('os-user-data:user_data', 'user_data'),
('os-availability-zone:availability_zone',
'availability_zone'),
- 'access_ip_v4', 'access_ip_v6',
+ ('os-access-ips:access_ip_v4', 'access_ip_v4'),
+ ('os-access-ips:access_ip_v6', 'access_ip_v6'),
('os-multiple-create:min_count', 'min_count'),
('os-multiple-create:max_count', 'max_count'),
('metadata', 'meta'),
@@ -205,6 +207,13 @@
body = json.loads(body)[response_key]
return resp, body
+ def create_backup(self, server_id, backup_type, rotation, name):
+ """Backup a server instance."""
+ return self.action(server_id, "create_backup", None,
+ backup_type=backup_type,
+ rotation=rotation,
+ name=name)
+
def change_password(self, server_id, admin_password):
"""Changes the root password for the server."""
return self.action(server_id, 'change_password', None,
@@ -356,6 +365,14 @@
"""Resets the state of a server to active/error."""
return self.action(server_id, 'reset_state', None, state=state)
+ def shelve_server(self, server_id, **kwargs):
+ """Shelves the provided server."""
+ return self.action(server_id, 'shelve', None, **kwargs)
+
+ def unshelve_server(self, server_id, **kwargs):
+ """Un-shelves the provided server."""
+ return self.action(server_id, 'unshelve', None, **kwargs)
+
def get_console_output(self, server_id, length):
return self.action(server_id, 'get_console_output', 'output',
length=length)
@@ -388,3 +405,11 @@
(str(server_id), str(request_id)))
body = json.loads(body)
return resp, body['instance_action']
+
+ def force_delete_server(self, server_id, **kwargs):
+ """Force delete a server."""
+ return self.action(server_id, 'force_delete', None, **kwargs)
+
+ def restore_soft_deleted_server(self, server_id, **kwargs):
+ """Restore a soft-deleted server."""
+ return self.action(server_id, 'restore', None, **kwargs)
diff --git a/tempest/services/compute/v3/xml/flavors_client.py b/tempest/services/compute/v3/xml/flavors_client.py
index a1c74d9..04c21b4 100644
--- a/tempest/services/compute/v3/xml/flavors_client.py
+++ b/tempest/services/compute/v3/xml/flavors_client.py
@@ -24,21 +24,18 @@
from tempest.services.compute.xml.common import Element
from tempest.services.compute.xml.common import Text
from tempest.services.compute.xml.common import xml_to_json
-from tempest.services.compute.xml.common import XMLNS_11
+from tempest.services.compute.xml.common import XMLNS_V3
-
-XMLNS_OS_FLV_EXT_DATA = \
- "http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1"
XMLNS_OS_FLV_ACCESS = \
- "http://docs.openstack.org/compute/ext/flavor_access/api/v2"
+ "http://docs.openstack.org/compute/core/flavor-access/api/v3"
-class FlavorsClientXML(RestClientXML):
+class FlavorsV3ClientXML(RestClientXML):
def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(FlavorsClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_type
+ super(FlavorsV3ClientXML, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
def _format_flavor(self, f):
flavor = {'links': []}
@@ -51,15 +48,12 @@
flavor['links'].append(v)
continue
- if k == '{%s}ephemeral' % XMLNS_OS_FLV_EXT_DATA:
- k = 'OS-FLV-EXT-DATA:ephemeral'
-
if k == '{%s}is_public' % XMLNS_OS_FLV_ACCESS:
- k = 'os-flavor-access:is_public'
+ k = 'flavor-access:is_public'
v = True if v == 'True' else False
if k == 'extra_specs':
- k = 'OS-FLV-WITH-EXT-SPECS:extra_specs'
+ k = 'flavor-extra-specs:extra_specs'
flavor[k] = dict(v)
continue
@@ -103,7 +97,7 @@
def create_flavor(self, name, ram, vcpus, disk, flavor_id, **kwargs):
"""Creates a new flavor or instance type."""
flavor = Element("flavor",
- xmlns=XMLNS_11,
+ xmlns=XMLNS_V3,
ram=ram,
vcpus=vcpus,
disk=disk,
@@ -114,13 +108,11 @@
if kwargs.get('swap'):
flavor.add_attr('swap', kwargs.get('swap'))
if kwargs.get('ephemeral'):
- flavor.add_attr('OS-FLV-EXT-DATA:ephemeral',
- kwargs.get('ephemeral'))
+ flavor.add_attr('ephemeral', kwargs.get('ephemeral'))
if kwargs.get('is_public'):
- flavor.add_attr('os-flavor-access:is_public',
+ flavor.add_attr('flavor-access:is_public',
kwargs.get('is_public'))
- flavor.add_attr('xmlns:OS-FLV-EXT-DATA', XMLNS_OS_FLV_EXT_DATA)
- flavor.add_attr('xmlns:os-flavor-access', XMLNS_OS_FLV_ACCESS)
+ flavor.add_attr('xmlns:flavor-access', XMLNS_OS_FLV_ACCESS)
resp, body = self.post('flavors', str(Document(flavor)), self.headers)
body = xml_to_json(etree.fromstring(body))
flavor = self._format_flavor(body)
@@ -145,21 +137,21 @@
extra_specs = Element("extra_specs")
for key in specs.keys():
extra_specs.add_attr(key, specs[key])
- resp, body = self.post('flavors/%s/os-extra_specs' % flavor_id,
+ resp, body = self.post('flavors/%s/flavor-extra-specs' % flavor_id,
str(Document(extra_specs)), self.headers)
body = xml_to_json(etree.fromstring(body))
return resp, body
def get_flavor_extra_spec(self, flavor_id):
"""Gets extra Specs of the mentioned flavor."""
- resp, body = self.get('flavors/%s/os-extra_specs' % flavor_id,
+ resp, body = self.get('flavors/%s/flavor-extra-specs' % flavor_id,
self.headers)
body = xml_to_json(etree.fromstring(body))
return resp, body
def get_flavor_extra_spec_with_key(self, flavor_id, key):
"""Gets extra Specs key-value of the mentioned flavor and key."""
- resp, xml_body = self.get('flavors/%s/os-extra_specs/%s' %
+ resp, xml_body = self.get('flavors/%s/flavor-extra-specs/%s' %
(str(flavor_id), key), self.headers)
body = {}
element = etree.fromstring(xml_body)
@@ -176,7 +168,7 @@
value = Text(v)
element.append(value)
- resp, body = self.put('flavors/%s/os-extra_specs/%s' %
+ resp, body = self.put('flavors/%s/flavor-extra-specs/%s' %
(flavor_id, key),
str(doc), self.headers)
body = xml_to_json(etree.fromstring(body))
@@ -184,15 +176,15 @@
def unset_flavor_extra_spec(self, flavor_id, key):
"""Unsets an extra spec based on the mentioned flavor and key."""
- return self.delete('flavors/%s/os-extra_specs/%s' % (str(flavor_id),
- key))
+ return self.delete('flavors/%s/flavor-extra-specs/%s' %
+ (str(flavor_id), key))
def _parse_array_access(self, node):
return [xml_to_json(x) for x in node]
def list_flavor_access(self, flavor_id):
"""Gets flavor access information given the flavor id."""
- resp, body = self.get('flavors/%s/os-flavor-access' % str(flavor_id),
+ resp, body = self.get('flavors/%s/flavor-access' % str(flavor_id),
self.headers)
body = self._parse_array(etree.fromstring(body))
return resp, body
@@ -200,9 +192,9 @@
def add_flavor_access(self, flavor_id, tenant_id):
"""Add flavor access for the specified tenant."""
doc = Document()
- server = Element("addTenantAccess")
+ server = Element("add_tenant_access")
doc.append(server)
- server.add_attr("tenant", tenant_id)
+ server.add_attr("tenant_id", tenant_id)
resp, body = self.post('flavors/%s/action' % str(flavor_id),
str(doc), self.headers)
body = self._parse_array_access(etree.fromstring(body))
@@ -211,9 +203,9 @@
def remove_flavor_access(self, flavor_id, tenant_id):
"""Remove flavor access from the specified tenant."""
doc = Document()
- server = Element("removeTenantAccess")
+ server = Element("remove_tenant_access")
doc.append(server)
- server.add_attr("tenant", tenant_id)
+ server.add_attr("tenant_id", tenant_id)
resp, body = self.post('flavors/%s/action' % str(flavor_id),
str(doc), self.headers)
body = self._parse_array_access(etree.fromstring(body))
diff --git a/tempest/services/compute/v3/xml/keypairs_client.py b/tempest/services/compute/v3/xml/keypairs_client.py
index 0157245..d87daff 100644
--- a/tempest/services/compute/v3/xml/keypairs_client.py
+++ b/tempest/services/compute/v3/xml/keypairs_client.py
@@ -24,21 +24,21 @@
from tempest.services.compute.xml.common import xml_to_json
-class KeyPairsClientXML(RestClientXML):
+class KeyPairsV3ClientXML(RestClientXML):
def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(KeyPairsClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_type
+ super(KeyPairsV3ClientXML, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
def list_keypairs(self):
- resp, body = self.get("os-keypairs", self.headers)
+ resp, body = self.get("keypairs", self.headers)
node = etree.fromstring(body)
body = [{'keypair': xml_to_json(x)} for x in node.getchildren()]
return resp, body
def get_keypair(self, key_name):
- resp, body = self.get("os-keypairs/%s" % str(key_name), self.headers)
+ resp, body = self.get("keypairs/%s" % str(key_name), self.headers)
body = xml_to_json(etree.fromstring(body))
return resp, body
@@ -60,10 +60,10 @@
doc.append(keypair_element)
- resp, body = self.post("os-keypairs",
+ resp, body = self.post("keypairs",
headers=self.headers, body=str(doc))
body = xml_to_json(etree.fromstring(body))
return resp, body
def delete_keypair(self, key_name):
- return self.delete("os-keypairs/%s" % str(key_name))
+ return self.delete("keypairs/%s" % str(key_name))
diff --git a/tempest/services/compute/v3/xml/servers_client.py b/tempest/services/compute/v3/xml/servers_client.py
index 7af4161..c3381a3 100644
--- a/tempest/services/compute/v3/xml/servers_client.py
+++ b/tempest/services/compute/v3/xml/servers_client.py
@@ -214,6 +214,14 @@
"""Resets the state of a server to active/error."""
return self.action(server_id, 'reset_state', None, state=state)
+ def shelve_server(self, server_id, **kwargs):
+ """Shelves the provided server."""
+ return self.action(server_id, 'shelve', None, **kwargs)
+
+ def unshelve_server(self, server_id, **kwargs):
+ """Un-shelves the provided server."""
+ return self.action(server_id, 'unshelve', None, **kwargs)
+
def delete_server(self, server_id):
"""Deletes the given server."""
return self.delete("servers/%s" % str(server_id))
@@ -299,7 +307,17 @@
flavor_ref=flavor_ref,
image_ref=image_ref,
name=name)
- attrs = ["admin_password", "access_ip_v4", "access_ip_v6", "key_name",
+ attrs = ["admin_password", "key_name",
+ ('os-access-ips:access_ip_v4',
+ 'access_ip_v4',
+ 'xmlns:os-access-ips',
+ "http://docs.openstack.org/compute/ext/"
+ "os-access-ips/api/v3"),
+ ('os-access-ips:access_ip_v6',
+ 'access_ip_v6',
+ 'xmlns:os-access-ips',
+ "http://docs.openstack.org/compute/ext/"
+ "os-access-ips/api/v3"),
("os-user-data:user_data",
'user_data',
'xmlns:os-user-data',
@@ -346,7 +364,10 @@
server.add_attr(post_param, value)
if 'security_groups' in kwargs:
- secgroups = Element("security_groups")
+ server.add_attr("xmlns:os-security-groups",
+ "http://docs.openstack.org/compute/ext/"
+ "securitygroups/api/v3")
+ secgroups = Element("os-security-groups:security_groups")
server.append(secgroups)
for secgroup in kwargs['security_groups']:
s = Element("security_group", name=secgroup['name'])
@@ -441,6 +462,13 @@
body = xml_to_json(etree.fromstring(body))
return resp, body
+ def create_backup(self, server_id, backup_type, rotation, name):
+ """Backup a server instance."""
+ return self.action(server_id, "create_backup", None,
+ backup_type=backup_type,
+ rotation=rotation,
+ name=name)
+
def change_password(self, server_id, password):
return self.action(server_id, "change_password", None,
admin_password=password)
@@ -621,3 +649,11 @@
(server_id, request_id), self.headers)
body = xml_to_json(etree.fromstring(body))
return resp, body
+
+ def force_delete_server(self, server_id, **kwargs):
+ """Force delete a server."""
+ return self.action(server_id, 'force_delete', None, **kwargs)
+
+ def restore_soft_deleted_server(self, server_id, **kwargs):
+ """Restore a soft-deleted server."""
+ return self.action(server_id, 'restore', None, **kwargs)
diff --git a/tempest/services/compute/xml/common.py b/tempest/services/compute/xml/common.py
index 860dd5b..d2a18a1 100644
--- a/tempest/services/compute/xml/common.py
+++ b/tempest/services/compute/xml/common.py
@@ -99,7 +99,15 @@
return self.__content
-def xml_to_json(node):
+def parse_array(node, plurals=None):
+ array = []
+ for child in node.getchildren():
+ array.append(xml_to_json(child,
+ plurals))
+ return array
+
+
+def xml_to_json(node, plurals=None):
"""This does a really braindead conversion of an XML tree to
something that looks like a json dump. In cases where the XML
and json structures are the same, then this "just works". In
@@ -115,7 +123,10 @@
tag = child.tag
if tag.startswith("{"):
ns, tag = tag.split("}", 1)
- json[tag] = xml_to_json(child)
+ if plurals is not None and tag in plurals:
+ json[tag] = parse_array(child)
+ else:
+ json[tag] = xml_to_json(child)
return json
diff --git a/tempest/services/compute/xml/hosts_client.py b/tempest/services/compute/xml/hosts_client.py
index f7d7b0a..519798e 100644
--- a/tempest/services/compute/xml/hosts_client.py
+++ b/tempest/services/compute/xml/hosts_client.py
@@ -47,18 +47,16 @@
resp, body = self.get("os-hosts/%s" % str(hostname), self.headers)
node = etree.fromstring(body)
- body = [xml_to_json(x) for x in node.getchildren()]
+ body = [xml_to_json(node)]
return resp, body
- def update_host(self, hostname, status=None, maintenance_mode=None,
- **kwargs):
+ def update_host(self, hostname, **kwargs):
"""Update a host."""
- request_body = Element(status=status,
- maintenance_mode=maintenance_mode)
+ request_body = Element("updates")
if kwargs:
- for k, v in kwargs.iteritem():
- request_body.add_attr(k, v)
+ for k, v in kwargs.iteritems():
+ request_body.append(Element(k, v))
resp, body = self.put("os-hosts/%s" % str(hostname),
str(Document(request_body)),
self.headers)
diff --git a/tempest/services/network/network_client_base.py b/tempest/services/network/network_client_base.py
index b48dd34..45ea2d6 100644
--- a/tempest/services/network/network_client_base.py
+++ b/tempest/services/network/network_client_base.py
@@ -14,7 +14,7 @@
import urllib
-# the folliwing map is used to construct proper URI
+# the following map is used to construct proper URI
# for the given neutron resource
service_resource_prefix_map = {
'networks': '',
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
index a999e31..155fa35 100644
--- a/tempest/services/network/xml/network_client.py
+++ b/tempest/services/network/xml/network_client.py
@@ -19,19 +19,24 @@
from tempest.services.compute.xml.common import deep_dict_to_xml
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
+from tempest.services.compute.xml.common import parse_array
from tempest.services.compute.xml.common import xml_to_json
from tempest.services.network import network_client_base as client_base
class NetworkClientXML(client_base.NetworkClientBase):
+ # list of plurals used for xml serialization
+ PLURALS = ['dns_nameservers', 'host_routes', 'allocation_pools',
+ 'fixed_ips', 'extensions']
+
def get_rest_client(self, config, username, password,
auth_url, tenant_name=None):
return RestClientXML(config, username, password,
auth_url, tenant_name)
def deserialize_list(self, body):
- return self._parse_array(etree.fromstring(body))
+ return parse_array(etree.fromstring(body), self.PLURALS)
def deserialize_single(self, body):
return _root_tag_fetcher_and_xml_to_json_parse(body)
@@ -54,7 +59,7 @@
p1.append(p2)
post_body.append(p1)
resp, body = self.post(uri, str(Document(post_body)))
- networks = self._parse_array(etree.fromstring(body))
+ networks = parse_array(etree.fromstring(body))
networks = {"networks": networks}
return resp, networks
@@ -83,12 +88,6 @@
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- array.append(xml_to_json(child))
- return array
-
def update_port(self, port_id, name):
uri = '%s/ports/%s' % (self.uri_prefix, str(port_id))
port = Element("port")
@@ -151,7 +150,7 @@
p1.append(p2)
post_body.append(p1)
resp, body = self.post(uri, str(Document(post_body)))
- subnets = self._parse_array(etree.fromstring(body))
+ subnets = parse_array(etree.fromstring(body))
subnets = {"subnets": subnets}
return resp, subnets
@@ -166,7 +165,7 @@
p1.append(p2)
post_body.append(p1)
resp, body = self.post(uri, str(Document(post_body)))
- ports = self._parse_array(etree.fromstring(body))
+ ports = parse_array(etree.fromstring(body))
ports = {"ports": ports}
return resp, ports
@@ -366,7 +365,7 @@
def list_router_interfaces(self, uuid):
uri = '%s/ports?device_id=%s' % (self.uri_prefix, uuid)
resp, body = self.get(uri)
- ports = self._parse_array(etree.fromstring(body))
+ ports = parse_array(etree.fromstring(body), self.PLURALS)
ports = {"ports": ports}
return resp, ports
@@ -395,14 +394,14 @@
def list_dhcp_agent_hosting_network(self, network_id):
uri = '%s/networks/%s/dhcp-agents' % (self.uri_prefix, network_id)
resp, body = self.get(uri)
- agents = self._parse_array(etree.fromstring(body))
+ agents = parse_array(etree.fromstring(body))
body = {'agents': agents}
return resp, body
def list_networks_hosted_by_one_dhcp_agent(self, agent_id):
uri = '%s/agents/%s/dhcp-networks' % (self.uri_prefix, agent_id)
resp, body = self.get(uri)
- networks = self._parse_array(etree.fromstring(body))
+ networks = parse_array(etree.fromstring(body))
body = {'networks': networks}
return resp, body
@@ -418,7 +417,8 @@
root_tag = body.tag
if root_tag.startswith("{"):
ns, root_tag = root_tag.split("}", 1)
- body = xml_to_json(etree.fromstring(xml_returned_body))
+ body = xml_to_json(etree.fromstring(xml_returned_body),
+ NetworkClientXML.PLURALS)
nil = '{http://www.w3.org/2001/XMLSchema-instance}nil'
for key, val in body.iteritems():
if isinstance(val, dict):
diff --git a/tempest/test.py b/tempest/test.py
index ceb2c80..342846f 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -33,6 +33,8 @@
LOG = logging.getLogger(__name__)
+CONF = config.CONF
+
# All the successful HTTP status codes from RFC 2616
HTTP_SUCCESS = (200, 201, 202, 203, 204, 205, 206)
@@ -110,15 +112,24 @@
@param bug: bug number causing the test to skip
@param condition: optional condition to be True for the skip to have place
+ @param interface: skip the test if it is the same as self._interface
"""
def decorator(f):
@functools.wraps(f)
- def wrapper(*func_args, **func_kwargs):
- if "bug" in kwargs:
- if "condition" not in kwargs or kwargs["condition"] is True:
- msg = "Skipped until Bug: %s is resolved." % kwargs["bug"]
- raise testtools.TestCase.skipException(msg)
- return f(*func_args, **func_kwargs)
+ def wrapper(self, *func_args, **func_kwargs):
+ skip = False
+ if "condition" in kwargs:
+ if kwargs["condition"] is True:
+ skip = True
+ elif "interface" in kwargs:
+ if kwargs["interface"] == self._interface:
+ skip = True
+ else:
+ skip = True
+ if "bug" in kwargs and skip is True:
+ msg = "Skipped until Bug: %s is resolved." % kwargs["bug"]
+ raise testtools.TestCase.skipException(msg)
+ return f(self, *func_args, **func_kwargs)
return wrapper
return decorator
@@ -146,7 +157,7 @@
"""A function that will check the list of enabled extensions from config
"""
- configs = config.TempestConfig()
+ configs = CONF
config_dict = {
'compute': configs.compute_feature_enabled.api_extensions,
'compute_v3': configs.compute_feature_enabled.api_v3_extensions,
@@ -214,7 +225,7 @@
testtools.testcase.WithAttributes,
testresources.ResourcedTestCase):
- config = config.TempestConfig()
+ config = CONF
setUpClassCalled = False
diff --git a/tempest/thirdparty/boto/test.py b/tempest/thirdparty/boto/test.py
index 5ae21c8..2f7a650 100644
--- a/tempest/thirdparty/boto/test.py
+++ b/tempest/thirdparty/boto/test.py
@@ -29,7 +29,7 @@
import tempest.clients
from tempest.common.utils.file_utils import have_effective_read_access
-import tempest.config
+from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
import tempest.test
@@ -37,6 +37,7 @@
from tempest.thirdparty.boto.utils.wait import state_wait
from tempest.thirdparty.boto.utils.wait import wait_exception
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -50,11 +51,10 @@
def all_read(*args):
return all(map(have_effective_read_access, args))
- config = tempest.config.TempestConfig()
- materials_path = config.boto.s3_materials_path
- ami_path = materials_path + os.sep + config.boto.ami_manifest
- aki_path = materials_path + os.sep + config.boto.aki_manifest
- ari_path = materials_path + os.sep + config.boto.ari_manifest
+ materials_path = CONF.boto.s3_materials_path
+ ami_path = materials_path + os.sep + CONF.boto.ami_manifest
+ aki_path = materials_path + os.sep + CONF.boto.aki_manifest
+ ari_path = materials_path + os.sep + CONF.boto.ari_manifest
A_I_IMAGES_READY = all_read(ami_path, aki_path, ari_path)
boto_logger = logging.getLogger('boto')
@@ -70,7 +70,7 @@
raise Exception("Unknown (Authentication?) Error")
openstack = tempest.clients.Manager()
try:
- if urlparse.urlparse(config.boto.ec2_url).hostname is None:
+ if urlparse.urlparse(CONF.boto.ec2_url).hostname is None:
raise Exception("Failed to get hostname from the ec2_url")
ec2client = openstack.ec2api_client
try:
@@ -87,7 +87,7 @@
EC2_CAN_CONNECT_ERROR = str(exc)
try:
- if urlparse.urlparse(config.boto.s3_url).hostname is None:
+ if urlparse.urlparse(CONF.boto.s3_url).hostname is None:
raise Exception("Failed to get hostname from the s3_url")
s3client = openstack.s3_client
try:
diff --git a/tempest/thirdparty/boto/utils/wait.py b/tempest/thirdparty/boto/utils/wait.py
index 1cd847b..db2303a 100644
--- a/tempest/thirdparty/boto/utils/wait.py
+++ b/tempest/thirdparty/boto/utils/wait.py
@@ -21,17 +21,12 @@
import boto.exception
from testtools import TestCase
-import tempest.config
+from tempest import config
from tempest.openstack.common import log as logging
+CONF = config.CONF
LOG = logging.getLogger(__name__)
-_boto_config = tempest.config.TempestConfig().boto
-
-default_timeout = _boto_config.build_timeout
-
-default_check_interval = _boto_config.build_interval
-
def state_wait(lfunction, final_set=set(), valid_set=None):
# TODO(afazekas): evaluate using ABC here
@@ -50,12 +45,12 @@
if valid_set is not None and status not in valid_set:
return status
dtime = time.time() - start_time
- if dtime > default_timeout:
+ if dtime > CONF.boto.build_timeout:
raise TestCase.failureException("State change timeout exceeded!"
'(%ds) While waiting'
'for %s at "%s"' %
(dtime, final_set, status))
- time.sleep(default_check_interval)
+ time.sleep(CONF.boto.build_interval)
old_status = status
status = lfunction()
@@ -73,12 +68,12 @@
text)
return result
dtime = time.time() - start_time
- if dtime > default_timeout:
+ if dtime > CONF.boto.build_timeout:
raise TestCase.failureException('Pattern find timeout exceeded!'
'(%ds) While waiting for'
'"%s" pattern in "%s"' %
(dtime, regexp, text))
- time.sleep(default_check_interval)
+ time.sleep(CONF.boto.build_interval)
def wait_no_exception(lfunction, exc_class=None, exc_matcher=None):
@@ -104,10 +99,10 @@
raise exc
# Let the other exceptions propagate
dtime = time.time() - start_time
- if dtime > default_timeout:
+ if dtime > CONF.boto.build_timeout:
raise TestCase.failureException("Wait timeout exceeded! (%ds)" %
dtime)
- time.sleep(default_check_interval)
+ time.sleep(CONF.boto.build_interval)
# NOTE(afazekas): EC2/boto normally raise exception instead of empty list
@@ -122,9 +117,9 @@
time.time() - start_time)
return exc
dtime = time.time() - start_time
- if dtime > default_timeout:
+ if dtime > CONF.boto.build_timeout:
raise TestCase.failureException("Wait timeout exceeded! (%ds)" %
dtime)
- time.sleep(default_check_interval)
+ time.sleep(CONF.boto.build_interval)
# TODO(afazekas): consider strategy design pattern..
diff --git a/tools/verify_tempest_config.py b/tools/verify_tempest_config.py
index 347659d..8850c2e 100755
--- a/tools/verify_tempest_config.py
+++ b/tools/verify_tempest_config.py
@@ -21,7 +21,7 @@
from tempest import config
-CONF = config.TempestConfig()
+CONF = config.CONF
#Dicts matching extension names to config options
NOVA_EXTENSIONS = {