Merge "Enable HostsAdminTestXML"
diff --git a/.testr.conf b/.testr.conf
index c25ebec..abaf14a 100644
--- a/.testr.conf
+++ b/.testr.conf
@@ -2,8 +2,7 @@
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-500} \
- OS_TEST_PATH=${OS_TEST_PATH:-./tempest} \
- ${PYTHON:-python} -m subunit.run discover -t ./ $OS_TEST_PATH $LISTOPT $IDOPTION
+ ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./tempest/test_discover} $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list
group_regex=([^\.]*\.)*
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 1080ddf..607ba8b 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -94,6 +94,265 @@
#syslog_log_facility=LOG_USER
+[image]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the Image service. (string value)
+#catalog_type=image
+
+# The image region name to use. If empty, the value of
+# identity.region is used instead. If no such region is found
+# in the service catalog, the first found one is used. (string
+# value)
+#region=
+
+# http accessible image (string value)
+#http_image=http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-uec.tar.gz
+
+
+[object-storage]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the Object-Storage service. (string value)
+#catalog_type=object-store
+
+# The object-storage region name to use. If empty, the value
+# of identity.region is used instead. If no such region is
+# found in the service catalog, the first found one is used.
+# (string value)
+#region=
+
+# Number of seconds to time on waiting for a containerto
+# container synchronization complete. (integer value)
+#container_sync_timeout=120
+
+# Number of seconds to wait while looping to check thestatus
+# of a container to container synchronization (integer value)
+#container_sync_interval=5
+
+# Role to add to users created for swift tests to enable
+# creating containers (string value)
+#operator_role=Member
+
+
+[network]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the Neutron service. (string value)
+#catalog_type=network
+
+# The network region name to use. If empty, the value of
+# identity.region is used instead. If no such region is found
+# in the service catalog, the first found one is used. (string
+# value)
+#region=
+
+# The cidr block to allocate tenant networks from (string
+# value)
+#tenant_network_cidr=10.100.0.0/16
+
+# The mask bits for tenant networks (integer value)
+#tenant_network_mask_bits=28
+
+# Whether tenant network connectivity should be evaluated
+# directly (boolean value)
+#tenant_networks_reachable=false
+
+# Id of the public network that provides external connectivity
+# (string value)
+#public_network_id=
+
+# Id of the public router that provides external connectivity
+# (string value)
+#public_router_id=
+
+
+[data_processing]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the data processing service. (string value)
+#catalog_type=data_processing
+
+
+[object-storage-feature-enabled]
+
+#
+# Options defined in tempest.config
+#
+
+# Set to True if the Container Quota middleware is enabled
+# (boolean value)
+#container_quotas=true
+
+# Set to True if the Account Quota middleware is enabled
+# (boolean value)
+#accounts_quotas=true
+
+# Set to True if the Crossdomain middleware is enabled
+# (boolean value)
+#crossdomain=true
+
+# Set to True if the TempURL middleware is enabled (boolean
+# value)
+#tempurl=true
+
+
+[network-feature-enabled]
+
+#
+# Options defined in tempest.config
+#
+
+# A list of enabled extensions with a special entry all which
+# indicates every extension is enabled (list value)
+#api_extensions=all
+
+
+[volume-feature-enabled]
+
+#
+# Options defined in tempest.config
+#
+
+# Runs Cinder multi-backend test (requires 2 backends)
+# (boolean value)
+#multi_backend=false
+
+# A list of enabled extensions with a special entry all which
+# indicates every extension is enabled (list value)
+#api_extensions=all
+
+
+[image-feature-enabled]
+
+#
+# Options defined in tempest.config
+#
+
+# Is the v2 image API enabled (boolean value)
+#api_v2=true
+
+# Is the v1 image API enabled (boolean value)
+#api_v1=true
+
+
+[compute-admin]
+
+#
+# Options defined in tempest.config
+#
+
+# Administrative Username to use for Nova API requests.
+# (string value)
+#username=admin
+
+# Administrative Tenant name to use for Nova API requests.
+# (string value)
+#tenant_name=admin
+
+# API key to use when authenticating as admin. (string value)
+#password=pass
+
+
+[volume]
+
+#
+# Options defined in tempest.config
+#
+
+# Time in seconds between volume availability checks. (integer
+# value)
+#build_interval=10
+
+# Timeout in seconds to wait for a volume to becomeavailable.
+# (integer value)
+#build_timeout=300
+
+# Catalog type of the Volume Service (string value)
+#catalog_type=volume
+
+# The volume region name to use. If empty, the value of
+# identity.region is used instead. If no such region is found
+# in the service catalog, the first found one is used. (string
+# value)
+#region=
+
+# Name of the backend1 (must be declared in cinder.conf)
+# (string value)
+#backend1_name=BACKEND_1
+
+# Name of the backend2 (must be declared in cinder.conf)
+# (string value)
+#backend2_name=BACKEND_2
+
+# Backend protocol to target when creating volume types
+# (string value)
+#storage_protocol=iSCSI
+
+# Backend vendor to target when creating volume types (string
+# value)
+#vendor_name=Open Source
+
+# Disk format to use when copying a volume to image (string
+# value)
+#disk_format=raw
+
+
+[compute-feature-enabled]
+
+#
+# Options defined in tempest.config
+#
+
+# If false, skip all nova v3 tests. (boolean value)
+#api_v3=true
+
+# If false, skip disk config tests (boolean value)
+#disk_config=true
+
+# A list of enabled extensions with a special entry all which
+# indicates every extension is enabled (list value)
+#api_extensions=all
+
+# A list of enabled v3 extensions with a special entry all
+# which indicates every extension is enabled (list value)
+#api_v3_extensions=all
+
+# Does the test environment support changing the admin
+# password? (boolean value)
+#change_password=false
+
+# Does the test environment support snapshots? (boolean value)
+#create_image=false
+
+# Does the test environment support resizing? (boolean value)
+#resize=false
+
+# Does the test environment support live migration available?
+# (boolean value)
+#live_migration=false
+
+# Does the test environment use block devices for live
+# migration (boolean value)
+#block_migration_for_live_migration=false
+
+# Does the test environment block migration support cinder
+# iSCSI volumes (boolean value)
+#block_migrate_cinder_iscsi=false
+
+
[identity]
#
@@ -157,6 +416,23 @@
#admin_password=pass
+[cli]
+
+#
+# Options defined in tempest.cli
+#
+
+# enable cli tests (boolean value)
+#enabled=true
+
+# directory where python client binaries are located (string
+# value)
+#cli_dir=/usr/local/bin
+
+# Number of seconds to wait on a CLI timeout (integer value)
+#timeout=15
+
+
[stress]
#
@@ -195,19 +471,6 @@
#default_thread_number_per_action=4
-[image-feature-enabled]
-
-#
-# Options defined in tempest.config
-#
-
-# Is the v2 image API enabled (boolean value)
-#api_v2=true
-
-# Is the v1 image API enabled (boolean value)
-#api_v1=true
-
-
[compute]
#
@@ -256,7 +519,7 @@
# (integer value)
#build_timeout=300
-# Does the test environment support snapshots? (boolean value)
+# Should the tests ssh to instances? (boolean value)
#run_ssh=false
# User name used to authenticate to an instance. (string
@@ -319,39 +582,30 @@
#shelved_offload_time=0
-[network]
+[scenario]
#
# Options defined in tempest.config
#
-# Catalog type of the Neutron service. (string value)
-#catalog_type=network
+# Directory containing image files (string value)
+#img_dir=/opt/stack/new/devstack/files/images/cirros-0.3.1-x86_64-uec
-# The network region name to use. If empty, the value of
-# identity.region is used instead. If no such region is found
-# in the service catalog, the first found one is used. (string
-# value)
-#region=
+# AMI image file name (string value)
+#ami_img_file=cirros-0.3.1-x86_64-blank.img
-# The cidr block to allocate tenant networks from (string
-# value)
-#tenant_network_cidr=10.100.0.0/16
+# ARI image file name (string value)
+#ari_img_file=cirros-0.3.1-x86_64-initrd
-# The mask bits for tenant networks (integer value)
-#tenant_network_mask_bits=28
+# AKI image file name (string value)
+#aki_img_file=cirros-0.3.1-x86_64-vmlinuz
-# Whether tenant network connectivity should be evaluated
-# directly (boolean value)
-#tenant_networks_reachable=false
+# ssh username for the image file (string value)
+#ssh_user=cirros
-# Id of the public network that provides external connectivity
-# (string value)
-#public_network_id=
-
-# Id of the public router that provides external connectivity
-# (string value)
-#public_router_id=
+# specifies how many resources to request at once. Used for
+# large operations testing. (integer value)
+#large_ops_number=0
[boto]
@@ -400,140 +654,6 @@
#build_interval=1
-[scenario]
-
-#
-# Options defined in tempest.config
-#
-
-# Directory containing image files (string value)
-#img_dir=/opt/stack/new/devstack/files/images/cirros-0.3.1-x86_64-uec
-
-# AMI image file name (string value)
-#ami_img_file=cirros-0.3.1-x86_64-blank.img
-
-# ARI image file name (string value)
-#ari_img_file=cirros-0.3.1-x86_64-initrd
-
-# AKI image file name (string value)
-#aki_img_file=cirros-0.3.1-x86_64-vmlinuz
-
-# ssh username for the image file (string value)
-#ssh_user=cirros
-
-# specifies how many resources to request at once. Used for
-# large operations testing. (integer value)
-#large_ops_number=0
-
-
-[image]
-
-#
-# Options defined in tempest.config
-#
-
-# Catalog type of the Image service. (string value)
-#catalog_type=image
-
-# The image region name to use. If empty, the value of
-# identity.region is used instead. If no such region is found
-# in the service catalog, the first found one is used. (string
-# value)
-#region=
-
-# http accessible image (string value)
-#http_image=http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-uec.tar.gz
-
-
-[compute-admin]
-
-#
-# Options defined in tempest.config
-#
-
-# Administrative Username to use for Nova API requests.
-# (string value)
-#username=admin
-
-# Administrative Tenant name to use for Nova API requests.
-# (string value)
-#tenant_name=admin
-
-# API key to use when authenticating as admin. (string value)
-#password=pass
-
-
-[cli]
-
-#
-# Options defined in tempest.cli
-#
-
-# enable cli tests (boolean value)
-#enabled=true
-
-# directory where python client binaries are located (string
-# value)
-#cli_dir=/usr/local/bin
-
-# Number of seconds to wait on a CLI timeout (integer value)
-#timeout=15
-
-
-[volume]
-
-#
-# Options defined in tempest.config
-#
-
-# Time in seconds between volume availability checks. (integer
-# value)
-#build_interval=10
-
-# Timeout in seconds to wait for a volume to becomeavailable.
-# (integer value)
-#build_timeout=300
-
-# Catalog type of the Volume Service (string value)
-#catalog_type=volume
-
-# The volume region name to use. If empty, the value of
-# identity.region is used instead. If no such region is found
-# in the service catalog, the first found one is used. (string
-# value)
-#region=
-
-# Name of the backend1 (must be declared in cinder.conf)
-# (string value)
-#backend1_name=BACKEND_1
-
-# Name of the backend2 (must be declared in cinder.conf)
-# (string value)
-#backend2_name=BACKEND_2
-
-# Backend protocol to target when creating volume types
-# (string value)
-#storage_protocol=iSCSI
-
-# Backend vendor to target when creating volume types (string
-# value)
-#vendor_name=Open Source
-
-# Disk format to use when copying a volume to image (string
-# value)
-#disk_format=raw
-
-
-[debug]
-
-#
-# Options defined in tempest.config
-#
-
-# Enable diagnostic commands (boolean value)
-#enable=true
-
-
[dashboard]
#
@@ -592,43 +712,14 @@
#max_template_size=524288
-[object-storage]
+[debug]
#
# Options defined in tempest.config
#
-# Catalog type of the Object-Storage service. (string value)
-#catalog_type=object-store
-
-# The object-storage region name to use. If empty, the value
-# of identity.region is used instead. If no such region is
-# found in the service catalog, the first found one is used.
-# (string value)
-#region=
-
-# Number of seconds to time on waiting for a containerto
-# container synchronization complete. (integer value)
-#container_sync_timeout=120
-
-# Number of seconds to wait while looping to check thestatus
-# of a container to container synchronization (integer value)
-#container_sync_interval=5
-
-# Role to add to users created for swift tests to enable
-# creating containers (string value)
-#operator_role=Member
-
-
-[network-feature-enabled]
-
-#
-# Options defined in tempest.config
-#
-
-# A list of enabled extensions with a special entry all which
-# indicates every extension is enabled (list value)
-#api_extensions=all
+# Enable diagnostic commands (boolean value)
+#enable=true
[service_available]
@@ -669,85 +760,8 @@
# value)
#horizon=true
-
-[compute-feature-enabled]
-
-#
-# Options defined in tempest.config
-#
-
-# If false, skip all nova v3 tests. (boolean value)
-#api_v3=true
-
-# If false, skip disk config tests (boolean value)
-#disk_config=true
-
-# A list of enabled extensions with a special entry all which
-# indicates every extension is enabled (list value)
-#api_extensions=all
-
-# A list of enabled v3 extensions with a special entry all
-# which indicates every extension is enabled (list value)
-#api_v3_extensions=all
-
-# Does the test environment support changing the admin
-# password? (boolean value)
-#change_password=false
-
-# Does the test environment support snapshots? (boolean value)
-#create_image=false
-
-# Does the test environment support resizing? (boolean value)
-#resize=false
-
-# Does the test environment support live migration available?
-# (boolean value)
-#live_migration=false
-
-# Does the test environment use block devices for live
-# migration (boolean value)
-#block_migration_for_live_migration=false
-
-# Does the test environment block migration support cinder
-# iSCSI volumes (boolean value)
-#block_migrate_cinder_iscsi=false
-
-
-[object-storage-feature-enabled]
-
-#
-# Options defined in tempest.config
-#
-
-# Set to True if the Container Quota middleware is enabled
-# (boolean value)
-#container_quotas=true
-
-# Set to True if the Account Quota middleware is enabled
-# (boolean value)
-#accounts_quotas=true
-
-# Set to True if the Crossdomain middleware is enabled
-# (boolean value)
-#crossdomain=true
-
-# Set to True if the TempURL middleware is enabled (boolean
+# Whether or not Savanna is expected to be available (boolean
# value)
-#tempurl=true
-
-
-[volume-feature-enabled]
-
-#
-# Options defined in tempest.config
-#
-
-# Runs Cinder multi-backend test (requires 2 backends)
-# (boolean value)
-#multi_backend=false
-
-# A list of enabled extensions with a special entry all which
-# indicates every extension is enabled (list value)
-#api_extensions=all
+#savanna=false
diff --git a/tempest/api/compute/__init__.py b/tempest/api/compute/__init__.py
index d20068e..e69de29 100644
--- a/tempest/api/compute/__init__.py
+++ b/tempest/api/compute/__init__.py
@@ -1,27 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest import config
-from tempest.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-CONFIG = config.TempestConfig()
-CREATE_IMAGE_ENABLED = CONFIG.compute_feature_enabled.create_image
-RESIZE_AVAILABLE = CONFIG.compute_feature_enabled.resize
-CHANGE_PASSWORD_AVAILABLE = CONFIG.compute_feature_enabled.change_password
-DISK_CONFIG_ENABLED = CONFIG.compute_feature_enabled.disk_config
diff --git a/tempest/api/compute/admin/test_fixed_ips.py b/tempest/api/compute/admin/test_fixed_ips.py
index 427f728..4989d6f 100644
--- a/tempest/api/compute/admin/test_fixed_ips.py
+++ b/tempest/api/compute/admin/test_fixed_ips.py
@@ -16,7 +16,6 @@
# under the License.
from tempest.api.compute import base
-from tempest import exceptions
from tempest.test import attr
@@ -30,7 +29,6 @@
msg = ("%s skipped as neutron is available" % cls.__name__)
raise cls.skipException(msg)
cls.client = cls.os_adm.fixed_ips_client
- cls.non_admin_client = cls.fixed_ips_client
resp, server = cls.create_test_server(wait_until='ACTIVE')
resp, server = cls.servers_client.get_server(server['id'])
for ip_set in server['addresses']:
@@ -46,11 +44,6 @@
resp, fixed_ip = self.client.get_fixed_ip_details(self.ip)
self.assertEqual(fixed_ip['address'], self.ip)
- @attr(type=['negative', 'gate'])
- def test_list_fixed_ip_details_with_non_admin_user(self):
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.get_fixed_ip_details, self.ip)
-
@attr(type='gate')
def test_set_reserve(self):
body = {"reserve": "None"}
@@ -63,36 +56,6 @@
resp, body = self.client.reserve_fixed_ip(self.ip, body)
self.assertEqual(resp.status, 202)
- @attr(type=['negative', 'gate'])
- def test_set_reserve_with_non_admin_user(self):
- body = {"reserve": "None"}
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.reserve_fixed_ip,
- self.ip, body)
-
- @attr(type=['negative', 'gate'])
- def test_set_unreserve_with_non_admin_user(self):
- body = {"unreserve": "None"}
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.reserve_fixed_ip,
- self.ip, body)
-
- @attr(type=['negative', 'gate'])
- def test_set_reserve_with_invalid_ip(self):
- # NOTE(maurosr): since this exercises the same code snippet, we do it
- # only for reserve action
- body = {"reserve": "None"}
- self.assertRaises(exceptions.NotFound,
- self.client.reserve_fixed_ip,
- "my.invalid.ip", body)
-
- @attr(type=['negative', 'gate'])
- def test_fixed_ip_with_invalid_action(self):
- body = {"invalid_action": "None"}
- self.assertRaises(exceptions.BadRequest,
- self.client.reserve_fixed_ip,
- self.ip, body)
-
class FixedIPsTestXml(FixedIPsTestJson):
_interface = 'xml'
diff --git a/tempest/api/compute/admin/test_fixed_ips_negative.py b/tempest/api/compute/admin/test_fixed_ips_negative.py
new file mode 100644
index 0000000..cf48f0a
--- /dev/null
+++ b/tempest/api/compute/admin/test_fixed_ips_negative.py
@@ -0,0 +1,80 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+#
+# 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 tempest.api.compute import base
+from tempest import exceptions
+from tempest.test import attr
+
+
+class FixedIPsNegativeTestJson(base.BaseV2ComputeAdminTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(FixedIPsNegativeTestJson, cls).setUpClass()
+ if cls.config.service_available.neutron:
+ msg = ("%s skipped as neutron is available" % cls.__name__)
+ raise cls.skipException(msg)
+ cls.client = cls.os_adm.fixed_ips_client
+ cls.non_admin_client = cls.fixed_ips_client
+ resp, server = cls.create_test_server(wait_until='ACTIVE')
+ resp, server = cls.servers_client.get_server(server['id'])
+ for ip_set in server['addresses']:
+ for ip in server['addresses'][ip_set]:
+ if ip['OS-EXT-IPS:type'] == 'fixed':
+ cls.ip = ip['addr']
+ break
+ if cls.ip:
+ break
+
+ @attr(type=['negative', 'gate'])
+ def test_list_fixed_ip_details_with_non_admin_user(self):
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.get_fixed_ip_details, self.ip)
+
+ @attr(type=['negative', 'gate'])
+ def test_set_reserve_with_non_admin_user(self):
+ body = {"reserve": "None"}
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.reserve_fixed_ip,
+ self.ip, body)
+
+ @attr(type=['negative', 'gate'])
+ def test_set_unreserve_with_non_admin_user(self):
+ body = {"unreserve": "None"}
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.reserve_fixed_ip,
+ self.ip, body)
+
+ @attr(type=['negative', 'gate'])
+ def test_set_reserve_with_invalid_ip(self):
+ # NOTE(maurosr): since this exercises the same code snippet, we do it
+ # only for reserve action
+ body = {"reserve": "None"}
+ self.assertRaises(exceptions.NotFound,
+ self.client.reserve_fixed_ip,
+ "my.invalid.ip", body)
+
+ @attr(type=['negative', 'gate'])
+ def test_fixed_ip_with_invalid_action(self):
+ body = {"invalid_action": "None"}
+ self.assertRaises(exceptions.BadRequest,
+ self.client.reserve_fixed_ip,
+ self.ip, body)
+
+
+class FixedIPsNegativeTestXml(FixedIPsNegativeTestJson):
+ _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index f49aae4..66d41b8 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -22,6 +22,8 @@
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class QuotasAdminTestJSON(base.BaseV2ComputeAdminTest):
_interface = 'json'
@@ -156,7 +158,7 @@
self.assertRaises(exceptions.OverLimit, self.create_test_server)
@skip_because(bug="1186354",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_groups_exceed_limit(self):
# Negative test: Creation Security Groups over limit should FAIL
@@ -180,7 +182,7 @@
"sg-overlimit", "sg-desc")
@skip_because(bug="1186354",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_groups_rules_exceed_limit(self):
# Negative test: Creation of Security Group Rules should FAIL
diff --git a/tempest/api/compute/admin/test_security_groups.py b/tempest/api/compute/admin/test_security_groups.py
index 5ed4823..da2a1a1 100644
--- a/tempest/api/compute/admin/test_security_groups.py
+++ b/tempest/api/compute/admin/test_security_groups.py
@@ -22,6 +22,8 @@
from tempest import config
from tempest.test import attr
+CONF = config.CONF
+
class SecurityGroupsTestAdminJSON(base.BaseV2ComputeAdminTest):
_interface = 'json'
@@ -40,7 +42,7 @@
self.assertEqual(202, resp.status)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
+ @testtools.skipIf(CONF.service_available.neutron,
"Skipped because neutron do not support all_tenants"
"search filter.")
@attr(type='smoke')
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index d18b749..e0a5376 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -267,6 +267,8 @@
cls.hypervisor_client = cls.os.hypervisor_v3_client
cls.tenant_usages_client = cls.os.tenant_usages_v3_client
cls.volumes_client = cls.os.volumes_client
+ cls.certificates_client = cls.os.certificates_v3_client
+ cls.keypairs_client = cls.os.keypairs_v3_client
@classmethod
def create_image_from_server(cls, server_id, **kwargs):
diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips.py b/tempest/api/compute/floating_ips/test_list_floating_ips.py
index 6387f4e..e4d03ae 100644
--- a/tempest/api/compute/floating_ips/test_list_floating_ips.py
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips.py
@@ -15,11 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-import uuid
-
from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest.test import attr
@@ -78,24 +74,6 @@
finally:
self.client.delete_floating_ip(floating_ip_id)
- @attr(type=['negative', 'gate'])
- def test_get_nonexistant_floating_ip_details(self):
- # Negative test:Should not be able to GET the details
- # of non-existent floating IP
- floating_ip_id = []
- resp, body = self.client.list_floating_ips()
- for i in range(len(body)):
- floating_ip_id.append(body[i]['id'])
- # Creating a non-existent floatingIP id
- while True:
- non_exist_id = data_utils.rand_int_id(start=999)
- if self.config.service_available.neutron:
- non_exist_id = str(uuid.uuid4())
- if non_exist_id not in floating_ip_id:
- break
- self.assertRaises(exceptions.NotFound,
- self.client.get_floating_ip_details, non_exist_id)
-
@attr(type='gate')
def test_list_floating_ip_pools(self):
# Positive test:Should return the list of floating IP Pools
diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py b/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
new file mode 100644
index 0000000..e7dc8ee
--- /dev/null
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
@@ -0,0 +1,48 @@
+# 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.
+
+import uuid
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest.test import attr
+
+
+class FloatingIPDetailsNegativeTestJSON(base.BaseV2ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(FloatingIPDetailsNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.floating_ips_client
+
+ @attr(type=['negative', 'gate'])
+ def test_get_nonexistent_floating_ip_details(self):
+ # Negative test:Should not be able to GET the details
+ # of non-existent floating IP
+ # Creating a non-existent floatingIP id
+ if self.config.service_available.neutron:
+ non_exist_id = str(uuid.uuid4())
+ else:
+ non_exist_id = data_utils.rand_int_id(start=999)
+ self.assertRaises(exceptions.NotFound,
+ self.client.get_floating_ip_details, non_exist_id)
+
+
+class FloatingIPDetailsNegativeTestXML(FloatingIPDetailsNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index 6e4c8cb..c711bd5 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -17,13 +17,14 @@
import testtools
-from tempest.api import compute
from tempest.api.compute import base
from tempest import clients
from tempest.common.utils import data_utils
+from tempest import config
from tempest.openstack.common import log as logging
from tempest.test import attr
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -84,7 +85,7 @@
resp, flavor = self.flavors_client.get_flavor_details(flavor_id)
return flavor['disk']
- @testtools.skipUnless(compute.CREATE_IMAGE_ENABLED,
+ @testtools.skipUnless(CONF.compute_feature_enabled.create_image,
'Environment unable to create images.')
@attr(type='smoke')
def test_create_delete_image(self):
diff --git a/tempest/api/compute/security_groups/test_security_group_rules_negative.py b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
index 1c38268..c0b202d 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules_negative.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
@@ -24,6 +24,8 @@
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class SecurityGroupRulesNegativeTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
@@ -34,7 +36,7 @@
cls.client = cls.security_groups_client
@skip_because(bug="1182384",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type=['negative', 'smoke'])
def test_create_security_group_rule_with_non_existent_id(self):
# Negative test: Creation of Security Group rule should FAIL
@@ -48,7 +50,7 @@
self.client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
+ @testtools.skipIf(CONF.service_available.neutron,
"Neutron not check the security_group_id")
@attr(type=['negative', 'smoke'])
def test_create_security_group_rule_with_invalid_id(self):
@@ -168,7 +170,7 @@
secgroup_id, ip_protocol, from_port, to_port)
@skip_because(bug="1182384",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type=['negative', 'smoke'])
def test_delete_security_group_rule_with_non_existent_id(self):
# Negative test: Deletion of Security Group rule should be FAIL
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index 7cb96af..95e9171 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -25,6 +25,8 @@
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class SecurityGroupsTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
@@ -129,7 +131,7 @@
non_exist_id)
@skip_because(bug="1161411",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_group_create_with_invalid_group_name(self):
# Negative test: Security Group should not be created with group name
@@ -149,7 +151,7 @@
s_description)
@skip_because(bug="1161411",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_group_create_with_invalid_group_description(self):
# Negative test:Security Group should not be created with description
@@ -167,7 +169,7 @@
self.client.create_security_group, s_name,
s_description)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
+ @testtools.skipIf(CONF.service_available.neutron,
"Neutron allows duplicate names for security groups")
@attr(type=['negative', 'gate'])
def test_security_group_create_with_duplicate_name(self):
diff --git a/tempest/api/compute/servers/test_attach_interfaces.py b/tempest/api/compute/servers/test_attach_interfaces.py
index a177cea..dbb7d75 100644
--- a/tempest/api/compute/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/servers/test_attach_interfaces.py
@@ -92,7 +92,7 @@
self.assertEqual(sorted(list1), sorted(list2))
- @attr(type='gate')
+ @attr(type='smoke')
def test_create_list_show_delete_interfaces(self):
server, ifs = self._create_server_get_interfaces()
interface_count = len(ifs)
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index cbd0eb1..5d62e1b 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -20,17 +20,18 @@
import netaddr
import testtools
-from tempest.api import compute
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest.test import attr
+CONF = config.CONF
+
class ServersTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ run_ssh = CONF.compute.run_ssh
disk_config = 'AUTO'
@classmethod
@@ -113,7 +114,7 @@
@classmethod
def setUpClass(cls):
- if not compute.DISK_CONFIG_ENABLED:
+ if not CONF.compute_feature_enabled.disk_config:
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
super(ServersTestManualDisk, cls).setUpClass()
diff --git a/tempest/api/compute/servers/test_disk_config.py b/tempest/api/compute/servers/test_disk_config.py
index 0121c42..358728e 100644
--- a/tempest/api/compute/servers/test_disk_config.py
+++ b/tempest/api/compute/servers/test_disk_config.py
@@ -17,17 +17,19 @@
import testtools
-from tempest.api import compute
from tempest.api.compute import base
+from tempest import config
from tempest.test import attr
+CONF = config.CONF
+
class ServerDiskConfigTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
- if not compute.DISK_CONFIG_ENABLED:
+ if not CONF.compute_feature_enabled.disk_config:
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
super(ServerDiskConfigTestJSON, cls).setUpClass()
@@ -85,7 +87,8 @@
else:
return self.flavor_ref
- @testtools.skipUnless(compute.RESIZE_AVAILABLE, 'Resize not available.')
+ @testtools.skipUnless(CONF.compute_feature_enabled.resize,
+ 'Resize not available.')
@attr(type='gate')
def test_resize_server_from_manual_to_auto(self):
# A server should be resized from manual to auto disk config
@@ -101,7 +104,8 @@
resp, server = self.client.get_server(self.server_id)
self.assertEqual('AUTO', server['OS-DCF:diskConfig'])
- @testtools.skipUnless(compute.RESIZE_AVAILABLE, 'Resize not available.')
+ @testtools.skipUnless(CONF.compute_feature_enabled.resize,
+ 'Resize not available.')
@attr(type='gate')
def test_resize_server_from_auto_to_manual(self):
# A server should be resized from auto to manual disk config
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index 4cbf94d..3748e37 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -23,6 +23,8 @@
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class ListServerFiltersTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
@@ -210,7 +212,7 @@
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
@skip_because(bug="1182883",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type='gate')
def test_list_servers_filtered_by_ip_regex(self):
# Filter servers by regex ip
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index e009888..d985d2b 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -20,21 +20,21 @@
import testtools
-from tempest.api import compute
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest import exceptions
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class ServerActionsTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
- resize_available = tempest.config.TempestConfig().\
- compute_feature_enabled.resize
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ resize_available = CONF.compute_feature_enabled.resize
+ run_ssh = CONF.compute.run_ssh
def setUp(self):
# NOTE(afazekas): Normally we use the same server with all test cases,
@@ -53,7 +53,7 @@
cls.client = cls.servers_client
cls.server_id = cls.rebuild_server(None)
- @testtools.skipUnless(compute.CHANGE_PASSWORD_AVAILABLE,
+ @testtools.skipUnless(CONF.compute_feature_enabled.change_password,
'Change password not available.')
@attr(type='gate')
def test_change_server_password(self):
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index 8142250..6532032 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -17,13 +17,12 @@
import base64
import sys
-import uuid
from tempest.api.compute import base
from tempest import clients
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ServersNegativeTestJSON(base.BaseV2ComputeTest):
@@ -40,13 +39,12 @@
def setUpClass(cls):
super(ServersNegativeTestJSON, cls).setUpClass()
cls.client = cls.servers_client
- cls.img_client = cls.images_client
cls.alt_os = clients.AltManager()
cls.alt_client = cls.alt_os.servers_client
resp, server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_server_name_blank(self):
# Create a server with name parameter empty
@@ -54,7 +52,7 @@
self.create_test_server,
name='')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_personality_file_contents_not_encoded(self):
# Use an unencoded file when creating a server with personality
@@ -66,7 +64,7 @@
self.create_test_server,
personality=person)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_invalid_image(self):
# Create a server with an unknown image
@@ -74,7 +72,7 @@
self.create_test_server,
image_id=-1)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_invalid_flavor(self):
# Create a server with an unknown flavor
@@ -82,7 +80,7 @@
self.create_test_server,
flavor=-1,)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_invalid_access_ip_v4_address(self):
# An access IPv4 address must match a valid address pattern
@@ -90,7 +88,7 @@
self.assertRaises(exceptions.BadRequest,
self.create_test_server, accessIPv4=IPv4)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_invalid_ip_v6_address(self):
# An access IPv6 address must match a valid address pattern
@@ -99,34 +97,35 @@
self.assertRaises(exceptions.BadRequest,
self.create_test_server, accessIPv6=IPv6)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resize_nonexistent_server(self):
- nonexistent_server = str(uuid.uuid4())
+ # Resize a non-existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.resize,
nonexistent_server, self.flavor_ref)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resize_server_with_non_existent_flavor(self):
# Resize a server with non-existent flavor
- nonexistent_flavor = str(uuid.uuid4())
+ nonexistent_flavor = data_utils.rand_uuid()
self.assertRaises(exceptions.BadRequest, self.client.resize,
self.server_id, flavor_ref=nonexistent_flavor)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resize_server_with_null_flavor(self):
# Resize a server with null flavor
self.assertRaises(exceptions.BadRequest, self.client.resize,
self.server_id, flavor_ref="")
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_reboot_non_existent_server(self):
# Reboot a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.reboot,
nonexistent_server, 'SOFT')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_pause_paused_server(self):
# Pause a paused server.
self.client.pause_server(self.server_id)
@@ -137,7 +136,7 @@
self.client.pause_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_rebuild_reboot_deleted_server(self):
# Rebuild and Reboot a deleted server
_, server = self.create_test_server()
@@ -150,10 +149,10 @@
self.assertRaises(exceptions.NotFound, self.client.reboot,
server['id'], 'SOFT')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_rebuild_non_existent_server(self):
# Rebuild a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
meta = {'rebuild': 'server'}
new_name = data_utils.rand_name('server')
file_contents = 'Test server rebuild.'
@@ -167,7 +166,7 @@
personality=personality,
adminPass='rebuild')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_numeric_server_name(self):
# Create a server with a numeric name
if self.__class__._interface == "xml":
@@ -178,7 +177,7 @@
self.create_test_server,
name=server_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_server_name_length_exceeds_256(self):
# Create a server with name length exceeding 256 characters
@@ -187,7 +186,7 @@
self.create_test_server,
name=server_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_invalid_network_uuid(self):
# Pass invalid network uuid while creating a server
@@ -197,7 +196,7 @@
self.create_test_server,
networks=networks)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_non_existant_keypair(self):
# Pass a non-existent keypair while creating a server
@@ -206,7 +205,7 @@
self.create_test_server,
key_name=key_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_server_metadata_exceeds_length_limit(self):
# Pass really long metadata while creating a server
@@ -215,7 +214,7 @@
self.create_test_server,
meta=metadata)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_name_of_non_existent_server(self):
# Update name of a non-existent server
@@ -225,7 +224,7 @@
self.assertRaises(exceptions.NotFound, self.client.update_server,
server_name, name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_server_set_empty_name(self):
# Update name of the server to an empty string
@@ -235,7 +234,7 @@
self.assertRaises(exceptions.BadRequest, self.client.update_server,
server_name, name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_server_of_another_tenant(self):
# Update name of a server that belongs to another tenant
@@ -244,7 +243,7 @@
self.alt_client.update_server, self.server_id,
name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_server_name_length_exceeds_256(self):
# Update name of server exceed the name length limit
@@ -254,34 +253,35 @@
self.server_id,
name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_non_existent_server(self):
# Delete a non existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.delete_server,
- '999erra43')
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_a_server_of_another_tenant(self):
# Delete a server that belongs to another tenant
self.assertRaises(exceptions.NotFound,
self.alt_client.delete_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_server_pass_negative_id(self):
# Pass an invalid string parameter to delete server
self.assertRaises(exceptions.NotFound, self.client.delete_server, -1)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_server_pass_id_exceeding_length_limit(self):
# Pass a server ID that exceeds length limit to delete server
self.assertRaises(exceptions.NotFound, self.client.delete_server,
sys.maxint + 1)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_nonexistent_security_group(self):
# Create a server with a nonexistent security group
@@ -290,49 +290,49 @@
self.create_test_server,
security_groups=security_groups)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_non_existent_server(self):
# Get a non existent server details
-
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.get_server,
- '999erra43')
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_stop_non_existent_server(self):
# Stop a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.servers_client.stop,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_pause_non_existent_server(self):
# pause a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.pause_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unpause_non_existent_server(self):
# unpause a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.unpause_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unpause_server_invalid_state(self):
# unpause an active server.
self.assertRaises(exceptions.Conflict,
self.client.unpause_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_suspend_non_existent_server(self):
# suspend a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.suspend_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_suspend_server_invalid_state(self):
# suspend a suspended server.
resp, _ = self.client.suspend_server(self.server_id)
@@ -344,66 +344,66 @@
self.client.suspend_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resume_non_existent_server(self):
# resume a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.resume_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resume_server_invalid_state(self):
# resume an active server.
self.assertRaises(exceptions.Conflict,
self.client.resume_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_console_output_of_non_existent_server(self):
# get the console output for a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.get_console_output,
nonexistent_server, 10)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_force_delete_nonexistent_server_id(self):
- non_existent_server_id = str(uuid.uuid4())
-
+ # force-delete a non existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.force_delete_server,
- non_existent_server_id)
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_force_delete_server_invalid_state(self):
# we can only force-delete a server in 'soft-delete' state
self.assertRaises(exceptions.Conflict,
self.client.force_delete_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_restore_nonexistent_server_id(self):
- non_existent_server_id = str(uuid.uuid4())
-
+ # restore-delete a non existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.restore_soft_deleted_server,
- non_existent_server_id)
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_restore_server_invalid_state(self):
# we can only restore-delete a server in 'soft-delete' state
self.assertRaises(exceptions.Conflict,
self.client.restore_soft_deleted_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_shelve_non_existent_server(self):
# shelve a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.shelve_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_shelve_shelved_server(self):
# shelve a shelved server.
resp, server = self.client.shelve_server(self.server_id)
@@ -430,14 +430,14 @@
self.client.shelve_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unshelve_non_existent_server(self):
# unshelve a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.unshelve_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unshelve_server_invalid_state(self):
# unshelve an active server.
self.assertRaises(exceptions.Conflict,
diff --git a/tempest/api/compute/servers/test_virtual_interfaces.py b/tempest/api/compute/servers/test_virtual_interfaces.py
index 77ada0b..164c6df 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces.py
@@ -28,7 +28,7 @@
class VirtualInterfacesTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
- CONF = config.TempestConfig()
+ CONF = config.CONF
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/test_auth_token.py b/tempest/api/compute/test_auth_token.py
index ffeede8..e52c415 100644
--- a/tempest/api/compute/test_auth_token.py
+++ b/tempest/api/compute/test_auth_token.py
@@ -18,6 +18,8 @@
from tempest.api.compute import base
import tempest.config as config
+CONF = config.CONF
+
class AuthTokenTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
@@ -37,7 +39,7 @@
# picking list_servers because it's easy.
self.servers_v2.list_servers()
- @testtools.skipIf(not config.TempestConfig().identity.uri_v3,
+ @testtools.skipIf(not CONF.identity.uri_v3,
'v3 auth client not configured')
def test_v3_token(self):
# Can get a token using v3 of the identity API and use that to perform
diff --git a/tempest/api/compute/test_live_block_migration.py b/tempest/api/compute/test_live_block_migration.py
index a7b6cd2..d2a3d28 100644
--- a/tempest/api/compute/test_live_block_migration.py
+++ b/tempest/api/compute/test_live_block_migration.py
@@ -30,7 +30,7 @@
_host_key = 'OS-EXT-SRV-ATTR:host'
_interface = 'json'
- CONF = config.TempestConfig()
+ CONF = config.CONF
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py b/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py
new file mode 100644
index 0000000..cea6e92
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py
@@ -0,0 +1,64 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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.
+
+import datetime
+
+from tempest.api.compute import base
+from tempest.test import attr
+import urllib
+
+
+class InstanceUsageAuditLogTestJSON(base.BaseV2ComputeAdminTest):
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(InstanceUsageAuditLogTestJSON, cls).setUpClass()
+ cls.adm_client = cls.os_adm.instance_usages_audit_log_client
+
+ @attr(type='gate')
+ def test_list_instance_usage_audit_logs(self):
+ # list instance usage audit logs
+ resp, body = self.adm_client.list_instance_usage_audit_logs()
+ self.assertEqual(200, resp.status)
+ expected_items = ['total_errors', 'total_instances', 'log',
+ 'num_hosts_running', 'num_hosts_done',
+ 'num_hosts', 'hosts_not_run', 'overall_status',
+ 'period_ending', 'period_beginning',
+ 'num_hosts_not_run']
+ for item in expected_items:
+ self.assertIn(item, body)
+
+ @attr(type='gate')
+ def test_get_instance_usage_audit_log(self):
+ # Get instance usage audit log before specified time
+ now = datetime.datetime.now()
+ resp, body = self.adm_client.get_instance_usage_audit_log(
+ urllib.quote(now.strftime("%Y-%m-%d %H:%M:%S")))
+
+ self.assertEqual(200, resp.status)
+ expected_items = ['total_errors', 'total_instances', 'log',
+ 'num_hosts_running', 'num_hosts_done', 'num_hosts',
+ 'hosts_not_run', 'overall_status', 'period_ending',
+ 'period_beginning', 'num_hosts_not_run']
+ for item in expected_items:
+ self.assertIn(item, body)
+
+
+class InstanceUsageAuditLogTestXML(InstanceUsageAuditLogTestJSON):
+ _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
new file mode 100644
index 0000000..dcf41c5
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_instance_usage_audit_log_negative.py
@@ -0,0 +1,56 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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.
+
+import datetime
+
+from tempest.api.compute import base
+from tempest import exceptions
+from tempest.test import attr
+import urllib
+
+
+class InstanceUsageAuditLogNegativeTestJSON(base.BaseV2ComputeAdminTest):
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(InstanceUsageAuditLogNegativeTestJSON, cls).setUpClass()
+ cls.adm_client = cls.os_adm.instance_usages_audit_log_client
+
+ @attr(type=['negative', 'gate'])
+ def test_instance_usage_audit_logs_with_nonadmin_user(self):
+ # the instance_usage_audit_logs API just can be accessed by admin user
+ self.assertRaises(exceptions.Unauthorized,
+ self.instance_usages_audit_log_client.
+ list_instance_usage_audit_logs)
+ now = datetime.datetime.now()
+ self.assertRaises(exceptions.Unauthorized,
+ self.instance_usages_audit_log_client.
+ get_instance_usage_audit_log,
+ urllib.quote(now.strftime("%Y-%m-%d %H:%M:%S")))
+
+ @attr(type=['negative', 'gate'])
+ def test_get_instance_usage_audit_logs_with_invalid_time(self):
+ self.assertRaises(exceptions.BadRequest,
+ self.adm_client.get_instance_usage_audit_log,
+ "invalid_time")
+
+
+class InstanceUsageAuditLogNegativeTestXML(
+ InstanceUsageAuditLogNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_quotas.py b/tempest/api/compute/v3/admin/test_quotas.py
index f49aae4..66d41b8 100644
--- a/tempest/api/compute/v3/admin/test_quotas.py
+++ b/tempest/api/compute/v3/admin/test_quotas.py
@@ -22,6 +22,8 @@
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class QuotasAdminTestJSON(base.BaseV2ComputeAdminTest):
_interface = 'json'
@@ -156,7 +158,7 @@
self.assertRaises(exceptions.OverLimit, self.create_test_server)
@skip_because(bug="1186354",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_groups_exceed_limit(self):
# Negative test: Creation Security Groups over limit should FAIL
@@ -180,7 +182,7 @@
"sg-overlimit", "sg-desc")
@skip_because(bug="1186354",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_groups_rules_exceed_limit(self):
# Negative test: Creation of Security Group Rules should FAIL
diff --git a/tempest/api/compute/v3/admin/test_services.py b/tempest/api/compute/v3/admin/test_services.py
index 64135ed..602f914 100644
--- a/tempest/api/compute/v3/admin/test_services.py
+++ b/tempest/api/compute/v3/admin/test_services.py
@@ -17,7 +17,6 @@
# under the License.
from tempest.api.compute import base
-from tempest import exceptions
from tempest.test import attr
@@ -33,7 +32,6 @@
def setUpClass(cls):
super(ServicesAdminV3TestJSON, cls).setUpClass()
cls.client = cls.services_admin_client
- cls.non_admin_client = cls.services_client
@attr(type='gate')
def test_list_services(self):
@@ -41,11 +39,6 @@
self.assertEqual(200, resp.status)
self.assertNotEqual(0, len(services))
- @attr(type=['negative', 'gate'])
- def test_list_services_with_non_admin_user(self):
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.list_services)
-
@attr(type='gate')
def test_get_service_by_service_binary_name(self):
binary_name = 'nova-compute'
@@ -74,15 +67,6 @@
# on order.
self.assertEqual(sorted(s1), sorted(s2))
- @attr(type=['negative', 'gate'])
- def test_get_service_by_invalid_params(self):
- # return all services if send the request with invalid parameter
- resp, services = self.client.list_services()
- params = {'xxx': 'nova-compute'}
- resp, services_xxx = self.client.list_services(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(len(services), len(services_xxx))
-
@attr(type='gate')
def test_get_service_by_service_and_host_name(self):
resp, services = self.client.list_services()
@@ -95,24 +79,6 @@
self.assertEqual(host_name, services[0]['host'])
self.assertEqual(binary_name, services[0]['binary'])
- @attr(type=['negative', 'gate'])
- def test_get_service_by_invalid_service_and_valid_host(self):
- resp, services = self.client.list_services()
- host_name = services[0]['host']
- params = {'host': host_name, 'binary': 'xxx'}
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(0, len(services))
-
- @attr(type=['negative', 'gate'])
- def test_get_service_with_valid_service_and_invalid_host(self):
- resp, services = self.client.list_services()
- binary_name = services[0]['binary']
- params = {'host': 'xxx', 'binary': binary_name}
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(0, len(services))
-
class ServicesAdminV3TestXML(ServicesAdminV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_services_negative.py b/tempest/api/compute/v3/admin/test_services_negative.py
new file mode 100644
index 0000000..337c051
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_services_negative.py
@@ -0,0 +1,72 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 NEC Corporation
+# Copyright 2013 IBM Corp.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.compute import base
+from tempest import exceptions
+from tempest.test import attr
+
+
+class ServicesAdminNegativeV3TestJSON(base.BaseV3ComputeAdminTest):
+
+ """
+ Tests Services API. List and Enable/Disable require admin privileges.
+ """
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ServicesAdminNegativeV3TestJSON, cls).setUpClass()
+ cls.client = cls.services_admin_client
+ cls.non_admin_client = cls.services_client
+
+ @attr(type=['negative', 'gate'])
+ def test_list_services_with_non_admin_user(self):
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.list_services)
+
+ @attr(type=['negative', 'gate'])
+ def test_get_service_by_invalid_params(self):
+ # return all services if send the request with invalid parameter
+ resp, services = self.client.list_services()
+ params = {'xxx': 'nova-compute'}
+ resp, services_xxx = self.client.list_services(params)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(len(services), len(services_xxx))
+
+ @attr(type=['negative', 'gate'])
+ def test_get_service_by_invalid_service_and_valid_host(self):
+ resp, services = self.client.list_services()
+ host_name = services[0]['host']
+ params = {'host': host_name, 'binary': 'xxx'}
+ resp, services = self.client.list_services(params)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(0, len(services))
+
+ @attr(type=['negative', 'gate'])
+ def test_get_service_with_valid_service_and_invalid_host(self):
+ resp, services = self.client.list_services()
+ binary_name = services[0]['binary']
+ params = {'host': 'xxx', 'binary': binary_name}
+ resp, services = self.client.list_services(params)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(0, len(services))
+
+
+class ServicesAdminNegativeV3TestXML(ServicesAdminNegativeV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/certificates/__init__.py b/tempest/api/compute/v3/certificates/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api/compute/v3/certificates/__init__.py
diff --git a/tempest/api/compute/v3/certificates/test_certificates.py b/tempest/api/compute/v3/certificates/test_certificates.py
new file mode 100644
index 0000000..fa6f191
--- /dev/null
+++ b/tempest/api/compute/v3/certificates/test_certificates.py
@@ -0,0 +1,40 @@
+# 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.test import attr
+
+
+class CertificatesV3TestJSON(base.BaseV3ComputeTest):
+ _interface = 'json'
+
+ @attr(type='gate')
+ def test_create_and_get_root_certificate(self):
+ # create certificates
+ resp, create_body = self.certificates_client.create_certificate()
+ self.assertEqual(201, resp.status)
+ self.assertIn('data', create_body)
+ self.assertIn('private_key', create_body)
+ # get the root certificate
+ resp, body = self.certificates_client.get_certificate('root')
+ 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/keypairs/__init__.py b/tempest/api/compute/v3/keypairs/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api/compute/v3/keypairs/__init__.py
diff --git a/tempest/api/compute/v3/keypairs/test_keypairs.py b/tempest/api/compute/v3/keypairs/test_keypairs.py
new file mode 100644
index 0000000..029633f
--- /dev/null
+++ b/tempest/api/compute/v3/keypairs/test_keypairs.py
@@ -0,0 +1,124 @@
+# 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 test
+
+
+class KeyPairsV3TestJSON(base.BaseV3ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(KeyPairsV3TestJSON, cls).setUpClass()
+ cls.client = cls.keypairs_client
+
+ def _delete_keypair(self, keypair_name):
+ resp, _ = self.client.delete_keypair(keypair_name)
+ self.assertEqual(204, resp.status)
+
+ def _create_keypair(self, keypair_name, pub_key=None):
+ resp, body = self.client.create_keypair(keypair_name, pub_key)
+ self.addCleanup(self._delete_keypair, keypair_name)
+ return resp, body
+
+ @test.attr(type='gate')
+ def test_keypairs_create_list_delete(self):
+ # Keypairs created should be available in the response list
+ # Create 3 keypairs
+ key_list = list()
+ for i in range(3):
+ k_name = data_utils.rand_name('keypair-')
+ resp, keypair = self._create_keypair(k_name)
+ # Need to pop these keys so that our compare doesn't fail later,
+ # as the keypair dicts from list API doesn't have them.
+ keypair.pop('private_key')
+ keypair.pop('user_id')
+ self.assertEqual(201, resp.status)
+ key_list.append(keypair)
+ # Fetch all keypairs and verify the list
+ # has all created keypairs
+ resp, fetched_list = self.client.list_keypairs()
+ self.assertEqual(200, resp.status)
+ # We need to remove the extra 'keypair' element in the
+ # returned dict. See comment in keypairs_client.list_keypairs()
+ new_list = list()
+ for keypair in fetched_list:
+ new_list.append(keypair['keypair'])
+ fetched_list = new_list
+ # Now check if all the created keypairs are in the fetched list
+ missing_kps = [kp for kp in key_list if kp not in fetched_list]
+ self.assertFalse(missing_kps,
+ "Failed to find keypairs %s in fetched list"
+ % ', '.join(m_key['name'] for m_key in missing_kps))
+
+ @test.attr(type='gate')
+ def test_keypair_create_delete(self):
+ # Keypair should be created, verified and deleted
+ k_name = data_utils.rand_name('keypair-')
+ resp, keypair = self._create_keypair(k_name)
+ self.assertEqual(201, resp.status)
+ private_key = keypair['private_key']
+ key_name = keypair['name']
+ self.assertEqual(key_name, k_name,
+ "The created keypair name is not equal "
+ "to the requested name")
+ self.assertTrue(private_key is not None,
+ "Field private_key is empty or not found.")
+
+ @test.attr(type='gate')
+ def test_get_keypair_detail(self):
+ # Keypair should be created, Got details by name and deleted
+ k_name = data_utils.rand_name('keypair-')
+ resp, keypair = self._create_keypair(k_name)
+ resp, keypair_detail = self.client.get_keypair(k_name)
+ self.assertEqual(200, resp.status)
+ self.assertIn('name', keypair_detail)
+ self.assertIn('public_key', keypair_detail)
+ self.assertEqual(keypair_detail['name'], k_name,
+ "The created keypair name is not equal "
+ "to requested name")
+ public_key = keypair_detail['public_key']
+ self.assertTrue(public_key is not None,
+ "Field public_key is empty or not found.")
+
+ @test.attr(type='gate')
+ def test_keypair_create_with_pub_key(self):
+ # Keypair should be created with a given public key
+ k_name = data_utils.rand_name('keypair-')
+ pub_key = ("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCs"
+ "Ne3/1ILNCqFyfYWDeTKLD6jEXC2OQHLmietMWW+/vd"
+ "aZq7KZEwO0jhglaFjU1mpqq4Gz5RX156sCTNM9vRbw"
+ "KAxfsdF9laBYVsex3m3Wmui3uYrKyumsoJn2g9GNnG1P"
+ "I1mrVjZ61i0GY3khna+wzlTpCCmy5HNlrmbj3XLqBUpip"
+ "TOXmsnr4sChzC53KCd8LXuwc1i/CZPvF+3XipvAgFSE53pCt"
+ "LOeB1kYMOBaiUPLQTWXR3JpckqFIQwhIH0zoHlJvZE8hh90"
+ "XcPojYN56tI0OlrGqojbediJYD0rUsJu4weZpbn8vilb3JuDY+jws"
+ "snSA8wzBx3A/8y9Pp1B nova@ubuntu")
+ resp, keypair = self._create_keypair(k_name, pub_key)
+ self.assertEqual(201, resp.status)
+ self.assertFalse('private_key' in keypair,
+ "Field private_key is not empty!")
+ key_name = keypair['name']
+ 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
new file mode 100644
index 0000000..edc0c26
--- /dev/null
+++ b/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
@@ -0,0 +1,101 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012 OpenStack Foundation
+# Copyright 2013 IBM Corp
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class KeyPairsNegativeV3TestJSON(base.BaseV3ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(KeyPairsNegativeV3TestJSON, cls).setUpClass()
+ cls.client = cls.keypairs_client
+
+ def _create_keypair(self, keypair_name, pub_key=None):
+ self.client.create_keypair(keypair_name, pub_key)
+ self.addCleanup(self.client.delete_keypair, keypair_name)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_keypair_create_with_invalid_pub_key(self):
+ # Keypair should not be created with a non RSA public key
+ k_name = data_utils.rand_name('keypair-')
+ pub_key = "ssh-rsa JUNK nova@ubuntu"
+ self.assertRaises(exceptions.BadRequest,
+ 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-")
+ self.assertRaises(exceptions.NotFound, self.client.delete_keypair,
+ k_name)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_keypair_with_empty_public_key(self):
+ # Keypair should not be created with an empty public key
+ k_name = data_utils.rand_name("keypair-")
+ pub_key = ' '
+ self.assertRaises(exceptions.BadRequest, self._create_keypair,
+ k_name, pub_key)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_keypair_when_public_key_bits_exceeds_maximum(self):
+ # Keypair should not be created when public key bits are too long
+ k_name = data_utils.rand_name("keypair-")
+ pub_key = 'ssh-rsa ' + 'A' * 2048 + ' openstack@ubuntu'
+ self.assertRaises(exceptions.BadRequest, self._create_keypair,
+ k_name, pub_key)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_keypair_with_duplicate_name(self):
+ # Keypairs with duplicate names should not be created
+ k_name = data_utils.rand_name('keypair-')
+ resp, _ = self.client.create_keypair(k_name)
+ self.addCleanup(self.client.delete_keypair, k_name)
+ self.assertEqual(201, resp.status)
+ # Now try the same keyname to create another key
+ self.assertRaises(exceptions.Conflict, self._create_keypair,
+ k_name)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_keypair_with_empty_name_string(self):
+ # Keypairs with name being an empty string should not be created
+ self.assertRaises(exceptions.BadRequest, self._create_keypair,
+ '')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_keypair_with_long_keynames(self):
+ # Keypairs with name longer than 255 chars should not be created
+ k_name = 'keypair-'.ljust(260, '0')
+ self.assertRaises(exceptions.BadRequest, self._create_keypair,
+ k_name)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_keypair_invalid_name(self):
+ # Keypairs with name being an invalid name should not be created
+ 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 f208a4b..d12f708 100644
--- a/tempest/api/compute/v3/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/v3/servers/test_attach_interfaces.py
@@ -92,7 +92,7 @@
self.assertEqual(sorted(list1), sorted(list2))
- @attr(type='gate')
+ @attr(type='smoke')
def test_create_list_show_delete_interfaces(self):
server, ifs = self._create_server_get_interfaces()
interface_count = len(ifs)
diff --git a/tempest/api/compute/v3/servers/test_attach_volume.py b/tempest/api/compute/v3/servers/test_attach_volume.py
new file mode 100644
index 0000000..a030584
--- /dev/null
+++ b/tempest/api/compute/v3/servers/test_attach_volume.py
@@ -0,0 +1,120 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 IBM Corp.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import testtools
+
+from tempest.api.compute import base
+from tempest.common.utils.linux.remote_client import RemoteClient
+from tempest import config
+from tempest.test import attr
+
+CONF = config.CONF
+
+
+class AttachVolumeV3TestJSON(base.BaseV3ComputeTest):
+ _interface = 'json'
+ run_ssh = CONF.compute.run_ssh
+
+ def __init__(self, *args, **kwargs):
+ super(AttachVolumeV3TestJSON, self).__init__(*args, **kwargs)
+ self.server = None
+ self.volume = None
+ self.attached = False
+
+ @classmethod
+ def setUpClass(cls):
+ super(AttachVolumeV3TestJSON, cls).setUpClass()
+ cls.device = cls.config.compute.volume_device_name
+ if not cls.config.service_available.cinder:
+ skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ def _detach(self, server_id, volume_id):
+ if self.attached:
+ self.servers_client.detach_volume(server_id, volume_id)
+ self.volumes_client.wait_for_volume_status(volume_id, 'available')
+
+ def _delete_volume(self):
+ if self.volume:
+ self.volumes_client.delete_volume(self.volume['id'])
+ self.volume = None
+
+ def _create_and_attach(self):
+ # Start a server and wait for it to become ready
+ admin_pass = self.image_ssh_password
+ resp, server = self.create_test_server(wait_until='ACTIVE',
+ admin_password=admin_pass)
+ self.server = server
+
+ # Record addresses so that we can ssh later
+ resp, server['addresses'] = \
+ self.servers_client.list_addresses(server['id'])
+
+ # Create a volume and wait for it to become ready
+ resp, volume = self.volumes_client.create_volume(1,
+ display_name='test')
+ self.volume = volume
+ self.addCleanup(self._delete_volume)
+ self.volumes_client.wait_for_volume_status(volume['id'], 'available')
+
+ # Attach the volume to the server
+ self.servers_client.attach_volume(server['id'], volume['id'],
+ device='/dev/%s' % self.device)
+ self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
+
+ self.attached = True
+ self.addCleanup(self._detach, server['id'], volume['id'])
+
+ @testtools.skipIf(not run_ssh, 'SSH required for this test')
+ @attr(type='gate')
+ def test_attach_detach_volume(self):
+ # Stop and Start a server with an attached volume, ensuring that
+ # the volume remains attached.
+ self._create_and_attach()
+ server = self.server
+ volume = self.volume
+
+ self.servers_client.stop(server['id'])
+ self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')
+
+ self.servers_client.start(server['id'])
+ self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+
+ linux_client = RemoteClient(server,
+ self.image_ssh_user,
+ server['admin_password'])
+ partitions = linux_client.get_partitions()
+ self.assertIn(self.device, partitions)
+
+ self._detach(server['id'], volume['id'])
+ self.attached = False
+
+ self.servers_client.stop(server['id'])
+ self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')
+
+ self.servers_client.start(server['id'])
+ self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+
+ linux_client = RemoteClient(server,
+ self.image_ssh_user,
+ server['admin_password'])
+ partitions = linux_client.get_partitions()
+ self.assertNotIn(self.device, partitions)
+
+
+class AttachVolumeV3TestXML(AttachVolumeV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_create_server.py b/tempest/api/compute/v3/servers/test_create_server.py
index 24ade96..94175ab 100644
--- a/tempest/api/compute/v3/servers/test_create_server.py
+++ b/tempest/api/compute/v3/servers/test_create_server.py
@@ -20,17 +20,18 @@
import netaddr
import testtools
-from tempest.api import compute
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest.test import attr
+CONF = config.CONF
+
class ServersTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ run_ssh = CONF.compute.run_ssh
disk_config = 'AUTO'
@classmethod
@@ -120,7 +121,7 @@
@classmethod
def setUpClass(cls):
- if not compute.DISK_CONFIG_ENABLED:
+ if not CONF.compute_feature_enabled.disk_config:
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
super(ServersTestManualDisk, cls).setUpClass()
diff --git a/tempest/api/compute/v3/servers/test_list_server_filters.py b/tempest/api/compute/v3/servers/test_list_server_filters.py
index d333a1d..3dd7b0b 100644
--- a/tempest/api/compute/v3/servers/test_list_server_filters.py
+++ b/tempest/api/compute/v3/servers/test_list_server_filters.py
@@ -23,6 +23,8 @@
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class ListServerFiltersV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
@@ -211,7 +213,7 @@
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
@skip_because(bug="1182883",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type='gate')
def test_list_servers_filtered_by_ip_regex(self):
# Filter servers by regex ip
diff --git a/tempest/api/compute/v3/servers/test_server_actions.py b/tempest/api/compute/v3/servers/test_server_actions.py
index ee37502..8cd6c11 100644
--- a/tempest/api/compute/v3/servers/test_server_actions.py
+++ b/tempest/api/compute/v3/servers/test_server_actions.py
@@ -20,21 +20,21 @@
import testtools
-from tempest.api import compute
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest import exceptions
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class ServerActionsV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
- resize_available = tempest.config.TempestConfig().\
- compute_feature_enabled.resize
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ resize_available = CONF.compute_feature_enabled.resize
+ run_ssh = CONF.compute.run_ssh
def setUp(self):
# NOTE(afazekas): Normally we use the same server with all test cases,
@@ -53,7 +53,7 @@
cls.client = cls.servers_client
cls.server_id = cls.rebuild_server(None)
- @testtools.skipUnless(compute.CHANGE_PASSWORD_AVAILABLE,
+ @testtools.skipUnless(CONF.compute_feature_enabled.change_password,
'Change password not available.')
@attr(type='gate')
def test_change_server_password(self):
diff --git a/tempest/api/compute/v3/servers/test_servers_negative.py b/tempest/api/compute/v3/servers/test_servers_negative.py
index 8142250..6532032 100644
--- a/tempest/api/compute/v3/servers/test_servers_negative.py
+++ b/tempest/api/compute/v3/servers/test_servers_negative.py
@@ -17,13 +17,12 @@
import base64
import sys
-import uuid
from tempest.api.compute import base
from tempest import clients
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ServersNegativeTestJSON(base.BaseV2ComputeTest):
@@ -40,13 +39,12 @@
def setUpClass(cls):
super(ServersNegativeTestJSON, cls).setUpClass()
cls.client = cls.servers_client
- cls.img_client = cls.images_client
cls.alt_os = clients.AltManager()
cls.alt_client = cls.alt_os.servers_client
resp, server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_server_name_blank(self):
# Create a server with name parameter empty
@@ -54,7 +52,7 @@
self.create_test_server,
name='')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_personality_file_contents_not_encoded(self):
# Use an unencoded file when creating a server with personality
@@ -66,7 +64,7 @@
self.create_test_server,
personality=person)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_invalid_image(self):
# Create a server with an unknown image
@@ -74,7 +72,7 @@
self.create_test_server,
image_id=-1)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_invalid_flavor(self):
# Create a server with an unknown flavor
@@ -82,7 +80,7 @@
self.create_test_server,
flavor=-1,)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_invalid_access_ip_v4_address(self):
# An access IPv4 address must match a valid address pattern
@@ -90,7 +88,7 @@
self.assertRaises(exceptions.BadRequest,
self.create_test_server, accessIPv4=IPv4)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_invalid_ip_v6_address(self):
# An access IPv6 address must match a valid address pattern
@@ -99,34 +97,35 @@
self.assertRaises(exceptions.BadRequest,
self.create_test_server, accessIPv6=IPv6)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resize_nonexistent_server(self):
- nonexistent_server = str(uuid.uuid4())
+ # Resize a non-existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.resize,
nonexistent_server, self.flavor_ref)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resize_server_with_non_existent_flavor(self):
# Resize a server with non-existent flavor
- nonexistent_flavor = str(uuid.uuid4())
+ nonexistent_flavor = data_utils.rand_uuid()
self.assertRaises(exceptions.BadRequest, self.client.resize,
self.server_id, flavor_ref=nonexistent_flavor)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resize_server_with_null_flavor(self):
# Resize a server with null flavor
self.assertRaises(exceptions.BadRequest, self.client.resize,
self.server_id, flavor_ref="")
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_reboot_non_existent_server(self):
# Reboot a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.reboot,
nonexistent_server, 'SOFT')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_pause_paused_server(self):
# Pause a paused server.
self.client.pause_server(self.server_id)
@@ -137,7 +136,7 @@
self.client.pause_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_rebuild_reboot_deleted_server(self):
# Rebuild and Reboot a deleted server
_, server = self.create_test_server()
@@ -150,10 +149,10 @@
self.assertRaises(exceptions.NotFound, self.client.reboot,
server['id'], 'SOFT')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_rebuild_non_existent_server(self):
# Rebuild a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
meta = {'rebuild': 'server'}
new_name = data_utils.rand_name('server')
file_contents = 'Test server rebuild.'
@@ -167,7 +166,7 @@
personality=personality,
adminPass='rebuild')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_numeric_server_name(self):
# Create a server with a numeric name
if self.__class__._interface == "xml":
@@ -178,7 +177,7 @@
self.create_test_server,
name=server_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_server_name_length_exceeds_256(self):
# Create a server with name length exceeding 256 characters
@@ -187,7 +186,7 @@
self.create_test_server,
name=server_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_invalid_network_uuid(self):
# Pass invalid network uuid while creating a server
@@ -197,7 +196,7 @@
self.create_test_server,
networks=networks)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_non_existant_keypair(self):
# Pass a non-existent keypair while creating a server
@@ -206,7 +205,7 @@
self.create_test_server,
key_name=key_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_server_metadata_exceeds_length_limit(self):
# Pass really long metadata while creating a server
@@ -215,7 +214,7 @@
self.create_test_server,
meta=metadata)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_name_of_non_existent_server(self):
# Update name of a non-existent server
@@ -225,7 +224,7 @@
self.assertRaises(exceptions.NotFound, self.client.update_server,
server_name, name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_server_set_empty_name(self):
# Update name of the server to an empty string
@@ -235,7 +234,7 @@
self.assertRaises(exceptions.BadRequest, self.client.update_server,
server_name, name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_server_of_another_tenant(self):
# Update name of a server that belongs to another tenant
@@ -244,7 +243,7 @@
self.alt_client.update_server, self.server_id,
name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_server_name_length_exceeds_256(self):
# Update name of server exceed the name length limit
@@ -254,34 +253,35 @@
self.server_id,
name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_non_existent_server(self):
# Delete a non existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.delete_server,
- '999erra43')
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_a_server_of_another_tenant(self):
# Delete a server that belongs to another tenant
self.assertRaises(exceptions.NotFound,
self.alt_client.delete_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_server_pass_negative_id(self):
# Pass an invalid string parameter to delete server
self.assertRaises(exceptions.NotFound, self.client.delete_server, -1)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_server_pass_id_exceeding_length_limit(self):
# Pass a server ID that exceeds length limit to delete server
self.assertRaises(exceptions.NotFound, self.client.delete_server,
sys.maxint + 1)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_nonexistent_security_group(self):
# Create a server with a nonexistent security group
@@ -290,49 +290,49 @@
self.create_test_server,
security_groups=security_groups)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_non_existent_server(self):
# Get a non existent server details
-
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.get_server,
- '999erra43')
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_stop_non_existent_server(self):
# Stop a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.servers_client.stop,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_pause_non_existent_server(self):
# pause a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.pause_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unpause_non_existent_server(self):
# unpause a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.unpause_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unpause_server_invalid_state(self):
# unpause an active server.
self.assertRaises(exceptions.Conflict,
self.client.unpause_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_suspend_non_existent_server(self):
# suspend a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.suspend_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_suspend_server_invalid_state(self):
# suspend a suspended server.
resp, _ = self.client.suspend_server(self.server_id)
@@ -344,66 +344,66 @@
self.client.suspend_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resume_non_existent_server(self):
# resume a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.resume_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resume_server_invalid_state(self):
# resume an active server.
self.assertRaises(exceptions.Conflict,
self.client.resume_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_console_output_of_non_existent_server(self):
# get the console output for a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.get_console_output,
nonexistent_server, 10)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_force_delete_nonexistent_server_id(self):
- non_existent_server_id = str(uuid.uuid4())
-
+ # force-delete a non existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.force_delete_server,
- non_existent_server_id)
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_force_delete_server_invalid_state(self):
# we can only force-delete a server in 'soft-delete' state
self.assertRaises(exceptions.Conflict,
self.client.force_delete_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_restore_nonexistent_server_id(self):
- non_existent_server_id = str(uuid.uuid4())
-
+ # restore-delete a non existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.restore_soft_deleted_server,
- non_existent_server_id)
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_restore_server_invalid_state(self):
# we can only restore-delete a server in 'soft-delete' state
self.assertRaises(exceptions.Conflict,
self.client.restore_soft_deleted_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_shelve_non_existent_server(self):
# shelve a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.shelve_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_shelve_shelved_server(self):
# shelve a shelved server.
resp, server = self.client.shelve_server(self.server_id)
@@ -430,14 +430,14 @@
self.client.shelve_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unshelve_non_existent_server(self):
# unshelve a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.unshelve_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unshelve_server_invalid_state(self):
# unshelve an active server.
self.assertRaises(exceptions.Conflict,
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index 660de95..c1ebc08 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -19,13 +19,15 @@
from tempest.api.compute import base
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest.test import attr
+CONF = config.CONF
+
class AttachVolumeTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ run_ssh = CONF.compute.run_ssh
def __init__(self, *args, **kwargs):
super(AttachVolumeTestJSON, self).__init__(*args, **kwargs)
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index 6408c15..090f31f 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -25,7 +25,6 @@
class BasicOperationsImagesTest(base.BaseV2ImageTest):
-
"""
Here we test the basic operations of images
"""
@@ -95,7 +94,6 @@
class ListImagesTest(base.BaseV2ImageTest):
-
"""
Here we test the listing of image information
"""
@@ -105,31 +103,114 @@
super(ListImagesTest, cls).setUpClass()
# We add a few images here to test the listing functionality of
# the images API
- for x in xrange(0, 10):
- cls._create_standard_image(x)
+ cls._create_standard_image('bare', 'raw')
+ cls._create_standard_image('bare', 'raw')
+ cls._create_standard_image('ami', 'raw')
+ # Add some more for listing
+ cls._create_standard_image('ami', 'ami')
+ cls._create_standard_image('ari', 'ari')
+ cls._create_standard_image('aki', 'aki')
@classmethod
- def _create_standard_image(cls, number):
+ def _create_standard_image(cls, container_format, disk_format):
"""
Create a new standard image and return the ID of the newly-registered
image. Note that the size of the new image is a random number between
1024 and 4096
"""
image_file = StringIO.StringIO('*' * random.randint(1024, 4096))
- name = 'New Standard Image %s' % number
- resp, body = cls.create_image(name=name, container_format='bare',
- disk_format='raw',
+ name = data_utils.rand_name('image-')
+ resp, body = cls.create_image(name=name,
+ container_format=container_format,
+ disk_format=disk_format,
visibility='public')
image_id = body['id']
resp, body = cls.client.store_image(image_id, data=image_file)
return image_id
+ def _list_by_param_value_and_assert(self, params):
+ """
+ Perform list action with given params and validates result.
+ """
+ resp, images_list = self.client.image_list(params=params)
+ self.assertEqual(200, resp.status)
+ # Validating params of fetched images
+ for image in images_list:
+ for key in params:
+ msg = "Failed to list images by %s" % key
+ self.assertEqual(params[key], image[key], msg)
+
@attr(type='gate')
def test_index_no_params(self):
# Simple test to see all fixture images returned
resp, images_list = self.client.image_list()
self.assertEqual(resp['status'], '200')
image_list = map(lambda x: x['id'], images_list)
+
for image in self.created_images:
self.assertIn(image, image_list)
+
+ @attr(type='gate')
+ def test_list_images_param_container_format(self):
+ # Test to get all images with container_format='bare'
+ params = {"container_format": "bare"}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_list_images_param_disk_format(self):
+ # Test to get all images with disk_format = raw
+ params = {"disk_format": "raw"}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_list_images_param_visibility(self):
+ # Test to get all images with visibility = public
+ params = {"visibility": "public"}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_list_images_param_size(self):
+ # Test to get all images by size
+ image_id = self.created_images[1]
+ # Get image metadata
+ resp, image = self.client.get_image(image_id)
+ self.assertEqual(resp['status'], '200')
+
+ params = {"size": image['size']}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_list_images_param_min_max_size(self):
+ # Test to get all images with size between 2000 to 3000
+ image_id = self.created_images[1]
+ # Get image metadata
+ resp, image = self.client.get_image(image_id)
+ self.assertEqual(resp['status'], '200')
+
+ size = image['size']
+ params = {"size_min": size - 500, "size_max": size + 500}
+ resp, images_list = self.client.image_list(params=params)
+ self.assertEqual(resp['status'], '200')
+ image_size_list = map(lambda x: x['size'], images_list)
+
+ for image_size in image_size_list:
+ self.assertTrue(image_size >= params['size_min'] and
+ image_size <= params['size_max'],
+ "Failed to get images by size_min and size_max")
+
+ @attr(type='gate')
+ def test_list_images_param_status(self):
+ # Test to get all available images
+ params = {"status": "available"}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_list_images_param_limit(self):
+ # Test to get images by limit
+ params = {"limit": 2}
+ resp, images_list = self.client.image_list(params=params)
+ self.assertEqual(resp['status'], '200')
+
+ self.assertEqual(len(images_list), params['limit'],
+ "Failed to get images by limit")
diff --git a/tempest/api/network/common.py b/tempest/api/network/common.py
index 528a204..ae0eda1 100644
--- a/tempest/api/network/common.py
+++ b/tempest/api/network/common.py
@@ -102,8 +102,7 @@
self.floating_ip_address)
def __str__(self):
- return '<"FloatingIP" addr="%s" id="%s">' % (self.__class__.__name__,
- self.floating_ip_address,
+ return '<"FloatingIP" addr="%s" id="%s">' % (self.floating_ip_address,
self.id)
def delete(self):
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index 3a41f4f..7ce8ca6 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -25,7 +25,7 @@
"""
Tests the following operations in the Quantum API using the REST client for
- Quantum:
+ Neutron:
Create a Floating IP
Update a Floating IP
@@ -33,7 +33,7 @@
List all Floating IPs
Show Floating IP details
- v2.0 of the Quantum API is assumed. It is also assumed that the following
+ v2.0 of the Neutron API is assumed. It is also assumed that the following
options are defined in the [network] section of etc/tempest.conf:
public_network_id which is the id for the external network present
@@ -47,24 +47,13 @@
# Create network, subnet, router and add interface
cls.network = cls.create_network()
cls.subnet = cls.create_subnet(cls.network)
- cls.router = cls.create_router(
- data_utils.rand_name('router-'),
- external_network_id=cls.network_cfg.public_network_id)
- resp, _ = cls.client.add_router_interface_with_subnet_id(
- cls.router['id'], cls.subnet['id'])
+ cls.router = cls.create_router(data_utils.rand_name('router-'),
+ external_network_id=cls.ext_net_id)
+ cls.create_router_interface(cls.router['id'], cls.subnet['id'])
cls.port = list()
# Create two ports one each for Creation and Updating of floatingIP
for i in range(2):
- resp, port = cls.client.create_port(cls.network['id'])
- cls.port.append(port['port'])
-
- @classmethod
- def tearDownClass(cls):
- cls.client.remove_router_interface_with_subnet_id(cls.router['id'],
- cls.subnet['id'])
- for i in range(2):
- cls.client.delete_port(cls.port[i]['id'])
- super(FloatingIPTestJSON, cls).tearDownClass()
+ cls.create_port(cls.network)
def _delete_floating_ip(self, floating_ip_id):
# Deletes a floating IP and verifies if it is deleted or not
@@ -81,29 +70,29 @@
def test_create_list_show_update_delete_floating_ip(self):
# Creates a floating IP
resp, floating_ip = self.client.create_floating_ip(
- self.ext_net_id, port_id=self.port[0]['id'])
+ self.ext_net_id, port_id=self.ports[0]['id'])
self.assertEqual('201', resp['status'])
- create_floating_ip = floating_ip['floatingip']
- self.assertIsNotNone(create_floating_ip['id'])
- self.assertIsNotNone(create_floating_ip['tenant_id'])
- self.assertIsNotNone(create_floating_ip['floating_ip_address'])
- self.assertEqual(create_floating_ip['port_id'], self.port[0]['id'])
- self.assertEqual(create_floating_ip['floating_network_id'],
+ created_floating_ip = floating_ip['floatingip']
+ self.assertIsNotNone(created_floating_ip['id'])
+ self.assertIsNotNone(created_floating_ip['tenant_id'])
+ self.assertIsNotNone(created_floating_ip['floating_ip_address'])
+ self.assertEqual(created_floating_ip['port_id'], self.ports[0]['id'])
+ self.assertEqual(created_floating_ip['floating_network_id'],
self.ext_net_id)
- self.addCleanup(self._delete_floating_ip, create_floating_ip['id'])
+ self.addCleanup(self._delete_floating_ip, created_floating_ip['id'])
# Verifies the details of a floating_ip
resp, floating_ip = self.client.show_floating_ip(
- create_floating_ip['id'])
+ created_floating_ip['id'])
self.assertEqual('200', resp['status'])
- show_floating_ip = floating_ip['floatingip']
- self.assertEqual(show_floating_ip['id'], create_floating_ip['id'])
- self.assertEqual(show_floating_ip['floating_network_id'],
+ shown_floating_ip = floating_ip['floatingip']
+ self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
+ self.assertEqual(shown_floating_ip['floating_network_id'],
self.ext_net_id)
- self.assertEqual(show_floating_ip['tenant_id'],
- create_floating_ip['tenant_id'])
- self.assertEqual(show_floating_ip['floating_ip_address'],
- create_floating_ip['floating_ip_address'])
- self.assertEqual(show_floating_ip['port_id'], self.port[0]['id'])
+ self.assertEqual(shown_floating_ip['tenant_id'],
+ created_floating_ip['tenant_id'])
+ self.assertEqual(shown_floating_ip['floating_ip_address'],
+ created_floating_ip['floating_ip_address'])
+ self.assertEqual(shown_floating_ip['port_id'], self.ports[0]['id'])
# Verify the floating ip exists in the list of all floating_ips
resp, floating_ips = self.client.list_floatingips()
@@ -111,25 +100,25 @@
floatingip_id_list = list()
for f in floating_ips['floatingips']:
floatingip_id_list.append(f['id'])
- self.assertIn(create_floating_ip['id'], floatingip_id_list)
-
+ self.assertIn(created_floating_ip['id'], floatingip_id_list)
# Associate floating IP to the other port
resp, floating_ip = self.client.update_floating_ip(
- create_floating_ip['id'], port_id=self.port[1]['id'])
+ created_floating_ip['id'], port_id=self.ports[1]['id'])
self.assertEqual('200', resp['status'])
- update_floating_ip = floating_ip['floatingip']
- self.assertEqual(update_floating_ip['port_id'], self.port[1]['id'])
- self.assertIsNotNone(update_floating_ip['fixed_ip_address'])
- self.assertEqual(update_floating_ip['router_id'], self.router['id'])
+ updated_floating_ip = floating_ip['floatingip']
+ self.assertEqual(updated_floating_ip['port_id'], self.ports[1]['id'])
+ self.assertEqual(updated_floating_ip['fixed_ip_address'],
+ self.ports[1]['fixed_ips'][0]['ip_address'])
+ self.assertEqual(updated_floating_ip['router_id'], self.router['id'])
# Disassociate floating IP from the port
resp, floating_ip = self.client.update_floating_ip(
- create_floating_ip['id'], port_id=None)
+ created_floating_ip['id'], port_id=None)
self.assertEqual('200', resp['status'])
- update_floating_ip = floating_ip['floatingip']
- self.assertIsNone(update_floating_ip['port_id'])
- self.assertIsNone(update_floating_ip['fixed_ip_address'])
- self.assertIsNone(update_floating_ip['router_id'])
+ updated_floating_ip = floating_ip['floatingip']
+ self.assertIsNone(updated_floating_ip['port_id'])
+ self.assertIsNone(updated_floating_ip['fixed_ip_address'])
+ self.assertIsNone(updated_floating_ip['router_id'])
class FloatingIPTestXML(FloatingIPTestJSON):
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index 14c8500..68ca66a 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -184,24 +184,6 @@
found = n['id']
self.assertIsNotNone(found, "Port list doesn't contain created port")
- @attr(type=['negative', 'smoke'])
- def test_show_non_existent_network(self):
- non_exist_id = data_utils.rand_name('network')
- self.assertRaises(exceptions.NotFound, self.client.show_network,
- non_exist_id)
-
- @attr(type=['negative', 'smoke'])
- def test_show_non_existent_subnet(self):
- non_exist_id = data_utils.rand_name('subnet')
- self.assertRaises(exceptions.NotFound, self.client.show_subnet,
- non_exist_id)
-
- @attr(type=['negative', 'smoke'])
- def test_show_non_existent_port(self):
- non_exist_id = data_utils.rand_name('port')
- self.assertRaises(exceptions.NotFound, self.client.show_port,
- non_exist_id)
-
class NetworksTestXML(NetworksTestJSON):
_interface = 'xml'
diff --git a/tempest/api/network/test_networks_negative.py b/tempest/api/network/test_networks_negative.py
new file mode 100644
index 0000000..6820c25
--- /dev/null
+++ b/tempest/api/network/test_networks_negative.py
@@ -0,0 +1,60 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 Huawei Technologies Co.,LTD.
+# 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.network import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest.test import attr
+
+
+class NetworksNegativeTestJSON(base.BaseNetworkTest):
+ _interface = 'json'
+
+ @attr(type=['negative', 'smoke'])
+ def test_show_non_existent_network(self):
+ non_exist_id = data_utils.rand_name('network')
+ self.assertRaises(exceptions.NotFound, self.client.show_network,
+ non_exist_id)
+
+ @attr(type=['negative', 'smoke'])
+ def test_show_non_existent_subnet(self):
+ non_exist_id = data_utils.rand_name('subnet')
+ self.assertRaises(exceptions.NotFound, self.client.show_subnet,
+ non_exist_id)
+
+ @attr(type=['negative', 'smoke'])
+ def test_show_non_existent_port(self):
+ non_exist_id = data_utils.rand_name('port')
+ self.assertRaises(exceptions.NotFound, self.client.show_port,
+ non_exist_id)
+
+ @attr(type=['negative', 'smoke'])
+ 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")
+
+ @attr(type=['negative', 'smoke'])
+ def test_delete_non_existent_network(self):
+ non_exist_id = data_utils.rand_name('network')
+ self.assertRaises(exceptions.NotFound, self.client.delete_network,
+ non_exist_id)
+
+
+class NetworksNegativeTestXML(NetworksNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index 06e07bb..21934f2 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -19,7 +19,7 @@
from tempest.api.network import base
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
class RoutersTest(base.BaseAdminNetworkTest):
@@ -54,7 +54,7 @@
router_id, port_id)
self.assertEqual('200', resp['status'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_show_list_update_delete_router(self):
# Create a router
# NOTE(salv-orlando): Do not invoke self.create_router
@@ -97,7 +97,7 @@
create_body['router']['id'])
self.assertEqual(show_body['router']['name'], updated_name)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_add_remove_router_interface_with_subnet_id(self):
network = self.create_network()
subnet = self.create_subnet(network)
@@ -116,7 +116,7 @@
self.assertEqual(show_port_body['port']['device_id'],
router['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_add_remove_router_interface_with_port_id(self):
network = self.create_network()
self.create_subnet(network)
@@ -160,7 +160,7 @@
public_subnet_id = public_net_body['network']['subnets'][0]
self.assertEqual(fixed_ips[0]['subnet_id'], public_subnet_id)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_router_set_gateway(self):
router = self.create_router(data_utils.rand_name('router-'))
self.client.update_router(
@@ -175,7 +175,7 @@
{'network_id': self.network_cfg.public_network_id})
self._verify_gateway_port(router['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_router_set_gateway_with_snat_explicit(self):
router = self.create_router(data_utils.rand_name('router-'))
self.admin_client.update_router_with_snat_gw_info(
@@ -189,7 +189,7 @@
'enable_snat': True})
self._verify_gateway_port(router['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_router_set_gateway_without_snat(self):
router = self.create_router(data_utils.rand_name('router-'))
self.admin_client.update_router_with_snat_gw_info(
@@ -203,7 +203,7 @@
'enable_snat': False})
self._verify_gateway_port(router['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_router_unset_gateway(self):
router = self.create_router(
data_utils.rand_name('router-'),
@@ -216,7 +216,7 @@
device_id=router['id'])
self.assertFalse(list_body['ports'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_router_reset_gateway_without_snat(self):
router = self.create_router(
data_utils.rand_name('router-'),
@@ -232,7 +232,8 @@
'enable_snat': False})
self._verify_gateway_port(router['id'])
- @attr(type='smoke')
+ @test.requires_ext(extension='extraroute', service='network')
+ @test.attr(type='smoke')
def test_update_extra_route(self):
self.network = self.create_network()
self.name = self.network['name']
diff --git a/tempest/api/network/test_service_type_management.py b/tempest/api/network/test_service_type_management.py
index ae03e96..da6800b 100644
--- a/tempest/api/network/test_service_type_management.py
+++ b/tempest/api/network/test_service_type_management.py
@@ -13,13 +13,20 @@
# under the License.
from tempest.api.network import base
-from tempest.test import attr
+from tempest import test
class ServiceTypeManagementTestJSON(base.BaseNetworkTest):
_interface = 'json'
- @attr(type='smoke')
+ @classmethod
+ def setUpClass(cls):
+ super(ServiceTypeManagementTestJSON, cls).setUpClass()
+ if not test.is_extension_enabled('service-type', 'network'):
+ msg = "Neutron Service Type Management not enabled."
+ raise cls.skipException(msg)
+
+ @test.attr(type='smoke')
def test_service_provider_list(self):
resp, body = self.client.list_service_providers()
self.assertEqual(resp['status'], '200')
diff --git a/tempest/api/object_storage/test_account_quotas.py b/tempest/api/object_storage/test_account_quotas.py
index c1b3391..ac1c7d1 100644
--- a/tempest/api/object_storage/test_account_quotas.py
+++ b/tempest/api/object_storage/test_account_quotas.py
@@ -23,10 +23,12 @@
from tempest import exceptions
from tempest.test import attr
+CONF = config.CONF
+
class AccountQuotasTest(base.BaseObjectTest):
accounts_quotas_available = \
- config.TempestConfig().object_storage_feature_enabled.accounts_quotas
+ CONF.object_storage_feature_enabled.accounts_quotas
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/object_storage/test_container_quotas.py b/tempest/api/object_storage/test_container_quotas.py
index c7b5e28..513d24a 100644
--- a/tempest/api/object_storage/test_container_quotas.py
+++ b/tempest/api/object_storage/test_container_quotas.py
@@ -24,6 +24,7 @@
from tempest.test import attr
from tempest.test import HTTP_SUCCESS
+CONF = config.CONF
QUOTA_BYTES = 10
QUOTA_COUNT = 3
SKIP_MSG = "Container quotas middleware not available."
@@ -32,7 +33,7 @@
class ContainerQuotasTest(base.BaseObjectTest):
"""Attemps to test the perfect behavior of quotas in a container."""
container_quotas_available = \
- config.TempestConfig().object_storage_feature_enabled.container_quotas
+ CONF.object_storage_feature_enabled.container_quotas
def setUp(self):
"""Creates and sets a container with quotas.
diff --git a/tempest/api/object_storage/test_crossdomain.py b/tempest/api/object_storage/test_crossdomain.py
index 51ecd16..41430c8 100644
--- a/tempest/api/object_storage/test_crossdomain.py
+++ b/tempest/api/object_storage/test_crossdomain.py
@@ -23,10 +23,12 @@
from tempest.test import attr
from tempest.test import HTTP_SUCCESS
+CONF = config.CONF
+
class CrossdomainTest(base.BaseObjectTest):
crossdomain_available = \
- config.TempestConfig().object_storage_feature_enabled.crossdomain
+ CONF.object_storage_feature_enabled.crossdomain
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/object_storage/test_object_temp_url.py b/tempest/api/object_storage/test_object_temp_url.py
index bb03932..9d5a1c0 100644
--- a/tempest/api/object_storage/test_object_temp_url.py
+++ b/tempest/api/object_storage/test_object_temp_url.py
@@ -27,11 +27,13 @@
from tempest.test import attr
from tempest.test import HTTP_SUCCESS
+CONF = config.CONF
+
class ObjectTempUrlTest(base.BaseObjectTest):
tempurl_available = \
- config.TempestConfig().object_storage_feature_enabled.tempurl
+ CONF.object_storage_feature_enabled.tempurl
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/orchestration/stacks/test_non_empty_stack.py b/tempest/api/orchestration/stacks/test_non_empty_stack.py
index b19344d..eead234 100644
--- a/tempest/api/orchestration/stacks/test_non_empty_stack.py
+++ b/tempest/api/orchestration/stacks/test_non_empty_stack.py
@@ -78,6 +78,10 @@
cls.resource_type = 'AWS::AutoScaling::LaunchConfiguration'
cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
+ def assert_fields_in_dict(self, obj, *fields):
+ for field in fields:
+ self.assertIn(field, obj)
+
@attr(type='gate')
def test_stack_list(self):
"""Created stack should be on the list of existing stacks."""
@@ -93,8 +97,19 @@
resp, stack = self.client.get_stack(self.stack_name)
self.assertEqual('200', resp['status'])
self.assertIsInstance(stack, dict)
+ self.assert_fields_in_dict(stack, 'stack_name', 'id', 'links',
+ 'parameters', 'outputs', 'disable_rollback',
+ 'stack_status_reason', 'stack_status',
+ 'creation_time', 'updated_time',
+ 'capabilities', 'notification_topics',
+ 'timeout_mins', 'template_description')
+ self.assert_fields_in_dict(stack['parameters'], 'AWS::StackId',
+ 'trigger', 'AWS::Region', 'AWS::StackName')
+ self.assertEqual(True, stack['disable_rollback'],
+ 'disable_rollback should default to True')
self.assertEqual(self.stack_name, stack['stack_name'])
self.assertEqual(self.stack_id, stack['id'])
+ self.assertEqual('fluffy', stack['outputs'][0]['output_key'])
@attr(type='gate')
def test_list_resources(self):
@@ -103,6 +118,11 @@
resp, resources = self.client.list_resources(self.stack_identifier)
self.assertEqual('200', resp['status'])
self.assertIsInstance(resources, list)
+ for res in resources:
+ self.assert_fields_in_dict(res, 'logical_resource_id',
+ 'resource_type', 'resource_status',
+ 'updated_time')
+
resources_names = map(lambda resource: resource['logical_resource_id'],
resources)
self.assertIn(self.resource_name, resources_names)
@@ -116,6 +136,11 @@
resp, resource = self.client.get_resource(self.stack_identifier,
self.resource_name)
self.assertIsInstance(resource, dict)
+ self.assert_fields_in_dict(resource, 'resource_name', 'description',
+ 'links', 'logical_resource_id',
+ 'resource_status', 'updated_time',
+ 'required_by', 'resource_status_reason',
+ 'physical_resource_id', 'resource_type')
self.assertEqual(self.resource_name, resource['logical_resource_id'])
self.assertEqual(self.resource_type, resource['resource_type'])
@@ -135,6 +160,12 @@
resp, events = self.client.list_events(self.stack_identifier)
self.assertEqual('200', resp['status'])
self.assertIsInstance(events, list)
+
+ for event in events:
+ self.assert_fields_in_dict(event, 'logical_resource_id', 'id',
+ 'resource_status_reason',
+ 'resource_status', 'event_time')
+
resource_statuses = map(lambda event: event['resource_status'], events)
self.assertIn('CREATE_IN_PROGRESS', resource_statuses)
self.assertIn('CREATE_COMPLETE', resource_statuses)
@@ -151,6 +182,11 @@
self.resource_name, event_id)
self.assertEqual('200', resp['status'])
self.assertIsInstance(event, dict)
+ self.assert_fields_in_dict(event, 'resource_name', 'event_time',
+ 'links', 'logical_resource_id',
+ 'resource_status', 'resource_status_reason',
+ 'physical_resource_id', 'id',
+ 'resource_properties', 'resource_type')
self.assertEqual(self.resource_name, event['resource_name'])
self.assertEqual('state changed', event['resource_status_reason'])
self.assertEqual(self.resource_name, event['logical_resource_id'])
diff --git a/tempest/api/orchestration/stacks/test_server_cfn_init.py b/tempest/api/orchestration/stacks/test_server_cfn_init.py
index 0480570..6fbbb5b 100644
--- a/tempest/api/orchestration/stacks/test_server_cfn_init.py
+++ b/tempest/api/orchestration/stacks/test_server_cfn_init.py
@@ -18,18 +18,17 @@
from tempest.api.orchestration import base
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest.openstack.common import log as logging
from tempest.test import attr
-
+CONF = config.CONF
LOG = logging.getLogger(__name__)
class ServerCfnInitTestJSON(base.BaseOrchestrationTest):
_interface = 'json'
- existing_keypair = (tempest.config.TempestConfig().
- orchestration.keypair_name is not None)
+ existing_keypair = CONF.orchestration.keypair_name is not None
template = """
HeatTemplateFormatVersion: '2012-12-12'
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 465f570..ba99309 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -42,6 +42,7 @@
cls.volumes_client = os.volumes_client
cls.snapshots_client = os.snapshots_client
cls.servers_client = os.servers_client
+ cls.volumes_extension_client = 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
diff --git a/tempest/api/volume/test_extensions.py b/tempest/api/volume/test_extensions.py
new file mode 100644
index 0000000..90988a2
--- /dev/null
+++ b/tempest/api/volume/test_extensions.py
@@ -0,0 +1,43 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 IBM Corp.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+from tempest.api.volume import base
+from tempest.test import attr
+
+
+class ExtensionsTestJSON(base.BaseVolumeTest):
+ _interface = 'json'
+
+ @attr(type='gate')
+ def test_list_extensions(self):
+ # List of all extensions
+ resp, extensions = self.volumes_extension_client.list_extensions()
+ self.assertEqual(200, resp.status)
+ if len(self.config.volume_feature_enabled.api_extensions) == 0:
+ raise self.skipException('There are not any extensions configured')
+ ext = self.config.volume_feature_enabled.api_extensions[0]
+ if ext == 'all':
+ self.assertIn('Hosts', map(lambda x: x['name'], extensions))
+ elif ext:
+ self.assertIn(ext, map(lambda x: x['name'], extensions))
+ else:
+ raise self.skipException('There are not any extensions configured')
+
+
+class ExtensionsTestXML(ExtensionsTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/volume/test_volumes_list.py b/tempest/api/volume/test_volumes_list.py
index def330e..3c66eb8 100644
--- a/tempest/api/volume/test_volumes_list.py
+++ b/tempest/api/volume/test_volumes_list.py
@@ -15,6 +15,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
+import operator
from tempest.api.volume import base
from tempest.common.utils import data_utils
@@ -23,6 +24,8 @@
LOG = logging.getLogger(__name__)
+VOLUME_FIELDS = ('id', 'display_name')
+
class VolumesListTest(base.BaseVolumeTest):
@@ -36,7 +39,11 @@
_interface = 'json'
- def assertVolumesIn(self, fetched_list, expected_list):
+ def assertVolumesIn(self, fetched_list, expected_list, fields=None):
+ if fields:
+ expected_list = map(operator.itemgetter(*fields), expected_list)
+ fetched_list = map(operator.itemgetter(*fields), fetched_list)
+
missing_vols = [v for v in expected_list if v not in fetched_list]
if len(missing_vols) == 0:
return
@@ -113,7 +120,8 @@
# Fetch all volumes
resp, fetched_list = self.client.list_volumes()
self.assertEqual(200, resp.status)
- self.assertVolumesIn(fetched_list, self.volume_list)
+ self.assertVolumesIn(fetched_list, self.volume_list,
+ fields=VOLUME_FIELDS)
@attr(type='gate')
def test_volume_list_with_details(self):
@@ -150,7 +158,8 @@
self.assertEqual(200, resp.status)
for volume in fetched_list:
self.assertEqual('available', volume['status'])
- self.assertVolumesIn(fetched_list, self.volume_list)
+ self.assertVolumesIn(fetched_list, self.volume_list,
+ fields=VOLUME_FIELDS)
@attr(type='gate')
def test_volumes_list_details_by_status(self):
@@ -170,7 +179,8 @@
self.assertEqual(200, resp.status)
for volume in fetched_list:
self.assertEqual(zone, volume['availability_zone'])
- self.assertVolumesIn(fetched_list, self.volume_list)
+ self.assertVolumesIn(fetched_list, self.volume_list,
+ fields=VOLUME_FIELDS)
@attr(type='gate')
def test_volumes_list_details_by_availability_zone(self):
diff --git a/tempest/clients.py b/tempest/clients.py
index fe5ed74..a38f915 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -52,12 +52,16 @@
VolumesExtensionsClientJSON
from tempest.services.compute.v3.json.availability_zone_client import \
AvailabilityZoneV3ClientJSON
+from tempest.services.compute.v3.json.certificates_client import \
+ CertificatesV3ClientJSON
from tempest.services.compute.v3.json.extensions_client import \
ExtensionsV3ClientJSON
from tempest.services.compute.v3.json.hypervisor_client import \
HypervisorV3ClientJSON
from tempest.services.compute.v3.json.interfaces_client import \
InterfacesV3ClientJSON
+from tempest.services.compute.v3.json.keypairs_client import \
+ KeyPairsV3ClientJSON
from tempest.services.compute.v3.json.servers_client import \
ServersV3ClientJSON
from tempest.services.compute.v3.json.services_client import \
@@ -66,12 +70,15 @@
TenantUsagesV3ClientJSON
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.hypervisor_client import \
HypervisorV3ClientXML
from tempest.services.compute.v3.xml.interfaces_client import \
InterfacesV3ClientXML
+from tempest.services.compute.v3.xml.keypairs_client import KeyPairsV3ClientXML
from tempest.services.compute.v3.xml.servers_client import ServersV3ClientXML
from tempest.services.compute.v3.xml.services_client import \
ServicesV3ClientXML
@@ -105,6 +112,7 @@
TenantUsagesClientXML
from tempest.services.compute.xml.volumes_extensions_client import \
VolumesExtensionsClientXML
+from tempest.services.data_processing.v1_1.client import DataProcessingClient
from tempest.services.identity.json.identity_client import IdentityClientJSON
from tempest.services.identity.json.identity_client import TokenClientJSON
from tempest.services.identity.v3.json.credentials_client import \
@@ -145,15 +153,20 @@
VolumeHostsClientJSON
from tempest.services.volume.json.admin.volume_types_client import \
VolumeTypesClientJSON
+from tempest.services.volume.json.extensions_client import \
+ ExtensionsClientJSON as VolumeExtensionClientJSON
from tempest.services.volume.json.snapshots_client import SnapshotsClientJSON
from tempest.services.volume.json.volumes_client import VolumesClientJSON
from tempest.services.volume.xml.admin.volume_hosts_client import \
VolumeHostsClientXML
from tempest.services.volume.xml.admin.volume_types_client import \
VolumeTypesClientXML
+from tempest.services.volume.xml.extensions_client import \
+ ExtensionsClientXML as VolumeExtensionClientXML
from tempest.services.volume.xml.snapshots_client import SnapshotsClientXML
from tempest.services.volume.xml.volumes_client import VolumesClientXML
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -174,13 +187,12 @@
:param password: Override of the password
:param tenant_name: Override of the tenant name
"""
- self.config = config.TempestConfig()
-
+ self.config = CONF
# If no creds are provided, we fall back on the defaults
# in the config file for the Compute API.
- self.username = username or self.config.identity.username
- self.password = password or self.config.identity.password
- self.tenant_name = tenant_name or self.config.identity.tenant_name
+ self.username = username or CONF.identity.username
+ self.password = password or CONF.identity.password
+ self.tenant_name = tenant_name or CONF.identity.tenant_name
if None in (self.username, self.password, self.tenant_name):
msg = ("Missing required credentials. "
@@ -189,15 +201,15 @@
{'u': username, 'p': password, 't': tenant_name})
raise exceptions.InvalidConfiguration(msg)
- self.auth_url = self.config.identity.uri
- self.auth_url_v3 = self.config.identity.uri_v3
+ self.auth_url = CONF.identity.uri
+ self.auth_url_v3 = CONF.identity.uri_v3
- client_args = (self.config, self.username, self.password,
+ client_args = (CONF, self.username, self.password,
self.auth_url, self.tenant_name)
if self.auth_url_v3:
auth_version = 'v3'
- client_args_v3_auth = (self.config, self.username,
+ client_args_v3_auth = (CONF, self.username,
self.password, self.auth_url_v3,
self.tenant_name, auth_version)
else:
@@ -207,10 +219,12 @@
if interface == 'xml':
self.certificates_client = CertificatesClientXML(*client_args)
+ self.certificates_v3_client = CertificatesV3ClientXML(*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.quotas_client = QuotasClientXML(*client_args)
self.flavors_client = FlavorsClientXML(*client_args)
@@ -224,7 +238,7 @@
self.volume_types_client = VolumeTypesClientXML(*client_args)
self.identity_client = IdentityClientXML(*client_args)
self.identity_v3_client = IdentityV3ClientXML(*client_args)
- self.token_client = TokenClientXML(self.config)
+ self.token_client = TokenClientXML(CONF)
self.security_groups_client = SecurityGroupsClientXML(
*client_args)
self.interfaces_v3_client = InterfacesV3ClientXML(*client_args)
@@ -252,6 +266,8 @@
self.instance_usages_audit_log_client = \
InstanceUsagesAuditLogClientXML(*client_args)
self.volume_hosts_client = VolumeHostsClientXML(*client_args)
+ self.volumes_extension_client = VolumeExtensionClientXML(
+ *client_args)
if client_args_v3_auth:
self.servers_client_v3_auth = ServersClientXML(
@@ -259,10 +275,13 @@
elif interface == 'json':
self.certificates_client = CertificatesClientJSON(*client_args)
+ self.certificates_v3_client = CertificatesV3ClientJSON(
+ *client_args)
self.servers_client = ServersClientJSON(*client_args)
self.servers_v3_client = ServersV3ClientJSON(*client_args)
self.limits_client = LimitsClientJSON(*client_args)
self.images_client = ImagesClientJSON(*client_args)
+ self.keypairs_v3_client = KeyPairsV3ClientJSON(*client_args)
self.keypairs_client = KeyPairsClientJSON(*client_args)
self.quotas_client = QuotasClientJSON(*client_args)
self.flavors_client = FlavorsClientJSON(*client_args)
@@ -276,7 +295,7 @@
self.volume_types_client = VolumeTypesClientJSON(*client_args)
self.identity_client = IdentityClientJSON(*client_args)
self.identity_v3_client = IdentityV3ClientJSON(*client_args)
- self.token_client = TokenClientJSON(self.config)
+ self.token_client = TokenClientJSON(CONF)
self.security_groups_client = SecurityGroupsClientJSON(
*client_args)
self.interfaces_v3_client = InterfacesV3ClientJSON(*client_args)
@@ -304,6 +323,8 @@
self.instance_usages_audit_log_client = \
InstanceUsagesAuditLogClientJSON(*client_args)
self.volume_hosts_client = VolumeHostsClientJSON(*client_args)
+ self.volumes_extension_client = VolumeExtensionClientJSON(
+ *client_args)
if client_args_v3_auth:
self.servers_client_v3_auth = ServersClientJSON(
@@ -314,7 +335,7 @@
# common clients
self.account_client = AccountClient(*client_args)
- if self.config.service_available.glance:
+ if CONF.service_available.glance:
self.image_client = ImageClientJSON(*client_args)
self.image_client_v2 = ImageClientV2JSON(*client_args)
self.container_client = ContainerClient(*client_args)
@@ -325,6 +346,7 @@
self.custom_object_client = ObjectClientCustomizedHeader(*client_args)
self.custom_account_client = \
AccountClientCustomizedHeader(*client_args)
+ self.data_processing_client = DataProcessingClient(*client_args)
class AltManager(Manager):
@@ -335,10 +357,9 @@
"""
def __init__(self, interface='json'):
- conf = config.TempestConfig()
- super(AltManager, self).__init__(conf.identity.alt_username,
- conf.identity.alt_password,
- conf.identity.alt_tenant_name,
+ super(AltManager, self).__init__(CONF.identity.alt_username,
+ CONF.identity.alt_password,
+ CONF.identity.alt_tenant_name,
interface=interface)
@@ -350,10 +371,9 @@
"""
def __init__(self, interface='json'):
- conf = config.TempestConfig()
- super(AdminManager, self).__init__(conf.identity.admin_username,
- conf.identity.admin_password,
- conf.identity.admin_tenant_name,
+ super(AdminManager, self).__init__(CONF.identity.admin_username,
+ CONF.identity.admin_password,
+ CONF.identity.admin_tenant_name,
interface=interface)
@@ -365,11 +385,10 @@
"""
def __init__(self, interface='json'):
- conf = config.TempestConfig()
base = super(ComputeAdminManager, self)
- base.__init__(conf.compute_admin.username,
- conf.compute_admin.password,
- conf.compute_admin.tenant_name,
+ base.__init__(CONF.compute_admin.username,
+ CONF.compute_admin.password,
+ CONF.compute_admin.tenant_name,
interface=interface)
@@ -379,9 +398,8 @@
so that heat templates can create users
"""
def __init__(self, interface='json'):
- conf = config.TempestConfig()
base = super(OrchestrationManager, self)
- base.__init__(conf.identity.admin_username,
- conf.identity.admin_password,
- conf.identity.tenant_name,
+ base.__init__(CONF.identity.admin_username,
+ CONF.identity.admin_password,
+ CONF.identity.tenant_name,
interface=interface)
diff --git a/tempest/common/debug.py b/tempest/common/debug.py
index 69c933c..f132f6a 100644
--- a/tempest/common/debug.py
+++ b/tempest/common/debug.py
@@ -19,13 +19,14 @@
from tempest.openstack.common import log as logging
+CONF = config.CONF
LOG = logging.getLogger(__name__)
tables = ['filter', 'nat', 'mangle']
def log_ip_ns():
- if not config.TempestConfig().debug.enable:
+ if not CONF.debug.enable:
return
LOG.info("Host Addr:\n" + commands.ip_addr_raw())
LOG.info("Host Route:\n" + commands.ip_route_raw())
diff --git a/tempest/common/generate_sample_tempest.py b/tempest/common/generate_sample_tempest.py
index 545703b..6097aa8 100644
--- a/tempest/common/generate_sample_tempest.py
+++ b/tempest/common/generate_sample_tempest.py
@@ -18,7 +18,7 @@
import sys
-from tempest import config
+import tempest.config
from tempest.openstack.common.config import generator
# NOTE(mtreinish): This hack is needed because of how oslo config is used in
@@ -31,5 +31,7 @@
# the issue by manually loading the config file (which may or may not exist)
# which will populate all the options before running the generator.
-config.TempestConfig()
-generator.generate(sys.argv[1:])
+
+if __name__ == "__main__":
+ CONF = tempest.config.TempestConfigPrivate(False)
+ generator.generate(sys.argv[1:])
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index 5dbb3a7..da60318 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -25,6 +25,7 @@
from tempest import exceptions
from tempest.openstack.common import log as logging
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -36,7 +37,7 @@
self.isolated_net_resources = {}
self.ports = []
self.name = name
- self.config = config.TempestConfig()
+ self.config = CONF
self.tempest_client = tempest_client
self.interface = interface
self.password = password
@@ -44,11 +45,11 @@
self._get_admin_clients())
def _get_official_admin_clients(self):
- username = self.config.identity.admin_username
- password = self.config.identity.admin_password
- tenant_name = self.config.identity.admin_tenant_name
- auth_url = self.config.identity.uri
- dscv = self.config.identity.disable_ssl_certificate_validation
+ username = CONF.identity.admin_username
+ password = CONF.identity.admin_password
+ tenant_name = CONF.identity.admin_tenant_name
+ auth_url = CONF.identity.uri
+ dscv = CONF.identity.disable_ssl_certificate_validation
identity_client = keystoneclient.Client(username=username,
password=password,
tenant_name=tenant_name,
@@ -164,7 +165,7 @@
role = None
try:
roles = self._list_roles()
- admin_role = self.config.identity.admin_role
+ admin_role = CONF.identity.admin_role
if self.tempest_client:
role = next(r for r in roles if r['name'] == admin_role)
else:
@@ -229,8 +230,8 @@
if not self.tempest_client:
body = {'subnet': {'name': subnet_name, 'tenant_id': tenant_id,
'network_id': network_id, 'ip_version': 4}}
- base_cidr = netaddr.IPNetwork(self.config.network.tenant_network_cidr)
- mask_bits = self.config.network.tenant_network_mask_bits
+ base_cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
+ mask_bits = CONF.network.tenant_network_mask_bits
for subnet_cidr in base_cidr.subnet(mask_bits):
try:
if self.tempest_client:
@@ -252,7 +253,7 @@
def _create_router(self, router_name, tenant_id):
external_net_id = dict(
- network_id=self.config.network.public_network_id)
+ network_id=CONF.network.public_network_id)
if self.tempest_client:
resp, resp_body = self.network_admin_client.create_router(
router_name,
@@ -328,7 +329,7 @@
self.isolated_creds['primary'] = (user, tenant)
LOG.info("Acquired isolated creds:\n user: %s, tenant: %s"
% (username, tenant_name))
- if self.config.service_available.neutron:
+ if CONF.service_available.neutron:
network, subnet, router = self._create_network_resources(
self._get_tenant_id(tenant))
self.isolated_net_resources['primary'] = (
@@ -347,7 +348,7 @@
self.isolated_creds['admin'] = (user, tenant)
LOG.info("Acquired admin isolated creds:\n user: %s, tenant: %s"
% (username, tenant_name))
- if self.config.service_available.neutron:
+ if CONF.service_available.neutron:
network, subnet, router = self._create_network_resources(
self._get_tenant_id(tenant))
self.isolated_net_resources['admin'] = (
@@ -366,7 +367,7 @@
self.isolated_creds['alt'] = (user, tenant)
LOG.info("Acquired alt isolated creds:\n user: %s, tenant: %s"
% (username, tenant_name))
- if self.config.service_available.neutron:
+ if CONF.service_available.neutron:
network, subnet, router = self._create_network_resources(
self._get_tenant_id(tenant))
self.isolated_net_resources['alt'] = (
diff --git a/tempest/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py
index 144536a..fa59e14 100644
--- a/tempest/common/utils/linux/remote_client.py
+++ b/tempest/common/utils/linux/remote_client.py
@@ -17,18 +17,20 @@
from tempest.common.ssh import Client
from tempest.common import utils
-from tempest.config import TempestConfig
+from tempest import config
from tempest.exceptions import ServerUnreachable
+CONF = config.CONF
+
class RemoteClient():
# NOTE(afazekas): It should always get an address instead of server
def __init__(self, server, username, password=None, pkey=None):
- ssh_timeout = TempestConfig().compute.ssh_timeout
- network = TempestConfig().compute.network_for_ssh
- ip_version = TempestConfig().compute.ip_version_for_ssh
- ssh_channel_timeout = TempestConfig().compute.ssh_channel_timeout
+ ssh_timeout = CONF.compute.ssh_timeout
+ network = CONF.compute.network_for_ssh
+ ip_version = CONF.compute.ip_version_for_ssh
+ ssh_channel_timeout = CONF.compute.ssh_channel_timeout
if isinstance(server, basestring):
ip_address = server
else:
diff --git a/tempest/common/waiters.py b/tempest/common/waiters.py
index d2b40c9..aedba15 100644
--- a/tempest/common/waiters.py
+++ b/tempest/common/waiters.py
@@ -19,7 +19,7 @@
from tempest import exceptions
from tempest.openstack.common import log as logging
-CONFIG = config.TempestConfig()
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -55,7 +55,7 @@
# responses
if str(task_state) == "None":
# without state api extension 3 sec usually enough
- time.sleep(CONFIG.compute.ready_wait)
+ time.sleep(CONF.compute.ready_wait)
return
else:
return
diff --git a/tempest/config.py b/tempest/config.py
index 3d9eba9..1247a8d 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -18,12 +18,9 @@
from __future__ import print_function
import os
-import sys
-
from oslo.config import cfg
-from tempest.common.utils.misc import singleton
from tempest.openstack.common import log as logging
@@ -137,7 +134,7 @@
help="Timeout in seconds to wait for an instance to build."),
cfg.BoolOpt('run_ssh',
default=False,
- help="Does the test environment support snapshots?"),
+ help="Should the tests ssh to instances?"),
cfg.StrOpt('ssh_user',
default='root',
help="User name used to authenticate to an instance."),
@@ -486,6 +483,16 @@
]
+data_processing_group = cfg.OptGroup(name="data_processing",
+ title="Data Processing options")
+
+DataProcessingGroup = [
+ cfg.StrOpt('catalog_type',
+ default='data_processing',
+ help="Catalog type of the data processing service.")
+]
+
+
boto_group = cfg.OptGroup(name='boto',
title='EC2/S3 options')
BotoGroup = [
@@ -621,6 +628,9 @@
cfg.BoolOpt('horizon',
default=True,
help="Whether or not Horizon is expected to be available"),
+ cfg.BoolOpt('savanna',
+ default=False,
+ help="Whether or not Savanna is expected to be available"),
]
debug_group = cfg.OptGroup(name="debug",
@@ -633,8 +643,8 @@
]
-@singleton
-class TempestConfig:
+# this should never be called outside of this class
+class TempestConfigPrivate(object):
"""Provides OpenStack configuration information."""
DEFAULT_CONFIG_DIR = os.path.join(
@@ -643,8 +653,9 @@
DEFAULT_CONFIG_FILE = "tempest.conf"
- def __init__(self):
+ def __init__(self, parse_conf=True):
"""Initialize a configuration from a conf directory and conf file."""
+ super(TempestConfigPrivate, self).__init__()
config_files = []
failsafe_path = "/etc/tempest/" + self.DEFAULT_CONFIG_FILE
@@ -660,10 +671,9 @@
'TEMPEST_CONFIG' in os.environ):
path = failsafe_path
- if not os.path.exists(path):
- msg = "Config file %s not found" % path
- print(RuntimeError(msg), file=sys.stderr)
- else:
+ # only parse the config file if we expect one to exist. This is needed
+ # to remove an issue with the config file up to date checker.
+ if parse_conf:
config_files.append(path)
cfg.CONF([], project='tempest', default_config_files=config_files)
@@ -688,6 +698,8 @@
ObjectStoreFeaturesGroup)
register_opt_group(cfg.CONF, orchestration_group, OrchestrationGroup)
register_opt_group(cfg.CONF, dashboard_group, DashboardGroup)
+ register_opt_group(cfg.CONF, data_processing_group,
+ DataProcessingGroup)
register_opt_group(cfg.CONF, boto_group, BotoGroup)
register_opt_group(cfg.CONF, compute_admin_group, ComputeAdminGroup)
register_opt_group(cfg.CONF, stress_group, StressGroup)
@@ -709,6 +721,7 @@
'object-storage-feature-enabled']
self.orchestration = cfg.CONF.orchestration
self.dashboard = cfg.CONF.dashboard
+ self.data_processing = cfg.CONF.data_processing
self.boto = cfg.CONF.boto
self.compute_admin = cfg.CONF['compute-admin']
self.stress = cfg.CONF.stress
@@ -719,3 +732,16 @@
self.compute_admin.username = self.identity.admin_username
self.compute_admin.password = self.identity.admin_password
self.compute_admin.tenant_name = self.identity.admin_tenant_name
+
+
+class TempestConfigProxy(object):
+ _config = None
+
+ def __getattr__(self, attr):
+ if not self._config:
+ self._config = TempestConfigPrivate()
+
+ return getattr(self._config, attr)
+
+
+CONF = TempestConfigProxy()
diff --git a/tempest/manager.py b/tempest/manager.py
index e3aeb31..42b8c8f 100644
--- a/tempest/manager.py
+++ b/tempest/manager.py
@@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-import tempest.config
+from tempest import config
from tempest import exceptions
@@ -29,7 +29,7 @@
"""
def __init__(self):
- self.config = tempest.config.TempestConfig()
+ self.config = config.CONF
self.client_attr_names = []
# we do this everywhere, have it be part of the super class
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 9f97964..d3d34d0 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -24,12 +24,14 @@
import cinderclient.client
import glanceclient
import heatclient.client
+import keystoneclient.apiclient.exceptions
import keystoneclient.v2_0.client
import netaddr
from neutronclient.common import exceptions as exc
import neutronclient.v2_0.client
import novaclient.client
from novaclient import exceptions as nova_exceptions
+import swiftclient
from tempest.api.network import common as net_common
from tempest.common import isolated_creds
@@ -74,6 +76,10 @@
self.volume_client = self._get_volume_client(username,
password,
tenant_name)
+ self.object_storage_client = self._get_object_storage_client(
+ username,
+ password,
+ tenant_name)
self.orchestration_client = self._get_orchestration_client(
username,
password,
@@ -122,6 +128,30 @@
region_name=region,
http_log_debug=True)
+ def _get_object_storage_client(self, username, password, tenant_name):
+ auth_url = self.config.identity.uri
+ # add current tenant to Member group.
+ keystone_admin = self._get_identity_client(
+ self.config.identity.admin_username,
+ self.config.identity.admin_password,
+ self.config.identity.admin_tenant_name)
+
+ # enable test user to operate swift by adding Member role to him.
+ roles = keystone_admin.roles.list()
+ member_role = [role for role in roles if role.name == 'Member'][0]
+ # NOTE(maurosr): This is surrounded in the try-except block cause
+ # neutron tests doesn't have tenant isolation.
+ try:
+ keystone_admin.roles.add_user_role(self.identity_client.user_id,
+ member_role.id,
+ self.identity_client.tenant_id)
+ except keystoneclient.apiclient.exceptions.Conflict:
+ pass
+
+ return swiftclient.Connection(auth_url, username, password,
+ tenant_name=tenant_name,
+ auth_version='2')
+
def _get_orchestration_client(self, username=None, password=None,
tenant_name=None):
if not username:
@@ -207,7 +237,7 @@
cls.isolated_creds = isolated_creds.IsolatedCreds(
__name__, tempest_client=False)
- username, tenant_name, password = cls.credentials()
+ username, password, tenant_name = cls.credentials()
cls.manager = OfficialClientManager(username, password, tenant_name)
cls.compute_client = cls.manager.compute_client
@@ -215,19 +245,33 @@
cls.identity_client = cls.manager.identity_client
cls.network_client = cls.manager.network_client
cls.volume_client = cls.manager.volume_client
+ cls.object_storage_client = cls.manager.object_storage_client
cls.orchestration_client = cls.manager.orchestration_client
cls.resource_keys = {}
cls.os_resources = []
@classmethod
- def credentials(cls):
+ def _get_credentials(cls, get_creds, prefix):
if cls.config.compute.allow_tenant_isolation:
- return cls.isolated_creds.get_primary_creds()
+ username, tenant_name, password = get_creds()
+ else:
+ username = getattr(cls.config.identity, prefix + 'username')
+ password = getattr(cls.config.identity, prefix + 'password')
+ tenant_name = getattr(cls.config.identity, prefix + 'tenant_name')
+ return username, password, tenant_name
- username = cls.config.identity.username
- password = cls.config.identity.password
- tenant_name = cls.config.identity.tenant_name
- return username, tenant_name, password
+ @classmethod
+ def credentials(cls):
+ return cls._get_credentials(cls.isolated_creds.get_primary_creds, '')
+
+ @classmethod
+ def alt_credentials(cls):
+ return cls._get_credentials(cls.isolated_creds.get_alt_creds, 'alt_')
+
+ @classmethod
+ def admin_credentials(cls):
+ return cls._get_credentials(cls.isolated_creds.get_admin_creds,
+ 'admin_')
@classmethod
def tearDownClass(cls):
@@ -248,7 +292,8 @@
except Exception as e:
# If the resource is already missing, mission accomplished.
# add status code as workaround for bug 1247568
- if e.__class__.__name__ == 'NotFound' or e.status_code == 404:
+ if (e.__class__.__name__ == 'NotFound' or
+ hasattr(e, 'status_code') and e.status_code == 404):
continue
raise
@@ -348,8 +393,8 @@
# so case sensitive comparisons can really mess things
# up.
if new_status.lower() == error_status.lower():
- message = "%s failed to get to expected status. \
- In %s state." % (thing, new_status)
+ message = ("%s failed to get to expected status. "
+ "In %s state.") % (thing, new_status)
raise exceptions.BuildErrorException(message)
elif new_status == expected_status and expected_status is not None:
return True # All good.
@@ -360,8 +405,8 @@
check_status,
self.config.compute.build_timeout,
self.config.compute.build_interval):
- message = "Timed out waiting for thing %s \
- to become %s" % (thing_id, log_status)
+ message = ("Timed out waiting for thing %s "
+ "to become %s") % (thing_id, log_status)
raise exceptions.TimeoutException(message)
def _create_loginable_secgroup_rule_nova(self, client=None,
@@ -608,12 +653,15 @@
self.set_resource(name, port)
return port
- def _create_floating_ip(self, server, external_network_id):
+ def _get_server_port_id(self, server):
result = self.network_client.list_ports(device_id=server.id)
ports = result.get('ports', [])
self.assertEqual(len(ports), 1,
"Unable to determine which port to target.")
- port_id = ports[0]['id']
+ return ports[0]['id']
+
+ def _create_floating_ip(self, server, external_network_id):
+ port_id = self._get_server_port_id(server)
body = dict(
floatingip=dict(
floating_network_id=external_network_id,
@@ -628,6 +676,12 @@
self.set_resource(data_utils.rand_name('floatingip-'), floating_ip)
return floating_ip
+ def _associate_floating_ip(self, floating_ip, server):
+ port_id = self._get_server_port_id(server)
+ floating_ip.update(port_id=port_id)
+ self.assertEqual(port_id, floating_ip.port_id)
+ return floating_ip
+
def _disassociate_floating_ip(self, floating_ip):
"""
:param floating_ip: type DeletableFloatingIp
diff --git a/tempest/scenario/test_cross_tenant_connectivity.py b/tempest/scenario/test_cross_tenant_connectivity.py
index ad2c271..faba987 100644
--- a/tempest/scenario/test_cross_tenant_connectivity.py
+++ b/tempest/scenario/test_cross_tenant_connectivity.py
@@ -143,10 +143,9 @@
@classmethod
def setUpClass(cls):
super(TestNetworkCrossTenant, cls).setUpClass()
+ alt_creds = cls.alt_credentials()
cls.alt_tenant_id = cls.manager._get_identity_client(
- cls.config.identity.alt_username,
- cls.config.identity.alt_password,
- cls.config.identity.alt_tenant_name
+ *alt_creds
).tenant_id
cls.check_preconditions()
# TODO(mnewby) Consider looking up entities as needed instead
@@ -161,15 +160,11 @@
cls.tenants = {}
cls.demo_tenant = cls.TenantProperties(
cls.tenant_id,
- cls.config.identity.username,
- cls.config.identity.password,
- cls.config.identity.tenant_name
+ *cls.credentials()
)
cls.alt_tenant = cls.TenantProperties(
cls.alt_tenant_id,
- cls.config.identity.alt_username,
- cls.config.identity.alt_password,
- cls.config.identity.alt_tenant_name
+ *alt_creds
)
for tenant in [cls.demo_tenant, cls.alt_tenant]:
cls.tenants[tenant.tenant_id] = tenant
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index 54517ab..33dd6c0 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -27,6 +27,7 @@
from tempest.test import attr
from tempest.test import services
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -90,6 +91,10 @@
- detach the floating-ip from the VM and verify that it becomes
unreachable
+ - associate detached floating ip to a new VM and verify connectivity.
+ VMs are created with unique keypair so connectivity also asserts that
+ floating IP is associated with the new VM instead of the old one
+
# TODO(mnewby) - Need to implement the following:
- the Tempest host can ssh into the VM via the IP address and
successfully execute the following:
@@ -138,8 +143,6 @@
"""
- CONF = config.TempestConfig()
-
@classmethod
def check_preconditions(cls):
super(TestNetworkBasicOps, cls).check_preconditions()
@@ -156,18 +159,13 @@
cls.check_preconditions()
# TODO(mnewby) Consider looking up entities as needed instead
# of storing them as collections on the class.
- cls.keypairs = {}
cls.security_groups = {}
cls.networks = []
cls.subnets = []
cls.routers = []
- cls.servers = []
+ cls.servers = {}
cls.floating_ips = {}
- def _create_keypairs(self):
- self.keypairs[self.tenant_id] = self.create_keypair(
- name=data_utils.rand_name('keypair-smoke-'))
-
def _create_security_groups(self):
self.security_groups[self.tenant_id] =\
self._create_security_group_neutron(tenant_id=self.tenant_id)
@@ -197,39 +195,38 @@
def _create_server(self, name, network):
tenant_id = network.tenant_id
- keypair_name = self.keypairs[tenant_id].name
+ keypair = self.create_keypair(name='keypair-%s' % name)
security_groups = [self.security_groups[tenant_id].name]
create_kwargs = {
'nics': [
{'net-id': network.id},
],
- 'key_name': keypair_name,
+ 'key_name': keypair.name,
'security_groups': security_groups,
}
server = self.create_server(name=name, create_kwargs=create_kwargs)
+ self.servers[server] = keypair
return server
def _create_servers(self):
for i, network in enumerate(self.networks):
name = data_utils.rand_name('server-smoke-%d-' % i)
- server = self._create_server(name, network)
- self.servers.append(server)
+ self._create_server(name, network)
def _check_tenant_network_connectivity(self):
- if not self.config.network.tenant_networks_reachable:
+ if not CONF.network.tenant_networks_reachable:
msg = 'Tenant networks not configured to be reachable.'
LOG.info(msg)
return
# The target login is assumed to have been configured for
# key-based authentication by cloud-init.
- ssh_login = self.config.compute.image_ssh_user
- private_key = self.keypairs[self.tenant_id].private_key
+ ssh_login = CONF.compute.image_ssh_user
try:
- for server in self.servers:
+ for server, key in self.servers.items():
for net_name, ip_addresses in server.networks.iteritems():
for ip_address in ip_addresses:
self._check_vm_connectivity(ip_address, ssh_login,
- private_key)
+ key.private_key)
except Exception as exc:
LOG.exception(exc)
debug.log_ip_ns()
@@ -241,25 +238,27 @@
self.assertTrue(
tempest.test.call_until_true(
- ip_tracker.run_checks, self.config.compute.build_timeout,
- self.config.compute.build_interval),
+ ip_tracker.run_checks, CONF.compute.build_timeout,
+ CONF.compute.build_interval),
"Timed out while waiting for the floating IP assignments "
"to propagate")
def _create_and_associate_floating_ips(self):
- public_network_id = self.config.network.public_network_id
- for server in self.servers:
+ public_network_id = CONF.network.public_network_id
+ for server in self.servers.keys():
floating_ip = self._create_floating_ip(server, public_network_id)
self.floating_ips[floating_ip] = server
def _check_public_network_connectivity(self, should_connect=True):
# The target login is assumed to have been configured for
# key-based authentication by cloud-init.
- ssh_login = self.config.compute.image_ssh_user
- private_key = self.keypairs[self.tenant_id].private_key
+ ssh_login = CONF.compute.image_ssh_user
try:
for floating_ip, server in self.floating_ips.iteritems():
ip_address = floating_ip.floating_ip_address
+ private_key = None
+ if should_connect:
+ private_key = self.servers[server].private_key
self._check_vm_connectivity(ip_address,
ssh_login,
private_key,
@@ -274,10 +273,18 @@
self._disassociate_floating_ip(floating_ip)
self.floating_ips[floating_ip] = None
+ def _reassociate_floating_ips(self):
+ network = self.networks[0]
+ for floating_ip in self.floating_ips.keys():
+ name = data_utils.rand_name('new_server-smoke-')
+ # create a new server for the floating ip
+ server = self._create_server(name, network)
+ self._associate_floating_ip(floating_ip, server)
+ self.floating_ips[floating_ip] = server
+
@attr(type='smoke')
@services('compute', 'network')
def test_network_basic_ops(self):
- self._create_keypairs()
self._create_security_groups()
self._create_networks()
self._check_networks()
@@ -288,3 +295,6 @@
self._check_public_network_connectivity(should_connect=True)
self._disassociate_floating_ips()
self._check_public_network_connectivity(should_connect=False)
+ self._reassociate_floating_ips()
+ self._wait_for_floating_ip_association()
+ self._check_public_network_connectivity(should_connect=True)
diff --git a/tempest/scenario/test_swift_basic_ops.py b/tempest/scenario/test_swift_basic_ops.py
new file mode 100644
index 0000000..6763503
--- /dev/null
+++ b/tempest/scenario/test_swift_basic_ops.py
@@ -0,0 +1,101 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 IBM Corp.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+from tempest.common.utils.data_utils import rand_name
+from tempest.openstack.common import log as logging
+from tempest.scenario import manager
+from tempest.test import services
+
+LOG = logging.getLogger(__name__)
+
+
+class TestSwiftBasicOps(manager.OfficialClientTest):
+ """
+ Test swift with the follow operations:
+ * get swift stat.
+ * create container.
+ * upload a file to the created container.
+ * list container's objects and assure that the uploaded file is present.
+ * delete object from container.
+ * list container's objects and assure that the deleted file is gone.
+ * delete a container.
+ * list containers and assure that the deleted container is gone.
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestSwiftBasicOps, cls).setUpClass()
+ if not cls.config.service_available.swift:
+ skip_msg = ("%s skipped as swift is not available" %
+ cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ def _get_swift_stat(self):
+ """get swift status for our user account."""
+ self.object_storage_client.get_account()
+ LOG.debug('Swift status information obtained successfully')
+
+ def _create_container(self, container_name=None):
+ name = container_name or rand_name('swift-scenario-container')
+ self.object_storage_client.put_container(name)
+ # look for the container to assure it is created
+ self._list_and_check_container_objects(name)
+ LOG.debug('Container %s created' % (name))
+ return name
+
+ def _delete_container(self, container_name):
+ self.object_storage_client.delete_container(container_name)
+ LOG.debug('Container %s deleted' % (container_name))
+
+ def _upload_object_to_container(self, container_name, obj_name=None):
+ obj_name = obj_name or rand_name('swift-scenario-object')
+ self.object_storage_client.put_object(container_name, obj_name,
+ rand_name('obj_data'),
+ content_type='text/plain')
+ return obj_name
+
+ def _delete_object(self, container_name, filename):
+ self.object_storage_client.delete_object(container_name, filename)
+ self._list_and_check_container_objects(container_name,
+ not_present_obj=[filename])
+
+ def _list_and_check_container_objects(self, container_name, present_obj=[],
+ not_present_obj=[]):
+ """
+ List objects for a given container and assert which are present and
+ which are not.
+ """
+ meta, response = self.object_storage_client.get_container(
+ container_name)
+ # create a list with file name only
+ object_list = [obj['name'] for obj in response]
+ if present_obj:
+ for obj in present_obj:
+ self.assertIn(obj, object_list)
+ if not_present_obj:
+ for obj in not_present_obj:
+ self.assertNotIn(obj, object_list)
+
+ @services('object')
+ def test_swift_basic_ops(self):
+ self._get_swift_stat()
+ container_name = self._create_container()
+ obj_name = self._upload_object_to_container(container_name)
+ self._list_and_check_container_objects(container_name, [obj_name])
+ self._delete_object(container_name, obj_name)
+ self._delete_container(container_name)
diff --git a/tempest/services/compute/v3/json/certificates_client.py b/tempest/services/compute/v3/json/certificates_client.py
new file mode 100644
index 0000000..bf0152b
--- /dev/null
+++ b/tempest/services/compute/v3/json/certificates_client.py
@@ -0,0 +1,42 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 IBM Corp
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import json
+
+from tempest.common.rest_client import RestClient
+
+
+class CertificatesV3ClientJSON(RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(CertificatesV3ClientJSON, 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)
+ body = json.loads(body)
+ return resp, body['certificate']
+
+ def create_certificate(self):
+ """create certificates."""
+ url = "os-certificates"
+ resp, body = self.post(url, None, self.headers)
+ body = json.loads(body)
+ return resp, body['certificate']
diff --git a/tempest/services/compute/v3/json/instance_usage_audit_log_client.py b/tempest/services/compute/v3/json/instance_usage_audit_log_client.py
new file mode 100644
index 0000000..07ce1bb
--- /dev/null
+++ b/tempest/services/compute/v3/json/instance_usage_audit_log_client.py
@@ -0,0 +1,40 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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.
+
+import json
+
+from tempest.common.rest_client import RestClient
+
+
+class InstanceUsagesAuditLogClientJSON(RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(InstanceUsagesAuditLogClientJSON, self).__init__(
+ config, username, password, auth_url, tenant_name)
+ self.service = self.config.compute.catalog_type
+
+ def list_instance_usage_audit_logs(self):
+ url = 'os-instance_usage_audit_log'
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body["instance_usage_audit_logs"]
+
+ def get_instance_usage_audit_log(self, time_before):
+ url = 'os-instance_usage_audit_log/%s' % time_before
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body["instance_usage_audit_log"]
diff --git a/tempest/services/compute/v3/json/keypairs_client.py b/tempest/services/compute/v3/json/keypairs_client.py
new file mode 100644
index 0000000..500aa0e
--- /dev/null
+++ b/tempest/services/compute/v3/json/keypairs_client.py
@@ -0,0 +1,56 @@
+# 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.
+
+import json
+
+from tempest.common.rest_client import RestClient
+
+
+class KeyPairsV3ClientJSON(RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(KeyPairsV3ClientJSON, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
+
+ def list_keypairs(self):
+ resp, body = self.get("keypairs")
+ body = json.loads(body)
+ # Each returned keypair is embedded within an unnecessary 'keypair'
+ # element which is a deviation from other resources like floating-ips,
+ # servers, etc. A bug?
+ # For now we shall adhere to the spec, but the spec for keypairs
+ # is yet to be found
+ return resp, body['keypairs']
+
+ def get_keypair(self, key_name):
+ resp, body = self.get("keypairs/%s" % str(key_name))
+ body = json.loads(body)
+ return resp, body['keypair']
+
+ def create_keypair(self, name, pub_key=None):
+ post_body = {'keypair': {'name': name}}
+ if pub_key:
+ post_body['keypair']['public_key'] = pub_key
+ post_body = json.dumps(post_body)
+ resp, body = self.post("keypairs",
+ headers=self.headers, body=post_body)
+ body = json.loads(body)
+ return resp, body['keypair']
+
+ def delete_keypair(self, key_name):
+ return self.delete("keypairs/%s" % str(key_name))
diff --git a/tempest/services/compute/v3/xml/certificates_client.py b/tempest/services/compute/v3/xml/certificates_client.py
new file mode 100644
index 0000000..99dc337
--- /dev/null
+++ b/tempest/services/compute/v3/xml/certificates_client.py
@@ -0,0 +1,41 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 IBM Corp
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+from tempest.common.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/instance_usage_audit_log_client.py b/tempest/services/compute/v3/xml/instance_usage_audit_log_client.py
new file mode 100644
index 0000000..175997b
--- /dev/null
+++ b/tempest/services/compute/v3/xml/instance_usage_audit_log_client.py
@@ -0,0 +1,41 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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 InstanceUsagesAuditLogClientXML(RestClientXML):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(InstanceUsagesAuditLogClientXML, self).__init__(
+ config, username, password, auth_url, tenant_name)
+ self.service = self.config.compute.catalog_type
+
+ def list_instance_usage_audit_logs(self):
+ 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
+
+ def get_instance_usage_audit_log(self, time_before):
+ url = 'os-instance_usage_audit_log/%s' % time_before
+ resp, body = self.get(url, self.headers)
+ instance_usage_audit_log = xml_to_json(etree.fromstring(body))
+ return resp, instance_usage_audit_log
diff --git a/tempest/services/compute/v3/xml/keypairs_client.py b/tempest/services/compute/v3/xml/keypairs_client.py
new file mode 100644
index 0000000..d87daff
--- /dev/null
+++ b/tempest/services/compute/v3/xml/keypairs_client.py
@@ -0,0 +1,69 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+#
+# 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/xml/common.py b/tempest/services/compute/xml/common.py
index 860dd5b..d2a18a1 100644
--- a/tempest/services/compute/xml/common.py
+++ b/tempest/services/compute/xml/common.py
@@ -99,7 +99,15 @@
return self.__content
-def xml_to_json(node):
+def parse_array(node, plurals=None):
+ array = []
+ for child in node.getchildren():
+ array.append(xml_to_json(child,
+ plurals))
+ return array
+
+
+def xml_to_json(node, plurals=None):
"""This does a really braindead conversion of an XML tree to
something that looks like a json dump. In cases where the XML
and json structures are the same, then this "just works". In
@@ -115,7 +123,10 @@
tag = child.tag
if tag.startswith("{"):
ns, tag = tag.split("}", 1)
- json[tag] = xml_to_json(child)
+ if plurals is not None and tag in plurals:
+ json[tag] = parse_array(child)
+ else:
+ json[tag] = xml_to_json(child)
return json
diff --git a/tempest/services/data_processing/__init__.py b/tempest/services/data_processing/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/data_processing/__init__.py
diff --git a/tempest/services/data_processing/v1_1/__init__.py b/tempest/services/data_processing/v1_1/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/data_processing/v1_1/__init__.py
diff --git a/tempest/services/data_processing/v1_1/client.py b/tempest/services/data_processing/v1_1/client.py
new file mode 100644
index 0000000..bd147e8
--- /dev/null
+++ b/tempest/services/data_processing/v1_1/client.py
@@ -0,0 +1,77 @@
+# 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.
+
+import json
+
+from tempest.common import rest_client
+
+
+class DataProcessingClient(rest_client.RestClient):
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(DataProcessingClient, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.data_processing.catalog_type
+
+ @classmethod
+ def _request_and_parse(cls, req_fun, uri, res_name, *args, **kwargs):
+ """Make a request using specified req_fun and parse response.
+
+ It returns pair: resp and parsed resource(s) body.
+ """
+
+ resp, body = req_fun(uri, headers={
+ 'Content-Type': 'application/json'
+ }, *args, **kwargs)
+ body = json.loads(body)
+ return resp, body[res_name]
+
+ def list_node_group_templates(self):
+ """List all node group templates for a user."""
+
+ uri = 'node-group-templates'
+ return self._request_and_parse(self.get, uri, 'node_group_templates')
+
+ def get_node_group_template(self, tmpl_id):
+ """Returns the details of a single node group template."""
+
+ uri = "node-group-templates/%s" % tmpl_id
+ return self._request_and_parse(self.get, uri, 'node_group_template')
+
+ def create_node_group_template(self, name, plugin_name, hadoop_version,
+ node_processes, flavor_id,
+ node_configs=None, **kwargs):
+ """Creates node group template with specified params.
+
+ It supports passing additional params using kwargs and returns created
+ object.
+ """
+ uri = "node-group-templates"
+ body = kwargs.copy()
+ body.update({
+ 'name': name,
+ 'plugin_name': plugin_name,
+ 'hadoop_version': hadoop_version,
+ 'node_processes': node_processes,
+ 'flavor_id': flavor_id,
+ 'node_configs': node_configs or dict(),
+ })
+ return self._request_and_parse(self.post, uri, 'node_group_template',
+ body=json.dumps(body))
+
+ def delete_node_group_template(self, tmpl_id):
+ """Deletes the specified node group template by id."""
+
+ uri = "node-group-templates/%s" % tmpl_id
+ return self.delete(uri)
diff --git a/tempest/services/image/v1/json/image_client.py b/tempest/services/image/v1/json/image_client.py
index 9f5a405..61dd050 100644
--- a/tempest/services/image/v1/json/image_client.py
+++ b/tempest/services/image/v1/json/image_client.py
@@ -36,7 +36,8 @@
super(ImageClientJSON, self).__init__(config, username, password,
auth_url, tenant_name)
self.service = self.config.images.catalog_type
- self.http = self._get_http()
+ if config.service_available.glance:
+ self.http = self._get_http()
def _image_meta_from_headers(self, headers):
meta = {'properties': {}}
diff --git a/tempest/services/image/v2/json/image_client.py b/tempest/services/image/v2/json/image_client.py
index 3d37267..c654a49 100644
--- a/tempest/services/image/v2/json/image_client.py
+++ b/tempest/services/image/v2/json/image_client.py
@@ -31,7 +31,8 @@
super(ImageClientV2JSON, self).__init__(config, username, password,
auth_url, tenant_name)
self.service = self.config.images.catalog_type
- self.http = self._get_http()
+ if config.service_available.glance:
+ self.http = self._get_http()
def _get_http(self):
token, endpoint = self.keystone_auth(self.user, self.password,
diff --git a/tempest/services/network/network_client_base.py b/tempest/services/network/network_client_base.py
index b48dd34..45ea2d6 100644
--- a/tempest/services/network/network_client_base.py
+++ b/tempest/services/network/network_client_base.py
@@ -14,7 +14,7 @@
import urllib
-# the folliwing map is used to construct proper URI
+# the following map is used to construct proper URI
# for the given neutron resource
service_resource_prefix_map = {
'networks': '',
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
index a999e31..155fa35 100644
--- a/tempest/services/network/xml/network_client.py
+++ b/tempest/services/network/xml/network_client.py
@@ -19,19 +19,24 @@
from tempest.services.compute.xml.common import deep_dict_to_xml
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
+from tempest.services.compute.xml.common import parse_array
from tempest.services.compute.xml.common import xml_to_json
from tempest.services.network import network_client_base as client_base
class NetworkClientXML(client_base.NetworkClientBase):
+ # list of plurals used for xml serialization
+ PLURALS = ['dns_nameservers', 'host_routes', 'allocation_pools',
+ 'fixed_ips', 'extensions']
+
def get_rest_client(self, config, username, password,
auth_url, tenant_name=None):
return RestClientXML(config, username, password,
auth_url, tenant_name)
def deserialize_list(self, body):
- return self._parse_array(etree.fromstring(body))
+ return parse_array(etree.fromstring(body), self.PLURALS)
def deserialize_single(self, body):
return _root_tag_fetcher_and_xml_to_json_parse(body)
@@ -54,7 +59,7 @@
p1.append(p2)
post_body.append(p1)
resp, body = self.post(uri, str(Document(post_body)))
- networks = self._parse_array(etree.fromstring(body))
+ networks = parse_array(etree.fromstring(body))
networks = {"networks": networks}
return resp, networks
@@ -83,12 +88,6 @@
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- array.append(xml_to_json(child))
- return array
-
def update_port(self, port_id, name):
uri = '%s/ports/%s' % (self.uri_prefix, str(port_id))
port = Element("port")
@@ -151,7 +150,7 @@
p1.append(p2)
post_body.append(p1)
resp, body = self.post(uri, str(Document(post_body)))
- subnets = self._parse_array(etree.fromstring(body))
+ subnets = parse_array(etree.fromstring(body))
subnets = {"subnets": subnets}
return resp, subnets
@@ -166,7 +165,7 @@
p1.append(p2)
post_body.append(p1)
resp, body = self.post(uri, str(Document(post_body)))
- ports = self._parse_array(etree.fromstring(body))
+ ports = parse_array(etree.fromstring(body))
ports = {"ports": ports}
return resp, ports
@@ -366,7 +365,7 @@
def list_router_interfaces(self, uuid):
uri = '%s/ports?device_id=%s' % (self.uri_prefix, uuid)
resp, body = self.get(uri)
- ports = self._parse_array(etree.fromstring(body))
+ ports = parse_array(etree.fromstring(body), self.PLURALS)
ports = {"ports": ports}
return resp, ports
@@ -395,14 +394,14 @@
def list_dhcp_agent_hosting_network(self, network_id):
uri = '%s/networks/%s/dhcp-agents' % (self.uri_prefix, network_id)
resp, body = self.get(uri)
- agents = self._parse_array(etree.fromstring(body))
+ agents = parse_array(etree.fromstring(body))
body = {'agents': agents}
return resp, body
def list_networks_hosted_by_one_dhcp_agent(self, agent_id):
uri = '%s/agents/%s/dhcp-networks' % (self.uri_prefix, agent_id)
resp, body = self.get(uri)
- networks = self._parse_array(etree.fromstring(body))
+ networks = parse_array(etree.fromstring(body))
body = {'networks': networks}
return resp, body
@@ -418,7 +417,8 @@
root_tag = body.tag
if root_tag.startswith("{"):
ns, root_tag = root_tag.split("}", 1)
- body = xml_to_json(etree.fromstring(xml_returned_body))
+ body = xml_to_json(etree.fromstring(xml_returned_body),
+ NetworkClientXML.PLURALS)
nil = '{http://www.w3.org/2001/XMLSchema-instance}nil'
for key, val in body.iteritems():
if isinstance(val, dict):
diff --git a/tempest/services/volume/json/extensions_client.py b/tempest/services/volume/json/extensions_client.py
new file mode 100644
index 0000000..01dd3e9
--- /dev/null
+++ b/tempest/services/volume/json/extensions_client.py
@@ -0,0 +1,34 @@
+# 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.
+
+import json
+
+from tempest.common.rest_client import RestClient
+
+
+class ExtensionsClientJSON(RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(ExtensionsClientJSON, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.volume.catalog_type
+
+ def list_extensions(self):
+ url = 'extensions'
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['extensions']
diff --git a/tempest/services/volume/xml/extensions_client.py b/tempest/services/volume/xml/extensions_client.py
new file mode 100644
index 0000000..b4e6536
--- /dev/null
+++ b/tempest/services/volume/xml/extensions_client.py
@@ -0,0 +1,40 @@
+# 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 lxml import etree
+from tempest.common.rest_client import RestClientXML
+from tempest.services.compute.xml.common import xml_to_json
+
+
+class ExtensionsClientXML(RestClientXML):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(ExtensionsClientXML, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.volume.catalog_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
diff --git a/tempest/test.py b/tempest/test.py
index b48832f..342846f 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -33,6 +33,8 @@
LOG = logging.getLogger(__name__)
+CONF = config.CONF
+
# All the successful HTTP status codes from RFC 2616
HTTP_SUCCESS = (200, 201, 202, 203, 204, 205, 206)
@@ -155,7 +157,7 @@
"""A function that will check the list of enabled extensions from config
"""
- configs = config.TempestConfig()
+ configs = CONF
config_dict = {
'compute': configs.compute_feature_enabled.api_extensions,
'compute_v3': configs.compute_feature_enabled.api_v3_extensions,
@@ -223,7 +225,7 @@
testtools.testcase.WithAttributes,
testresources.ResourcedTestCase):
- config = config.TempestConfig()
+ config = CONF
setUpClassCalled = False
diff --git a/tempest/test_discover/__init__.py b/tempest/test_discover/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/test_discover/__init__.py
diff --git a/tempest/test_discover/test_discover.py b/tempest/test_discover/test_discover.py
new file mode 100644
index 0000000..2e19bf2
--- /dev/null
+++ b/tempest/test_discover/test_discover.py
@@ -0,0 +1,32 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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 os
+import unittest
+
+
+def load_tests(loader, tests, pattern):
+ suite = unittest.TestSuite()
+ base_path = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
+ base_path = os.path.split(base_path)[0]
+ for test_dir in ['./tempest/api', './tempest/cli', './tempest/scenario',
+ './tempest/thirdparty']:
+ if not pattern:
+ suite.addTests(loader.discover(test_dir, top_level_dir=base_path))
+ else:
+ suite.addTests(loader.discover(test_dir, pattern=pattern,
+ top_level_dir=base_path))
+ return suite
diff --git a/tempest/tests/fake_config.py b/tempest/tests/fake_config.py
new file mode 100644
index 0000000..baf6b2b
--- /dev/null
+++ b/tempest/tests/fake_config.py
@@ -0,0 +1,28 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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.
+
+
+class FakeConfig(object):
+
+ class fake_compute(object):
+ build_interval = 10
+ build_timeout = 10
+
+ class fake_identity(object):
+ disable_ssl_certificate_validation = True
+
+ compute = fake_compute()
+ identity = fake_identity()
diff --git a/tempest/tests/fake_http.py b/tempest/tests/fake_http.py
new file mode 100644
index 0000000..5974377
--- /dev/null
+++ b/tempest/tests/fake_http.py
@@ -0,0 +1,48 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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 httplib2
+
+
+class fake_httplib2(object):
+
+ def __init__(self, return_type=None):
+ self.return_type = return_type
+
+ def request(self, uri, method="GET", body=None, headers=None,
+ redirections=5, connection_type=None):
+ if not self.return_type:
+ fake_headers = httplib2.Response(headers)
+ return_obj = {
+ 'uri': uri,
+ 'method': method,
+ 'body': body,
+ 'headers': headers
+ }
+ return (fake_headers, return_obj)
+ # return (headers, return_obj)
+ elif isinstance(self.return_type, int):
+ body = "fake_body"
+ header_info = {
+ 'content-type': 'text/plain',
+ 'status': str(self.return_type),
+ 'content-length': len(body)
+ }
+ resp_header = httplib2.Response(header_info)
+ return (resp_header, body)
+ else:
+ msg = "unsupported return type %s" % self.return_type
+ raise TypeError(msg)
diff --git a/tempest/tests/test_rest_client.py b/tempest/tests/test_rest_client.py
new file mode 100644
index 0000000..ae6174c
--- /dev/null
+++ b/tempest/tests/test_rest_client.py
@@ -0,0 +1,92 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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 httplib2
+
+from tempest.common import rest_client
+from tempest import exceptions
+from tempest.openstack.common.fixture import mockpatch
+from tempest.tests import base
+from tempest.tests import fake_config
+from tempest.tests import fake_http
+
+
+class BaseRestClientTestClass(base.TestCase):
+
+ def _set_token(self):
+ self.rest_client.token = 'fake token'
+
+ def setUp(self):
+ super(BaseRestClientTestClass, self).setUp()
+ self.rest_client = rest_client.RestClient(fake_config.FakeConfig(),
+ 'fake_user', 'fake_pass',
+ 'http://fake_url/v2.0')
+ self.stubs.Set(httplib2.Http, 'request', self.fake_http.request)
+ self.useFixture(mockpatch.PatchObject(self.rest_client, '_set_auth',
+ side_effect=self._set_token()))
+ self.useFixture(mockpatch.PatchObject(self.rest_client,
+ '_log_response'))
+
+
+class TestRestClientHTTPMethods(BaseRestClientTestClass):
+ def setUp(self):
+ self.fake_http = fake_http.fake_httplib2()
+ super(TestRestClientHTTPMethods, self).setUp()
+ self.useFixture(mockpatch.PatchObject(self.rest_client,
+ '_error_checker'))
+
+ def test_post(self):
+ __, return_dict = self.rest_client.post('fake_endpoint', {},
+ {})
+ self.assertEqual('POST', return_dict['method'])
+
+ def test_get(self):
+ __, return_dict = self.rest_client.get('fake_endpoint')
+ self.assertEqual('GET', return_dict['method'])
+
+ def test_delete(self):
+ __, return_dict = self.rest_client.delete('fake_endpoint')
+ self.assertEqual('DELETE', return_dict['method'])
+
+ def test_patch(self):
+ __, return_dict = self.rest_client.patch('fake_endpoint', {},
+ {})
+ self.assertEqual('PATCH', return_dict['method'])
+
+ def test_put(self):
+ __, return_dict = self.rest_client.put('fake_endpoint', {},
+ {})
+ self.assertEqual('PUT', return_dict['method'])
+
+ def test_head(self):
+ self.useFixture(mockpatch.PatchObject(self.rest_client,
+ 'response_checker'))
+ __, return_dict = self.rest_client.head('fake_endpoint')
+ self.assertEqual('HEAD', return_dict['method'])
+
+ def test_copy(self):
+ __, return_dict = self.rest_client.copy('fake_endpoint')
+ self.assertEqual('COPY', return_dict['method'])
+
+
+class TestRestClientNotFoundHandling(BaseRestClientTestClass):
+ def setUp(self):
+ self.fake_http = fake_http.fake_httplib2(404)
+ super(TestRestClientNotFoundHandling, self).setUp()
+
+ def test_post(self):
+ self.assertRaises(exceptions.NotFound, self.rest_client.post,
+ 'fake_endpoint', {}, {})
diff --git a/tempest/thirdparty/boto/test.py b/tempest/thirdparty/boto/test.py
index 5ae21c8..2f7a650 100644
--- a/tempest/thirdparty/boto/test.py
+++ b/tempest/thirdparty/boto/test.py
@@ -29,7 +29,7 @@
import tempest.clients
from tempest.common.utils.file_utils import have_effective_read_access
-import tempest.config
+from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
import tempest.test
@@ -37,6 +37,7 @@
from tempest.thirdparty.boto.utils.wait import state_wait
from tempest.thirdparty.boto.utils.wait import wait_exception
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -50,11 +51,10 @@
def all_read(*args):
return all(map(have_effective_read_access, args))
- config = tempest.config.TempestConfig()
- materials_path = config.boto.s3_materials_path
- ami_path = materials_path + os.sep + config.boto.ami_manifest
- aki_path = materials_path + os.sep + config.boto.aki_manifest
- ari_path = materials_path + os.sep + config.boto.ari_manifest
+ materials_path = CONF.boto.s3_materials_path
+ ami_path = materials_path + os.sep + CONF.boto.ami_manifest
+ aki_path = materials_path + os.sep + CONF.boto.aki_manifest
+ ari_path = materials_path + os.sep + CONF.boto.ari_manifest
A_I_IMAGES_READY = all_read(ami_path, aki_path, ari_path)
boto_logger = logging.getLogger('boto')
@@ -70,7 +70,7 @@
raise Exception("Unknown (Authentication?) Error")
openstack = tempest.clients.Manager()
try:
- if urlparse.urlparse(config.boto.ec2_url).hostname is None:
+ if urlparse.urlparse(CONF.boto.ec2_url).hostname is None:
raise Exception("Failed to get hostname from the ec2_url")
ec2client = openstack.ec2api_client
try:
@@ -87,7 +87,7 @@
EC2_CAN_CONNECT_ERROR = str(exc)
try:
- if urlparse.urlparse(config.boto.s3_url).hostname is None:
+ if urlparse.urlparse(CONF.boto.s3_url).hostname is None:
raise Exception("Failed to get hostname from the s3_url")
s3client = openstack.s3_client
try:
diff --git a/tempest/thirdparty/boto/utils/wait.py b/tempest/thirdparty/boto/utils/wait.py
index 1cd847b..db2303a 100644
--- a/tempest/thirdparty/boto/utils/wait.py
+++ b/tempest/thirdparty/boto/utils/wait.py
@@ -21,17 +21,12 @@
import boto.exception
from testtools import TestCase
-import tempest.config
+from tempest import config
from tempest.openstack.common import log as logging
+CONF = config.CONF
LOG = logging.getLogger(__name__)
-_boto_config = tempest.config.TempestConfig().boto
-
-default_timeout = _boto_config.build_timeout
-
-default_check_interval = _boto_config.build_interval
-
def state_wait(lfunction, final_set=set(), valid_set=None):
# TODO(afazekas): evaluate using ABC here
@@ -50,12 +45,12 @@
if valid_set is not None and status not in valid_set:
return status
dtime = time.time() - start_time
- if dtime > default_timeout:
+ if dtime > CONF.boto.build_timeout:
raise TestCase.failureException("State change timeout exceeded!"
'(%ds) While waiting'
'for %s at "%s"' %
(dtime, final_set, status))
- time.sleep(default_check_interval)
+ time.sleep(CONF.boto.build_interval)
old_status = status
status = lfunction()
@@ -73,12 +68,12 @@
text)
return result
dtime = time.time() - start_time
- if dtime > default_timeout:
+ if dtime > CONF.boto.build_timeout:
raise TestCase.failureException('Pattern find timeout exceeded!'
'(%ds) While waiting for'
'"%s" pattern in "%s"' %
(dtime, regexp, text))
- time.sleep(default_check_interval)
+ time.sleep(CONF.boto.build_interval)
def wait_no_exception(lfunction, exc_class=None, exc_matcher=None):
@@ -104,10 +99,10 @@
raise exc
# Let the other exceptions propagate
dtime = time.time() - start_time
- if dtime > default_timeout:
+ if dtime > CONF.boto.build_timeout:
raise TestCase.failureException("Wait timeout exceeded! (%ds)" %
dtime)
- time.sleep(default_check_interval)
+ time.sleep(CONF.boto.build_interval)
# NOTE(afazekas): EC2/boto normally raise exception instead of empty list
@@ -122,9 +117,9 @@
time.time() - start_time)
return exc
dtime = time.time() - start_time
- if dtime > default_timeout:
+ if dtime > CONF.boto.build_timeout:
raise TestCase.failureException("Wait timeout exceeded! (%ds)" %
dtime)
- time.sleep(default_check_interval)
+ time.sleep(CONF.boto.build_interval)
# TODO(afazekas): consider strategy design pattern..
diff --git a/tools/verify_tempest_config.py b/tools/verify_tempest_config.py
index 347659d..8850c2e 100755
--- a/tools/verify_tempest_config.py
+++ b/tools/verify_tempest_config.py
@@ -21,7 +21,7 @@
from tempest import config
-CONF = config.TempestConfig()
+CONF = config.CONF
#Dicts matching extension names to config options
NOVA_EXTENSIONS = {
diff --git a/tox.ini b/tox.ini
index c7f92ae..b44b3e0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -8,6 +8,7 @@
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_ALL=C
+ OS_TEST_PATH=./tempest/test_discover
usedevelop = True
install_command = pip install -U {opts} {packages}