Merge "Enable all nova v3 tests"
diff --git a/include/sample_vm/README.txt b/include/sample_vm/README.txt
deleted file mode 100644
index 51b609d..0000000
--- a/include/sample_vm/README.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-You will need to download an image into this directory..
-Will also need to update the tests to reference this new image.
-
-You could use e.g. the Ubuntu Natty cloud images (this matches the sample configuration):
-$ wget http://cloud-images.ubuntu.com/releases/natty/release/ubuntu-11.04-server-cloudimg-amd64.tar.gz
-$ tar xvzf ubuntu-11.04-server-cloudimg-amd64.tar.gz
diff --git a/include/swift_objects/README.txt b/include/swift_objects/README.txt
deleted file mode 100644
index 3857524..0000000
--- a/include/swift_objects/README.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-## For the swift tests you will need three objects to upload for the test
-## examples below are a 512K object, a 500M object, and 1G object
-dd if=/dev/zero of=swift_small bs=512 count=1024
-dd if=/dev/zero of=swift_medium bs=512 count=1024000
-dd if=/dev/zero of=swift_large bs=1024 count=1024000
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index f29a202..715ec16 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -158,6 +158,7 @@
cls.services_client = cls.os.services_client
cls.hypervisor_client = cls.os.hypervisor_client
cls.servers_client_v3_auth = cls.os.servers_client_v3_auth
+ cls.certificates_client = cls.os.certificates_client
@classmethod
def create_image_from_server(cls, server_id, **kwargs):
@@ -229,6 +230,8 @@
cls.servers_client = cls.os.servers_v3_client
cls.images_client = cls.os.image_client
+ cls.services_client = cls.os.services_v3_client
+ cls.extensions_client = cls.os.extensions_v3_client
@classmethod
def create_image_from_server(cls, server_id, **kwargs):
@@ -288,3 +291,4 @@
cls.os_adm = os_adm
cls.severs_admin_client = cls.os_adm.servers_v3_client
+ cls.services_admin_client = cls.os_adm.services_v3_client
diff --git a/tempest/api/compute/certificates/__init__.py b/tempest/api/compute/certificates/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api/compute/certificates/__init__.py
diff --git a/tempest/api/compute/certificates/test_certificates.py b/tempest/api/compute/certificates/test_certificates.py
new file mode 100644
index 0000000..4be1cff
--- /dev/null
+++ b/tempest/api/compute/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 CertificatesTestJSON(base.BaseV2ComputeTest):
+ _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(200, 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 CertificatesTestXML(CertificatesTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 961737a..b8700ec 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -22,6 +22,7 @@
from tempest.api import compute
from tempest.api.compute import base
+from tempest.common.utils.data_utils import parse_image_id
from tempest.common.utils.data_utils import rand_name
from tempest.common.utils.linux.remote_client import RemoteClient
import tempest.config
@@ -199,6 +200,74 @@
raise exceptions.TimeoutException(message)
@attr(type='gate')
+ def test_create_backup(self):
+ # Positive test:create backup successfully and rotate backups correctly
+ # create the first and the second backup
+ backup1 = rand_name('backup')
+ resp, _ = self.servers_client.create_backup(self.server_id,
+ 'daily',
+ 2,
+ backup1)
+ oldest_backup_exist = True
+
+ # the oldest one should be deleted automatically in this test
+ def _clean_oldest_backup(oldest_backup):
+ if oldest_backup_exist:
+ self.os.image_client.delete_image(oldest_backup)
+
+ image1_id = parse_image_id(resp['location'])
+ self.addCleanup(_clean_oldest_backup, image1_id)
+ self.assertEqual(202, resp.status)
+
+ backup2 = rand_name('backup')
+ self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+ resp, _ = self.servers_client.create_backup(self.server_id,
+ 'daily',
+ 2,
+ backup2)
+ image2_id = parse_image_id(resp['location'])
+ self.addCleanup(self.os.image_client.delete_image, image2_id)
+ self.assertEqual(202, resp.status)
+
+ # verify they have been created
+ properties = {
+ 'image_type': 'backup',
+ 'backup_type': "daily",
+ 'instance_uuid': self.server_id,
+ }
+ resp, image_list = self.os.image_client.image_list_detail(
+ properties,
+ sort_key='created_at',
+ sort_dir='asc')
+ self.assertEqual(200, resp.status)
+ self.assertEqual(2, len(image_list))
+ self.assertEqual((backup1, backup2),
+ (image_list[0]['name'], image_list[1]['name']))
+
+ # create the third one, due to the rotation is 2,
+ # the first one will be deleted
+ backup3 = rand_name('backup')
+ self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+ resp, _ = self.servers_client.create_backup(self.server_id,
+ 'daily',
+ 2,
+ backup3)
+ image3_id = parse_image_id(resp['location'])
+ self.addCleanup(self.os.image_client.delete_image, image3_id)
+ self.assertEqual(202, resp.status)
+ # the first back up should be deleted
+ self.os.image_client.wait_for_resource_deletion(image1_id)
+ oldest_backup_exist = False
+ resp, image_list = self.os.image_client.image_list_detail(
+ properties,
+ sort_key='created_at',
+ sort_dir='asc')
+ self.assertEqual(200, resp.status)
+ self.assertEqual(2, len(image_list))
+ self.assertEqual((backup2, backup3),
+ (image_list[0]['name'], image_list[1]['name']))
+
+ @attr(type='gate')
def test_get_console_output(self):
# Positive test:Should be able to GET the console output
# for a given server_id and number of lines
@@ -245,6 +314,31 @@
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
@attr(type='gate')
+ def test_shelve_unshelve_server(self):
+ resp, server = self.client.shelve_server(self.server_id)
+ self.assertEqual(202, resp.status)
+
+ offload_time = self.config.compute.shelved_offload_time
+ if offload_time >= 0:
+ self.client.wait_for_server_status(self.server_id,
+ 'SHELVED_OFFLOADED',
+ extra_timeout=offload_time)
+ else:
+ self.client.wait_for_server_status(self.server_id,
+ 'SHELVED')
+
+ resp, server = self.client.get_server(self.server_id)
+ image_name = server['name'] + '-shelved'
+ params = {'name': image_name}
+ resp, images = self.images_client.list_images(params)
+ self.assertEqual(1, len(images))
+ self.assertEqual(image_name, images[0]['name'])
+
+ resp, server = self.client.unshelve_server(self.server_id)
+ self.assertEqual(202, resp.status)
+ self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+
+ @attr(type='gate')
def test_stop_start_server(self):
resp, server = self.servers_client.stop(self.server_id)
self.assertEqual(202, resp.status)
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index 7eb127d..b12afd1 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -396,6 +396,54 @@
self.client.restore_soft_deleted_server,
self.server_id)
+ @attr(type=['negative', 'gate'])
+ def test_shelve_non_existent_server(self):
+ # shelve a non existent server
+ nonexistent_server = str(uuid.uuid4())
+ self.assertRaises(exceptions.NotFound, self.client.shelve_server,
+ nonexistent_server)
+
+ @attr(type=['negative', 'gate'])
+ def test_shelve_shelved_server(self):
+ # shelve a shelved server.
+ resp, server = self.client.shelve_server(self.server_id)
+ self.assertEqual(202, resp.status)
+ self.addCleanup(self.client.unshelve_server, self.server_id)
+
+ offload_time = self.config.compute.shelved_offload_time
+ if offload_time >= 0:
+ self.client.wait_for_server_status(self.server_id,
+ 'SHELVED_OFFLOADED',
+ extra_timeout=offload_time)
+ else:
+ self.client.wait_for_server_status(self.server_id,
+ 'SHELVED')
+
+ resp, server = self.client.get_server(self.server_id)
+ image_name = server['name'] + '-shelved'
+ params = {'name': image_name}
+ resp, images = self.images_client.list_images(params)
+ self.assertEqual(1, len(images))
+ self.assertEqual(image_name, images[0]['name'])
+
+ self.assertRaises(exceptions.Conflict,
+ self.client.shelve_server,
+ self.server_id)
+
+ @attr(type=['negative', 'gate'])
+ def test_unshelve_non_existent_server(self):
+ # unshelve a non existent server
+ nonexistent_server = str(uuid.uuid4())
+ self.assertRaises(exceptions.NotFound, self.client.unshelve_server,
+ nonexistent_server)
+
+ @attr(type=['negative', 'gate'])
+ def test_unshelve_server_invalid_state(self):
+ # unshelve an active server.
+ self.assertRaises(exceptions.Conflict,
+ self.client.unshelve_server,
+ self.server_id)
+
class ServersNegativeTestXML(ServersNegativeTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/__init__.py b/tempest/api/compute/v3/admin/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api/compute/v3/admin/__init__.py
diff --git a/tempest/api/compute/v3/admin/test_services.py b/tempest/api/compute/v3/admin/test_services.py
new file mode 100644
index 0000000..67f9947
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_services.py
@@ -0,0 +1,135 @@
+# 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 ServicesAdminV3TestJSON(base.BaseV3ComputeAdminTest):
+
+ """
+ Tests Services API. List and Enable/Disable require admin privileges.
+ """
+
+ _interface = 'json'
+
+ @classmethod
+ 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):
+ resp, services = self.client.list_services()
+ 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'
+ params = {'binary': binary_name}
+ resp, services = self.client.list_services(params)
+ self.assertEqual(200, resp.status)
+ self.assertNotEqual(0, len(services))
+ for service in services:
+ self.assertEqual(binary_name, service['binary'])
+
+ @attr(type='gate')
+ def test_get_service_by_host_name(self):
+ resp, services = self.client.list_services()
+ host_name = services[0]['host']
+ services_on_host = [service for service in services if
+ service['host'] == host_name]
+ params = {'host': host_name}
+ resp, services = self.client.list_services(params)
+
+ # we could have a periodic job checkin between the 2 service
+ # lookups, so only compare binary lists.
+ s1 = map(lambda x: x['binary'], services)
+ s2 = map(lambda x: x['binary'], services_on_host)
+
+ # sort the lists before comparing, to take out dependency
+ # 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()
+ host_name = services[0]['host']
+ binary_name = services[0]['binary']
+ params = {'host': host_name, 'binary': binary_name}
+ resp, services = self.client.list_services(params)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(1, len(services))
+ 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))
+
+ @attr(type='gate')
+ def test_service_enable_disable(self):
+ resp, services = self.client.list_services()
+ host_name = services[0]['host']
+ binary_name = services[0]['binary']
+
+ resp, service = self.client.disable_service(host_name, binary_name)
+ self.assertEqual(200, resp.status)
+ params = {'host': host_name, 'binary': binary_name}
+ resp, services = self.client.list_services(params)
+ self.assertEqual('disabled', services[0]['status'])
+
+ resp, service = self.client.enable_service(host_name, binary_name)
+ self.assertEqual(200, resp.status)
+ resp, services = self.client.list_services(params)
+ self.assertEqual('enabled', services[0]['status'])
+
+
+class ServicesAdminV3TestXML(ServicesAdminV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/test_extensions.py b/tempest/api/compute/v3/test_extensions.py
new file mode 100644
index 0000000..d7269d1
--- /dev/null
+++ b/tempest/api/compute/v3/test_extensions.py
@@ -0,0 +1,35 @@
+# 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 ExtensionsV3TestJSON(base.BaseV3ComputeTest):
+ _interface = 'json'
+
+ @attr(type='gate')
+ def test_list_extensions(self):
+ # List of all extensions
+ resp, extensions = self.extensions_client.list_extensions()
+ self.assertIn("extensions", extensions)
+ self.assertEqual(200, resp.status)
+
+
+class ExtensionsV3TestXML(ExtensionsV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/image/base.py b/tempest/api/image/base.py
index ab0cb00..28ed5b6 100644
--- a/tempest/api/image/base.py
+++ b/tempest/api/image/base.py
@@ -14,9 +14,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+import cStringIO as StringIO
+
from tempest import clients
from tempest.common import isolated_creds
-from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils import data_utils
from tempest import exceptions
from tempest.openstack.common import log as logging
import tempest.test
@@ -61,7 +63,7 @@
@classmethod
def create_image(cls, **kwargs):
"""Wrapper that returns a test image."""
- name = rand_name(cls.__name__ + "-instance")
+ name = data_utils.rand_name(cls.__name__ + "-instance")
if 'name' in kwargs:
name = kwargs.pop('name')
@@ -86,6 +88,36 @@
raise cls.skipException(msg)
+class BaseV1ImageMembersTest(BaseV1ImageTest):
+ @classmethod
+ def setUpClass(cls):
+ super(BaseV1ImageMembersTest, cls).setUpClass()
+ if cls.config.compute.allow_tenant_isolation:
+ creds = cls.isolated_creds.get_alt_creds()
+ username, tenant_name, password = creds
+ cls.os_alt = clients.Manager(username=username,
+ password=password,
+ tenant_name=tenant_name)
+ cls.alt_tenant_id = cls.isolated_creds.get_alt_tenant()['id']
+ else:
+ cls.os_alt = clients.AltManager()
+ identity_client = cls._get_identity_admin_client()
+ cls.alt_tenant_id = identity_client.get_tenant_by_name(
+ cls.os_alt.tenant_name)['id']
+
+ cls.alt_img_cli = cls.os_alt.image_client
+
+ def _create_image(self):
+ image_file = StringIO.StringIO('*' * 1024)
+ resp, image = self.create_image(container_format='bare',
+ disk_format='raw',
+ is_public=False,
+ data=image_file)
+ self.assertEqual(201, resp.status)
+ image_id = image['id']
+ return image_id
+
+
class BaseV2ImageTest(BaseImageTest):
@classmethod
@@ -95,3 +127,40 @@
if not cls.config.image_feature_enabled.api_v2:
msg = "Glance API v2 not supported"
raise cls.skipException(msg)
+
+
+class BaseV2MemeberImageTest(BaseImageTest):
+
+ @classmethod
+ def setUpClass(cls):
+ super(BaseV2MemeberImageTest, cls).setUpClass()
+ if cls.config.compute.allow_tenant_isolation:
+ creds = cls.isolated_creds.get_alt_creds()
+ username, tenant_name, password = creds
+ cls.os_alt = clients.Manager(username=username,
+ password=password,
+ tenant_name=tenant_name,
+ interface=cls._interface)
+ cls.alt_tenant_id = cls.isolated_creds.get_alt_tenant()['id']
+ else:
+ cls.os_alt = clients.AltManager()
+ alt_tenant_name = cls.os_alt.tenant_name
+ identity_client = cls._get_identity_admin_client()
+ cls.alt_tenant_id = identity_client.get_tenant_by_name(
+ alt_tenant_name)['id']
+ cls.os_img_client = cls.os.image_client_v2
+ cls.alt_img_client = cls.os_alt.image_client_v2
+
+ def _list_image_ids_as_alt(self):
+ _, image_list = self.alt_img_client.image_list()
+ image_ids = map(lambda x: x['id'], image_list)
+ return image_ids
+
+ def _create_image(self):
+ name = data_utils.rand_name('image')
+ resp, image = self.os_img_client.create_image(name,
+ container_format='bare',
+ disk_format='raw')
+ image_id = image['id']
+ self.addCleanup(self.os_img_client.delete_image, image_id)
+ return image_id
diff --git a/tempest/api/image/v1/test_image_members.py b/tempest/api/image/v1/test_image_members.py
index 9ea9a3d..437527d 100644
--- a/tempest/api/image/v1/test_image_members.py
+++ b/tempest/api/image/v1/test_image_members.py
@@ -14,44 +14,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-import cStringIO as StringIO
from tempest.api.image import base
-from tempest import clients
-from tempest.common.utils.data_utils import rand_name
-from tempest import exceptions
from tempest.test import attr
-class ImageMembersTests(base.BaseV1ImageTest):
-
- @classmethod
- def setUpClass(cls):
- super(ImageMembersTests, cls).setUpClass()
- if cls.config.compute.allow_tenant_isolation:
- creds = cls.isolated_creds.get_alt_creds()
- username, tenant_name, password = creds
- cls.os_alt = clients.Manager(username=username,
- password=password,
- tenant_name=tenant_name)
- else:
- cls.os_alt = clients.AltManager()
-
- alt_tenant_name = cls.os_alt.tenant_name
- identity_client = cls._get_identity_admin_client()
- _, tenants = identity_client.list_tenants()
- cls.alt_tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
- alt_tenant_name][0]
-
- def _create_image(self):
- image_file = StringIO.StringIO('*' * 1024)
- resp, image = self.create_image(container_format='bare',
- disk_format='raw',
- is_public=False,
- data=image_file)
- self.assertEqual(201, resp.status)
- image_id = image['id']
- return image_id
+class ImageMembersTest(base.BaseV1ImageMembersTest):
@attr(type='gate')
def test_add_image_member(self):
@@ -63,6 +31,9 @@
members = body['members']
members = map(lambda x: x['member_id'], members)
self.assertIn(self.alt_tenant_id, members)
+ # get image as alt user
+ resp, body = self.alt_img_cli.get_image(image)
+ self.assertEqual(200, resp.status)
@attr(type='gate')
def test_get_shared_images(self):
@@ -90,25 +61,3 @@
self.assertEqual(200, resp.status)
members = body['members']
self.assertEqual(0, len(members), str(members))
-
- @attr(type=['negative', 'gate'])
- def test_add_member_with_non_existing_image(self):
- # Add member with non existing image.
- non_exist_image = rand_name('image_')
- self.assertRaises(exceptions.NotFound, self.client.add_member,
- self.alt_tenant_id, non_exist_image)
-
- @attr(type=['negative', 'gate'])
- def test_delete_member_with_non_existing_image(self):
- # Delete member with non existing image.
- non_exist_image = rand_name('image_')
- self.assertRaises(exceptions.NotFound, self.client.delete_member,
- self.alt_tenant_id, non_exist_image)
-
- @attr(type=['negative', 'gate'])
- def test_delete_member_with_non_existing_tenant(self):
- # Delete member with non existing tenant.
- image_id = self._create_image()
- non_exist_tenant = rand_name('tenant_')
- self.assertRaises(exceptions.NotFound, self.client.delete_member,
- non_exist_tenant, image_id)
diff --git a/tempest/api/image/v1/test_image_members_negative.py b/tempest/api/image/v1/test_image_members_negative.py
new file mode 100644
index 0000000..83f7a0f
--- /dev/null
+++ b/tempest/api/image/v1/test_image_members_negative.py
@@ -0,0 +1,54 @@
+# 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.
+
+
+from tempest.api.image import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest.test import attr
+
+
+class ImageMembersNegativeTest(base.BaseV1ImageMembersTest):
+
+ @attr(type=['negative', 'gate'])
+ def test_add_member_with_non_existing_image(self):
+ # Add member with non existing image.
+ non_exist_image = data_utils.rand_uuid()
+ self.assertRaises(exceptions.NotFound, self.client.add_member,
+ self.alt_tenant_id, non_exist_image)
+
+ @attr(type=['negative', 'gate'])
+ def test_delete_member_with_non_existing_image(self):
+ # Delete member with non existing image.
+ non_exist_image = data_utils.rand_uuid()
+ self.assertRaises(exceptions.NotFound, self.client.delete_member,
+ self.alt_tenant_id, non_exist_image)
+
+ @attr(type=['negative', 'gate'])
+ def test_delete_member_with_non_existing_tenant(self):
+ # Delete member with non existing tenant.
+ image_id = self._create_image()
+ non_exist_tenant = data_utils.rand_uuid_hex()
+ self.assertRaises(exceptions.NotFound, self.client.delete_member,
+ non_exist_tenant, image_id)
+
+ @attr(type=['negative', 'gate'])
+ def test_get_image_without_membership(self):
+ # Image is hidden from another tenants.
+ image_id = self._create_image()
+ self.assertRaises(exceptions.NotFound,
+ self.alt_img_cli.get_image,
+ image_id)
diff --git a/tempest/api/image/v2/test_images_member.py b/tempest/api/image/v2/test_images_member.py
new file mode 100644
index 0000000..954c79d
--- /dev/null
+++ b/tempest/api/image/v2/test_images_member.py
@@ -0,0 +1,55 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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.image import base
+from tempest.test import attr
+
+
+class ImagesMemberTest(base.BaseV2MemeberImageTest):
+ _interface = 'json'
+
+ @attr(type='gate')
+ def test_image_share_accept(self):
+ image_id = self._create_image()
+ resp, member = self.os_img_client.add_member(image_id,
+ self.alt_tenant_id)
+ self.assertEqual(member['member_id'], self.alt_tenant_id)
+ self.assertEqual(member['image_id'], image_id)
+ self.assertEqual(member['status'], 'pending')
+ self.assertNotIn(image_id, self._list_image_ids_as_alt())
+ self.alt_img_client.update_member_status(image_id,
+ self.alt_tenant_id,
+ 'accepted')
+ self.assertIn(image_id, self._list_image_ids_as_alt())
+ _, body = self.os_img_client.get_image_membership(image_id)
+ members = body['members']
+ member = members[0]
+ self.assertEqual(len(members), 1, str(members))
+ self.assertEqual(member['member_id'], self.alt_tenant_id)
+ self.assertEqual(member['image_id'], image_id)
+ self.assertEqual(member['status'], 'accepted')
+
+ @attr(type='gate')
+ def test_image_share_reject(self):
+ image_id = self._create_image()
+ resp, member = self.os_img_client.add_member(image_id,
+ self.alt_tenant_id)
+ self.assertEqual(member['member_id'], self.alt_tenant_id)
+ self.assertEqual(member['image_id'], image_id)
+ self.assertEqual(member['status'], 'pending')
+ self.assertNotIn(image_id, self._list_image_ids_as_alt())
+ self.alt_img_client.update_member_status(image_id,
+ self.alt_tenant_id,
+ 'rejected')
+ self.assertNotIn(image_id, self._list_image_ids_as_alt())
diff --git a/tempest/api/image/v2/test_images_member_negative.py b/tempest/api/image/v2/test_images_member_negative.py
new file mode 100644
index 0000000..3c17959
--- /dev/null
+++ b/tempest/api/image/v2/test_images_member_negative.py
@@ -0,0 +1,43 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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.image import base
+from tempest import exceptions
+from tempest.test import attr
+
+
+class ImagesMemberNegativeTest(base.BaseV2MemeberImageTest):
+ _interface = 'json'
+
+ @attr(type=['negative', 'gate'])
+ def test_image_share_invalid_status(self):
+ image_id = self._create_image()
+ resp, member = self.os_img_client.add_member(image_id,
+ self.alt_tenant_id)
+ self.assertEqual(member['status'], 'pending')
+ self.assertRaises(exceptions.BadRequest,
+ self.alt_img_client.update_member_status,
+ image_id, self.alt_tenant_id, 'notavalidstatus')
+
+ @attr(type=['negative', 'gate'])
+ def test_image_share_owner_cannot_accept(self):
+ image_id = self._create_image()
+ resp, member = self.os_img_client.add_member(image_id,
+ self.alt_tenant_id)
+ self.assertEqual(member['status'], 'pending')
+ self.assertNotIn(image_id, self._list_image_ids_as_alt())
+ self.assertRaises(exceptions.Unauthorized,
+ self.os_img_client.update_member_status,
+ image_id, self.alt_tenant_id, 'accepted')
+ self.assertNotIn(image_id, self._list_image_ids_as_alt())
diff --git a/tempest/api/network/admin/__init__.py b/tempest/api/network/admin/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api/network/admin/__init__.py
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
new file mode 100644
index 0000000..5b04cbb
--- /dev/null
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -0,0 +1,64 @@
+# 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.
+
+from tempest.api.network import base
+from tempest.common.utils.data_utils import rand_name
+from tempest.test import attr
+
+
+class L3AgentSchedulerJSON(base.BaseAdminNetworkTest):
+ _interface = 'json'
+
+ """
+ Tests the following operations in the Neutron API using the REST client for
+ Neutron:
+
+ List routers that the given L3 agent is hosting.
+ List L3 agents hosting the given router.
+
+ 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:
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(L3AgentSchedulerJSON, cls).setUpClass()
+
+ @attr(type='smoke')
+ def test_list_routers_on_l3_agent(self):
+ resp, body = self.admin_client.list_agents()
+ agents = body['agents']
+ for a in agents:
+ if a['agent_type'] == 'L3 agent':
+ agent = a
+ resp, body = self.admin_client.list_routers_on_l3_agent(
+ agent['id'])
+ self.assertEqual('200', resp['status'])
+
+ @attr(type='smoke')
+ def test_list_l3_agents_hosting_router(self):
+ name = rand_name('router-')
+ resp, router = self.client.create_router(name)
+ self.assertEqual('201', resp['status'])
+ resp, body = self.admin_client.list_l3_agents_hosting_router(
+ router['router']['id'])
+ self.assertEqual('200', resp['status'])
+ resp, _ = self.client.delete_router(router['router']['id'])
+ self.assertEqual(204, resp.status)
+
+
+class L3AgentSchedulerXML(L3AgentSchedulerJSON):
+ _interface = 'xml'
diff --git a/tempest/api/network/test_service_type_management.py b/tempest/api/network/test_service_type_management.py
new file mode 100644
index 0000000..ae03e96
--- /dev/null
+++ b/tempest/api/network/test_service_type_management.py
@@ -0,0 +1,30 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+#
+# 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.test import attr
+
+
+class ServiceTypeManagementTestJSON(base.BaseNetworkTest):
+ _interface = 'json'
+
+ @attr(type='smoke')
+ def test_service_provider_list(self):
+ resp, body = self.client.list_service_providers()
+ self.assertEqual(resp['status'], '200')
+ self.assertIsInstance(body['service_providers'], list)
+
+
+class ServiceTypeManagementTestXML(ServiceTypeManagementTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index 538d5be..f42c2f5 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -237,6 +237,36 @@
resp, body = self.client.unreserve_volume(self.volume['id'])
self.assertEqual(202, resp.status)
+ @attr(type=['negative', 'gate'])
+ def test_list_volumes_with_nonexistent_name(self):
+ v_name = rand_name('Volume-')
+ params = {'display_name': v_name}
+ resp, fetched_volume = self.client.list_volumes(params)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(0, len(fetched_volume))
+
+ @attr(type=['negative', 'gate'])
+ def test_list_volumes_detail_with_nonexistent_name(self):
+ v_name = rand_name('Volume-')
+ params = {'display_name': v_name}
+ resp, fetched_volume = self.client.list_volumes_with_detail(params)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(0, len(fetched_volume))
+
+ @attr(type=['negative', 'gate'])
+ def test_list_volumes_with_invalid_status(self):
+ params = {'status': 'null'}
+ resp, fetched_volume = self.client.list_volumes(params)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(0, len(fetched_volume))
+
+ @attr(type=['negative', 'gate'])
+ def test_list_volumes_detail_with_invalid_status(self):
+ params = {'status': 'null'}
+ resp, fetched_volume = self.client.list_volumes_with_detail(params)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(0, len(fetched_volume))
+
class VolumesNegativeTestXML(VolumesNegativeTest):
_interface = 'xml'
diff --git a/tempest/clients.py b/tempest/clients.py
index 156df30..a52ed5d 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -23,6 +23,8 @@
AggregatesClientJSON
from tempest.services.compute.json.availability_zone_client import \
AvailabilityZoneClientJSON
+from tempest.services.compute.json.certificates_client import \
+ CertificatesClientJSON
from tempest.services.compute.json.extensions_client import \
ExtensionsClientJSON
from tempest.services.compute.json.fixed_ips_client import FixedIPsClientJSON
@@ -46,12 +48,22 @@
TenantUsagesClientJSON
from tempest.services.compute.json.volumes_extensions_client import \
VolumesExtensionsClientJSON
+from tempest.services.compute.v3.json.extensions_client import \
+ ExtensionsV3ClientJSON
from tempest.services.compute.v3.json.servers_client import \
ServersV3ClientJSON
+from tempest.services.compute.v3.json.services_client import \
+ ServicesV3ClientJSON
+from tempest.services.compute.v3.xml.extensions_client import \
+ ExtensionsV3ClientXML
from tempest.services.compute.v3.xml.servers_client import ServersV3ClientXML
+from tempest.services.compute.v3.xml.services_client import \
+ ServicesV3ClientXML
from tempest.services.compute.xml.aggregates_client import AggregatesClientXML
from tempest.services.compute.xml.availability_zone_client import \
AvailabilityZoneClientXML
+from tempest.services.compute.xml.certificates_client import \
+ CertificatesClientXML
from tempest.services.compute.xml.extensions_client import ExtensionsClientXML
from tempest.services.compute.xml.fixed_ips_client import FixedIPsClientXML
from tempest.services.compute.xml.flavors_client import FlavorsClientXML
@@ -169,6 +181,7 @@
self.servers_client_v3_auth = None
if interface == 'xml':
+ self.certificates_client = CertificatesClientXML(*client_args)
self.servers_client = ServersClientXML(*client_args)
self.servers_v3_client = ServersV3ClientXML(*client_args)
self.limits_client = LimitsClientXML(*client_args)
@@ -176,6 +189,7 @@
self.keypairs_client = KeyPairsClientXML(*client_args)
self.quotas_client = QuotasClientXML(*client_args)
self.flavors_client = FlavorsClientXML(*client_args)
+ self.extensions_v3_client = ExtensionsV3ClientXML(*client_args)
self.extensions_client = ExtensionsClientXML(*client_args)
self.volumes_extensions_client = VolumesExtensionsClientXML(
*client_args)
@@ -193,6 +207,7 @@
self.fixed_ips_client = FixedIPsClientXML(*client_args)
self.availability_zone_client = AvailabilityZoneClientXML(
*client_args)
+ self.services_v3_client = ServicesV3ClientXML(*client_args)
self.service_client = ServiceClientXML(*client_args)
self.aggregates_client = AggregatesClientXML(*client_args)
self.services_client = ServicesClientXML(*client_args)
@@ -208,6 +223,7 @@
*client_args_v3_auth)
elif interface == 'json':
+ self.certificates_client = CertificatesClientJSON(*client_args)
self.servers_client = ServersClientJSON(*client_args)
self.servers_v3_client = ServersV3ClientJSON(*client_args)
self.limits_client = LimitsClientJSON(*client_args)
@@ -215,6 +231,7 @@
self.keypairs_client = KeyPairsClientJSON(*client_args)
self.quotas_client = QuotasClientJSON(*client_args)
self.flavors_client = FlavorsClientJSON(*client_args)
+ self.extensions_v3_client = ExtensionsV3ClientJSON(*client_args)
self.extensions_client = ExtensionsClientJSON(*client_args)
self.volumes_extensions_client = VolumesExtensionsClientJSON(
*client_args)
@@ -232,6 +249,7 @@
self.fixed_ips_client = FixedIPsClientJSON(*client_args)
self.availability_zone_client = AvailabilityZoneClientJSON(
*client_args)
+ self.services_v3_client = ServicesV3ClientJSON(*client_args)
self.service_client = ServiceClientJSON(*client_args)
self.aggregates_client = AggregatesClientJSON(*client_args)
self.services_client = ServicesClientJSON(*client_args)
diff --git a/tempest/common/utils/data_utils.py b/tempest/common/utils/data_utils.py
index 3ab8fe0..4f93e1c 100644
--- a/tempest/common/utils/data_utils.py
+++ b/tempest/common/utils/data_utils.py
@@ -19,10 +19,19 @@
import random
import re
import urllib
+import uuid
from tempest import exceptions
+def rand_uuid():
+ return str(uuid.uuid4())
+
+
+def rand_uuid_hex():
+ return uuid.uuid4().hex
+
+
def rand_name(name='test'):
return name + "-tempest-" + str(random.randint(1, 0x7fffffff))
diff --git a/tempest/common/waiters.py b/tempest/common/waiters.py
index 15569cd..bea2cdc 100644
--- a/tempest/common/waiters.py
+++ b/tempest/common/waiters.py
@@ -24,7 +24,8 @@
# NOTE(afazekas): This function needs to know a token and a subject.
-def wait_for_server_status(client, server_id, status, ready_wait=True):
+def wait_for_server_status(client, server_id, status, ready_wait=True,
+ extra_timeout=0):
"""Waits for a server to reach a given status."""
def _get_task_state(body):
@@ -37,6 +38,7 @@
old_status = server_status = body['status']
old_task_state = task_state = _get_task_state(body)
start_time = int(time.time())
+ timeout = client.build_timeout + extra_timeout
while True:
# NOTE(afazekas): Now the BUILD status only reached
# between the UNKOWN->ACTIVE transition.
@@ -70,12 +72,12 @@
if server_status == 'ERROR':
raise exceptions.BuildErrorException(server_id=server_id)
- timed_out = int(time.time()) - start_time >= client.build_timeout
+ timed_out = int(time.time()) - start_time >= timeout
if timed_out:
message = ('Server %s failed to reach %s status within the '
'required time (%s s).' %
- (server_id, status, client.build_timeout))
+ (server_id, status, timeout))
message += ' Current status: %s.' % server_status
raise exceptions.TimeoutException(message)
old_status = server_status
diff --git a/tempest/config.py b/tempest/config.py
index a629486..68b51c3 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -196,7 +196,14 @@
cfg.StrOpt('volume_device_name',
default='vdb',
help="Expected device name when a volume is attached to "
- "an instance")
+ "an instance"),
+ cfg.IntOpt('shelved_offload_time',
+ default=0,
+ help='Time in seconds before a shelved instance is eligible '
+ 'for removing from a host. -1 never offload, 0 offload '
+ 'when shelved. This time should be the same as the time '
+ 'of nova.conf, and some tests will run for as long as the '
+ 'time.')
]
compute_features_group = cfg.OptGroup(name='compute-feature-enabled',
diff --git a/tempest/exceptions.py b/tempest/exceptions.py
index 67406b0..02fc231 100644
--- a/tempest/exceptions.py
+++ b/tempest/exceptions.py
@@ -82,7 +82,7 @@
class ImageKilledException(TempestException):
- message = "Image %(image_id)s 'killed' while waiting for %(status)s"
+ message = "Image %(image_id)s 'killed' while waiting for '%(status)s'"
class AddImageException(TempestException):
diff --git a/tempest/services/compute/json/certificates_client.py b/tempest/services/compute/json/certificates_client.py
new file mode 100644
index 0000000..9fdce17
--- /dev/null
+++ b/tempest/services/compute/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 CertificatesClientJSON(RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(CertificatesClientJSON, self).__init__(config, username,
+ password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_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/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index 55a4a1b..87512fb 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -154,9 +154,10 @@
body = json.loads(body)
return resp, body
- def wait_for_server_status(self, server_id, status):
+ def wait_for_server_status(self, server_id, status, extra_timeout=0):
"""Waits for a server to reach a given status."""
- return waiters.wait_for_server_status(self, server_id, status)
+ return waiters.wait_for_server_status(self, server_id, status,
+ extra_timeout=extra_timeout)
def wait_for_server_termination(self, server_id, ignore_error=False):
"""Waits for server to reach termination."""
@@ -197,6 +198,13 @@
body = json.loads(body)[response_key]
return resp, body
+ def create_backup(self, server_id, backup_type, rotation, name):
+ """Backup a server instance."""
+ return self.action(server_id, "createBackup", None,
+ backup_type=backup_type,
+ rotation=rotation,
+ name=name)
+
def change_password(self, server_id, adminPass):
"""Changes the root password for the server."""
return self.action(server_id, 'changePassword', None,
@@ -333,25 +341,33 @@
return self.action(server_id, 'unlock', None, **kwargs)
def suspend_server(self, server_id, **kwargs):
- """Suspends the provded server."""
+ """Suspends the provided server."""
return self.action(server_id, 'suspend', None, **kwargs)
def resume_server(self, server_id, **kwargs):
- """Un-suspends the provded server."""
+ """Un-suspends the provided server."""
return self.action(server_id, 'resume', None, **kwargs)
def pause_server(self, server_id, **kwargs):
- """Pauses the provded server."""
+ """Pauses the provided server."""
return self.action(server_id, 'pause', None, **kwargs)
def unpause_server(self, server_id, **kwargs):
- """Un-pauses the provded server."""
+ """Un-pauses the provided server."""
return self.action(server_id, 'unpause', None, **kwargs)
def reset_state(self, server_id, state='error'):
"""Resets the state of a server to active/error."""
return self.action(server_id, 'os-resetState', None, state=state)
+ def shelve_server(self, server_id, **kwargs):
+ """Shelves the provided server."""
+ return self.action(server_id, 'shelve', None, **kwargs)
+
+ def unshelve_server(self, server_id, **kwargs):
+ """Un-shelves the provided server."""
+ return self.action(server_id, 'unshelve', None, **kwargs)
+
def get_console_output(self, server_id, length):
return self.action(server_id, 'os-getConsoleOutput', 'output',
length=length)
diff --git a/tempest/services/compute/v3/json/extensions_client.py b/tempest/services/compute/v3/json/extensions_client.py
new file mode 100644
index 0000000..60c0217
--- /dev/null
+++ b/tempest/services/compute/v3/json/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.
+
+import json
+
+from tempest.common.rest_client import RestClient
+
+
+class ExtensionsV3ClientJSON(RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(ExtensionsV3ClientJSON, self).__init__(config, username,
+ password, auth_url,
+ tenant_name)
+ self.service = self.config.compute.catalog_v3_type
+
+ def list_extensions(self):
+ url = 'extensions'
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body
+
+ def is_enabled(self, extension):
+ _, extensions = self.list_extensions()
+ exts = extensions['extensions']
+ return any([e for e in exts if e['name'] == extension])
diff --git a/tempest/services/compute/v3/json/servers_client.py b/tempest/services/compute/v3/json/servers_client.py
index 21b2b40..cddbb53 100644
--- a/tempest/services/compute/v3/json/servers_client.py
+++ b/tempest/services/compute/v3/json/servers_client.py
@@ -161,9 +161,10 @@
body = json.loads(body)
return resp, body
- def wait_for_server_status(self, server_id, status):
+ def wait_for_server_status(self, server_id, status, extra_timeout=0):
"""Waits for a server to reach a given status."""
- return waiters.wait_for_server_status(self, server_id, status)
+ return waiters.wait_for_server_status(self, server_id, status,
+ extra_timeout=extra_timeout)
def wait_for_server_termination(self, server_id, ignore_error=False):
"""Waits for server to reach termination."""
diff --git a/tempest/services/compute/v3/json/services_client.py b/tempest/services/compute/v3/json/services_client.py
new file mode 100644
index 0000000..41564e5
--- /dev/null
+++ b/tempest/services/compute/v3/json/services_client.py
@@ -0,0 +1,71 @@
+# 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.
+
+import json
+import urllib
+
+from tempest.common.rest_client import RestClient
+
+
+class ServicesV3ClientJSON(RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(ServicesV3ClientJSON, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
+
+ def list_services(self, params=None):
+ url = 'os-services'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['services']
+
+ def enable_service(self, host_name, binary):
+ """
+ Enable service on a host
+ host_name: Name of host
+ binary: Service binary
+ """
+ post_body = json.dumps({
+ 'service': {
+ 'binary': binary,
+ 'host': host_name
+ }
+ })
+ resp, body = self.put('os-services/enable', post_body, self.headers)
+ body = json.loads(body)
+ return resp, body['service']
+
+ def disable_service(self, host_name, binary):
+ """
+ Disable service on a host
+ host_name: Name of host
+ binary: Service binary
+ """
+ post_body = json.dumps({
+ 'service': {
+ 'binary': binary,
+ 'host': host_name
+ }
+ })
+ resp, body = self.put('os-services/disable', post_body, self.headers)
+ body = json.loads(body)
+ return resp, body['service']
diff --git a/tempest/services/compute/v3/xml/extensions_client.py b/tempest/services/compute/v3/xml/extensions_client.py
new file mode 100644
index 0000000..e03251c
--- /dev/null
+++ b/tempest/services/compute/v3/xml/extensions_client.py
@@ -0,0 +1,45 @@
+# 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 ExtensionsV3ClientXML(RestClientXML):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(ExtensionsV3ClientXML, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
+
+ def _parse_array(self, node):
+ array = []
+ for child in node:
+ array.append(xml_to_json(child))
+ return array
+
+ def list_extensions(self):
+ url = 'extensions'
+ resp, body = self.get(url, self.headers)
+ body = self._parse_array(etree.fromstring(body))
+ return resp, {'extensions': body}
+
+ def is_enabled(self, extension):
+ _, extensions = self.list_extensions()
+ exts = extensions['extensions']
+ return any([e for e in exts if e['name'] == extension])
diff --git a/tempest/services/compute/v3/xml/servers_client.py b/tempest/services/compute/v3/xml/servers_client.py
index 7a8b370..2ad5849 100644
--- a/tempest/services/compute/v3/xml/servers_client.py
+++ b/tempest/services/compute/v3/xml/servers_client.py
@@ -376,9 +376,10 @@
server = self._parse_server(etree.fromstring(body))
return resp, server
- def wait_for_server_status(self, server_id, status):
+ def wait_for_server_status(self, server_id, status, extra_timeout=0):
"""Waits for a server to reach a given status."""
- return waiters.wait_for_server_status(self, server_id, status)
+ return waiters.wait_for_server_status(self, server_id, status,
+ extra_timeout=extra_timeout)
def wait_for_server_termination(self, server_id, ignore_error=False):
"""Waits for server to reach termination."""
diff --git a/tempest/services/compute/v3/xml/services_client.py b/tempest/services/compute/v3/xml/services_client.py
new file mode 100644
index 0000000..855641b
--- /dev/null
+++ b/tempest/services/compute/v3/xml/services_client.py
@@ -0,0 +1,73 @@
+# 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.
+
+import urllib
+
+from lxml import etree
+from tempest.common.rest_client import RestClientXML
+from tempest.services.compute.xml.common import Document
+from tempest.services.compute.xml.common import Element
+from tempest.services.compute.xml.common import xml_to_json
+
+
+class ServicesV3ClientXML(RestClientXML):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(ServicesV3ClientXML, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
+
+ def list_services(self, params=None):
+ url = 'os-services'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url, self.headers)
+ node = etree.fromstring(body)
+ body = [xml_to_json(x) for x in node.getchildren()]
+ return resp, body
+
+ def enable_service(self, host_name, binary):
+ """
+ Enable service on a host
+ host_name: Name of host
+ binary: Service binary
+ """
+ post_body = Element("service")
+ post_body.add_attr('binary', binary)
+ post_body.add_attr('host', host_name)
+
+ resp, body = self.put('os-services/enable', str(Document(post_body)),
+ self.headers)
+ body = xml_to_json(etree.fromstring(body))
+ return resp, body
+
+ def disable_service(self, host_name, binary):
+ """
+ Disable service on a host
+ host_name: Name of host
+ binary: Service binary
+ """
+ post_body = Element("service")
+ post_body.add_attr('binary', binary)
+ post_body.add_attr('host', host_name)
+
+ resp, body = self.put('os-services/disable', str(Document(post_body)),
+ self.headers)
+ body = xml_to_json(etree.fromstring(body))
+ return resp, body
diff --git a/tempest/services/compute/xml/certificates_client.py b/tempest/services/compute/xml/certificates_client.py
new file mode 100644
index 0000000..7523352
--- /dev/null
+++ b/tempest/services/compute/xml/certificates_client.py
@@ -0,0 +1,40 @@
+# 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 CertificatesClientXML(RestClientXML):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(CertificatesClientXML, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_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/xml/servers_client.py b/tempest/services/compute/xml/servers_client.py
index e21bfc4..3319238 100644
--- a/tempest/services/compute/xml/servers_client.py
+++ b/tempest/services/compute/xml/servers_client.py
@@ -217,6 +217,14 @@
"""Un-pauses the provided server."""
return self.action(server_id, 'unpause', None, **kwargs)
+ def shelve_server(self, server_id, **kwargs):
+ """Shelves the provided server."""
+ return self.action(server_id, 'shelve', None, **kwargs)
+
+ def unshelve_server(self, server_id, **kwargs):
+ """Un-shelves the provided server."""
+ return self.action(server_id, 'unshelve', None, **kwargs)
+
def reset_state(self, server_id, state='error'):
"""Resets the state of a server to active/error."""
return self.action(server_id, 'os-resetState', None, state=state)
@@ -351,9 +359,10 @@
server = self._parse_server(etree.fromstring(body))
return resp, server
- def wait_for_server_status(self, server_id, status):
+ def wait_for_server_status(self, server_id, status, extra_timeout=0):
"""Waits for a server to reach a given status."""
- return waiters.wait_for_server_status(self, server_id, status)
+ return waiters.wait_for_server_status(self, server_id, status,
+ extra_timeout=extra_timeout)
def wait_for_server_termination(self, server_id, ignore_error=False):
"""Waits for server to reach termination."""
@@ -411,6 +420,13 @@
body = xml_to_json(etree.fromstring(body))
return resp, body
+ def create_backup(self, server_id, backup_type, rotation, name):
+ """Backup a server instance."""
+ return self.action(server_id, "createBackup", None,
+ backup_type=backup_type,
+ rotation=rotation,
+ name=name)
+
def change_password(self, server_id, password):
return self.action(server_id, "changePassword", None,
adminPass=password)
diff --git a/tempest/services/image/v1/json/image_client.py b/tempest/services/image/v1/json/image_client.py
index b19f65d..9f5a405 100644
--- a/tempest/services/image/v1/json/image_client.py
+++ b/tempest/services/image/v1/json/image_client.py
@@ -187,9 +187,15 @@
body = json.loads(body)
return resp, body['images']
- def image_list_detail(self, **kwargs):
+ def image_list_detail(self, properties=dict(), **kwargs):
url = 'v1/images/detail'
+ params = {}
+ for key, value in properties.items():
+ params['property-%s' % key] = value
+
+ kwargs.update(params)
+
if len(kwargs) > 0:
url += '?%s' % urllib.urlencode(kwargs)
@@ -270,7 +276,7 @@
if value == 'killed':
raise exceptions.ImageKilledException(image_id=image_id,
- status=value)
+ status=status)
if dtime > self.build_timeout:
message = ('Time Limit Exceeded! (%ds)'
'while waiting for %s, '
diff --git a/tempest/services/image/v2/json/image_client.py b/tempest/services/image/v2/json/image_client.py
index 342a09c..3d37267 100644
--- a/tempest/services/image/v2/json/image_client.py
+++ b/tempest/services/image/v2/json/image_client.py
@@ -134,3 +134,27 @@
url = 'v2/images/%s/tags/%s' % (image_id, tag)
resp, _ = self.delete(url)
return resp
+
+ def get_image_membership(self, image_id):
+ url = 'v2/images/%s/members' % image_id
+ resp, body = self.get(url)
+ body = json.loads(body)
+ self.expected_success(200, resp)
+ return resp, body
+
+ def add_member(self, image_id, member_id):
+ url = 'v2/images/%s/members' % image_id
+ data = json.dumps({'member': member_id})
+ resp, body = self.post(url, data, self.headers)
+ body = json.loads(body)
+ self.expected_success(200, resp)
+ return resp, body
+
+ def update_member_status(self, image_id, member_id, status):
+ """Valid status are: ``pending``, ``accepted``, ``rejected``."""
+ url = 'v2/images/%s/members/%s' % (image_id, member_id)
+ data = json.dumps({'status': status})
+ resp, body = self.put(url, data, self.headers)
+ body = json.loads(body)
+ self.expected_success(200, resp)
+ return resp, body
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index e7cd33f..aa7f2f2 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -673,3 +673,27 @@
resp, body = self.get(uri, self.headers)
body = json.loads(body)
return resp, body
+
+ def list_agents(self):
+ uri = '%s/agents' % self.uri_prefix
+ resp, body = self.get(uri, self.headers)
+ body = json.loads(body)
+ return resp, body
+
+ def list_routers_on_l3_agent(self, agent_id):
+ uri = '%s/agents/%s/l3-routers' % (self.uri_prefix, agent_id)
+ resp, body = self.get(uri, self.headers)
+ body = json.loads(body)
+ return resp, body
+
+ def list_l3_agents_hosting_router(self, router_id):
+ uri = '%s/routers/%s/l3-agents' % (self.uri_prefix, router_id)
+ resp, body = self.get(uri, self.headers)
+ body = json.loads(body)
+ return resp, body
+
+ def list_service_providers(self):
+ uri = '%s/service-providers' % self.uri_prefix
+ resp, body = self.get(uri, self.headers)
+ body = json.loads(body)
+ return resp, body
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
index 04ad86f..5af2dfb 100755
--- a/tempest/services/network/xml/network_client.py
+++ b/tempest/services/network/xml/network_client.py
@@ -554,6 +554,32 @@
ports = {"ports": ports}
return resp, ports
+ def list_agents(self):
+ uri = '%s/agents' % self.uri_prefix
+ resp, body = self.get(uri, self.headers)
+ agents = self._parse_array(etree.fromstring(body))
+ agents = {'agents': agents}
+ return resp, agents
+
+ def list_routers_on_l3_agent(self, agent_id):
+ uri = '%s/agents/%s/l3-routers' % (self.uri_prefix, agent_id)
+ resp, body = self.get(uri, self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def list_l3_agents_hosting_router(self, router_id):
+ uri = '%s/routers/%s/l3-agents' % (self.uri_prefix, router_id)
+ resp, body = self.get(uri, self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def list_service_providers(self):
+ uri = '%s/service-providers' % self.uri_prefix
+ resp, body = self.get(uri, self.headers)
+ providers = self._parse_array(etree.fromstring(body))
+ body = {'service_providers': providers}
+ return resp, body
+
def _root_tag_fetcher_and_xml_to_json_parse(xml_returned_body):
body = ET.fromstring(xml_returned_body)
diff --git a/tox.ini b/tox.ini
index a3c781b..9356dd7 100644
--- a/tox.ini
+++ b/tox.ini
@@ -77,6 +77,11 @@
[testenv:smoke]
sitepackages = True
+commands =
+ sh tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])((smoke)|(^tempest\.scenario)) {posargs}'
+
+[testenv:smoke-serial]
+sitepackages = True
# This is still serial because neutron doesn't work with parallel. See:
# https://bugs.launchpad.net/tempest/+bug/1216076 so the neutron smoke
# job would fail if we moved it to parallel.