Merge "Adding description for testcases - swift part3"
diff --git a/releasenotes/notes/25/subunt-describe-call-verbose-arg-fix.yaml b/releasenotes/notes/25/subunt-describe-call-verbose-arg-fix.yaml
new file mode 100644
index 0000000..d2a644e
--- /dev/null
+++ b/releasenotes/notes/25/subunt-describe-call-verbose-arg-fix.yaml
@@ -0,0 +1,10 @@
+---
+fixes:
+ - |
+ Fixed bug #1890060. tempest subunit_describe_calls --verbose not working with Cliff CLI.
+ The subunit_describe_calls --verbose argument was a boolean and worked in the non Cliff CLI
+ which is now deprecated, but does not work with cliff since --verbase is a standard cliff
+ argument which is an int. Since the tool is in lib directory we cannot change the interface,
+ so we add a new argument -a --all-stdout that will allow cliff CLI to support the
+ feature in subunnit_describe_calls to print request and response headers and bodies
+ to stdout.
\ No newline at end of file
diff --git a/releasenotes/notes/add-can-migrate-between-any-hosts-config-option-x8ah4f9737a28e9b.yaml b/releasenotes/notes/add-can-migrate-between-any-hosts-config-option-x8ah4f9737a28e9b.yaml
new file mode 100644
index 0000000..26fe01a
--- /dev/null
+++ b/releasenotes/notes/add-can-migrate-between-any-hosts-config-option-x8ah4f9737a28e9b.yaml
@@ -0,0 +1,9 @@
+---
+features:
+ - Add a new config option can_migrate_between_any_hosts in the
+ compute-feature-enabled section, which can be set to False for environment
+ with non homogeneous compute nodes, so that it can select a destination
+ host for migrating automatically, otherwise the testcase may fail
+ unexpectedly. e.g., if source host is with CPU "E5-2699 v4" and the
+ selected target host is with CPU "E5-2670 v3", the live-migration will
+ fail because of the downgrade issue.
diff --git a/tempest/api/compute/admin/test_live_migration.py b/tempest/api/compute/admin/test_live_migration.py
index 064949f..941315e 100644
--- a/tempest/api/compute/admin/test_live_migration.py
+++ b/tempest/api/compute/admin/test_live_migration.py
@@ -71,6 +71,10 @@
def _live_migrate(self, server_id, target_host, state,
volume_backed=False):
+ # If target_host is None, check whether source host is different with
+ # the new host after migration.
+ if target_host is None:
+ source_host = self.get_host_for_server(server_id)
self._migrate_server_to(server_id, target_host, volume_backed)
waiters.wait_for_server_status(self.servers_client, server_id, state)
migration_list = (self.admin_migration_client.list_migrations()
@@ -82,8 +86,12 @@
if (live_migration['instance_uuid'] == server_id):
msg += "\n%s" % live_migration
msg += "]"
- self.assertEqual(target_host, self.get_host_for_server(server_id),
- msg)
+ if target_host is None:
+ self.assertNotEqual(source_host,
+ self.get_host_for_server(server_id), msg)
+ else:
+ self.assertEqual(target_host, self.get_host_for_server(server_id),
+ msg)
class LiveMigrationTest(LiveMigrationTestBase):
@@ -105,7 +113,11 @@
server_id = self.create_test_server(wait_until="ACTIVE",
volume_backed=volume_backed)['id']
source_host = self.get_host_for_server(server_id)
- destination_host = self.get_host_other_than(server_id)
+ if not CONF.compute_feature_enabled.can_migrate_between_any_hosts:
+ # not to specify a host so that the scheduler will pick one
+ destination_host = None
+ else:
+ destination_host = self.get_host_other_than(server_id)
if state == 'PAUSED':
self.admin_servers_client.pause_server(server_id)
@@ -161,7 +173,11 @@
"""Test live migrating a server with volume attached"""
server = self.create_test_server(wait_until="ACTIVE")
server_id = server['id']
- target_host = self.get_host_other_than(server_id)
+ if not CONF.compute_feature_enabled.can_migrate_between_any_hosts:
+ # not to specify a host so that the scheduler will pick one
+ target_host = None
+ else:
+ target_host = self.get_host_other_than(server_id)
volume = self.create_volume()
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index 7f62c64..990dd52 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -296,21 +296,32 @@
for ip in ip_list:
self.assertNotIn(ip_list[ip], map(lambda x: x['id'], servers))
- @decorators.skip_because(bug="1540645")
@decorators.idempotent_id('a905e287-c35e-42f2-b132-d02b09f3654a')
def test_list_servers_filtered_by_ip_regex(self):
"""Filter the list of servers by part of server ip address"""
- # Here should be listed all servers
if not self.fixed_network_name:
msg = 'fixed_network_name needs to be configured to run this test'
raise self.skipException(msg)
- self.s1 = self.client.show_server(self.s1['id'])['server']
- addr_spec = self.s1['addresses'][self.fixed_network_name][0]
- ip = addr_spec['addr'][0:-3]
+ # query addresses of the 3 servers
+ addrs = []
+ for s in [self.s1, self.s2, self.s3]:
+ s_show = self.client.show_server(s['id'])['server']
+ addr_spec = s_show['addresses'][self.fixed_network_name][0]
+ addrs.append(addr_spec['addr'])
+ # find common part of the 3 ip addresses
+ prefix = ''
+ addrs_len = [len(a) for a in addrs]
+ addrs_len.sort()
+ # iterate over the smallest length of an ip
+ for i in range(addrs_len[0]):
+ if not addrs[0][i] == addrs[1][i] == addrs[2][i]:
+ break
+ prefix += addrs[0][i]
+
if addr_spec['version'] == 4:
- params = {'ip': ip}
+ params = {'ip': prefix}
else:
- params = {'ip6': ip}
+ params = {'ip6': prefix}
# capture all servers in case something goes wrong
all_servers = self.client.list_servers(detail=True)
body = self.client.list_servers(**params)
diff --git a/tempest/api/network/admin/test_ports.py b/tempest/api/network/admin/test_ports.py
index 51f2857..5f9f29f 100644
--- a/tempest/api/network/admin/test_ports.py
+++ b/tempest/api/network/admin/test_ports.py
@@ -48,6 +48,8 @@
"name": data_utils.rand_name(self.__class__.__name__)}
body = self.admin_ports_client.create_port(**post_body)
port = body['port']
+ self.addCleanup(self.admin_ports_client.wait_for_resource_deletion,
+ port['id'])
self.addCleanup(
test_utils.call_and_ignore_notfound_exc,
self.admin_ports_client.delete_port, port['id'])
@@ -63,6 +65,8 @@
"name": data_utils.rand_name(self.__class__.__name__)}
body = self.admin_ports_client.create_port(**post_body)
port = body['port']
+ self.addCleanup(self.admin_ports_client.wait_for_resource_deletion,
+ port['id'])
self.addCleanup(
test_utils.call_and_ignore_notfound_exc,
self.admin_ports_client.delete_port, port['id'])
@@ -82,6 +86,8 @@
"name": data_utils.rand_name(self.__class__.__name__)}
body = self.admin_ports_client.create_port(**post_body)
port = body['port']
+ self.addCleanup(self.admin_ports_client.wait_for_resource_deletion,
+ port['id'])
self.addCleanup(
test_utils.call_and_ignore_notfound_exc,
self.admin_ports_client.delete_port, port['id'])
@@ -110,6 +116,8 @@
name=data_utils.rand_name(self.__class__.__name__),
network_id=self.network['id'])
port = body['port']
+ self.addCleanup(self.admin_ports_client.wait_for_resource_deletion,
+ port['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.admin_ports_client.delete_port, port['id'])
body = self.admin_ports_client.show_port(port['id'])
diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py
index c6d049a..479578d 100644
--- a/tempest/api/network/test_ports.py
+++ b/tempest/api/network/test_ports.py
@@ -77,6 +77,8 @@
name=data_utils.rand_name(self.__class__.__name__))
port = body['port']
# Schedule port deletion with verification upon test completion
+ self.addCleanup(self.ports_client.wait_for_resource_deletion,
+ port['id'])
self.addCleanup(self._delete_port, port['id'])
self.assertTrue(port['admin_state_up'])
# Verify port update
@@ -99,6 +101,10 @@
created_ports = body['ports']
port1 = created_ports[0]
port2 = created_ports[1]
+ self.addCleanup(self.ports_client.wait_for_resource_deletion,
+ port1['id'])
+ self.addCleanup(self.ports_client.wait_for_resource_deletion,
+ port2['id'])
self.addCleanup(self._delete_port, port1['id'])
self.addCleanup(self._delete_port, port2['id'])
self.assertEqual(port1['network_id'], network1['id'])
@@ -126,6 +132,8 @@
body = self.ports_client.create_port(
network_id=net_id,
name=data_utils.rand_name(self.__class__.__name__))
+ self.addCleanup(self.ports_client.wait_for_resource_deletion,
+ body['port']['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.ports_client.delete_port, body['port']['id'])
port = body['port']
@@ -183,11 +191,15 @@
port_1 = self.ports_client.create_port(
network_id=network['id'],
name=data_utils.rand_name(self.__class__.__name__))
+ self.addCleanup(self.ports_client.wait_for_resource_deletion,
+ port_1['port']['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.ports_client.delete_port, port_1['port']['id'])
port_2 = self.ports_client.create_port(
network_id=network['id'],
name=data_utils.rand_name(self.__class__.__name__))
+ self.addCleanup(self.ports_client.wait_for_resource_deletion,
+ port_2['port']['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.ports_client.delete_port, port_2['port']['id'])
# List ports filtered by fixed_ips
@@ -241,6 +253,8 @@
network_id=network['id'],
name=data_utils.rand_name(self.__class__.__name__),
fixed_ips=fixed_ips)
+ self.addCleanup(self.ports_client.wait_for_resource_deletion,
+ port_1['port']['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.ports_client.delete_port, port_1['port']['id'])
fixed_ips = [{'subnet_id': subnet['id'], 'ip_address': ip_address_2}]
@@ -248,6 +262,8 @@
network_id=network['id'],
name=data_utils.rand_name(self.__class__.__name__),
fixed_ips=fixed_ips)
+ self.addCleanup(self.ports_client.wait_for_resource_deletion,
+ port_2['port']['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.ports_client.delete_port, port_2['port']['id'])
@@ -307,6 +323,8 @@
# Add router interface to port created above
self.routers_client.add_router_interface(router['id'],
port_id=port['port']['id'])
+ self.addCleanup(self.ports_client.wait_for_resource_deletion,
+ port['port']['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.routers_client.remove_router_interface,
router['id'], port_id=port['port']['id'])
@@ -343,6 +361,8 @@
# Create a port with multiple IP addresses
port = self.create_port(network,
fixed_ips=fixed_ips)
+ self.addCleanup(self.ports_client.wait_for_resource_deletion,
+ port['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.ports_client.delete_port, port['id'])
self.assertEqual(2, len(port['fixed_ips']))
@@ -386,6 +406,8 @@
"admin_state_up": True,
"fixed_ips": fixed_ip_1}
body = self.ports_client.create_port(**post_body)
+ self.addCleanup(self.ports_client.wait_for_resource_deletion,
+ body['port']['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.ports_client.delete_port, body['port']['id'])
port = body['port']
@@ -456,6 +478,8 @@
network_id=self.network['id'],
mac_address=free_mac_address,
name=data_utils.rand_name(self.__class__.__name__))
+ self.addCleanup(self.ports_client.wait_for_resource_deletion,
+ body['port']['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.ports_client.delete_port, body['port']['id'])
port = body['port']
@@ -474,6 +498,8 @@
network = self._create_network()
self._create_subnet(network)
port = self.create_port(network, security_groups=[])
+ self.addCleanup(self.ports_client.wait_for_resource_deletion,
+ port['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.ports_client.delete_port, port['id'])
self.assertIsNotNone(port['security_groups'])
diff --git a/tempest/api/object_storage/test_account_bulk.py b/tempest/api/object_storage/test_account_bulk.py
index 80f790f..687fe57 100644
--- a/tempest/api/object_storage/test_account_bulk.py
+++ b/tempest/api/object_storage/test_account_bulk.py
@@ -21,6 +21,7 @@
class BulkTest(base.BaseObjectTest):
+ """Test bulk operation of archived file"""
def setUp(self):
super(BulkTest, self).setUp()
@@ -70,7 +71,7 @@
@decorators.idempotent_id('a407de51-1983-47cc-9f14-47c2b059413c')
@utils.requires_ext(extension='bulk_upload', service='object')
def test_extract_archive(self):
- # Test bulk operation of file upload with an archived file
+ """Test bulk operation of file upload with an archived file"""
filepath, container_name, object_name = self._create_archive()
resp = self._upload_archive(filepath)
self.containers.append(container_name)
@@ -95,7 +96,7 @@
@decorators.idempotent_id('c075e682-0d2a-43b2-808d-4116200d736d')
@utils.requires_ext(extension='bulk_delete', service='object')
def test_bulk_delete(self):
- # Test bulk operation of deleting multiple files
+ """Test bulk operation of deleting multiple files"""
filepath, container_name, object_name = self._create_archive()
self._upload_archive(filepath)
@@ -110,7 +111,7 @@
@decorators.idempotent_id('dbea2bcb-efbb-4674-ac8a-a5a0e33d1d79')
@utils.requires_ext(extension='bulk_delete', service='object')
def test_bulk_delete_by_POST(self):
- # Test bulk operation of deleting multiple files
+ """Test bulk operation of deleting multiple files by HTTP POST"""
filepath, container_name, object_name = self._create_archive()
self._upload_archive(filepath)
diff --git a/tempest/api/object_storage/test_account_quotas.py b/tempest/api/object_storage/test_account_quotas.py
index 48f42ec..6854bbe 100644
--- a/tempest/api/object_storage/test_account_quotas.py
+++ b/tempest/api/object_storage/test_account_quotas.py
@@ -22,6 +22,7 @@
class AccountQuotasTest(base.BaseObjectTest):
+ """Test account quotas"""
credentials = [['operator', CONF.object_storage.operator_role],
['reseller', CONF.object_storage.reseller_admin_role]]
@@ -79,6 +80,7 @@
@decorators.idempotent_id('a22ef352-a342-4587-8f47-3bbdb5b039c4')
@utils.requires_ext(extension='account_quotas', service='object')
def test_upload_valid_object(self):
+ """Test uploading valid object"""
object_name = data_utils.rand_name(name="TestObject")
data = data_utils.arbitrary_string()
resp, _ = self.object_client.create_object(self.container_name,
diff --git a/tempest/api/object_storage/test_account_services_negative.py b/tempest/api/object_storage/test_account_services_negative.py
index 3e664d7..8d2a501 100644
--- a/tempest/api/object_storage/test_account_services_negative.py
+++ b/tempest/api/object_storage/test_account_services_negative.py
@@ -21,6 +21,7 @@
class AccountNegativeTest(base.BaseObjectTest):
+ """Negative tests of account"""
credentials = [['operator', CONF.object_storage.operator_role],
['operator_alt', CONF.object_storage.operator_role]]
@@ -33,7 +34,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('070e6aca-6152-4867-868d-1118d68fb38c')
def test_list_containers_with_non_authorized_user(self):
- # list containers using non-authorized user
+ """Test listing containers using non-authorized user"""
test_auth_provider = self.os_operator.auth_provider
# Get auth for the test user
diff --git a/tempest/api/object_storage/test_container_acl.py b/tempest/api/object_storage/test_container_acl.py
index e9ca0b1..c8731fe 100644
--- a/tempest/api/object_storage/test_container_acl.py
+++ b/tempest/api/object_storage/test_container_acl.py
@@ -22,6 +22,7 @@
class ObjectTestACLs(base.BaseObjectTest):
+ """Test object ACLs"""
credentials = [['operator', CONF.object_storage.operator_role],
['operator_alt', CONF.object_storage.operator_role]]
@@ -36,7 +37,7 @@
@decorators.idempotent_id('a3270f3f-7640-4944-8448-c7ea783ea5b6')
def test_read_object_with_rights(self):
- # attempt to read object using authorized user
+ """Test reading object using authorized user"""
# update X-Container-Read metadata ACL
tenant_id = self.os_roles_operator_alt.credentials.tenant_id
user_id = self.os_roles_operator_alt.credentials.user_id
@@ -64,7 +65,7 @@
@decorators.idempotent_id('aa58bfa5-40d9-4bc3-82b4-d07f4a9e392a')
def test_write_object_with_rights(self):
- # attempt to write object using authorized user
+ """Test writing object using authorized user"""
# update X-Container-Write metadata ACL
tenant_id = self.os_roles_operator_alt.credentials.tenant_id
user_id = self.os_roles_operator_alt.credentials.user_id
diff --git a/tempest/api/object_storage/test_container_services.py b/tempest/api/object_storage/test_container_services.py
index cdc420e..7ad6f6f 100644
--- a/tempest/api/object_storage/test_container_services.py
+++ b/tempest/api/object_storage/test_container_services.py
@@ -19,6 +19,8 @@
class ContainerTest(base.BaseObjectTest):
+ """Test containers"""
+
def tearDown(self):
self.delete_containers()
super(ContainerTest, self).tearDown()
@@ -26,6 +28,7 @@
@decorators.attr(type='smoke')
@decorators.idempotent_id('92139d73-7819-4db1-85f8-3f2f22a8d91f')
def test_create_container(self):
+ """Test creating container"""
container_name = data_utils.rand_name(name='TestContainer')
resp, _ = self.container_client.update_container(container_name)
self.containers.append(container_name)
@@ -33,7 +36,7 @@
@decorators.idempotent_id('49f866ed-d6af-4395-93e7-4187eb56d322')
def test_create_container_overwrite(self):
- # overwrite container with the same name
+ """Test overwriting container with the same name"""
container_name = data_utils.rand_name(name='TestContainer')
self.container_client.update_container(container_name)
self.containers.append(container_name)
@@ -43,7 +46,7 @@
@decorators.idempotent_id('c2ac4d59-d0f5-40d5-ba19-0635056d48cd')
def test_create_container_with_metadata_key(self):
- # create container with the blank value of metadata
+ """Test creating container with the blank value of metadata"""
container_name = data_utils.rand_name(name='TestContainer')
headers = {'X-Container-Meta-test-container-meta': ''}
resp, _ = self.container_client.update_container(
@@ -60,7 +63,7 @@
@decorators.idempotent_id('e1e8df32-7b22-44e1-aa08-ccfd8d446b58')
def test_create_container_with_metadata_value(self):
- # create container with metadata value
+ """Test creating container with metadata value"""
container_name = data_utils.rand_name(name='TestContainer')
# metadata name using underscores should be converted to hyphens
@@ -79,7 +82,7 @@
@decorators.idempotent_id('24d16451-1c0c-4e4f-b59c-9840a3aba40e')
def test_create_container_with_remove_metadata_key(self):
- # create container with the blank value of remove metadata
+ """Test creating container with the blank value of remove metadata"""
container_name = data_utils.rand_name(name='TestContainer')
headers = {'X-Container-Meta-test-container-meta': 'Meta1'}
self.container_client.update_container(container_name, **headers)
@@ -97,7 +100,7 @@
@decorators.idempotent_id('8a21ebad-a5c7-4e29-b428-384edc8cd156')
def test_create_container_with_remove_metadata_value(self):
- # create container with remove metadata
+ """Test creating container with remove metadata"""
container_name = data_utils.rand_name(name='TestContainer')
headers = {'X-Container-Meta-test-container-meta': 'Meta1'}
self.container_client.update_container(container_name, **headers)
@@ -114,6 +117,7 @@
@decorators.idempotent_id('95d3a249-b702-4082-a2c4-14bb860cf06a')
def test_delete_container(self):
+ """Test deleting container"""
# create a container
container_name = self.create_container()
# delete container, success asserted within
@@ -123,7 +127,7 @@
@decorators.attr(type='smoke')
@decorators.idempotent_id('312ff6bd-5290-497f-bda1-7c5fec6697ab')
def test_list_container_contents(self):
- # get container contents list
+ """Test getting container contents list"""
container_name = self.create_container()
object_name, _ = self.create_object(container_name)
@@ -134,7 +138,7 @@
@decorators.idempotent_id('4646ac2d-9bfb-4c7d-a3c5-0f527402b3df')
def test_list_container_contents_with_no_object(self):
- # get empty container contents list
+ """Test getting empty container contents list"""
container_name = self.create_container()
resp, object_list = self.container_client.list_container_objects(
@@ -144,7 +148,7 @@
@decorators.idempotent_id('fe323a32-57b9-4704-a996-2e68f83b09bc')
def test_list_container_contents_with_delimiter(self):
- # get container contents list using delimiter param
+ """Test getting container contents list using delimiter param"""
container_name = self.create_container()
object_name = data_utils.rand_name(name='TestObject/')
self.create_object(container_name, object_name)
@@ -158,7 +162,7 @@
@decorators.idempotent_id('55b4fa5c-e12e-4ca9-8fcf-a79afe118522')
def test_list_container_contents_with_end_marker(self):
- # get container contents list using end_marker param
+ """Test getting container contents list using end_marker param"""
container_name = self.create_container()
object_name, _ = self.create_object(container_name)
@@ -171,7 +175,7 @@
@decorators.idempotent_id('196f5034-6ab0-4032-9da9-a937bbb9fba9')
def test_list_container_contents_with_format_json(self):
- # get container contents list using format_json param
+ """Test getting container contents list using format_json param"""
container_name = self.create_container()
self.create_object(container_name)
@@ -190,7 +194,7 @@
@decorators.idempotent_id('655a53ca-4d15-408c-a377-f4c6dbd0a1fa')
def test_list_container_contents_with_format_xml(self):
- # get container contents list using format_xml param
+ """Test getting container contents list using format_xml param"""
container_name = self.create_container()
self.create_object(container_name)
@@ -214,7 +218,7 @@
@decorators.idempotent_id('297ec38b-2b61-4ff4-bcd1-7fa055e97b61')
def test_list_container_contents_with_limit(self):
- # get container contents list using limit param
+ """Test getting container contents list using limit param"""
container_name = self.create_container()
object_name, _ = self.create_object(container_name)
@@ -227,7 +231,7 @@
@decorators.idempotent_id('c31ddc63-2a58-4f6b-b25c-94d2937e6867')
def test_list_container_contents_with_marker(self):
- # get container contents list using marker param
+ """Test getting container contents list using marker param"""
container_name = self.create_container()
object_name, _ = self.create_object(container_name)
@@ -240,7 +244,7 @@
@decorators.idempotent_id('58ca6cc9-6af0-408d-aaec-2a6a7b2f0df9')
def test_list_container_contents_with_path(self):
- # get container contents list using path param
+ """Test getting container contents list using path param"""
container_name = self.create_container()
object_name = data_utils.rand_name(name='TestObject')
object_name = 'Swift/' + object_name
@@ -255,7 +259,7 @@
@decorators.idempotent_id('77e742c7-caf2-4ec9-8aa4-f7d509a3344c')
def test_list_container_contents_with_prefix(self):
- # get container contents list using prefix param
+ """Test getting container contents list using prefix param"""
container_name = self.create_container()
object_name, _ = self.create_object(container_name)
@@ -270,7 +274,7 @@
@decorators.attr(type='smoke')
@decorators.idempotent_id('96e68f0e-19ec-4aa2-86f3-adc6a45e14dd')
def test_list_container_metadata(self):
- # List container metadata
+ """Test listing container metadata"""
container_name = self.create_container()
metadata = {'name': 'Pictures'}
@@ -286,7 +290,7 @@
@decorators.idempotent_id('a2faf936-6b13-4f8d-92a2-c2278355821e')
def test_list_no_container_metadata(self):
- # HEAD container without metadata
+ """Test listing container without metadata"""
container_name = self.create_container()
resp, _ = self.container_client.list_container_metadata(
@@ -296,7 +300,10 @@
@decorators.idempotent_id('cf19bc0b-7e16-4a5a-aaed-cb0c2fe8deef')
def test_update_container_metadata_with_create_and_delete_metadata(self):
- # Send one request of adding and deleting metadata
+ """Test updating container with adding and deleting metadata
+
+ Send one request of adding and deleting metadata.
+ """
container_name = data_utils.rand_name(name='TestContainer')
metadata_1 = {'X-Container-Meta-test-container-meta1': 'Meta1'}
self.container_client.update_container(container_name, **metadata_1)
@@ -319,7 +326,7 @@
@decorators.idempotent_id('2ae5f295-4bf1-4e04-bfad-21e54b62cec5')
def test_update_container_metadata_with_create_metadata(self):
- # update container metadata using add metadata
+ """Test updating container metadata using add metadata"""
container_name = self.create_container()
metadata = {'test-container-meta1': 'Meta1'}
@@ -337,7 +344,7 @@
@decorators.idempotent_id('3a5ce7d4-6e4b-47d0-9d87-7cd42c325094')
def test_update_container_metadata_with_delete_metadata(self):
- # update container metadata using delete metadata
+ """Test updating container metadata using delete metadata"""
container_name = data_utils.rand_name(name='TestContainer')
metadata = {'X-Container-Meta-test-container-meta1': 'Meta1'}
self.container_client.update_container(container_name, **metadata)
@@ -355,7 +362,7 @@
@decorators.idempotent_id('31f40a5f-6a52-4314-8794-cd89baed3040')
def test_update_container_metadata_with_create_metadata_key(self):
- # update container metadata with a blank value of metadata
+ """Test updating container metadata with a blank value of metadata"""
container_name = self.create_container()
metadata = {'test-container-meta1': ''}
@@ -371,7 +378,7 @@
@decorators.idempotent_id('a2e36378-6f1f-43f4-840a-ffd9cfd61914')
def test_update_container_metadata_with_delete_metadata_key(self):
- # update container metadata with a blank value of metadata
+ """Test updating container metadata with a blank value of metadata"""
container_name = data_utils.rand_name(name='TestContainer')
headers = {'X-Container-Meta-test-container-meta1': 'Meta1'}
self.container_client.update_container(container_name, **headers)
diff --git a/tempest/api/object_storage/test_healthcheck.py b/tempest/api/object_storage/test_healthcheck.py
index 8e9e406..f5e2443 100644
--- a/tempest/api/object_storage/test_healthcheck.py
+++ b/tempest/api/object_storage/test_healthcheck.py
@@ -19,12 +19,14 @@
class HealthcheckTest(base.BaseObjectTest):
+ """Test healthcheck"""
def setUp(self):
super(HealthcheckTest, self).setUp()
@decorators.idempotent_id('db5723b1-f25c-49a9-bfeb-7b5640caf337')
def test_get_healthcheck(self):
+ """Test getting healthcheck"""
url = self.account_client._get_base_version_url() + "healthcheck"
resp, body = self.account_client.raw_request(url, "GET")
self.account_client._error_checker(resp, body)
diff --git a/tempest/api/object_storage/test_object_version.py b/tempest/api/object_storage/test_object_version.py
index 75111b6..b64b172 100644
--- a/tempest/api/object_storage/test_object_version.py
+++ b/tempest/api/object_storage/test_object_version.py
@@ -24,6 +24,8 @@
class ContainerTest(base.BaseObjectTest):
+ """Test versioned container"""
+
def assertContainer(self, container, count, byte, versioned):
resp, _ = self.container_client.list_container_metadata(container)
self.assertHeaders(resp, 'Container', 'HEAD')
@@ -39,6 +41,15 @@
not CONF.object_storage_feature_enabled.object_versioning,
'Object-versioning is disabled')
def test_versioned_container(self):
+ """Test versioned container
+
+ 1. create container1
+ 2. create container2, with container1 as 'X-versions-Location' header
+ 3. create object1 in container1
+ 4. create 2nd version of object1
+ 5. delete object version 2
+ 6. delete object version 1
+ """
# create container
vers_container_name = data_utils.rand_name(name='TestVersionContainer')
resp, _ = self.container_client.update_container(vers_container_name)
diff --git a/tempest/api/volume/admin/test_volume_services.py b/tempest/api/volume/admin/test_volume_services.py
index 293af81..1d12a73 100644
--- a/tempest/api/volume/admin/test_volume_services.py
+++ b/tempest/api/volume/admin/test_volume_services.py
@@ -39,12 +39,14 @@
@decorators.idempotent_id('e0218299-0a59-4f43-8b2b-f1c035b3d26d')
def test_list_services(self):
+ """Test listing volume services"""
services = (self.admin_volume_services_client.list_services()
['services'])
self.assertNotEmpty(services)
@decorators.idempotent_id('63a3e1ca-37ee-4983-826d-83276a370d25')
def test_get_service_by_service_binary_name(self):
+ """Test getting volume service by binary name"""
services = (self.admin_volume_services_client.list_services(
binary=self.binary_name)['services'])
self.assertNotEmpty(services)
@@ -53,6 +55,7 @@
@decorators.idempotent_id('178710e4-7596-4e08-9333-745cb8bc4f8d')
def test_get_service_by_host_name(self):
+ """Test getting volume service by service host name"""
services_on_host = [service for service in self.services if
_get_host(service['host']) == self.host_name]
@@ -69,6 +72,7 @@
@decorators.idempotent_id('67ec6902-f91d-4dec-91fa-338523208bbc')
def test_get_service_by_volume_host_name(self):
+ """Test getting volume service by volume host name"""
volume_id = self.create_volume()['id']
volume = self.admin_volume_client.show_volume(volume_id)['volume']
hostname = _get_host(volume['os-vol-host-attr:host'])
@@ -83,7 +87,7 @@
@decorators.idempotent_id('ffa6167c-4497-4944-a464-226bbdb53908')
def test_get_service_by_service_and_host_name(self):
-
+ """Test getting volume service by binary name and host name"""
services = (self.admin_volume_services_client.list_services(
host=self.host_name, binary=self.binary_name))['services']
diff --git a/tempest/api/volume/admin/test_volume_type_access.py b/tempest/api/volume/admin/test_volume_type_access.py
index b64face..55ec428 100644
--- a/tempest/api/volume/admin/test_volume_type_access.py
+++ b/tempest/api/volume/admin/test_volume_type_access.py
@@ -24,11 +24,13 @@
class VolumeTypesAccessTest(base.BaseVolumeAdminTest):
+ """Test volume type access"""
credentials = ['primary', 'alt', 'admin']
@decorators.idempotent_id('d4dd0027-835f-4554-a6e5-50903fb79184')
def test_volume_type_access_add(self):
+ """Test adding volume type access for non-admin project"""
# Creating a NON public volume type
params = {'os-volume-type-access:is_public': False}
volume_type = self.create_volume_type(**params)
@@ -52,6 +54,7 @@
@decorators.idempotent_id('5220eb28-a435-43ce-baaf-ed46f0e95159')
def test_volume_type_access_list(self):
+ """Test listing volume type access"""
# Creating a NON public volume type
params = {'os-volume-type-access:is_public': False}
volume_type = self.create_volume_type(**params)
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs.py b/tempest/api/volume/admin/test_volume_types_extra_specs.py
index 730acdf..852aa93 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs.py
@@ -19,6 +19,7 @@
class VolumeTypesExtraSpecsTest(base.BaseVolumeAdminTest):
+ """Test volume type extra specs"""
@classmethod
def resource_setup(cls):
@@ -27,7 +28,7 @@
@decorators.idempotent_id('b42923e9-0452-4945-be5b-d362ae533e60')
def test_volume_type_extra_specs_list(self):
- # List Volume types extra specs.
+ """Test listing volume type extra specs"""
extra_specs = {"spec1": "val1"}
body = self.admin_volume_types_client.create_volume_type_extra_specs(
self.volume_type['id'], extra_specs)['extra_specs']
@@ -40,7 +41,7 @@
@decorators.idempotent_id('0806db36-b4a0-47a1-b6f3-c2e7f194d017')
def test_volume_type_extra_specs_update(self):
- # Update volume type extra specs
+ """Test updating volume type extra specs"""
extra_specs = {"spec2": "val1"}
body = self.admin_volume_types_client.create_volume_type_extra_specs(
self.volume_type['id'], extra_specs)['extra_specs']
@@ -74,7 +75,7 @@
@decorators.idempotent_id('d4772798-601f-408a-b2a5-29e8a59d1220')
def test_volume_type_extra_spec_create_get_delete(self):
- # Create/Get/Delete volume type extra spec.
+ """Test Create/Get/Delete volume type extra specs"""
spec_key = "spec3"
extra_specs = {spec_key: "val1"}
body = self.admin_volume_types_client.create_volume_type_extra_specs(
diff --git a/tempest/api/volume/admin/test_volumes_backup.py b/tempest/api/volume/admin/test_volumes_backup.py
index 45060d0..bd4b3fa 100644
--- a/tempest/api/volume/admin/test_volumes_backup.py
+++ b/tempest/api/volume/admin/test_volumes_backup.py
@@ -67,11 +67,8 @@
# Export Backup
export_backup = (self.admin_backups_client.export_backup(backup['id'])
['backup-record'])
- self.assertIn('backup_service', export_backup)
- self.assertIn('backup_url', export_backup)
self.assertTrue(export_backup['backup_service'].startswith(
'cinder.backup.drivers'))
- self.assertIsNotNone(export_backup['backup_url'])
# NOTE(geguileo): Backups are imported with the same backup id
# (important for incremental backups among other things), so we cannot
@@ -92,7 +89,6 @@
# deletions will delete data from the backup back-end because they
# were both pointing to the same backend data.
self.addCleanup(self._delete_backup, new_id)
- self.assertIn("id", import_backup)
self.assertEqual(new_id, import_backup['id'])
waiters.wait_for_volume_resource_status(self.admin_backups_client,
import_backup['id'],
diff --git a/tempest/api/volume/admin/test_volumes_list.py b/tempest/api/volume/admin/test_volumes_list.py
index 6ce4a85..c3229f0 100644
--- a/tempest/api/volume/admin/test_volumes_list.py
+++ b/tempest/api/volume/admin/test_volumes_list.py
@@ -24,6 +24,7 @@
class VolumesListAdminTestJSON(base.BaseVolumeAdminTest):
+ """Test listing volumes with admin privilege"""
@classmethod
def resource_setup(cls):
@@ -41,7 +42,7 @@
@decorators.idempotent_id('5866286f-3290-4cfd-a414-088aa6cdc469')
def test_volume_list_param_tenant(self):
- # Test to list volumes from single tenant
+ """Test admin can list volumes belonging to specified project"""
# Create a volume in admin tenant
adm_vol = self.admin_volume_client.create_volume(
size=CONF.volume.volume_size)['volume']
diff --git a/tempest/api/volume/test_availability_zone.py b/tempest/api/volume/test_availability_zone.py
index 0b6ee38..39369be 100644
--- a/tempest/api/volume/test_availability_zone.py
+++ b/tempest/api/volume/test_availability_zone.py
@@ -22,7 +22,7 @@
@decorators.idempotent_id('01f1ae88-eba9-4c6b-a011-6f7ace06b725')
def test_get_availability_zone_list(self):
- # List of availability zone
+ """Test listing volume available zones"""
availability_zone = (
self.availability_zone_client.list_availability_zones()
['availabilityZoneInfo'])
diff --git a/tempest/api/volume/test_extensions.py b/tempest/api/volume/test_extensions.py
index 39ce00c..acd9ca2 100644
--- a/tempest/api/volume/test_extensions.py
+++ b/tempest/api/volume/test_extensions.py
@@ -26,10 +26,11 @@
class ExtensionsTestJSON(base.BaseVolumeTest):
+ """Test volume extensions"""
@decorators.idempotent_id('94607eb0-43a5-47ca-82aa-736b41bd2e2c')
def test_list_extensions(self):
- # List of all extensions
+ """Test listing volume extensions"""
extensions = (self.volumes_extension_client.list_extensions()
['extensions'])
if not CONF.volume_feature_enabled.api_extensions:
diff --git a/tempest/api/volume/test_image_metadata.py b/tempest/api/volume/test_image_metadata.py
index 53b3acc..8f9bbd2 100644
--- a/tempest/api/volume/test_image_metadata.py
+++ b/tempest/api/volume/test_image_metadata.py
@@ -24,6 +24,7 @@
class VolumesImageMetadata(base.BaseVolumeTest):
+ """Test volume image metadata"""
@classmethod
def skip_checks(cls):
@@ -41,6 +42,7 @@
@decorators.idempotent_id('03efff0b-5c75-4822-8f10-8789ac15b13e')
@utils.services('image')
def test_update_show_delete_image_metadata(self):
+ """Test update/show/delete volume's image metadata"""
# Update image metadata
image_metadata = {'image_id': '5137a025-3c5f-43c1-bc64-5f41270040a5',
'image_name': 'image',
diff --git a/tempest/api/volume/test_snapshot_metadata.py b/tempest/api/volume/test_snapshot_metadata.py
index e6fe25d..ee1b5e5 100644
--- a/tempest/api/volume/test_snapshot_metadata.py
+++ b/tempest/api/volume/test_snapshot_metadata.py
@@ -23,6 +23,8 @@
class SnapshotMetadataTestJSON(base.BaseVolumeTest):
+ """Test snapshot metadata"""
+
@classmethod
def skip_checks(cls):
super(SnapshotMetadataTestJSON, cls).skip_checks()
@@ -45,6 +47,7 @@
@decorators.idempotent_id('a2f20f99-e363-4584-be97-bc33afb1a56c')
def test_crud_snapshot_metadata(self):
+ """Test create/get/update/delete snapshot metadata"""
# Create metadata for the snapshot
metadata = {"key1": "value1",
"key2": "value2",
@@ -82,7 +85,7 @@
@decorators.idempotent_id('e8ff85c5-8f97-477f-806a-3ac364a949ed')
def test_update_show_snapshot_metadata_item(self):
- # Update metadata item for the snapshot
+ """Test update/show snapshot metadata item"""
metadata = {"key1": "value1",
"key2": "value2",
"key3": "value3"}
diff --git a/tempest/api/volume/test_volumes_actions.py b/tempest/api/volume/test_volumes_actions.py
index e42ea40..5b50bfa 100644
--- a/tempest/api/volume/test_volumes_actions.py
+++ b/tempest/api/volume/test_volumes_actions.py
@@ -25,6 +25,8 @@
class VolumesActionsTest(base.BaseVolumeTest):
+ """Test volume actions"""
+
create_default_network = True
@classmethod
@@ -38,6 +40,7 @@
@decorators.attr(type='smoke')
@utils.services('compute')
def test_attach_detach_volume_to_instance(self):
+ """Test attaching and detaching volume to instance"""
# Create a server
server = self.create_server()
# Volume is attached and detached successfully from an instance
@@ -53,7 +56,7 @@
@decorators.idempotent_id('63e21b4c-0a0c-41f6-bfc3-7c2816815599')
def test_volume_bootable(self):
- # Verify that a volume bootable flag is retrieved
+ """Test setting and retrieving bootable flag of a volume"""
for bool_bootable in [True, False]:
self.volumes_client.set_bootable_volume(self.volume['id'],
bootable=bool_bootable)
@@ -69,6 +72,11 @@
@decorators.idempotent_id('9516a2c8-9135-488c-8dd6-5677a7e5f371')
@utils.services('compute')
def test_get_volume_attachment(self):
+ """Test getting volume attachments
+
+ Attach a volume to a server, and then retrieve volume's attachments
+ info.
+ """
# Create a server
server = self.create_server()
# Verify that a volume's attachment information is retrieved
@@ -96,6 +104,7 @@
@decorators.idempotent_id('d8f1ca95-3d5b-44a3-b8ca-909691c9532d')
@utils.services('image')
def test_volume_upload(self):
+ """Test uploading volume to create an image"""
# NOTE(gfidente): the volume uploaded in Glance comes from setUpClass,
# it is shared with the other tests. After it is uploaded in Glance,
# there is no way to delete it from Cinder, so we delete it from Glance
@@ -118,6 +127,7 @@
@decorators.idempotent_id('92c4ef64-51b2-40c0-9f7e-4749fbaaba33')
def test_reserve_unreserve_volume(self):
+ """Test reserving and unreserving volume"""
# Mark volume as reserved.
self.volumes_client.reserve_volume(self.volume['id'])
# To get the volume info
@@ -131,6 +141,7 @@
@decorators.idempotent_id('fff74e1e-5bd3-4b33-9ea9-24c103bc3f59')
def test_volume_readonly_update(self):
+ """Test updating and retrieve volume's readonly flag"""
for readonly in [True, False]:
# Update volume readonly
self.volumes_client.update_volume_readonly(self.volume['id'],
diff --git a/tempest/api/volume/test_volumes_backup.py b/tempest/api/volume/test_volumes_backup.py
index c178272..e3b8800 100644
--- a/tempest/api/volume/test_volumes_backup.py
+++ b/tempest/api/volume/test_volumes_backup.py
@@ -80,11 +80,7 @@
self.assertEqual('container', backup['container'])
# Get all backups with detail
- backups = self.backups_client.list_backups(
- detail=True)['backups']
- for backup_info in backups:
- self.assertIn('created_at', backup_info)
- self.assertIn('links', backup_info)
+ backups = self.backups_client.list_backups(detail=True)['backups']
self.assertIn((backup['name'], backup['id']),
[(m['name'], m['id']) for m in backups])
@@ -176,7 +172,6 @@
backup['id'], **update_kwargs)['backup']
self.assertEqual(backup['id'], update_backup['id'])
self.assertEqual(update_kwargs['name'], update_backup['name'])
- self.assertIn('links', update_backup)
# Assert response body for show_backup method
retrieved_backup = self.backups_client.show_backup(
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index 866bd87..76c22f0 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -28,6 +28,7 @@
class VolumesNegativeTest(base.BaseVolumeTest):
+ """Negative tests of volumes"""
@classmethod
def resource_setup(cls):
@@ -58,50 +59,49 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('f131c586-9448-44a4-a8b0-54ca838aa43e')
def test_volume_get_nonexistent_volume_id(self):
- # Should not be able to get a non-existent volume
+ """Test getting non existent volume should fail"""
self.assertRaises(lib_exc.NotFound, self.volumes_client.show_volume,
data_utils.rand_uuid())
@decorators.attr(type=['negative'])
@decorators.idempotent_id('555efa6e-efcd-44ef-8a3b-4a7ca4837a29')
def test_volume_delete_nonexistent_volume_id(self):
- # Should not be able to delete a non-existent Volume
+ """Test deleting non existent volume should fail"""
self.assertRaises(lib_exc.NotFound, self.volumes_client.delete_volume,
data_utils.rand_uuid())
@decorators.attr(type=['negative'])
@decorators.idempotent_id('1ed83a8a-682d-4dfb-a30e-ee63ffd6c049')
def test_create_volume_with_invalid_size(self):
- # Should not be able to create volume with invalid size in request
+ """Test creating volume with invalid size should fail"""
self.assertRaises(lib_exc.BadRequest,
self.volumes_client.create_volume, size='#$%')
@decorators.attr(type=['negative'])
@decorators.idempotent_id('9387686f-334f-4d31-a439-33494b9e2683')
def test_create_volume_without_passing_size(self):
- # Should not be able to create volume without passing size
- # in request
+ """Test creating volume with empty size should fail"""
self.assertRaises(lib_exc.BadRequest,
self.volumes_client.create_volume, size='')
@decorators.attr(type=['negative'])
@decorators.idempotent_id('41331caa-eaf4-4001-869d-bc18c1869360')
def test_create_volume_with_size_zero(self):
- # Should not be able to create volume with size zero
+ """Test creating volume with zero size should fail"""
self.assertRaises(lib_exc.BadRequest,
self.volumes_client.create_volume, size='0')
@decorators.attr(type=['negative'])
@decorators.idempotent_id('8b472729-9eba-446e-a83b-916bdb34bef7')
def test_create_volume_with_size_negative(self):
- # Should not be able to create volume with size negative
+ """Test creating volume with negative size should fail"""
self.assertRaises(lib_exc.BadRequest,
self.volumes_client.create_volume, size='-1')
@decorators.attr(type=['negative'])
@decorators.idempotent_id('10254ed8-3849-454e-862e-3ab8e6aa01d2')
def test_create_volume_with_nonexistent_volume_type(self):
- # Should not be able to create volume with non-existent volume type
+ """Test creating volume with non existent volume type should fail"""
self.assertRaises(lib_exc.NotFound, self.volumes_client.create_volume,
size=CONF.volume.volume_size,
volume_type=data_utils.rand_uuid())
@@ -109,7 +109,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('0c36f6ae-4604-4017-b0a9-34fdc63096f9')
def test_create_volume_with_nonexistent_snapshot_id(self):
- # Should not be able to create volume with non-existent snapshot
+ """Test creating volume with non existent snapshot should fail"""
self.assertRaises(lib_exc.NotFound, self.volumes_client.create_volume,
size=CONF.volume.volume_size,
snapshot_id=data_utils.rand_uuid())
@@ -117,7 +117,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('47c73e08-4be8-45bb-bfdf-0c4e79b88344')
def test_create_volume_with_nonexistent_source_volid(self):
- # Should not be able to create volume with non-existent source volume
+ """Test creating volume with non existent source volume should fail"""
self.assertRaises(lib_exc.NotFound, self.volumes_client.create_volume,
size=CONF.volume.volume_size,
source_volid=data_utils.rand_uuid())
@@ -125,46 +125,49 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('0186422c-999a-480e-a026-6a665744c30c')
def test_update_volume_with_nonexistent_volume_id(self):
+ """Test updating non existent volume should fail"""
self.assertRaises(lib_exc.NotFound, self.volumes_client.update_volume,
volume_id=data_utils.rand_uuid())
@decorators.attr(type=['negative'])
@decorators.idempotent_id('e66e40d6-65e6-4e75-bdc7-636792fa152d')
def test_update_volume_with_invalid_volume_id(self):
+ """Test updating volume with invalid volume id should fail"""
self.assertRaises(lib_exc.NotFound, self.volumes_client.update_volume,
volume_id=data_utils.rand_name('invalid'))
@decorators.attr(type=['negative'])
@decorators.idempotent_id('72aeca85-57a5-4c1f-9057-f320f9ea575b')
def test_update_volume_with_empty_volume_id(self):
+ """Test updating volume with empty volume id should fail"""
self.assertRaises(lib_exc.NotFound, self.volumes_client.update_volume,
volume_id='')
@decorators.attr(type=['negative'])
@decorators.idempotent_id('30799cfd-7ee4-446c-b66c-45b383ed211b')
def test_get_invalid_volume_id(self):
- # Should not be able to get volume with invalid id
+ """Test getting volume with invalid volume id should fail"""
self.assertRaises(lib_exc.NotFound, self.volumes_client.show_volume,
data_utils.rand_name('invalid'))
@decorators.attr(type=['negative'])
@decorators.idempotent_id('c6c3db06-29ad-4e91-beb0-2ab195fe49e3')
def test_get_volume_without_passing_volume_id(self):
- # Should not be able to get volume when empty ID is passed
+ """Test getting volume with empty volume id should fail"""
self.assertRaises(lib_exc.NotFound,
self.volumes_client.show_volume, '')
@decorators.attr(type=['negative'])
@decorators.idempotent_id('1f035827-7c32-4019-9240-b4ec2dbd9dfd')
def test_delete_invalid_volume_id(self):
- # Should not be able to delete volume when invalid ID is passed
+ """Test deleting volume with invalid volume id should fail"""
self.assertRaises(lib_exc.NotFound, self.volumes_client.delete_volume,
data_utils.rand_name('invalid'))
@decorators.attr(type=['negative'])
@decorators.idempotent_id('441a1550-5d44-4b30-af0f-a6d402f52026')
def test_delete_volume_without_passing_volume_id(self):
- # Should not be able to delete volume when empty ID is passed
+ """Test deleting volume with empty volume id should fail"""
self.assertRaises(lib_exc.NotFound,
self.volumes_client.delete_volume, '')
@@ -172,6 +175,7 @@
@decorators.idempotent_id('f5e56b0a-5d02-43c1-a2a7-c9b792c2e3f6')
@utils.services('compute')
def test_attach_volumes_with_nonexistent_volume_id(self):
+ """Test attaching non existent volume to server should fail"""
server = self.create_server()
self.assertRaises(lib_exc.NotFound,
@@ -183,6 +187,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('9f9c24e4-011d-46b5-b992-952140ce237a')
def test_detach_volumes_with_invalid_volume_id(self):
+ """Test detaching volume with invalid volume id should fail"""
self.assertRaises(lib_exc.NotFound,
self.volumes_client.detach_volume,
'xxx')
@@ -190,7 +195,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('e0c75c74-ee34-41a9-9288-2a2051452854')
def test_volume_extend_with_size_smaller_than_original_size(self):
- # Extend volume with smaller size than original size.
+ """Test extending volume with decreasing size should fail"""
extend_size = 0
self.assertRaises(lib_exc.BadRequest,
self.volumes_client.extend_volume,
@@ -199,7 +204,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('5d0b480d-e833-439f-8a5a-96ad2ed6f22f')
def test_volume_extend_with_non_number_size(self):
- # Extend volume when size is non number.
+ """Test extending volume with non-integer size should fail"""
extend_size = 'abc'
self.assertRaises(lib_exc.BadRequest,
self.volumes_client.extend_volume,
@@ -208,7 +213,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('355218f1-8991-400a-a6bb-971239287d92')
def test_volume_extend_with_None_size(self):
- # Extend volume with None size.
+ """Test extending volume with none size should fail"""
extend_size = None
self.assertRaises(lib_exc.BadRequest,
self.volumes_client.extend_volume,
@@ -217,7 +222,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('8f05a943-013c-4063-ac71-7baf561e82eb')
def test_volume_extend_with_nonexistent_volume_id(self):
- # Extend volume size when volume is nonexistent.
+ """Test extending non existent volume should fail"""
extend_size = self.volume['size'] + 1
self.assertRaises(lib_exc.NotFound, self.volumes_client.extend_volume,
data_utils.rand_uuid(), new_size=extend_size)
@@ -225,7 +230,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('aff8ba64-6d6f-4f2e-bc33-41a08ee9f115')
def test_volume_extend_without_passing_volume_id(self):
- # Extend volume size when passing volume id is None.
+ """Test extending volume without passing volume id should fail"""
extend_size = self.volume['size'] + 1
self.assertRaises(lib_exc.NotFound, self.volumes_client.extend_volume,
None, new_size=extend_size)
@@ -233,6 +238,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('ac6084c0-0546-45f9-b284-38a367e0e0e2')
def test_reserve_volume_with_nonexistent_volume_id(self):
+ """Test reserving non existent volume should fail"""
self.assertRaises(lib_exc.NotFound,
self.volumes_client.reserve_volume,
data_utils.rand_uuid())
@@ -240,6 +246,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('eb467654-3dc1-4a72-9b46-47c29d22654c')
def test_unreserve_volume_with_nonexistent_volume_id(self):
+ """Test unreserving non existent volume should fail"""
self.assertRaises(lib_exc.NotFound,
self.volumes_client.unreserve_volume,
data_utils.rand_uuid())
@@ -247,6 +254,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('449c4ed2-ecdd-47bb-98dc-072aeccf158c')
def test_reserve_volume_with_negative_volume_status(self):
+ """Test reserving already reserved volume should fail"""
# Mark volume as reserved.
self.volumes_client.reserve_volume(self.volume['id'])
# Mark volume which is marked as reserved before
@@ -259,6 +267,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('0f4aa809-8c7b-418f-8fb3-84c7a5dfc52f')
def test_list_volumes_with_nonexistent_name(self):
+ """Test listing volumes with non existent name should get nothing"""
v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
params = {'name': v_name}
fetched_volume = self.volumes_client.list_volumes(
@@ -268,6 +277,10 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('9ca17820-a0e7-4cbd-a7fa-f4468735e359')
def test_list_volumes_detail_with_nonexistent_name(self):
+ """Test listing volume details with non existent name
+
+ Listing volume details with non existent name should get nothing.
+ """
v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
params = {'name': v_name}
fetched_volume = \
@@ -278,6 +291,7 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('143b279b-7522-466b-81be-34a87d564a7c')
def test_list_volumes_with_invalid_status(self):
+ """Test listing volumes with invalid status should get nothing"""
params = {'status': 'null'}
fetched_volume = self.volumes_client.list_volumes(
params=params)['volumes']
@@ -286,6 +300,10 @@
@decorators.attr(type=['negative'])
@decorators.idempotent_id('ba94b27b-be3f-496c-a00e-0283b373fa75')
def test_list_volumes_detail_with_invalid_status(self):
+ """Test listing volume details with invalid status
+
+ Listing volume details with invalid status should get nothing
+ """
params = {'status': 'null'}
fetched_volume = \
self.volumes_client.list_volumes(detail=True,
@@ -296,6 +314,7 @@
@decorators.idempotent_id('5b810c91-0ad1-47ce-aee8-615f789be78f')
@utils.services('image')
def test_create_volume_from_image_with_decreasing_size(self):
+ """Test creating volume from image with decreasing size should fail"""
# Create image
image = self.create_image()
@@ -311,6 +330,7 @@
@decorators.idempotent_id('d15e7f35-2cfc-48c8-9418-c8223a89bcbb')
@utils.services('image')
def test_create_volume_from_deactivated_image(self):
+ """Test creating volume from deactivated image should fail"""
# Create image
image = self.create_image()
diff --git a/tempest/cmd/subunit_describe_calls.py b/tempest/cmd/subunit_describe_calls.py
index e029538..172fbaa 100644
--- a/tempest/cmd/subunit_describe_calls.py
+++ b/tempest/cmd/subunit_describe_calls.py
@@ -30,6 +30,8 @@
* ``--ports, -p``: (Optional) The path to a JSON file describing the ports
being used by different services
* ``--verbose, -v``: (Optional) Print Request and Response Headers and Body
+ data to stdout in the non cliff deprecated CLI
+* ``--all-stdout, -a``: (Optional) Print Request and Response Headers and Body
data to stdout
@@ -278,7 +280,7 @@
return url_parser
-def output(url_parser, output_file, verbose):
+def output(url_parser, output_file, all_stdout):
if output_file is not None:
with open(output_file, "w") as outfile:
outfile.write(json.dumps(url_parser.test_logs))
@@ -294,7 +296,7 @@
sys.stdout.write('\t- {0} {1} request for {2} to {3}\n'.format(
item.get('status_code'), item.get('verb'),
item.get('service'), item.get('url')))
- if verbose:
+ if all_stdout:
sys.stdout.write('\t\t- request headers: {0}\n'.format(
item.get('request_headers')))
sys.stdout.write('\t\t- request body: {0}\n'.format(
@@ -313,7 +315,7 @@
"please use: 'tempest subunit-describe-calls'")
cl_args = ArgumentParser().parse_args()
parser = parse(cl_args.subunit, cl_args.non_subunit_name, cl_args.ports)
- output(parser, cl_args.output_file, cl_args.verbose)
+ output(parser, cl_args.output_file, cl_args.all_stdout)
def _parser_add_args(parser):
@@ -339,9 +341,23 @@
help="A JSON file describing the ports for each service."
)
- parser.add_argument(
- "-v", "--verbose", action='store_true', default=False,
- help="Add Request and Response header and body data to stdout."
+ group = parser.add_mutually_exclusive_group()
+ # the -v and --verbose command are for the old subunit-describe-calls
+ # main() CLI interface. It does not work with the new
+ # tempest subunit-describe-callss CLI. So when the main CLI approach is
+ # deleted this argument is not needed.
+ group.add_argument(
+ "-v", "--verbose", action='store_true', dest='all_stdout',
+ help='Add Request and Response header and body data to stdout print.'
+ ' NOTE: This argument deprecated and does not work with'
+ ' tempest subunit-describe-calls CLI.'
+ ' Use new option: "-a", "--all-stdout"'
+ )
+ group.add_argument(
+ "-a", "--all-stdout", action='store_true',
+ help="Add Request and Response header and body data to stdout print."
+ " Note: this argument work with the subunit-describe-calls and"
+ " tempest subunit-describe-calls CLI commands."
)
diff --git a/tempest/config.py b/tempest/config.py
index eca2023..989b8ef 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -481,6 +481,12 @@
'MIN_LIBVIRT_VERSION is >= 1.2.17 on all '
'branches from stable/rocky and will be '
'removed in a future release.'),
+ cfg.BoolOpt('can_migrate_between_any_hosts',
+ default=True,
+ help="Does the test environment support migrating between "
+ "any hosts? In environments with non-homogeneous compute "
+ "nodes you can set this to False so that it will select "
+ "destination host for migrating automatically"),
cfg.BoolOpt('vnc_console',
default=False,
help='Enable VNC console. This configuration value should '
diff --git a/tempest/lib/api_schema/response/volume/backups.py b/tempest/lib/api_schema/response/volume/backups.py
new file mode 100644
index 0000000..9e85f5f
--- /dev/null
+++ b/tempest/lib/api_schema/response/volume/backups.py
@@ -0,0 +1,229 @@
+# Copyright 2015 NEC Corporation. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import copy
+
+from tempest.lib.api_schema.response.compute.v2_1 import parameter_types
+
+common_show_backup = {
+ 'type': 'object',
+ 'properties': {
+ 'status': {'type': 'string'},
+ 'object_count': {'type': 'integer'},
+ 'container': {'type': ['string', 'null']},
+ 'description': {'type': ['string', 'null']},
+ 'links': parameter_types.links,
+ 'availability_zone': {'type': ['string', 'null']},
+ 'created_at': parameter_types.date_time,
+ 'updated_at': parameter_types.date_time_or_null,
+ 'name': {'type': ['string', 'null']},
+ 'has_dependent_backups': {'type': 'boolean'},
+ 'volume_id': {'type': 'string', 'format': 'uuid'},
+ 'fail_reason': {'type': ['string', 'null']},
+ 'size': {'type': 'integer'},
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'is_incremental': {'type': 'boolean'},
+ 'data_timestamp': parameter_types.date_time_or_null,
+ 'snapshot_id': {'type': ['string', 'null']},
+ # TODO(zhufl): os-backup-project-attr:project_id is added
+ # in 3.18, we should move it to the 3.18 schema file when
+ # microversion is supported in volume interfaces.
+ 'os-backup-project-attr:project_id': {
+ 'type': 'string', 'format': 'uuid'},
+ # TODO(zhufl): metadata is added in 3.43, we should move it
+ # to the 3.43 schema file when microversion is supported
+ # in volume interfaces.
+ 'metadata': {'^.+$': {'type': 'string'}},
+ # TODO(zhufl): user_id is added in 3.56, we should move it
+ # to the 3.56 schema file when microversion is supported
+ # in volume interfaces.
+ 'user_id': {'type': 'string'},
+ },
+ 'additionalProperties': False,
+ 'required': ['status', 'object_count', 'fail_reason', 'links',
+ 'created_at', 'updated_at', 'name', 'volume_id', 'size', 'id',
+ 'data_timestamp']
+}
+
+create_backup = {
+ 'status_code': [202],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'backup': {
+ 'type': 'object',
+ 'properties': {
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'links': parameter_types.links,
+ 'name': {'type': 'string'},
+ # TODO(zhufl): metadata is added in 3.43, we should move it
+ # to the 3.43 schema file when microversion is supported
+ # in volume interfaces.
+ 'metadata': {'^.+$': {'type': 'string'}},
+ },
+ 'additionalProperties': False,
+ 'required': ['id', 'links', 'name']
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['backup']
+ }
+}
+
+update_backup = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'backup': {
+ 'type': 'object',
+ 'properties': {
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'links': parameter_types.links,
+ 'name': {'type': 'string'},
+ 'metadata': {'^.+$': {'type': 'string'}}
+ },
+ 'additionalProperties': False,
+ 'required': ['id', 'links', 'name']
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['backup']
+ }
+}
+
+restore_backup = {
+ 'status_code': [202],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'restore': {
+ 'type': 'object',
+ 'properties': {
+ 'backup_id': {'type': 'string', 'format': 'uuid'},
+ 'volume_id': {'type': 'string', 'format': 'uuid'},
+ 'volume_name': {'type': 'string'},
+ },
+ 'additionalProperties': False,
+ 'required': ['backup_id', 'volume_id', 'volume_name']
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['restore']
+ }
+}
+
+delete_backup = {'status_code': [202]}
+
+show_backup = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'backup': common_show_backup
+ },
+ 'additionalProperties': False,
+ 'required': ['backup']
+ }
+}
+
+list_backups_no_detail = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'backups': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'links': parameter_types.links,
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'name': {'type': ['string', 'null']},
+ # TODO(zhufl): count is added in 3.45, we should move
+ # it to the 3.45 schema file when microversion is
+ # supported in volume interfaces
+ 'count': {'type': 'integer'}
+ },
+ 'additionalProperties': False,
+ 'required': ['links', 'id', 'name']
+ }
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['backups'],
+ }
+}
+
+list_backups_detail = copy.deepcopy(common_show_backup)
+# TODO(zhufl): count is added in 3.45, we should move it to the 3.45 schema
+# file when microversion is supported in volume interfaces
+list_backups_detail['properties'].update({'count': {'type': 'integer'}})
+list_backups_with_detail = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'backups': {
+ 'type': 'array',
+ 'items': list_backups_detail
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['backups'],
+ }
+}
+
+export_backup = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'backup-record': {
+ 'type': 'object',
+ 'properties': {
+ 'backup_service': {'type': 'string'},
+ 'backup_url': {'type': 'string'}
+ },
+ 'additionalProperties': False,
+ 'required': ['backup_service', 'backup_url']
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['backup-record']
+ }
+}
+
+import_backup = {
+ 'status_code': [201],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'backup': {
+ 'type': 'object',
+ 'properties': {
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'links': parameter_types.links,
+ 'name': {'type': ['string', 'null']},
+ },
+ 'additionalProperties': False,
+ 'required': ['id', 'links', 'name']
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['backup']
+ }
+}
+
+reset_backup_status = {'status_code': [202]}
diff --git a/tempest/lib/api_schema/response/volume/groups.py b/tempest/lib/api_schema/response/volume/groups.py
new file mode 100644
index 0000000..cb31269
--- /dev/null
+++ b/tempest/lib/api_schema/response/volume/groups.py
@@ -0,0 +1,164 @@
+# Copyright 2015 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.lib.api_schema.response.compute.v2_1 import parameter_types
+
+create_group = {
+ 'status_code': [202],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'group': {
+ 'type': 'object',
+ 'properties': {
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'name': {'type': 'string'},
+ },
+ 'additionalProperties': False,
+ 'required': ['id', 'name']
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['group']
+ }
+}
+
+delete_group = {'status_code': [202]}
+
+show_group = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'group': {
+ 'type': 'object',
+ 'properties': {
+ 'status': {'type': 'string'},
+ 'description': {'type': ['string', 'null']},
+ 'availability_zone': {'type': 'string'},
+ 'created_at': parameter_types.date_time,
+ 'group_type': {'type': 'string', 'format': 'uuid'},
+ 'group_snapshot_id': {'type': ['string', 'null']},
+ 'source_group_id': {'type': ['string', 'null']},
+ 'volume_types': {
+ 'type': 'array',
+ 'items': {'type': 'string', 'format': 'uuid'}
+ },
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'name': {'type': 'string'},
+ # TODO(zhufl): volumes is added in 3.25, we should move it
+ # to the 3.25 schema file when microversion is supported
+ # in volume interfaces
+ 'volumes': {
+ 'type': 'array',
+ 'items': {'type': 'string', 'format': 'uuid'}
+ },
+ 'replication_status': {'type': 'string'}
+ },
+ 'additionalProperties': False,
+ 'required': ['status', 'description', 'created_at',
+ 'group_type', 'volume_types', 'id', 'name']
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['group']
+ }
+}
+
+list_groups_no_detail = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'groups': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'name': {'type': 'string'}
+ },
+ 'additionalProperties': False,
+ 'required': ['id', 'name'],
+ }
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['groups'],
+ }
+}
+
+list_groups_with_detail = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'groups': {
+ 'type': 'array',
+ 'items': {
+ 'type': 'object',
+ 'properties': {
+ 'status': {'type': 'string'},
+ 'description': {'type': ['string', 'null']},
+ 'availability_zone': {'type': 'string'},
+ 'created_at': parameter_types.date_time,
+ 'group_type': {'type': 'string', 'format': 'uuid'},
+ 'group_snapshot_id': {'type': ['string', 'null']},
+ 'source_group_id': {'type': ['string', 'null']},
+ 'volume_types': {
+ 'type': 'array',
+ 'items': {'type': 'string', 'format': 'uuid'}
+ },
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'name': {'type': 'string'},
+ # TODO(zhufl): volumes is added in 3.25, we should
+ # move it to the 3.25 schema file when microversion
+ # is supported in volume interfaces
+ 'volumes': {
+ 'type': 'array',
+ 'items': {'type': 'string', 'format': 'uuid'}
+ },
+ },
+ 'additionalProperties': False,
+ 'required': ['status', 'description', 'created_at',
+ 'group_type', 'volume_types', 'id', 'name']
+ }
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['groups'],
+ }
+}
+
+create_group_from_source = {
+ 'status_code': [202],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'group': {
+ 'type': 'object',
+ 'properties': {
+ 'id': {'type': 'string', 'format': 'uuid'},
+ 'name': {'type': 'string'},
+ },
+ 'additionalProperties': False,
+ 'required': ['id', 'name']
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['group']
+ }
+}
+update_group = {'status_code': [202]}
+reset_group_status = {'status_code': [202]}
diff --git a/tempest/lib/common/utils/linux/remote_client.py b/tempest/lib/common/utils/linux/remote_client.py
index 8ac1d38..71fed02 100644
--- a/tempest/lib/common/utils/linux/remote_client.py
+++ b/tempest/lib/common/utils/linux/remote_client.py
@@ -11,7 +11,6 @@
# under the License.
import functools
-import re
import sys
import netaddr
@@ -134,9 +133,8 @@
This method will not unmount the config drive, so unmount_config_drive
must be used for cleanup.
"""
- cmd_blkid = 'blkid | grep -i config-2'
- result = self.exec_command(cmd_blkid)
- dev_name = re.match('([^:]+)', result).group()
+ cmd_blkid = 'blkid -L config-2 -o device'
+ dev_name = self.exec_command(cmd_blkid).strip()
try:
self.exec_command('sudo mount %s /mnt' % dev_name)
diff --git a/tempest/lib/services/volume/v3/backups_client.py b/tempest/lib/services/volume/v3/backups_client.py
index 970471e..1df45fa 100644
--- a/tempest/lib/services/volume/v3/backups_client.py
+++ b/tempest/lib/services/volume/v3/backups_client.py
@@ -16,6 +16,7 @@
from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
+from tempest.lib.api_schema.response.volume import backups as schema
from tempest.lib.common import rest_client
from tempest.lib import exceptions as lib_exc
from tempest.lib.services.volume import base_client
@@ -34,7 +35,7 @@
post_body = json.dumps({'backup': kwargs})
resp, body = self.post('backups', post_body)
body = json.loads(body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.create_backup, resp, body)
return rest_client.ResponseBody(resp, body)
def update_backup(self, backup_id, **kwargs):
@@ -47,7 +48,7 @@
put_body = json.dumps({'backup': kwargs})
resp, body = self.put('backups/%s' % backup_id, put_body)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.update_backup, resp, body)
return rest_client.ResponseBody(resp, body)
def restore_backup(self, backup_id, **kwargs):
@@ -60,13 +61,13 @@
post_body = json.dumps({'restore': kwargs})
resp, body = self.post('backups/%s/restore' % (backup_id), post_body)
body = json.loads(body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.restore_backup, resp, body)
return rest_client.ResponseBody(resp, body)
def delete_backup(self, backup_id):
"""Delete a backup of volume."""
resp, body = self.delete('backups/%s' % backup_id)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.delete_backup, resp, body)
return rest_client.ResponseBody(resp, body)
def show_backup(self, backup_id):
@@ -74,7 +75,7 @@
url = "backups/%s" % backup_id
resp, body = self.get(url)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.show_backup, resp, body)
return rest_client.ResponseBody(resp, body)
def list_backups(self, detail=False, **params):
@@ -86,13 +87,15 @@
https://docs.openstack.org/api-ref/block-storage/v3/index.html#list-backups-with-detail
"""
url = "backups"
+ list_backups_schema = schema.list_backups_no_detail
if detail:
url += "/detail"
+ list_backups_schema = schema.list_backups_with_detail
if params:
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(list_backups_schema, resp, body)
return rest_client.ResponseBody(resp, body)
def export_backup(self, backup_id):
@@ -100,7 +103,7 @@
url = "backups/%s/export_record" % backup_id
resp, body = self.get(url)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.export_backup, resp, body)
return rest_client.ResponseBody(resp, body)
def import_backup(self, **kwargs):
@@ -113,14 +116,14 @@
post_body = json.dumps({'backup-record': kwargs})
resp, body = self.post("backups/import_record", post_body)
body = json.loads(body)
- self.expected_success(201, resp.status)
+ self.validate_response(schema.import_backup, resp, body)
return rest_client.ResponseBody(resp, body)
def reset_backup_status(self, backup_id, status):
"""Reset the specified backup's status."""
post_body = json.dumps({'os-reset_status': {"status": status}})
resp, body = self.post('backups/%s/action' % backup_id, post_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.reset_backup_status, resp, body)
return rest_client.ResponseBody(resp, body)
def is_resource_deleted(self, id):
diff --git a/tempest/lib/services/volume/v3/groups_client.py b/tempest/lib/services/volume/v3/groups_client.py
index ffae232..3d8523d 100644
--- a/tempest/lib/services/volume/v3/groups_client.py
+++ b/tempest/lib/services/volume/v3/groups_client.py
@@ -16,6 +16,7 @@
from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
+from tempest.lib.api_schema.response.volume import groups as schema
from tempest.lib.common import rest_client
from tempest.lib import exceptions as lib_exc
from tempest.lib.services.volume import base_client
@@ -23,6 +24,7 @@
class GroupsClient(base_client.BaseClient):
"""Client class to send CRUD Volume Group API requests"""
+ api_version = 'v3'
def create_group(self, **kwargs):
"""Creates a group.
@@ -35,7 +37,7 @@
post_body = json.dumps({'group': kwargs})
resp, body = self.post('groups', post_body)
body = json.loads(body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.create_group, resp, body)
return rest_client.ResponseBody(resp, body)
def delete_group(self, group_id, delete_volumes=True):
@@ -49,7 +51,7 @@
post_body = json.dumps({'delete': post_body})
resp, body = self.post('groups/%s/action' % group_id,
post_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.delete_group, resp, body)
return rest_client.ResponseBody(resp, body)
def show_group(self, group_id):
@@ -62,7 +64,7 @@
url = "groups/%s" % str(group_id)
resp, body = self.get(url)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema.show_group, resp, body)
return rest_client.ResponseBody(resp, body)
def list_groups(self, detail=False, **params):
@@ -74,13 +76,15 @@
https://docs.openstack.org/api-ref/block-storage/v3/#list-groups-with-details
"""
url = "groups"
+ schema_list_groups = schema.list_groups_no_detail
if detail:
url += "/detail"
+ schema_list_groups = schema.list_groups_with_detail
if params:
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.validate_response(schema_list_groups, resp, body)
return rest_client.ResponseBody(resp, body)
def create_group_from_source(self, **kwargs):
@@ -93,7 +97,7 @@
post_body = json.dumps({'create-from-src': kwargs})
resp, body = self.post('groups/action', post_body)
body = json.loads(body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.create_group_from_source, resp, body)
return rest_client.ResponseBody(resp, body)
def update_group(self, group_id, **kwargs):
@@ -105,7 +109,7 @@
"""
put_body = json.dumps({'group': kwargs})
resp, body = self.put('groups/%s' % group_id, put_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.update_group, resp, body)
return rest_client.ResponseBody(resp, body)
def reset_group_status(self, group_id, status_to_set):
@@ -116,7 +120,7 @@
"""
post_body = json.dumps({'reset_status': {'status': status_to_set}})
resp, body = self.post('groups/%s/action' % group_id, post_body)
- self.expected_success(202, resp.status)
+ self.validate_response(schema.reset_group_status, resp, body)
return rest_client.ResponseBody(resp, body)
def is_resource_deleted(self, id):
diff --git a/tempest/manager.py b/tempest/manager.py
index e3174d4..b485ef2 100644
--- a/tempest/manager.py
+++ b/tempest/manager.py
@@ -33,7 +33,7 @@
def __init__(self, credentials, scope='project'):
msg = ("tempest.manager.Manager is not a stable interface and as such "
- "it should not imported directly. It will be removed as "
+ "it should not be imported directly. It will be removed as "
"soon as the client manager becomes available in tempest.lib.")
LOG.warning(msg)
dscv = CONF.identity.disable_ssl_certificate_validation
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index a80b77d..ff860d5 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -91,10 +91,32 @@
volume_microversion=self.volume_request_microversion,
placement_microversion=self.placement_request_microversion))
+ def setup_compute_client(cls):
+ """Compute and Compute security groups client"""
+ cls.compute_images_client = cls.os_primary.compute_images_client
+ cls.keypairs_client = cls.os_primary.keypairs_client
+ cls.compute_security_groups_client = (
+ cls.os_primary.compute_security_groups_client)
+ cls.compute_security_group_rules_client = (
+ cls.os_primary.compute_security_group_rules_client)
+ cls.servers_client = cls.os_primary.servers_client
+ cls.interface_client = cls.os_primary.interfaces_client
+
+ def setup_network_client(cls):
+ """Neutron network client"""
+ cls.networks_client = cls.os_primary.networks_client
+ cls.ports_client = cls.os_primary.ports_client
+ cls.routers_client = cls.os_primary.routers_client
+ cls.subnets_client = cls.os_primary.subnets_client
+ cls.floating_ips_client = cls.os_primary.floating_ips_client
+ cls.security_groups_client = cls.os_primary.security_groups_client
+ cls.security_group_rules_client = (
+ cls.os_primary.security_group_rules_client)
+
@classmethod
def setup_clients(cls):
+ """This setup the service clients for the tests"""
super(ScenarioTest, cls).setup_clients()
- # Clients (in alphabetical order)
cls.flavors_client = cls.os_primary.flavors_client
cls.compute_floating_ips_client = (
cls.os_primary.compute_floating_ips_client)
@@ -108,37 +130,20 @@
raise lib_exc.InvalidConfiguration(
'Either api_v1 or api_v2 must be True in '
'[image-feature-enabled].')
- # Compute image client
- cls.compute_images_client = cls.os_primary.compute_images_client
- cls.keypairs_client = cls.os_primary.keypairs_client
- # Nova security groups client
- cls.compute_security_groups_client = (
- cls.os_primary.compute_security_groups_client)
- cls.compute_security_group_rules_client = (
- cls.os_primary.compute_security_group_rules_client)
- cls.servers_client = cls.os_primary.servers_client
- cls.interface_client = cls.os_primary.interfaces_client
- # Neutron network client
- cls.networks_client = cls.os_primary.networks_client
- cls.ports_client = cls.os_primary.ports_client
- cls.routers_client = cls.os_primary.routers_client
- cls.subnets_client = cls.os_primary.subnets_client
- cls.floating_ips_client = cls.os_primary.floating_ips_client
- cls.security_groups_client = cls.os_primary.security_groups_client
- cls.security_group_rules_client = (
- cls.os_primary.security_group_rules_client)
- # Use the latest available volume clients
+
+ cls.setup_compute_client(cls)
+ cls.setup_network_client(cls)
if CONF.service_available.cinder:
cls.volumes_client = cls.os_primary.volumes_client_latest
cls.snapshots_client = cls.os_primary.snapshots_client_latest
cls.backups_client = cls.os_primary.backups_client_latest
# ## Test functions library
- #
# The create_[resource] functions only return body and discard the
# resp part which is not used in scenario tests
def create_port(self, network_id, client=None, **kwargs):
+ """Creates port"""
if not client:
client = self.ports_client
name = data_utils.rand_name(self.__class__.__name__)
@@ -156,6 +161,13 @@
return port
def create_keypair(self, client=None):
+ """Creates keypair
+
+ Keypair is a public key of OpenSSH key pair used for accessing
+ and create servers
+ Keypair can also be created by a private key for the same purpose
+ Here, the keys are randomly generated[public/private]
+ """
if not client:
client = self.keypairs_client
name = data_utils.rand_name(self.__class__.__name__)
@@ -295,6 +307,13 @@
def create_volume(self, size=None, name=None, snapshot_id=None,
imageRef=None, volume_type=None):
+ """Creates volume
+
+ This wrapper utility creates volume and waits for volume to be
+ in 'available' state.
+ This method returns the volume's full representation by GET request.
+ """
+
if size is None:
size = CONF.volume.volume_size
if imageRef:
@@ -334,6 +353,11 @@
def create_backup(self, volume_id, name=None, description=None,
force=False, snapshot_id=None, incremental=False,
container=None):
+ """Creates backup
+
+ This wrapper utility creates backup and waits for backup to be
+ in 'available' state.
+ """
name = name or data_utils.rand_name(
self.__class__.__name__ + "-backup")
@@ -351,6 +375,12 @@
return backup
def restore_backup(self, backup_id):
+ """Restore backup
+
+ This wrapper utility restores backup and waits for backup to be
+ in 'available' state.
+ """
+
restore = self.backups_client.restore_backup(backup_id)['restore']
self.addCleanup(self.volumes_client.delete_volume,
restore['volume_id'])
@@ -362,8 +392,31 @@
self.assertEqual(backup_id, restore['backup_id'])
return restore
+ def rebuild_server(self, server_id, image=None,
+ preserve_ephemeral=False, wait=True,
+ rebuild_kwargs=None):
+ if image is None:
+ image = CONF.compute.image_ref
+ rebuild_kwargs = rebuild_kwargs or {}
+ LOG.debug("Rebuilding server (id: %s, image: %s, preserve eph: %s)",
+ server_id, image, preserve_ephemeral)
+ self.servers_client.rebuild_server(
+ server_id=server_id,
+ image_ref=image,
+ preserve_ephemeral=preserve_ephemeral,
+ **rebuild_kwargs)
+ if wait:
+ waiters.wait_for_server_status(self.servers_client,
+ server_id, 'ACTIVE')
+
def create_volume_snapshot(self, volume_id, name=None, description=None,
metadata=None, force=False):
+ """Creates volume
+
+ This wrapper utility creates volume snapshot and waits for backup
+ to be in 'available' state.
+ """
+
name = name or data_utils.rand_name(
self.__class__.__name__ + '-snapshot')
snapshot = self.snapshots_client.create_snapshot(
@@ -372,6 +425,7 @@
display_name=name,
description=description,
metadata=metadata)['snapshot']
+
self.addCleanup(self.snapshots_client.wait_for_resource_deletion,
snapshot['id'])
self.addCleanup(self.snapshots_client.delete_snapshot, snapshot['id'])
@@ -401,6 +455,23 @@
admin_volume_type_client.delete_volume_type(volume_type['id'])
def create_volume_type(self, client=None, name=None, backend_name=None):
+ """Creates volume type
+
+ In a multiple-storage back-end configuration,
+ each back end has a name (volume_backend_name).
+ The name of the back end is declared as an extra-specification
+ of a volume type (such as, volume_backend_name=LVM).
+ When a volume is created, the scheduler chooses an
+ appropriate back end to handle the request, according
+ to the volume type specified by the user.
+ The scheduler uses volume types to explicitly create volumes on
+ specific back ends.
+
+ Before using volume type, a volume type has to be declared
+ to Block Storage. In addition to that, an extra-specification
+ has to be created to link the volume type to a back end name.
+ """
+
if not client:
client = self.os_admin.volume_types_client_latest
if not name:
@@ -416,6 +487,7 @@
volume_type = client.create_volume_type(
name=randomized_name, extra_specs=extra_specs)['volume_type']
+ self.assertIn('id', volume_type)
self.addCleanup(self._cleanup_volume_type, volume_type)
return volume_type
@@ -456,7 +528,7 @@
return rules
def _create_security_group(self):
- # Create security group
+ """Create security group and add rules to security group"""
sg_name = data_utils.rand_name(self.__class__.__name__)
sg_desc = sg_name + " description"
secgroup = self.compute_security_groups_client.create_security_group(
@@ -470,7 +542,6 @@
# Add rules to the security group
self._create_loginable_secgroup_rule(secgroup['id'])
-
return secgroup
def get_remote_client(self, ip_address, username=None, private_key=None,
@@ -502,36 +573,7 @@
linux_client.validate_authentication()
return linux_client
- def _image_create(self, name, fmt, path,
- disk_format=None, properties=None):
- if properties is None:
- properties = {}
- name = data_utils.rand_name('%s-' % name)
- params = {
- 'name': name,
- 'container_format': fmt,
- 'disk_format': disk_format or fmt,
- }
- if CONF.image_feature_enabled.api_v1:
- params['is_public'] = 'False'
- params['properties'] = properties
- params = {'headers': common_image.image_meta_to_headers(**params)}
- else:
- params['visibility'] = 'private'
- # Additional properties are flattened out in the v2 API.
- params.update(properties)
- body = self.image_client.create_image(**params)
- image = body['image'] if 'image' in body else body
- self.addCleanup(self.image_client.delete_image, image['id'])
- self.assertEqual("queued", image['status'])
- with open(path, 'rb') as image_file:
- if CONF.image_feature_enabled.api_v1:
- self.image_client.update_image(image['id'], data=image_file)
- else:
- self.image_client.store_image_file(image['id'], image_file)
- return image['id']
-
- def glance_image_create(self):
+ def image_create(self, name='scenario-img'):
img_path = CONF.scenario.img_file
if not os.path.exists(img_path):
# TODO(kopecmartin): replace LOG.warning for rasing
@@ -553,16 +595,38 @@
"properties: %s",
img_path, img_container_format, img_disk_format,
img_properties)
- image = self._image_create('scenario-img',
- img_container_format,
- img_path,
- disk_format=img_disk_format,
- properties=img_properties)
- LOG.debug("image:%s", image)
-
- return image
+ if img_properties is None:
+ img_properties = {}
+ name = data_utils.rand_name('%s-' % name)
+ params = {
+ 'name': name,
+ 'container_format': img_container_format,
+ 'disk_format': img_disk_format or img_container_format,
+ }
+ if CONF.image_feature_enabled.api_v1:
+ params['is_public'] = 'False'
+ if img_properties:
+ params['properties'] = img_properties
+ params = {'headers': common_image.image_meta_to_headers(**params)}
+ else:
+ params['visibility'] = 'private'
+ # Additional properties are flattened out in the v2 API.
+ if img_properties:
+ params.update(img_properties)
+ body = self.image_client.create_image(**params)
+ image = body['image'] if 'image' in body else body
+ self.addCleanup(self.image_client.delete_image, image['id'])
+ self.assertEqual("queued", image['status'])
+ with open(img_path, 'rb') as image_file:
+ if CONF.image_feature_enabled.api_v1:
+ self.image_client.update_image(image['id'], data=image_file)
+ else:
+ self.image_client.store_image_file(image['id'], image_file)
+ LOG.debug("image:%s", image['id'])
+ return image['id']
def _log_console_output(self, servers=None, client=None):
+ """Console log output"""
if not CONF.compute_feature_enabled.console_output:
LOG.debug('Console output not supported, cannot log')
return
@@ -581,11 +645,12 @@
"for the console log", server['id'])
def _log_net_info(self, exc):
- # network debug is called as part of ssh init
+ """network debug is called as part of ssh init"""
if not isinstance(exc, lib_exc.SSHTimeout):
LOG.debug('Network information on a devstack host')
def create_server_snapshot(self, server, name=None):
+ """Creates server snapshot"""
# Glance client
_image_client = self.image_client
# Compute client
@@ -603,7 +668,7 @@
_image_client.delete_image, image_id)
if CONF.image_feature_enabled.api_v1:
- # In glance v1 the additional properties are stored in the headers.
+ # In glance v1 the additional properties are stored in the headers
resp = _image_client.check_image(image_id)
snapshot_image = common_image.get_image_meta_from_headers(resp)
image_props = snapshot_image.get('properties', {})
@@ -633,22 +698,34 @@
return snapshot_image
def nova_volume_attach(self, server, volume_to_attach):
+ """Compute volume attach
+
+ This utility attaches volume from compute and waits for the
+ volume status to be 'in-use' state.
+ """
volume = self.servers_client.attach_volume(
server['id'], volumeId=volume_to_attach['id'])['volumeAttachment']
self.assertEqual(volume_to_attach['id'], volume['id'])
waiters.wait_for_volume_resource_status(self.volumes_client,
volume['id'], 'in-use')
-
# Return the updated volume after the attachment
return self.volumes_client.show_volume(volume['id'])['volume']
def nova_volume_detach(self, server, volume):
+ """Compute volume detach
+
+ This utility detaches volume from compute and check whether the
+ volume status is 'available' state, and if not, an exception
+ will be thrown.
+ """
self.servers_client.detach_volume(server['id'], volume['id'])
waiters.wait_for_volume_resource_status(self.volumes_client,
volume['id'], 'available')
+ volume = self.volumes_client.show_volume(volume['id'])['volume']
def ping_ip_address(self, ip_address, should_succeed=True,
ping_timeout=None, mtu=None, server=None):
+ """ping ip address"""
timeout = ping_timeout or CONF.validation.ping_timeout
cmd = ['ping', '-c1', '-w1']
@@ -709,6 +786,7 @@
:raises: AssertError if the result of the connectivity check does
not match the value of the should_connect param
"""
+
LOG.debug('checking network connections to IP %s with user: %s',
ip_address, username)
if should_connect:
@@ -732,7 +810,7 @@
LOG.exception(extra_msg)
raise
- def create_floating_ip(self, thing, pool_name=None):
+ def create_floating_ip(self, server, pool_name=None):
"""Create a floating IP and associates to a server on Nova"""
if not pool_name:
@@ -743,11 +821,17 @@
self.compute_floating_ips_client.delete_floating_ip,
floating_ip['id'])
self.compute_floating_ips_client.associate_floating_ip_to_server(
- floating_ip['ip'], thing['id'])
+ floating_ip['ip'], server['id'])
return floating_ip
def create_timestamp(self, ip_address, dev_name=None, mount_path='/mnt',
private_key=None, server=None):
+ """Creates timestamp
+
+ This wrapper utility does ssh, creates timestamp and returns the
+ created timestamp.
+ """
+
ssh_client = self.get_remote_client(ip_address,
private_key=private_key,
server=server)
@@ -765,6 +849,11 @@
def get_timestamp(self, ip_address, dev_name=None, mount_path='/mnt',
private_key=None, server=None):
+ """Returns timestamp
+
+ This wrapper utility does ssh and returns the timestamp.
+ """
+
ssh_client = self.get_remote_client(ip_address,
private_key=private_key,
server=server)
@@ -782,6 +871,7 @@
Based on the configuration we're in, return a correct ip
address for validating that a guest is up.
"""
+
if CONF.validation.connect_method == 'floating':
# The tests calling this method don't have a floating IP
# and can't make use of the validation resources. So the
@@ -807,6 +897,8 @@
@classmethod
def get_host_for_server(cls, server_id):
+ """Gets host of server"""
+
server_details = cls.os_admin.servers_client.show_server(server_id)
return server_details['server']['OS-EXT-SRV-ATTR:host']
@@ -825,6 +917,12 @@
security_group=None,
delete_on_termination=False,
name=None):
+ """Boot instance from resource
+
+ This wrapper utility boots instance from resource with block device
+ mapping with source info passed in arguments
+ """
+
create_kwargs = dict()
if keypair:
create_kwargs['key_name'] = keypair['name']
@@ -841,6 +939,7 @@
return self.create_server(image_id='', **create_kwargs)
def create_volume_from_image(self):
+ """Create volume from image"""
img_uuid = CONF.compute.image_ref
vol_name = data_utils.rand_name(
self.__class__.__name__ + '-volume-origin')
@@ -896,8 +995,17 @@
namestart='subnet-smoke', **kwargs):
"""Create a subnet for the given network
+ This utility creates subnet for the given network
within the cidr block configured for tenant networks.
+
+ :param **kwargs:
+ See extra parameters below
+
+ :Keyword Arguments:
+
+ * *ip_version = ip version of the given network,
"""
+
if not subnets_client:
subnets_client = self.subnets_client
@@ -1000,22 +1108,23 @@
"Unable to get network by name: %s" % network_name)
return net[0]
- def create_floating_ip(self, thing, external_network_id=None,
+ def create_floating_ip(self, server, external_network_id=None,
port_id=None, client=None):
"""Create a floating IP and associates to a resource/port on Neutron"""
+
if not external_network_id:
external_network_id = CONF.network.public_network_id
if not client:
client = self.floating_ips_client
if not port_id:
- port_id, ip4 = self._get_server_port_id_and_ip4(thing)
+ port_id, ip4 = self._get_server_port_id_and_ip4(server)
else:
ip4 = None
kwargs = {
'floating_network_id': external_network_id,
'port_id': port_id,
- 'tenant_id': thing.get('project_id') or thing['tenant_id'],
+ 'tenant_id': server.get('project_id') or server['tenant_id'],
'fixed_ip_address': ip4,
}
if CONF.network.subnet_id:
@@ -1035,6 +1144,7 @@
:param status: target status
:raises: AssertionError if status doesn't match
"""
+
floatingip_id = floating_ip['id']
def refresh():
@@ -1061,6 +1171,7 @@
private_key,
should_connect=True,
servers_for_debug=None):
+ """Checks tenant network connectivity"""
if not CONF.network.project_networks_reachable:
msg = 'Tenant networks not configured to be reachable.'
LOG.info(msg)
@@ -1093,6 +1204,7 @@
:returns: True, if the connection succeeded and it was expected to
succeed. False otherwise.
"""
+
method_name = '%s_check' % protocol
connectivity_checker = getattr(source, method_name)
@@ -1156,6 +1268,7 @@
:param project_id: secgroup will be created in this project
:returns: the created security group
"""
+
if client is None:
client = self.security_groups_client
if not project_id:
@@ -1197,6 +1310,7 @@
port_range_max: 22
}
"""
+
if sec_group_rules_client is None:
sec_group_rules_client = self.security_group_rules_client
if security_groups_client is None:
@@ -1287,6 +1401,7 @@
network has, a tenant router will be created and returned that
routes traffic to the public network.
"""
+
if not client:
client = self.routers_client
if not project_id:
@@ -1327,6 +1442,7 @@
'provider:segmentation_id': '42'}
:returns: network, subnet, router
"""
+
if CONF.network.shared_physical_network:
# NOTE(Shrews): This exception is for environments where tenant
# credential isolation is available, but network separation is
@@ -1383,6 +1499,7 @@
def create_encryption_type(self, client=None, type_id=None, provider=None,
key_size=None, cipher=None,
control_location=None):
+ """Creates an encryption type for volume"""
if not client:
client = self.admin_encryption_types_client
if not type_id:
@@ -1396,6 +1513,7 @@
def create_encrypted_volume(self, encryption_provider, volume_type,
key_size=256, cipher='aes-xts-plain64',
control_location='front-end'):
+ """Creates an encrypted volume"""
volume_type = self.create_volume_type(name=volume_type)
self.create_encryption_type(type_id=volume_type['id'],
provider=encryption_provider,
@@ -1436,11 +1554,12 @@
cls.object_client = cls.os_operator.object_client
def get_swift_stat(self):
- """get swift status for our user account."""
+ """Get swift status for our user account."""
self.account_client.list_account_containers()
LOG.debug('Swift status information obtained successfully')
def create_container(self, container_name=None):
+ """Creates container"""
name = container_name or data_utils.rand_name(
'swift-scenario-container')
self.container_client.update_container(name)
@@ -1453,10 +1572,12 @@
return name
def delete_container(self, container_name):
+ """Deletes container"""
self.container_client.delete_container(container_name)
LOG.debug('Container %s deleted', container_name)
def upload_object_to_container(self, container_name, obj_name=None):
+ """Uploads object to container"""
obj_name = obj_name or data_utils.rand_name('swift-scenario-object')
obj_data = data_utils.random_bytes()
self.object_client.create_object(container_name, obj_name, obj_data)
@@ -1467,6 +1588,7 @@
return obj_name, obj_data
def delete_object(self, container_name, filename):
+ """Deletes object"""
self.object_client.delete_object(container_name, filename)
self.list_and_check_container_objects(container_name,
not_present_obj=[filename])
@@ -1474,8 +1596,13 @@
def list_and_check_container_objects(self, container_name,
present_obj=None,
not_present_obj=None):
- # List objects for a given container and assert which are present and
- # which are not.
+ """List and verify objects for a given container
+
+ This utility lists objects for a given container
+ and asserts which are present and
+ which are not
+ """
+
if present_obj is None:
present_obj = []
if not_present_obj is None:
@@ -1490,5 +1617,6 @@
self.assertNotIn(obj, object_list)
def download_and_verify(self, container_name, obj_name, expected_data):
+ """Asserts the object and expected data to verify if they are same"""
_, obj = self.object_client.get_object(container_name, obj_name)
self.assertEqual(obj, expected_data)
diff --git a/tempest/scenario/test_encrypted_cinder_volumes.py b/tempest/scenario/test_encrypted_cinder_volumes.py
index 008d1ae..fc93a5e 100644
--- a/tempest/scenario/test_encrypted_cinder_volumes.py
+++ b/tempest/scenario/test_encrypted_cinder_volumes.py
@@ -44,7 +44,7 @@
raise cls.skipException('Encrypted volume attach is not supported')
def launch_instance(self):
- image = self.glance_image_create()
+ image = self.image_create()
keypair = self.create_keypair()
return self.create_server(image_id=image, key_name=keypair['name'])
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index 4cd860d..fe42583 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -106,7 +106,7 @@
@decorators.idempotent_id('bdbb5441-9204-419d-a225-b4fdbfb1a1a8')
@utils.services('compute', 'volume', 'image', 'network')
def test_minimum_basic_scenario(self):
- image = self.glance_image_create()
+ image = self.image_create()
keypair = self.create_keypair()
server = self.create_server(image_id=image, key_name=keypair['name'])
diff --git a/tempest/scenario/test_network_v6.py b/tempest/scenario/test_network_v6.py
index 8de6614..14f24c7 100644
--- a/tempest/scenario/test_network_v6.py
+++ b/tempest/scenario/test_network_v6.py
@@ -130,7 +130,7 @@
key_name=self.keypair['name'],
security_groups=[{'name': self.sec_grp['name']}],
networks=[{'uuid': n['id']} for n in networks])
- fip = self.create_floating_ip(thing=srv)
+ fip = self.create_floating_ip(server=srv)
ips = self.define_server_ips(srv=srv)
ssh = self.get_remote_client(
ip_address=fip['floating_ip_address'],
diff --git a/tempest/tests/cmd/sample_streams/calls.subunit b/tempest/tests/cmd/subunit_describe_calls_data/calls.subunit
similarity index 100%
rename from tempest/tests/cmd/sample_streams/calls.subunit
rename to tempest/tests/cmd/subunit_describe_calls_data/calls.subunit
Binary files differ
diff --git a/tempest/tests/cmd/subunit_describe_calls_data/calls_subunit_expected.json b/tempest/tests/cmd/subunit_describe_calls_data/calls_subunit_expected.json
new file mode 100644
index 0000000..53976ee
--- /dev/null
+++ b/tempest/tests/cmd/subunit_describe_calls_data/calls_subunit_expected.json
@@ -0,0 +1,87 @@
+{"bar":[
+ {
+ "name":"AgentsAdminTestJSON:setUp",
+ "request_body":"{\"agent\": {\"url\": \"xxx://xxxx/xxx/xxx\", \"hypervisor\": \"common\", \"md5hash\": \"add6bb58e139be103324d04d82d8f545\", \"version\": \"7.0\", \"architecture\": \"tempest-x86_64-424013832\", \"os\": \"linux\"}}",
+ "request_headers":"{'Content-Type': 'application/json', 'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
+ "response_body":"{\"agent\": {\"url\": \"xxx://xxxx/xxx/xxx\", \"hypervisor\": \"common\", \"md5hash\": \"add6bb58e139be103324d04d82d8f545\", \"version\": \"7.0\", \"architecture\": \"tempest-x86_64-424013832\", \"os\": \"linux\", \"agent_id\": 1}}",
+ "response_headers":"{'status': '200', 'content-length': '203', 'x-compute-request-id': 'req-25ddaae2-0ef1-40d1-8228-59bd64a7e75b', 'vary': 'X-OpenStack-Nova-API-Version', 'connection': 'close', 'x-openstack-nova-api-version': '2.1', 'date': 'Tue, 02 Feb 2016 03:27:00 GMT', 'content-type': 'application/json'}",
+ "service":"Nova",
+ "status_code":"200",
+ "url":"v2.1/<id>/os-agents",
+ "verb":"POST"
+},
+ {
+ "name":"AgentsAdminTestJSON:test_create_agent",
+ "request_body":"{\"agent\": {\"url\": \"xxx://xxxx/xxx/xxx\", \"hypervisor\": \"kvm\", \"md5hash\": \"add6bb58e139be103324d04d82d8f545\", \"version\": \"7.0\", \"architecture\": \"tempest-x86-252246646\", \"os\": \"win\"}}",
+ "request_headers":"{'Content-Type': 'application/json', 'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
+ "response_body":"{\"agent\": {\"url\": \"xxx://xxxx/xxx/xxx\", \"hypervisor\": \"kvm\", \"md5hash\": \"add6bb58e139be103324d04d82d8f545\", \"version\": \"7.0\", \"architecture\": \"tempest-x86-252246646\", \"os\": \"win\", \"agent_id\": 2}}",
+ "response_headers":"{'status': '200', 'content-length': '195', 'x-compute-request-id': 'req-b4136f06-c015-4e7e-995f-c43831e3ecce', 'vary': 'X-OpenStack-Nova-API-Version', 'connection': 'close', 'x-openstack-nova-api-version': '2.1', 'date': 'Tue, 02 Feb 2016 03:27:00 GMT', 'content-type': 'application/json'}",
+ "service":"Nova",
+ "status_code":"200",
+ "url":"v2.1/<id>/os-agents",
+ "verb":"POST"
+},
+ {
+ "name":"AgentsAdminTestJSON:tearDown",
+ "request_body":"None",
+ "request_headers":"{'Content-Type': 'application/json', 'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
+ "response_body":"",
+ "response_headers":"{'status': '200', 'content-length': '0', 'x-compute-request-id': 'req-ee905fd6-a5b5-4da4-8c37-5363cb25bd9d', 'vary': 'X-OpenStack-Nova-API-Version', 'connection': 'close', 'x-openstack-nova-api-version': '2.1', 'date': 'Tue, 02 Feb 2016 03:27:00 GMT', 'content-type': 'application/json'}",
+ "service":"Nova",
+ "status_code":"200",
+ "url":"v2.1/<id>/os-agents/1",
+ "verb":"DELETE"
+},
+ {
+ "name":"AgentsAdminTestJSON:_run_cleanups",
+ "request_body":"None",
+ "request_headers":"{'Content-Type': 'application/json', 'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
+ "response_headers":"{'status': '200', 'content-length': '0', 'x-compute-request-id': 'req-e912cac0-63e0-4679-a68a-b6d18ddca074', 'vary': 'X-OpenStack-Nova-API-Version', 'connection': 'close', 'x-openstack-nova-api-version': '2.1', 'date': 'Tue, 02 Feb 2016 03:27:00 GMT', 'content-type': 'application/json'}",
+ "service":"Nova",
+ "status_code":"200",
+ "url":"v2.1/<id>/os-agents/2",
+ "verb":"DELETE"
+}], "foo":[
+ {
+ "name":"AgentsAdminTestJSON:setUp",
+ "request_body":"{\"agent\": {\"url\": \"xxx://xxxx/xxx/xxx\", \"hypervisor\": \"common\", \"md5hash\": \"add6bb58e139be103324d04d82d8f545\", \"version\": \"7.0\", \"architecture\": \"tempest-x86_64-948635295\", \"os\": \"linux\"}}",
+ "request_headers":"{'Content-Type': 'application/json', 'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
+ "response_body":"{\"agent\": {\"url\": \"xxx://xxxx/xxx/xxx\", \"hypervisor\": \"common\", \"md5hash\": \"add6bb58e139be103324d04d82d8f545\", \"version\": \"7.0\", \"architecture\": \"tempest-x86_64-948635295\", \"os\": \"linux\", \"agent_id\": 3}}",
+ "response_headers":"{'status': '200', 'content-length': '203', 'x-compute-request-id': 'req-ccd2116d-04b1-4ffe-ae32-fb623f68bf1c', 'vary': 'X-OpenStack-Nova-API-Version', 'connection': 'close', 'x-openstack-nova-api-version': '2.1', 'date': 'Tue, 02 Feb 2016 03:27:01 GMT', 'content-type': 'application/json'}",
+ "service":"Nova",
+ "status_code":"200",
+ "url":"v2.1/<id>/os-agents",
+ "verb":"POST"
+},
+ {
+ "name":"AgentsAdminTestJSON:test_delete_agent",
+ "request_body":"None",
+ "request_headers":"{'Content-Type': 'application/json', 'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
+ "response_body":"",
+ "response_headers":"{'status': '200', 'content-length': '0', 'x-compute-request-id': 'req-6e7fa28f-ae61-4388-9a78-947c58bc0588', 'vary': 'X-OpenStack-Nova-API-Version', 'connection': 'close', 'x-openstack-nova-api-version': '2.1', 'date': 'Tue, 02 Feb 2016 03:27:01 GMT', 'content-type': 'application/json'}",
+ "service":"Nova",
+ "status_code":"200",
+ "url":"v2.1/<id>/os-agents/3",
+ "verb":"DELETE"
+},
+ {
+ "name":"AgentsAdminTestJSON:test_delete_agent",
+ "request_body":"None",
+ "request_headers":"{'Content-Type': 'application/json', 'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
+ "response_body":"{\"agents\": []}",
+ "response_headers":"{'status': '200', 'content-length': '14', 'content-location': 'http://23.253.76.97:8774/v2.1/cf6b1933fe5b476fbbabb876f6d1b924/os-agents', 'x-compute-request-id': 'req-e41aa9b4-41a6-4138-ae04-220b768eb644', 'vary': 'X-OpenStack-Nova-API-Version', 'connection': 'close', 'x-openstack-nova-api-version': '2.1', 'date': 'Tue, 02 Feb 2016 03:27:01 GMT', 'content-type': 'application/json'}",
+ "service":"Nova",
+ "status_code":"200",
+ "url":"v2.1/<id>/os-agents",
+ "verb":"GET"
+},
+ {
+ "name":"AgentsAdminTestJSON:tearDown",
+ "request_body":"None",
+ "request_headers":"{'Content-Type': 'application/json', 'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
+ "response_headers":"{'status': '404', 'content-length': '82', 'x-compute-request-id': 'req-e297aeea-91cf-4f26-b49c-8f46b1b7a926', 'vary': 'X-OpenStack-Nova-API-Version', 'connection': 'close', 'x-openstack-nova-api-version': '2.1', 'date': 'Tue, 02 Feb 2016 03:27:02 GMT', 'content-type': 'application/json; charset=UTF-8'}",
+ "service":"Nova",
+ "status_code":"404",
+ "url":"v2.1/<id>/os-agents/3",
+ "verb":"DELETE"
+}]}
\ No newline at end of file
diff --git a/tempest/tests/cmd/test_subunit_describe_calls.py b/tempest/tests/cmd/test_subunit_describe_calls.py
index cb34ba6..4fed84a 100644
--- a/tempest/tests/cmd/test_subunit_describe_calls.py
+++ b/tempest/tests/cmd/test_subunit_describe_calls.py
@@ -14,220 +14,422 @@
# License for the specific language governing permissions and limitations
# under the License.
+import argparse
+from io import StringIO
import os
+import shutil
import subprocess
+import sys
import tempfile
+from unittest import mock
+from unittest.mock import patch
+
+from oslo_serialization import jsonutils as json
from tempest.cmd import subunit_describe_calls
from tempest.tests import base
-class TestSubunitDescribeCalls(base.TestCase):
- def test_return_code(self):
- subunit_file = os.path.join(
- os.path.dirname(os.path.abspath(__file__)),
- 'sample_streams/calls.subunit')
- p = subprocess.Popen([
- 'subunit-describe-calls', '-s', subunit_file,
- '-o', tempfile.mkstemp()[1]], stdin=subprocess.PIPE)
- p.communicate()
- self.assertEqual(0, p.returncode)
+class TestArgumentParser(base.TestCase):
+ def test_init(self):
+ test_object = subunit_describe_calls.ArgumentParser()
+ self.assertEqual("subunit-describe-calls", test_object.prog)
+ self.assertEqual(subunit_describe_calls.DESCRIPTION,
+ test_object.description)
- def test_verbose(self):
- subunit_file = os.path.join(
- os.path.dirname(os.path.abspath(__file__)),
- 'sample_streams/calls.subunit')
- p = subprocess.Popen([
- 'subunit-describe-calls', '-s', subunit_file,
- '-v'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
- stdout = p.communicate()
- self.assertEqual(0, p.returncode)
- self.assertIn(b'- request headers:', stdout[0])
- self.assertIn(b'- request body:', stdout[0])
- self.assertIn(b'- response headers:', stdout[0])
- self.assertIn(b'- response body:', stdout[0])
- def test_return_code_no_output(self):
- subunit_file = os.path.join(
+class TestUrlParser(base.TestCase):
+ services_custom_ports = {
+ "18776": "Block Storage",
+ "18774": "Nova",
+ "18773": "Nova-API",
+ "18386": "Sahara",
+ "35358": "Keystone",
+ "19292": "Glance",
+ "19696": "Neutron",
+ "16000": "Swift",
+ "18004": "Heat",
+ "18777": "Ceilometer",
+ "10080": "Horizon",
+ "18080": "Swift",
+ "1873": "rsync",
+ "13260": "iSCSI",
+ "13306": "MySQL",
+ "15672": "AMQP",
+ "18082": "murano"}
+
+ def setUp(self):
+ super(TestUrlParser, self).setUp()
+ self.test_object = subunit_describe_calls.UrlParser()
+
+ def test_get_service_default_ports(self):
+ base_url = "http://site.something.com:"
+ for port in self.test_object.services:
+ url = base_url + port + "/v2/action"
+ service = self.test_object.services[port]
+ self.assertEqual(service, self.test_object.get_service(url))
+
+ def test_get_service_custom_ports(self):
+ self.test_object = subunit_describe_calls.\
+ UrlParser(services=self.services_custom_ports)
+ base_url = "http://site.something.com:"
+ for port in self.services_custom_ports:
+ url = base_url + port + "/v2/action"
+ service = self.services_custom_ports[port]
+ self.assertEqual(service, self.test_object.get_service(url))
+
+ def test_get_service_port_not_found(self):
+ url = "https://site.somewhere.com:1234/v2/action"
+ self.assertEqual("Unknown", self.test_object.get_service(url))
+ self.assertEqual("Unknown", self.test_object.get_service(""))
+
+ def test_parse_details_none(self):
+ self.assertIsNone(self.test_object.parse_details(None))
+
+ def test_url_path_ports(self):
+ uuid_sample1 = "3715e0bb-b1b3-4291-aa13-2c86c3b9ec93"
+ uuid_sample2 = "2715e0bb-b1b4-4291-aa13-2c86c3b9ec88"
+
+ # test http url
+ host = "http://host.company.com"
+ url = host + ":8776/v3/" + uuid_sample1 + "/types/" + \
+ uuid_sample2 + "/extra_specs"
+ self.assertEqual("v3/<uuid>/types/<uuid>/extra_specs",
+ self.test_object.url_path(url))
+ url = host + ":8774/v2.1/servers/" + uuid_sample1
+ self.assertEqual("v2.1/servers/<uuid>",
+ self.test_object.url_path(url))
+ # test https url
+ host = "https://host.company.com"
+ url = host + ":8776/v3/" + uuid_sample1 + "/types/" + \
+ uuid_sample2 + "/extra_specs"
+ self.assertEqual("v3/<uuid>/types/<uuid>/extra_specs",
+ self.test_object.url_path(url))
+ url = host + ":8774/v2.1/servers/" + uuid_sample1
+ self.assertEqual("v2.1/servers/<uuid>",
+ self.test_object.url_path(url))
+
+ def test_url_path_no_match(self):
+ host_port = 'https://host.company.com:1234/'
+ url = 'v2/action/no/special/data'
+ self.assertEqual(url, self.test_object.url_path(host_port + url))
+ url = 'data'
+ self.assertEqual(url, self.test_object.url_path(url))
+
+
+class TestCliBase(base.TestCase):
+ """Base class for share code on all CLI sub-process testing"""
+
+ def setUp(self):
+ super(TestCliBase, self).setUp()
+ self._subunit_file = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
- 'sample_streams/calls.subunit')
+ 'subunit_describe_calls_data', 'calls.subunit')
+
+ def _bytes_to_string(self, data):
+ if isinstance(data, (bytes, bytearray)):
+ data = str(data, 'utf-8')
+ return data
+
+ def _assert_cli_message(self, data):
+ data = self._bytes_to_string(data)
+ self.assertIn("Running subunit_describe_calls ...", data)
+
+ def _assert_deprecated_warning(self, stdout):
+ self.assertIn(
+ b"Use of: 'subunit-describe-calls' is deprecated, "
+ b"please use: 'tempest subunit-describe-calls'", stdout)
+
+ def _assert_expect_json(self, json_data):
+ expected_file_name = os.path.join(
+ os.path.dirname(os.path.abspath(__file__)),
+ 'subunit_describe_calls_data', 'calls_subunit_expected.json')
+ with open(expected_file_name, "rb") as read_file:
+ expected_result = json.load(read_file)
+ self.assertDictEqual(expected_result, json_data)
+
+ def _assert_headers_and_bodies(self, data):
+ data = self._bytes_to_string(data)
+ self.assertIn('- request headers:', data)
+ self.assertIn('- request body:', data)
+ self.assertIn('- response headers:', data)
+ self.assertIn('- response body:', data)
+
+ def _assert_methods_details(self, data):
+ data = self._bytes_to_string(data)
+ self.assertIn('foo', data)
+ self.assertIn('- 200 POST request for Nova to v2.1/<id>/',
+ data)
+ self.assertIn('- 200 DELETE request for Nova to v2.1/<id>/',
+ data)
+ self.assertIn('- 200 GET request for Nova to v2.1/<id>/',
+ data)
+ self.assertIn('- 404 DELETE request for Nova to v2.1/<id>/',
+ data)
+
+ def _assert_mutual_exclusive_message(self, stderr):
+ self.assertIn(b"usage: subunit-describe-calls "
+ b"[-h] [-s [<subunit file>]]", stderr)
+ self.assertIn(b"[-n <non subunit name>] [-o <output file>]",
+ stderr)
+ self.assertIn(b"[-p <ports file>] [-v | -a]", stderr)
+ self.assertIn(
+ b"subunit-describe-calls: error: argument -v/--verbose: "
+ b"not allowed with argument -a/--all-stdout", stderr)
+
+ def _assert_no_headers_and_bodies(self, data):
+ data = self._bytes_to_string(data)
+ self.assertNotIn('- request headers:', data)
+ self.assertNotIn('- request body:', data)
+ self.assertNotIn('- response headers:', data)
+ self.assertNotIn('- response body:', data)
+
+
+class TestMainCli(TestCliBase):
+ """Test cases that use subunit_describe_calls module main interface
+
+ via subprocess calls to make sure the total user experience
+ is well defined and tested. This interface is deprecated.
+ Note: these test do not affect code coverage percentages.
+ """
+
+ def test_main_output_file(self):
+ temp_file = tempfile.mkstemp()[1]
p = subprocess.Popen([
- 'subunit-describe-calls', '-s', subunit_file],
- stdin=subprocess.PIPE, stdout=subprocess.PIPE)
- stdout = p.communicate()
+ 'subunit-describe-calls', '-s', self._subunit_file,
+ '-o', temp_file], stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
self.assertEqual(0, p.returncode)
- self.assertIn(b'foo', stdout[0])
- self.assertIn(b'- 200 POST request for Nova to v2.1/<id>/',
- stdout[0])
- self.assertIn(b'- 200 DELETE request for Nova to v2.1/<id>/',
- stdout[0])
- self.assertIn(b'- 200 GET request for Nova to v2.1/<id>/',
- stdout[0])
- self.assertIn(b'- 404 DELETE request for Nova to v2.1/<id>/',
- stdout[0])
- self.assertNotIn(b'- request headers:', stdout[0])
- self.assertNotIn(b'- request body:', stdout[0])
- self.assertNotIn(b'- response headers:', stdout[0])
- self.assertNotIn(b'- response body:', stdout[0])
+ self._assert_cli_message(stdout)
+ self._assert_deprecated_warning(stdout)
+ with open(temp_file, 'r') as file:
+ data = json.loads(file.read())
+ self._assert_expect_json(data)
+
+ def test_main_verbose(self):
+ p = subprocess.Popen([
+ 'subunit-describe-calls', '-s', self._subunit_file,
+ '-v'], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ self.assertEqual(0, p.returncode)
+ self._assert_cli_message(stdout)
+ self._assert_deprecated_warning(stdout)
+ self._assert_methods_details(stdout)
+ self._assert_headers_and_bodies(stdout)
+
+ def test_main_all_stdout(self):
+ p = subprocess.Popen([
+ 'subunit-describe-calls', '-s', self._subunit_file,
+ '--all-stdout'], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ self.assertEqual(0, p.returncode)
+ self._assert_cli_message(stdout)
+ self._assert_deprecated_warning(stdout)
+ self._assert_methods_details(stdout)
+ self._assert_headers_and_bodies(stdout)
+
+ def test_main(self):
+ p = subprocess.Popen([
+ 'subunit-describe-calls', '-s', self._subunit_file],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ self.assertEqual(0, p.returncode)
+ self._assert_cli_message(stdout)
+ self._assert_deprecated_warning(stdout)
+ self._assert_methods_details(stdout)
+ self._assert_no_headers_and_bodies(stdout)
+
+ def test_main_verbose_and_all_stdout(self):
+ p = subprocess.Popen([
+ 'subunit-describe-calls', '-s', self._subunit_file,
+ '-a', '-v'],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ self.assertEqual(2, p.returncode)
+ self._assert_cli_message(stdout)
+ self._assert_deprecated_warning(stdout)
+ self._assert_mutual_exclusive_message(stderr)
+
+
+class TestCli(TestCliBase):
+ """Test cases that use tempest subunit_describe_calls cliff interface
+
+ via subprocess calls to make sure the total user experience
+ is well defined and tested.
+ Note: these test do not affect code coverage percentages.
+ """
+
+ def _assert_cliff_verbose(self, stdout):
+ self.assertIn(b'tempest initialize_app', stdout)
+ self.assertIn(b'prepare_to_run_command TempestSubunitDescribeCalls',
+ stdout)
+ self.assertIn(b'tempest clean_up TempestSubunitDescribeCalls',
+ stdout)
+
+ def test_run_all_stdout(self):
+ p = subprocess.Popen(['tempest', 'subunit-describe-calls',
+ '-s', self._subunit_file, '-a'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ self.assertEqual(0, p.returncode)
+ self._assert_cli_message(stdout)
+ self._assert_methods_details(stdout)
+ self._assert_headers_and_bodies(stdout)
+
+ def test_run_verbose(self):
+ p = subprocess.Popen(['tempest', 'subunit-describe-calls',
+ '-s', self._subunit_file, '-v'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ self.assertEqual(0, p.returncode)
+ self._assert_cli_message(stdout)
+ self._assert_methods_details(stdout)
+ self._assert_no_headers_and_bodies(stdout)
+ self._assert_cliff_verbose(stderr)
+
+ def test_run_min(self):
+ p = subprocess.Popen(['tempest', 'subunit-describe-calls',
+ '-s', self._subunit_file],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ self.assertEqual(0, p.returncode)
+ self._assert_cli_message(stdout)
+ self._assert_methods_details(stdout)
+ self._assert_no_headers_and_bodies(stdout)
+
+ def test_run_verbose_all_stdout(self):
+ """Test Cliff -v argument
+
+ Since Cliff framework has a argument at the
+ abstract command level the -v or --verbose for
+ this command is not processed as a boolean.
+ So the use of verbose only exists for the
+ deprecated main CLI interface. When the
+ main is deleted this test would not be needed.
+ """
+ p = subprocess.Popen(['tempest', 'subunit-describe-calls',
+ '-s', self._subunit_file, '-a', '-v'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ self.assertEqual(0, p.returncode)
+ self._assert_cli_message(stdout)
+ self._assert_cliff_verbose(stderr)
+ self._assert_methods_details(stdout)
+
+
+class TestSubunitDescribeCalls(TestCliBase):
+ """Test cases use the subunit_describe_calls module interface
+
+ and effect code coverage reporting
+ """
+
+ def setUp(self):
+ super(TestSubunitDescribeCalls, self).setUp()
+ self.test_object = subunit_describe_calls.TempestSubunitDescribeCalls(
+ app=mock.Mock(),
+ app_args=mock.Mock(spec=argparse.Namespace))
def test_parse(self):
- subunit_file = os.path.join(
- os.path.dirname(os.path.abspath(__file__)),
- 'sample_streams/calls.subunit')
- parser = subunit_describe_calls.parse(
- open(subunit_file), "pythonlogging", None)
- expected_result = {
- 'bar': [{
- 'name': 'AgentsAdminTestJSON:setUp',
- 'request_body': '{"agent": {"url": "xxx://xxxx/xxx/xxx", '
- '"hypervisor": "common", "md5hash": '
- '"add6bb58e139be103324d04d82d8f545", "version": "7.0", '
- '"architecture": "tempest-x86_64-424013832", "os": "linux"}}',
- 'request_headers': "{'Content-Type': 'application/json', "
- "'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
- 'response_body': '{"agent": {"url": "xxx://xxxx/xxx/xxx", '
- '"hypervisor": "common", "md5hash": '
- '"add6bb58e139be103324d04d82d8f545", "version": "7.0", '
- '"architecture": "tempest-x86_64-424013832", "os": "linux", '
- '"agent_id": 1}}',
- 'response_headers': "{'status': '200', 'content-length': "
- "'203', 'x-compute-request-id': "
- "'req-25ddaae2-0ef1-40d1-8228-59bd64a7e75b', 'vary': "
- "'X-OpenStack-Nova-API-Version', 'connection': 'close', "
- "'x-openstack-nova-api-version': '2.1', 'date': "
- "'Tue, 02 Feb 2016 03:27:00 GMT', 'content-type': "
- "'application/json'}",
- 'service': 'Nova',
- 'status_code': '200',
- 'url': 'v2.1/<id>/os-agents',
- 'verb': 'POST'}, {
- 'name': 'AgentsAdminTestJSON:test_create_agent',
- 'request_body': '{"agent": {"url": "xxx://xxxx/xxx/xxx", '
- '"hypervisor": "kvm", "md5hash": '
- '"add6bb58e139be103324d04d82d8f545", "version": "7.0", '
- '"architecture": "tempest-x86-252246646", "os": "win"}}',
- 'request_headers': "{'Content-Type': 'application/json', "
- "'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
- 'response_body': '{"agent": {"url": "xxx://xxxx/xxx/xxx", '
- '"hypervisor": "kvm", "md5hash": '
- '"add6bb58e139be103324d04d82d8f545", "version": "7.0", '
- '"architecture": "tempest-x86-252246646", "os": "win", '
- '"agent_id": 2}}',
- 'response_headers': "{'status': '200', 'content-length': "
- "'195', 'x-compute-request-id': "
- "'req-b4136f06-c015-4e7e-995f-c43831e3ecce', 'vary': "
- "'X-OpenStack-Nova-API-Version', 'connection': 'close', "
- "'x-openstack-nova-api-version': '2.1', 'date': "
- "'Tue, 02 Feb 2016 03:27:00 GMT', 'content-type': "
- "'application/json'}",
- 'service': 'Nova',
- 'status_code': '200',
- 'url': 'v2.1/<id>/os-agents',
- 'verb': 'POST'}, {
- 'name': 'AgentsAdminTestJSON:tearDown',
- 'request_body': 'None',
- 'request_headers': "{'Content-Type': 'application/json', "
- "'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
- 'response_body': '',
- 'response_headers': "{'status': '200', 'content-length': "
- "'0', 'x-compute-request-id': "
- "'req-ee905fd6-a5b5-4da4-8c37-5363cb25bd9d', 'vary': "
- "'X-OpenStack-Nova-API-Version', 'connection': 'close', "
- "'x-openstack-nova-api-version': '2.1', 'date': "
- "'Tue, 02 Feb 2016 03:27:00 GMT', 'content-type': "
- "'application/json'}",
- 'service': 'Nova',
- 'status_code': '200',
- 'url': 'v2.1/<id>/os-agents/1',
- 'verb': 'DELETE'}, {
- 'name': 'AgentsAdminTestJSON:_run_cleanups',
- 'request_body': 'None',
- 'request_headers': "{'Content-Type': 'application/json', "
- "'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
- 'response_headers': "{'status': '200', 'content-length': "
- "'0', 'x-compute-request-id': "
- "'req-e912cac0-63e0-4679-a68a-b6d18ddca074', 'vary': "
- "'X-OpenStack-Nova-API-Version', 'connection': 'close', "
- "'x-openstack-nova-api-version': '2.1', 'date': "
- "'Tue, 02 Feb 2016 03:27:00 GMT', 'content-type': "
- "'application/json'}",
- 'service': 'Nova',
- 'status_code': '200',
- 'url': 'v2.1/<id>/os-agents/2',
- 'verb': 'DELETE'}],
- 'foo': [{
- 'name': 'AgentsAdminTestJSON:setUp',
- 'request_body': '{"agent": {"url": "xxx://xxxx/xxx/xxx", '
- '"hypervisor": "common", "md5hash": '
- '"add6bb58e139be103324d04d82d8f545", "version": "7.0", '
- '"architecture": "tempest-x86_64-948635295", "os": "linux"}}',
- 'request_headers': "{'Content-Type': 'application/json', "
- "'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
- 'response_body': '{"agent": {"url": "xxx://xxxx/xxx/xxx", '
- '"hypervisor": "common", "md5hash": '
- '"add6bb58e139be103324d04d82d8f545", "version": "7.0", '
- '"architecture": "tempest-x86_64-948635295", "os": "linux", '
- '"agent_id": 3}}',
- 'response_headers': "{'status': '200', 'content-length': "
- "'203', 'x-compute-request-id': "
- "'req-ccd2116d-04b1-4ffe-ae32-fb623f68bf1c', 'vary': "
- "'X-OpenStack-Nova-API-Version', 'connection': 'close', "
- "'x-openstack-nova-api-version': '2.1', 'date': "
- "'Tue, 02 Feb 2016 03:27:01 GMT', 'content-type': "
- "'application/json'}",
- 'service': 'Nova',
- 'status_code': '200',
- 'url': 'v2.1/<id>/os-agents',
- 'verb': 'POST'}, {
- 'name': 'AgentsAdminTestJSON:test_delete_agent',
- 'request_body': 'None',
- 'request_headers': "{'Content-Type': 'application/json', "
- "'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
- 'response_body': '',
- 'response_headers': "{'status': '200', 'content-length': "
- "'0', 'x-compute-request-id': "
- "'req-6e7fa28f-ae61-4388-9a78-947c58bc0588', 'vary': "
- "'X-OpenStack-Nova-API-Version', 'connection': 'close', "
- "'x-openstack-nova-api-version': '2.1', 'date': "
- "'Tue, 02 Feb 2016 03:27:01 GMT', 'content-type': "
- "'application/json'}",
- 'service': 'Nova',
- 'status_code': '200',
- 'url': 'v2.1/<id>/os-agents/3',
- 'verb': 'DELETE'}, {
- 'name': 'AgentsAdminTestJSON:test_delete_agent',
- 'request_body': 'None',
- 'request_headers': "{'Content-Type': 'application/json', "
- "'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
- 'response_body': '{"agents": []}',
- 'response_headers': "{'status': '200', 'content-length': "
- "'14', 'content-location': "
- "'http://23.253.76.97:8774/v2.1/"
- "cf6b1933fe5b476fbbabb876f6d1b924/os-agents', "
- "'x-compute-request-id': "
- "'req-e41aa9b4-41a6-4138-ae04-220b768eb644', 'vary': "
- "'X-OpenStack-Nova-API-Version', 'connection': 'close', "
- "'x-openstack-nova-api-version': '2.1', 'date': "
- "'Tue, 02 Feb 2016 03:27:01 GMT', 'content-type': "
- "'application/json'}",
- 'service': 'Nova',
- 'status_code': '200',
- 'url': 'v2.1/<id>/os-agents',
- 'verb': 'GET'}, {
- 'name': 'AgentsAdminTestJSON:tearDown',
- 'request_body': 'None',
- 'request_headers': "{'Content-Type': 'application/json', "
- "'Accept': 'application/json', 'X-Auth-Token': '<omitted>'}",
- 'response_headers': "{'status': '404', 'content-length': "
- "'82', 'x-compute-request-id': "
- "'req-e297aeea-91cf-4f26-b49c-8f46b1b7a926', 'vary': "
- "'X-OpenStack-Nova-API-Version', 'connection': 'close', "
- "'x-openstack-nova-api-version': '2.1', 'date': "
- "'Tue, 02 Feb 2016 03:27:02 GMT', 'content-type': "
- "'application/json; charset=UTF-8'}",
- 'service': 'Nova',
- 'status_code': '404',
- 'url': 'v2.1/<id>/os-agents/3',
- 'verb': 'DELETE'}]}
+ with open(self._subunit_file, 'r') as read_file:
+ parser = subunit_describe_calls.parse(
+ read_file, "pythonlogging", None)
+ self._assert_expect_json(parser.test_logs)
- self.assertEqual(expected_result, parser.test_logs)
+ def test_get_description(self):
+ self.assertEqual(subunit_describe_calls.DESCRIPTION,
+ self.test_object.get_description())
+
+ def test_get_parser_default_min(self):
+ parser = self.test_object.get_parser('NAME')
+ parsed_args = parser.parse_args([])
+ self.assertIsNone(parsed_args.output_file)
+ self.assertIsNone(parsed_args.ports)
+ self.assertFalse(parsed_args.all_stdout)
+ self.assertEqual(parsed_args.subunit, sys.stdin)
+
+ def test_get_parser_default_max(self):
+ temp_dir = tempfile.mkdtemp(prefix="parser")
+ self.addCleanup(shutil.rmtree, temp_dir, ignore_errors=True)
+ outfile_name = os.path.join(temp_dir, 'output.json')
+ open(outfile_name, 'a').close()
+ portfile_name = os.path.join(temp_dir, 'ports.json')
+ open(portfile_name, 'a').close()
+
+ parser = self.test_object.get_parser('NAME')
+ parsed_args = parser.parse_args(["-a", "-o " + outfile_name,
+ "-p " + portfile_name])
+
+ self.assertIsNotNone(parsed_args.output_file)
+ self.assertIsNotNone(parsed_args.ports)
+ self.assertTrue(parsed_args.all_stdout)
+ self.assertEqual(parsed_args.subunit, sys.stdin)
+
+ def test_take_action_min(self):
+ parser = self.test_object.get_parser('NAME')
+ parsed_args = parser.parse_args(["-s" + self._subunit_file],)
+ with patch('sys.stdout', new=StringIO()) as mock_stdout:
+ self.test_object.take_action(parsed_args)
+
+ stdout_data = mock_stdout.getvalue()
+ self._assert_methods_details(stdout_data)
+ self._assert_no_headers_and_bodies(stdout_data)
+
+ def test_take_action_all_stdout(self):
+ parser = self.test_object.get_parser('NAME')
+ parsed_args = parser.parse_args(["-as" + self._subunit_file],)
+ with patch('sys.stdout', new=StringIO()) as mock_stdout:
+ self.test_object.take_action(parsed_args)
+
+ stdout_data = mock_stdout.getvalue()
+ self._assert_methods_details(stdout_data)
+ self._assert_headers_and_bodies(stdout_data)
+
+ def test_take_action_outfile_files(self):
+ temp_file = tempfile.mkstemp()[1]
+ parser = self.test_object.get_parser('NAME')
+ parsed_args = parser.parse_args(
+ ["-as" + self._subunit_file, '-o', temp_file], )
+ with patch('sys.stdout', new=StringIO()) as mock_stdout:
+ self.test_object.take_action(parsed_args)
+ stdout_data = mock_stdout.getvalue()
+ self._assert_cli_message(stdout_data)
+ with open(temp_file, 'r') as file:
+ data = json.loads(file.read())
+ self._assert_expect_json(data)
+
+ def test_take_action_no_items(self):
+ temp_file = tempfile.mkstemp()[1]
+ parser = self.test_object.get_parser('NAME')
+ parsed_args = parser.parse_args(
+ ["-as" + temp_file], )
+ with patch('sys.stdout', new=StringIO()) as mock_stdout:
+ self.test_object.take_action(parsed_args)
+ stdout_data = mock_stdout.getvalue()
+ self._assert_cli_message(stdout_data)
+
+ def test_take_action_exception(self):
+ parser = self.test_object.get_parser('NAME')
+ parsed_args = parser.parse_args(["-s" + self._subunit_file],)
+ with patch('sys.stderr', new=StringIO()) as mock_stderr:
+ with patch('tempest.cmd.subunit_describe_calls.entry_point') \
+ as mock_method:
+ mock_method.side_effect = OSError()
+ self.assertRaises(OSError, self.test_object.take_action,
+ parsed_args)
+ stderr_data = mock_stderr.getvalue()
+
+ self.assertIn("Traceback (most recent call last):", stderr_data)
+ self.assertIn("entry_point(parsed_args)", stderr_data)
diff --git a/tempest/tests/lib/cmd/test_check_uuid.py b/tempest/tests/lib/cmd/test_check_uuid.py
index 130f90a..28ebca1 100644
--- a/tempest/tests/lib/cmd/test_check_uuid.py
+++ b/tempest/tests/lib/cmd/test_check_uuid.py
@@ -11,13 +11,56 @@
# under the License.
import importlib
+import os
+import sys
import tempfile
from unittest import mock
+import fixtures
+
from tempest.lib.cmd import check_uuid
from tempest.tests import base
+class TestCLInterface(base.TestCase):
+ CODE = "import unittest\n" \
+ "class TestClass(unittest.TestCase):\n" \
+ " def test_tests(self):\n" \
+ " pass"
+
+ def create_tests_file(self, directory):
+ with open(directory + "/__init__.py", "w"):
+ pass
+
+ tests_file = directory + "/tests.py"
+ with open(tests_file, "w") as fake_file:
+ fake_file.write(TestCLInterface.CODE)
+
+ return tests_file
+
+ def test_fix_argument_no(self):
+ temp_dir = self.useFixture(fixtures.TempDir(rootdir="."))
+ tests_file = self.create_tests_file(temp_dir.path)
+
+ sys.argv = [sys.argv[0]] + ["--package",
+ os.path.relpath(temp_dir.path)]
+
+ self.assertRaises(SystemExit, check_uuid.run)
+ with open(tests_file, "r") as f:
+ self.assertTrue(TestCLInterface.CODE == f.read())
+
+ def test_fix_argument_yes(self):
+ temp_dir = self.useFixture(fixtures.TempDir(rootdir="."))
+ tests_file = self.create_tests_file(temp_dir.path)
+
+ sys.argv = [sys.argv[0]] + ["--fix", "--package",
+ os.path.relpath(temp_dir.path)]
+
+ check_uuid.run()
+ with open(tests_file, "r") as f:
+ self.assertTrue(TestCLInterface.CODE != f.read())
+
+
class TestSourcePatcher(base.TestCase):
def test_add_patch(self):
patcher = check_uuid.SourcePatcher()
diff --git a/tempest/tests/lib/services/volume/v3/test_backups_client.py b/tempest/tests/lib/services/volume/v3/test_backups_client.py
index 97e1132..ca7918a 100644
--- a/tempest/tests/lib/services/volume/v3/test_backups_client.py
+++ b/tempest/tests/lib/services/volume/v3/test_backups_client.py
@@ -45,6 +45,8 @@
"availability_zone": "az1",
"container": "volumebackups",
"created_at": "2013-04-02T10:35:27.000000",
+ "updated_at": "2013-04-02T10:39:27.000000",
+ "data_timestamp": "2013-04-02T10:35:27.000000",
"description": None,
"fail_reason": None,
"id": "2ef47aee-8844-490c-804d-2a8efe561c65",
@@ -64,7 +66,6 @@
"user_id": "515ba0dd59f84f25a6a084a45d8d93b2",
"size": 1,
"status": "available",
- "updated_at": "2013-04-02T10:35:27.000000",
"volume_id": "e5185058-943a-4cb4-96d9-72c184c337d6",
"is_incremental": True,
"has_dependent_backups": False
diff --git a/tools/generate-tempest-plugins-list.py b/tools/generate-tempest-plugins-list.py
index 530ce5e..618c388 100644
--- a/tools/generate-tempest-plugins-list.py
+++ b/tools/generate-tempest-plugins-list.py
@@ -41,7 +41,7 @@
'x/intel-nfv-ci-tests', # https://review.opendev.org/#/c/634640/
'openstack/networking-generic-switch',
# https://review.opendev.org/#/c/634846/
- 'openstack/networking-l2gw-tempest-plugin',
+ 'x/networking-l2gw-tempest-plugin',
# https://review.opendev.org/#/c/635093/
'openstack/networking-midonet', # https://review.opendev.org/#/c/635096/
'x/networking-plumgrid', # https://review.opendev.org/#/c/635096/