Merge "Remove unused method basic_auth from rest client"
diff --git a/README.rst b/README.rst
index 4098e32..bff2bf8 100644
--- a/README.rst
+++ b/README.rst
@@ -63,13 +63,13 @@
used tool. After setting up your configuration file, you can execute
the set of Tempest tests by using ``testr`` ::
- $> testr run --parallel tempest
+ $> testr run --parallel
To run one single test ::
$> 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
+Alternatively, you can use the run_tempest.sh script which will create a venv
and run the tests or use tox to do the same.
Configuration
@@ -101,3 +101,20 @@
For the moment, the best solution is to provide the same image uuid for
both image_ref and image_ref_alt. Tempest will skip tests as needed if it
detects that both images are the same.
+
+Unit Tests
+----------
+
+Tempest also has a set of unit tests which test the tempest code itself. These
+tests can be run by specifing the test discovery path::
+
+ $> OS_TEST_PATH=./tempest/tests testr run --parallel
+
+By setting OS_TEST_PATH to ./tempest/tests it specifies that test discover
+should only be run on the unit test directory. The default value of OS_TEST_PATH
+is OS_TEST_PATH=./tempest/test_discover which will only run test discover on the
+tempest suite.
+
+Alternatively, you can use the run_tests.sh script which will create a venv and
+run the unit tests. There are also the py26, py27, or py33 tox jobs which will
+run the unit tests with the corresponding version of python.
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index bb9a68e..21c8506 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -226,7 +226,7 @@
# Timeout in seconds to wait for ping to succeed. (integer
# value)
-#ping_timeout=60
+#ping_timeout=120
# Timeout in seconds to wait for authentication to succeed.
# (integer value)
diff --git a/etc/whitelist.yaml b/etc/whitelist.yaml
index 1c12b6c..2d8b741 100644
--- a/etc/whitelist.yaml
+++ b/etc/whitelist.yaml
@@ -78,6 +78,8 @@
ceilometer-acentral:
- module: "ceilometer.central.manager"
message: "403 Forbidden"
+ - module: "ceilometer.central.manager"
+ message: "get_samples\\(\\) got an unexpected keyword argument 'resources'"
ceilometer-alarm-evaluator:
- module: "ceilometer.alarm.service"
@@ -133,6 +135,8 @@
message: "but the actual state is deleting to caller"
- module: "nova.openstack.common.rpc.common"
message: "Traceback \\(most recent call last"
+ - module: "nova.openstack.common.threadgroup"
+ message: "Service with host .* topic conductor exists."
n-sch:
- module: "nova.scheduler.filter_scheduler"
diff --git a/run_tempest.sh b/run_tempest.sh
index be9b38a..f6c330d 100755
--- a/run_tempest.sh
+++ b/run_tempest.sh
@@ -13,7 +13,7 @@
echo " -t, --serial Run testr serially"
echo " -C, --config Config file location"
echo " -h, --help Print this usage message"
- echo " -d, --debug Debug this script -- set -o xtrace"
+ echo " -d, --debug Run tests with testtools instead of testr. This allows you to use PDB"
echo " -l, --logging Enable logging"
echo " -L, --logging-config Logging config file location. Default is etc/logging.conf"
echo " -- [TESTROPTIONS] After the first '--' you can pass arbitrary arguments to testr "
@@ -26,6 +26,7 @@
always_venv=0
never_venv=0
no_site_packages=0
+debug=0
force=0
wrapper=""
config_file=""
@@ -50,7 +51,7 @@
-n|--no-site-packages) no_site_packages=1;;
-f|--force) force=1;;
-u|--update) update=1;;
- -d|--debug) set -o xtrace;;
+ -d|--debug) debug=1;;
-C|--config) config_file=$2; shift;;
-s|--smoke) testrargs+="smoke"; noseargs+="--attr=type=smoke";;
-t|--serial) serial=1;;
@@ -94,6 +95,14 @@
testr_init
${wrapper} find . -type f -name "*.pyc" -delete
export OS_TEST_PATH=./tempest/test_discover
+ if [ $debug -eq 1 ]; then
+ if [ "$testrargs" = "" ]; then
+ testrargs="discover ./tempest/test_discover"
+ fi
+ ${wrapper} python -m testtools.run $testrargs
+ return $?
+ fi
+
if [ $serial -eq 1 ]; then
${wrapper} testr run --subunit $testrargs | ${wrapper} subunit-2to1 | ${wrapper} tools/colorizer.py
else
diff --git a/run_tests.sh b/run_tests.sh
index 3f00453..eaa7fd7 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -13,7 +13,7 @@
echo " -p, --pep8 Just run pep8"
echo " -c, --coverage Generate coverage report"
echo " -h, --help Print this usage message"
- echo " -d, --debug Debug this script -- set -o xtrace"
+ echo " -d, --debug Run tests with testtools instead of testr. This allows you to use PDB"
echo " -- [TESTROPTIONS] After the first '--' you can pass arbitrary arguments to testr "
}
@@ -25,6 +25,7 @@
always_venv=0
never_venv=0
no_site_packages=0
+debug=0
force=0
coverage=0
wrapper=""
@@ -48,7 +49,7 @@
-n|--no-site-packages) no_site_packages=1;;
-f|--force) force=1;;
-u|--update) update=1;;
- -d|--debug) set -o xtrace;;
+ -d|--debug) debug=1;;
-p|--pep8) let just_pep8=1;;
-c|--coverage) coverage=1;;
-t|--serial) serial=1;;
@@ -75,6 +76,14 @@
testr_init
${wrapper} find . -type f -name "*.pyc" -delete
export OS_TEST_PATH=./tempest/tests
+ if [ $debug -eq 1 ]; then
+ if [ "$testrargs" = "" ]; then
+ testrargs="discover ./tempest/tests"
+ fi
+ ${wrapper} python -m testtools.run $testrargs
+ return $?
+ fi
+
if [ $serial -eq 1 ]; then
${wrapper} testr run --subunit $testrargs | ${wrapper} subunit-2to1 | ${wrapper} tools/colorizer.py
else
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index dfcc6a9..d4a32e6 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -15,12 +15,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import config
-from tempest import exceptions
-from tempest.test import attr
-from tempest.test import skip_because
-
-CONF = config.CONF
+from tempest import test
class QuotasAdminTestJSON(base.BaseV2ComputeAdminTest):
@@ -30,11 +25,8 @@
@classmethod
def setUpClass(cls):
super(QuotasAdminTestJSON, cls).setUpClass()
- cls.auth_url = cls.config.identity.uri
cls.client = cls.os.quotas_client
cls.adm_client = cls.os_adm.quotas_client
- cls.identity_admin_client = cls._get_identity_admin_client()
- cls.sg_client = cls.security_groups_client
# NOTE(afazekas): these test cases should always create and use a new
# tenant most of them should be skipped if we can't do that
@@ -49,7 +41,7 @@
'instances', 'security_group_rules',
'cores', 'security_groups'))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_get_default_quotas(self):
# Admin can get the default resource quota set for a tenant
expected_quota_set = self.default_quota_set | set(['id'])
@@ -60,7 +52,7 @@
sorted(quota_set.keys()))
self.assertEqual(quota_set['id'], self.demo_tenant_id)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_all_quota_resources_for_tenant(self):
# Admin can update all the resource quota limits for a tenant
resp, default_quota_set = self.client.get_default_quota_set(
@@ -84,7 +76,7 @@
self.assertEqual(new_quota_set, quota_set)
# TODO(afazekas): merge these test cases
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_updated_quotas(self):
# Verify that GET shows the updated quota set
tenant_name = data_utils.rand_name('cpu_quota_tenant_')
@@ -102,119 +94,6 @@
self.assertEqual(200, resp.status)
self.assertEqual(quota_set['ram'], 5120)
- # TODO(afazekas): Add dedicated tenant to the skiped quota tests
- # it can be moved into the setUpClass as well
- @attr(type='gate')
- def test_create_server_when_cpu_quota_is_full(self):
- # Disallow server creation when tenant's vcpu quota is full
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
- default_vcpu_quota = quota_set['cores']
- vcpu_quota = 0 # Set the quota to zero to conserve resources
-
- resp, quota_set = self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- cores=vcpu_quota)
-
- self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
- cores=default_vcpu_quota)
- self.assertRaises(exceptions.OverLimit, self.create_test_server)
-
- @attr(type='gate')
- def test_create_server_when_memory_quota_is_full(self):
- # Disallow server creation when tenant's memory quota is full
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
- default_mem_quota = quota_set['ram']
- mem_quota = 0 # Set the quota to zero to conserve resources
-
- self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- ram=mem_quota)
-
- self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
- ram=default_mem_quota)
- self.assertRaises(exceptions.OverLimit, self.create_test_server)
-
- @attr(type='gate')
- def test_update_quota_normal_user(self):
- self.assertRaises(exceptions.Unauthorized,
- self.client.update_quota_set,
- self.demo_tenant_id,
- ram=0)
-
- @attr(type=['negative', 'gate'])
- def test_create_server_when_instances_quota_is_full(self):
- # Once instances quota limit is reached, disallow server creation
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
- default_instances_quota = quota_set['instances']
- instances_quota = 0 # Set quota to zero to disallow server creation
-
- self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- instances=instances_quota)
- self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
- instances=default_instances_quota)
- self.assertRaises(exceptions.OverLimit, self.create_test_server)
-
- @skip_because(bug="1186354",
- condition=CONF.service_available.neutron)
- @attr(type=['negative', 'gate'])
- def test_security_groups_exceed_limit(self):
- # Negative test: Creation Security Groups over limit should FAIL
-
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
- default_sg_quota = quota_set['security_groups']
- sg_quota = 0 # Set the quota to zero to conserve resources
-
- resp, quota_set =\
- self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- security_groups=sg_quota)
-
- self.addCleanup(self.adm_client.update_quota_set,
- self.demo_tenant_id,
- security_groups=default_sg_quota)
-
- # Check we cannot create anymore
- self.assertRaises(exceptions.OverLimit,
- self.sg_client.create_security_group,
- "sg-overlimit", "sg-desc")
-
- @skip_because(bug="1186354",
- condition=CONF.service_available.neutron)
- @attr(type=['negative', 'gate'])
- def test_security_groups_rules_exceed_limit(self):
- # Negative test: Creation of Security Group Rules should FAIL
- # when we reach limit maxSecurityGroupRules
-
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
- default_sg_rules_quota = quota_set['security_group_rules']
- sg_rules_quota = 0 # Set the quota to zero to conserve resources
-
- resp, quota_set =\
- self.adm_client.update_quota_set(
- self.demo_tenant_id,
- force=True,
- security_group_rules=sg_rules_quota)
-
- self.addCleanup(self.adm_client.update_quota_set,
- self.demo_tenant_id,
- security_group_rules=default_sg_rules_quota)
-
- s_name = data_utils.rand_name('securitygroup-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup =\
- self.sg_client.create_security_group(s_name, s_description)
- self.addCleanup(self.sg_client.delete_security_group,
- securitygroup['id'])
-
- secgroup_id = securitygroup['id']
- ip_protocol = 'tcp'
-
- # Check we cannot create SG rule anymore
- self.assertRaises(exceptions.OverLimit,
- self.sg_client.create_security_group_rule,
- secgroup_id, ip_protocol, 1025, 1025)
-
class QuotasAdminTestXML(QuotasAdminTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py
new file mode 100644
index 0000000..d3696a1
--- /dev/null
+++ b/tempest/api/compute/admin/test_quotas_negative.py
@@ -0,0 +1,155 @@
+# Copyright 2014 NEC Corporation. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import config
+from tempest import exceptions
+from tempest import test
+
+CONF = config.CONF
+
+
+class QuotasAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
+ _interface = 'json'
+ force_tenant_isolation = True
+
+ @classmethod
+ def setUpClass(cls):
+ super(QuotasAdminNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.os.quotas_client
+ cls.adm_client = cls.os_adm.quotas_client
+ cls.sg_client = cls.security_groups_client
+
+ # NOTE(afazekas): these test cases should always create and use a new
+ # tenant most of them should be skipped if we can't do that
+ cls.demo_tenant_id = cls.isolated_creds.get_primary_user().get(
+ 'tenantId')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_update_quota_normal_user(self):
+ self.assertRaises(exceptions.Unauthorized,
+ self.client.update_quota_set,
+ self.demo_tenant_id,
+ ram=0)
+
+ # TODO(afazekas): Add dedicated tenant to the skiped quota tests
+ # it can be moved into the setUpClass as well
+ @test.attr(type=['negative', 'gate'])
+ def test_create_server_when_cpu_quota_is_full(self):
+ # Disallow server creation when tenant's vcpu quota is full
+ resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ default_vcpu_quota = quota_set['cores']
+ vcpu_quota = 0 # Set the quota to zero to conserve resources
+
+ resp, quota_set = self.adm_client.update_quota_set(self.demo_tenant_id,
+ force=True,
+ cores=vcpu_quota)
+
+ self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
+ cores=default_vcpu_quota)
+ self.assertRaises(exceptions.OverLimit, self.create_test_server)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_server_when_memory_quota_is_full(self):
+ # Disallow server creation when tenant's memory quota is full
+ resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ default_mem_quota = quota_set['ram']
+ mem_quota = 0 # Set the quota to zero to conserve resources
+
+ self.adm_client.update_quota_set(self.demo_tenant_id,
+ force=True,
+ ram=mem_quota)
+
+ self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
+ ram=default_mem_quota)
+ self.assertRaises(exceptions.OverLimit, self.create_test_server)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_server_when_instances_quota_is_full(self):
+ # Once instances quota limit is reached, disallow server creation
+ resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ default_instances_quota = quota_set['instances']
+ instances_quota = 0 # Set quota to zero to disallow server creation
+
+ self.adm_client.update_quota_set(self.demo_tenant_id,
+ force=True,
+ instances=instances_quota)
+ self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
+ instances=default_instances_quota)
+ self.assertRaises(exceptions.OverLimit, self.create_test_server)
+
+ @test.skip_because(bug="1186354",
+ condition=CONF.service_available.neutron)
+ @test.attr(type='gate')
+ def test_security_groups_exceed_limit(self):
+ # Negative test: Creation Security Groups over limit should FAIL
+
+ resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ default_sg_quota = quota_set['security_groups']
+ sg_quota = 0 # Set the quota to zero to conserve resources
+
+ resp, quota_set =\
+ self.adm_client.update_quota_set(self.demo_tenant_id,
+ force=True,
+ security_groups=sg_quota)
+
+ self.addCleanup(self.adm_client.update_quota_set,
+ self.demo_tenant_id,
+ security_groups=default_sg_quota)
+
+ # Check we cannot create anymore
+ self.assertRaises(exceptions.OverLimit,
+ self.sg_client.create_security_group,
+ "sg-overlimit", "sg-desc")
+
+ @test.skip_because(bug="1186354",
+ condition=CONF.service_available.neutron)
+ @test.attr(type=['negative', 'gate'])
+ def test_security_groups_rules_exceed_limit(self):
+ # Negative test: Creation of Security Group Rules should FAIL
+ # when we reach limit maxSecurityGroupRules
+
+ resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
+ default_sg_rules_quota = quota_set['security_group_rules']
+ sg_rules_quota = 0 # Set the quota to zero to conserve resources
+
+ resp, quota_set =\
+ self.adm_client.update_quota_set(
+ self.demo_tenant_id,
+ force=True,
+ security_group_rules=sg_rules_quota)
+
+ self.addCleanup(self.adm_client.update_quota_set,
+ self.demo_tenant_id,
+ security_group_rules=default_sg_rules_quota)
+
+ s_name = data_utils.rand_name('securitygroup-')
+ s_description = data_utils.rand_name('description-')
+ resp, securitygroup =\
+ self.sg_client.create_security_group(s_name, s_description)
+ self.addCleanup(self.sg_client.delete_security_group,
+ securitygroup['id'])
+
+ secgroup_id = securitygroup['id']
+ ip_protocol = 'tcp'
+
+ # Check we cannot create SG rule anymore
+ self.assertRaises(exceptions.OverLimit,
+ self.sg_client.create_security_group_rule,
+ secgroup_id, ip_protocol, 1025, 1025)
+
+
+class QuotasAdminNegativeTestXML(QuotasAdminNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_servers.py b/tempest/api/compute/admin/test_servers.py
index 10484a9..2cee78a 100644
--- a/tempest/api/compute/admin/test_servers.py
+++ b/tempest/api/compute/admin/test_servers.py
@@ -99,6 +99,18 @@
self.servers_client.wait_for_server_termination(server['id'])
@attr(type='gate')
+ def test_delete_server_while_in_error_state(self):
+ # Delete a server while it's VM state is error
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.reset_state(server['id'], state='error')
+ self.assertEqual(202, resp.status)
+ # Verify server's state
+ resp, server = self.client.get_server(server['id'])
+ self.assertEqual(server['status'], 'ERROR')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+
+ @attr(type='gate')
def test_reset_state_server(self):
# Reset server's state to 'error'
resp, server = self.client.reset_state(self.s1_id)
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 872a841..5539894 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -33,9 +33,6 @@
@classmethod
def setUpClass(cls):
super(BaseComputeTest, cls).setUpClass()
- if not cls.config.service_available.nova:
- skip_msg = ("%s skipped as nova is not available" % cls.__name__)
- raise cls.skipException(skip_msg)
os = cls.get_client_manager()
@@ -261,6 +258,11 @@
@classmethod
def setUpClass(cls):
# By default compute tests do not create network resources
+ if cls._interface == "xml":
+ skip_msg = ("XML interface is being removed from Nova v3. "
+ "%s will be removed shortly" % cls.__name__)
+ raise cls.skipException(skip_msg)
+
cls.set_network_resources()
super(BaseV3ComputeTest, cls).setUpClass()
if not cls.config.compute_feature_enabled.api_v3:
diff --git a/tempest/api/compute/floating_ips/base.py b/tempest/api/compute/floating_ips/base.py
index e2c9b04..fd76e62 100644
--- a/tempest/api/compute/floating_ips/base.py
+++ b/tempest/api/compute/floating_ips/base.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2014 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/images/test_list_image_filters.py b/tempest/api/compute/images/test_list_image_filters.py
index 8ace879..c04729c 100644
--- a/tempest/api/compute/images/test_list_image_filters.py
+++ b/tempest/api/compute/images/test_list_image_filters.py
@@ -220,7 +220,7 @@
self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
@attr(type=['negative', 'gate'])
- def test_get_nonexistant_image(self):
+ def test_get_nonexistent_image(self):
# Negative test: GET on non-existent image should fail
self.assertRaises(exceptions.NotFound, self.client.get_image, 999)
diff --git a/tempest/api/compute/keypairs/test_keypairs_negative.py b/tempest/api/compute/keypairs/test_keypairs_negative.py
index 85b8505..93b0692 100644
--- a/tempest/api/compute/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/keypairs/test_keypairs_negative.py
@@ -41,9 +41,9 @@
self._create_keypair, k_name, pub_key)
@test.attr(type=['negative', 'gate'])
- def test_keypair_delete_nonexistant_key(self):
- # Non-existant key deletion should throw a proper error
- k_name = data_utils.rand_name("keypair-non-existant-")
+ def test_keypair_delete_nonexistent_key(self):
+ # Non-existent key deletion should throw a proper error
+ k_name = data_utils.rand_name("keypair-non-existent-")
self.assertRaises(exceptions.NotFound, self.client.delete_keypair,
k_name)
diff --git a/tempest/api/compute/security_groups/base.py b/tempest/api/compute/security_groups/base.py
index 66f2600..6838ce1 100644
--- a/tempest/api/compute/security_groups/base.py
+++ b/tempest/api/compute/security_groups/base.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 582faf8..fea8dd5 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -84,7 +84,8 @@
# Log in and verify the boot time has changed
linux_client = RemoteClient(server, self.ssh_user, self.password)
new_boot_time = linux_client.get_boot_time()
- self.assertGreater(new_boot_time, boot_time)
+ self.assertTrue(new_boot_time > boot_time,
+ '%s > %s' % (new_boot_time, boot_time))
@skip_because(bug="1014647")
@attr(type='smoke')
@@ -104,7 +105,8 @@
# Log in and verify the boot time has changed
linux_client = RemoteClient(server, self.ssh_user, self.password)
new_boot_time = linux_client.get_boot_time()
- self.assertGreater(new_boot_time, boot_time)
+ self.assertTrue(new_boot_time > boot_time,
+ '%s > %s' % (new_boot_time, boot_time))
@attr(type='smoke')
def test_rebuild_server(self):
@@ -230,7 +232,7 @@
def test_create_backup(self):
# Positive test:create backup successfully and rotate backups correctly
# create the first and the second backup
- backup1 = data_utils.rand_name('backup')
+ backup1 = data_utils.rand_name('backup-1')
resp, _ = self.servers_client.create_backup(self.server_id,
'daily',
2,
@@ -247,7 +249,7 @@
self.assertEqual(202, resp.status)
self.os.image_client.wait_for_image_status(image1_id, 'active')
- backup2 = data_utils.rand_name('backup')
+ backup2 = data_utils.rand_name('backup-2')
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
resp, _ = self.servers_client.create_backup(self.server_id,
'daily',
@@ -266,6 +268,7 @@
}
resp, image_list = self.os.image_client.image_list_detail(
properties,
+ status='active',
sort_key='created_at',
sort_dir='asc')
self.assertEqual(200, resp.status)
@@ -275,7 +278,7 @@
# create the third one, due to the rotation is 2,
# the first one will be deleted
- backup3 = data_utils.rand_name('backup')
+ backup3 = data_utils.rand_name('backup-3')
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
resp, _ = self.servers_client.create_backup(self.server_id,
'daily',
@@ -290,10 +293,15 @@
oldest_backup_exist = False
resp, image_list = self.os.image_client.image_list_detail(
properties,
+ status='active',
sort_key='created_at',
sort_dir='asc')
self.assertEqual(200, resp.status)
- self.assertEqual(2, len(image_list))
+ self.assertEqual(2, len(image_list),
+ 'Unexpected number of images for '
+ 'v2:test_create_backup; was the oldest backup not '
+ 'yet deleted? Image list: %s' %
+ [image['name'] for image in image_list])
self.assertEqual((backup2, backup3),
(image_list[0]['name'], image_list[1]['name']))
diff --git a/tempest/api/compute/servers/test_server_metadata.py b/tempest/api/compute/servers/test_server_metadata.py
index 80ac4da..ad4931c 100644
--- a/tempest/api/compute/servers/test_server_metadata.py
+++ b/tempest/api/compute/servers/test_server_metadata.py
@@ -14,8 +14,7 @@
# under the License.
from tempest.api.compute import base
-from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ServerMetadataTestJSON(base.BaseV2ComputeTest):
@@ -28,8 +27,6 @@
cls.quotas = cls.quotas_client
cls.admin_client = cls._get_identity_admin_client()
resp, tenants = cls.admin_client.list_tenants()
- cls.tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
- cls.client.tenant_name][0]
resp, server = cls.create_test_server(meta={}, wait_until='ACTIVE')
cls.server_id = server['id']
@@ -40,7 +37,7 @@
resp, _ = self.client.set_server_metadata(self.server_id, meta)
self.assertEqual(resp.status, 200)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_server_metadata(self):
# All metadata key/value pairs for a server should be returned
resp, resp_metadata = self.client.list_server_metadata(self.server_id)
@@ -50,7 +47,7 @@
expected = {'key1': 'value1', 'key2': 'value2'}
self.assertEqual(expected, resp_metadata)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_set_server_metadata(self):
# The server's metadata should be replaced with the provided values
# Create a new set of metadata for the server
@@ -64,22 +61,7 @@
resp, resp_metadata = self.client.list_server_metadata(self.server_id)
self.assertEqual(resp_metadata, req_metadata)
- @attr(type='gate')
- def test_server_create_metadata_key_too_long(self):
- # Attempt to start a server with a meta-data key that is > 255
- # characters
-
- # Try a few values
- for sz in [256, 257, 511, 1023]:
- key = "k" * sz
- meta = {key: 'data1'}
- self.assertRaises(exceptions.OverLimit,
- self.create_test_server,
- meta=meta)
-
- # no teardown - all creates should fail
-
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_server_metadata(self):
# The server's metadata values should be updated to the
# provided values
@@ -93,7 +75,7 @@
expected = {'key1': 'alt1', 'key2': 'value2', 'key3': 'value3'}
self.assertEqual(expected, resp_metadata)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_metadata_empty_body(self):
# The original metadata should not be lost if empty metadata body is
# passed
@@ -103,14 +85,14 @@
expected = {'key1': 'value1', 'key2': 'value2'}
self.assertEqual(expected, resp_metadata)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_server_metadata_item(self):
# The value for a specific metadata key should be returned
resp, meta = self.client.get_server_metadata_item(self.server_id,
'key2')
self.assertEqual('value2', meta['key2'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_set_server_metadata_item(self):
# The item's value should be updated to the provided value
# Update the metadata value
@@ -124,7 +106,7 @@
expected = {'key1': 'value1', 'key2': 'value2', 'nova': 'alt'}
self.assertEqual(expected, resp_metadata)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_server_metadata_item(self):
# The metadata value/key pair should be deleted from the server
resp, meta = self.client.delete_server_metadata_item(self.server_id,
@@ -136,80 +118,6 @@
expected = {'key2': 'value2'}
self.assertEqual(expected, resp_metadata)
- @attr(type=['negative', 'gate'])
- def test_server_metadata_negative(self):
- # Blank key should trigger an error.
- meta = {'': 'data1'}
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server,
- meta=meta)
-
- # GET on a non-existent server should not succeed
- self.assertRaises(exceptions.NotFound,
- self.client.get_server_metadata_item, 999, 'test2')
-
- # List metadata on a non-existent server should not succeed
- self.assertRaises(exceptions.NotFound,
- self.client.list_server_metadata, 999)
-
- # Raise BadRequest if key in uri does not match
- # the key passed in body.
- meta = {'testkey': 'testvalue'}
- self.assertRaises(exceptions.BadRequest,
- self.client.set_server_metadata_item,
- self.server_id, 'key', meta)
-
- # Set metadata on a non-existent server should not succeed
- meta = {'meta1': 'data1'}
- self.assertRaises(exceptions.NotFound,
- self.client.set_server_metadata, 999, meta)
-
- # An update should not happen for a non-existent image
- meta = {'key1': 'value1', 'key2': 'value2'}
- self.assertRaises(exceptions.NotFound,
- self.client.update_server_metadata, 999, meta)
-
- # Blank key should trigger an error
- meta = {'': 'data1'}
- self.assertRaises(exceptions.BadRequest,
- self.client.update_server_metadata,
- self.server_id, meta=meta)
-
- # Should not be able to delete metadata item from a non-existent server
- self.assertRaises(exceptions.NotFound,
- self.client.delete_server_metadata_item, 999, 'd')
-
- # Raise a 413 OverLimit exception while exceeding metadata items limit
- # for tenant.
- _, quota_set = self.quotas.get_quota_set(self.tenant_id)
- quota_metadata = quota_set['metadata_items']
- req_metadata = {}
- for num in range(1, quota_metadata + 2):
- req_metadata['key' + str(num)] = 'val' + str(num)
- self.assertRaises(exceptions.OverLimit,
- self.client.set_server_metadata,
- self.server_id, req_metadata)
-
- # Raise a 413 OverLimit exception while exceeding metadata items limit
- # for tenant (update).
- self.assertRaises(exceptions.OverLimit,
- self.client.update_server_metadata,
- self.server_id, req_metadata)
-
- # Raise a bad request error for blank key.
- # set_server_metadata will replace all metadata with new value
- meta = {'': 'data1'}
- self.assertRaises(exceptions.BadRequest,
- self.client.set_server_metadata,
- self.server_id, meta=meta)
-
- # Raise a bad request error for a missing metadata field
- # set_server_metadata will replace all metadata with new value
- meta = {'meta1': 'data1'}
- self.assertRaises(exceptions.BadRequest,
- self.client.set_server_metadata,
- self.server_id, meta=meta, no_metadata_field=True)
-
class ServerMetadataTestXML(ServerMetadataTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/servers/test_server_metadata_negative.py b/tempest/api/compute/servers/test_server_metadata_negative.py
new file mode 100644
index 0000000..d12f91c
--- /dev/null
+++ b/tempest/api/compute/servers/test_server_metadata_negative.py
@@ -0,0 +1,165 @@
+# 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.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class ServerMetadataNegativeTestJSON(base.BaseV2ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ServerMetadataNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.servers_client
+ cls.quotas = cls.quotas_client
+ cls.admin_client = cls._get_identity_admin_client()
+ resp, tenants = cls.admin_client.list_tenants()
+ cls.tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
+ cls.client.tenant_name][0]
+ resp, server = cls.create_test_server(meta={}, wait_until='ACTIVE')
+
+ cls.server_id = server['id']
+
+ @test.attr(type=['gate', 'negative'])
+ def test_server_create_metadata_key_too_long(self):
+ # Attempt to start a server with a meta-data key that is > 255
+ # characters
+
+ # Tryset_server_metadata_item a few values
+ for sz in [256, 257, 511, 1023]:
+ key = "k" * sz
+ meta = {key: 'data1'}
+ self.assertRaises(exceptions.OverLimit,
+ self.create_test_server,
+ meta=meta)
+
+ # no teardown - all creates should fail
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_server_metadata_blank_key(self):
+ # Blank key should trigger an error.
+ meta = {'': 'data1'}
+ self.assertRaises(exceptions.BadRequest,
+ self.create_test_server,
+ meta=meta)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_server_metadata_non_existent_server(self):
+ # GET on a non-existent server should not succeed
+ non_existent_server_id = data_utils.rand_uuid()
+ self.assertRaises(exceptions.NotFound,
+ self.client.get_server_metadata_item,
+ non_existent_server_id,
+ 'test2')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_list_server_metadata_non_existent_server(self):
+ # List metadata on a non-existent server should not succeed
+ non_existent_server_id = data_utils.rand_uuid()
+ self.assertRaises(exceptions.NotFound,
+ self.client.list_server_metadata,
+ non_existent_server_id)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_wrong_key_passed_in_body(self):
+ # Raise BadRequest if key in uri does not match
+ # the key passed in body.
+ meta = {'testkey': 'testvalue'}
+ self.assertRaises(exceptions.BadRequest,
+ self.client.set_server_metadata_item,
+ self.server_id, 'key', meta)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_set_metadata_non_existent_server(self):
+ # Set metadata on a non-existent server should not succeed
+ non_existent_server_id = data_utils.rand_uuid()
+ meta = {'meta1': 'data1'}
+ self.assertRaises(exceptions.NotFound,
+ self.client.set_server_metadata,
+ non_existent_server_id,
+ meta)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_update_metadata_non_existent_server(self):
+ # An update should not happen for a non-existent server
+ non_existent_server_id = data_utils.rand_uuid()
+ meta = {'key1': 'value1', 'key2': 'value2'}
+ self.assertRaises(exceptions.NotFound,
+ self.client.update_server_metadata,
+ non_existent_server_id,
+ meta)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_update_metadata_with_blank_key(self):
+ # Blank key should trigger an error
+ meta = {'': 'data1'}
+ self.assertRaises(exceptions.BadRequest,
+ self.client.update_server_metadata,
+ self.server_id, meta=meta)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_delete_metadata_non_existent_server(self):
+ # Should not be able to delete metadata item from a non-existent server
+ non_existent_server_id = data_utils.rand_uuid()
+ self.assertRaises(exceptions.NotFound,
+ self.client.delete_server_metadata_item,
+ non_existent_server_id,
+ 'd')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_metadata_items_limit(self):
+ # Raise a 413 OverLimit exception while exceeding metadata items limit
+ # for tenant.
+ _, quota_set = self.quotas.get_quota_set(self.tenant_id)
+ quota_metadata = quota_set['metadata_items']
+ req_metadata = {}
+ for num in range(1, quota_metadata + 2):
+ req_metadata['key' + str(num)] = 'val' + str(num)
+ self.assertRaises(exceptions.OverLimit,
+ self.client.set_server_metadata,
+ self.server_id, req_metadata)
+
+ # Raise a 413 OverLimit exception while exceeding metadata items limit
+ # for tenant (update).
+ self.assertRaises(exceptions.OverLimit,
+ self.client.update_server_metadata,
+ self.server_id, req_metadata)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_set_server_metadata_blank_key(self):
+ # Raise a bad request error for blank key.
+ # set_server_metadata will replace all metadata with new value
+ meta = {'': 'data1'}
+ self.assertRaises(exceptions.BadRequest,
+ self.client.set_server_metadata,
+ self.server_id, meta=meta)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_set_server_metadata_missing_metadata(self):
+ # Raise a bad request error for a missing metadata field
+ # set_server_metadata will replace all metadata with new value
+ meta = {'meta1': 'data1'}
+ self.assertRaises(exceptions.BadRequest,
+ self.client.set_server_metadata,
+ self.server_id, meta=meta, no_metadata_field=True)
+
+
+class ServerMetadataNegativeTestXML(ServerMetadataNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_servers.py b/tempest/api/compute/servers/test_servers.py
index 8ae43b5..203832e 100644
--- a/tempest/api/compute/servers/test_servers.py
+++ b/tempest/api/compute/servers/test_servers.py
@@ -104,6 +104,24 @@
self.assertEqual('::babe:202:202', server['accessIPv6'])
@attr(type='gate')
+ def test_delete_server_while_in_shutoff_state(self):
+ # Delete a server while it's VM state is Shutoff
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.stop(server['id'])
+ self.client.wait_for_server_status(server['id'], 'SHUTOFF')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+
+ @attr(type='gate')
+ def test_delete_server_while_in_pause_state(self):
+ # Delete a server while it's VM state is Pause
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.pause_server(server['id'])
+ self.client.wait_for_server_status(server['id'], 'PAUSED')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+
+ @attr(type='gate')
def test_delete_server_while_in_building_state(self):
# Delete a server while it's VM state is Building
resp, server = self.create_test_server(wait_until='BUILD')
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index a389c27..8f49aec 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -195,7 +195,7 @@
networks=networks)
@test.attr(type=['negative', 'gate'])
- def test_create_with_non_existant_keypair(self):
+ def test_create_with_non_existent_keypair(self):
# Pass a non-existent keypair while creating a server
key_name = data_utils.rand_name('key')
diff --git a/tempest/api/compute/v3/admin/test_aggregates.py b/tempest/api/compute/v3/admin/test_aggregates.py
index 7491742..956eddd 100644
--- a/tempest/api/compute/v3/admin/test_aggregates.py
+++ b/tempest/api/compute/v3/admin/test_aggregates.py
@@ -210,10 +210,3 @@
wait_until='ACTIVE')
resp, body = admin_servers_client.get_server(server['id'])
self.assertEqual(self.host, body[self._host_key])
-
-
-class AggregatesAdminV3TestXML(AggregatesAdminV3TestJSON):
- _host_key = (
- '{http://docs.openstack.org/compute/ext/'
- 'extended_server_attributes/api/v3}host')
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_aggregates_negative.py b/tempest/api/compute/v3/admin/test_aggregates_negative.py
index 4eb75a5..da3568a 100644
--- a/tempest/api/compute/v3/admin/test_aggregates_negative.py
+++ b/tempest/api/compute/v3/admin/test_aggregates_negative.py
@@ -188,7 +188,3 @@
self.assertRaises(exceptions.NotFound, self.client.remove_host,
aggregate['id'], non_exist_host)
-
-
-class AggregatesAdminNegativeV3TestXML(AggregatesAdminNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_availability_zone.py b/tempest/api/compute/v3/admin/test_availability_zone.py
index 2955dc8..5ced2b1 100644
--- a/tempest/api/compute/v3/admin/test_availability_zone.py
+++ b/tempest/api/compute/v3/admin/test_availability_zone.py
@@ -53,7 +53,3 @@
self.non_adm_client.get_availability_zone_list()
self.assertEqual(200, resp.status)
self.assertTrue(len(availability_zone) > 0)
-
-
-class AZAdminV3TestXML(AZAdminV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_availability_zone_negative.py b/tempest/api/compute/v3/admin/test_availability_zone_negative.py
index d69e956..60cd1d6 100644
--- a/tempest/api/compute/v3/admin/test_availability_zone_negative.py
+++ b/tempest/api/compute/v3/admin/test_availability_zone_negative.py
@@ -39,7 +39,3 @@
self.assertRaises(
exceptions.Unauthorized,
self.non_adm_client.get_availability_zone_list_detail)
-
-
-class AZAdminNegativeV3TestXML(AZAdminNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_flavors_access.py b/tempest/api/compute/v3/admin/test_flavors_access.py
index 532dc48..d668640 100644
--- a/tempest/api/compute/v3/admin/test_flavors_access.py
+++ b/tempest/api/compute/v3/admin/test_flavors_access.py
@@ -99,7 +99,3 @@
resp, flavors = self.flavors_client.list_flavors_with_detail()
self.assertEqual(resp.status, 200)
self.assertNotIn(new_flavor['id'], map(lambda x: x['id'], flavors))
-
-
-class FlavorsAdminV3TestXML(FlavorsAccessV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_flavors_access_negative.py b/tempest/api/compute/v3/admin/test_flavors_access_negative.py
index e9d811c..8595b2c 100644
--- a/tempest/api/compute/v3/admin/test_flavors_access_negative.py
+++ b/tempest/api/compute/v3/admin/test_flavors_access_negative.py
@@ -140,7 +140,3 @@
self.client.remove_flavor_access,
new_flavor['id'],
str(uuid.uuid4()))
-
-
-class FlavorsAdminNegativeV3TestXML(FlavorsAccessNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_flavors_extra_specs.py b/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
index b084157..0363fcb 100644
--- a/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
@@ -120,7 +120,3 @@
self.assertEqual(resp.status, 200)
self.assertEqual(body['key1'], 'value1')
self.assertNotIn('key2', body)
-
-
-class FlavorsExtraSpecsV3TestXML(FlavorsExtraSpecsV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py b/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
index a81edb1..0f300a1 100644
--- a/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
@@ -124,7 +124,3 @@
"key1",
key1="value",
key2="value")
-
-
-class FlavorsExtraSpecsNegativeV3TestXML(FlavorsExtraSpecsNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_hosts.py b/tempest/api/compute/v3/admin/test_hosts.py
index a110d02..8199ee8 100644
--- a/tempest/api/compute/v3/admin/test_hosts.py
+++ b/tempest/api/compute/v3/admin/test_hosts.py
@@ -86,7 +86,3 @@
self.assertIsNotNone(host_resource['memory_mb'])
self.assertIsNotNone(host_resource['project'])
self.assertEqual(hostname, host_resource['host'])
-
-
-class HostsAdminV3TestXML(HostsAdminV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_hosts_negative.py b/tempest/api/compute/v3/admin/test_hosts_negative.py
index 9841950..aa50618 100644
--- a/tempest/api/compute/v3/admin/test_hosts_negative.py
+++ b/tempest/api/compute/v3/admin/test_hosts_negative.py
@@ -168,7 +168,3 @@
self.assertRaises(exceptions.Unauthorized,
self.non_admin_client.reboot_host,
hostname)
-
-
-class HostsAdminNegativeV3TestXML(HostsAdminNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_hypervisor.py b/tempest/api/compute/v3/admin/test_hypervisor.py
index 84f6b4d..8bd4abb 100644
--- a/tempest/api/compute/v3/admin/test_hypervisor.py
+++ b/tempest/api/compute/v3/admin/test_hypervisor.py
@@ -97,7 +97,3 @@
hypers[0]['hypervisor_hostname'])
self.assertEqual(200, resp.status)
self.assertTrue(len(hypers) > 0)
-
-
-class HypervisorAdminV3TestXML(HypervisorAdminV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_hypervisor_negative.py b/tempest/api/compute/v3/admin/test_hypervisor_negative.py
index 68b0af0..63e8cae 100644
--- a/tempest/api/compute/v3/admin/test_hypervisor_negative.py
+++ b/tempest/api/compute/v3/admin/test_hypervisor_negative.py
@@ -136,7 +136,3 @@
exceptions.Unauthorized,
self.non_adm_client.search_hypervisor,
hypers[0]['hypervisor_hostname'])
-
-
-class HypervisorAdminNegativeV3TestXML(HypervisorAdminNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py b/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py
index fada98c..9651338 100644
--- a/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py
+++ b/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py
@@ -57,7 +57,3 @@
for item in expected_items:
self.assertIn(item, body)
self.assertEqual(body['period_ending'], "2012-12-23 23:00:00")
-
-
-class InstanceUsageAuditLogV3TestXML(InstanceUsageAuditLogV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_instance_usage_audit_log_negative.py b/tempest/api/compute/v3/admin/test_instance_usage_audit_log_negative.py
index 06b3711..8ed1a98 100644
--- a/tempest/api/compute/v3/admin/test_instance_usage_audit_log_negative.py
+++ b/tempest/api/compute/v3/admin/test_instance_usage_audit_log_negative.py
@@ -39,8 +39,3 @@
self.assertRaises(exceptions.BadRequest,
self.adm_client.list_instance_usage_audit_logs,
"invalid_time")
-
-
-class InstanceUsageLogNegativeV3TestXML(
- InstanceUsageLogNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_quotas.py b/tempest/api/compute/v3/admin/test_quotas.py
index ed4561d..e116734 100644
--- a/tempest/api/compute/v3/admin/test_quotas.py
+++ b/tempest/api/compute/v3/admin/test_quotas.py
@@ -147,7 +147,3 @@
self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
instances=default_instances_quota)
self.assertRaises(exceptions.OverLimit, self.create_test_server)
-
-
-class QuotasAdminV3TestXML(QuotasAdminV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_servers.py b/tempest/api/compute/v3/admin/test_servers.py
index dec573e..a8e1a0a 100644
--- a/tempest/api/compute/v3/admin/test_servers.py
+++ b/tempest/api/compute/v3/admin/test_servers.py
@@ -15,6 +15,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import exceptions
+from tempest import test
from tempest.test import attr
from tempest.test import skip_because
@@ -62,6 +63,7 @@
self.assertEqual('200', resp['status'])
self.assertEqual([], servers)
+ @test.skip_because(bug='1265416')
@attr(type='gate')
def test_list_servers_by_admin_with_all_tenants(self):
# Listing servers by admin user with all tenants parameter
@@ -83,6 +85,18 @@
self.servers_client.wait_for_server_termination(server['id'])
@attr(type='gate')
+ def test_delete_server_while_in_error_state(self):
+ # Delete a server while it's VM state is error
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.reset_state(server['id'], state='error')
+ self.assertEqual(202, resp.status)
+ # Verify server's state
+ resp, server = self.client.get_server(server['id'])
+ self.assertEqual(server['status'], 'ERROR')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+
+ @attr(type='gate')
def test_reset_state_server(self):
# Reset server's state to 'error'
resp, server = self.client.reset_state(self.s1_id)
@@ -155,7 +169,3 @@
resp, server = self.non_admin_client.get_server(rebuilt_server['id'])
rebuilt_image_id = server['image']['id']
self.assertEqual(self.image_ref_alt, rebuilt_image_id)
-
-
-class ServersAdminV3TestXML(ServersAdminV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_servers_negative.py b/tempest/api/compute/v3/admin/test_servers_negative.py
index fb4b043..a86bdfc 100644
--- a/tempest/api/compute/v3/admin/test_servers_negative.py
+++ b/tempest/api/compute/v3/admin/test_servers_negative.py
@@ -135,7 +135,3 @@
self.assertRaises(exceptions.Conflict,
self.client.migrate_server,
server_id)
-
-
-class ServersAdminNegativeV3TestXML(ServersAdminNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_services.py b/tempest/api/compute/v3/admin/test_services.py
index ba32739..9e55e78 100644
--- a/tempest/api/compute/v3/admin/test_services.py
+++ b/tempest/api/compute/v3/admin/test_services.py
@@ -76,7 +76,3 @@
self.assertEqual(1, len(services))
self.assertEqual(host_name, services[0]['host'])
self.assertEqual(binary_name, services[0]['binary'])
-
-
-class ServicesAdminV3TestXML(ServicesAdminV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_services_negative.py b/tempest/api/compute/v3/admin/test_services_negative.py
index 6f583fa..1382347 100644
--- a/tempest/api/compute/v3/admin/test_services_negative.py
+++ b/tempest/api/compute/v3/admin/test_services_negative.py
@@ -64,7 +64,3 @@
resp, services = self.client.list_services(params)
self.assertEqual(200, resp.status)
self.assertEqual(0, len(services))
-
-
-class ServicesAdminNegativeV3TestXML(ServicesAdminNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_simple_tenant_usage.py b/tempest/api/compute/v3/admin/test_simple_tenant_usage.py
index 3a2d2e5..7ee835b 100644
--- a/tempest/api/compute/v3/admin/test_simple_tenant_usage.py
+++ b/tempest/api/compute/v3/admin/test_simple_tenant_usage.py
@@ -83,7 +83,3 @@
self.assertEqual(200, resp.status)
self.assertEqual(len(tenant_usage), 8)
-
-
-class TenantUsagesV3TestXML(TenantUsagesV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_simple_tenant_usage_negative.py b/tempest/api/compute/v3/admin/test_simple_tenant_usage_negative.py
index 58acd07..00068dc 100644
--- a/tempest/api/compute/v3/admin/test_simple_tenant_usage_negative.py
+++ b/tempest/api/compute/v3/admin/test_simple_tenant_usage_negative.py
@@ -71,7 +71,3 @@
'detailed': int(bool(True))}
self.assertRaises(exceptions.Unauthorized,
self.client.list_tenant_usages, params)
-
-
-class TenantUsagesNegativeV3TestXML(TenantUsagesNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/certificates/test_certificates.py b/tempest/api/compute/v3/certificates/test_certificates.py
index 4dfa3be..b24f4d8 100644
--- a/tempest/api/compute/v3/certificates/test_certificates.py
+++ b/tempest/api/compute/v3/certificates/test_certificates.py
@@ -32,7 +32,3 @@
self.assertEqual(200, resp.status)
self.assertIn('data', body)
self.assertIn('private_key', body)
-
-
-class CertificatesV3TestXML(CertificatesV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_image_metadata.py b/tempest/api/compute/v3/images/test_image_metadata.py
index 89a2f75..d0d2daf 100644
--- a/tempest/api/compute/v3/images/test_image_metadata.py
+++ b/tempest/api/compute/v3/images/test_image_metadata.py
@@ -106,7 +106,3 @@
resp, resp_metadata = self.client.list_image_metadata(self.image_id)
expected = {'key2': 'value2'}
self.assertEqual(expected, resp_metadata)
-
-
-class ImagesMetadataTestXML(ImagesMetadataTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_image_metadata_negative.py b/tempest/api/compute/v3/images/test_image_metadata_negative.py
index 4878936..6e7cc8f 100644
--- a/tempest/api/compute/v3/images/test_image_metadata_negative.py
+++ b/tempest/api/compute/v3/images/test_image_metadata_negative.py
@@ -73,7 +73,3 @@
self.assertRaises(exceptions.NotFound,
self.client.delete_image_metadata_item,
data_utils.rand_uuid(), 'key1')
-
-
-class ImagesMetadataTestXML(ImagesMetadataTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_images.py b/tempest/api/compute/v3/images/test_images.py
index ea097ad..52772e0 100644
--- a/tempest/api/compute/v3/images/test_images.py
+++ b/tempest/api/compute/v3/images/test_images.py
@@ -118,7 +118,3 @@
self.assertRaises(exceptions.NotFound,
self.servers_client.create_image,
test_uuid, snapshot_name)
-
-
-class ImagesV3TestXML(ImagesV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_images_oneserver.py b/tempest/api/compute/v3/images/test_images_oneserver.py
index 0cb748b..fb54942 100644
--- a/tempest/api/compute/v3/images/test_images_oneserver.py
+++ b/tempest/api/compute/v3/images/test_images_oneserver.py
@@ -119,10 +119,6 @@
@attr(type=['gate'])
def test_create_image_specify_multibyte_character_image_name(self):
- if self.__class__._interface == "xml":
- # NOTE(sdague): not entirely accurage, but we'd need a ton of work
- # in our XML client to make this good
- raise self.skipException("Not testable in XML")
# prefix character is:
# http://www.fileformat.info/info/unicode/char/1F4A9/index.htm
utf8_name = data_utils.rand_name(u'\xF0\x9F\x92\xA9')
@@ -130,7 +126,3 @@
image_id = data_utils.parse_image_id(resp['location'])
self.addCleanup(self.client.delete_image, image_id)
self.assertEqual('202', resp['status'])
-
-
-class ImagesOneServerTestXML(ImagesOneServerTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_images_oneserver_negative.py b/tempest/api/compute/v3/images/test_images_oneserver_negative.py
index 3f93fbe..d9e7882 100644
--- a/tempest/api/compute/v3/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/v3/images/test_images_oneserver_negative.py
@@ -85,8 +85,6 @@
@skip_because(bug="1006725")
@attr(type=['negative', 'gate'])
def test_create_image_specify_multibyte_character_image_name(self):
- if self.__class__._interface == "xml":
- raise self.skipException("Not testable in XML")
# invalid multibyte sequence from:
# http://stackoverflow.com/questions/1301402/
# example-invalid-utf8-string
@@ -154,7 +152,3 @@
self.image_ids.remove(image_id)
self.assertRaises(exceptions.NotFound, self.client.get_image, image_id)
-
-
-class ImagesOneServerNegativeTestXML(ImagesOneServerNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_list_image_filters.py b/tempest/api/compute/v3/images/test_list_image_filters.py
index 8ace879..f654920 100644
--- a/tempest/api/compute/v3/images/test_list_image_filters.py
+++ b/tempest/api/compute/v3/images/test_list_image_filters.py
@@ -135,8 +135,6 @@
# Verify only the expected number of results are returned
params = {'limit': '1'}
resp, images = self.client.list_images(params)
- # when _interface='xml', one element for images_links in images
- # ref: Question #224349
self.assertEqual(1, len([x for x in images if 'id' in x]))
@attr(type='gate')
@@ -220,10 +218,6 @@
self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
@attr(type=['negative', 'gate'])
- def test_get_nonexistant_image(self):
+ def test_get_nonexistent_image(self):
# Negative test: GET on non-existent image should fail
self.assertRaises(exceptions.NotFound, self.client.get_image, 999)
-
-
-class ListImageFiltersTestXML(ListImageFiltersTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/keypairs/test_keypairs.py b/tempest/api/compute/v3/keypairs/test_keypairs.py
index 3b449f7..4aef8b1 100644
--- a/tempest/api/compute/v3/keypairs/test_keypairs.py
+++ b/tempest/api/compute/v3/keypairs/test_keypairs.py
@@ -116,7 +116,3 @@
self.assertEqual(key_name, k_name,
"The created keypair name is not equal "
"to the requested name!")
-
-
-class KeyPairsV3TestXML(KeyPairsV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/keypairs/test_keypairs_negative.py b/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
index 5180c72..87f62b7 100644
--- a/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
@@ -41,9 +41,9 @@
self._create_keypair, k_name, pub_key)
@test.attr(type=['negative', 'gate'])
- def test_keypair_delete_nonexistant_key(self):
- # Non-existant key deletion should throw a proper error
- k_name = data_utils.rand_name("keypair-non-existant-")
+ def test_keypair_delete_nonexistent_key(self):
+ # Non-existent key deletion should throw a proper error
+ k_name = data_utils.rand_name("keypair-non-existent-")
self.assertRaises(exceptions.NotFound, self.client.delete_keypair,
k_name)
@@ -93,7 +93,3 @@
k_name = 'key_/.\@:'
self.assertRaises(exceptions.BadRequest, self._create_keypair,
k_name)
-
-
-class KeyPairsNegativeV3TestXML(KeyPairsNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_attach_interfaces.py b/tempest/api/compute/v3/servers/test_attach_interfaces.py
index 8f69c54..aa85424 100644
--- a/tempest/api/compute/v3/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/v3/servers/test_attach_interfaces.py
@@ -119,7 +119,3 @@
_ifs = self._test_delete_interface(server, ifs)
self.assertEqual(len(ifs) - 1, len(_ifs))
-
-
-class AttachInterfacesV3TestXML(AttachInterfacesV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_attach_volume.py b/tempest/api/compute/v3/servers/test_attach_volume.py
index ff95ca4..2529af9 100644
--- a/tempest/api/compute/v3/servers/test_attach_volume.py
+++ b/tempest/api/compute/v3/servers/test_attach_volume.py
@@ -112,7 +112,3 @@
server['admin_password'])
partitions = linux_client.get_partitions()
self.assertNotIn(self.device, partitions)
-
-
-class AttachVolumeV3TestXML(AttachVolumeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_create_server.py b/tempest/api/compute/v3/servers/test_create_server.py
index 7c63865..cb02894 100644
--- a/tempest/api/compute/v3/servers/test_create_server.py
+++ b/tempest/api/compute/v3/servers/test_create_server.py
@@ -222,11 +222,3 @@
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
super(ServersV3TestManualDisk, cls).setUpClass()
-
-
-class ServersV3TestXML(ServersV3TestJSON):
- _interface = 'xml'
-
-
-class ServersWithSpecificFlavorV3TestXML(ServersWithSpecificFlavorV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_instance_actions.py b/tempest/api/compute/v3/servers/test_instance_actions.py
index 0b4b9bf..dd5dd30 100644
--- a/tempest/api/compute/v3/servers/test_instance_actions.py
+++ b/tempest/api/compute/v3/servers/test_instance_actions.py
@@ -61,7 +61,3 @@
# Get the action details of the provided server with invalid request
self.assertRaises(exceptions.NotFound, self.client.get_instance_action,
self.server_id, '999')
-
-
-class InstanceActionsV3TestXML(InstanceActionsV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_list_server_filters.py b/tempest/api/compute/v3/servers/test_list_server_filters.py
index 99cf8e1..8698d97 100644
--- a/tempest/api/compute/v3/servers/test_list_server_filters.py
+++ b/tempest/api/compute/v3/servers/test_list_server_filters.py
@@ -123,7 +123,6 @@
# Verify only the expected number of servers are returned
params = {'limit': 1}
resp, servers = self.client.list_servers(params)
- # when _interface='xml', one element for servers_links in servers
self.assertEqual(1, len([x for x in servers['servers'] if 'id' in x]))
@utils.skip_unless_attr('multiple_images', 'Only one image found')
@@ -250,7 +249,3 @@
params = {'limit': 1}
resp, servers = self.client.list_servers_with_detail(params)
self.assertEqual(1, len(servers['servers']))
-
-
-class ListServerFiltersV3TestXML(ListServerFiltersV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_list_servers_negative.py b/tempest/api/compute/v3/servers/test_list_servers_negative.py
index 7217148..23f2bda 100644
--- a/tempest/api/compute/v3/servers/test_list_servers_negative.py
+++ b/tempest/api/compute/v3/servers/test_list_servers_negative.py
@@ -103,7 +103,6 @@
# List servers by specifying limits
resp, body = self.client.list_servers({'limit': 1})
self.assertEqual('200', resp['status'])
- # when _interface='xml', one element for servers_links in servers
self.assertEqual(1, len([x for x in body['servers'] if 'id' in x]))
@attr(type=['negative', 'gate'])
@@ -162,7 +161,3 @@
if srv['id'] in deleted_ids]
self.assertEqual('200', resp['status'])
self.assertEqual([], actual)
-
-
-class ListServersNegativeV3TestXML(ListServersNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_multiple_create.py b/tempest/api/compute/v3/servers/test_multiple_create.py
index c7377a6..429a8ba 100644
--- a/tempest/api/compute/v3/servers/test_multiple_create.py
+++ b/tempest/api/compute/v3/servers/test_multiple_create.py
@@ -87,7 +87,3 @@
return_reservation_id=True)
self.assertEqual(resp['status'], '202')
self.assertIn('reservation_id', body)
-
-
-class MultipleCreateV3TestXML(MultipleCreateV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_server_actions.py b/tempest/api/compute/v3/servers/test_server_actions.py
index eb7bc94..fdf23f8 100644
--- a/tempest/api/compute/v3/servers/test_server_actions.py
+++ b/tempest/api/compute/v3/servers/test_server_actions.py
@@ -225,7 +225,7 @@
def test_create_backup(self):
# Positive test:create backup successfully and rotate backups correctly
# create the first and the second backup
- backup1 = data_utils.rand_name('backup')
+ backup1 = data_utils.rand_name('backup-1')
resp, _ = self.servers_client.create_backup(self.server_id,
'daily',
2,
@@ -242,7 +242,7 @@
self.assertEqual(202, resp.status)
self.images_client.wait_for_image_status(image1_id, 'active')
- backup2 = data_utils.rand_name('backup')
+ backup2 = data_utils.rand_name('backup-2')
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
resp, _ = self.servers_client.create_backup(self.server_id,
'daily',
@@ -270,7 +270,7 @@
# create the third one, due to the rotation is 2,
# the first one will be deleted
- backup3 = data_utils.rand_name('backup')
+ backup3 = data_utils.rand_name('backup-3')
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
resp, _ = self.servers_client.create_backup(self.server_id,
'daily',
@@ -287,7 +287,11 @@
sort_key='created_at',
sort_dir='asc')
self.assertEqual(200, resp.status)
- self.assertEqual(2, len(image_list))
+ self.assertEqual(2, len(image_list),
+ 'Unexpected number of images for '
+ 'v3:test_create_backup; was the oldest backup not '
+ 'yet deleted? Image list: %s' %
+ [image['name'] for image in image_list])
self.assertEqual((backup2, backup3),
(image_list[0]['name'], image_list[1]['name']))
@@ -402,7 +406,3 @@
resp, server = self.servers_client.start(self.server_id)
self.assertEqual(202, resp.status)
self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
-
-
-class ServerActionsV3TestXML(ServerActionsV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_server_addresses.py b/tempest/api/compute/v3/servers/test_server_addresses.py
index 6ecd28b..bffa7c4 100644
--- a/tempest/api/compute/v3/servers/test_server_addresses.py
+++ b/tempest/api/compute/v3/servers/test_server_addresses.py
@@ -78,7 +78,3 @@
addr = addr[addr_type]
for address in addresses[addr_type]:
self.assertTrue(any([a for a in addr if a == address]))
-
-
-class ServerAddressesV3TestXML(ServerAddressesV3Test):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_server_metadata.py b/tempest/api/compute/v3/servers/test_server_metadata.py
index 0571f38..1758b0b 100644
--- a/tempest/api/compute/v3/servers/test_server_metadata.py
+++ b/tempest/api/compute/v3/servers/test_server_metadata.py
@@ -209,7 +209,3 @@
self.assertRaises(exceptions.BadRequest,
self.client.set_server_metadata,
self.server_id, meta=meta, no_metadata_field=True)
-
-
-class ServerMetadataV3TestXML(ServerMetadataV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_server_rescue.py b/tempest/api/compute/v3/servers/test_server_rescue.py
index 870432b..99e8f68 100644
--- a/tempest/api/compute/v3/servers/test_server_rescue.py
+++ b/tempest/api/compute/v3/servers/test_server_rescue.py
@@ -167,7 +167,3 @@
self.servers_client.detach_volume,
self.server_id,
self.volume_to_detach['id'])
-
-
-class ServerRescueV3TestXML(ServerRescueV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_servers.py b/tempest/api/compute/v3/servers/test_servers.py
index 40ca0f0..c476b78 100644
--- a/tempest/api/compute/v3/servers/test_servers.py
+++ b/tempest/api/compute/v3/servers/test_servers.py
@@ -105,6 +105,24 @@
server['os-access-ips:access_ip_v6'])
@test.attr(type='gate')
+ def test_delete_server_while_in_shutoff_state(self):
+ # Delete a server while it's VM state is Shutoff
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.stop(server['id'])
+ self.client.wait_for_server_status(server['id'], 'SHUTOFF')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+
+ @test.attr(type='gate')
+ def test_delete_server_while_in_pause_state(self):
+ # Delete a server while it's VM state is Pause
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ resp, body = self.client.pause_server(server['id'])
+ self.client.wait_for_server_status(server['id'], 'PAUSED')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+
+ @test.attr(type='gate')
def test_delete_server_while_in_building_state(self):
# Delete a server while it's VM state is Building
resp, server = self.create_test_server(wait_until='BUILD')
@@ -126,7 +144,3 @@
self.client.wait_for_server_status(server['id'], 'ACTIVE')
resp, server = self.client.get_server(server['id'])
self.assertEqual('2001:2001::3', server['os-access-ips:access_ip_v6'])
-
-
-class ServersV3TestXML(ServersV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_servers_negative.py b/tempest/api/compute/v3/servers/test_servers_negative.py
index bb80293..aadba77 100644
--- a/tempest/api/compute/v3/servers/test_servers_negative.py
+++ b/tempest/api/compute/v3/servers/test_servers_negative.py
@@ -155,9 +155,6 @@
@test.attr(type=['negative', 'gate'])
def test_create_numeric_server_name(self):
# Create a server with a numeric name
- if self.__class__._interface == "xml":
- raise self.skipException("Not testable in XML")
-
server_name = 12345
self.assertRaises(exceptions.BadRequest,
self.create_test_server,
@@ -183,7 +180,7 @@
networks=networks)
@test.attr(type=['negative', 'gate'])
- def test_create_with_non_existant_keypair(self):
+ def test_create_with_non_existent_keypair(self):
# Pass a non-existent keypair while creating a server
key_name = data_utils.rand_name('key')
@@ -428,7 +425,3 @@
self.assertRaises(exceptions.Conflict,
self.client.unshelve_server,
self.server_id)
-
-
-class ServersNegativeV3TestXML(ServersNegativeV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/test_extensions.py b/tempest/api/compute/v3/test_extensions.py
index 8a88fca..32f62d5 100644
--- a/tempest/api/compute/v3/test_extensions.py
+++ b/tempest/api/compute/v3/test_extensions.py
@@ -49,7 +49,3 @@
resp, extension = self.extensions_client.get_extension('servers')
self.assertEqual(200, resp.status)
self.assertEqual('servers', extension['alias'])
-
-
-class ExtensionsV3TestXML(ExtensionsV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/test_live_block_migration.py b/tempest/api/compute/v3/test_live_block_migration.py
index 50a5f3c..087bffb 100644
--- a/tempest/api/compute/v3/test_live_block_migration.py
+++ b/tempest/api/compute/v3/test_live_block_migration.py
@@ -162,10 +162,3 @@
cls.servers_client.delete_server(server_id)
super(LiveBlockMigrationV3TestJSON, cls).tearDownClass()
-
-
-class LiveBlockMigrationV3TestXML(LiveBlockMigrationV3TestJSON):
- _host_key = (
- '{http://docs.openstack.org/compute/ext/'
- 'extended_server_attributes/api/v3}host')
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/test_quotas.py b/tempest/api/compute/v3/test_quotas.py
index df25249..1cbfa2b 100644
--- a/tempest/api/compute/v3/test_quotas.py
+++ b/tempest/api/compute/v3/test_quotas.py
@@ -63,7 +63,3 @@
resp, tenant_quota_set = self.client.get_quota_set(self.tenant_id)
self.assertEqual(200, resp.status)
self.assertEqual(defualt_quota_set, tenant_quota_set)
-
-
-class QuotasV3TestXML(QuotasV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/test_version.py b/tempest/api/compute/v3/test_version.py
index 166d161..6fbe794 100644
--- a/tempest/api/compute/v3/test_version.py
+++ b/tempest/api/compute/v3/test_version.py
@@ -28,7 +28,3 @@
self.assertEqual(200, resp.status)
self.assertIn("id", version)
self.assertEqual("v3.0", version["id"])
-
-
-class VersionV3TestXML(VersionV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/volumes/test_volumes_get.py b/tempest/api/compute/volumes/test_volumes_get.py
index d8cc190..b5a4802 100644
--- a/tempest/api/compute/volumes/test_volumes_get.py
+++ b/tempest/api/compute/volumes/test_volumes_get.py
@@ -55,7 +55,7 @@
# GET Volume
resp, fetched_volume = self.client.get_volume(volume['id'])
self.assertEqual(200, resp.status)
- # Verfication of details of fetched Volume
+ # Verification of details of fetched Volume
self.assertEqual(v_name,
fetched_volume['displayName'],
'The fetched Volume is different '
diff --git a/tempest/api/compute/volumes/test_volumes_negative.py b/tempest/api/compute/volumes/test_volumes_negative.py
index b653600..e01e349 100644
--- a/tempest/api/compute/volumes/test_volumes_negative.py
+++ b/tempest/api/compute/volumes/test_volumes_negative.py
@@ -33,18 +33,18 @@
raise cls.skipException(skip_msg)
@attr(type=['negative', 'gate'])
- def test_volume_get_nonexistant_volume_id(self):
- # Negative: Should not be able to get details of nonexistant volume
- # Creating a nonexistant volume id
- # Trying to GET a non existant volume
+ def test_volume_get_nonexistent_volume_id(self):
+ # Negative: Should not be able to get details of nonexistent volume
+ # Creating a nonexistent volume id
+ # Trying to GET a non existent volume
self.assertRaises(exceptions.NotFound, self.client.get_volume,
str(uuid.uuid4()))
@attr(type=['negative', 'gate'])
- def test_volume_delete_nonexistant_volume_id(self):
- # Negative: Should not be able to delete nonexistant Volume
- # Creating nonexistant volume id
- # Trying to DELETE a non existant volume
+ def test_volume_delete_nonexistent_volume_id(self):
+ # Negative: Should not be able to delete nonexistent Volume
+ # Creating nonexistent volume id
+ # Trying to DELETE a non existent volume
self.assertRaises(exceptions.NotFound, self.client.delete_volume,
str(uuid.uuid4()))
diff --git a/tempest/services/compute/v3/xml/__init__.py b/tempest/api/data_processing/__init__.py
similarity index 100%
copy from tempest/services/compute/v3/xml/__init__.py
copy to tempest/api/data_processing/__init__.py
diff --git a/tempest/api/data_processing/base.py b/tempest/api/data_processing/base.py
new file mode 100644
index 0000000..ab882cd
--- /dev/null
+++ b/tempest/api/data_processing/base.py
@@ -0,0 +1,91 @@
+# Copyright (c) 2013 Mirantis Inc.
+#
+# 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
+import tempest.test
+
+
+CONF = config.CONF
+
+
+class BaseDataProcessingTest(tempest.test.BaseTestCase):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(BaseDataProcessingTest, cls).setUpClass()
+ os = cls.get_client_manager()
+ if not CONF.service_available.savanna:
+ raise cls.skipException("Savanna support is required")
+ cls.client = os.data_processing_client
+
+ # set some constants
+ cls.flavor_ref = CONF.compute.flavor_ref
+ cls.simple_node_group_template = {
+ 'plugin_name': 'vanilla',
+ 'hadoop_version': '1.2.1',
+ 'node_processes': [
+ "datanode",
+ "tasktracker"
+ ],
+ 'flavor_id': cls.flavor_ref,
+ 'node_configs': {
+ 'HDFS': {
+ 'Data Node Heap Size': 1024
+ },
+ 'MapReduce': {
+ 'Task Tracker Heap Size': 1024
+ }
+ }
+ }
+
+ # add lists for watched resources
+ cls._node_group_templates = []
+
+ @classmethod
+ def tearDownClass(cls):
+ # cleanup node group templates
+ for ngt_id in cls._node_group_templates:
+ try:
+ cls.client.delete_node_group_template(ngt_id)
+ except Exception:
+ # ignore errors while auto removing created resource
+ pass
+
+ super(BaseDataProcessingTest, cls).tearDownClass()
+
+ @classmethod
+ def create_node_group_template(cls, name, plugin_name, hadoop_version,
+ node_processes, flavor_id,
+ node_configs=None, **kwargs):
+ """Creates watched node group template with specified params.
+
+ It supports passing additional params using kwargs and returns created
+ object. All resources created in this method will be automatically
+ removed in tearDownClass method.
+ """
+
+ resp, body = cls.client.create_node_group_template(name, plugin_name,
+ hadoop_version,
+ node_processes,
+ flavor_id,
+ node_configs,
+ **kwargs)
+
+ # store id of created node group template
+ template_id = body['id']
+ cls._node_group_templates.append(template_id)
+
+ return resp, body, template_id
diff --git a/tempest/api/data_processing/test_node_group_templates.py b/tempest/api/data_processing/test_node_group_templates.py
new file mode 100644
index 0000000..ff4fa6a
--- /dev/null
+++ b/tempest/api/data_processing/test_node_group_templates.py
@@ -0,0 +1,83 @@
+# Copyright (c) 2013 Mirantis Inc.
+#
+# 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.data_processing import base as dp_base
+from tempest.common.utils import data_utils
+from tempest.test import attr
+
+
+class NodeGroupTemplateTest(dp_base.BaseDataProcessingTest):
+ def _create_simple_node_group_template(self, template_name=None):
+ """Creates simple Node Group Template with optional name specified.
+
+ It creates template and ensures response status and template name.
+ Returns id and name of created template.
+ """
+
+ if template_name is None:
+ # generate random name if it's not specified
+ template_name = data_utils.rand_name('savanna')
+
+ # create simple node group template
+ resp, body, template_id = self.create_node_group_template(
+ template_name, **self.simple_node_group_template)
+
+ # ensure that template created successfully
+ self.assertEqual(202, resp.status)
+ self.assertEqual(template_name, body['name'])
+
+ return template_id, template_name
+
+ @attr(type='smoke')
+ def test_node_group_template_create(self):
+ # just create and ensure template
+ self._create_simple_node_group_template()
+
+ @attr(type='smoke')
+ def test_node_group_template_list(self):
+ template_info = self._create_simple_node_group_template()
+
+ # check for node group template in list
+ resp, templates = self.client.list_node_group_templates()
+
+ self.assertEqual(200, resp.status)
+ templates_info = list([(template['id'], template['name'])
+ for template in templates])
+ self.assertIn(template_info, templates_info)
+
+ @attr(type='smoke')
+ def test_node_group_template_get(self):
+ template_id, template_name = self._create_simple_node_group_template()
+
+ # check node group template fetch by id
+ resp, template = self.client.get_node_group_template(template_id)
+
+ self.assertEqual(200, resp.status)
+ self.assertEqual(template_name, template['name'])
+ self.assertEqual(self.simple_node_group_template['plugin_name'],
+ template['plugin_name'])
+ self.assertEqual(self.simple_node_group_template['node_processes'],
+ template['node_processes'])
+ self.assertEqual(self.simple_node_group_template['flavor_id'],
+ template['flavor_id'])
+
+ @attr(type='smoke')
+ def test_node_group_template_delete(self):
+ template_id, template_name = self._create_simple_node_group_template()
+
+ # delete the node group template by id
+ resp = self.client.delete_node_group_template(template_id)
+
+ self.assertEqual('204', resp[0]['status'])
diff --git a/tempest/api/identity/admin/test_roles_negative.py b/tempest/api/identity/admin/test_roles_negative.py
index cc53b60..e316dc7 100644
--- a/tempest/api/identity/admin/test_roles_negative.py
+++ b/tempest/api/identity/admin/test_roles_negative.py
@@ -134,14 +134,6 @@
self.client.clear_auth()
@attr(type=['negative', 'gate'])
- def test_assign_user_role_for_non_existent_user(self):
- # Attempt to assign a role to a non existent user should fail
- (user, tenant, role) = self._get_role_params()
- non_existent_user = str(uuid.uuid4().hex)
- self.assertRaises(exceptions.NotFound, self.client.assign_user_role,
- tenant['id'], non_existent_user, role['id'])
-
- @attr(type=['negative', 'gate'])
def test_assign_user_role_for_non_existent_role(self):
# Attempt to assign a non existent role to user should fail
(user, tenant, role) = self._get_role_params()
@@ -192,37 +184,26 @@
self.client.clear_auth()
@attr(type=['negative', 'gate'])
- def test_remove_user_role_non_existant_user(self):
- # Attempt to remove a role from a non existent user should fail
- (user, tenant, role) = self._get_role_params()
- resp, user_role = self.client.assign_user_role(tenant['id'],
- user['id'],
- role['id'])
- non_existant_user = str(uuid.uuid4().hex)
- self.assertRaises(exceptions.NotFound, self.client.remove_user_role,
- tenant['id'], non_existant_user, role['id'])
-
- @attr(type=['negative', 'gate'])
- def test_remove_user_role_non_existant_role(self):
+ def test_remove_user_role_non_existent_role(self):
# Attempt to delete a non existent role from a user should fail
(user, tenant, role) = self._get_role_params()
resp, user_role = self.client.assign_user_role(tenant['id'],
user['id'],
role['id'])
- non_existant_role = str(uuid.uuid4().hex)
+ non_existent_role = str(uuid.uuid4().hex)
self.assertRaises(exceptions.NotFound, self.client.remove_user_role,
- tenant['id'], user['id'], non_existant_role)
+ tenant['id'], user['id'], non_existent_role)
@attr(type=['negative', 'gate'])
- def test_remove_user_role_non_existant_tenant(self):
+ def test_remove_user_role_non_existent_tenant(self):
# Attempt to remove a role from a non existent tenant should fail
(user, tenant, role) = self._get_role_params()
resp, user_role = self.client.assign_user_role(tenant['id'],
user['id'],
role['id'])
- non_existant_tenant = str(uuid.uuid4().hex)
+ non_existent_tenant = str(uuid.uuid4().hex)
self.assertRaises(exceptions.NotFound, self.client.remove_user_role,
- non_existant_tenant, user['id'], role['id'])
+ non_existent_tenant, user['id'], role['id'])
@attr(type=['negative', 'gate'])
def test_list_user_roles_by_unauthorized_user(self):
@@ -247,14 +228,6 @@
finally:
self.client.clear_auth()
- @attr(type=['negative', 'gate'])
- def test_list_user_roles_for_non_existent_user(self):
- # Attempt to list roles of a non existent user should fail
- (user, tenant, role) = self._get_role_params()
- non_existent_user = str(uuid.uuid4().hex)
- self.assertRaises(exceptions.NotFound, self.client.list_user_roles,
- tenant['id'], non_existent_user)
-
class RolesTestXML(RolesNegativeTestJSON):
_interface = 'xml'
diff --git a/tempest/api/identity/admin/test_users_negative.py b/tempest/api/identity/admin/test_users_negative.py
index 1170c6f..ba7af09 100644
--- a/tempest/api/identity/admin/test_users_negative.py
+++ b/tempest/api/identity/admin/test_users_negative.py
@@ -64,7 +64,7 @@
self.data.tenant['id'], self.data.test_email)
@attr(type=['negative', 'gate'])
- def test_create_user_for_non_existant_tenant(self):
+ def test_create_user_for_non_existent_tenant(self):
# Attempt to create a user in a non-existent tenant should fail
self.assertRaises(exceptions.NotFound, self.client.create_user,
self.alt_user, self.alt_password, '49ffgg99999',
@@ -96,7 +96,7 @@
self.alt_email, enabled=3)
@attr(type=['negative', 'gate'])
- def test_update_user_for_non_existant_user(self):
+ def test_update_user_for_non_existent_user(self):
# Attempt to update a user non-existent user should fail
user_name = data_utils.rand_name('user-')
non_existent_id = str(uuid.uuid4())
@@ -133,7 +133,7 @@
self.data.user['id'])
@attr(type=['negative', 'gate'])
- def test_delete_non_existant_user(self):
+ def test_delete_non_existent_user(self):
# Attempt to delete a non-existent user should fail
self.assertRaises(exceptions.NotFound, self.client.delete_user,
'junk12345123')
diff --git a/tempest/api/identity/admin/v3/test_groups.py b/tempest/api/identity/admin/v3/test_groups.py
index ca8ca54..70afec7 100644
--- a/tempest/api/identity/admin/v3/test_groups.py
+++ b/tempest/api/identity/admin/v3/test_groups.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
# All Rights Reserved.
#
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index bfc2287..2a5401f 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -199,8 +199,8 @@
@attr(type='gate')
def test_list_images_param_status(self):
- # Test to get all available images
- params = {"status": "available"}
+ # Test to get all active images
+ params = {"status": "active"}
self._list_by_param_value_and_assert(params)
@attr(type='gate')
diff --git a/tempest/api/network/admin/test_agent_management.py b/tempest/api/network/admin/test_agent_management.py
index ca3bd8d..b05f275 100644
--- a/tempest/api/network/admin/test_agent_management.py
+++ b/tempest/api/network/admin/test_agent_management.py
@@ -32,6 +32,10 @@
resp, body = self.admin_client.list_agents()
self.assertEqual('200', resp['status'])
agents = body['agents']
+ # Hearthbeats must be excluded from comparison
+ self.agent.pop('heartbeat_timestamp', None)
+ for agent in agents:
+ agent.pop('heartbeat_timestamp', None)
self.assertIn(self.agent, agents)
@attr(type=['smoke'])
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index d7df6b2..0085cd6 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -115,13 +115,13 @@
"""Wrapper utility that returns a test network."""
network_name = network_name or data_utils.rand_name('test-network-')
- resp, body = cls.client.create_network(network_name)
+ resp, body = cls.client.create_network(name=network_name)
network = body['network']
cls.networks.append(network)
return network
@classmethod
- def create_subnet(cls, network):
+ def create_subnet(cls, network, ip_version=4):
"""Wrapper utility that returns a test subnet."""
cidr = netaddr.IPNetwork(cls.network_cfg.tenant_network_cidr)
mask_bits = cls.network_cfg.tenant_network_mask_bits
@@ -130,8 +130,10 @@
failure = None
for subnet_cidr in cidr.subnet(mask_bits):
try:
- resp, body = cls.client.create_subnet(network['id'],
- str(subnet_cidr))
+ resp, body = cls.client.create_subnet(
+ network_id=network['id'],
+ cidr=str(subnet_cidr),
+ ip_version=ip_version)
break
except exceptions.BadRequest as e:
is_overlapping_cidr = 'overlaps with another subnet' in str(e)
@@ -150,7 +152,7 @@
@classmethod
def create_port(cls, network):
"""Wrapper utility that returns a test port."""
- resp, body = cls.client.create_port(network['id'])
+ resp, body = cls.client.create_port(network_id=network['id'])
port = body['port']
cls.ports.append(port)
return port
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index e050c17..a7c1bd2 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -112,7 +112,7 @@
# Create a floating IP
created_floating_ip = self.create_floating_ip(self.ext_net_id)
# Create a port
- resp, port = self.client.create_port(self.network['id'])
+ resp, port = self.client.create_port(network_id=self.network['id'])
created_port = port['port']
resp, floating_ip = self.client.update_floating_ip(
created_floating_ip['id'], port_id=created_port['id'])
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index 4269644..b1f4608 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -65,13 +65,13 @@
def test_create_update_delete_network_subnet(self):
# Creates a network
name = data_utils.rand_name('network-')
- resp, body = self.client.create_network(name)
+ resp, body = self.client.create_network(name=name)
self.assertEqual('201', resp['status'])
network = body['network']
net_id = network['id']
# Verification of network update
new_name = "New_network"
- resp, body = self.client.update_network(net_id, new_name)
+ resp, body = self.client.update_network(net_id, name=new_name)
self.assertEqual('200', resp['status'])
updated_net = body['network']
self.assertEqual(updated_net['name'], new_name)
@@ -80,8 +80,10 @@
mask_bits = self.network_cfg.tenant_network_mask_bits
for subnet_cidr in cidr.subnet(mask_bits):
try:
- resp, body = self.client.create_subnet(net_id,
- str(subnet_cidr))
+ resp, body = self.client.create_subnet(
+ network_id=net_id,
+ cidr=str(subnet_cidr),
+ ip_version=4)
break
except exceptions.BadRequest as e:
is_overlapping_cidr = 'overlaps with another subnet' in str(e)
@@ -92,7 +94,8 @@
subnet_id = subnet['id']
# Verification of subnet update
new_subnet = "New_subnet"
- resp, body = self.client.update_subnet(subnet_id, new_subnet)
+ resp, body = self.client.update_subnet(subnet_id,
+ name=new_subnet)
self.assertEqual('200', resp['status'])
updated_subnet = body['subnet']
self.assertEqual(updated_subnet['name'], new_subnet)
@@ -179,12 +182,13 @@
@attr(type='smoke')
def test_create_update_delete_port(self):
# Verify that successful port creation, update & deletion
- resp, body = self.client.create_port(self.network['id'])
+ resp, body = self.client.create_port(
+ network_id=self.network['id'])
self.assertEqual('201', resp['status'])
port = body['port']
# Verification of port update
new_port = "New_Port"
- resp, body = self.client.update_port(port['id'], new_port)
+ resp, body = self.client.update_port(port['id'], name=new_port)
self.assertEqual('200', resp['status'])
updated_port = body['port']
self.assertEqual(updated_port['name'], new_port)
@@ -241,7 +245,7 @@
bulk network creation
bulk subnet creation
- bulk subnet creation
+ bulk port creation
list tenant's networks
v2.0 of the Neutron API is assumed. It is also assumed that the following
diff --git a/tempest/api/network/test_networks_negative.py b/tempest/api/network/test_networks_negative.py
index 67306e9..89c8a9f 100644
--- a/tempest/api/network/test_networks_negative.py
+++ b/tempest/api/network/test_networks_negative.py
@@ -45,7 +45,7 @@
def test_update_non_existent_network(self):
non_exist_id = data_utils.rand_name('network')
self.assertRaises(exceptions.NotFound, self.client.update_network,
- non_exist_id, "new_name")
+ non_exist_id, name="new_name")
@attr(type=['negative', 'smoke'])
def test_delete_non_existent_network(self):
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index e746597..426273c 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -94,7 +94,8 @@
network = self.create_network()
self.create_subnet(network)
router = self.create_router(data_utils.rand_name('router-'))
- resp, port_body = self.client.create_port(network['id'])
+ resp, port_body = self.client.create_port(
+ network_id=network['id'])
# add router interface to port created above
resp, interface = self.client.add_router_interface_with_port_id(
router['id'], port_body['port']['id'])
diff --git a/tempest/api/object_storage/test_account_quotas.py b/tempest/api/object_storage/test_account_quotas.py
index 6312f69..cacc66e 100644
--- a/tempest/api/object_storage/test_account_quotas.py
+++ b/tempest/api/object_storage/test_account_quotas.py
@@ -17,12 +17,9 @@
from tempest.api.object_storage import base
from tempest import clients
from tempest.common.utils import data_utils
-from tempest import config
from tempest import exceptions
from tempest import test
-CONF = config.CONF
-
class AccountQuotasTest(base.BaseObjectTest):
@@ -106,15 +103,6 @@
self.assertEqual(resp["status"], "201")
self.assertHeaders(resp, 'Object', 'PUT')
- @test.attr(type=["negative", "smoke"])
- @test.requires_ext(extension='account_quotas', service='object')
- def test_upload_large_object(self):
- object_name = data_utils.rand_name(name="TestObject")
- data = data_utils.arbitrary_string(30)
- self.assertRaises(exceptions.OverLimit,
- self.object_client.create_object,
- self.container_name, object_name, data)
-
@test.attr(type=["smoke"])
@test.requires_ext(extension='account_quotas', service='object')
def test_admin_modify_quota(self):
@@ -138,20 +126,3 @@
self.assertEqual(resp["status"], "204")
self.assertHeaders(resp, 'Account', 'POST')
-
- @test.attr(type=["negative", "smoke"])
- @test.requires_ext(extension='account_quotas', service='object')
- def test_user_modify_quota(self):
- """Test that a user is not able to modify or remove a quota on
- its account.
- """
-
- # Not able to remove quota
- self.assertRaises(exceptions.Unauthorized,
- self.account_client.create_account_metadata,
- {"Quota-Bytes": ""})
-
- # Not able to modify quota
- self.assertRaises(exceptions.Unauthorized,
- self.account_client.create_account_metadata,
- {"Quota-Bytes": "100"})
diff --git a/tempest/api/object_storage/test_account_quotas_negative.py b/tempest/api/object_storage/test_account_quotas_negative.py
new file mode 100644
index 0000000..e35cd17
--- /dev/null
+++ b/tempest/api/object_storage/test_account_quotas_negative.py
@@ -0,0 +1,119 @@
+# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
+#
+# Author: Joe H. Rahme <joe.hakim.rahme@enovance.com>
+#
+# 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.object_storage import base
+from tempest import clients
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class AccountQuotasNegativeTest(base.BaseObjectTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(AccountQuotasNegativeTest, cls).setUpClass()
+ cls.container_name = data_utils.rand_name(name="TestContainer")
+ cls.container_client.create_container(cls.container_name)
+
+ cls.data.setup_test_user()
+
+ cls.os_reselleradmin = clients.Manager(
+ cls.data.test_user,
+ cls.data.test_password,
+ cls.data.test_tenant)
+
+ # Retrieve the ResellerAdmin role id
+ reseller_role_id = None
+ try:
+ _, roles = cls.os_admin.identity_client.list_roles()
+ reseller_role_id = next(r['id'] for r in roles if r['name']
+ == 'ResellerAdmin')
+ except StopIteration:
+ msg = "No ResellerAdmin role found"
+ raise exceptions.NotFound(msg)
+
+ # Retrieve the ResellerAdmin tenant id
+ _, users = cls.os_admin.identity_client.get_users()
+ reseller_user_id = next(usr['id'] for usr in users if usr['name']
+ == cls.data.test_user)
+
+ # Retrieve the ResellerAdmin tenant id
+ _, tenants = cls.os_admin.identity_client.list_tenants()
+ reseller_tenant_id = next(tnt['id'] for tnt in tenants if tnt['name']
+ == cls.data.test_tenant)
+
+ # Assign the newly created user the appropriate ResellerAdmin role
+ cls.os_admin.identity_client.assign_user_role(
+ reseller_tenant_id,
+ reseller_user_id,
+ reseller_role_id)
+
+ # Retrieve a ResellerAdmin auth token and use it to set a quota
+ # on the client's account
+ cls.reselleradmin_token = cls.token_client.get_token(
+ cls.data.test_user,
+ cls.data.test_password,
+ cls.data.test_tenant)
+
+ def setUp(self):
+ super(AccountQuotasNegativeTest, self).setUp()
+
+ # Set a quota of 20 bytes on the user's account before each test
+ headers = {"X-Auth-Token": self.reselleradmin_token,
+ "X-Account-Meta-Quota-Bytes": "20"}
+
+ self.os.custom_account_client.request("POST", "", headers, "")
+
+ def tearDown(self):
+ # remove the quota from the container
+ headers = {"X-Auth-Token": self.reselleradmin_token,
+ "X-Remove-Account-Meta-Quota-Bytes": "x"}
+
+ self.os.custom_account_client.request("POST", "", headers, "")
+ super(AccountQuotasNegativeTest, self).tearDown()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.delete_containers([cls.container_name])
+ cls.data.teardown_all()
+ super(AccountQuotasNegativeTest, cls).tearDownClass()
+
+ @test.attr(type=["negative", "smoke"])
+ @test.requires_ext(extension='account_quotas', service='object')
+ def test_user_modify_quota(self):
+ """Test that a user is not able to modify or remove a quota on
+ its account.
+ """
+
+ # Not able to remove quota
+ self.assertRaises(exceptions.Unauthorized,
+ self.account_client.create_account_metadata,
+ {"Quota-Bytes": ""})
+
+ # Not able to modify quota
+ self.assertRaises(exceptions.Unauthorized,
+ self.account_client.create_account_metadata,
+ {"Quota-Bytes": "100"})
+
+ @test.attr(type=["negative", "smoke"])
+ @test.requires_ext(extension='account_quotas', service='object')
+ def test_upload_large_object(self):
+ object_name = data_utils.rand_name(name="TestObject")
+ data = data_utils.arbitrary_string(30)
+ self.assertRaises(exceptions.OverLimit,
+ self.object_client.create_object,
+ self.container_name, object_name, data)
diff --git a/tempest/api/object_storage/test_account_services.py b/tempest/api/object_storage/test_account_services.py
index 68b9222..79fd99d 100644
--- a/tempest/api/object_storage/test_account_services.py
+++ b/tempest/api/object_storage/test_account_services.py
@@ -16,8 +16,8 @@
import random
from tempest.api.object_storage import base
+from tempest.common import custom_matchers
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest.test import attr
from tempest.test import HTTP_SUCCESS
@@ -52,6 +52,13 @@
self.assertIn(container_name, container_names)
@attr(type='smoke')
+ def test_list_extensions(self):
+ resp, extensions = self.account_client.list_extensions()
+
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertThat(resp, custom_matchers.AreAllWellFormatted())
+
+ @attr(type='smoke')
def test_list_containers_with_limit(self):
# list containers one of them, half of them then all of them
for limit in (1, self.containers_count / 2, self.containers_count):
@@ -146,26 +153,3 @@
resp, _ = self.account_client.list_account_metadata()
self.assertHeaders(resp, 'Account', 'HEAD')
self.assertNotIn('x-account-meta-' + header, resp)
-
- @attr(type=['negative', 'gate'])
- def test_list_containers_with_non_authorized_user(self):
- # list containers using non-authorized user
-
- # create user
- self.data.setup_test_user()
- resp, body = \
- self.token_client.auth(self.data.test_user,
- self.data.test_password,
- self.data.test_tenant)
- new_token = \
- self.token_client.get_token(self.data.test_user,
- self.data.test_password,
- self.data.test_tenant)
- custom_headers = {'X-Auth-Token': new_token}
- params = {'format': 'json'}
- # list containers with non-authorized user token
- self.assertRaises(exceptions.Unauthorized,
- self.custom_account_client.list_account_containers,
- params=params, metadata=custom_headers)
- # delete the user which was created
- self.data.teardown_all()
diff --git a/tempest/api/object_storage/test_account_services_negative.py b/tempest/api/object_storage/test_account_services_negative.py
new file mode 100644
index 0000000..3b07e17
--- /dev/null
+++ b/tempest/api/object_storage/test_account_services_negative.py
@@ -0,0 +1,46 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
+#
+# Author: Joe H. Rahme <joe.hakim.rahme@enovance.com>
+#
+# 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.object_storage import base
+from tempest import exceptions
+from tempest.test import attr
+
+
+class AccountNegativeTest(base.BaseObjectTest):
+
+ @attr(type=['negative', 'gate'])
+ def test_list_containers_with_non_authorized_user(self):
+ # list containers using non-authorized user
+
+ # create user
+ self.data.setup_test_user()
+ self.token_client.auth(self.data.test_user,
+ self.data.test_password,
+ self.data.test_tenant)
+ new_token = \
+ self.token_client.get_token(self.data.test_user,
+ self.data.test_password,
+ self.data.test_tenant)
+ custom_headers = {'X-Auth-Token': new_token}
+ params = {'format': 'json'}
+ # list containers with non-authorized user token
+ self.assertRaises(exceptions.Unauthorized,
+ self.custom_account_client.list_account_containers,
+ params=params, metadata=custom_headers)
+ # delete the user which was created
+ self.data.teardown_all()
diff --git a/tempest/api/object_storage/test_container_acl.py b/tempest/api/object_storage/test_container_acl.py
index a01b703..0733524 100644
--- a/tempest/api/object_storage/test_container_acl.py
+++ b/tempest/api/object_storage/test_container_acl.py
@@ -15,7 +15,6 @@
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest.test import attr
from tempest.test import HTTP_SUCCESS
@@ -44,108 +43,6 @@
self.delete_containers([self.container_name])
super(ObjectTestACLs, self).tearDown()
- @attr(type=['negative', 'gate'])
- def test_write_object_without_using_creds(self):
- # trying to create object with empty headers
- # X-Auth-Token is not provided
- object_name = data_utils.rand_name(name='Object')
- self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.create_object,
- self.container_name, object_name, 'data')
-
- @attr(type=['negative', 'gate'])
- def test_delete_object_without_using_creds(self):
- # create object
- object_name = data_utils.rand_name(name='Object')
- resp, _ = self.object_client.create_object(self.container_name,
- object_name, 'data')
- # trying to delete object with empty headers
- # X-Auth-Token is not provided
- self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.delete_object,
- self.container_name, object_name)
-
- @attr(type=['negative', 'gate'])
- def test_write_object_with_non_authorized_user(self):
- # attempt to upload another file using non-authorized user
- # User provided token is forbidden. ACL are not set
- object_name = data_utils.rand_name(name='Object')
- # trying to create object with non-authorized user
- self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.create_object,
- self.container_name, object_name, 'data',
- metadata=self.custom_headers)
-
- @attr(type=['negative', 'gate'])
- def test_read_object_with_non_authorized_user(self):
- # attempt to read object using non-authorized user
- # User provided token is forbidden. ACL are not set
- object_name = data_utils.rand_name(name='Object')
- resp, _ = self.object_client.create_object(
- self.container_name, object_name, 'data')
- self.assertEqual(resp['status'], '201')
- self.assertHeaders(resp, 'Object', 'PUT')
- # trying to get object with non authorized user token
- self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.get_object,
- self.container_name, object_name,
- metadata=self.custom_headers)
-
- @attr(type=['negative', 'gate'])
- def test_delete_object_with_non_authorized_user(self):
- # attempt to delete object using non-authorized user
- # User provided token is forbidden. ACL are not set
- object_name = data_utils.rand_name(name='Object')
- resp, _ = self.object_client.create_object(
- self.container_name, object_name, 'data')
- self.assertEqual(resp['status'], '201')
- self.assertHeaders(resp, 'Object', 'PUT')
- # trying to delete object with non-authorized user token
- self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.delete_object,
- self.container_name, object_name,
- metadata=self.custom_headers)
-
- @attr(type=['negative', 'smoke'])
- def test_read_object_without_rights(self):
- # attempt to read object using non-authorized user
- # update X-Container-Read metadata ACL
- cont_headers = {'X-Container-Read': 'badtenant:baduser'}
- resp_meta, body = self.container_client.update_container_metadata(
- self.container_name, metadata=cont_headers,
- metadata_prefix='')
- self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
- self.assertHeaders(resp_meta, 'Container', 'POST')
- # create object
- object_name = data_utils.rand_name(name='Object')
- resp, _ = self.object_client.create_object(self.container_name,
- object_name, 'data')
- self.assertEqual(resp['status'], '201')
- self.assertHeaders(resp, 'Object', 'PUT')
- # Trying to read the object without rights
- self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.get_object,
- self.container_name, object_name,
- metadata=self.custom_headers)
-
- @attr(type=['negative', 'smoke'])
- def test_write_object_without_rights(self):
- # attempt to write object using non-authorized user
- # update X-Container-Write metadata ACL
- cont_headers = {'X-Container-Write': 'badtenant:baduser'}
- resp_meta, body = self.container_client.update_container_metadata(
- self.container_name, metadata=cont_headers,
- metadata_prefix='')
- self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
- self.assertHeaders(resp_meta, 'Container', 'POST')
- # Trying to write the object without rights
- object_name = data_utils.rand_name(name='Object')
- self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.create_object,
- self.container_name,
- object_name, 'data',
- metadata=self.custom_headers)
-
@attr(type='smoke')
def test_read_object_with_rights(self):
# attempt to read object using authorized user
@@ -189,48 +86,3 @@
metadata=self.custom_headers)
self.assertIn(int(resp['status']), HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'PUT')
-
- @attr(type=['negative', 'smoke'])
- def test_write_object_without_write_rights(self):
- # attempt to write object using non-authorized user
- # update X-Container-Read and X-Container-Write metadata ACL
- cont_headers = {'X-Container-Read':
- self.data.test_tenant + ':' + self.data.test_user,
- 'X-Container-Write': ''}
- resp_meta, body = self.container_client.update_container_metadata(
- self.container_name, metadata=cont_headers,
- metadata_prefix='')
- self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
- self.assertHeaders(resp_meta, 'Container', 'POST')
- # Trying to write the object without write rights
- object_name = data_utils.rand_name(name='Object')
- self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.create_object,
- self.container_name,
- object_name, 'data',
- metadata=self.custom_headers)
-
- @attr(type=['negative', 'smoke'])
- def test_delete_object_without_write_rights(self):
- # attempt to delete object using non-authorized user
- # update X-Container-Read and X-Container-Write metadata ACL
- cont_headers = {'X-Container-Read':
- self.data.test_tenant + ':' + self.data.test_user,
- 'X-Container-Write': ''}
- resp_meta, body = self.container_client.update_container_metadata(
- self.container_name, metadata=cont_headers,
- metadata_prefix='')
- self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
- self.assertHeaders(resp_meta, 'Container', 'POST')
- # create object
- object_name = data_utils.rand_name(name='Object')
- resp, _ = self.object_client.create_object(self.container_name,
- object_name, 'data')
- self.assertEqual(resp['status'], '201')
- self.assertHeaders(resp, 'Object', 'PUT')
- # Trying to delete the object without write rights
- self.assertRaises(exceptions.Unauthorized,
- self.custom_object_client.delete_object,
- self.container_name,
- object_name,
- metadata=self.custom_headers)
diff --git a/tempest/api/object_storage/test_container_acl_negative.py b/tempest/api/object_storage/test_container_acl_negative.py
new file mode 100644
index 0000000..e75f21d
--- /dev/null
+++ b/tempest/api/object_storage/test_container_acl_negative.py
@@ -0,0 +1,195 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
+#
+# Author: Joe H. Rahme <joe.hakim.rahme@enovance.com>
+#
+# 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.object_storage import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest.test import attr
+from tempest.test import HTTP_SUCCESS
+
+
+class ObjectACLsNegativeTest(base.BaseObjectTest):
+ @classmethod
+ def setUpClass(cls):
+ super(ObjectACLsNegativeTest, cls).setUpClass()
+ cls.data.setup_test_user()
+ cls.new_token = cls.token_client.get_token(cls.data.test_user,
+ cls.data.test_password,
+ cls.data.test_tenant)
+ cls.custom_headers = {'X-Auth-Token': cls.new_token}
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.data.teardown_all()
+ super(ObjectACLsNegativeTest, cls).tearDownClass()
+
+ def setUp(self):
+ super(ObjectACLsNegativeTest, self).setUp()
+ self.container_name = data_utils.rand_name(name='TestContainer')
+ self.container_client.create_container(self.container_name)
+
+ def tearDown(self):
+ self.delete_containers([self.container_name])
+ super(ObjectACLsNegativeTest, self).tearDown()
+
+ @attr(type=['negative', 'gate'])
+ def test_write_object_without_using_creds(self):
+ # trying to create object with empty headers
+ # X-Auth-Token is not provided
+ object_name = data_utils.rand_name(name='Object')
+ self.assertRaises(exceptions.Unauthorized,
+ self.custom_object_client.create_object,
+ self.container_name, object_name, 'data')
+
+ @attr(type=['negative', 'gate'])
+ def test_delete_object_without_using_creds(self):
+ # create object
+ object_name = data_utils.rand_name(name='Object')
+ resp, _ = self.object_client.create_object(self.container_name,
+ object_name, 'data')
+ # trying to delete object with empty headers
+ # X-Auth-Token is not provided
+ self.assertRaises(exceptions.Unauthorized,
+ self.custom_object_client.delete_object,
+ self.container_name, object_name)
+
+ @attr(type=['negative', 'gate'])
+ def test_write_object_with_non_authorized_user(self):
+ # attempt to upload another file using non-authorized user
+ # User provided token is forbidden. ACL are not set
+ object_name = data_utils.rand_name(name='Object')
+ # trying to create object with non-authorized user
+ self.assertRaises(exceptions.Unauthorized,
+ self.custom_object_client.create_object,
+ self.container_name, object_name, 'data',
+ metadata=self.custom_headers)
+
+ @attr(type=['negative', 'gate'])
+ def test_read_object_with_non_authorized_user(self):
+ # attempt to read object using non-authorized user
+ # User provided token is forbidden. ACL are not set
+ object_name = data_utils.rand_name(name='Object')
+ resp, _ = self.object_client.create_object(
+ self.container_name, object_name, 'data')
+ self.assertEqual(resp['status'], '201')
+ self.assertHeaders(resp, 'Object', 'PUT')
+ # trying to get object with non authorized user token
+ self.assertRaises(exceptions.Unauthorized,
+ self.custom_object_client.get_object,
+ self.container_name, object_name,
+ metadata=self.custom_headers)
+
+ @attr(type=['negative', 'gate'])
+ def test_delete_object_with_non_authorized_user(self):
+ # attempt to delete object using non-authorized user
+ # User provided token is forbidden. ACL are not set
+ object_name = data_utils.rand_name(name='Object')
+ resp, _ = self.object_client.create_object(
+ self.container_name, object_name, 'data')
+ self.assertEqual(resp['status'], '201')
+ self.assertHeaders(resp, 'Object', 'PUT')
+ # trying to delete object with non-authorized user token
+ self.assertRaises(exceptions.Unauthorized,
+ self.custom_object_client.delete_object,
+ self.container_name, object_name,
+ metadata=self.custom_headers)
+
+ @attr(type=['negative', 'smoke'])
+ def test_read_object_without_rights(self):
+ # attempt to read object using non-authorized user
+ # update X-Container-Read metadata ACL
+ cont_headers = {'X-Container-Read': 'badtenant:baduser'}
+ resp_meta, body = self.container_client.update_container_metadata(
+ self.container_name, metadata=cont_headers,
+ metadata_prefix='')
+ self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
+ self.assertHeaders(resp_meta, 'Container', 'POST')
+ # create object
+ object_name = data_utils.rand_name(name='Object')
+ resp, _ = self.object_client.create_object(self.container_name,
+ object_name, 'data')
+ self.assertEqual(resp['status'], '201')
+ self.assertHeaders(resp, 'Object', 'PUT')
+ # Trying to read the object without rights
+ self.assertRaises(exceptions.Unauthorized,
+ self.custom_object_client.get_object,
+ self.container_name, object_name,
+ metadata=self.custom_headers)
+
+ @attr(type=['negative', 'smoke'])
+ def test_write_object_without_rights(self):
+ # attempt to write object using non-authorized user
+ # update X-Container-Write metadata ACL
+ cont_headers = {'X-Container-Write': 'badtenant:baduser'}
+ resp_meta, body = self.container_client.update_container_metadata(
+ self.container_name, metadata=cont_headers,
+ metadata_prefix='')
+ self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
+ self.assertHeaders(resp_meta, 'Container', 'POST')
+ # Trying to write the object without rights
+ object_name = data_utils.rand_name(name='Object')
+ self.assertRaises(exceptions.Unauthorized,
+ self.custom_object_client.create_object,
+ self.container_name,
+ object_name, 'data',
+ metadata=self.custom_headers)
+
+ @attr(type=['negative', 'smoke'])
+ def test_write_object_without_write_rights(self):
+ # attempt to write object using non-authorized user
+ # update X-Container-Read and X-Container-Write metadata ACL
+ cont_headers = {'X-Container-Read':
+ self.data.test_tenant + ':' + self.data.test_user,
+ 'X-Container-Write': ''}
+ resp_meta, body = self.container_client.update_container_metadata(
+ self.container_name, metadata=cont_headers,
+ metadata_prefix='')
+ self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
+ self.assertHeaders(resp_meta, 'Container', 'POST')
+ # Trying to write the object without write rights
+ object_name = data_utils.rand_name(name='Object')
+ self.assertRaises(exceptions.Unauthorized,
+ self.custom_object_client.create_object,
+ self.container_name,
+ object_name, 'data',
+ metadata=self.custom_headers)
+
+ @attr(type=['negative', 'smoke'])
+ def test_delete_object_without_write_rights(self):
+ # attempt to delete object using non-authorized user
+ # update X-Container-Read and X-Container-Write metadata ACL
+ cont_headers = {'X-Container-Read':
+ self.data.test_tenant + ':' + self.data.test_user,
+ 'X-Container-Write': ''}
+ resp_meta, body = self.container_client.update_container_metadata(
+ self.container_name, metadata=cont_headers,
+ metadata_prefix='')
+ self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
+ self.assertHeaders(resp_meta, 'Container', 'POST')
+ # create object
+ object_name = data_utils.rand_name(name='Object')
+ resp, _ = self.object_client.create_object(self.container_name,
+ object_name, 'data')
+ self.assertEqual(resp['status'], '201')
+ self.assertHeaders(resp, 'Object', 'PUT')
+ # Trying to delete the object without write rights
+ self.assertRaises(exceptions.Unauthorized,
+ self.custom_object_client.delete_object,
+ self.container_name,
+ object_name,
+ metadata=self.custom_headers)
diff --git a/tempest/api/object_storage/test_healthcheck.py b/tempest/api/object_storage/test_healthcheck.py
index fdac12f..78bff03 100644
--- a/tempest/api/object_storage/test_healthcheck.py
+++ b/tempest/api/object_storage/test_healthcheck.py
@@ -16,7 +16,6 @@
from tempest.api.object_storage import base
-from tempest import clients
from tempest.common import custom_matchers
from tempest.test import attr
from tempest.test import HTTP_SUCCESS
@@ -28,37 +27,17 @@
def setUpClass(cls):
super(HealthcheckTest, cls).setUpClass()
- # creates a test user. The test user will set its base_url to the Swift
- # endpoint and test the healthcheck feature.
- cls.data.setup_test_user()
-
- cls.os_test_user = clients.Manager(
- cls.data.test_user,
- cls.data.test_password,
- cls.data.test_tenant)
-
- @classmethod
- def tearDownClass(cls):
- cls.data.teardown_all()
- super(HealthcheckTest, cls).tearDownClass()
-
def setUp(self):
super(HealthcheckTest, self).setUp()
- client = self.os_test_user.account_client
- client._set_auth()
-
+ self.account_client._set_auth()
# Turning http://.../v1/foobar into http://.../
- client.base_url = "/".join(client.base_url.split("/")[:-2])
-
- def tearDown(self):
- # clear the base_url for subsequent requests
- self.os_test_user.account_client.base_url = None
- super(HealthcheckTest, self).tearDown()
+ self.account_client.base_url = "/".join(
+ self.account_client.base_url.split("/")[:-2])
@attr('gate')
def test_get_healthcheck(self):
- resp, _ = self.os_test_user.account_client.get("healthcheck", {})
+ resp, _ = self.account_client.get("healthcheck", {})
# The status is expected to be 200
self.assertIn(int(resp['status']), HTTP_SUCCESS)
diff --git a/tempest/api/object_storage/test_object_expiry.py b/tempest/api/object_storage/test_object_expiry.py
index 7ca0e51..3aae0a1 100644
--- a/tempest/api/object_storage/test_object_expiry.py
+++ b/tempest/api/object_storage/test_object_expiry.py
@@ -28,30 +28,34 @@
cls.container_name = data_utils.rand_name(name='TestContainer')
cls.container_client.create_container(cls.container_name)
+ def setUp(self):
+ super(ObjectExpiryTest, self).setUp()
+ # create object
+ self.object_name = data_utils.rand_name(name='TestObject')
+ resp, _ = self.object_client.create_object(self.container_name,
+ self.object_name, '')
+
@classmethod
def tearDownClass(cls):
cls.delete_containers([cls.container_name])
super(ObjectExpiryTest, cls).tearDownClass()
def _test_object_expiry(self, metadata):
- # create object
- object_name = data_utils.rand_name(name='TestObject')
- resp, _ = self.object_client.create_object(self.container_name,
- object_name, '')
# update object metadata
resp, _ = \
self.object_client.update_object_metadata(self.container_name,
- object_name, metadata,
+ self.object_name,
+ metadata,
metadata_prefix='')
# verify object metadata
resp, _ = \
self.object_client.list_object_metadata(self.container_name,
- object_name)
+ self.object_name)
self.assertEqual(resp['status'], '200')
self.assertHeaders(resp, 'Object', 'HEAD')
self.assertIn('x-delete-at', resp)
resp, body = self.object_client.get_object(self.container_name,
- object_name)
+ self.object_name)
self.assertEqual(resp['status'], '200')
self.assertHeaders(resp, 'Object', 'GET')
self.assertIn('x-delete-at', resp)
@@ -61,7 +65,7 @@
# object should not be there anymore
self.assertRaises(exceptions.NotFound, self.object_client.get_object,
- self.container_name, object_name)
+ self.container_name, self.object_name)
@attr(type='gate')
def test_get_object_after_expiry_time(self):
diff --git a/tempest/api/object_storage/test_object_formpost.py b/tempest/api/object_storage/test_object_formpost.py
index 621a693..6f46ec9 100644
--- a/tempest/api/object_storage/test_object_formpost.py
+++ b/tempest/api/object_storage/test_object_formpost.py
@@ -116,21 +116,3 @@
self.assertIn(int(resp['status']), HTTP_SUCCESS)
self.assertHeaders(resp, "Object", "GET")
self.assertEqual(body, "hello world")
-
- @attr(type=['gate', 'negative'])
- def test_post_object_using_form_expired(self):
- body, content_type = self.get_multipart_form(expires=1)
- time.sleep(2)
-
- headers = {'Content-Type': content_type,
- 'Content-Length': str(len(body))}
-
- url = "%s/%s/%s" % (self.container_client.base_url,
- self.container_name,
- self.object_name)
-
- # Use a raw request, otherwise authentication headers are used
- resp, body = self.object_client.http_obj.request(url, "POST",
- body, headers=headers)
- self.assertEqual(int(resp['status']), 401)
- self.assertIn('FormPost: Form Expired', body)
diff --git a/tempest/api/object_storage/test_object_formpost_negative.py b/tempest/api/object_storage/test_object_formpost_negative.py
new file mode 100644
index 0000000..a07e277
--- /dev/null
+++ b/tempest/api/object_storage/test_object_formpost_negative.py
@@ -0,0 +1,112 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
+# Author: Joe H. Rahme <joe.hakim.rahme@enovance.com>
+#
+# 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 hashlib
+import hmac
+import time
+import urlparse
+
+from tempest.api.object_storage import base
+from tempest.common.utils import data_utils
+from tempest.test import attr
+
+
+class ObjectFormPostNegativeTest(base.BaseObjectTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(ObjectFormPostNegativeTest, cls).setUpClass()
+ cls.container_name = data_utils.rand_name(name='TestContainer')
+ cls.object_name = data_utils.rand_name(name='ObjectTemp')
+
+ cls.container_client.create_container(cls.container_name)
+ cls.containers = [cls.container_name]
+
+ cls.key = 'Meta'
+ cls.metadata = {'Temp-URL-Key': cls.key}
+ cls.account_client.create_account_metadata(metadata=cls.metadata)
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.account_client.delete_account_metadata(metadata=cls.metadata)
+ cls.delete_containers(cls.containers)
+ cls.data.teardown_all()
+ super(ObjectFormPostNegativeTest, cls).tearDownClass()
+
+ def get_multipart_form(self, expires=600):
+ path = "%s/%s/%s" % (
+ urlparse.urlparse(self.container_client.base_url).path,
+ self.container_name,
+ self.object_name)
+
+ redirect = ''
+ max_file_size = 104857600
+ max_file_count = 10
+ expires += int(time.time())
+ hmac_body = '%s\n%s\n%s\n%s\n%s' % (path,
+ redirect,
+ max_file_size,
+ max_file_count,
+ expires)
+
+ signature = hmac.new(self.key, hmac_body, hashlib.sha1).hexdigest()
+
+ fields = {'redirect': redirect,
+ 'max_file_size': str(max_file_size),
+ 'max_file_count': str(max_file_count),
+ 'expires': str(expires),
+ 'signature': signature}
+
+ boundary = '--boundary--'
+ data = []
+ for (key, value) in fields.items():
+ data.append('--' + boundary)
+ data.append('Content-Disposition: form-data; name="%s"' % key)
+ data.append('')
+ data.append(value)
+
+ data.append('--' + boundary)
+ data.append('Content-Disposition: form-data; '
+ 'name="file1"; filename="testfile"')
+ data.append('Content-Type: application/octet-stream')
+ data.append('')
+ data.append('hello world')
+
+ data.append('--' + boundary + '--')
+ data.append('')
+
+ body = '\r\n'.join(data)
+ content_type = 'multipart/form-data; boundary=%s' % boundary
+ return body, content_type
+
+ @attr(type=['gate', 'negative'])
+ def test_post_object_using_form_expired(self):
+ body, content_type = self.get_multipart_form(expires=1)
+ time.sleep(2)
+
+ headers = {'Content-Type': content_type,
+ 'Content-Length': str(len(body))}
+
+ url = "%s/%s/%s" % (self.container_client.base_url,
+ self.container_name,
+ self.object_name)
+
+ # Use a raw request, otherwise authentication headers are used
+ resp, body = self.object_client.http_obj.request(url, "POST",
+ body, headers=headers)
+ self.assertEqual(int(resp['status']), 401)
+ self.assertIn('FormPost: Form Expired', body)
diff --git a/tempest/api/object_storage/test_object_services.py b/tempest/api/object_storage/test_object_services.py
index 256165b..13f197b 100644
--- a/tempest/api/object_storage/test_object_services.py
+++ b/tempest/api/object_storage/test_object_services.py
@@ -31,20 +31,9 @@
cls.container_client.create_container(cls.container_name)
cls.containers = [cls.container_name]
- cls.data.setup_test_user()
- resp, body = cls.token_client.auth(cls.data.test_user,
- cls.data.test_password,
- cls.data.test_tenant)
- cls.new_token = cls.token_client.get_token(cls.data.test_user,
- cls.data.test_password,
- cls.data.test_tenant)
- cls.custom_headers = {'X-Auth-Token': cls.new_token}
-
@classmethod
def tearDownClass(cls):
cls.delete_containers(cls.containers)
- # delete the user setup created
- cls.data.teardown_all()
super(ObjectTest, cls).tearDownClass()
@attr(type='smoke')
diff --git a/tempest/api/object_storage/test_object_temp_url.py b/tempest/api/object_storage/test_object_temp_url.py
index 0523c68..47c270e 100644
--- a/tempest/api/object_storage/test_object_temp_url.py
+++ b/tempest/api/object_storage/test_object_temp_url.py
@@ -22,7 +22,6 @@
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -186,19 +185,3 @@
resp, body = self.object_client.head(url)
self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'HEAD')
-
- @test.attr(type=['gate', 'negative'])
- @test.requires_ext(extension='tempurl', service='object')
- def test_get_object_after_expiration_time(self):
-
- expires = self._get_expiry_date(1)
- # get a temp URL for the created object
- url = self._get_temp_url(self.container_name,
- self.object_name, "GET",
- expires, self.key)
-
- # temp URL is valid for 1 seconds, let's wait 2
- time.sleep(2)
-
- self.assertRaises(exceptions.Unauthorized,
- self.object_client.get, url)
diff --git a/tempest/api/object_storage/test_object_temp_url_negative.py b/tempest/api/object_storage/test_object_temp_url_negative.py
new file mode 100644
index 0000000..cc507c5
--- /dev/null
+++ b/tempest/api/object_storage/test_object_temp_url_negative.py
@@ -0,0 +1,109 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
+#
+# Author: Joe H. Rahme <joe.hakim.rahme@enovance.com>
+#
+# 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 hashlib
+import hmac
+import time
+import urlparse
+
+from tempest.api.object_storage import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class ObjectTempUrlNegativeTest(base.BaseObjectTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(ObjectTempUrlNegativeTest, cls).setUpClass()
+
+ cls.container_name = data_utils.rand_name(name='TestContainer')
+ cls.container_client.create_container(cls.container_name)
+ cls.containers = [cls.container_name]
+
+ # update account metadata
+ cls.key = 'Meta'
+ cls.metadata = {'Temp-URL-Key': cls.key}
+ cls.account_client.create_account_metadata(metadata=cls.metadata)
+ cls.account_client_metadata, _ = \
+ cls.account_client.list_account_metadata()
+
+ @classmethod
+ def tearDownClass(cls):
+ resp, _ = cls.account_client.delete_account_metadata(
+ metadata=cls.metadata)
+
+ cls.delete_containers(cls.containers)
+
+ # delete the user setup created
+ cls.data.teardown_all()
+ super(ObjectTempUrlNegativeTest, cls).tearDownClass()
+
+ def setUp(self):
+ super(ObjectTempUrlNegativeTest, self).setUp()
+ # make sure the metadata has been set
+ self.assertIn('x-account-meta-temp-url-key',
+ self.account_client_metadata)
+
+ self.assertEqual(
+ self.account_client_metadata['x-account-meta-temp-url-key'],
+ self.key)
+
+ # create object
+ self.object_name = data_utils.rand_name(name='ObjectTemp')
+ self.data = data_utils.arbitrary_string(size=len(self.object_name),
+ base_text=self.object_name)
+ self.object_client.create_object(self.container_name,
+ self.object_name, self.data)
+
+ def _get_expiry_date(self, expiration_time=1000):
+ return int(time.time() + expiration_time)
+
+ def _get_temp_url(self, container, object_name, method, expires,
+ key):
+ """Create the temporary URL."""
+
+ path = "%s/%s/%s" % (
+ urlparse.urlparse(self.object_client.base_url).path,
+ container, object_name)
+
+ hmac_body = '%s\n%s\n%s' % (method, expires, path)
+ sig = hmac.new(key, hmac_body, hashlib.sha1).hexdigest()
+
+ url = "%s/%s?temp_url_sig=%s&temp_url_expires=%s" % (container,
+ object_name,
+ sig, expires)
+
+ return url
+
+ @test.attr(type=['gate', 'negative'])
+ @test.requires_ext(extension='tempurl', service='object')
+ def test_get_object_after_expiration_time(self):
+
+ expires = self._get_expiry_date(1)
+ # get a temp URL for the created object
+ url = self._get_temp_url(self.container_name,
+ self.object_name, "GET",
+ expires, self.key)
+
+ # temp URL is valid for 1 seconds, let's wait 2
+ time.sleep(2)
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.object_client.get, url)
diff --git a/tempest/api/orchestration/stacks/test_templates.py b/tempest/api/orchestration/stacks/test_templates.py
index 6cbc872..2da819d 100644
--- a/tempest/api/orchestration/stacks/test_templates.py
+++ b/tempest/api/orchestration/stacks/test_templates.py
@@ -10,17 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-import logging
-
from tempest.api.orchestration import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest.test import attr
-LOG = logging.getLogger(__name__)
-
-
class TemplateYAMLTestJSON(base.BaseOrchestrationTest):
_interface = 'json'
@@ -59,14 +53,6 @@
self.parameters)
self.assertEqual('200', resp['status'])
- @attr(type=['gate', 'negative'])
- def test_validate_template_url(self):
- """Validating template passing url to it."""
- self.assertRaises(exceptions.BadRequest,
- self.client.validate_template_url,
- template_url=self.invalid_template_url,
- parameters=self.parameters)
-
class TemplateAWSTestJSON(TemplateYAMLTestJSON):
template = """
diff --git a/tempest/api/orchestration/stacks/test_templates_negative.py b/tempest/api/orchestration/stacks/test_templates_negative.py
new file mode 100644
index 0000000..c55f6ee
--- /dev/null
+++ b/tempest/api/orchestration/stacks/test_templates_negative.py
@@ -0,0 +1,62 @@
+# Copyright 2014 NEC Corporation. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.orchestration import base
+from tempest import exceptions
+from tempest import test
+
+
+class TemplateYAMLNegativeTestJSON(base.BaseOrchestrationTest):
+ _interface = 'json'
+
+ template = """
+HeatTemplateFormatVersion: '2012-12-12'
+Description: |
+ Template which creates only a new user
+Resources:
+ CfnUser:
+ Type: AWS::IAM::User
+"""
+
+ invalid_template_url = 'http://www.example.com/template.yaml'
+
+ @classmethod
+ def setUpClass(cls):
+ super(TemplateYAMLNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.orchestration_client
+ cls.parameters = {}
+
+ @test.attr(type=['gate', 'negative'])
+ def test_validate_template_url(self):
+ """Validating template passing url to it."""
+ self.assertRaises(exceptions.BadRequest,
+ self.client.validate_template_url,
+ template_url=self.invalid_template_url,
+ parameters=self.parameters)
+
+
+class TemplateAWSNegativeTestJSON(TemplateYAMLNegativeTestJSON):
+ template = """
+{
+ "AWSTemplateFormatVersion" : "2010-09-09",
+ "Description" : "Template which creates only a new user",
+ "Resources" : {
+ "CfnUser" : {
+ "Type" : "AWS::IAM::User"
+ }
+ }
+}
+"""
+
+ invalid_template_url = 'http://www.example.com/template.template'
diff --git a/tempest/api/volume/admin/test_volume_types.py b/tempest/api/volume/admin/test_volume_types.py
index 0ea999a..4add2c1 100644
--- a/tempest/api/volume/admin/test_volume_types.py
+++ b/tempest/api/volume/admin/test_volume_types.py
@@ -15,27 +15,12 @@
from tempest.api.volume import base
from tempest.common.utils import data_utils
-from tempest.services.volume.json.admin import volume_types_client
from tempest.test import attr
-class VolumeTypesTest(base.BaseVolumeV1Test):
+class VolumeTypesTest(base.BaseVolumeV1AdminTest):
_interface = "json"
- @classmethod
- def setUpClass(cls):
- super(VolumeTypesTest, cls).setUpClass()
- adm_user = cls.config.identity.admin_username
- adm_pass = cls.config.identity.admin_password
- adm_tenant = cls.config.identity.admin_tenant_name
- auth_url = cls.config.identity.uri
-
- cls.client = volume_types_client.VolumeTypesClientJSON(cls.config,
- adm_user,
- adm_pass,
- auth_url,
- adm_tenant)
-
def _delete_volume(self, volume_id):
resp, _ = self.volumes_client.delete_volume(volume_id)
self.assertEqual(202, resp.status)
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 008fb1a..9c6eebe 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -36,10 +36,7 @@
cls.os = cls.get_client_manager()
- cls.volumes_client = cls.os.volumes_client
- cls.snapshots_client = cls.os.snapshots_client
cls.servers_client = cls.os.servers_client
- cls.volumes_extension_client = cls.os.volumes_extension_client
cls.image_ref = cls.config.compute.image_ref
cls.flavor_ref = cls.config.compute.flavor_ref
cls.build_interval = cls.config.volume.build_interval
@@ -116,12 +113,9 @@
msg = "Volume API v1 not supported"
raise cls.skipException(msg)
super(BaseVolumeV1Test, cls).setUpClass()
+ cls.snapshots_client = cls.os.snapshots_client
cls.volumes_client = cls.os.volumes_client
- cls.volumes_client.keystone_auth(cls.os.username,
- cls.os.password,
- cls.os.auth_url,
- cls.volumes_client.service,
- cls.os.tenant_name)
+ cls.volumes_extension_client = cls.os.volumes_extension_client
class BaseVolumeV1AdminTest(BaseVolumeV1Test):
diff --git a/tempest/api/volume/test_extensions.py b/tempest/api/volume/test_extensions.py
index d9f9037..deef8a1 100644
--- a/tempest/api/volume/test_extensions.py
+++ b/tempest/api/volume/test_extensions.py
@@ -22,7 +22,7 @@
LOG = logging.getLogger(__name__)
-class ExtensionsTestJSON(base.BaseVolumeTest):
+class ExtensionsTestJSON(base.BaseVolumeV1Test):
_interface = 'json'
@attr(type='gate')
diff --git a/tempest/api/volume/test_volume_metadata.py b/tempest/api/volume/test_volume_metadata.py
index 6e46168..6d23c0a 100644
--- a/tempest/api/volume/test_volume_metadata.py
+++ b/tempest/api/volume/test_volume_metadata.py
@@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.api.volume.base import BaseVolumeTest
+from tempest.api.volume import base
from tempest import test
-class VolumeMetadataTest(BaseVolumeTest):
+class VolumeMetadataTest(base.BaseVolumeV1Test):
_interface = "json"
@classmethod
diff --git a/tempest/api/volume/test_volume_transfers.py b/tempest/api/volume/test_volume_transfers.py
index 8710d82..4ee7bd0 100644
--- a/tempest/api/volume/test_volume_transfers.py
+++ b/tempest/api/volume/test_volume_transfers.py
@@ -55,10 +55,17 @@
cls.alt_client = cls.os_alt.volumes_client
cls.adm_client = cls.os_adm.volumes_client
+ def _delete_volume(self, volume_id):
+ # Delete the specified volume using admin creds
+ resp, _ = self.adm_client.delete_volume(volume_id)
+ self.assertEqual(202, resp.status)
+ self.adm_client.wait_for_resource_deletion(volume_id)
+
@attr(type='gate')
def test_create_get_list_accept_volume_transfer(self):
# Create a volume first
volume = self.create_volume()
+ self.addCleanup(self._delete_volume, volume['id'])
# Create a volume transfer
resp, transfer = self.client.create_volume_transfer(volume['id'])
@@ -88,6 +95,7 @@
def test_create_list_delete_volume_transfer(self):
# Create a volume first
volume = self.create_volume()
+ self.addCleanup(self._delete_volume, volume['id'])
# Create a volume transfer
resp, body = self.client.create_volume_transfer(volume['id'])
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index 7d9f894..284c321 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -34,14 +34,14 @@
cls.mountpoint = "/dev/vdc"
@attr(type=['negative', 'gate'])
- def test_volume_get_nonexistant_volume_id(self):
- # Should not be able to get a non-existant volume
+ def test_volume_get_nonexistent_volume_id(self):
+ # Should not be able to get a non-existent volume
self.assertRaises(exceptions.NotFound, self.client.get_volume,
str(uuid.uuid4()))
@attr(type=['negative', 'gate'])
- def test_volume_delete_nonexistant_volume_id(self):
- # Should not be able to delete a non-existant Volume
+ def test_volume_delete_nonexistent_volume_id(self):
+ # Should not be able to delete a non-existent Volume
self.assertRaises(exceptions.NotFound, self.client.delete_volume,
str(uuid.uuid4()))
@@ -80,8 +80,8 @@
size='-1', display_name=v_name, metadata=metadata)
@attr(type=['negative', 'gate'])
- def test_create_volume_with_nonexistant_volume_type(self):
- # Should not be able to create volume with non-existant volume type
+ def test_create_volume_with_nonexistent_volume_type(self):
+ # Should not be able to create volume with non-existent volume type
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
self.assertRaises(exceptions.NotFound, self.client.create_volume,
@@ -89,8 +89,8 @@
display_name=v_name, metadata=metadata)
@attr(type=['negative', 'gate'])
- def test_create_volume_with_nonexistant_snapshot_id(self):
- # Should not be able to create volume with non-existant snapshot
+ def test_create_volume_with_nonexistent_snapshot_id(self):
+ # Should not be able to create volume with non-existent snapshot
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
self.assertRaises(exceptions.NotFound, self.client.create_volume,
@@ -98,8 +98,8 @@
display_name=v_name, metadata=metadata)
@attr(type=['negative', 'gate'])
- def test_create_volume_with_nonexistant_source_volid(self):
- # Should not be able to create volume with non-existant source volume
+ def test_create_volume_with_nonexistent_source_volid(self):
+ # Should not be able to create volume with non-existent source volume
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
self.assertRaises(exceptions.NotFound, self.client.create_volume,
@@ -107,7 +107,7 @@
display_name=v_name, metadata=metadata)
@attr(type=['negative', 'gate'])
- def test_update_volume_with_nonexistant_volume_id(self):
+ def test_update_volume_with_nonexistent_volume_id(self):
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
self.assertRaises(exceptions.NotFound, self.client.update_volume,
diff --git a/tempest/cli/simple_read_only/heat_templates/heat_minimal_hot.yaml b/tempest/cli/simple_read_only/heat_templates/heat_minimal_hot.yaml
index 6d89b7b..4657bfc 100644
--- a/tempest/cli/simple_read_only/heat_templates/heat_minimal_hot.yaml
+++ b/tempest/cli/simple_read_only/heat_templates/heat_minimal_hot.yaml
@@ -3,10 +3,10 @@
parameters:
instance_image:
description: Glance image name
- type: String
+ type: string
instance_type:
description: Nova instance type
- type: String
+ type: string
default: m1.small
constraints:
- allowed_values: [m1.small, m1.medium, m1.large]
diff --git a/tempest/cli/simple_read_only/test_cinder.py b/tempest/cli/simple_read_only/test_cinder.py
index f71a2de..5dcb708 100644
--- a/tempest/cli/simple_read_only/test_cinder.py
+++ b/tempest/cli/simple_read_only/test_cinder.py
@@ -18,7 +18,10 @@
import subprocess
import tempest.cli
+from tempest import config
+
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -30,6 +33,13 @@
their own. They only verify the structure of output if present.
"""
+ @classmethod
+ def setUpClass(cls):
+ if not CONF.service_available.cinder:
+ msg = ("%s skipped as Cinder is not available" % cls.__name__)
+ raise cls.skipException(msg)
+ super(SimpleReadOnlyCinderClientTest, cls).setUpClass()
+
def test_cinder_fake_action(self):
self.assertRaises(subprocess.CalledProcessError,
self.cinder,
@@ -47,6 +57,12 @@
def test_cinder_volumes_list(self):
self.cinder('list')
+ self.cinder('list', params='--all-tenants 1')
+ self.cinder('list', params='--all-tenants 0')
+ self.assertRaises(subprocess.CalledProcessError,
+ self.cinder,
+ 'list',
+ params='--all-tenants bad')
def test_cinder_quota_class_show(self):
"""This CLI can accept and string as param."""
diff --git a/tempest/cli/simple_read_only/test_glance.py b/tempest/cli/simple_read_only/test_glance.py
index 0e0f995..b558190 100644
--- a/tempest/cli/simple_read_only/test_glance.py
+++ b/tempest/cli/simple_read_only/test_glance.py
@@ -35,6 +35,13 @@
their own. They only verify the structure of output if present.
"""
+ @classmethod
+ def setUpClass(cls):
+ if not CONF.service_available.glance:
+ msg = ("%s skipped as Glance is not available" % cls.__name__)
+ raise cls.skipException(msg)
+ super(SimpleReadOnlyGlanceClientTest, cls).setUpClass()
+
def test_glance_fake_action(self):
self.assertRaises(subprocess.CalledProcessError,
self.glance,
diff --git a/tempest/cli/simple_read_only/test_nova.py b/tempest/cli/simple_read_only/test_nova.py
index 822e531..f8ba971 100644
--- a/tempest/cli/simple_read_only/test_nova.py
+++ b/tempest/cli/simple_read_only/test_nova.py
@@ -42,6 +42,13 @@
"""
+ @classmethod
+ def setUpClass(cls):
+ if not CONF.service_available.nova:
+ msg = ("%s skipped as Nova is not available" % cls.__name__)
+ raise cls.skipException(msg)
+ super(SimpleReadOnlyNovaClientTest, cls).setUpClass()
+
def test_admin_fake_action(self):
self.assertRaises(subprocess.CalledProcessError,
self.nova,
diff --git a/tempest/cli/simple_read_only/test_nova_manage.py b/tempest/cli/simple_read_only/test_nova_manage.py
index a92e8da..13a1589 100644
--- a/tempest/cli/simple_read_only/test_nova_manage.py
+++ b/tempest/cli/simple_read_only/test_nova_manage.py
@@ -16,9 +16,11 @@
import subprocess
import tempest.cli
+from tempest import config
from tempest.openstack.common import log as logging
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -34,6 +36,13 @@
"""
+ @classmethod
+ def setUpClass(cls):
+ if not CONF.service_available.nova:
+ msg = ("%s skipped as Nova is not available" % cls.__name__)
+ raise cls.skipException(msg)
+ super(SimpleReadOnlyNovaManageTest, cls).setUpClass()
+
def test_admin_fake_action(self):
self.assertRaises(subprocess.CalledProcessError,
self.nova_manage,
diff --git a/tempest/clients.py b/tempest/clients.py
index e44da84..4c40ce0 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -78,31 +78,6 @@
TenantUsagesV3ClientJSON
from tempest.services.compute.v3.json.version_client import \
VersionV3ClientJSON
-from tempest.services.compute.v3.xml.aggregates_client import \
- AggregatesV3ClientXML
-from tempest.services.compute.v3.xml.availability_zone_client import \
- AvailabilityZoneV3ClientXML
-from tempest.services.compute.v3.xml.certificates_client import \
- 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.hosts_client import HostsV3ClientXML
-from tempest.services.compute.v3.xml.hypervisor_client import \
- HypervisorV3ClientXML
-from tempest.services.compute.v3.xml.instance_usage_audit_log_client import \
- InstanceUsagesAuditLogV3ClientXML
-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.quotas_client import \
- QuotasV3ClientXML
-from tempest.services.compute.v3.xml.servers_client import ServersV3ClientXML
-from tempest.services.compute.v3.xml.services_client import \
- ServicesV3ClientXML
-from tempest.services.compute.v3.xml.tenant_usages_client import \
- TenantUsagesV3ClientXML
-from tempest.services.compute.v3.xml.version_client import VersionV3ClientXML
from tempest.services.compute.xml.aggregates_client import AggregatesClientXML
from tempest.services.compute.xml.availability_zone_client import \
AvailabilityZoneClientXML
@@ -168,6 +143,10 @@
ObjectClientCustomizedHeader
from tempest.services.orchestration.json.orchestration_client import \
OrchestrationClient
+from tempest.services.telemetry.json.telemetry_client import \
+ TelemetryClientJSON
+from tempest.services.telemetry.xml.telemetry_client import \
+ TelemetryClientXML
from tempest.services.volume.json.admin.volume_hosts_client import \
VolumeHostsClientJSON
from tempest.services.volume.json.admin.volume_types_client import \
@@ -238,20 +217,13 @@
if interface == 'xml':
self.certificates_client = CertificatesClientXML(*client_args)
- self.certificates_v3_client = CertificatesV3ClientXML(*client_args)
self.baremetal_client = BaremetalClientXML(*client_args)
self.servers_client = ServersClientXML(*client_args)
- 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.keypairs_v3_client = KeyPairsV3ClientXML(*client_args)
self.quotas_client = QuotasClientXML(*client_args)
- self.quotas_v3_client = QuotasV3ClientXML(*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(
*client_args)
@@ -264,42 +236,32 @@
self.token_client = TokenClientXML(CONF)
self.security_groups_client = SecurityGroupsClientXML(
*client_args)
- self.interfaces_v3_client = InterfacesV3ClientXML(*client_args)
self.interfaces_client = InterfacesClientXML(*client_args)
self.endpoints_client = EndPointClientXML(*client_args)
self.fixed_ips_client = FixedIPsClientXML(*client_args)
- self.availability_zone_v3_client = AvailabilityZoneV3ClientXML(
- *client_args)
self.availability_zone_client = AvailabilityZoneClientXML(
*client_args)
- self.services_v3_client = ServicesV3ClientXML(*client_args)
self.service_client = ServiceClientXML(*client_args)
- self.aggregates_v3_client = AggregatesV3ClientXML(*client_args)
self.aggregates_client = AggregatesClientXML(*client_args)
self.services_client = ServicesClientXML(*client_args)
- self.tenant_usages_v3_client = TenantUsagesV3ClientXML(
- *client_args)
self.tenant_usages_client = TenantUsagesClientXML(*client_args)
- self.version_v3_client = VersionV3ClientXML(*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)
self.network_client = NetworkClientXML(*client_args)
self.credentials_client = CredentialsClientXML(*client_args)
self.instance_usages_audit_log_client = \
InstanceUsagesAuditLogClientXML(*client_args)
- self.instance_usages_audit_log_v3_client = \
- InstanceUsagesAuditLogV3ClientXML(*client_args)
self.volume_hosts_client = VolumeHostsClientXML(*client_args)
self.volumes_extension_client = VolumeExtensionClientXML(
*client_args)
- self.hosts_v3_client = HostsV3ClientXML(*client_args)
if client_args_v3_auth:
self.servers_client_v3_auth = ServersClientXML(
*client_args_v3_auth)
+ if CONF.service_available.ceilometer:
+ self.telemetry_client = TelemetryClientXML(*client_args)
elif interface == 'json':
self.certificates_client = CertificatesClientJSON(*client_args)
@@ -362,6 +324,8 @@
self.volumes_extension_client = VolumeExtensionClientJSON(
*client_args)
self.hosts_v3_client = HostsV3ClientJSON(*client_args)
+ if CONF.service_available.ceilometer:
+ self.telemetry_client = TelemetryClientJSON(*client_args)
if client_args_v3_auth:
self.servers_client_v3_auth = ServersClientJSON(
diff --git a/tempest/common/glance_http.py b/tempest/common/glance_http.py
index e72cd9e..2ce05ee 100644
--- a/tempest/common/glance_http.py
+++ b/tempest/common/glance_http.py
@@ -218,6 +218,8 @@
return getattr(self.connection, name)
def makefile(self, *args, **kwargs):
+ # Ensure the socket is closed when this file is closed
+ kwargs['close'] = True
return socket._fileobject(self.connection, *args, **kwargs)
@@ -345,6 +347,15 @@
self.sock = OpenSSLConnectionDelegator(self.context, sock)
self.sock.connect((self.host, self.port))
+ def close(self):
+ if self.sock:
+ # Remove the reference to the socket but don't close it yet.
+ # Response close will close both socket and associated
+ # file. Closing socket too soon will cause response
+ # reads to fail with socket IO error 'Bad file descriptor'.
+ self.sock = None
+ super(VerifiedHTTPSConnection, self).close()
+
class ResponseBodyIterator(object):
"""A class that acts as an iterator over an HTTP response."""
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index 95d12c1..f2df061 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -146,18 +146,28 @@
else:
self.identity_admin_client.tenants.delete(tenant)
- def _create_creds(self, suffix=None, admin=False):
- data_utils.rand_name_root = data_utils.rand_name(self.name)
- if suffix:
- data_utils.rand_name_root += suffix
- tenant_name = data_utils.rand_name_root + "-tenant"
+ def _create_creds(self, suffix="", admin=False):
+ """Create random credentials under the following schema.
+
+ If the name contains a '.' is the full class path of something, and
+ we don't really care. If it isn't, it's probably a meaningful name,
+ so use it.
+
+ For logging purposes, -user and -tenant are long and redundant,
+ don't use them. The user# will be sufficient to figure it out.
+ """
+ if '.' in self.name:
+ root = ""
+ else:
+ root = self.name
+
+ tenant_name = data_utils.rand_name(root) + suffix
tenant_desc = tenant_name + "-desc"
tenant = self._create_tenant(name=tenant_name,
description=tenant_desc)
- if suffix:
- data_utils.rand_name_root += suffix
- username = data_utils.rand_name_root + "-user"
- email = data_utils.rand_name_root + "@example.com"
+
+ username = data_utils.rand_name(root) + suffix
+ email = data_utils.rand_name(root) + suffix + "@example.com"
user = self._create_user(username, self.password,
tenant, email)
if admin:
@@ -237,7 +247,7 @@
def _create_network(self, name, tenant_id):
if self.tempest_client:
resp, resp_body = self.network_admin_client.create_network(
- name, tenant_id=tenant_id)
+ name=name, tenant_id=tenant_id)
else:
body = {'network': {'tenant_id': tenant_id, 'name': name}}
resp_body = self.network_admin_client.create_network(body)
@@ -257,15 +267,18 @@
if self.network_resources:
resp, resp_body = self.network_admin_client.\
create_subnet(
- network_id, str(subnet_cidr),
+ network_id=network_id, cidr=str(subnet_cidr),
name=subnet_name,
tenant_id=tenant_id,
- enable_dhcp=self.network_resources['dhcp'])
+ enable_dhcp=self.network_resources['dhcp'],
+ ip_version=4)
else:
resp, resp_body = self.network_admin_client.\
- create_subnet(network_id, str(subnet_cidr),
+ create_subnet(network_id=network_id,
+ cidr=str(subnet_cidr),
name=subnet_name,
- tenant_id=tenant_id)
+ tenant_id=tenant_id,
+ ip_version=4)
else:
body['subnet']['cidr'] = str(subnet_cidr)
resp_body = self.network_admin_client.create_subnet(body)
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 966c277..b1fef99 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -265,7 +265,8 @@
" (auth URL is '%s'), the response status is %s" %
(req_url, resp.status))
raise exceptions.AuthenticationFailure(user=user,
- password=password)
+ password=password,
+ tenant=project_name)
def expected_success(self, expected_code, read_code):
assert_msg = ("This function only allowed to use for HTTP status"
@@ -441,18 +442,17 @@
if resp.status < 400:
return
- JSON_ENC = ['application/json; charset=UTF-8', 'application/json',
- 'application/json; charset=utf-8']
+ JSON_ENC = ['application/json', 'application/json; charset=utf-8']
# NOTE(mtreinish): This is for compatibility with Glance and swift
# APIs. These are the return content types that Glance api v1
# (and occasionally swift) are using.
- TXT_ENC = ['text/plain', 'text/plain; charset=UTF-8',
- 'text/html; charset=UTF-8', 'text/plain; charset=utf-8']
- XML_ENC = ['application/xml', 'application/xml; charset=UTF-8']
+ TXT_ENC = ['text/plain', 'text/html', 'text/html; charset=utf-8',
+ 'text/plain; charset=utf-8']
+ XML_ENC = ['application/xml', 'application/xml; charset=utf-8']
- if ctype in JSON_ENC or ctype in XML_ENC:
+ if ctype.lower() in JSON_ENC or ctype.lower() in XML_ENC:
parse_resp = True
- elif ctype in TXT_ENC:
+ elif ctype.lower() in TXT_ENC:
parse_resp = False
else:
raise exceptions.RestClientException(str(resp.status))
diff --git a/tempest/common/ssh.py b/tempest/common/ssh.py
index 5eb7336..0ed9b82 100644
--- a/tempest/common/ssh.py
+++ b/tempest/common/ssh.py
@@ -93,20 +93,6 @@
def _is_timed_out(self, start_time):
return (time.time() - self.timeout) > start_time
- def connect_until_closed(self):
- """Connect to the server and wait until connection is lost."""
- try:
- ssh = self._get_ssh_connection()
- _transport = ssh.get_transport()
- _start_time = time.time()
- _timed_out = self._is_timed_out(_start_time)
- while _transport.is_active() and not _timed_out:
- time.sleep(5)
- _timed_out = self._is_timed_out(_start_time)
- ssh.close()
- except (EOFError, paramiko.AuthenticationException, socket.error):
- return
-
def exec_command(self, cmd):
"""
Execute the specified command on the server.
@@ -138,7 +124,7 @@
raise exceptions.TimeoutException(
"Command: '{0}' executed on host '{1}'.".format(
cmd, self.host))
- if not ready[0]: # If there is nothing to read.
+ if not ready[0]: # If there is nothing to read.
continue
out_chunk = err_chunk = None
if channel.recv_ready():
diff --git a/tempest/common/utils/data_utils.py b/tempest/common/utils/data_utils.py
index 2b2963c..cd32720 100644
--- a/tempest/common/utils/data_utils.py
+++ b/tempest/common/utils/data_utils.py
@@ -30,8 +30,12 @@
return uuid.uuid4().hex
-def rand_name(name='test'):
- return name + "-tempest-" + str(random.randint(1, 0x7fffffff))
+def rand_name(name=''):
+ randbits = str(random.randint(1, 0x7fffffff))
+ if name:
+ return name + '-' + randbits
+ else:
+ return randbits
def rand_int_id(start=0, end=0x7fffffff):
diff --git a/tempest/config.py b/tempest/config.py
index d529965..5a9199d 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -147,7 +147,7 @@
default='root',
help="User name used to authenticate to an instance."),
cfg.IntOpt('ping_timeout',
- default=60,
+ default=120,
help="Timeout in seconds to wait for ping to "
"succeed."),
cfg.IntOpt('ssh_timeout',
diff --git a/tempest/openstack/common/fixture/mockpatch.py b/tempest/openstack/common/fixture/mockpatch.py
index 858e77c..d7dcc11 100644
--- a/tempest/openstack/common/fixture/mockpatch.py
+++ b/tempest/openstack/common/fixture/mockpatch.py
@@ -22,14 +22,15 @@
class PatchObject(fixtures.Fixture):
"""Deal with code around mock."""
- def __init__(self, obj, attr, **kwargs):
+ def __init__(self, obj, attr, new=mock.DEFAULT, **kwargs):
self.obj = obj
self.attr = attr
self.kwargs = kwargs
+ self.new = new
def setUp(self):
super(PatchObject, self).setUp()
- _p = mock.patch.object(self.obj, self.attr, **self.kwargs)
+ _p = mock.patch.object(self.obj, self.attr, self.new, **self.kwargs)
self.mock = _p.start()
self.addCleanup(_p.stop)
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 04882f3..ca3a2db 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -233,7 +233,7 @@
def setUpClass(cls):
super(OfficialClientTest, cls).setUpClass()
cls.isolated_creds = isolated_creds.IsolatedCreds(
- __name__, tempest_client=False,
+ cls.__name__, tempest_client=False,
network_resources=cls.network_resources)
username, password, tenant_name = cls.credentials()
diff --git a/tempest/scenario/test_aggregates_basic_ops.py b/tempest/scenario/test_aggregates_basic_ops.py
index 3ae9567..7afa863 100644
--- a/tempest/scenario/test_aggregates_basic_ops.py
+++ b/tempest/scenario/test_aggregates_basic_ops.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
# All Rights Reserved.
#
diff --git a/tempest/scenario/test_cross_tenant_connectivity.py b/tempest/scenario/test_cross_tenant_connectivity.py
index cb64314..6fd10be 100644
--- a/tempest/scenario/test_cross_tenant_connectivity.py
+++ b/tempest/scenario/test_cross_tenant_connectivity.py
@@ -369,7 +369,6 @@
msg)
except Exception:
debug.log_ip_ns()
- self._log_console_output(servers=self.servers)
raise
def _test_in_tenant_block(self, tenant):
@@ -472,17 +471,21 @@
@attr(type='smoke')
@services('compute', 'network')
def test_cross_tenant_traffic(self):
- for tenant_id in self.tenants.keys():
- self._deploy_tenant(tenant_id)
- self._verify_network_details(self.tenants[tenant_id])
- self._verify_mac_addr(self.tenants[tenant_id])
+ try:
+ for tenant_id in self.tenants.keys():
+ self._deploy_tenant(tenant_id)
+ self._verify_network_details(self.tenants[tenant_id])
+ self._verify_mac_addr(self.tenants[tenant_id])
- # in-tenant check
- self._test_in_tenant_block(self.demo_tenant)
- self._test_in_tenant_allow(self.demo_tenant)
+ # in-tenant check
+ self._test_in_tenant_block(self.demo_tenant)
+ self._test_in_tenant_allow(self.demo_tenant)
- # cross tenant check
- source_tenant = self.demo_tenant
- dest_tenant = self.alt_tenant
- self._test_cross_tenant_block(source_tenant, dest_tenant)
- self._test_cross_tenant_allow(source_tenant, dest_tenant)
+ # cross tenant check
+ source_tenant = self.demo_tenant
+ dest_tenant = self.alt_tenant
+ self._test_cross_tenant_block(source_tenant, dest_tenant)
+ self._test_cross_tenant_allow(source_tenant, dest_tenant)
+ except Exception:
+ self._log_console_output(servers=self.servers)
+ raise
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index c2c5e27..26a4dc0 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -159,6 +159,7 @@
self.cinder_list()
self.cinder_show()
self.nova_volume_attach()
+ self.addCleanup(self.nova_volume_detach)
self.cinder_show()
self.nova_reboot()
@@ -167,5 +168,3 @@
self._create_loginable_secgroup_rule_nova()
self.ssh_to_server()
self.check_partitions()
-
- self.nova_volume_detach()
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index eaca1fd..aea5874 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -186,8 +186,7 @@
key.private_key)
except Exception:
LOG.exception('Tenant connectivity check failed')
- self._log_console_output(
- servers=[server for server, _key in self.servers])
+ self._log_console_output(servers=self.servers.keys())
debug.log_ip_ns()
raise
@@ -214,8 +213,7 @@
should_connect=should_connect)
except Exception:
LOG.exception('Public network connectivity check failed')
- self._log_console_output(
- servers=[server for server, _key in self.servers])
+ self._log_console_output(servers=self.servers.keys())
debug.log_ip_ns()
raise
diff --git a/tempest/services/compute/v3/xml/aggregates_client.py b/tempest/services/compute/v3/xml/aggregates_client.py
deleted file mode 100644
index d619aa7..0000000
--- a/tempest/services/compute/v3/xml/aggregates_client.py
+++ /dev/null
@@ -1,128 +0,0 @@
-# Copyright 2013 NEC Corporation.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common.rest_client import RestClientXML
-from tempest import exceptions
-from tempest.services.compute.xml.common import Document
-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
-
-
-class AggregatesV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(AggregatesV3ClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def _format_aggregate(self, g):
- agg = xml_to_json(g)
- aggregate = {}
- for key, value in agg.items():
- if key == 'hosts':
- aggregate['hosts'] = []
- for k, v in value.items():
- aggregate['hosts'].append(v)
- elif key == 'availability_zone':
- aggregate[key] = None if value == 'None' else value
- else:
- aggregate[key] = value
- return aggregate
-
- def _parse_array(self, node):
- return [self._format_aggregate(x) for x in node]
-
- def list_aggregates(self):
- """Get aggregate list."""
- resp, body = self.get("os-aggregates", self.headers)
- aggregates = self._parse_array(etree.fromstring(body))
- return resp, aggregates
-
- def get_aggregate(self, aggregate_id):
- """Get details of the given aggregate."""
- resp, body = self.get("os-aggregates/%s" % str(aggregate_id),
- self.headers)
- aggregate = self._format_aggregate(etree.fromstring(body))
- return resp, aggregate
-
- def create_aggregate(self, name, availability_zone=None):
- """Creates a new aggregate."""
- post_body = Element("aggregate",
- name=name,
- availability_zone=availability_zone)
- resp, body = self.post('os-aggregates',
- str(Document(post_body)),
- self.headers)
- aggregate = self._format_aggregate(etree.fromstring(body))
- return resp, aggregate
-
- def update_aggregate(self, aggregate_id, name, availability_zone=None):
- """Update a aggregate."""
- put_body = Element("aggregate",
- name=name,
- availability_zone=availability_zone)
- resp, body = self.put('os-aggregates/%s' % str(aggregate_id),
- str(Document(put_body)),
- self.headers)
- aggregate = self._format_aggregate(etree.fromstring(body))
- return resp, aggregate
-
- def delete_aggregate(self, aggregate_id):
- """Deletes the given aggregate."""
- return self.delete("os-aggregates/%s" % str(aggregate_id),
- self.headers)
-
- def is_resource_deleted(self, id):
- try:
- self.get_aggregate(id)
- except exceptions.NotFound:
- return True
- return False
-
- def add_host(self, aggregate_id, host):
- """Adds a host to the given aggregate."""
- post_body = Element("add_host", host=host)
- resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- str(Document(post_body)),
- self.headers)
- aggregate = self._format_aggregate(etree.fromstring(body))
- return resp, aggregate
-
- def remove_host(self, aggregate_id, host):
- """Removes a host from the given aggregate."""
- post_body = Element("remove_host", host=host)
- resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- str(Document(post_body)),
- self.headers)
- aggregate = self._format_aggregate(etree.fromstring(body))
- return resp, aggregate
-
- def set_metadata(self, aggregate_id, meta):
- """Replaces the aggregate's existing metadata with new metadata."""
- post_body = Element("set_metadata")
- metadata = Element("metadata")
- post_body.append(metadata)
- for k, v in meta.items():
- meta = Element(k)
- meta.append(Text(v))
- metadata.append(meta)
- resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- str(Document(post_body)),
- self.headers)
- aggregate = self._format_aggregate(etree.fromstring(body))
- return resp, aggregate
diff --git a/tempest/services/compute/v3/xml/availability_zone_client.py b/tempest/services/compute/v3/xml/availability_zone_client.py
deleted file mode 100644
index 5278eab..0000000
--- a/tempest/services/compute/v3/xml/availability_zone_client.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2013 NEC Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common.rest_client import RestClientXML
-from tempest.services.compute.xml.common import xml_to_json
-
-
-class AvailabilityZoneV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(AvailabilityZoneV3ClientXML, self).__init__(config, username,
- password, auth_url,
- tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def _parse_array(self, node):
- return [xml_to_json(x) for x in node]
-
- def get_availability_zone_list(self):
- resp, body = self.get('os-availability-zone', self.headers)
- availability_zone = self._parse_array(etree.fromstring(body))
- return resp, availability_zone
-
- def get_availability_zone_list_detail(self):
- resp, body = self.get('os-availability-zone/detail', self.headers)
- availability_zone = self._parse_array(etree.fromstring(body))
- return resp, availability_zone
diff --git a/tempest/services/compute/v3/xml/certificates_client.py b/tempest/services/compute/v3/xml/certificates_client.py
deleted file mode 100644
index 0ff4de4..0000000
--- a/tempest/services/compute/v3/xml/certificates_client.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# 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.rest_client import RestClientXML
-
-
-class CertificatesV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(CertificatesV3ClientXML, self).__init__(config, username,
- password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def get_certificate(self, id):
- url = "os-certificates/%s" % (id)
- resp, body = self.get(url, self.headers)
- body = self._parse_resp(body)
- return resp, body
-
- def create_certificate(self):
- """create certificates."""
- url = "os-certificates"
- resp, body = self.post(url, None, self.headers)
- body = self._parse_resp(body)
- return resp, body
diff --git a/tempest/services/compute/v3/xml/extensions_client.py b/tempest/services/compute/v3/xml/extensions_client.py
deleted file mode 100644
index 8145e20..0000000
--- a/tempest/services/compute/v3/xml/extensions_client.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# 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 lxml import etree
-from tempest.common.rest_client import RestClientXML
-from tempest.services.compute.xml.common import xml_to_json
-
-
-class ExtensionsV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(ExtensionsV3ClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def _parse_array(self, node):
- array = []
- for child in node:
- array.append(xml_to_json(child))
- return array
-
- def list_extensions(self):
- url = 'extensions'
- resp, body = self.get(url, self.headers)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def is_enabled(self, extension):
- _, extensions = self.list_extensions()
- exts = extensions['extensions']
- return any([e for e in exts if e['name'] == extension])
-
- def get_extension(self, extension_alias):
- resp, body = self.get('extensions/%s' % extension_alias, self.headers)
- body = xml_to_json(etree.fromstring(body))
- return resp, body
diff --git a/tempest/services/compute/v3/xml/flavors_client.py b/tempest/services/compute/v3/xml/flavors_client.py
deleted file mode 100644
index f568488..0000000
--- a/tempest/services/compute/v3/xml/flavors_client.py
+++ /dev/null
@@ -1,210 +0,0 @@
-# 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.
-
-import urllib
-
-from lxml import etree
-
-from tempest.common.rest_client import RestClientXML
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import 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_V3
-
-XMLNS_OS_FLV_ACCESS = \
- "http://docs.openstack.org/compute/core/flavor-access/api/v3"
-
-
-class FlavorsV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- 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': []}
- for k, v in f.items():
- if k == 'id':
- flavor['id'] = v
- continue
-
- if k == 'link':
- flavor['links'].append(v)
- continue
-
- if k == '{%s}is_public' % XMLNS_OS_FLV_ACCESS:
- k = 'flavor-access:is_public'
- v = True if v == 'True' else False
-
- if k == 'extra_specs':
- k = 'flavor-extra-specs:extra_specs'
- flavor[k] = dict(v)
- continue
-
- try:
- v = int(v)
- except ValueError:
- try:
- v = float(v)
- except ValueError:
- pass
-
- flavor[k] = v
-
- return flavor
-
- def _parse_array(self, node):
- return [self._format_flavor(xml_to_json(x)) for x in node]
-
- def _list_flavors(self, url, params):
- if params:
- url += "?%s" % urllib.urlencode(params)
-
- resp, body = self.get(url, self.headers)
- flavors = self._parse_array(etree.fromstring(body))
- return resp, flavors
-
- def list_flavors(self, params=None):
- url = 'flavors'
- return self._list_flavors(url, params)
-
- def list_flavors_with_detail(self, params=None):
- url = 'flavors/detail'
- return self._list_flavors(url, params)
-
- def get_flavor_details(self, flavor_id):
- resp, body = self.get("flavors/%s" % str(flavor_id), self.headers)
- body = xml_to_json(etree.fromstring(body))
- flavor = self._format_flavor(body)
- return resp, flavor
-
- def create_flavor(self, name, ram, vcpus, disk, flavor_id, **kwargs):
- """Creates a new flavor or instance type."""
- flavor = Element("flavor",
- xmlns=XMLNS_V3,
- ram=ram,
- vcpus=vcpus,
- disk=disk,
- id=flavor_id,
- name=name)
- if kwargs.get('rxtx'):
- flavor.add_attr('rxtx_factor', kwargs.get('rxtx'))
- if kwargs.get('swap'):
- flavor.add_attr('swap', kwargs.get('swap'))
- if kwargs.get('ephemeral'):
- flavor.add_attr('ephemeral', kwargs.get('ephemeral'))
- if kwargs.get('is_public'):
- flavor.add_attr('flavor-access:is_public',
- kwargs.get('is_public'))
- 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)
- return resp, flavor
-
- def delete_flavor(self, flavor_id):
- """Deletes the given flavor."""
- return self.delete("flavors/%s" % str(flavor_id), self.headers)
-
- def is_resource_deleted(self, id):
- # Did not use get_flavor_details(id) for verification as it gives
- # 200 ok even for deleted id. LP #981263
- # we can remove the loop here and use get by ID when bug gets sortedout
- resp, flavors = self.list_flavors_with_detail()
- for flavor in flavors:
- if flavor['id'] == id:
- return False
- return True
-
- def set_flavor_extra_spec(self, flavor_id, specs):
- """Sets extra Specs to the mentioned flavor."""
- extra_specs = Element("extra_specs")
- for key in specs.keys():
- extra_specs.add_attr(key, specs[key])
- 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/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/flavor-extra-specs/%s' %
- (str(flavor_id), key), self.headers)
- body = {}
- element = etree.fromstring(xml_body)
- key = element.get('key')
- body[key] = xml_to_json(element)
- return resp, body
-
- def update_flavor_extra_spec(self, flavor_id, key, **kwargs):
- """Update extra Specs details of the mentioned flavor and key."""
- doc = Document()
- for (k, v) in kwargs.items():
- element = Element(k)
- doc.append(element)
- value = Text(v)
- element.append(value)
-
- resp, body = self.put('flavors/%s/flavor-extra-specs/%s' %
- (flavor_id, key),
- str(doc), self.headers)
- body = xml_to_json(etree.fromstring(body))
- return resp, {key: body}
-
- 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/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/flavor-access' % str(flavor_id),
- self.headers)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def add_flavor_access(self, flavor_id, tenant_id):
- """Add flavor access for the specified tenant."""
- doc = Document()
- server = Element("add_tenant_access")
- doc.append(server)
- 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))
- return resp, body
-
- def remove_flavor_access(self, flavor_id, tenant_id):
- """Remove flavor access from the specified tenant."""
- doc = Document()
- server = Element("remove_tenant_access")
- doc.append(server)
- 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))
- return resp, body
diff --git a/tempest/services/compute/v3/xml/hosts_client.py b/tempest/services/compute/v3/xml/hosts_client.py
deleted file mode 100644
index 2951928..0000000
--- a/tempest/services/compute/v3/xml/hosts_client.py
+++ /dev/null
@@ -1,90 +0,0 @@
-# Copyright 2013 IBM Corp.
-#
-# 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 urllib
-
-from lxml import etree
-from tempest.common.rest_client import RestClientXML
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import xml_to_json
-
-
-class HostsV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(HostsV3ClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def list_hosts(self, params=None):
- """Lists all hosts."""
-
- url = 'os-hosts'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url, self.headers)
- node = etree.fromstring(body)
- body = [xml_to_json(x) for x in node.getchildren()]
- return resp, body
-
- def show_host_detail(self, hostname):
- """Show detail information for the host."""
-
- resp, body = self.get("os-hosts/%s" % str(hostname), self.headers)
- node = etree.fromstring(body)
- body = [xml_to_json(node)]
- return resp, body
-
- def update_host(self, hostname, **kwargs):
- """Update a host."""
-
- request_body = Element("host")
- if kwargs:
- 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)
- node = etree.fromstring(body)
- body = [xml_to_json(x) for x in node.getchildren()]
- return resp, body
-
- def startup_host(self, hostname):
- """Startup a host."""
-
- resp, body = self.get("os-hosts/%s/startup" % str(hostname),
- self.headers)
- node = etree.fromstring(body)
- body = [xml_to_json(x) for x in node.getchildren()]
- return resp, body
-
- def shutdown_host(self, hostname):
- """Shutdown a host."""
-
- resp, body = self.get("os-hosts/%s/shutdown" % str(hostname),
- self.headers)
- node = etree.fromstring(body)
- body = [xml_to_json(x) for x in node.getchildren()]
- return resp, body
-
- def reboot_host(self, hostname):
- """Reboot a host."""
-
- resp, body = self.get("os-hosts/%s/reboot" % str(hostname),
- self.headers)
- node = etree.fromstring(body)
- body = [xml_to_json(x) for x in node.getchildren()]
- return resp, body
diff --git a/tempest/services/compute/v3/xml/hypervisor_client.py b/tempest/services/compute/v3/xml/hypervisor_client.py
deleted file mode 100644
index 2f232ab..0000000
--- a/tempest/services/compute/v3/xml/hypervisor_client.py
+++ /dev/null
@@ -1,77 +0,0 @@
-# Copyright 2013 IBM Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common.rest_client import RestClientXML
-from tempest.services.compute.xml.common import xml_to_json
-
-
-class HypervisorV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(HypervisorV3ClientXML, self).__init__(config, username,
- password, auth_url,
- tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def _parse_array(self, node):
- return [xml_to_json(x) for x in node]
-
- def get_hypervisor_list(self):
- """List hypervisors information."""
- resp, body = self.get('os-hypervisors', self.headers)
- hypervisors = self._parse_array(etree.fromstring(body))
- return resp, hypervisors
-
- def get_hypervisor_list_details(self):
- """Show detailed hypervisors information."""
- resp, body = self.get('os-hypervisors/detail', self.headers)
- hypervisors = self._parse_array(etree.fromstring(body))
- return resp, hypervisors
-
- def get_hypervisor_show_details(self, hyper_id):
- """Display the details of the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s' % hyper_id,
- self.headers)
- hypervisor = xml_to_json(etree.fromstring(body))
- return resp, hypervisor
-
- def get_hypervisor_servers(self, hyper_name):
- """List instances belonging to the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/servers' % hyper_name,
- self.headers)
- hypervisors = self._parse_array(etree.fromstring(body))
- return resp, hypervisors
-
- def get_hypervisor_stats(self):
- """Get hypervisor statistics over all compute nodes."""
- resp, body = self.get('os-hypervisors/statistics', self.headers)
- stats = xml_to_json(etree.fromstring(body))
- return resp, stats
-
- def get_hypervisor_uptime(self, hyper_id):
- """Display the uptime of the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/uptime' % hyper_id,
- self.headers)
- uptime = xml_to_json(etree.fromstring(body))
- return resp, uptime
-
- def search_hypervisor(self, hyper_name):
- """Search specified hypervisor."""
- resp, body = self.get('os-hypervisors/search?query=%s' % hyper_name,
- self.headers)
- hypervisors = self._parse_array(etree.fromstring(body))
- return resp, hypervisors
diff --git a/tempest/services/compute/v3/xml/instance_usage_audit_log_client.py b/tempest/services/compute/v3/xml/instance_usage_audit_log_client.py
deleted file mode 100644
index ed6f36e..0000000
--- a/tempest/services/compute/v3/xml/instance_usage_audit_log_client.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright 2013 IBM Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common.rest_client import RestClientXML
-from tempest.services.compute.xml.common import xml_to_json
-
-
-class InstanceUsagesAuditLogV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(InstanceUsagesAuditLogV3ClientXML, self).__init__(
- config, username, password, auth_url, tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def list_instance_usage_audit_logs(self, time_before=None):
- if time_before:
- url = 'os-instance-usage-audit-log?before=%s' % time_before
- else:
- url = 'os-instance-usage-audit-log'
- resp, body = self.get(url, self.headers)
- instance_usage_audit_logs = xml_to_json(etree.fromstring(body))
- return resp, instance_usage_audit_logs
diff --git a/tempest/services/compute/v3/xml/interfaces_client.py b/tempest/services/compute/v3/xml/interfaces_client.py
deleted file mode 100644
index 870c130..0000000
--- a/tempest/services/compute/v3/xml/interfaces_client.py
+++ /dev/null
@@ -1,108 +0,0 @@
-# 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 time
-
-from lxml import etree
-
-from tempest.common.rest_client import RestClientXML
-from tempest import exceptions
-from tempest.services.compute.xml.common import Document
-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
-
-
-class InterfacesV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(InterfacesV3ClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def _process_xml_interface(self, node):
- iface = xml_to_json(node)
- # NOTE(danms): if multiple addresses per interface is ever required,
- # xml_to_json will need to be fixed or replaced in this case
- iface['fixed_ips'] = [dict(iface['fixed_ips']['fixed_ip'].items())]
- return iface
-
- def list_interfaces(self, server):
- resp, body = self.get('servers/%s/os-attach-interfaces' % server,
- self.headers)
- node = etree.fromstring(body)
- interfaces = [self._process_xml_interface(x)
- for x in node.getchildren()]
- return resp, interfaces
-
- def create_interface(self, server, port_id=None, network_id=None,
- fixed_ip=None):
- doc = Document()
- iface = Element('interface_attachment')
- if port_id:
- _port_id = Element('port_id')
- _port_id.append(Text(port_id))
- iface.append(_port_id)
- if network_id:
- _network_id = Element('net_id')
- _network_id.append(Text(network_id))
- iface.append(_network_id)
- if fixed_ip:
- _fixed_ips = Element('fixed_ips')
- _fixed_ip = Element('fixed_ip')
- _ip_address = Element('ip_address')
- _ip_address.append(Text(fixed_ip))
- _fixed_ip.append(_ip_address)
- _fixed_ips.append(_fixed_ip)
- iface.append(_fixed_ips)
- doc.append(iface)
- resp, body = self.post('servers/%s/os-attach-interfaces' % server,
- headers=self.headers,
- body=str(doc))
- body = self._process_xml_interface(etree.fromstring(body))
- return resp, body
-
- def show_interface(self, server, port_id):
- resp, body =\
- self.get('servers/%s/os-attach-interfaces/%s' % (server, port_id),
- self.headers)
- body = self._process_xml_interface(etree.fromstring(body))
- return resp, body
-
- def delete_interface(self, server, port_id):
- resp, body =\
- self.delete('servers/%s/os-attach-interfaces/%s' % (server,
- port_id))
- return resp, body
-
- def wait_for_interface_status(self, server, port_id, status):
- """Waits for a interface to reach a given status."""
- resp, body = self.show_interface(server, port_id)
- interface_status = body['port_state']
- start = int(time.time())
-
- while(interface_status != status):
- time.sleep(self.build_interval)
- resp, body = self.show_interface(server, port_id)
- interface_status = body['port_state']
-
- timed_out = int(time.time()) - start >= self.build_timeout
-
- if interface_status != status and timed_out:
- message = ('Interface %s failed to reach %s status within '
- 'the required time (%s s).' %
- (port_id, status, self.build_timeout))
- raise exceptions.TimeoutException(message)
- return resp, body
diff --git a/tempest/services/compute/v3/xml/keypairs_client.py b/tempest/services/compute/v3/xml/keypairs_client.py
deleted file mode 100644
index 6efb7fe..0000000
--- a/tempest/services/compute/v3/xml/keypairs_client.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# Copyright 2012 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 lxml import etree
-from tempest.common.rest_client import RestClientXML
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import Text
-from tempest.services.compute.xml.common import xml_to_json
-
-
-class KeyPairsV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- 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("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("keypairs/%s" % str(key_name), self.headers)
- body = xml_to_json(etree.fromstring(body))
- return resp, body
-
- def create_keypair(self, name, pub_key=None):
- doc = Document()
-
- keypair_element = Element("keypair")
-
- if pub_key:
- public_key_element = Element("public_key")
- public_key_text = Text(pub_key)
- public_key_element.append(public_key_text)
- keypair_element.append(public_key_element)
-
- name_element = Element("name")
- name_text = Text(name)
- name_element.append(name_text)
- keypair_element.append(name_element)
-
- doc.append(keypair_element)
-
- 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("keypairs/%s" % str(key_name))
diff --git a/tempest/services/compute/v3/xml/quotas_client.py b/tempest/services/compute/v3/xml/quotas_client.py
deleted file mode 100644
index 145c6e8..0000000
--- a/tempest/services/compute/v3/xml/quotas_client.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# Copyright 2012 NTT Data
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common.rest_client import RestClientXML
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import xml_to_json
-from tempest.services.compute.xml.common import XMLNS_V3
-
-
-class QuotasV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(QuotasV3ClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def _format_quota(self, q):
- quota = {}
- for k, v in q.items():
- try:
- v = int(v)
- except ValueError:
- pass
-
- quota[k] = v
-
- return quota
-
- def _parse_array(self, node):
- return [self._format_quota(xml_to_json(x)) for x in node]
-
- def get_quota_set(self, tenant_id):
- """List the quota set for a tenant."""
-
- url = 'os-quota-sets/%s' % str(tenant_id)
- resp, body = self.get(url, self.headers)
- body = xml_to_json(etree.fromstring(body))
- body = self._format_quota(body)
- return resp, body
-
- def get_default_quota_set(self, tenant_id):
- """List the default quota set for a tenant."""
-
- url = 'os-quota-sets/%s/defaults' % str(tenant_id)
- resp, body = self.get(url, self.headers)
- body = xml_to_json(etree.fromstring(body))
- body = self._format_quota(body)
- return resp, body
-
- def update_quota_set(self, tenant_id, force=None,
- metadata_items=None, ram=None, floating_ips=None,
- fixed_ips=None, key_pairs=None, instances=None,
- security_group_rules=None, cores=None,
- security_groups=None):
- """
- Updates the tenant's quota limits for one or more resources
- """
- post_body = Element("quota_set",
- xmlns=XMLNS_V3)
-
- if force is not None:
- post_body.add_attr('force', force)
-
- if metadata_items is not None:
- post_body.add_attr('metadata_items', metadata_items)
-
- if ram is not None:
- post_body.add_attr('ram', ram)
-
- if floating_ips is not None:
- post_body.add_attr('floating_ips', floating_ips)
-
- if fixed_ips is not None:
- post_body.add_attr('fixed_ips', fixed_ips)
-
- if key_pairs is not None:
- post_body.add_attr('key_pairs', key_pairs)
-
- if instances is not None:
- post_body.add_attr('instances', instances)
-
- if security_group_rules is not None:
- post_body.add_attr('security_group_rules', security_group_rules)
-
- if cores is not None:
- post_body.add_attr('cores', cores)
-
- if security_groups is not None:
- post_body.add_attr('security_groups', security_groups)
-
- resp, body = self.put('os-quota-sets/%s' % str(tenant_id),
- str(Document(post_body)),
- self.headers)
- body = xml_to_json(etree.fromstring(body))
- body = self._format_quota(body)
- return resp, body
diff --git a/tempest/services/compute/v3/xml/servers_client.py b/tempest/services/compute/v3/xml/servers_client.py
deleted file mode 100644
index 240c962..0000000
--- a/tempest/services/compute/v3/xml/servers_client.py
+++ /dev/null
@@ -1,663 +0,0 @@
-# Copyright 2012 IBM Corp.
-# Copyright 2013 Hewlett-Packard Development Company, L.P.
-# 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 time
-import urllib
-
-from lxml import etree
-
-from tempest.common.rest_client import RestClientXML
-from tempest.common import waiters
-from tempest import exceptions
-from tempest.openstack.common import log as logging
-from tempest.services.compute.xml.common import Document
-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_V3
-
-
-LOG = logging.getLogger(__name__)
-
-
-def _translate_ip_xml_json(ip):
- """
- Convert the address version to int.
- """
- ip = dict(ip)
- version = ip.get('version')
- if version:
- ip['version'] = int(version)
- if ip.get('type'):
- ip['type'] = ip.get('type')
- if ip.get('mac_addr'):
- ip['mac_addr'] = ip.get('mac_addr')
- return ip
-
-
-def _translate_network_xml_to_json(network):
- return [_translate_ip_xml_json(ip.attrib)
- for ip in network.findall('{%s}ip' % XMLNS_V3)]
-
-
-def _translate_addresses_xml_to_json(xml_addresses):
- return dict((network.attrib['id'], _translate_network_xml_to_json(network))
- for network in xml_addresses.findall('{%s}network' % XMLNS_V3))
-
-
-def _translate_server_xml_to_json(xml_dom):
- """Convert server XML to server JSON.
-
- The addresses collection does not convert well by the dumb xml_to_json.
- This method does some pre and post-processing to deal with that.
-
- Translate XML addresses subtree to JSON.
-
- Having xml_doc similar to
- <api:server xmlns:api="http://docs.openstack.org/compute/api/v3">
- <api:addresses>
- <api:network id="foo_novanetwork">
- <api:ip version="4" addr="192.168.0.4"/>
- </api:network>
- <api:network id="bar_novanetwork">
- <api:ip version="4" addr="10.1.0.4"/>
- <api:ip version="6" addr="2001:0:0:1:2:3:4:5"/>
- </api:network>
- </api:addresses>
- </api:server>
-
- the _translate_server_xml_to_json(etree.fromstring(xml_doc)) should produce
- something like
-
- {'addresses': {'bar_novanetwork': [{'addr': '10.1.0.4', 'version': 4},
- {'addr': '2001:0:0:1:2:3:4:5',
- 'version': 6}],
- 'foo_novanetwork': [{'addr': '192.168.0.4', 'version': 4}]}}
- """
- nsmap = {'api': XMLNS_V3}
- addresses = xml_dom.xpath('/api:server/api:addresses', namespaces=nsmap)
- if addresses:
- if len(addresses) > 1:
- raise ValueError('Expected only single `addresses` element.')
- json_addresses = _translate_addresses_xml_to_json(addresses[0])
- json = xml_to_json(xml_dom)
- json['addresses'] = json_addresses
- else:
- json = xml_to_json(xml_dom)
- disk_config = ('{http://docs.openstack.org'
- '/compute/ext/disk_config/api/v3}disk_config')
- terminated_at = ('{http://docs.openstack.org/'
- 'compute/ext/os-server-usage/api/v3}terminated_at')
- launched_at = ('{http://docs.openstack.org'
- '/compute/ext/os-server-usage/api/v3}launched_at')
- power_state = ('{http://docs.openstack.org'
- '/compute/ext/extended_status/api/v3}power_state')
- availability_zone = ('{http://docs.openstack.org'
- '/compute/ext/extended_availability_zone/api/v3}'
- 'availability_zone')
- vm_state = ('{http://docs.openstack.org'
- '/compute/ext/extended_status/api/v3}vm_state')
- task_state = ('{http://docs.openstack.org'
- '/compute/ext/extended_status/api/v3}task_state')
- access_ip_v4 = ('{http://docs.openstack.org/compute/ext/'
- 'os-access-ips/api/v3}access_ip_v4')
- access_ip_v6 = ('{http://docs.openstack.org/compute/ext/'
- 'os-access-ips/api/v3}access_ip_v6')
- if disk_config in json:
- json['os-disk-config:disk_config'] = json.pop(disk_config)
- if terminated_at in json:
- json['os-server-usage:terminated_at'] = json.pop(terminated_at)
- if launched_at in json:
- json['os-server-usage:launched_at'] = json.pop(launched_at)
- if power_state in json:
- json['os-extended-status:power_state'] = json.pop(power_state)
- if availability_zone in json:
- json['os-extended-availability-zone:availability_zone'] = json.pop(
- availability_zone)
- if vm_state in json:
- json['os-extended-status:vm_state'] = json.pop(vm_state)
- if task_state in json:
- json['os-extended-status:task_state'] = json.pop(task_state)
- if access_ip_v4 in json:
- json['os-access-ips:access_ip_v4'] = json.pop(access_ip_v4)
- if access_ip_v6 in json:
- json['os-access-ips:access_ip_v6'] = json.pop(access_ip_v6)
- return json
-
-
-class ServersV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url,
- tenant_name=None, auth_version='v2'):
- super(ServersV3ClientXML, self).__init__(config, username, password,
- auth_url, tenant_name,
- auth_version=auth_version)
- self.service = self.config.compute.catalog_v3_type
-
- def _parse_key_value(self, node):
- """Parse <foo key='key'>value</foo> data into {'key': 'value'}."""
- data = {}
- for node in node.getchildren():
- data[node.get('key')] = node.text
- return data
-
- def _parse_links(self, node, json):
- del json['link']
- json['links'] = []
- for linknode in node.findall('{http://www.w3.org/2005/Atom}link'):
- json['links'].append(xml_to_json(linknode))
-
- def _parse_server(self, body):
- json = _translate_server_xml_to_json(body)
-
- if 'metadata' in json and json['metadata']:
- # NOTE(danms): if there was metadata, we need to re-parse
- # that as a special type
- metadata_tag = body.find('{%s}metadata' % XMLNS_V3)
- json["metadata"] = self._parse_key_value(metadata_tag)
- if 'link' in json:
- self._parse_links(body, json)
- for sub in ['image', 'flavor']:
- if sub in json and 'link' in json[sub]:
- self._parse_links(body, json[sub])
- return json
-
- def _parse_xml_virtual_interfaces(self, xml_dom):
- """
- Return server's virtual interfaces XML as JSON.
- """
- data = {"virtual_interfaces": []}
- for iface in xml_dom.getchildren():
- data["virtual_interfaces"].append(
- {"id": iface.get("id"),
- "mac_address": iface.get("mac_address")})
- return data
-
- def get_server(self, server_id):
- """Returns the details of an existing server."""
- resp, body = self.get("servers/%s" % str(server_id), self.headers)
- server = self._parse_server(etree.fromstring(body))
- return resp, server
-
- def migrate_server(self, server_id, **kwargs):
- """Migrates the given server ."""
- return self.action(server_id, 'migrate', None, **kwargs)
-
- def lock_server(self, server_id, **kwargs):
- """Locks the given server."""
- return self.action(server_id, 'lock', None, **kwargs)
-
- def unlock_server(self, server_id, **kwargs):
- """Unlocks the given server."""
- return self.action(server_id, 'unlock', None, **kwargs)
-
- def suspend_server(self, server_id, **kwargs):
- """Suspends the provided server."""
- return self.action(server_id, 'suspend', None, **kwargs)
-
- def resume_server(self, server_id, **kwargs):
- """Un-suspends the provided server."""
- return self.action(server_id, 'resume', None, **kwargs)
-
- def pause_server(self, server_id, **kwargs):
- """Pauses the provided server."""
- return self.action(server_id, 'pause', None, **kwargs)
-
- def unpause_server(self, server_id, **kwargs):
- """Un-pauses the provided server."""
- return self.action(server_id, 'unpause', None, **kwargs)
-
- def reset_state(self, server_id, state='error'):
- """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))
-
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- array.append(xml_to_json(child))
- return array
-
- def list_servers(self, params=None):
- url = 'servers'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url, self.headers)
- servers = self._parse_array(etree.fromstring(body))
- return resp, {"servers": servers}
-
- def list_servers_with_detail(self, params=None):
- url = 'servers/detail'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url, self.headers)
- servers = self._parse_array(etree.fromstring(body))
- return resp, {"servers": servers}
-
- def update_server(self, server_id, name=None, meta=None, access_ip_v4=None,
- access_ip_v6=None, disk_config=None):
- doc = Document()
- server = Element("server")
- doc.append(server)
-
- if name is not None:
- server.add_attr("name", name)
- if access_ip_v4 or access_ip_v6:
- server.add_attr('xmlns:os-access-ips',
- "http://docs.openstack.org/compute/ext/"
- "os-access-ips/api/v3")
- if access_ip_v4 is not None:
- server.add_attr("os-access-ips:access_ip_v4", access_ip_v4)
- if access_ip_v6 is not None:
- server.add_attr("os-access-ips:access_ip_v6", access_ip_v6)
- if disk_config is not None:
- server.add_attr('xmlns:os-disk-config', "http://docs.openstack.org"
- "/compute/ext/disk_config/api/v3")
- server.add_attr("os-disk-config:disk_config", disk_config)
- if meta is not None:
- metadata = Element("metadata")
- server.append(metadata)
- for k, v in meta:
- meta = Element("meta", key=k)
- meta.append(Text(v))
- metadata.append(meta)
-
- resp, body = self.put('servers/%s' % str(server_id),
- str(doc), self.headers)
- return resp, xml_to_json(etree.fromstring(body))
-
- def create_server(self, name, image_ref, flavor_ref, **kwargs):
- """
- Creates an instance of a server.
- name (Required): The name of the server.
- image_ref (Required): Reference to the image used to build the server.
- flavor_ref (Required): The flavor used to build the server.
- Following optional keyword arguments are accepted:
- admin_password: Sets the initial root password.
- key_name: Key name of keypair that was created earlier.
- meta: A dictionary of values to be used as metadata.
- security_groups: A list of security group dicts.
- networks: A list of network dicts with UUID and fixed_ip.
- user_data: User data for instance.
- availability_zone: Availability zone in which to launch instance.
- access_ip_v4: The IPv4 access address for the server.
- access_ip_v6: The IPv6 access address for the server.
- min_count: Count of minimum number of instances to launch.
- max_count: Count of maximum number of instances to launch.
- disk_config: Determines if user or admin controls disk configuration.
- return_reservation_id: Enable/Disable the return of reservation id.
- """
- server = Element("server",
- xmlns=XMLNS_V3,
- flavor_ref=flavor_ref,
- image_ref=image_ref,
- name=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',
- "http://docs.openstack.org/compute/ext/userdata/api/v3"),
- ("os-availability-zone:availability_zone",
- 'availability_zone',
- 'xmlns:os-availability-zone',
- "http://docs.openstack.org/compute/ext/"
- "availabilityzone/api/v3"),
- ("os-multiple-create:min_count",
- 'min_count',
- 'xmlns:os-multiple-create',
- "http://docs.openstack.org/compute/ext/"
- "multiplecreate/api/v3"),
- ("os-multiple-create:max_count",
- 'max_count',
- 'xmlns:os-multiple-create',
- "http://docs.openstack.org/compute/ext/"
- "multiplecreate/api/v3"),
- ("os-multiple-create:return_reservation_id",
- "return_reservation_id",
- 'xmlns:os-multiple-create',
- "http://docs.openstack.org/compute/ext/"
- "multiplecreate/api/v3"),
- ("os-disk-config:disk_config",
- "disk_config",
- "xmlns:os-disk-config",
- "http://docs.openstack.org/"
- "compute/ext/disk_config/api/v3")]
-
- for attr in attrs:
- if isinstance(attr, tuple):
- post_param = attr[0]
- key = attr[1]
- value = kwargs.get(key)
- if value is not None:
- server.add_attr(attr[2], attr[3])
- server.add_attr(post_param, value)
- else:
- post_param = attr
- key = attr
- value = kwargs.get(key)
- if value is not None:
- server.add_attr(post_param, value)
-
- if 'security_groups' in kwargs:
- 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'])
- secgroups.append(s)
-
- if 'networks' in kwargs:
- networks = Element("networks")
- server.append(networks)
- for network in kwargs['networks']:
- s = Element("network", uuid=network['uuid'],
- fixed_ip=network['fixed_ip'])
- networks.append(s)
-
- if 'meta' in kwargs:
- metadata = Element("metadata")
- server.append(metadata)
- for k, v in kwargs['meta'].items():
- meta = Element("meta", key=k)
- meta.append(Text(v))
- metadata.append(meta)
-
- resp, body = self.post('servers', str(Document(server)), self.headers)
- server = self._parse_server(etree.fromstring(body))
- return resp, server
-
- def wait_for_server_status(self, server_id, status, extra_timeout=0,
- raise_on_error=True):
- """Waits for a server to reach a given status."""
- return waiters.wait_for_server_status(self, server_id, status,
- extra_timeout=extra_timeout,
- raise_on_error=raise_on_error)
-
- def wait_for_server_termination(self, server_id, ignore_error=False):
- """Waits for server to reach termination."""
- start_time = int(time.time())
- while True:
- try:
- resp, body = self.get_server(server_id)
- except exceptions.NotFound:
- return
-
- server_status = body['status']
- if server_status == 'ERROR' and not ignore_error:
- raise exceptions.BuildErrorException
-
- if int(time.time()) - start_time >= self.build_timeout:
- raise exceptions.TimeoutException
-
- time.sleep(self.build_interval)
-
- def _parse_network(self, node):
- addrs = []
- for child in node.getchildren():
- addrs.append({'version': int(child.get('version')),
- 'addr': child.get('addr')})
- return {node.get('id'): addrs}
-
- def list_addresses(self, server_id):
- """Lists all addresses for a server."""
- resp, body = self.get("servers/%s/ips" % str(server_id), self.headers)
-
- networks = {}
- xml_list = etree.fromstring(body)
- for child in xml_list.getchildren():
- network = self._parse_network(child)
- networks.update(**network)
-
- return resp, networks
-
- def list_addresses_by_network(self, server_id, network_id):
- """Lists all addresses of a specific network type for a server."""
- resp, body = self.get("servers/%s/ips/%s" % (str(server_id),
- network_id),
- self.headers)
- network = self._parse_network(etree.fromstring(body))
-
- return resp, network
-
- def action(self, server_id, action_name, response_key, **kwargs):
- if 'xmlns' not in kwargs:
- kwargs['xmlns'] = XMLNS_V3
- doc = Document((Element(action_name, **kwargs)))
- resp, body = self.post("servers/%s/action" % server_id,
- str(doc), self.headers)
- if response_key is not None:
- 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)
-
- def reboot(self, server_id, reboot_type):
- return self.action(server_id, "reboot", None, type=reboot_type)
-
- def rebuild(self, server_id, image_ref, **kwargs):
- kwargs['image_ref'] = image_ref
- if 'disk_config' in kwargs:
- kwargs['os-disk-config:disk_config'] = kwargs['disk_config']
- del kwargs['disk_config']
- kwargs['xmlns:os-disk-config'] = "http://docs.openstack.org/"\
- "compute/ext/disk_config/api/v3"
- kwargs['xmlns:atom'] = "http://www.w3.org/2005/Atom"
- if 'xmlns' not in kwargs:
- kwargs['xmlns'] = XMLNS_V3
-
- attrs = kwargs.copy()
- if 'metadata' in attrs:
- del attrs['metadata']
- rebuild = Element("rebuild",
- **attrs)
-
- if 'metadata' in kwargs:
- metadata = Element("metadata")
- rebuild.append(metadata)
- for k, v in kwargs['metadata'].items():
- meta = Element("meta", key=k)
- meta.append(Text(v))
- metadata.append(meta)
-
- resp, body = self.post('servers/%s/action' % server_id,
- str(Document(rebuild)), self.headers)
- server = self._parse_server(etree.fromstring(body))
- return resp, server
-
- def resize(self, server_id, flavor_ref, **kwargs):
- if 'disk_config' in kwargs:
- kwargs['os-disk-config:disk_config'] = kwargs['disk_config']
- del kwargs['disk_config']
- kwargs['xmlns:os-disk-config'] = "http://docs.openstack.org/"\
- "compute/ext/disk_config/api/v3"
- kwargs['xmlns:atom'] = "http://www.w3.org/2005/Atom"
- kwargs['flavor_ref'] = flavor_ref
- return self.action(server_id, 'resize', None, **kwargs)
-
- def confirm_resize(self, server_id, **kwargs):
- return self.action(server_id, 'confirm_resize', None, **kwargs)
-
- def revert_resize(self, server_id, **kwargs):
- return self.action(server_id, 'revert_resize', None, **kwargs)
-
- def stop(self, server_id, **kwargs):
- return self.action(server_id, 'stop', None, **kwargs)
-
- def start(self, server_id, **kwargs):
- return self.action(server_id, 'start', None, **kwargs)
-
- def create_image(self, server_id, name, meta=None):
- """Creates an image of the original server."""
- post_body = Element('create_image', name=name)
-
- if meta:
- metadata = Element('metadata')
- post_body.append(metadata)
- for k, v in meta.items():
- data = Element('meta', key=k)
- data.append(Text(v))
- metadata.append(data)
- resp, body = self.post('servers/%s/action' % str(server_id),
- str(Document(post_body)), self.headers)
- return resp, body
-
- def live_migrate_server(self, server_id, dest_host, use_block_migration):
- """This should be called with administrator privileges ."""
-
- req_body = Element("migrate_live",
- xmlns=XMLNS_V3,
- disk_over_commit=False,
- block_migration=use_block_migration,
- host=dest_host)
-
- resp, body = self.post("servers/%s/action" % str(server_id),
- str(Document(req_body)), self.headers)
- return resp, body
-
- def list_server_metadata(self, server_id):
- resp, body = self.get("servers/%s/metadata" % str(server_id),
- self.headers)
- body = self._parse_key_value(etree.fromstring(body))
- return resp, body
-
- def set_server_metadata(self, server_id, meta, no_metadata_field=False):
- doc = Document()
- if not no_metadata_field:
- metadata = Element("metadata")
- doc.append(metadata)
- for k, v in meta.items():
- meta_element = Element("meta", key=k)
- meta_element.append(Text(v))
- metadata.append(meta_element)
- resp, body = self.put('servers/%s/metadata' % str(server_id),
- str(doc), self.headers)
- return resp, xml_to_json(etree.fromstring(body))
-
- def update_server_metadata(self, server_id, meta):
- doc = Document()
- metadata = Element("metadata")
- doc.append(metadata)
- for k, v in meta.items():
- meta_element = Element("meta", key=k)
- meta_element.append(Text(v))
- metadata.append(meta_element)
- resp, body = self.post("/servers/%s/metadata" % str(server_id),
- str(doc), headers=self.headers)
- body = xml_to_json(etree.fromstring(body))
- return resp, body
-
- def get_server_metadata_item(self, server_id, key):
- resp, body = self.get("servers/%s/metadata/%s" % (str(server_id), key),
- headers=self.headers)
- return resp, dict([(etree.fromstring(body).attrib['key'],
- xml_to_json(etree.fromstring(body)))])
-
- def set_server_metadata_item(self, server_id, key, meta):
- doc = Document()
- for k, v in meta.items():
- meta_element = Element("metadata", key=k)
- meta_element.append(Text(v))
- doc.append(meta_element)
- resp, body = self.put('servers/%s/metadata/%s' % (str(server_id), key),
- str(doc), self.headers)
- return resp, xml_to_json(etree.fromstring(body))
-
- def delete_server_metadata_item(self, server_id, key):
- resp, body = self.delete("servers/%s/metadata/%s" %
- (str(server_id), key))
- return resp, body
-
- def get_console_output(self, server_id, length):
- return self.action(server_id, 'get_console_output', 'output',
- length=length)
-
- def rescue_server(self, server_id, **kwargs):
- """Rescue the provided server."""
- return self.action(server_id, 'rescue', None, **kwargs)
-
- def unrescue_server(self, server_id):
- """Unrescue the provided server."""
- return self.action(server_id, 'unrescue', None)
-
- def attach_volume(self, server_id, volume_id, device='/dev/vdz'):
- return self.action(server_id, "attach", None, volume_id=volume_id,
- device=device)
-
- def detach_volume(self, server_id, volume_id):
- return self.action(server_id, "detach", None, volume_id=volume_id)
-
- def get_server_diagnostics(self, server_id):
- """Get the usage data for a server."""
- resp, body = self.get("servers/%s/os-server-diagnostics" % server_id,
- self.headers)
- body = xml_to_json(etree.fromstring(body))
- return resp, body
-
- def list_instance_actions(self, server_id):
- """List the provided server action."""
- resp, body = self.get("servers/%s/os-instance-actions" % server_id,
- self.headers)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def get_instance_action(self, server_id, request_id):
- """Returns the action details of the provided server."""
- resp, body = self.get("servers/%s/os-instance-actions/%s" %
- (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/v3/xml/services_client.py b/tempest/services/compute/v3/xml/services_client.py
deleted file mode 100644
index 749a812..0000000
--- a/tempest/services/compute/v3/xml/services_client.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# 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.
-
-import urllib
-
-from lxml import etree
-from tempest.common.rest_client import RestClientXML
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import xml_to_json
-
-
-class ServicesV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(ServicesV3ClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def list_services(self, params=None):
- url = 'os-services'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url, self.headers)
- node = etree.fromstring(body)
- body = [xml_to_json(x) for x in node.getchildren()]
- return resp, body
-
- def enable_service(self, host_name, binary):
- """
- Enable service on a host
- host_name: Name of host
- binary: Service binary
- """
- post_body = Element("service")
- post_body.add_attr('binary', binary)
- post_body.add_attr('host', host_name)
-
- resp, body = self.put('os-services/enable', str(Document(post_body)),
- self.headers)
- body = xml_to_json(etree.fromstring(body))
- return resp, body
-
- def disable_service(self, host_name, binary):
- """
- Disable service on a host
- host_name: Name of host
- binary: Service binary
- """
- post_body = Element("service")
- post_body.add_attr('binary', binary)
- post_body.add_attr('host', host_name)
-
- resp, body = self.put('os-services/disable', str(Document(post_body)),
- self.headers)
- body = xml_to_json(etree.fromstring(body))
- return resp, body
diff --git a/tempest/services/compute/v3/xml/tenant_usages_client.py b/tempest/services/compute/v3/xml/tenant_usages_client.py
deleted file mode 100644
index 12b7655..0000000
--- a/tempest/services/compute/v3/xml/tenant_usages_client.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2013 NEC Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import urllib
-
-from lxml import etree
-
-from tempest.common.rest_client import RestClientXML
-from tempest.services.compute.xml.common import xml_to_json
-
-
-class TenantUsagesV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(TenantUsagesV3ClientXML, self).__init__(config, username,
- password, auth_url,
- tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def _parse_array(self, node):
- json = xml_to_json(node)
- return json
-
- def list_tenant_usages(self, params=None):
- url = 'os-simple-tenant-usage'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url, self.headers)
- tenant_usage = self._parse_array(etree.fromstring(body))
- return resp, tenant_usage['tenant_usage']
-
- def get_tenant_usage(self, tenant_id, params=None):
- url = 'os-simple-tenant-usage/%s' % tenant_id
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url, self.headers)
- tenant_usage = self._parse_array(etree.fromstring(body))
- return resp, tenant_usage
diff --git a/tempest/services/compute/v3/xml/version_client.py b/tempest/services/compute/v3/xml/version_client.py
deleted file mode 100644
index 7ecb31f..0000000
--- a/tempest/services/compute/v3/xml/version_client.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright 2014 NEC Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.services.compute.xml import common
-
-
-class VersionV3ClientXML(rest_client.RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(VersionV3ClientXML, self).__init__(config, username,
- password, auth_url,
- tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def _parse_array(self, node):
- json = common.xml_to_json(node)
- return json
-
- def get_version(self):
- resp, body = self.get('', self.headers)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index 8cb74a9..47c20d2 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -47,50 +47,8 @@
def serialize(self, data):
return json.dumps(data)
- def create_network(self, name, **kwargs):
- post_body = {'network': kwargs}
- post_body['network']['name'] = name
- body = json.dumps(post_body)
- uri = '%s/networks' % (self.uri_prefix)
- resp, body = self.post(uri, body)
- body = json.loads(body)
- return resp, body
-
- def create_bulk_network(self, count, names):
- network_list = list()
- for i in range(count):
- network_list.append({'name': names[i]})
- post_body = {'networks': network_list}
- body = json.dumps(post_body)
- uri = '%s/networks' % (self.uri_prefix)
- resp, body = self.post(uri, body)
- body = json.loads(body)
- return resp, body
-
- def create_subnet(self, net_uuid, cidr, ip_version=4, **kwargs):
- post_body = {'subnet': kwargs}
- post_body['subnet']['ip_version'] = ip_version
- post_body['subnet']['network_id'] = net_uuid
- post_body['subnet']['cidr'] = cidr
- body = json.dumps(post_body)
- uri = '%s/subnets' % (self.uri_prefix)
- resp, body = self.post(uri, body)
- body = json.loads(body)
- return resp, body
-
- def create_port(self, network_id, **kwargs):
- post_body = {
- 'port': {
- 'network_id': network_id,
- }
- }
- for key, val in kwargs.items():
- post_body['port'][key] = val
- body = json.dumps(post_body)
- uri = '%s/ports' % (self.uri_prefix)
- resp, body = self.post(uri, body)
- body = json.loads(body)
- return resp, body
+ def serialize_list(self, data, root=None, item=None):
+ return self.serialize(data)
def update_quotas(self, tenant_id, **kwargs):
put_body = {'quota': kwargs}
@@ -105,42 +63,6 @@
resp, body = self.delete(uri)
return resp, body
- def update_subnet(self, subnet_id, new_name):
- put_body = {
- 'subnet': {
- 'name': new_name,
- }
- }
- body = json.dumps(put_body)
- uri = '%s/subnets/%s' % (self.uri_prefix, subnet_id)
- resp, body = self.put(uri, body)
- body = json.loads(body)
- return resp, body
-
- def update_port(self, port_id, new_name):
- put_body = {
- 'port': {
- 'name': new_name,
- }
- }
- body = json.dumps(put_body)
- uri = '%s/ports/%s' % (self.uri_prefix, port_id)
- resp, body = self.put(uri, body)
- body = json.loads(body)
- return resp, body
-
- def update_network(self, network_id, new_name):
- put_body = {
- "network": {
- "name": new_name,
- }
- }
- body = json.dumps(put_body)
- uri = '%s/networks/%s' % (self.uri_prefix, network_id)
- resp, body = self.put(uri, body)
- body = json.loads(body)
- return resp, body
-
def create_router(self, name, admin_state_up=True, **kwargs):
post_body = {'router': kwargs}
post_body['router']['name'] = name
@@ -272,22 +194,6 @@
body = json.loads(body)
return resp, body
- def create_bulk_subnet(self, subnet_list):
- post_body = {'subnets': subnet_list}
- body = json.dumps(post_body)
- uri = '%s/subnets' % (self.uri_prefix)
- resp, body = self.post(uri, body)
- body = json.loads(body)
- return resp, body
-
- def create_bulk_port(self, port_list):
- post_body = {'ports': port_list}
- body = json.dumps(post_body)
- uri = '%s/ports' % (self.uri_prefix)
- resp, body = self.post(uri, body)
- body = json.loads(body)
- return resp, body
-
def create_vip(self, name, protocol, protocol_port, subnet_id, pool_id):
post_body = {
"vip": {
diff --git a/tempest/services/network/network_client_base.py b/tempest/services/network/network_client_base.py
index 57b0ebb..f4a012f 100644
--- a/tempest/services/network/network_client_base.py
+++ b/tempest/services/network/network_client_base.py
@@ -156,3 +156,31 @@
if name[:prefix_len] == prefix:
return method_functors[index](name[prefix_len:])
raise AttributeError(name)
+
+ # Common methods that are hard to automate
+ def create_bulk_network(self, count, names):
+ network_list = list()
+ for i in range(count):
+ network_list.append({'name': names[i]})
+ post_data = {'networks': network_list}
+ body = self.serialize_list(post_data, "networks", "network")
+ uri = self.get_uri("networks")
+ resp, body = self.post(uri, body)
+ body = {'networks': self.deserialize_list(body)}
+ return resp, body
+
+ def create_bulk_subnet(self, subnet_list):
+ post_data = {'subnets': subnet_list}
+ body = self.serialize_list(post_data, 'subnets', 'subnet')
+ uri = self.get_uri('subnets')
+ resp, body = self.post(uri, body)
+ body = {'subnets': self.deserialize_list(body)}
+ return resp, body
+
+ def create_bulk_port(self, port_list):
+ post_data = {'ports': port_list}
+ body = self.serialize_list(post_data, 'ports', 'port')
+ uri = self.get_uri('ports')
+ resp, body = self.post(uri, body)
+ body = {'ports': self.deserialize_list(body)}
+ return resp, body
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
index ebb2d00..b8e39ad 100644
--- a/tempest/services/network/xml/network_client.py
+++ b/tempest/services/network/xml/network_client.py
@@ -33,6 +33,12 @@
return RestClientXML(config, username, password,
auth_url, tenant_name)
+ def _parse_array(self, node):
+ array = []
+ for child in node.getchildren():
+ array.append(xml_to_json(child))
+ return array
+
def deserialize_list(self, body):
return parse_array(etree.fromstring(body), self.PLURALS)
@@ -44,84 +50,34 @@
# expecting the dict with single key
root = body.keys()[0]
post_body = Element(root)
+ post_body.add_attr('xmlns:xsi',
+ 'http://www.w3.org/2001/XMLSchema-instance')
for name, attr in body[root].items():
- elt = Element(name, attr)
+ elt = self._get_element(name, attr)
post_body.append(elt)
return str(Document(post_body))
- def create_network(self, name):
- uri = '%s/networks' % (self.uri_prefix)
- post_body = Element("network")
- p2 = Element("name", name)
- post_body.append(p2)
- resp, body = self.post(uri, str(Document(post_body)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
+ def serialize_list(self, body, root_name=None, item_name=None):
+ # expecting dict in form
+ # body = {'resources': [res_dict1, res_dict2, ...]
+ post_body = Element(root_name)
+ post_body.add_attr('xmlns:xsi',
+ 'http://www.w3.org/2001/XMLSchema-instance')
+ for item in body[body.keys()[0]]:
+ elt = Element(item_name)
+ for name, attr in item.items():
+ elt_content = self._get_element(name, attr)
+ elt.append(elt_content)
+ post_body.append(elt)
+ return str(Document(post_body))
- def create_bulk_network(self, count, names):
- uri = '%s/networks' % (self.uri_prefix)
- post_body = Element("networks")
- for i in range(count):
- p1 = Element("network")
- p2 = Element("name", names[i])
- p1.append(p2)
- post_body.append(p1)
- resp, body = self.post(uri, str(Document(post_body)))
- networks = parse_array(etree.fromstring(body))
- networks = {"networks": networks}
- return resp, networks
-
- def create_subnet(self, net_uuid, cidr):
- uri = '%s/subnets' % (self.uri_prefix)
- subnet = Element("subnet")
- p2 = Element("network_id", net_uuid)
- p3 = Element("cidr", cidr)
- p4 = Element("ip_version", 4)
- subnet.append(p2)
- subnet.append(p3)
- subnet.append(p4)
- resp, body = self.post(uri, str(Document(subnet)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def create_port(self, net_uuid, **kwargs):
- uri = '%s/ports' % (self.uri_prefix)
- port = Element("port")
- p1 = Element('network_id', net_uuid)
- port.append(p1)
- for key, val in kwargs.items():
- key = Element(key, val)
- port.append(key)
- resp, body = self.post(uri, str(Document(port)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def update_port(self, port_id, name):
- uri = '%s/ports/%s' % (self.uri_prefix, str(port_id))
- port = Element("port")
- p2 = Element("name", name)
- port.append(p2)
- resp, body = self.put(uri, str(Document(port)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def update_subnet(self, subnet_id, name):
- uri = '%s/subnets/%s' % (self.uri_prefix, str(subnet_id))
- subnet = Element("subnet")
- p2 = Element("name", name)
- subnet.append(p2)
- resp, body = self.put(uri, str(Document(subnet)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def update_network(self, net_id, name):
- uri = '%s/networks/%s' % (self.uri_prefix, str(net_id))
- network = Element("network")
- p2 = Element("name", name)
- network.append(p2)
- resp, body = self.put(uri, str(Document(network)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
+ def _get_element(self, name, value):
+ if value is None:
+ xml_elem = Element(name)
+ xml_elem.add_attr("xsi:nil", "true")
+ return xml_elem
+ else:
+ return Element(name, value)
def create_security_group(self, name):
uri = '%s/security-groups' % (self.uri_prefix)
@@ -147,36 +103,6 @@
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
- def create_bulk_subnet(self, subnet_list):
- uri = '%s/subnets' % (self.uri_prefix)
- post_body = Element("subnets")
- for i in range(len(subnet_list)):
- v = subnet_list[i]
- p1 = Element("subnet")
- for k, kv in v.iteritems():
- p2 = Element(k, kv)
- p1.append(p2)
- post_body.append(p1)
- resp, body = self.post(uri, str(Document(post_body)))
- subnets = parse_array(etree.fromstring(body))
- subnets = {"subnets": subnets}
- return resp, subnets
-
- def create_bulk_port(self, port_list):
- uri = '%s/ports' % (self.uri_prefix)
- post_body = Element("ports")
- for i in range(len(port_list)):
- v = port_list[i]
- p1 = Element("port")
- for k, kv in v.iteritems():
- p2 = Element(k, kv)
- p1.append(p2)
- post_body.append(p1)
- resp, body = self.post(uri, str(Document(post_body)))
- ports = parse_array(etree.fromstring(body))
- ports = {"ports": ports}
- return resp, ports
-
def create_vip(self, name, protocol, protocol_port, subnet_id, pool_id):
uri = '%s/lb/vips' % (self.uri_prefix)
post_body = Element("vip")
diff --git a/tempest/services/object_storage/account_client.py b/tempest/services/object_storage/account_client.py
index e796f9b..a6f47b7 100644
--- a/tempest/services/object_storage/account_client.py
+++ b/tempest/services/object_storage/account_client.py
@@ -33,9 +33,7 @@
HEAD on the storage URL
Returns all account metadata headers
"""
-
- headers = {"X-Storage-Token": self.token}
- resp, body = self.head('', headers=headers)
+ resp, body = self.head('')
return resp, body
def create_account_metadata(self, metadata,
@@ -54,7 +52,7 @@
Deletes an account metadata entry.
"""
- headers = {"X-Storage-Token": self.token}
+ headers = {}
for item in metadata:
headers[metadata_prefix + item] = 'x'
resp, body = self.post('', headers=headers, body=None)
@@ -63,8 +61,8 @@
def list_account_containers(self, params=None):
"""
GET on the (base) storage URL
- Given the X-Storage-URL and a valid X-Auth-Token, returns
- a list of all containers for the account.
+ Given valid X-Auth-Token, returns a list of all containers for the
+ account.
Optional Arguments:
limit=[integer value N]
@@ -93,6 +91,14 @@
body = json.loads(body)
return resp, body
+ def list_extensions(self):
+ _base_url = self.base_url
+ self.base_url = "/".join(self.base_url.split("/")[:-2])
+ resp, body = self.get('info')
+ self.base_url = _base_url
+ body = json.loads(body)
+ return resp, body
+
class AccountClientCustomizedHeader(RestClient):
@@ -127,8 +133,8 @@
def list_account_containers(self, params=None, metadata=None):
"""
GET on the (base) storage URL
- Given the X-Storage-URL and a valid X-Auth-Token, returns
- a list of all containers for the account.
+ Given a valid X-Auth-Token, returns a list of all containers for the
+ account.
Optional Arguments:
limit=[integer value N]
diff --git a/tempest/services/object_storage/container_client.py b/tempest/services/object_storage/container_client.py
index 15185bc..cbd07bf 100644
--- a/tempest/services/object_storage/container_client.py
+++ b/tempest/services/object_storage/container_client.py
@@ -82,8 +82,7 @@
Retrieves container metadata headers
"""
url = str(container_name)
- headers = {"X-Storage-Token": self.token}
- resp, body = self.head(url, headers=headers)
+ resp, body = self.head(url)
return resp, body
def list_all_container_objects(self, container, params=None):
diff --git a/tempest/services/compute/v3/xml/__init__.py b/tempest/services/telemetry/__init__.py
similarity index 100%
copy from tempest/services/compute/v3/xml/__init__.py
copy to tempest/services/telemetry/__init__.py
diff --git a/tempest/services/compute/v3/xml/__init__.py b/tempest/services/telemetry/json/__init__.py
similarity index 100%
copy from tempest/services/compute/v3/xml/__init__.py
copy to tempest/services/telemetry/json/__init__.py
diff --git a/tempest/services/telemetry/json/telemetry_client.py b/tempest/services/telemetry/json/telemetry_client.py
new file mode 100644
index 0000000..8d46bf3
--- /dev/null
+++ b/tempest/services/telemetry/json/telemetry_client.py
@@ -0,0 +1,52 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2014 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.common.rest_client import RestClient
+from tempest.openstack.common import jsonutils as json
+import tempest.services.telemetry.telemetry_client_base as client
+
+
+class TelemetryClientJSON(client.TelemetryClientBase):
+
+ def get_rest_client(self, config, username,
+ password, auth_url, tenant_name=None):
+ return RestClient(config, username, password, auth_url, tenant_name)
+
+ def deserialize(self, body):
+ return json.loads(body.replace("\n", ""))
+
+ def serialize(self, body):
+ return json.dumps(body)
+
+ def create_alarm(self, **kwargs):
+ uri = "%s/alarms" % self.uri_prefix
+ return self.post(uri, kwargs)
+
+ def add_sample(self, sample_list, meter_name, meter_unit, volume,
+ sample_type, resource_id, **kwargs):
+ sample = {"counter_name": meter_name, "counter_unit": meter_unit,
+ "counter_volume": volume, "counter_type": sample_type,
+ "resource_id": resource_id}
+ for key in kwargs:
+ sample[key] = kwargs[key]
+
+ sample_list.append(self.serialize(sample))
+ return sample_list
+
+ def create_sample(self, meter_name, sample_list):
+ uri = "%s/meters/%s" % (self.uri_prefix, meter_name)
+ return self.post(uri, str(sample_list))
diff --git a/tempest/services/telemetry/telemetry_client_base.py b/tempest/services/telemetry/telemetry_client_base.py
new file mode 100644
index 0000000..59127b9
--- /dev/null
+++ b/tempest/services/telemetry/telemetry_client_base.py
@@ -0,0 +1,133 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import abc
+import six
+import urllib
+
+
+@six.add_metaclass(abc.ABCMeta)
+class TelemetryClientBase(object):
+
+ """
+ Tempest REST client for Ceilometer V2 API.
+ Implements the following basic Ceilometer abstractions:
+ resources
+ meters
+ alarms
+ queries
+ statistics
+ """
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ self.rest_client = self.get_rest_client(config, username, password,
+ auth_url, tenant_name)
+ self.rest_client.service = \
+ self.rest_client.config.telemetry.catalog_type
+ self.headers = self.rest_client.headers
+ self.version = '2'
+ self.uri_prefix = "v%s" % self.version
+
+ @abc.abstractmethod
+ def get_rest_client(self, config, username, password,
+ auth_url, tenant_name):
+ """
+ :param config:
+ :param username:
+ :param password:
+ :param auth_url:
+ :param tenant_name:
+ :return: RestClient
+ """
+
+ @abc.abstractmethod
+ def deserialize(self, body):
+ """
+ :param body:
+ :return: Deserialize body
+ """
+
+ @abc.abstractmethod
+ def serialize(self, body):
+ """
+ :param body:
+ :return: Serialize body
+ """
+
+ def post(self, uri, body):
+ body = self.serialize(body)
+ resp, body = self.rest_client.post(uri, body, self.headers)
+ body = self.deserialize(body)
+ return resp, body
+
+ def put(self, uri, body):
+ return self.rest_client.put(uri, body, self.headers)
+
+ def get(self, uri):
+ resp, body = self.rest_client.get(uri)
+ body = self.deserialize(body)
+ return resp, body
+
+ def delete(self, uri):
+ resp, body = self.rest_client.delete(uri)
+ if body:
+ body = self.deserialize(body)
+ return resp, body
+
+ def helper_list(self, uri, query=None, period=None):
+ uri_dict = {}
+ if query:
+ uri_dict = {'q.field': query[0],
+ 'q.op': query[1],
+ 'q.value': query[2]}
+ if period:
+ uri_dict['period'] = period
+ if uri_dict:
+ uri += "?%s" % urllib.urlencode(uri_dict)
+ return self.get(uri)
+
+ def list_resources(self):
+ uri = '%s/resources' % self.uri_prefix
+ return self.get(uri)
+
+ def list_meters(self):
+ uri = '%s/meters' % self.uri_prefix
+ return self.get(uri)
+
+ def list_alarms(self):
+ uri = '%s/alarms' % self.uri_prefix
+ return self.get(uri)
+
+ def list_statistics(self, meter, period=None, query=None):
+ uri = "%s/meters/%s/statistics" % (self.uri_prefix, meter)
+ return self.helper_list(uri, query, period)
+
+ def list_samples(self, meter_id, query=None):
+ uri = '%s/meters/%s' % (self.uri_prefix, meter_id)
+ return self.helper_list(uri, query)
+
+ def get_resource(self, resource_id):
+ uri = '%s/resources/%s' % (self.uri_prefix, resource_id)
+ return self.get(uri)
+
+ def get_alarm(self, alarm_id):
+ uri = '%s/meter/%s' % (self.uri_prefix, alarm_id)
+ return self.get(uri)
+
+ def delete_alarm(self, alarm_id):
+ uri = "%s/alarms/%s" % (self.uri_prefix, alarm_id)
+ return self.delete(uri)
diff --git a/tempest/services/compute/v3/xml/__init__.py b/tempest/services/telemetry/xml/__init__.py
similarity index 100%
rename from tempest/services/compute/v3/xml/__init__.py
rename to tempest/services/telemetry/xml/__init__.py
diff --git a/tempest/services/telemetry/xml/telemetry_client.py b/tempest/services/telemetry/xml/telemetry_client.py
new file mode 100644
index 0000000..245ccb5
--- /dev/null
+++ b/tempest/services/telemetry/xml/telemetry_client.py
@@ -0,0 +1,42 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2014 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from lxml import etree
+
+from tempest.common.rest_client import RestClientXML
+from tempest.services.compute.xml.common import Document
+from tempest.services.compute.xml.common import xml_to_json
+import tempest.services.telemetry.telemetry_client_base as client
+
+
+class TelemetryClientXML(client.TelemetryClientBase):
+
+ def get_rest_client(self, config, username,
+ password, auth_url, tenant_name=None):
+ return RestClientXML(config, username, password, auth_url, tenant_name)
+
+ def _parse_array(self, body):
+ array = []
+ for child in body.getchildren():
+ array.append(xml_to_json(child))
+ return array
+
+ def serialize(self, body):
+ return str(Document(body))
+
+ def deserialize(self, body):
+ return self._parse_array(etree.fromstring(body))
diff --git a/tempest/stress/run_stress.py b/tempest/stress/run_stress.py
index 61fb58f..76320d0 100755
--- a/tempest/stress/run_stress.py
+++ b/tempest/stress/run_stress.py
@@ -19,7 +19,11 @@
import json
import sys
from testtools.testsuite import iterate_tests
-from unittest import loader
+try:
+ from unittest import loader
+except ImportError:
+ # unittest in python 2.6 does not contain loader, so uses unittest2
+ from unittest2 import loader
from tempest.openstack.common import log as logging
from tempest.stress import driver
diff --git a/tempest/test_discover/test_discover.py b/tempest/test_discover/test_discover.py
index 87fdbdc..3fbb8e1 100644
--- a/tempest/test_discover/test_discover.py
+++ b/tempest/test_discover/test_discover.py
@@ -13,7 +13,12 @@
# under the License.
import os
-import unittest
+import sys
+
+if sys.version_info >= (2, 7):
+ import unittest
+else:
+ import unittest2 as unittest
def load_tests(loader, tests, pattern):
diff --git a/tempest/tests/base.py b/tempest/tests/base.py
index 3654f64..15e4311 100644
--- a/tempest/tests/base.py
+++ b/tempest/tests/base.py
@@ -15,6 +15,7 @@
import os
import fixtures
+import mock
import testtools
from tempest.openstack.common.fixture import moxstubout
@@ -36,3 +37,22 @@
mox_fixture = self.useFixture(moxstubout.MoxStubout())
self.mox = mox_fixture.mox
self.stubs = mox_fixture.stubs
+
+ def patch(self, target, **kwargs):
+ """
+ Returns a started `mock.patch` object for the supplied target.
+
+ The caller may then call the returned patcher to create a mock object.
+
+ The caller does not need to call stop() on the returned
+ patcher object, as this method automatically adds a cleanup
+ to the test class to stop the patcher.
+
+ :param target: String module.class or module.object expression to patch
+ :param **kwargs: Passed as-is to `mock.patch`. See mock documentation
+ for details.
+ """
+ p = mock.patch(target, **kwargs)
+ m = p.start()
+ self.addCleanup(p.stop)
+ return m
diff --git a/tempest/tests/test_ssh.py b/tempest/tests/test_ssh.py
new file mode 100644
index 0000000..09bb588
--- /dev/null
+++ b/tempest/tests/test_ssh.py
@@ -0,0 +1,200 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2014 OpenStack Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import contextlib
+import socket
+
+import mock
+import testtools
+
+from tempest.common import ssh
+from tempest import exceptions
+from tempest.tests import base
+
+
+class TestSshClient(base.TestCase):
+
+ def test_pkey_calls_paramiko_RSAKey(self):
+ with contextlib.nested(
+ mock.patch('paramiko.RSAKey.from_private_key'),
+ mock.patch('cStringIO.StringIO')) as (rsa_mock, cs_mock):
+ cs_mock.return_value = mock.sentinel.csio
+ pkey = 'mykey'
+ ssh.Client('localhost', 'root', pkey=pkey)
+ rsa_mock.assert_called_once_with(mock.sentinel.csio)
+ cs_mock.assert_called_once_with('mykey')
+ rsa_mock.reset_mock()
+ cs_mock.rest_mock()
+ pkey = mock.sentinel.pkey
+ # Shouldn't call out to load a file from RSAKey, since
+ # a sentinel isn't a basestring...
+ ssh.Client('localhost', 'root', pkey=pkey)
+ rsa_mock.assert_not_called()
+ cs_mock.assert_not_called()
+
+ def test_get_ssh_connection(self):
+ c_mock = self.patch('paramiko.SSHClient')
+ aa_mock = self.patch('paramiko.AutoAddPolicy')
+ s_mock = self.patch('time.sleep')
+ t_mock = self.patch('time.time')
+
+ aa_mock.return_value = mock.sentinel.aa
+
+ def reset_mocks():
+ aa_mock.reset_mock()
+ c_mock.reset_mock()
+ s_mock.reset_mock()
+ t_mock.reset_mock()
+
+ # Test normal case for successful connection on first try
+ client_mock = mock.MagicMock()
+ c_mock.return_value = client_mock
+ client_mock.connect.return_value = True
+
+ client = ssh.Client('localhost', 'root', timeout=2)
+ client._get_ssh_connection(sleep=1)
+
+ aa_mock.assert_called_once_with()
+ client_mock.set_missing_host_key_policy.assert_called_once_with(
+ mock.sentinel.aa)
+ expected_connect = [mock.call(
+ 'localhost',
+ username='root',
+ pkey=None,
+ key_filename=None,
+ look_for_keys=False,
+ timeout=10.0,
+ password=None
+ )]
+ self.assertEqual(expected_connect, client_mock.connect.mock_calls)
+ s_mock.assert_not_called()
+ t_mock.assert_called_once_with()
+
+ reset_mocks()
+
+ # Test case when connection fails on first two tries and
+ # succeeds on third try (this validates retry logic)
+ client_mock.connect.side_effect = [socket.error, socket.error, True]
+ t_mock.side_effect = [
+ 1000, # Start time
+ 1001, # Sleep loop 1
+ 1002 # Sleep loop 2
+ ]
+
+ client._get_ssh_connection(sleep=1)
+
+ expected_sleeps = [
+ mock.call(1),
+ mock.call(1.01)
+ ]
+ self.assertEqual(expected_sleeps, s_mock.mock_calls)
+
+ reset_mocks()
+
+ # Test case when connection fails on first three tries and
+ # exceeds the timeout, so expect to raise a Timeout exception
+ client_mock.connect.side_effect = [
+ socket.error,
+ socket.error,
+ socket.error
+ ]
+ t_mock.side_effect = [
+ 1000, # Start time
+ 1001, # Sleep loop 1
+ 1002, # Sleep loop 2
+ 1003, # Sleep loop 3
+ 1004 # LOG.error() calls time.time()
+ ]
+
+ with testtools.ExpectedException(exceptions.SSHTimeout):
+ client._get_ssh_connection()
+
+ def test_exec_command(self):
+ gsc_mock = self.patch('tempest.common.ssh.Client._get_ssh_connection')
+ ito_mock = self.patch('tempest.common.ssh.Client._is_timed_out')
+ select_mock = self.patch('select.poll')
+
+ client_mock = mock.MagicMock()
+ tran_mock = mock.MagicMock()
+ chan_mock = mock.MagicMock()
+ poll_mock = mock.MagicMock()
+
+ def reset_mocks():
+ gsc_mock.reset_mock()
+ ito_mock.reset_mock()
+ select_mock.reset_mock()
+ poll_mock.reset_mock()
+ client_mock.reset_mock()
+ tran_mock.reset_mock()
+ chan_mock.reset_mock()
+
+ select_mock.return_value = poll_mock
+ gsc_mock.return_value = client_mock
+ ito_mock.return_value = True
+ client_mock.get_transport.return_value = tran_mock
+ tran_mock.open_session.return_value = chan_mock
+ poll_mock.poll.side_effect = [
+ [0, 0, 0]
+ ]
+
+ # Test for a timeout condition immediately raised
+ client = ssh.Client('localhost', 'root', timeout=2)
+ with testtools.ExpectedException(exceptions.TimeoutException):
+ client.exec_command("test")
+
+ chan_mock.fileno.assert_called_once_with()
+ chan_mock.exec_command.assert_called_once_with("test")
+ chan_mock.shutdown_write.assert_called_once_with()
+
+ SELECT_POLLIN = 1
+ poll_mock.register.assert_called_once_with(chan_mock, SELECT_POLLIN)
+ poll_mock.poll.assert_called_once_with(10)
+
+ # Test for proper reading of STDOUT and STDERROR and closing
+ # of all file descriptors.
+
+ reset_mocks()
+
+ select_mock.return_value = poll_mock
+ gsc_mock.return_value = client_mock
+ ito_mock.return_value = False
+ client_mock.get_transport.return_value = tran_mock
+ tran_mock.open_session.return_value = chan_mock
+ poll_mock.poll.side_effect = [
+ [1, 0, 0]
+ ]
+ closed_prop = mock.PropertyMock(return_value=True)
+ type(chan_mock).closed = closed_prop
+ chan_mock.recv_exit_status.return_value = 0
+ chan_mock.recv.return_value = ''
+ chan_mock.recv_stderr.return_value = ''
+
+ client = ssh.Client('localhost', 'root', timeout=2)
+ client.exec_command("test")
+
+ chan_mock.fileno.assert_called_once_with()
+ chan_mock.exec_command.assert_called_once_with("test")
+ chan_mock.shutdown_write.assert_called_once_with()
+
+ SELECT_POLLIN = 1
+ poll_mock.register.assert_called_once_with(chan_mock, SELECT_POLLIN)
+ poll_mock.poll.assert_called_once_with(10)
+ chan_mock.recv_ready.assert_called_once_with()
+ chan_mock.recv.assert_called_once_with(1024)
+ chan_mock.recv_stderr_ready.assert_called_once_with()
+ chan_mock.recv_stderr.assert_called_once_with(1024)
+ chan_mock.recv_exit_status.assert_called_once_with()
+ closed_prop.assert_called_once_with()
diff --git a/tools/install_venv.py b/tools/install_venv.py
index a7fb5ee..e41ca43 100644
--- a/tools/install_venv.py
+++ b/tools/install_venv.py
@@ -1,7 +1,7 @@
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
-# flake8: noqa
+#
# Copyright 2010 OpenStack Foundation
# Copyright 2013 IBM Corp.
#
@@ -17,66 +17,55 @@
# License for the specific language governing permissions and limitations
# under the License.
-"""Installation script for Tempest's development virtualenv."""
-
import os
import sys
-import install_venv_common as install_venv
+import install_venv_common as install_venv # noqa
-class CentOS(install_venv.Fedora):
- """This covers CentOS."""
-
- def post_process(self):
- if not self.check_pkg('openssl-devel'):
- self.yum.install('openssl-devel', check_exit_code=False)
-
-
-def print_help():
- """This prints Help."""
-
+def print_help(venv, root):
help = """
- Tempest development environment setup is complete.
+ Openstack development environment setup is complete.
- Tempest development uses virtualenv to track and manage Python dependencies
- while in development and testing.
+ Openstack development uses virtualenv to track and manage Python
+ dependencies while in development and testing.
- To activate the Tempest virtualenv for the extent of your current shell
+ To activate the Openstack virtualenv for the extent of your current shell
session you can run:
- $ source .venv/bin/activate
+ $ source %s/bin/activate
Or, if you prefer, you can run commands in the virtualenv on a case by case
basis by running:
- $ tools/with_venv.sh <your command>
+ $ %s/tools/with_venv.sh <your command>
Also, make test will automatically use the virtualenv.
"""
- print(help)
+ print(help % (venv, root))
def main(argv):
root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+
+ if os.environ.get('tools_path'):
+ root = os.environ['tools_path']
venv = os.path.join(root, '.venv')
+ if os.environ.get('venv'):
+ venv = os.environ['venv']
+
pip_requires = os.path.join(root, 'requirements.txt')
test_requires = os.path.join(root, 'test-requirements.txt')
py_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
project = 'Tempest'
install = install_venv.InstallVenv(root, venv, pip_requires, test_requires,
py_version, project)
- if os.path.exists('/etc/redhat-release'):
- with open('/etc/redhat-release') as rh_release:
- if 'CentOS' in rh_release.read():
- install_venv.Fedora = CentOS
options = install.parse_args(argv)
install.check_python_version()
install.check_dependencies()
install.create_virtualenv(no_site_packages=options.no_site_packages)
install.install_dependencies()
- install.post_process()
- print_help()
+ print_help(venv, root)
if __name__ == '__main__':
main(sys.argv)
diff --git a/tools/verify_tempest_config.py b/tools/verify_tempest_config.py
index f56b475..b393402 100755
--- a/tools/verify_tempest_config.py
+++ b/tools/verify_tempest_config.py
@@ -14,20 +14,17 @@
# License for the specific language governing permissions and limitations
# under the License.
+import json
import sys
+import httplib2
+
from tempest import clients
from tempest import config
CONF = config.CONF
-
-#Dicts matching extension names to config options
-NOVA_EXTENSIONS = {
- 'disk_config': 'DiskConfig',
- 'change_password': 'ServerPassword',
- 'flavor_extra': 'FlavorExtraSpecs'
-}
+RAW_HTTP = httplib2.Http()
def verify_glance_api_versions(os):
@@ -42,33 +39,102 @@
not CONF.image_feature_enabled.api_v2))
-def verify_extensions(os):
- results = {}
- extensions_client = os.extensions_client
+def verify_nova_api_versions(os):
+ # Check nova api versions
+ os.servers_client._set_auth()
+ v2_endpoint = os.servers_client.base_url
+ endpoint = 'http://' + v2_endpoint.split('/')[2]
+ __, body = RAW_HTTP.request(endpoint, 'GET')
+ body = json.loads(body)
+ versions = map(lambda x: x['id'], body['versions'])
+ if CONF.compute_feature_enabled.api_v3 != ('v3.0' in versions):
+ print('Config option compute api_v3 should be change to: %s' % (
+ not CONF.compute_feature_enabled.api_v3))
+
+
+def get_extension_client(os, service):
+ extensions_client = {
+ 'nova': os.extensions_client,
+ 'nova_v3': os.extensions_v3_client,
+ 'cinder': os.volumes_extension_client,
+ 'neutron': os.network_client,
+ }
+ if service not in extensions_client:
+ print('No tempest extensions client for %s' % service)
+ exit(1)
+ return extensions_client[service]
+
+
+def get_enabled_extensions(service):
+ extensions_options = {
+ 'nova': CONF.compute_feature_enabled.api_extensions,
+ 'nova_v3': CONF.compute_feature_enabled.api_v3_extensions,
+ 'cinder': CONF.volume_feature_enabled.api_extensions,
+ 'neutron': CONF.network_feature_enabled.api_extensions,
+ }
+ if service not in extensions_options:
+ print('No supported extensions list option for %s' % service)
+ exit(1)
+ return extensions_options[service]
+
+
+def verify_extensions(os, service, results):
+ extensions_client = get_extension_client(os, service)
__, resp = extensions_client.list_extensions()
- resp = resp['extensions']
- extensions = map(lambda x: x['name'], resp)
- results['nova_features'] = {}
- for extension in NOVA_EXTENSIONS.keys():
- if NOVA_EXTENSIONS[extension] in extensions:
- results['nova_features'][extension] = True
+ if isinstance(resp, dict):
+ # Neutron's extension 'name' field has is not a single word (it has
+ # spaces in the string) Since that can't be used for list option the
+ # api_extension option in the network-feature-enabled group uses alias
+ # instead of name.
+ if service == 'neutron':
+ extensions = map(lambda x: x['alias'], resp['extensions'])
else:
- results['nova_features'][extension] = False
+ extensions = map(lambda x: x['name'], resp['extensions'])
+
+ else:
+ extensions = map(lambda x: x['name'], resp)
+ if not results.get(service):
+ results[service] = {}
+ extensions_opt = get_enabled_extensions(service)
+ if extensions_opt[0] == 'all':
+ results[service]['extensions'] = 'all'
+ return results
+ # Verify that all configured extensions are actually enabled
+ for extension in extensions_opt:
+ results[service][extension] = extension in extensions
+ # Verify that there aren't additional extensions enabled that aren't
+ # specified in the config list
+ for extension in extensions:
+ if extension not in extensions_opt:
+ results[service][extension] = False
return results
def display_results(results):
- for option in NOVA_EXTENSIONS.keys():
- config_value = getattr(CONF.compute_feature_enabled, option)
- if config_value != results['nova_features'][option]:
- print("Config option: %s should be changed to: %s" % (
- option, not config_value))
+ for service in results:
+ # If all extensions are specified as being enabled there is no way to
+ # verify this so we just assume this to be true
+ if results[service].get('extensions'):
+ continue
+ extension_list = get_enabled_extensions(service)
+ for extension in results[service]:
+ if not results[service][extension]:
+ if extension in extension_list:
+ print("%s extension: %s should not be included in the list"
+ " of enabled extensions" % (service, extension))
+ else:
+ print("%s extension: %s should be included in the list of "
+ "enabled extensions" % (service, extension))
def main(argv):
+ print('Running config verification...')
os = clients.ComputeAdminManager(interface='json')
- results = verify_extensions(os)
+ results = {}
+ for service in ['nova', 'nova_v3', 'cinder', 'neutron']:
+ results = verify_extensions(os, service, results)
verify_glance_api_versions(os)
+ verify_nova_api_versions(os)
display_results(results)