Merge "Don't run lbaas scenario test as smoke test"
diff --git a/HACKING.rst b/HACKING.rst
index 8652971..025bf74 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -12,6 +12,7 @@
- [T104] Scenario tests require a services decorator
- [T105] Unit tests cannot use setUpClass
- [T106] vim configuration should not be kept in source files.
+- [N322] Method's default argument shouldn't be mutable
Test Data/Configuration
-----------------------
diff --git a/REVIEWING.rst b/REVIEWING.rst
new file mode 100644
index 0000000..d6dc83e
--- /dev/null
+++ b/REVIEWING.rst
@@ -0,0 +1,60 @@
+Reviewing Tempest Code
+======================
+
+To start read the `OpenStack Common Review Checklist
+<https://wiki.openstack.org/wiki/ReviewChecklist#Common_Review_Checklist>`_
+
+
+Ensuring code is executed
+-------------------------
+
+For any new or change to a test it has to be verified in the gate. This means
+that the first thing to check with any change is that a gate job actually runs
+it. Tests which aren't executed either because of configuration or skips should
+not be accepted.
+
+
+Unit Tests
+----------
+
+For any change that adds new functionality to either common functionality or an
+out-of-band tool unit tests are required. This is to ensure we don't introduce
+future regressions and to test conditions which we may not hit in the gate runs.
+Tests, and service clients aren't required to have unit tests since they should
+be self verifying by running them in the gate.
+
+
+API Stability
+-------------
+Tests should only be added for a published stable APIs. If a patch contains
+tests for an API which hasn't been marked as stable or for an API that which
+doesn't conform to the `API stability guidelines
+<https://wiki.openstack.org/wiki/Governance/Approved/APIStability>`_ then it
+should not be approved.
+
+
+Reject Copy and Paste Test Code
+------------------------
+When creating new tests that are similar to existing tests it is tempting to
+simply copy the code and make a few modifications. This increases code size and
+the maintenance burden. Such changes should not be approved if it is easy to
+abstract the duplicated code into a function or method.
+
+
+Being explicit
+--------------
+When tests are being added that depend on a configurable feature or extension,
+polling the API to discover that it is enabled should not be done. This will
+just result in bugs being masked because the test can be skipped automatically.
+Instead the config file should be used to determine whether a test should be
+skipped or not. Do not approve changes that depend on an API call to determine
+whether to skip or not.
+
+
+When to approve
+---------------
+ * Every patch needs two +2s before being approved.
+ * Its ok to hold off on an approval until a subject matter expert reviews it
+ * If a patch has already been approved but requires a trivial rebase to merge,
+ you do not have to wait for a second +2, since the patch has already had
+ two +2s.
diff --git a/doc/source/REVIEWING.rst b/doc/source/REVIEWING.rst
new file mode 120000
index 0000000..841e042
--- /dev/null
+++ b/doc/source/REVIEWING.rst
@@ -0,0 +1 @@
+../../REVIEWING.rst
\ No newline at end of file
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 25bc900..d3118ac 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -9,6 +9,7 @@
overview
HACKING
+ REVIEWING
------------
Field Guides
diff --git a/etc/accounts.yaml.sample b/etc/accounts.yaml.sample
index d191769..54fdcad 100644
--- a/etc/accounts.yaml.sample
+++ b/etc/accounts.yaml.sample
@@ -1,3 +1,7 @@
+# The number of accounts required can be estimated as CONCURRENCY x 2
+# Valid fields for credentials are defined in the descendants of
+# auth.Credentials - see KeystoneV[2|3]Credentials.CONF_ATTRIBUTES
+
- username: 'user_1'
tenant_name: 'test_tenant_1'
password: 'test_password'
diff --git a/etc/schemas/compute/admin/flavor_create.json b/etc/schemas/compute/admin/flavor_create.json
deleted file mode 100644
index 0a3e7b3..0000000
--- a/etc/schemas/compute/admin/flavor_create.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "name": "flavor-create",
- "http-method": "POST",
- "admin_client": true,
- "url": "flavors",
- "default_result_code": 400,
- "json-schema": {
- "type": "object",
- "properties": {
- "name": { "type": "string"},
- "ram": { "type": "integer", "minimum": 1},
- "vcpus": { "type": "integer", "minimum": 1},
- "disk": { "type": "integer"},
- "id": { "type": "integer"},
- "swap": { "type": "integer"},
- "rxtx_factor": { "type": "integer"},
- "OS-FLV-EXT-DATA:ephemeral": { "type": "integer"}
- }
- }
-}
diff --git a/etc/schemas/compute/servers/get_console_output.json b/etc/schemas/compute/servers/get_console_output.json
deleted file mode 100644
index 8d974ba..0000000
--- a/etc/schemas/compute/servers/get_console_output.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "name": "get-console-output",
- "http-method": "POST",
- "url": "servers/%s/action",
- "resources": [
- {"name":"server", "expected_result": 404}
- ],
- "json-schema": {
- "type": "object",
- "properties": {
- "os-getConsoleOutput": {
- "type": "object",
- "properties": {
- "length": {
- "type": ["integer", "string"],
- "minimum": 0
- }
- }
- }
- },
- "additionalProperties": false
- }
-}
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 9ace4ea..ef56ab3 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -474,6 +474,10 @@
# attachment? (boolean value)
#interface_attach=true
+# Does the test environment support creating snapshot images
+# of running instances? (boolean value)
+#snapshot=true
+
[dashboard]
@@ -929,8 +933,15 @@
# Directory containing image files (string value)
#img_dir=/opt/stack/new/devstack/files/images/cirros-0.3.1-x86_64-uec
-# QCOW2 image file name (string value)
-#qcow2_img_file=cirros-0.3.1-x86_64-disk.img
+# Image file name (string value)
+# Deprecated group/name - [DEFAULT]/qcow2_img_file
+#img_file=cirros-0.3.1-x86_64-disk.img
+
+# Image disk format (string value)
+#img_disk_format=qcow2
+
+# Image container format (string value)
+#img_container_format=bare
# AMI image file name (string value)
#ami_img_file=cirros-0.3.1-x86_64-blank.img
@@ -999,9 +1010,9 @@
# value)
#trove=false
-# Whether or not Marconi is expected to be available (boolean
+# Whether or not Zaqar is expected to be available (boolean
# value)
-#marconi=false
+#zaqar=false
[stress]
diff --git a/tempest/api/baremetal/admin/test_api_discovery.py b/tempest/api/baremetal/admin/test_api_discovery.py
index 7368b3e..09788f2 100644
--- a/tempest/api/baremetal/admin/test_api_discovery.py
+++ b/tempest/api/baremetal/admin/test_api_discovery.py
@@ -19,10 +19,8 @@
@test.attr(type='smoke')
def test_api_versions(self):
- resp, descr = self.client.get_api_description()
- self.assertEqual('200', resp['status'])
+ _, descr = self.client.get_api_description()
expected_versions = ('v1',)
-
versions = [version['id'] for version in descr['versions']]
for v in expected_versions:
@@ -30,16 +28,13 @@
@test.attr(type='smoke')
def test_default_version(self):
- resp, descr = self.client.get_api_description()
- self.assertEqual('200', resp['status'])
+ _, descr = self.client.get_api_description()
default_version = descr['default_version']
-
self.assertEqual(default_version['id'], 'v1')
@test.attr(type='smoke')
def test_version_1_resources(self):
- resp, descr = self.client.get_version_description(version='v1')
- self.assertEqual('200', resp['status'])
+ _, descr = self.client.get_version_description(version='v1')
expected_resources = ('nodes', 'chassis',
'ports', 'links', 'media_types')
diff --git a/tempest/api/baremetal/admin/test_chassis.py b/tempest/api/baremetal/admin/test_chassis.py
index c306c34..254a969 100644
--- a/tempest/api/baremetal/admin/test_chassis.py
+++ b/tempest/api/baremetal/admin/test_chassis.py
@@ -35,8 +35,7 @@
@test.attr(type='smoke')
def test_create_chassis(self):
descr = data_utils.rand_name('test-chassis-')
- resp, chassis = self.create_chassis(description=descr)
- self.assertEqual('201', resp['status'])
+ _, chassis = self.create_chassis(description=descr)
self.assertEqual(chassis['description'], descr)
@test.attr(type='smoke')
@@ -44,40 +43,35 @@
# Use a unicode string for testing:
# 'We ♡ OpenStack in Ukraine'
descr = u'В Україні ♡ OpenStack!'
- resp, chassis = self.create_chassis(description=descr)
- self.assertEqual('201', resp['status'])
+ _, chassis = self.create_chassis(description=descr)
self.assertEqual(chassis['description'], descr)
@test.attr(type='smoke')
def test_show_chassis(self):
- resp, chassis = self.client.show_chassis(self.chassis['uuid'])
- self.assertEqual('200', resp['status'])
+ _, chassis = self.client.show_chassis(self.chassis['uuid'])
self._assertExpected(self.chassis, chassis)
@test.attr(type="smoke")
def test_list_chassis(self):
- resp, body = self.client.list_chassis()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_chassis()
self.assertIn(self.chassis['uuid'],
[i['uuid'] for i in body['chassis']])
@test.attr(type='smoke')
def test_delete_chassis(self):
- resp, body = self.create_chassis()
+ _, body = self.create_chassis()
uuid = body['uuid']
- resp = self.delete_chassis(uuid)
- self.assertEqual('204', resp['status'])
+ self.delete_chassis(uuid)
self.assertRaises(exc.NotFound, self.client.show_chassis, uuid)
@test.attr(type='smoke')
def test_update_chassis(self):
- resp, body = self.create_chassis()
+ _, body = self.create_chassis()
uuid = body['uuid']
new_description = data_utils.rand_name('new-description-')
- resp, body = (self.client.update_chassis(uuid,
- description=new_description))
- self.assertEqual('200', resp['status'])
- resp, chassis = self.client.show_chassis(uuid)
+ _, body = (self.client.update_chassis(uuid,
+ description=new_description))
+ _, chassis = self.client.show_chassis(uuid)
self.assertEqual(chassis['description'], new_description)
diff --git a/tempest/api/baremetal/admin/test_drivers.py b/tempest/api/baremetal/admin/test_drivers.py
index 649886b..9e215dc 100644
--- a/tempest/api/baremetal/admin/test_drivers.py
+++ b/tempest/api/baremetal/admin/test_drivers.py
@@ -29,13 +29,11 @@
@test.attr(type="smoke")
def test_list_drivers(self):
- resp, drivers = self.client.list_drivers()
- self.assertEqual('200', resp['status'])
+ _, drivers = self.client.list_drivers()
self.assertIn(self.driver_name,
[d['name'] for d in drivers['drivers']])
@test.attr(type="smoke")
def test_show_driver(self):
- resp, driver = self.client.show_driver(self.driver_name)
- self.assertEqual('200', resp['status'])
+ _, driver = self.client.show_driver(self.driver_name)
self.assertEqual(self.driver_name, driver['name'])
diff --git a/tempest/api/baremetal/admin/test_nodes.py b/tempest/api/baremetal/admin/test_nodes.py
index fc67854..ab6aed3 100644
--- a/tempest/api/baremetal/admin/test_nodes.py
+++ b/tempest/api/baremetal/admin/test_nodes.py
@@ -40,30 +40,25 @@
'storage': '10240',
'memory': '1024'}
- resp, body = self.create_node(self.chassis['uuid'], **params)
- self.assertEqual('201', resp['status'])
+ _, body = self.create_node(self.chassis['uuid'], **params)
self._assertExpected(params, body['properties'])
@test.attr(type='smoke')
def test_delete_node(self):
- resp, node = self.create_node(self.chassis['uuid'])
- self.assertEqual('201', resp['status'])
+ _, node = self.create_node(self.chassis['uuid'])
- resp = self.delete_node(node['uuid'])
+ self.delete_node(node['uuid'])
- self.assertEqual(resp['status'], '204')
self.assertRaises(exc.NotFound, self.client.show_node, node['uuid'])
@test.attr(type='smoke')
def test_show_node(self):
- resp, loaded_node = self.client.show_node(self.node['uuid'])
- self.assertEqual('200', resp['status'])
+ _, loaded_node = self.client.show_node(self.node['uuid'])
self._assertExpected(self.node, loaded_node)
@test.attr(type='smoke')
def test_list_nodes(self):
- resp, body = self.client.list_nodes()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_nodes()
self.assertIn(self.node['uuid'],
[i['uuid'] for i in body['nodes']])
@@ -74,24 +69,40 @@
'storage': '10',
'memory': '128'}
- resp, node = self.create_node(self.chassis['uuid'], **props)
- self.assertEqual('201', resp['status'])
+ _, node = self.create_node(self.chassis['uuid'], **props)
new_p = {'cpu_arch': 'x86',
'cpu_num': '1',
'storage': '10000',
'memory': '12300'}
- resp, body = self.client.update_node(node['uuid'], properties=new_p)
- self.assertEqual('200', resp['status'])
- resp, node = self.client.show_node(node['uuid'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.update_node(node['uuid'], properties=new_p)
+ _, node = self.client.show_node(node['uuid'])
self._assertExpected(new_p, node['properties'])
@test.attr(type='smoke')
def test_validate_driver_interface(self):
- resp, body = self.client.validate_driver_interface(self.node['uuid'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.validate_driver_interface(self.node['uuid'])
core_interfaces = ['power', 'deploy']
for interface in core_interfaces:
self.assertIn(interface, body)
+
+ @test.attr(type='smoke')
+ def test_set_node_boot_device(self):
+ body = self.client.set_node_boot_device(self.node['uuid'], 'pxe')
+ # No content
+ self.assertEqual('', body)
+
+ @test.attr(type='smoke')
+ def test_get_node_boot_device(self):
+ body = self.client.get_node_boot_device(self.node['uuid'])
+ self.assertIn('boot_device', body)
+ self.assertIn('persistent', body)
+ self.assertTrue(isinstance(body['boot_device'], six.string_types))
+ self.assertTrue(isinstance(body['persistent'], bool))
+
+ @test.attr(type='smoke')
+ def test_get_node_supported_boot_devices(self):
+ body = self.client.get_node_supported_boot_devices(self.node['uuid'])
+ self.assertIn('supported_boot_devices', body)
+ self.assertTrue(isinstance(body['supported_boot_devices'], list))
diff --git a/tempest/api/baremetal/admin/test_nodestates.py b/tempest/api/baremetal/admin/test_nodestates.py
index f24f490..76f47f9 100644
--- a/tempest/api/baremetal/admin/test_nodestates.py
+++ b/tempest/api/baremetal/admin/test_nodestates.py
@@ -24,8 +24,8 @@
@classmethod
def setUpClass(cls):
super(TestNodeStates, cls).setUpClass()
- resp, cls.chassis = cls.create_chassis()
- resp, cls.node = cls.create_node(cls.chassis['uuid'])
+ _, cls.chassis = cls.create_chassis()
+ _, cls.node = cls.create_node(cls.chassis['uuid'])
def _validate_power_state(self, node_uuid, power_state):
# Validate that power state is set within timeout
@@ -34,8 +34,7 @@
start = timeutils.utcnow()
while timeutils.delta_seconds(
start, timeutils.utcnow()) < self.power_timeout:
- resp, node = self.client.show_node(node_uuid)
- self.assertEqual(200, resp.status)
+ _, node = self.client.show_node(node_uuid)
if node['power_state'] == power_state:
return
message = ('Failed to set power state within '
@@ -44,20 +43,16 @@
@test.attr(type='smoke')
def test_list_nodestates(self):
- resp, nodestates = self.client.list_nodestates(self.node['uuid'])
- self.assertEqual('200', resp['status'])
+ _, nodestates = self.client.list_nodestates(self.node['uuid'])
for key in nodestates:
self.assertEqual(nodestates[key], self.node[key])
@test.attr(type='smoke')
def test_set_node_power_state(self):
- resp, node = self.create_node(self.chassis['uuid'])
- self.assertEqual('201', resp['status'])
+ _, node = self.create_node(self.chassis['uuid'])
states = ["power on", "rebooting", "power off"]
for state in states:
# Set power state
- resp, _ = self.client.set_node_power_state(node['uuid'],
- state)
- self.assertEqual('202', resp['status'])
+ self.client.set_node_power_state(node['uuid'], state)
# Check power state after state is set
self._validate_power_state(node['uuid'], state)
diff --git a/tempest/api/baremetal/admin/test_ports.py b/tempest/api/baremetal/admin/test_ports.py
index d4adba9..b3f9b7f 100644
--- a/tempest/api/baremetal/admin/test_ports.py
+++ b/tempest/api/baremetal/admin/test_ports.py
@@ -39,12 +39,10 @@
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- resp, port = self.create_port(node_id=node_id, address=address)
- self.assertEqual(201, resp.status)
+ _, port = self.create_port(node_id=node_id, address=address)
- resp, body = self.client.show_port(port['uuid'])
+ _, body = self.client.show_port(port['uuid'])
- self.assertEqual(200, resp.status)
self._assertExpected(port, body)
@test.attr(type='smoke')
@@ -53,12 +51,10 @@
address = data_utils.rand_mac_address()
uuid = data_utils.rand_uuid()
- resp, port = self.create_port(node_id=node_id,
- address=address, uuid=uuid)
- self.assertEqual(201, resp.status)
+ _, port = self.create_port(node_id=node_id,
+ address=address, uuid=uuid)
- resp, body = self.client.show_port(uuid)
- self.assertEqual(200, resp.status)
+ _, body = self.client.show_port(uuid)
self._assertExpected(port, body)
@test.attr(type='smoke')
@@ -67,44 +63,37 @@
address = data_utils.rand_mac_address()
extra = {'key': 'value'}
- resp, port = self.create_port(node_id=node_id, address=address,
- extra=extra)
- self.assertEqual(201, resp.status)
+ _, port = self.create_port(node_id=node_id, address=address,
+ extra=extra)
- resp, body = self.client.show_port(port['uuid'])
- self.assertEqual(200, resp.status)
+ _, body = self.client.show_port(port['uuid'])
self._assertExpected(port, body)
@test.attr(type='smoke')
def test_delete_port(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- resp, port = self.create_port(node_id=node_id, address=address)
- self.assertEqual(201, resp.status)
+ _, port = self.create_port(node_id=node_id, address=address)
- resp = self.delete_port(port['uuid'])
+ self.delete_port(port['uuid'])
- self.assertEqual(204, resp.status)
self.assertRaises(exc.NotFound, self.client.show_port, port['uuid'])
@test.attr(type='smoke')
def test_show_port(self):
- resp, port = self.client.show_port(self.port['uuid'])
- self.assertEqual(200, resp.status)
+ _, port = self.client.show_port(self.port['uuid'])
self._assertExpected(self.port, port)
@test.attr(type='smoke')
def test_show_port_with_links(self):
- resp, port = self.client.show_port(self.port['uuid'])
- self.assertEqual(200, resp.status)
+ _, port = self.client.show_port(self.port['uuid'])
self.assertIn('links', port.keys())
self.assertEqual(2, len(port['links']))
self.assertIn(port['uuid'], port['links'][0]['href'])
@test.attr(type='smoke')
def test_list_ports(self):
- resp, body = self.client.list_ports()
- self.assertEqual(200, resp.status)
+ _, body = self.client.list_ports()
self.assertIn(self.port['uuid'],
[i['uuid'] for i in body['ports']])
# Verify self links.
@@ -114,8 +103,7 @@
@test.attr(type='smoke')
def test_list_with_limit(self):
- resp, body = self.client.list_ports(limit=3)
- self.assertEqual(200, resp.status)
+ _, body = self.client.list_ports(limit=3)
next_marker = body['ports'][-1]['uuid']
self.assertIn(next_marker, body['next'])
@@ -128,8 +116,7 @@
address=data_utils.rand_mac_address())
[1]['uuid'] for i in range(0, 5)]
- resp, body = self.client.list_ports_detail()
- self.assertEqual(200, resp.status)
+ _, body = self.client.list_ports_detail()
ports_dict = dict((port['uuid'], port) for port in body['ports']
if port['uuid'] in uuids)
@@ -153,8 +140,7 @@
self.create_port(node_id=node_id,
address=data_utils.rand_mac_address())
- resp, body = self.client.list_ports_detail(address=address)
- self.assertEqual(200, resp.status)
+ _, body = self.client.list_ports_detail(address=address)
self.assertEqual(1, len(body['ports']))
self.assertEqual(address, body['ports'][0]['address'])
@@ -164,9 +150,8 @@
address = data_utils.rand_mac_address()
extra = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}
- resp, port = self.create_port(node_id=node_id, address=address,
- extra=extra)
- self.assertEqual(201, resp.status)
+ _, port = self.create_port(node_id=node_id, address=address,
+ extra=extra)
new_address = data_utils.rand_mac_address()
new_extra = {'key1': 'new-value1', 'key2': 'new-value2',
@@ -185,11 +170,9 @@
'op': 'replace',
'value': new_extra['key3']}]
- resp, _ = self.client.update_port(port['uuid'], patch)
- self.assertEqual(200, resp.status)
+ self.client.update_port(port['uuid'], patch)
- resp, body = self.client.show_port(port['uuid'])
- self.assertEqual(200, resp.status)
+ _, body = self.client.show_port(port['uuid'])
self.assertEqual(new_address, body['address'])
self.assertEqual(new_extra, body['extra'])
@@ -199,26 +182,21 @@
address = data_utils.rand_mac_address()
extra = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}
- resp, port = self.create_port(node_id=node_id, address=address,
- extra=extra)
- self.assertEqual(201, resp.status)
+ _, port = self.create_port(node_id=node_id, address=address,
+ extra=extra)
# Removing one item from the collection
- resp, _ = self.client.update_port(port['uuid'],
- [{'path': '/extra/key2',
- 'op': 'remove'}])
- self.assertEqual(200, resp.status)
+ self.client.update_port(port['uuid'],
+ [{'path': '/extra/key2',
+ 'op': 'remove'}])
extra.pop('key2')
- resp, body = self.client.show_port(port['uuid'])
- self.assertEqual(200, resp.status)
+ _, body = self.client.show_port(port['uuid'])
self.assertEqual(extra, body['extra'])
# Removing the collection
- resp, _ = self.client.update_port(port['uuid'], [{'path': '/extra',
- 'op': 'remove'}])
- self.assertEqual(200, resp.status)
- resp, body = self.client.show_port(port['uuid'])
- self.assertEqual(200, resp.status)
+ self.client.update_port(port['uuid'], [{'path': '/extra',
+ 'op': 'remove'}])
+ _, body = self.client.show_port(port['uuid'])
self.assertEqual({}, body['extra'])
# Assert nothing else was changed
@@ -230,8 +208,7 @@
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- resp, port = self.create_port(node_id=node_id, address=address)
- self.assertEqual(201, resp.status)
+ _, port = self.create_port(node_id=node_id, address=address)
extra = {'key1': 'value1', 'key2': 'value2'}
@@ -242,11 +219,9 @@
'op': 'add',
'value': extra['key2']}]
- resp, _ = self.client.update_port(port['uuid'], patch)
- self.assertEqual(200, resp.status)
+ self.client.update_port(port['uuid'], patch)
- resp, body = self.client.show_port(port['uuid'])
- self.assertEqual(200, resp.status)
+ _, body = self.client.show_port(port['uuid'])
self.assertEqual(extra, body['extra'])
@test.attr(type='smoke')
@@ -255,9 +230,8 @@
address = data_utils.rand_mac_address()
extra = {'key1': 'value1', 'key2': 'value2'}
- resp, port = self.create_port(node_id=node_id, address=address,
- extra=extra)
- self.assertEqual(201, resp.status)
+ _, port = self.create_port(node_id=node_id, address=address,
+ extra=extra)
new_address = data_utils.rand_mac_address()
new_extra = {'key1': 'new-value1', 'key3': 'new-value3'}
@@ -274,10 +248,8 @@
'op': 'add',
'value': new_extra['key3']}]
- resp, _ = self.client.update_port(port['uuid'], patch)
- self.assertEqual(200, resp.status)
+ self.client.update_port(port['uuid'], patch)
- resp, body = self.client.show_port(port['uuid'])
- self.assertEqual(200, resp.status)
+ _, body = self.client.show_port(port['uuid'])
self.assertEqual(new_address, body['address'])
self.assertEqual(new_extra, body['extra'])
diff --git a/tempest/api/baremetal/admin/test_ports_negative.py b/tempest/api/baremetal/admin/test_ports_negative.py
index 7646677..ead3799 100644
--- a/tempest/api/baremetal/admin/test_ports_negative.py
+++ b/tempest/api/baremetal/admin/test_ports_negative.py
@@ -22,11 +22,8 @@
def setUp(self):
super(TestPortsNegative, self).setUp()
- resp, self.chassis = self.create_chassis()
- self.assertEqual('201', resp['status'])
-
- resp, self.node = self.create_node(self.chassis['uuid'])
- self.assertEqual('201', resp['status'])
+ _, self.chassis = self.create_chassis()
+ _, self.node = self.create_node(self.chassis['uuid'])
@test.attr(type=['negative', 'smoke'])
def test_create_port_malformed_mac(self):
@@ -137,13 +134,11 @@
address = data_utils.rand_mac_address()
extra = {'key': 'value'}
- resp, port = self.create_port(node_id=node_id, address=address,
- extra=extra)
- self.assertEqual('201', resp['status'])
+ _, port = self.create_port(node_id=node_id, address=address,
+ extra=extra)
port_id = port['uuid']
- resp, body = self.client.delete_port(port_id)
- self.assertEqual('204', resp['status'])
+ _, body = self.client.delete_port(port_id)
patch = [{'path': '/extra/key',
'op': 'replace',
@@ -169,8 +164,7 @@
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- resp, port = self.create_port(node_id=node_id, address=address)
- self.assertEqual('201', resp['status'])
+ _, port = self.create_port(node_id=node_id, address=address)
port_id = port['uuid']
self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
@@ -182,8 +176,7 @@
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- resp, port = self.create_port(node_id=node_id, address=address)
- self.assertEqual('201', resp['status'])
+ _, port = self.create_port(node_id=node_id, address=address)
port_id = port['uuid']
self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
@@ -196,8 +189,7 @@
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- resp, port = self.create_port(node_id=node_id, address=address)
- self.assertEqual('201', resp['status'])
+ _, port = self.create_port(node_id=node_id, address=address)
port_id = port['uuid']
self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
@@ -209,8 +201,7 @@
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- resp, port = self.create_port(node_id=node_id, address=address)
- self.assertEqual('201', resp['status'])
+ _, port = self.create_port(node_id=node_id, address=address)
port_id = port['uuid']
patch = [{'path': '/node_uuid',
@@ -225,11 +216,9 @@
address1 = data_utils.rand_mac_address()
address2 = data_utils.rand_mac_address()
- resp, port1 = self.create_port(node_id=node_id, address=address1)
- self.assertEqual('201', resp['status'])
+ _, port1 = self.create_port(node_id=node_id, address=address1)
- resp, port2 = self.create_port(node_id=node_id, address=address2)
- self.assertEqual('201', resp['status'])
+ _, port2 = self.create_port(node_id=node_id, address=address2)
port_id = port2['uuid']
patch = [{'path': '/address',
@@ -243,8 +232,7 @@
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- resp, port = self.create_port(node_id=node_id, address=address)
- self.assertEqual('201', resp['status'])
+ _, port = self.create_port(node_id=node_id, address=address)
port_id = port['uuid']
patch = [{'path': '/node_uuid',
@@ -258,8 +246,7 @@
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- resp, port = self.create_port(node_id=node_id, address=address)
- self.assertEqual('201', resp['status'])
+ _, port = self.create_port(node_id=node_id, address=address)
port_id = port['uuid']
patch = [{'path': '/address',
@@ -275,9 +262,8 @@
address = data_utils.rand_mac_address()
extra = {'key': 'value'}
- resp, port = self.create_port(node_id=node_id, address=address,
- extra=extra)
- self.assertEqual('201', resp['status'])
+ _, port = self.create_port(node_id=node_id, address=address,
+ extra=extra)
port_id = port['uuid']
patch = [{'path': '/extra/key',
@@ -291,8 +277,7 @@
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- resp, port = self.create_port(node_id=node_id, address=address)
- self.assertEqual('201', resp['status'])
+ _, port = self.create_port(node_id=node_id, address=address)
port_id = port['uuid']
patch = [{'path': '/extra',
@@ -307,8 +292,7 @@
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- resp, port = self.create_port(node_id=node_id, address=address)
- self.assertEqual('201', resp['status'])
+ _, port = self.create_port(node_id=node_id, address=address)
port_id = port['uuid']
patch = [{'path': '/nonexistent', ' op': 'replace', 'value': 'value'}]
@@ -321,8 +305,7 @@
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- resp, port = self.create_port(node_id=node_id, address=address)
- self.assertEqual('201', resp['status'])
+ _, port = self.create_port(node_id=node_id, address=address)
port_id = port['uuid']
self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
@@ -333,8 +316,7 @@
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- resp, port = self.create_port(node_id=node_id, address=address)
- self.assertEqual('201', resp['status'])
+ _, port = self.create_port(node_id=node_id, address=address)
port_id = port['uuid']
self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
@@ -345,8 +327,7 @@
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- resp, port = self.create_port(node_id=node_id, address=address)
- self.assertEqual('201', resp['status'])
+ _, port = self.create_port(node_id=node_id, address=address)
port_id = port['uuid']
self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
@@ -366,9 +347,8 @@
address = data_utils.rand_mac_address()
extra = {'key1': 'value1', 'key2': 'value2'}
- resp, port = self.create_port(node_id=node_id, address=address,
- extra=extra)
- self.assertEqual('201', resp['status'])
+ _, port = self.create_port(node_id=node_id, address=address,
+ extra=extra)
port_id = port['uuid']
new_address = data_utils.rand_mac_address()
@@ -393,7 +373,6 @@
patch)
# patch should not be applied
- resp, body = self.client.show_port(port_id)
- self.assertEqual(200, resp.status)
+ _, body = self.client.show_port(port_id)
self.assertEqual(address, body['address'])
self.assertEqual(extra, body['extra'])
diff --git a/tempest/api/compute/admin/test_flavors_negative.py b/tempest/api/compute/admin/test_flavors_negative.py
index 9e4412f..eece096 100644
--- a/tempest/api/compute/admin/test_flavors_negative.py
+++ b/tempest/api/compute/admin/test_flavors_negative.py
@@ -16,6 +16,7 @@
import uuid
from tempest.api.compute import base
+from tempest.api_schema.request.compute.v2 import flavors
from tempest.common.utils import data_utils
from tempest import exceptions
from tempest import test
@@ -106,4 +107,4 @@
test.NegativeAutoTest):
_interface = 'json'
_service = 'compute'
- _schema_file = 'compute/admin/flavor_create.json'
+ _schema = flavors.flavor_create
diff --git a/tempest/api/compute/admin/test_networks.py b/tempest/api/compute/admin/test_networks.py
new file mode 100644
index 0000000..032e2f5
--- /dev/null
+++ b/tempest/api/compute/admin/test_networks.py
@@ -0,0 +1,52 @@
+# Copyright 2014 Hewlett-Packard Development Company, L.P.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.compute import base
+from tempest import config
+
+CONF = config.CONF
+
+
+class NetworksTest(base.BaseComputeAdminTest):
+ _api_version = 2
+
+ """
+ Tests Nova Networks API that usually requires admin privileges.
+ API docs:
+ http://developer.openstack.org/api-ref-compute-v2-ext.html#ext-os-networks
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(NetworksTest, cls).setUpClass()
+ cls.client = cls.os_adm.networks_client
+
+ def test_get_network(self):
+ resp, networks = self.client.list_networks()
+ configured_network = [x for x in networks if x['label'] ==
+ CONF.compute.fixed_network_name]
+ self.assertEqual(1, len(configured_network),
+ "{0} networks with label {1}".format(
+ len(configured_network),
+ CONF.compute.fixed_network_name))
+ configured_network = configured_network[0]
+ _, network = self.client.get_network(configured_network['id'])
+ self.assertEqual(configured_network['label'], network['label'])
+
+ def test_list_all_networks(self):
+ _, networks = self.client.list_networks()
+ # Check the configured network is in the list
+ configured_network = CONF.compute.fixed_network_name
+ self.assertIn(configured_network, [x['label'] for x in networks])
diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py
index 599b058..4afda03 100644
--- a/tempest/api/compute/admin/test_quotas_negative.py
+++ b/tempest/api/compute/admin/test_quotas_negative.py
@@ -94,6 +94,7 @@
@test.skip_because(bug="1186354",
condition=CONF.service_available.neutron)
@test.attr(type='gate')
+ @test.services('network')
def test_security_groups_exceed_limit(self):
# Negative test: Creation Security Groups over limit should FAIL
@@ -120,6 +121,7 @@
@test.skip_because(bug="1186354",
condition=CONF.service_available.neutron)
@test.attr(type=['negative', 'gate'])
+ @test.services('network')
def test_security_groups_rules_exceed_limit(self):
# Negative test: Creation of Security Group Rules should FAIL
# when we reach limit maxSecurityGroupRules
diff --git a/tempest/api/compute/admin/test_security_group_default_rules.py b/tempest/api/compute/admin/test_security_group_default_rules.py
index 07408a8..a07d270 100644
--- a/tempest/api/compute/admin/test_security_group_default_rules.py
+++ b/tempest/api/compute/admin/test_security_group_default_rules.py
@@ -55,7 +55,7 @@
@test.attr(type='smoke')
def test_create_delete_security_group_default_rules(self):
# Create and delete Security Group default rule
- ip_protocols = {'tcp', 'udp', 'icmp'}
+ ip_protocols = ['tcp', 'udp', 'icmp']
for ip_protocol in ip_protocols:
rule = self._create_security_group_default_rules(ip_protocol)
# Delete Security Group default rule
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 343a39a..47d1254 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -271,10 +271,10 @@
return resp, body
@classmethod
- def create_test_server_group(cls, name="", policy=[]):
+ def create_test_server_group(cls, name="", policy=None):
if not name:
name = data_utils.rand_name(cls.__name__ + "-Server-Group")
- if not policy:
+ if policy is None:
policy = ['affinity']
resp, body = cls.servers_client.create_server_group(name, policy)
cls.server_groups.append(body['id'])
diff --git a/tempest/api/compute/images/test_images.py b/tempest/api/compute/images/test_images.py
index 29df2b0..bbb887f 100644
--- a/tempest/api/compute/images/test_images.py
+++ b/tempest/api/compute/images/test_images.py
@@ -28,6 +28,12 @@
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
+
+ if not CONF.compute_feature_enabled.snapshot:
+ skip_msg = ("%s skipped as instance snapshotting is not supported"
+ % cls.__name__)
+ raise cls.skipException(skip_msg)
+
cls.client = cls.images_client
cls.servers_client = cls.servers_client
diff --git a/tempest/api/compute/images/test_images_negative.py b/tempest/api/compute/images/test_images_negative.py
index 6163f4d..771040b 100644
--- a/tempest/api/compute/images/test_images_negative.py
+++ b/tempest/api/compute/images/test_images_negative.py
@@ -29,6 +29,12 @@
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
+
+ if not CONF.compute_feature_enabled.snapshot:
+ skip_msg = ("%s skipped as instance snapshotting is not supported"
+ % cls.__name__)
+ raise cls.skipException(skip_msg)
+
cls.client = cls.images_client
cls.servers_client = cls.servers_client
diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index c81cec5..1c5d4a3 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -47,6 +47,7 @@
self.__class__.server_id = self.rebuild_server(self.server_id)
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(ImagesOneServerTestJSON, cls).setUpClass()
cls.client = cls.images_client
@@ -54,12 +55,13 @@
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
- try:
- resp, server = cls.create_test_server(wait_until='ACTIVE')
- cls.server_id = server['id']
- except Exception:
- cls.tearDownClass()
- raise
+ if not CONF.compute_feature_enabled.snapshot:
+ skip_msg = ("%s skipped as instance snapshotting is not supported"
+ % cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ resp, server = cls.create_test_server(wait_until='ACTIVE')
+ cls.server_id = server['id']
def _get_default_flavor_disk_size(self, flavor_id):
resp, flavor = self.flavors_client.get_flavor_details(flavor_id)
diff --git a/tempest/api/compute/images/test_images_oneserver_negative.py b/tempest/api/compute/images/test_images_oneserver_negative.py
index 9c4ab00..51d9b85 100644
--- a/tempest/api/compute/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/images/test_images_oneserver_negative.py
@@ -55,6 +55,7 @@
self.__class__.server_id = self.rebuild_server(self.server_id)
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(ImagesOneServerNegativeTestJSON, cls).setUpClass()
cls.client = cls.images_client
@@ -62,12 +63,13 @@
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
- try:
- resp, server = cls.create_test_server(wait_until='ACTIVE')
- cls.server_id = server['id']
- except Exception:
- cls.tearDownClass()
- raise
+ if not CONF.compute_feature_enabled.snapshot:
+ skip_msg = ("%s skipped as instance snapshotting is not supported"
+ % cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ resp, server = cls.create_test_server(wait_until='ACTIVE')
+ cls.server_id = server['id']
cls.image_ids = []
diff --git a/tempest/api/compute/images/test_list_image_filters.py b/tempest/api/compute/images/test_list_image_filters.py
index f9350e1..9f1cfc8 100644
--- a/tempest/api/compute/images/test_list_image_filters.py
+++ b/tempest/api/compute/images/test_list_image_filters.py
@@ -16,6 +16,8 @@
import StringIO
import time
+import testtools
+
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import config
@@ -30,6 +32,7 @@
class ListImageFiltersTestJSON(base.BaseV2ComputeTest):
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(ListImageFiltersTestJSON, cls).setUpClass()
if not CONF.service_available.glance:
@@ -63,34 +66,32 @@
cls.image3 = _create_image()
cls.image3_id = cls.image3['id']
+ if not CONF.compute_feature_enabled.snapshot:
+ return
+
# Create instances and snapshots via nova
- try:
- resp, cls.server1 = cls.create_test_server()
- resp, cls.server2 = cls.create_test_server(wait_until='ACTIVE')
- # NOTE(sdague) this is faster than doing the sync wait_util on both
- cls.servers_client.wait_for_server_status(cls.server1['id'],
- 'ACTIVE')
+ resp, cls.server1 = cls.create_test_server()
+ resp, cls.server2 = cls.create_test_server(wait_until='ACTIVE')
+ # NOTE(sdague) this is faster than doing the sync wait_util on both
+ cls.servers_client.wait_for_server_status(cls.server1['id'],
+ 'ACTIVE')
- # Create images to be used in the filter tests
- resp, cls.snapshot1 = cls.create_image_from_server(
- cls.server1['id'], wait_until='ACTIVE')
- cls.snapshot1_id = cls.snapshot1['id']
+ # Create images to be used in the filter tests
+ resp, cls.snapshot1 = cls.create_image_from_server(
+ cls.server1['id'], wait_until='ACTIVE')
+ cls.snapshot1_id = cls.snapshot1['id']
- # Servers have a hidden property for when they are being imaged
- # Performing back-to-back create image calls on a single
- # server will sometimes cause failures
- resp, cls.snapshot3 = cls.create_image_from_server(
- cls.server2['id'], wait_until='ACTIVE')
- cls.snapshot3_id = cls.snapshot3['id']
+ # Servers have a hidden property for when they are being imaged
+ # Performing back-to-back create image calls on a single
+ # server will sometimes cause failures
+ resp, cls.snapshot3 = cls.create_image_from_server(
+ cls.server2['id'], wait_until='ACTIVE')
+ cls.snapshot3_id = cls.snapshot3['id']
- # Wait for the server to be active after the image upload
- resp, cls.snapshot2 = cls.create_image_from_server(
- cls.server1['id'], wait_until='ACTIVE')
- cls.snapshot2_id = cls.snapshot2['id']
- except Exception:
- LOG.exception('setUpClass failed')
- cls.tearDownClass()
- raise
+ # Wait for the server to be active after the image upload
+ resp, cls.snapshot2 = cls.create_image_from_server(
+ cls.server1['id'], wait_until='ACTIVE')
+ cls.snapshot2_id = cls.snapshot2['id']
@test.attr(type='gate')
def test_list_images_filter_by_status(self):
@@ -114,6 +115,8 @@
self.assertFalse(any([i for i in images if i['id'] == self.image2_id]))
self.assertFalse(any([i for i in images if i['id'] == self.image3_id]))
+ @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
+ 'Snapshotting is not available.')
@test.attr(type='gate')
def test_list_images_filter_by_server_id(self):
# The images should contain images filtered by server id
@@ -129,6 +132,8 @@
self.assertFalse(any([i for i in images
if i['id'] == self.snapshot3_id]))
+ @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
+ 'Snapshotting is not available.')
@test.attr(type='gate')
def test_list_images_filter_by_server_ref(self):
# The list of servers should be filtered by server ref
@@ -146,6 +151,8 @@
self.assertTrue(any([i for i in images
if i['id'] == self.snapshot3_id]))
+ @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
+ 'Snapshotting is not available.')
@test.attr(type='gate')
def test_list_images_filter_by_type(self):
# The list of servers should be filtered by image type
@@ -211,6 +218,8 @@
resp, images = self.client.list_images_with_detail(params)
self.assertEqual(1, len(images))
+ @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
+ 'Snapshotting is not available.')
@test.attr(type='gate')
def test_list_images_with_detail_filter_by_server_ref(self):
# Detailed list of servers should be filtered by server ref
@@ -228,6 +237,8 @@
self.assertTrue(any([i for i in images
if i['id'] == self.snapshot3_id]))
+ @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
+ 'Snapshotting is not available.')
@test.attr(type='gate')
def test_list_images_with_detail_filter_by_type(self):
# The detailed list of servers should be filtered by image type
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 005f38a..fd6df3e 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -256,7 +256,10 @@
resp, server = self.client.get_server(self.server_id)
self.assertEqual(previous_flavor_ref, server['flavor']['id'])
+ @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
+ 'Snapshotting not available, backup not possible.')
@test.attr(type='gate')
+ @test.services('image')
def test_create_backup(self):
# Positive test:create backup successfully and rotate backups correctly
# create the first and the second backup
diff --git a/tempest/api/compute/servers/test_server_rescue.py b/tempest/api/compute/servers/test_server_rescue.py
index ab98d88..b737888 100644
--- a/tempest/api/compute/servers/test_server_rescue.py
+++ b/tempest/api/compute/servers/test_server_rescue.py
@@ -54,7 +54,6 @@
# Server for positive tests
resp, server = cls.create_test_server(wait_until='BUILD')
- resp, resc_server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
cls.password = server['adminPass']
cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE')
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index 792b523..b9ec29e 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -404,13 +404,6 @@
nonexistent_server)
@test.attr(type=['negative', 'gate'])
- def test_force_delete_server_invalid_state(self):
- # we can only force-delete a server in 'soft-delete' state
- self.assertRaises(exceptions.Conflict,
- self.client.force_delete_server,
- self.server_id)
-
- @test.attr(type=['negative', 'gate'])
def test_restore_nonexistent_server_id(self):
# restore-delete a non existent server
nonexistent_server = data_utils.rand_uuid()
diff --git a/tempest/api/compute/servers/test_servers_negative_new.py b/tempest/api/compute/servers/test_servers_negative_new.py
index 43ddb3a..c5f9fdd 100644
--- a/tempest/api/compute/servers/test_servers_negative_new.py
+++ b/tempest/api/compute/servers/test_servers_negative_new.py
@@ -15,6 +15,7 @@
from tempest.api.compute import base
+from tempest.api_schema.request.compute.v2 import servers
from tempest import test
@@ -25,7 +26,7 @@
class GetConsoleOutputNegativeTestJSON(base.BaseV2ComputeTest,
test.NegativeAutoTest):
_service = 'compute'
- _schema_file = 'compute/servers/get_console_output.json'
+ _schema = servers.get_console_output
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/v3/images/test_images_oneserver.py b/tempest/api/compute/v3/images/test_images_oneserver.py
index 795437b..edf91a7 100644
--- a/tempest/api/compute/v3/images/test_images_oneserver.py
+++ b/tempest/api/compute/v3/images/test_images_oneserver.py
@@ -47,6 +47,7 @@
super(ImagesOneServerV3Test, self).tearDown()
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(ImagesOneServerV3Test, cls).setUpClass()
cls.client = cls.images_client
@@ -54,12 +55,8 @@
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
- try:
- resp, server = cls.create_test_server(wait_until='ACTIVE')
- cls.server_id = server['id']
- except Exception:
- cls.tearDownClass()
- raise
+ resp, server = cls.create_test_server(wait_until='ACTIVE')
+ cls.server_id = server['id']
def _get_default_flavor_disk_size(self, flavor_id):
resp, flavor = self.flavors_client.get_flavor_details(flavor_id)
diff --git a/tempest/api/compute/v3/images/test_images_oneserver_negative.py b/tempest/api/compute/v3/images/test_images_oneserver_negative.py
index eed81c6..544a5a5 100644
--- a/tempest/api/compute/v3/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/v3/images/test_images_oneserver_negative.py
@@ -55,6 +55,7 @@
self.__class__.server_id = self.rebuild_server(self.server_id)
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(ImagesOneServerNegativeV3Test, cls).setUpClass()
cls.client = cls.images_client
@@ -62,12 +63,8 @@
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
- try:
- resp, server = cls.create_test_server(wait_until='ACTIVE')
- cls.server_id = server['id']
- except Exception:
- cls.tearDownClass()
- raise
+ resp, server = cls.create_test_server(wait_until='ACTIVE')
+ cls.server_id = server['id']
cls.image_ids = []
diff --git a/tempest/api/compute/v3/servers/test_server_actions.py b/tempest/api/compute/v3/servers/test_server_actions.py
index d05e158..538507f 100644
--- a/tempest/api/compute/v3/servers/test_server_actions.py
+++ b/tempest/api/compute/v3/servers/test_server_actions.py
@@ -250,6 +250,8 @@
resp, server = self.client.get_server(self.server_id)
self.assertEqual(previous_flavor_ref, server['flavor']['id'])
+ @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
+ 'Snapshotting not available, backup not possible.')
@test.attr(type='gate')
def test_create_backup(self):
# Positive test:create backup successfully and rotate backups correctly
diff --git a/tempest/api/database/flavors/test_flavors.py b/tempest/api/database/flavors/test_flavors.py
index 64d71b9..a5c8caa 100644
--- a/tempest/api/database/flavors/test_flavors.py
+++ b/tempest/api/database/flavors/test_flavors.py
@@ -27,8 +27,7 @@
@test.attr(type='smoke')
def test_get_db_flavor(self):
# The expected flavor details should be returned
- resp, flavor = self.client.get_db_flavor_details(self.db_flavor_ref)
- self.assertEqual(200, resp.status)
+ _, flavor = self.client.get_db_flavor_details(self.db_flavor_ref)
self.assertEqual(self.db_flavor_ref, str(flavor['id']))
self.assertIn('ram', flavor)
self.assertIn('links', flavor)
@@ -36,11 +35,9 @@
@test.attr(type='smoke')
def test_list_db_flavors(self):
- resp, flavor = self.client.get_db_flavor_details(self.db_flavor_ref)
- self.assertEqual(200, resp.status)
+ _, flavor = self.client.get_db_flavor_details(self.db_flavor_ref)
# List of all flavors should contain the expected flavor
- resp, flavors = self.client.list_db_flavors()
- self.assertEqual(200, resp.status)
+ _, flavors = self.client.list_db_flavors()
self.assertIn(flavor, flavors)
def _check_values(self, names, db_flavor, os_flavor, in_db=True):
@@ -55,18 +52,16 @@
self.assertNotIn(name, db_flavor)
@test.attr(type='smoke')
+ @test.services('compute')
def test_compare_db_flavors_with_os(self):
- resp, db_flavors = self.client.list_db_flavors()
- self.assertEqual(200, resp.status)
- resp, os_flavors = self.os_flavors_client.list_flavors_with_detail()
- self.assertEqual(200, resp.status)
+ _, db_flavors = self.client.list_db_flavors()
+ _, os_flavors = self.os_flavors_client.list_flavors_with_detail()
self.assertEqual(len(os_flavors), len(db_flavors),
"OS flavors %s do not match DB flavors %s" %
(os_flavors, db_flavors))
for os_flavor in os_flavors:
- resp, db_flavor =\
+ _, db_flavor =\
self.client.get_db_flavor_details(os_flavor['id'])
- self.assertEqual(200, resp.status)
self._check_values(['id', 'name', 'ram'], db_flavor, os_flavor)
self._check_values(['disk', 'vcpus', 'swap'], db_flavor, os_flavor,
in_db=False)
diff --git a/tempest/api/database/versions/test_versions.py b/tempest/api/database/versions/test_versions.py
index 6101f47..453abe7 100644
--- a/tempest/api/database/versions/test_versions.py
+++ b/tempest/api/database/versions/test_versions.py
@@ -27,8 +27,7 @@
@test.attr(type='smoke')
def test_list_db_versions(self):
- resp, versions = self.client.list_db_versions()
- self.assertEqual(200, resp.status)
+ _, versions = self.client.list_db_versions()
self.assertTrue(len(versions) > 0, "No database versions found")
# List of all versions should contain the current version, and there
# should only be one 'current' version
diff --git a/tempest/api/network/admin/test_agent_management.py b/tempest/api/network/admin/test_agent_management.py
index b848994..f8782ad 100644
--- a/tempest/api/network/admin/test_agent_management.py
+++ b/tempest/api/network/admin/test_agent_management.py
@@ -32,8 +32,7 @@
@test.attr(type='smoke')
def test_list_agent(self):
- resp, body = self.admin_client.list_agents()
- self.assertEqual('200', resp['status'])
+ _, body = self.admin_client.list_agents()
agents = body['agents']
# Hearthbeats must be excluded from comparison
self.agent.pop('heartbeat_timestamp', None)
@@ -45,15 +44,13 @@
@test.attr(type=['smoke'])
def test_list_agents_non_admin(self):
- resp, body = self.client.list_agents()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_agents()
self.assertEqual(len(body["agents"]), 0)
@test.attr(type='smoke')
def test_show_agent(self):
- resp, body = self.admin_client.show_agent(self.agent['id'])
+ _, body = self.admin_client.show_agent(self.agent['id'])
agent = body['agent']
- self.assertEqual('200', resp['status'])
self.assertEqual(agent['id'], self.agent['id'])
@test.attr(type='smoke')
@@ -62,10 +59,9 @@
# Try to update the 'admin_state_up' to the original
# one to avoid the negative effect.
agent_status = {'admin_state_up': origin_status}
- resp, body = self.admin_client.update_agent(agent_id=self.agent['id'],
- agent_info=agent_status)
+ _, body = self.admin_client.update_agent(agent_id=self.agent['id'],
+ agent_info=agent_status)
updated_status = body['agent']['admin_state_up']
- self.assertEqual('200', resp['status'])
self.assertEqual(origin_status, updated_status)
@test.attr(type='smoke')
@@ -73,10 +69,8 @@
self.useFixture(fixtures.LockFixture('agent_description'))
description = 'description for update agent.'
agent_description = {'description': description}
- resp, body = self.admin_client.update_agent(
- agent_id=self.agent['id'],
- agent_info=agent_description)
- self.assertEqual('200', resp['status'])
+ _, body = self.admin_client.update_agent(agent_id=self.agent['id'],
+ agent_info=agent_description)
self.addCleanup(self._restore_agent)
updated_description = body['agent']['description']
self.assertEqual(updated_description, description)
diff --git a/tempest/api/network/admin/test_dhcp_agent_scheduler.py b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
index 25e1cc0..c84d1a7 100644
--- a/tempest/api/network/admin/test_dhcp_agent_scheduler.py
+++ b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
@@ -35,9 +35,8 @@
@test.attr(type='smoke')
def test_list_dhcp_agent_hosting_network(self):
- resp, body = self.admin_client.list_dhcp_agent_hosting_network(
+ _, body = self.admin_client.list_dhcp_agent_hosting_network(
self.network['id'])
- self.assertEqual(resp['status'], '200')
@test.attr(type='smoke')
def test_list_networks_hosted_by_one_dhcp(self):
@@ -51,9 +50,8 @@
def _check_network_in_dhcp_agent(self, network_id, agent):
network_ids = []
- resp, body = self.admin_client.list_networks_hosted_by_one_dhcp_agent(
+ _, body = self.admin_client.list_networks_hosted_by_one_dhcp_agent(
agent['id'])
- self.assertEqual(resp['status'], '200')
networks = body['networks']
for network in networks:
network_ids.append(network['id'])
@@ -85,17 +83,15 @@
self._remove_network_from_dhcp_agent(network_id, agent)
def _remove_network_from_dhcp_agent(self, network_id, agent):
- resp, body = self.admin_client.remove_network_from_dhcp_agent(
+ _, body = self.admin_client.remove_network_from_dhcp_agent(
agent_id=agent['id'],
network_id=network_id)
- self.assertEqual(resp['status'], '204')
self.assertFalse(self._check_network_in_dhcp_agent(
network_id, agent))
def _add_dhcp_agent_to_network(self, network_id, agent):
- resp, body = self.admin_client.add_dhcp_agent_to_network(
- agent['id'], network_id)
- self.assertEqual(resp['status'], '201')
+ _, body = self.admin_client.add_dhcp_agent_to_network(agent['id'],
+ network_id)
self.assertTrue(self._check_network_in_dhcp_agent(
network_id, agent))
diff --git a/tempest/api/network/admin/test_external_network_extension.py b/tempest/api/network/admin/test_external_network_extension.py
index c7fde77..710c669 100644
--- a/tempest/api/network/admin/test_external_network_extension.py
+++ b/tempest/api/network/admin/test_external_network_extension.py
@@ -26,9 +26,8 @@
post_body = {'name': data_utils.rand_name('network-')}
if external:
post_body['router:external'] = external
- resp, body = self.admin_client.create_network(**post_body)
+ _, body = self.admin_client.create_network(**post_body)
network = body['network']
- self.assertEqual('201', resp['status'])
self.addCleanup(self.admin_client.delete_network, network['id'])
return network
@@ -46,9 +45,8 @@
network = self._create_network(external=False)
self.assertFalse(network.get('router:external', False))
update_body = {'router:external': True}
- resp, body = self.admin_client.update_network(network['id'],
- **update_body)
- self.assertEqual('200', resp['status'])
+ _, body = self.admin_client.update_network(network['id'],
+ **update_body)
updated_network = body['network']
# Verify that router:external parameter was updated
self.assertTrue(updated_network['router:external'])
@@ -59,8 +57,7 @@
# List networks as a normal user and confirm the external
# network extension attribute is returned for those networks
# that were created as external
- resp, body = self.client.list_networks()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_networks()
networks_list = [net['id'] for net in body['networks']]
self.assertIn(external_network['id'], networks_list)
self.assertIn(self.network['id'], networks_list)
@@ -75,14 +72,12 @@
external_network = self._create_network()
# Show an external network as a normal user and confirm the
# external network extension attribute is returned.
- resp, body = self.client.show_network(external_network['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_network(external_network['id'])
show_ext_net = body['network']
self.assertEqual(external_network['name'], show_ext_net['name'])
self.assertEqual(external_network['id'], show_ext_net['id'])
self.assertTrue(show_ext_net['router:external'])
- resp, body = self.client.show_network(self.network['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_network(self.network['id'])
show_net = body['network']
# Verify with show that router:external is False for network
self.assertEqual(self.network['name'], show_net['name'])
diff --git a/tempest/api/network/admin/test_floating_ips_admin_actions.py b/tempest/api/network/admin/test_floating_ips_admin_actions.py
index 5728432..3718cb5 100644
--- a/tempest/api/network/admin/test_floating_ips_admin_actions.py
+++ b/tempest/api/network/admin/test_floating_ips_admin_actions.py
@@ -36,21 +36,18 @@
@test.attr(type='smoke')
def test_list_floating_ips_from_admin_and_nonadmin(self):
# Create floating ip from admin user
- resp, floating_ip_admin = self.admin_client.create_floatingip(
+ _, floating_ip_admin = self.admin_client.create_floatingip(
floating_network_id=self.ext_net_id)
- self.assertEqual('201', resp['status'])
self.addCleanup(self.admin_client.delete_floatingip,
floating_ip_admin['floatingip']['id'])
# Create floating ip from alt user
- resp, body = self.alt_client.create_floatingip(
+ _, body = self.alt_client.create_floatingip(
floating_network_id=self.ext_net_id)
- self.assertEqual('201', resp['status'])
floating_ip_alt = body['floatingip']
self.addCleanup(self.alt_client.delete_floatingip,
floating_ip_alt['id'])
# List floating ips from admin
- resp, body = self.admin_client.list_floatingips()
- self.assertEqual('200', resp['status'])
+ _, body = self.admin_client.list_floatingips()
floating_ip_ids_admin = [f['id'] for f in body['floatingips']]
# Check that admin sees all floating ips
self.assertIn(self.floating_ip['id'], floating_ip_ids_admin)
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
index 3b05f42..d7de73b 100644
--- a/tempest/api/network/admin/test_l3_agent_scheduler.py
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -52,9 +52,7 @@
@test.attr(type='smoke')
def test_list_routers_on_l3_agent(self):
- resp, body = self.admin_client.list_routers_on_l3_agent(
- self.agent['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.admin_client.list_routers_on_l3_agent(self.agent['id'])
@test.attr(type='smoke')
def test_add_list_remove_router_on_l3_agent(self):
@@ -62,21 +60,20 @@
name = data_utils.rand_name('router1-')
resp, router = self.client.create_router(name)
self.addCleanup(self.client.delete_router, router['router']['id'])
- resp, body = self.admin_client.add_router_to_l3_agent(
- self.agent['id'], router['router']['id'])
- self.assertEqual('201', resp['status'])
- resp, body = self.admin_client.list_l3_agents_hosting_router(
+ _, body = self.admin_client.add_router_to_l3_agent(
+ self.agent['id'],
router['router']['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.admin_client.list_l3_agents_hosting_router(
+ router['router']['id'])
for agent in body['agents']:
l3_agent_ids.append(agent['id'])
self.assertIn('agent_type', agent)
self.assertEqual('L3 agent', agent['agent_type'])
self.assertIn(self.agent['id'], l3_agent_ids)
del l3_agent_ids[:]
- resp, body = self.admin_client.remove_router_from_l3_agent(
- self.agent['id'], router['router']['id'])
- self.assertEqual('204', resp['status'])
+ _, body = self.admin_client.remove_router_from_l3_agent(
+ self.agent['id'],
+ router['router']['id'])
# NOTE(afazekas): The deletion not asserted, because neutron
# is not forbidden to reschedule the router to the same agent
diff --git a/tempest/api/network/admin/test_lbaas_agent_scheduler.py b/tempest/api/network/admin/test_lbaas_agent_scheduler.py
index 675c62d..d0c31b3 100644
--- a/tempest/api/network/admin/test_lbaas_agent_scheduler.py
+++ b/tempest/api/network/admin/test_lbaas_agent_scheduler.py
@@ -50,17 +50,15 @@
@test.attr(type='smoke')
def test_list_pools_on_lbaas_agent(self):
found = False
- resp, body = self.admin_client.list_agents(
+ _, body = self.admin_client.list_agents(
agent_type="Loadbalancer agent")
- self.assertEqual('200', resp['status'])
agents = body['agents']
for a in agents:
msg = 'Load Balancer agent expected'
self.assertEqual(a['agent_type'], 'Loadbalancer agent', msg)
- resp, body = (
+ _, body = (
self.admin_client.list_pools_hosted_by_one_lbaas_agent(
a['id']))
- self.assertEqual('200', resp['status'])
pools = body['pools']
if self.pool['id'] in [p['id'] for p in pools]:
found = True
@@ -69,9 +67,8 @@
@test.attr(type='smoke')
def test_show_lbaas_agent_hosting_pool(self):
- resp, body = self.admin_client.show_lbaas_agent_hosting_pool(
+ _, body = self.admin_client.show_lbaas_agent_hosting_pool(
self.pool['id'])
- self.assertEqual('200', resp['status'])
self.assertEqual('Loadbalancer agent', body['agent']['agent_type'])
diff --git a/tempest/api/network/admin/test_load_balancer_admin_actions.py b/tempest/api/network/admin/test_load_balancer_admin_actions.py
index fe4fc60..a97d275 100644
--- a/tempest/api/network/admin/test_load_balancer_admin_actions.py
+++ b/tempest/api/network/admin/test_load_balancer_admin_actions.py
@@ -47,56 +47,54 @@
@test.attr(type='smoke')
def test_create_vip_as_admin_for_another_tenant(self):
name = data_utils.rand_name('vip-')
- resp, body = self.admin_client.create_pool(
- name=data_utils.rand_name('pool-'), lb_method="ROUND_ROBIN",
- protocol="HTTP", subnet_id=self.subnet['id'],
+ _, body = self.admin_client.create_pool(
+ name=data_utils.rand_name('pool-'),
+ lb_method="ROUND_ROBIN",
+ protocol="HTTP",
+ subnet_id=self.subnet['id'],
tenant_id=self.tenant_id)
- self.assertEqual('201', resp['status'])
pool = body['pool']
self.addCleanup(self.admin_client.delete_pool, pool['id'])
- resp, body = self.admin_client.create_vip(name=name,
- protocol="HTTP",
- protocol_port=80,
- subnet_id=self.subnet['id'],
- pool_id=pool['id'],
- tenant_id=self.tenant_id)
- self.assertEqual('201', resp['status'])
+ _, body = self.admin_client.create_vip(name=name,
+ protocol="HTTP",
+ protocol_port=80,
+ subnet_id=self.subnet['id'],
+ pool_id=pool['id'],
+ tenant_id=self.tenant_id)
vip = body['vip']
self.addCleanup(self.admin_client.delete_vip, vip['id'])
self.assertIsNotNone(vip['id'])
self.assertEqual(self.tenant_id, vip['tenant_id'])
- resp, body = self.client.show_vip(vip['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_vip(vip['id'])
show_vip = body['vip']
self.assertEqual(vip['id'], show_vip['id'])
self.assertEqual(vip['name'], show_vip['name'])
@test.attr(type='smoke')
def test_create_health_monitor_as_admin_for_another_tenant(self):
- resp, body = (
+ _, body = (
self.admin_client.create_health_monitor(delay=4,
max_retries=3,
type="TCP",
timeout=1,
tenant_id=self.tenant_id))
- self.assertEqual('201', resp['status'])
health_monitor = body['health_monitor']
self.addCleanup(self.admin_client.delete_health_monitor,
health_monitor['id'])
self.assertIsNotNone(health_monitor['id'])
self.assertEqual(self.tenant_id, health_monitor['tenant_id'])
- resp, body = self.client.show_health_monitor(health_monitor['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_health_monitor(health_monitor['id'])
show_health_monitor = body['health_monitor']
self.assertEqual(health_monitor['id'], show_health_monitor['id'])
@test.attr(type='smoke')
def test_create_pool_from_admin_user_other_tenant(self):
- resp, body = self.admin_client.create_pool(
- name=data_utils.rand_name('pool-'), lb_method="ROUND_ROBIN",
- protocol="HTTP", subnet_id=self.subnet['id'],
+ _, body = self.admin_client.create_pool(
+ name=data_utils.rand_name('pool-'),
+ lb_method="ROUND_ROBIN",
+ protocol="HTTP",
+ subnet_id=self.subnet['id'],
tenant_id=self.tenant_id)
- self.assertEqual('201', resp['status'])
pool = body['pool']
self.addCleanup(self.admin_client.delete_pool, pool['id'])
self.assertIsNotNone(pool['id'])
@@ -104,10 +102,10 @@
@test.attr(type='smoke')
def test_create_member_from_admin_user_other_tenant(self):
- resp, body = self.admin_client.create_member(
- address="10.0.9.47", protocol_port=80, pool_id=self.pool['id'],
- tenant_id=self.tenant_id)
- self.assertEqual('201', resp['status'])
+ _, body = self.admin_client.create_member(address="10.0.9.47",
+ protocol_port=80,
+ pool_id=self.pool['id'],
+ tenant_id=self.tenant_id)
member = body['member']
self.addCleanup(self.admin_client.delete_member, member['id'])
self.assertIsNotNone(member['id'])
diff --git a/tempest/api/network/admin/test_quotas.py b/tempest/api/network/admin/test_quotas.py
index 9fa54b1..9ac97f9 100644
--- a/tempest/api/network/admin/test_quotas.py
+++ b/tempest/api/network/admin/test_quotas.py
@@ -57,16 +57,14 @@
self.addCleanup(self.identity_admin_client.delete_tenant, tenant_id)
# Change quotas for tenant
- resp, quota_set = self.admin_client.update_quotas(tenant_id,
- **new_quotas)
- self.assertEqual('200', resp['status'])
+ _, quota_set = self.admin_client.update_quotas(tenant_id,
+ **new_quotas)
self.addCleanup(self.admin_client.reset_quotas, tenant_id)
for key, value in new_quotas.iteritems():
self.assertEqual(value, quota_set[key])
# Confirm our tenant is listed among tenants with non default quotas
- resp, non_default_quotas = self.admin_client.list_quotas()
- self.assertEqual('200', resp['status'])
+ _, non_default_quotas = self.admin_client.list_quotas()
found = False
for qs in non_default_quotas['quotas']:
if qs['tenant_id'] == tenant_id:
@@ -74,17 +72,14 @@
self.assertTrue(found)
# Confirm from API quotas were changed as requested for tenant
- resp, quota_set = self.admin_client.show_quotas(tenant_id)
+ _, quota_set = self.admin_client.show_quotas(tenant_id)
quota_set = quota_set['quota']
- self.assertEqual('200', resp['status'])
for key, value in new_quotas.iteritems():
self.assertEqual(value, quota_set[key])
# Reset quotas to default and confirm
- resp, body = self.admin_client.reset_quotas(tenant_id)
- self.assertEqual('204', resp['status'])
- resp, non_default_quotas = self.admin_client.list_quotas()
- self.assertEqual('200', resp['status'])
+ _, body = self.admin_client.reset_quotas(tenant_id)
+ _, non_default_quotas = self.admin_client.list_quotas()
for q in non_default_quotas['quotas']:
self.assertNotEqual(tenant_id, q['tenant_id'])
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index d75339c..1a23cb6 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -49,6 +49,7 @@
neutron as True
"""
+ _interface = 'json'
force_tenant_isolation = False
# Default to ipv4.
diff --git a/tempest/api/network/base_routers.py b/tempest/api/network/base_routers.py
index 1303bcf..f69e6fd 100644
--- a/tempest/api/network/base_routers.py
+++ b/tempest/api/network/base_routers.py
@@ -26,34 +26,29 @@
super(BaseRouterTest, cls).setUpClass()
def _delete_router(self, router_id):
- resp, _ = self.client.delete_router(router_id)
- self.assertEqual(204, resp.status)
+ self.client.delete_router(router_id)
# Asserting that the router is not found in the list
# after deletion
- resp, list_body = self.client.list_routers()
- self.assertEqual('200', resp['status'])
+ _, list_body = self.client.list_routers()
routers_list = list()
for router in list_body['routers']:
routers_list.append(router['id'])
self.assertNotIn(router_id, routers_list)
def _add_router_interface_with_subnet_id(self, router_id, subnet_id):
- resp, interface = self.client.add_router_interface_with_subnet_id(
+ _, interface = self.client.add_router_interface_with_subnet_id(
router_id, subnet_id)
- self.assertEqual('200', resp['status'])
self.addCleanup(self._remove_router_interface_with_subnet_id,
router_id, subnet_id)
self.assertEqual(subnet_id, interface['subnet_id'])
return interface
def _remove_router_interface_with_subnet_id(self, router_id, subnet_id):
- resp, body = self.client.remove_router_interface_with_subnet_id(
+ _, body = self.client.remove_router_interface_with_subnet_id(
router_id, subnet_id)
- self.assertEqual('200', resp['status'])
self.assertEqual(subnet_id, body['subnet_id'])
def _remove_router_interface_with_port_id(self, router_id, port_id):
- resp, body = self.client.remove_router_interface_with_port_id(
- router_id, port_id)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.remove_router_interface_with_port_id(router_id,
+ port_id)
self.assertEqual(port_id, body['port_id'])
diff --git a/tempest/api/network/base_security_groups.py b/tempest/api/network/base_security_groups.py
index 90be454..c2af2f2 100644
--- a/tempest/api/network/base_security_groups.py
+++ b/tempest/api/network/base_security_groups.py
@@ -26,32 +26,27 @@
def _create_security_group(self):
# Create a security group
name = data_utils.rand_name('secgroup-')
- resp, group_create_body = self.client.create_security_group(name=name)
- self.assertEqual('201', resp['status'])
+ _, group_create_body = self.client.create_security_group(name=name)
self.addCleanup(self._delete_security_group,
group_create_body['security_group']['id'])
self.assertEqual(group_create_body['security_group']['name'], name)
return group_create_body, name
def _delete_security_group(self, secgroup_id):
- resp, _ = self.client.delete_security_group(secgroup_id)
- self.assertEqual(204, resp.status)
+ self.client.delete_security_group(secgroup_id)
# Asserting that the security group is not found in the list
# after deletion
- resp, list_body = self.client.list_security_groups()
- self.assertEqual('200', resp['status'])
+ _, list_body = self.client.list_security_groups()
secgroup_list = list()
for secgroup in list_body['security_groups']:
secgroup_list.append(secgroup['id'])
self.assertNotIn(secgroup_id, secgroup_list)
def _delete_security_group_rule(self, rule_id):
- resp, _ = self.client.delete_security_group_rule(rule_id)
- self.assertEqual(204, resp.status)
+ self.client.delete_security_group_rule(rule_id)
# Asserting that the security group is not found in the list
# after deletion
- resp, list_body = self.client.list_security_group_rules()
- self.assertEqual('200', resp['status'])
+ _, list_body = self.client.list_security_group_rules()
rules_list = list()
for rule in list_body['security_group_rules']:
rules_list.append(rule['id'])
diff --git a/tempest/api/network/common.py b/tempest/api/network/common.py
index 97e120f..5ac8b5a 100644
--- a/tempest/api/network/common.py
+++ b/tempest/api/network/common.py
@@ -13,6 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+import abc
+
+import six
+
class AttributeDict(dict):
@@ -27,6 +31,7 @@
return super(AttributeDict, self).__getattribute__(name)
+@six.add_metaclass(abc.ABCMeta)
class DeletableResource(AttributeDict):
"""
@@ -42,8 +47,9 @@
return '<%s id="%s" name="%s">' % (self.__class__.__name__,
self.id, self.name)
+ @abc.abstractmethod
def delete(self):
- raise NotImplemented()
+ return
def __hash__(self):
return id(self)
diff --git a/tempest/api/network/test_allowed_address_pair.py b/tempest/api/network/test_allowed_address_pair.py
index 8d984d1..86acc71 100644
--- a/tempest/api/network/test_allowed_address_pair.py
+++ b/tempest/api/network/test_allowed_address_pair.py
@@ -54,16 +54,14 @@
# Create port with allowed address pair attribute
allowed_address_pairs = [{'ip_address': self.ip_address,
'mac_address': self.mac_address}]
- resp, body = self.client.create_port(
+ _, body = self.client.create_port(
network_id=self.network['id'],
allowed_address_pairs=allowed_address_pairs)
- self.assertEqual('201', resp['status'])
port_id = body['port']['id']
self.addCleanup(self.client.delete_port, port_id)
# Confirm port was created with allowed address pair attribute
- resp, body = self.client.list_ports()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_ports()
ports = body['ports']
port = [p for p in ports if p['id'] == port_id]
msg = 'Created port not found in list of ports returned by Neutron'
@@ -73,21 +71,18 @@
@test.attr(type='smoke')
def test_update_port_with_address_pair(self):
# Create a port without allowed address pair
- resp, body = self.client.create_port(network_id=self.network['id'])
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_port(network_id=self.network['id'])
port_id = body['port']['id']
self.addCleanup(self.client.delete_port, port_id)
# Confirm port is created
- resp, body = self.client.show_port(port_id)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_port(port_id)
# Update allowed address pair attribute of port
allowed_address_pairs = [{'ip_address': self.ip_address,
'mac_address': self.mac_address}]
- resp, body = self.client.update_port(
+ _, body = self.client.update_port(
port_id, allowed_address_pairs=allowed_address_pairs)
- self.assertEqual('200', resp['status'])
newport = body['port']
self._confirm_allowed_address_pair(newport, self.ip_address)
diff --git a/tempest/api/network/test_extensions.py b/tempest/api/network/test_extensions.py
index 529f8e9..c3607c8 100644
--- a/tempest/api/network/test_extensions.py
+++ b/tempest/api/network/test_extensions.py
@@ -47,16 +47,14 @@
expected_alias = [ext for ext in expected_alias if
test.is_extension_enabled(ext, 'network')]
actual_alias = list()
- resp, extensions = self.client.list_extensions()
- self.assertEqual('200', resp['status'])
+ _, extensions = self.client.list_extensions()
list_extensions = extensions['extensions']
# Show and verify the details of the available extensions
for ext in list_extensions:
ext_name = ext['name']
ext_alias = ext['alias']
actual_alias.append(ext['alias'])
- resp, ext_details = self.client.show_extension(ext_alias)
- self.assertEqual('200', resp['status'])
+ _, ext_details = self.client.show_extension(ext_alias)
ext_details = ext_details['extension']
self.assertIsNotNone(ext_details)
diff --git a/tempest/api/network/test_extra_dhcp_options.py b/tempest/api/network/test_extra_dhcp_options.py
index 371c651..82ebc5a 100644
--- a/tempest/api/network/test_extra_dhcp_options.py
+++ b/tempest/api/network/test_extra_dhcp_options.py
@@ -54,16 +54,13 @@
{'opt_value': '123.123.123.123', 'opt_name': 'tftp-server'},
{'opt_value': '123.123.123.45', 'opt_name': 'server-ip-address'}
]
- resp, body = self.client.create_port(
- network_id=self.network['id'],
- extra_dhcp_opts=extra_dhcp_opts)
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_port(network_id=self.network['id'],
+ extra_dhcp_opts=extra_dhcp_opts)
port_id = body['port']['id']
self.addCleanup(self.client.delete_port, port_id)
# Confirm port created has Extra DHCP Options
- resp, body = self.client.list_ports()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_ports()
ports = body['ports']
port = [p for p in ports if p['id'] == port_id]
self.assertTrue(port)
@@ -78,13 +75,11 @@
{'opt_value': '123.123.123.45', 'opt_name': 'server-ip-address'}
]
name = data_utils.rand_name('new-port-name')
- resp, body = self.client.update_port(
- self.port['id'], name=name, extra_dhcp_opts=extra_dhcp_opts)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.update_port(self.port['id'], name=name,
+ extra_dhcp_opts=extra_dhcp_opts)
# Confirm extra dhcp options were added to the port
- resp, body = self.client.show_port(self.port['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_port(self.port['id'])
self._confirm_extra_dhcp_options(body['port'], extra_dhcp_opts)
def _confirm_extra_dhcp_options(self, port, extra_dhcp_opts):
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index 2463654..8b42a9e 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -68,9 +68,9 @@
@test.attr(type='smoke')
def test_create_list_show_update_delete_floating_ip(self):
# Creates a floating IP
- resp, body = self.client.create_floatingip(
- floating_network_id=self.ext_net_id, port_id=self.ports[0]['id'])
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_floatingip(
+ floating_network_id=self.ext_net_id,
+ port_id=self.ports[0]['id'])
created_floating_ip = body['floatingip']
self.addCleanup(self.client.delete_floatingip,
created_floating_ip['id'])
@@ -83,9 +83,7 @@
self.assertIn(created_floating_ip['fixed_ip_address'],
[ip['ip_address'] for ip in self.ports[0]['fixed_ips']])
# Verifies the details of a floating_ip
- resp, floating_ip = self.client.show_floatingip(
- created_floating_ip['id'])
- self.assertEqual('200', resp['status'])
+ _, floating_ip = self.client.show_floatingip(created_floating_ip['id'])
shown_floating_ip = floating_ip['floatingip']
self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
self.assertEqual(shown_floating_ip['floating_network_id'],
@@ -97,16 +95,15 @@
self.assertEqual(shown_floating_ip['port_id'], self.ports[0]['id'])
# Verify the floating ip exists in the list of all floating_ips
- resp, floating_ips = self.client.list_floatingips()
- self.assertEqual('200', resp['status'])
+ _, floating_ips = self.client.list_floatingips()
floatingip_id_list = list()
for f in floating_ips['floatingips']:
floatingip_id_list.append(f['id'])
self.assertIn(created_floating_ip['id'], floatingip_id_list)
# Associate floating IP to the other port
- resp, floating_ip = self.client.update_floatingip(
- created_floating_ip['id'], port_id=self.ports[1]['id'])
- self.assertEqual('200', resp['status'])
+ _, floating_ip = self.client.update_floatingip(
+ created_floating_ip['id'],
+ port_id=self.ports[1]['id'])
updated_floating_ip = floating_ip['floatingip']
self.assertEqual(updated_floating_ip['port_id'], self.ports[1]['id'])
self.assertEqual(updated_floating_ip['fixed_ip_address'],
@@ -114,9 +111,9 @@
self.assertEqual(updated_floating_ip['router_id'], self.router['id'])
# Disassociate floating IP from the port
- resp, floating_ip = self.client.update_floatingip(
- created_floating_ip['id'], port_id=None)
- self.assertEqual('200', resp['status'])
+ _, floating_ip = self.client.update_floatingip(
+ created_floating_ip['id'],
+ port_id=None)
updated_floating_ip = floating_ip['floatingip']
self.assertIsNone(updated_floating_ip['port_id'])
self.assertIsNone(updated_floating_ip['fixed_ip_address'])
@@ -125,24 +122,21 @@
@test.attr(type='smoke')
def test_floating_ip_delete_port(self):
# Create a floating IP
- resp, body = self.client.create_floatingip(
+ _, body = self.client.create_floatingip(
floating_network_id=self.ext_net_id)
- self.assertEqual('201', resp['status'])
created_floating_ip = body['floatingip']
self.addCleanup(self.client.delete_floatingip,
created_floating_ip['id'])
# Create a port
resp, port = self.client.create_port(network_id=self.network['id'])
created_port = port['port']
- resp, floating_ip = self.client.update_floatingip(
- created_floating_ip['id'], port_id=created_port['id'])
- self.assertEqual('200', resp['status'])
+ _, floating_ip = self.client.update_floatingip(
+ created_floating_ip['id'],
+ port_id=created_port['id'])
# Delete port
self.client.delete_port(created_port['id'])
# Verifies the details of the floating_ip
- resp, floating_ip = self.client.show_floatingip(
- created_floating_ip['id'])
- self.assertEqual('200', resp['status'])
+ _, floating_ip = self.client.show_floatingip(created_floating_ip['id'])
shown_floating_ip = floating_ip['floatingip']
# Confirm the fields are back to None
self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
@@ -153,9 +147,9 @@
@test.attr(type='smoke')
def test_floating_ip_update_different_router(self):
# Associate a floating IP to a port on a router
- resp, body = self.client.create_floatingip(
- floating_network_id=self.ext_net_id, port_id=self.ports[1]['id'])
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_floatingip(
+ floating_network_id=self.ext_net_id,
+ port_id=self.ports[1]['id'])
created_floating_ip = body['floatingip']
self.addCleanup(self.client.delete_floatingip,
created_floating_ip['id'])
@@ -167,9 +161,9 @@
self.create_router_interface(router2['id'], subnet2['id'])
port_other_router = self.create_port(network2)
# Associate floating IP to the other port on another router
- resp, floating_ip = self.client.update_floatingip(
- created_floating_ip['id'], port_id=port_other_router['id'])
- self.assertEqual('200', resp['status'])
+ _, floating_ip = self.client.update_floatingip(
+ created_floating_ip['id'],
+ port_id=port_other_router['id'])
updated_floating_ip = floating_ip['floatingip']
self.assertEqual(updated_floating_ip['router_id'], router2['id'])
self.assertEqual(updated_floating_ip['port_id'],
@@ -178,20 +172,19 @@
@test.attr(type='smoke')
def test_create_floating_ip_specifying_a_fixed_ip_address(self):
- resp, body = self.client.create_floatingip(
+ _, body = self.client.create_floatingip(
floating_network_id=self.ext_net_id,
port_id=self.ports[1]['id'],
fixed_ip_address=self.ports[1]['fixed_ips'][0]['ip_address'])
- self.assertEqual('201', resp['status'])
created_floating_ip = body['floatingip']
self.addCleanup(self.client.delete_floatingip,
created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['id'])
self.assertEqual(created_floating_ip['fixed_ip_address'],
self.ports[1]['fixed_ips'][0]['ip_address'])
- resp, floating_ip = self.client.update_floatingip(
- created_floating_ip['id'], port_id=None)
- self.assertEqual('200', resp['status'])
+ _, floating_ip = self.client.update_floatingip(
+ created_floating_ip['id'],
+ port_id=None)
self.assertIsNone(floating_ip['floatingip']['port_id'])
@test.attr(type='smoke')
@@ -201,25 +194,23 @@
list_ips = [str(ip) for ip in ips[-3:-1]]
fixed_ips = [{'ip_address': list_ips[0]}, {'ip_address': list_ips[1]}]
# Create port
- resp, body = self.client.create_port(network_id=self.network['id'],
- fixed_ips=fixed_ips)
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_port(network_id=self.network['id'],
+ fixed_ips=fixed_ips)
port = body['port']
self.addCleanup(self.client.delete_port, port['id'])
# Create floating ip
- resp, body = self.client.create_floatingip(
- floating_network_id=self.ext_net_id, port_id=port['id'],
+ _, body = self.client.create_floatingip(
+ floating_network_id=self.ext_net_id,
+ port_id=port['id'],
fixed_ip_address=list_ips[0])
- self.assertEqual('201', resp['status'])
floating_ip = body['floatingip']
self.addCleanup(self.client.delete_floatingip, floating_ip['id'])
self.assertIsNotNone(floating_ip['id'])
self.assertEqual(floating_ip['fixed_ip_address'], list_ips[0])
# Update floating ip
- resp, body = self.client.update_floatingip(
- floating_ip['id'], port_id=port['id'],
- fixed_ip_address=list_ips[1])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.update_floatingip(floating_ip['id'],
+ port_id=port['id'],
+ fixed_ip_address=list_ips[1])
update_floating_ip = body['floatingip']
self.assertEqual(update_floating_ip['fixed_ip_address'],
list_ips[1])
diff --git a/tempest/api/network/test_fwaas_extensions.py b/tempest/api/network/test_fwaas_extensions.py
index 555cbda..6eec79e 100644
--- a/tempest/api/network/test_fwaas_extensions.py
+++ b/tempest/api/network/test_fwaas_extensions.py
@@ -74,8 +74,7 @@
def _wait_for_active(self, fw_id):
def _wait():
- resp, firewall = self.client.show_firewall(fw_id)
- self.assertEqual('200', resp['status'])
+ _, firewall = self.client.show_firewall(fw_id)
firewall = firewall['firewall']
return firewall['status'] == 'ACTIVE'
@@ -87,8 +86,7 @@
@test.attr(type='smoke')
def test_list_firewall_rules(self):
# List firewall rules
- resp, fw_rules = self.client.list_firewall_rules()
- self.assertEqual('200', resp['status'])
+ _, fw_rules = self.client.list_firewall_rules()
fw_rules = fw_rules['firewall_rules']
self.assertIn((self.fw_rule['id'],
self.fw_rule['name'],
@@ -106,22 +104,19 @@
@test.attr(type='smoke')
def test_create_update_delete_firewall_rule(self):
# Create firewall rule
- resp, body = self.client.create_firewall_rule(
+ _, body = self.client.create_firewall_rule(
name=data_utils.rand_name("fw-rule"),
action="allow",
protocol="tcp")
- self.assertEqual('201', resp['status'])
fw_rule_id = body['firewall_rule']['id']
# Update firewall rule
- resp, body = self.client.update_firewall_rule(fw_rule_id,
- shared=True)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.update_firewall_rule(fw_rule_id,
+ shared=True)
self.assertTrue(body["firewall_rule"]['shared'])
# Delete firewall rule
- resp, _ = self.client.delete_firewall_rule(fw_rule_id)
- self.assertEqual('204', resp['status'])
+ self.client.delete_firewall_rule(fw_rule_id)
# Confirm deletion
resp, fw_rules = self.client.list_firewall_rules()
self.assertNotIn(fw_rule_id,
@@ -130,15 +125,13 @@
@test.attr(type='smoke')
def test_show_firewall_rule(self):
# show a created firewall rule
- resp, fw_rule = self.client.show_firewall_rule(self.fw_rule['id'])
- self.assertEqual('200', resp['status'])
+ _, fw_rule = self.client.show_firewall_rule(self.fw_rule['id'])
for key, value in fw_rule['firewall_rule'].iteritems():
self.assertEqual(self.fw_rule[key], value)
@test.attr(type='smoke')
def test_list_firewall_policies(self):
- resp, fw_policies = self.client.list_firewall_policies()
- self.assertEqual('200', resp['status'])
+ _, fw_policies = self.client.list_firewall_policies()
fw_policies = fw_policies['firewall_policies']
self.assertIn((self.fw_policy['id'],
self.fw_policy['name'],
@@ -150,24 +143,21 @@
@test.attr(type='smoke')
def test_create_update_delete_firewall_policy(self):
# Create firewall policy
- resp, body = self.client.create_firewall_policy(
+ _, body = self.client.create_firewall_policy(
name=data_utils.rand_name("fw-policy"))
- self.assertEqual('201', resp['status'])
fw_policy_id = body['firewall_policy']['id']
self.addCleanup(self._try_delete_policy, fw_policy_id)
# Update firewall policy
- resp, body = self.client.update_firewall_policy(fw_policy_id,
- shared=True,
- name="updated_policy")
- self.assertEqual('200', resp['status'])
+ _, body = self.client.update_firewall_policy(fw_policy_id,
+ shared=True,
+ name="updated_policy")
updated_fw_policy = body["firewall_policy"]
self.assertTrue(updated_fw_policy['shared'])
self.assertEqual("updated_policy", updated_fw_policy['name'])
# Delete firewall policy
- resp, _ = self.client.delete_firewall_policy(fw_policy_id)
- self.assertEqual('204', resp['status'])
+ self.client.delete_firewall_policy(fw_policy_id)
# Confirm deletion
resp, fw_policies = self.client.list_firewall_policies()
fw_policies = fw_policies['firewall_policies']
@@ -176,9 +166,7 @@
@test.attr(type='smoke')
def test_show_firewall_policy(self):
# show a created firewall policy
- resp, fw_policy = self.client.show_firewall_policy(
- self.fw_policy['id'])
- self.assertEqual('200', resp['status'])
+ _, fw_policy = self.client.show_firewall_policy(self.fw_policy['id'])
fw_policy = fw_policy['firewall_policy']
for key, value in fw_policy.iteritems():
self.assertEqual(self.fw_policy[key], value)
@@ -195,10 +183,9 @@
router['id'], subnet['id'])
# Create firewall
- resp, body = self.client.create_firewall(
+ _, body = self.client.create_firewall(
name=data_utils.rand_name("firewall"),
firewall_policy_id=self.fw_policy['id'])
- self.assertEqual('201', resp['status'])
created_firewall = body['firewall']
firewall_id = created_firewall['id']
self.addCleanup(self._try_delete_firewall, firewall_id)
@@ -206,8 +193,7 @@
self._wait_for_active(firewall_id)
# show a created firewall
- resp, firewall = self.client.show_firewall(firewall_id)
- self.assertEqual('200', resp['status'])
+ _, firewall = self.client.show_firewall(firewall_id)
firewall = firewall['firewall']
for key, value in firewall.iteritems():
@@ -216,8 +202,7 @@
self.assertEqual(created_firewall[key], value)
# list firewall
- resp, firewalls = self.client.list_firewalls()
- self.assertEqual('200', resp['status'])
+ _, firewalls = self.client.list_firewalls()
firewalls = firewalls['firewalls']
self.assertIn((created_firewall['id'],
created_firewall['name'],
@@ -227,8 +212,7 @@
m['firewall_policy_id']) for m in firewalls])
# Delete firewall
- resp, _ = self.client.delete_firewall(firewall_id)
- self.assertEqual('204', resp['status'])
+ self.client.delete_firewall(firewall_id)
class FWaaSExtensionTestXML(FWaaSExtensionTestJSON):
diff --git a/tempest/api/network/test_load_balancer.py b/tempest/api/network/test_load_balancer.py
index 7a12ef6..e3109ea 100644
--- a/tempest/api/network/test_load_balancer.py
+++ b/tempest/api/network/test_load_balancer.py
@@ -67,34 +67,31 @@
delete_obj = getattr(self.client, 'delete_' + obj_name)
list_objs = getattr(self.client, 'list_' + obj_name + 's')
- resp, body = create_obj(**kwargs)
- self.assertEqual('201', resp['status'])
+ _, body = create_obj(**kwargs)
obj = body[obj_name]
self.addCleanup(delete_obj, obj['id'])
for key, value in obj.iteritems():
# It is not relevant to filter by all arguments. That is why
# there is a list of attr to except
if key not in attr_exceptions:
- resp, body = list_objs(**{key: value})
- self.assertEqual('200', resp['status'])
+ _, body = list_objs(**{key: value})
objs = [v[key] for v in body[obj_name + 's']]
self.assertIn(value, objs)
@test.attr(type='smoke')
def test_list_vips(self):
# Verify the vIP exists in the list of all vIPs
- resp, body = self.client.list_vips()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_vips()
vips = body['vips']
self.assertIn(self.vip['id'], [v['id'] for v in vips])
@test.attr(type='smoke')
def test_list_vips_with_filter(self):
name = data_utils.rand_name('vip-')
- resp, body = self.client.create_pool(
- name=data_utils.rand_name("pool-"), lb_method="ROUND_ROBIN",
- protocol="HTTPS", subnet_id=self.subnet['id'])
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_pool(name=data_utils.rand_name("pool-"),
+ lb_method="ROUND_ROBIN",
+ protocol="HTTPS",
+ subnet_id=self.subnet['id'])
pool = body['pool']
self.addCleanup(self.client.delete_pool, pool['id'])
attr_exceptions = ['status', 'session_persistence',
@@ -116,18 +113,16 @@
protocol='HTTP',
subnet_id=self.subnet['id'])
pool = body['pool']
- resp, body = self.client.create_vip(name=name,
- protocol="HTTP",
- protocol_port=80,
- subnet_id=self.subnet['id'],
- pool_id=pool['id'],
- address=address)
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_vip(name=name,
+ protocol="HTTP",
+ protocol_port=80,
+ subnet_id=self.subnet['id'],
+ pool_id=pool['id'],
+ address=address)
vip = body['vip']
vip_id = vip['id']
# Confirm VIP's address correctness with a show
- resp, body = self.client.show_vip(vip_id)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_vip(vip_id)
vip = body['vip']
self.assertEqual(address, vip['address'])
# Verification of vip update
@@ -136,13 +131,12 @@
persistence_type = "HTTP_COOKIE"
update_data = {"session_persistence": {
"type": persistence_type}}
- resp, body = self.client.update_vip(vip_id,
- name=new_name,
- description=new_description,
- connection_limit=10,
- admin_state_up=False,
- **update_data)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.update_vip(vip_id,
+ name=new_name,
+ description=new_description,
+ connection_limit=10,
+ admin_state_up=False,
+ **update_data)
updated_vip = body['vip']
self.assertEqual(new_name, updated_vip['name'])
self.assertEqual(new_description, updated_vip['description'])
@@ -150,30 +144,24 @@
self.assertFalse(updated_vip['admin_state_up'])
self.assertEqual(persistence_type,
updated_vip['session_persistence']['type'])
- # Verification of vip delete
- resp, body = self.client.delete_vip(vip['id'])
- self.assertEqual('204', resp['status'])
+ self.client.delete_vip(vip['id'])
self.client.wait_for_resource_deletion('vip', vip['id'])
# Verification of pool update
new_name = "New_pool"
- resp, body = self.client.update_pool(pool['id'],
- name=new_name,
- description="new_description",
- lb_method='LEAST_CONNECTIONS')
- self.assertEqual('200', resp['status'])
+ _, body = self.client.update_pool(pool['id'],
+ name=new_name,
+ description="new_description",
+ lb_method='LEAST_CONNECTIONS')
updated_pool = body['pool']
self.assertEqual(new_name, updated_pool['name'])
self.assertEqual('new_description', updated_pool['description'])
self.assertEqual('LEAST_CONNECTIONS', updated_pool['lb_method'])
- # Verification of pool delete
- resp, body = self.client.delete_pool(pool['id'])
- self.assertEqual('204', resp['status'])
+ self.client.delete_pool(pool['id'])
@test.attr(type='smoke')
def test_show_vip(self):
# Verifies the details of a vip
- resp, body = self.client.show_vip(self.vip['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_vip(self.vip['id'])
vip = body['vip']
for key, value in vip.iteritems():
# 'status' should not be confirmed in api tests
@@ -183,17 +171,14 @@
@test.attr(type='smoke')
def test_show_pool(self):
# Here we need to new pool without any dependence with vips
- resp, body = self.client.create_pool(
- name=data_utils.rand_name("pool-"),
- lb_method='ROUND_ROBIN',
- protocol='HTTP',
- subnet_id=self.subnet['id'])
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_pool(name=data_utils.rand_name("pool-"),
+ lb_method='ROUND_ROBIN',
+ protocol='HTTP',
+ subnet_id=self.subnet['id'])
pool = body['pool']
self.addCleanup(self.client.delete_pool, pool['id'])
# Verifies the details of a pool
- resp, body = self.client.show_pool(pool['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_pool(pool['id'])
shown_pool = body['pool']
for key, value in pool.iteritems():
# 'status' should not be confirmed in api tests
@@ -203,8 +188,7 @@
@test.attr(type='smoke')
def test_list_pools(self):
# Verify the pool exists in the list of all pools
- resp, body = self.client.list_pools()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_pools()
pools = body['pools']
self.assertIn(self.pool['id'], [p['id'] for p in pools])
@@ -222,8 +206,7 @@
@test.attr(type='smoke')
def test_list_members(self):
# Verify the member exists in the list of all members
- resp, body = self.client.list_members()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_members()
members = body['members']
self.assertIn(self.member['id'], [m['id'] for m in members])
@@ -237,26 +220,22 @@
@test.attr(type='smoke')
def test_create_update_delete_member(self):
# Creates a member
- resp, body = self.client.create_member(address="10.0.9.47",
- protocol_port=80,
- pool_id=self.pool['id'])
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_member(address="10.0.9.47",
+ protocol_port=80,
+ pool_id=self.pool['id'])
member = body['member']
# Verification of member update
- resp, body = self.client.update_member(member['id'],
- admin_state_up=False)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.update_member(member['id'],
+ admin_state_up=False)
updated_member = body['member']
self.assertFalse(updated_member['admin_state_up'])
# Verification of member delete
- resp, body = self.client.delete_member(member['id'])
- self.assertEqual('204', resp['status'])
+ self.client.delete_member(member['id'])
@test.attr(type='smoke')
def test_show_member(self):
# Verifies the details of a member
- resp, body = self.client.show_member(self.member['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_member(self.member['id'])
member = body['member']
for key, value in member.iteritems():
# 'status' should not be confirmed in api tests
@@ -266,8 +245,7 @@
@test.attr(type='smoke')
def test_list_health_monitors(self):
# Verify the health monitor exists in the list of all health monitors
- resp, body = self.client.list_health_monitors()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_health_monitors()
health_monitors = body['health_monitors']
self.assertIn(self.health_monitor['id'],
[h['id'] for h in health_monitors])
@@ -282,31 +260,27 @@
@test.attr(type='smoke')
def test_create_update_delete_health_monitor(self):
# Creates a health_monitor
- resp, body = self.client.create_health_monitor(delay=4,
- max_retries=3,
- type="TCP",
- timeout=1)
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_health_monitor(delay=4,
+ max_retries=3,
+ type="TCP",
+ timeout=1)
health_monitor = body['health_monitor']
# Verification of health_monitor update
- resp, body = (self.client.update_health_monitor
- (health_monitor['id'],
- admin_state_up=False))
- self.assertEqual('200', resp['status'])
+ _, body = (self.client.update_health_monitor
+ (health_monitor['id'],
+ admin_state_up=False))
updated_health_monitor = body['health_monitor']
self.assertFalse(updated_health_monitor['admin_state_up'])
# Verification of health_monitor delete
- resp, body = self.client.delete_health_monitor(health_monitor['id'])
- self.assertEqual('204', resp['status'])
+ _, body = self.client.delete_health_monitor(health_monitor['id'])
@test.attr(type='smoke')
def test_create_health_monitor_http_type(self):
hm_type = "HTTP"
- resp, body = self.client.create_health_monitor(delay=4,
- max_retries=3,
- type=hm_type,
- timeout=1)
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_health_monitor(delay=4,
+ max_retries=3,
+ type=hm_type,
+ timeout=1)
health_monitor = body['health_monitor']
self.addCleanup(self.client.delete_health_monitor,
health_monitor['id'])
@@ -314,20 +288,18 @@
@test.attr(type='smoke')
def test_update_health_monitor_http_method(self):
- resp, body = self.client.create_health_monitor(delay=4,
- max_retries=3,
- type="HTTP",
- timeout=1)
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_health_monitor(delay=4,
+ max_retries=3,
+ type="HTTP",
+ timeout=1)
health_monitor = body['health_monitor']
self.addCleanup(self.client.delete_health_monitor,
health_monitor['id'])
- resp, body = (self.client.update_health_monitor
- (health_monitor['id'],
- http_method="POST",
- url_path="/home/user",
- expected_codes="290"))
- self.assertEqual('200', resp['status'])
+ _, body = (self.client.update_health_monitor
+ (health_monitor['id'],
+ http_method="POST",
+ url_path="/home/user",
+ expected_codes="290"))
updated_health_monitor = body['health_monitor']
self.assertEqual("POST", updated_health_monitor['http_method'])
self.assertEqual("/home/user", updated_health_monitor['url_path'])
@@ -336,8 +308,7 @@
@test.attr(type='smoke')
def test_show_health_monitor(self):
# Verifies the details of a health_monitor
- resp, body = self.client.show_health_monitor(self.health_monitor['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_health_monitor(self.health_monitor['id'])
health_monitor = body['health_monitor']
for key, value in health_monitor.iteritems():
# 'status' should not be confirmed in api tests
@@ -347,9 +318,8 @@
@test.attr(type='smoke')
def test_associate_disassociate_health_monitor_with_pool(self):
# Verify that a health monitor can be associated with a pool
- resp, body = (self.client.associate_health_monitor_with_pool
- (self.health_monitor['id'], self.pool['id']))
- self.assertEqual('201', resp['status'])
+ _, body = (self.client.associate_health_monitor_with_pool
+ (self.health_monitor['id'], self.pool['id']))
resp, body = self.client.show_health_monitor(
self.health_monitor['id'])
health_monitor = body['health_monitor']
@@ -359,10 +329,9 @@
[p['pool_id'] for p in health_monitor['pools']])
self.assertIn(health_monitor['id'], pool['health_monitors'])
# Verify that a health monitor can be disassociated from a pool
- resp, body = (self.client.disassociate_health_monitor_with_pool
- (self.health_monitor['id'], self.pool['id']))
- self.assertEqual('204', resp['status'])
- resp, body = self.client.show_pool(self.pool['id'])
+ (self.client.disassociate_health_monitor_with_pool
+ (self.health_monitor['id'], self.pool['id']))
+ _, body = self.client.show_pool(self.pool['id'])
pool = body['pool']
resp, body = self.client.show_health_monitor(
self.health_monitor['id'])
@@ -374,8 +343,7 @@
@test.attr(type='smoke')
def test_get_lb_pool_stats(self):
# Verify the details of pool stats
- resp, body = self.client.list_lb_pool_stats(self.pool['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_lb_pool_stats(self.pool['id'])
stats = body['stats']
self.assertIn("bytes_in", stats)
self.assertIn("total_connections", stats)
@@ -384,52 +352,41 @@
@test.attr(type='smoke')
def test_update_list_of_health_monitors_associated_with_pool(self):
- resp, _ = (self.client.associate_health_monitor_with_pool
- (self.health_monitor['id'], self.pool['id']))
- self.assertEqual('201', resp['status'])
- resp, _ = self.client.update_health_monitor(
+ (self.client.associate_health_monitor_with_pool
+ (self.health_monitor['id'], self.pool['id']))
+ self.client.update_health_monitor(
self.health_monitor['id'], admin_state_up=False)
- self.assertEqual('200', resp['status'])
- resp, body = self.client.show_pool(self.pool['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_pool(self.pool['id'])
health_monitors = body['pool']['health_monitors']
for health_monitor_id in health_monitors:
- resp, body = self.client.show_health_monitor(health_monitor_id)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_health_monitor(health_monitor_id)
self.assertFalse(body['health_monitor']['admin_state_up'])
- resp, _ = (self.client.disassociate_health_monitor_with_pool
- (self.health_monitor['id'], self.pool['id']))
- self.assertEqual('204', resp['status'])
+ (self.client.disassociate_health_monitor_with_pool
+ (self.health_monitor['id'], self.pool['id']))
@test.attr(type='smoke')
def test_update_admin_state_up_of_pool(self):
- resp, _ = self.client.update_pool(self.pool['id'],
- admin_state_up=False)
- self.assertEqual('200', resp['status'])
- resp, body = self.client.show_pool(self.pool['id'])
- self.assertEqual('200', resp['status'])
+ self.client.update_pool(self.pool['id'],
+ admin_state_up=False)
+ _, body = self.client.show_pool(self.pool['id'])
pool = body['pool']
self.assertFalse(pool['admin_state_up'])
@test.attr(type='smoke')
def test_show_vip_associated_with_pool(self):
- resp, body = self.client.show_pool(self.pool['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_pool(self.pool['id'])
pool = body['pool']
- resp, body = self.client.show_vip(pool['vip_id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_vip(pool['vip_id'])
vip = body['vip']
self.assertEqual(self.vip['name'], vip['name'])
self.assertEqual(self.vip['id'], vip['id'])
@test.attr(type='smoke')
def test_show_members_associated_with_pool(self):
- resp, body = self.client.show_pool(self.pool['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_pool(self.pool['id'])
members = body['pool']['members']
for member_id in members:
- resp, body = self.client.show_member(member_id)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_member(member_id)
self.assertIsNotNone(body['member']['status'])
self.assertEqual(member_id, body['member']['id'])
self.assertIsNotNone(body['member']['admin_state_up'])
@@ -437,34 +394,28 @@
@test.attr(type='smoke')
def test_update_pool_related_to_member(self):
# Create new pool
- resp, body = self.client.create_pool(
- name=data_utils.rand_name("pool-"),
- lb_method='ROUND_ROBIN',
- protocol='HTTP',
- subnet_id=self.subnet['id'])
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_pool(name=data_utils.rand_name("pool-"),
+ lb_method='ROUND_ROBIN',
+ protocol='HTTP',
+ subnet_id=self.subnet['id'])
new_pool = body['pool']
self.addCleanup(self.client.delete_pool, new_pool['id'])
# Update member with new pool's id
- resp, body = self.client.update_member(self.member['id'],
- pool_id=new_pool['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.update_member(self.member['id'],
+ pool_id=new_pool['id'])
# Confirm with show that pool_id change
resp, body = self.client.show_member(self.member['id'])
member = body['member']
self.assertEqual(member['pool_id'], new_pool['id'])
# Update member with old pool id, this is needed for clean up
- resp, body = self.client.update_member(self.member['id'],
- pool_id=self.pool['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.update_member(self.member['id'],
+ pool_id=self.pool['id'])
@test.attr(type='smoke')
def test_update_member_weight(self):
- resp, _ = self.client.update_member(self.member['id'],
- weight=2)
- self.assertEqual('200', resp['status'])
- resp, body = self.client.show_member(self.member['id'])
- self.assertEqual('200', resp['status'])
+ self.client.update_member(self.member['id'],
+ weight=2)
+ _, body = self.client.show_member(self.member['id'])
member = body['member']
self.assertEqual(2, member['weight'])
diff --git a/tempest/api/network/test_metering_extensions.py b/tempest/api/network/test_metering_extensions.py
index 08ccbfe..0cc218b 100644
--- a/tempest/api/network/test_metering_extensions.py
+++ b/tempest/api/network/test_metering_extensions.py
@@ -35,6 +35,7 @@
"""
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(MeteringJSON, cls).setUpClass()
if not test.is_extension_enabled('metering', 'network'):
@@ -42,22 +43,16 @@
raise cls.skipException(msg)
description = "metering label created by tempest"
name = data_utils.rand_name("metering-label")
- try:
- cls.metering_label = cls.create_metering_label(name, description)
- remote_ip_prefix = "10.0.0.0/24"
- direction = "ingress"
- cls.metering_label_rule = cls.create_metering_label_rule(
- remote_ip_prefix, direction,
- metering_label_id=cls.metering_label['id'])
- except Exception:
- LOG.exception('setUpClass failed')
- cls.tearDownClass()
- raise
+ cls.metering_label = cls.create_metering_label(name, description)
+ remote_ip_prefix = "10.0.0.0/24"
+ direction = "ingress"
+ cls.metering_label_rule = cls.create_metering_label_rule(
+ remote_ip_prefix, direction,
+ metering_label_id=cls.metering_label['id'])
def _delete_metering_label(self, metering_label_id):
# Deletes a label and verifies if it is deleted or not
- resp, body = self.admin_client.delete_metering_label(metering_label_id)
- self.assertEqual(204, resp.status)
+ _, body = self.admin_client.delete_metering_label(metering_label_id)
# Asserting that the label is not found in list after deletion
resp, labels = (self.admin_client.list_metering_labels(
id=metering_label_id))
@@ -65,9 +60,8 @@
def _delete_metering_label_rule(self, metering_label_rule_id):
# Deletes a rule and verifies if it is deleted or not
- resp, body = (self.admin_client.delete_metering_label_rule(
- metering_label_rule_id))
- self.assertEqual(204, resp.status)
+ _, body = (self.admin_client.delete_metering_label_rule(
+ metering_label_rule_id))
# Asserting that the rule is not found in list after deletion
resp, rules = (self.admin_client.list_metering_label_rules(
id=metering_label_rule_id))
@@ -76,8 +70,7 @@
@test.attr(type='smoke')
def test_list_metering_labels(self):
# Verify label filtering
- resp, body = self.admin_client.list_metering_labels(id=33)
- self.assertEqual('200', resp['status'])
+ _, body = self.admin_client.list_metering_labels(id=33)
metering_labels = body['metering_labels']
self.assertEqual(0, len(metering_labels))
@@ -86,9 +79,8 @@
# Creates a label
name = data_utils.rand_name('metering-label-')
description = "label created by tempest"
- resp, body = (self.admin_client.create_metering_label(name=name,
- description=description))
- self.assertEqual('201', resp['status'])
+ _, body = (self.admin_client.create_metering_label(name=name,
+ description=description))
metering_label = body['metering_label']
self.addCleanup(self._delete_metering_label,
metering_label['id'])
@@ -101,9 +93,8 @@
@test.attr(type='smoke')
def test_show_metering_label(self):
# Verifies the details of a label
- resp, body = (self.admin_client.show_metering_label(
- self.metering_label['id']))
- self.assertEqual('200', resp['status'])
+ _, body = (self.admin_client.show_metering_label(
+ self.metering_label['id']))
metering_label = body['metering_label']
self.assertEqual(self.metering_label['id'], metering_label['id'])
self.assertEqual(self.metering_label['tenant_id'],
@@ -115,19 +106,17 @@
@test.attr(type='smoke')
def test_list_metering_label_rules(self):
# Verify rule filtering
- resp, body = self.admin_client.list_metering_label_rules(id=33)
- self.assertEqual('200', resp['status'])
+ _, body = self.admin_client.list_metering_label_rules(id=33)
metering_label_rules = body['metering_label_rules']
self.assertEqual(0, len(metering_label_rules))
@test.attr(type='smoke')
def test_create_delete_metering_label_rule_with_filters(self):
# Creates a rule
- resp, body = (self.admin_client.create_metering_label_rule(
- remote_ip_prefix="10.0.1.0/24",
- direction="ingress",
- metering_label_id=self.metering_label['id']))
- self.assertEqual('201', resp['status'])
+ _, body = (self.admin_client.create_metering_label_rule(
+ remote_ip_prefix="10.0.1.0/24",
+ direction="ingress",
+ metering_label_id=self.metering_label['id']))
metering_label_rule = body['metering_label_rule']
self.addCleanup(self._delete_metering_label_rule,
metering_label_rule['id'])
@@ -140,9 +129,8 @@
@test.attr(type='smoke')
def test_show_metering_label_rule(self):
# Verifies the details of a rule
- resp, body = (self.admin_client.show_metering_label_rule(
- self.metering_label_rule['id']))
- self.assertEqual('200', resp['status'])
+ _, body = (self.admin_client.show_metering_label_rule(
+ self.metering_label_rule['id']))
metering_label_rule = body['metering_label_rule']
self.assertEqual(self.metering_label_rule['id'],
metering_label_rule['id'])
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index ac3a072..f3da614 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -71,14 +71,13 @@
def test_create_update_delete_network_subnet(self):
# Create a network
name = data_utils.rand_name('network-')
- resp, body = self.client.create_network(name=name)
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_network(name=name)
network = body['network']
net_id = network['id']
+ self.assertEqual('ACTIVE', network['status'])
# Verify network update
new_name = "New_network"
- resp, body = self.client.update_network(net_id, name=new_name)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.update_network(net_id, name=new_name)
updated_net = body['network']
self.assertEqual(updated_net['name'], new_name)
# Find a cidr that is not in use yet and create a subnet with it
@@ -86,23 +85,19 @@
subnet_id = subnet['id']
# Verify subnet update
new_name = "New_subnet"
- resp, body = self.client.update_subnet(subnet_id, name=new_name)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.update_subnet(subnet_id, name=new_name)
updated_subnet = body['subnet']
self.assertEqual(updated_subnet['name'], new_name)
# Delete subnet and network
- resp, body = self.client.delete_subnet(subnet_id)
- self.assertEqual('204', resp['status'])
+ _, body = self.client.delete_subnet(subnet_id)
# Remove subnet from cleanup list
self.subnets.pop()
- resp, body = self.client.delete_network(net_id)
- self.assertEqual('204', resp['status'])
+ _, body = self.client.delete_network(net_id)
@test.attr(type='smoke')
def test_show_network(self):
# Verify the details of a network
- resp, body = self.client.show_network(self.network['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_network(self.network['id'])
network = body['network']
for key in ['id', 'name']:
self.assertEqual(network[key], self.network[key])
@@ -111,9 +106,8 @@
def test_show_network_fields(self):
# Verify specific fields of a network
fields = ['id', 'name']
- resp, body = self.client.show_network(self.network['id'],
- fields=fields)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_network(self.network['id'],
+ fields=fields)
network = body['network']
self.assertEqual(sorted(network.keys()), sorted(fields))
for field_name in fields:
@@ -122,8 +116,7 @@
@test.attr(type='smoke')
def test_list_networks(self):
# Verify the network exists in the list of all networks
- resp, body = self.client.list_networks()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_networks()
networks = [network['id'] for network in body['networks']
if network['id'] == self.network['id']]
self.assertNotEmpty(networks, "Created network not found in the list")
@@ -132,8 +125,7 @@
def test_list_networks_fields(self):
# Verify specific fields of the networks
fields = ['id', 'name']
- resp, body = self.client.list_networks(fields=fields)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_networks(fields=fields)
networks = body['networks']
self.assertNotEmpty(networks, "Network list returned is empty")
for network in networks:
@@ -142,8 +134,7 @@
@test.attr(type='smoke')
def test_show_subnet(self):
# Verify the details of a subnet
- resp, body = self.client.show_subnet(self.subnet['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_subnet(self.subnet['id'])
subnet = body['subnet']
self.assertNotEmpty(subnet, "Subnet returned has no fields")
for key in ['id', 'cidr']:
@@ -154,9 +145,8 @@
def test_show_subnet_fields(self):
# Verify specific fields of a subnet
fields = ['id', 'network_id']
- resp, body = self.client.show_subnet(self.subnet['id'],
- fields=fields)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_subnet(self.subnet['id'],
+ fields=fields)
subnet = body['subnet']
self.assertEqual(sorted(subnet.keys()), sorted(fields))
for field_name in fields:
@@ -165,8 +155,7 @@
@test.attr(type='smoke')
def test_list_subnets(self):
# Verify the subnet exists in the list of all subnets
- resp, body = self.client.list_subnets()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_subnets()
subnets = [subnet['id'] for subnet in body['subnets']
if subnet['id'] == self.subnet['id']]
self.assertNotEmpty(subnets, "Created subnet not found in the list")
@@ -175,8 +164,7 @@
def test_list_subnets_fields(self):
# Verify specific fields of subnets
fields = ['id', 'network_id']
- resp, body = self.client.list_subnets(fields=fields)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_subnets(fields=fields)
subnets = body['subnets']
self.assertNotEmpty(subnets, "Subnet list returned is empty")
for subnet in subnets:
@@ -194,8 +182,7 @@
def test_delete_network_with_subnet(self):
# Creates a network
name = data_utils.rand_name('network-')
- resp, body = self.client.create_network(name=name)
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_network(name=name)
network = body['network']
net_id = network['id']
self.addCleanup(self._try_delete_network, net_id)
@@ -205,8 +192,7 @@
subnet_id = subnet['id']
# Delete network while the subnet still exists
- resp, body = self.client.delete_network(net_id)
- self.assertEqual('204', resp['status'])
+ _, body = self.client.delete_network(net_id)
# Verify that the subnet got automatically deleted.
self.assertRaises(exceptions.NotFound, self.client.show_subnet,
@@ -221,16 +207,14 @@
def test_create_delete_subnet_with_gw(self):
gateway = '10.100.0.13'
name = data_utils.rand_name('network-')
- resp, body = self.client.create_network(name=name)
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_network(name=name)
network = body['network']
net_id = network['id']
subnet = self.create_subnet(network, gateway)
# Verifies Subnet GW in IPv4
self.assertEqual(subnet['gateway_ip'], gateway)
# Delete network and subnet
- resp, body = self.client.delete_network(net_id)
- self.assertEqual('204', resp['status'])
+ self.client.delete_network(net_id)
self.subnets.pop()
@test.attr(type='smoke')
@@ -238,16 +222,14 @@
net = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
gateway_ip = str(netaddr.IPAddress(net.first + 1))
name = data_utils.rand_name('network-')
- resp, body = self.client.create_network(name=name)
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_network(name=name)
network = body['network']
net_id = network['id']
subnet = self.create_subnet(network)
# Verifies Subnet GW in IPv4
self.assertEqual(subnet['gateway_ip'], gateway_ip)
# Delete network and subnet
- resp, body = self.client.delete_network(net_id)
- self.assertEqual('204', resp['status'])
+ self.client.delete_network(net_id)
self.subnets.pop()
@@ -279,8 +261,7 @@
def _delete_networks(self, created_networks):
for n in created_networks:
- resp, body = self.client.delete_network(n['id'])
- self.assertEqual(204, resp.status)
+ self.client.delete_network(n['id'])
# Asserting that the networks are not found in the list after deletion
resp, body = self.client.list_networks()
networks_list = [network['id'] for network in body['networks']]
@@ -289,8 +270,7 @@
def _delete_subnets(self, created_subnets):
for n in created_subnets:
- resp, body = self.client.delete_subnet(n['id'])
- self.assertEqual(204, resp.status)
+ self.client.delete_subnet(n['id'])
# Asserting that the subnets are not found in the list after deletion
resp, body = self.client.list_subnets()
subnets_list = [subnet['id'] for subnet in body['subnets']]
@@ -299,8 +279,7 @@
def _delete_ports(self, created_ports):
for n in created_ports:
- resp, body = self.client.delete_port(n['id'])
- self.assertEqual(204, resp.status)
+ self.client.delete_port(n['id'])
# Asserting that the ports are not found in the list after deletion
resp, body = self.client.list_ports()
ports_list = [port['id'] for port in body['ports']]
@@ -312,9 +291,8 @@
# Creates 2 networks in one request
network_names = [data_utils.rand_name('network-'),
data_utils.rand_name('network-')]
- resp, body = self.client.create_bulk_network(2, network_names)
+ _, body = self.client.create_bulk_network(network_names)
created_networks = body['networks']
- self.assertEqual('201', resp['status'])
self.addCleanup(self._delete_networks, created_networks)
# Asserting that the networks are found in the list after creation
resp, body = self.client.list_networks()
@@ -344,10 +322,9 @@
}
subnets_list.append(p1)
del subnets_list[1]['name']
- resp, body = self.client.create_bulk_subnet(subnets_list)
+ _, body = self.client.create_bulk_subnet(subnets_list)
created_subnets = body['subnets']
self.addCleanup(self._delete_subnets, created_subnets)
- self.assertEqual('201', resp['status'])
# Asserting that the subnets are found in the list after creation
resp, body = self.client.list_subnets()
subnets_list = [subnet['id'] for subnet in body['subnets']]
@@ -370,10 +347,9 @@
}
port_list.append(p1)
del port_list[1]['name']
- resp, body = self.client.create_bulk_port(port_list)
+ _, body = self.client.create_bulk_port(port_list)
created_ports = body['ports']
self.addCleanup(self._delete_ports, created_ports)
- self.assertEqual('201', resp['status'])
# Asserting that the ports are found in the list after creation
resp, body = self.client.list_ports()
ports_list = [port['id'] for port in body['ports']]
@@ -398,33 +374,32 @@
@test.attr(type='smoke')
def test_create_delete_subnet_with_gw(self):
- gateway = '2003::2'
+ net = netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr)
+ gateway = str(netaddr.IPAddress(net.first + 2))
name = data_utils.rand_name('network-')
- resp, body = self.client.create_network(name=name)
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_network(name=name)
network = body['network']
net_id = network['id']
subnet = self.create_subnet(network, gateway)
# Verifies Subnet GW in IPv6
self.assertEqual(subnet['gateway_ip'], gateway)
# Delete network and subnet
- resp, body = self.client.delete_network(net_id)
- self.assertEqual('204', resp['status'])
+ self.client.delete_network(net_id)
self.subnets.pop()
@test.attr(type='smoke')
def test_create_delete_subnet_without_gw(self):
+ net = netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr)
+ gateway_ip = str(netaddr.IPAddress(net.first + 1))
name = data_utils.rand_name('network-')
- resp, body = self.client.create_network(name=name)
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_network(name=name)
network = body['network']
net_id = network['id']
subnet = self.create_subnet(network)
# Verifies Subnet GW in IPv6
- self.assertEqual(subnet['gateway_ip'], '2003::1')
+ self.assertEqual(subnet['gateway_ip'], gateway_ip)
# Delete network and subnet
- resp, body = self.client.delete_network(net_id)
- self.assertEqual('204', resp['status'])
+ _, body = self.client.delete_network(net_id)
self.subnets.pop()
@testtools.skipUnless(CONF.network_feature_enabled.ipv6_subnet_attributes,
@@ -433,8 +408,7 @@
@test.attr(type='smoke')
def test_create_delete_subnet_with_v6_attributes(self):
name = data_utils.rand_name('network-')
- resp, body = self.client.create_network(name=name)
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_network(name=name)
network = body['network']
net_id = network['id']
subnet = self.create_subnet(network,
@@ -446,8 +420,7 @@
self.assertEqual(subnet['ipv6_ra_mode'], 'slaac')
self.assertEqual(subnet['ipv6_address_mode'], 'slaac')
# Delete network and subnet
- resp, body = self.client.delete_network(net_id)
- self.assertEqual('204', resp['status'])
+ self.client.delete_network(net_id)
self.subnets.pop()
diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py
index e6e6ea1..c6fe817 100644
--- a/tempest/api/network/test_ports.py
+++ b/tempest/api/network/test_ports.py
@@ -16,6 +16,7 @@
import socket
from tempest.api.network import base
+from tempest.common import custom_matchers
from tempest.common.utils import data_utils
from tempest import config
from tempest import test
@@ -44,29 +45,24 @@
cls.port = cls.create_port(cls.network)
def _delete_port(self, port_id):
- resp, body = self.client.delete_port(port_id)
- self.assertEqual('204', resp['status'])
- resp, body = self.client.list_ports()
- self.assertEqual('200', resp['status'])
+ self.client.delete_port(port_id)
+ _, body = self.client.list_ports()
ports_list = body['ports']
self.assertFalse(port_id in [n['id'] for n in ports_list])
@test.attr(type='smoke')
def test_create_update_delete_port(self):
# Verify port creation
- resp, body = self.client.create_port(network_id=self.network['id'])
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_port(network_id=self.network['id'])
port = body['port']
# Schedule port deletion with verification upon test completion
self.addCleanup(self._delete_port, port['id'])
self.assertTrue(port['admin_state_up'])
# Verify port update
new_name = "New_Port"
- resp, body = self.client.update_port(
- port['id'],
- name=new_name,
- admin_state_up=False)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.update_port(port['id'],
+ name=new_name,
+ admin_state_up=False)
updated_port = body['port']
self.assertEqual(updated_port['name'], new_name)
self.assertFalse(updated_port['admin_state_up'])
@@ -74,30 +70,22 @@
@test.attr(type='smoke')
def test_show_port(self):
# Verify the details of port
- resp, body = self.client.show_port(self.port['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_port(self.port['id'])
port = body['port']
self.assertIn('id', port)
- self.assertEqual(port['id'], self.port['id'])
- self.assertEqual(self.port['admin_state_up'], port['admin_state_up'])
- self.assertEqual(self.port['device_id'], port['device_id'])
- self.assertEqual(self.port['device_owner'], port['device_owner'])
- self.assertEqual(self.port['mac_address'], port['mac_address'])
- self.assertEqual(self.port['name'], port['name'])
- self.assertEqual(self.port['security_groups'],
- port['security_groups'])
- self.assertEqual(self.port['network_id'], port['network_id'])
- self.assertEqual(self.port['security_groups'],
- port['security_groups'])
- self.assertEqual(port['fixed_ips'], [])
+ # TODO(Santosh)- This is a temporary workaround to compare create_port
+ # and show_port dict elements.Remove this once extra_dhcp_opts issue
+ # gets fixed in neutron.( bug - 1365341.)
+ self.assertThat(self.port,
+ custom_matchers.MatchesDictExceptForKeys
+ (port, excluded_keys=['extra_dhcp_opts']))
@test.attr(type='smoke')
def test_show_port_fields(self):
# Verify specific fields of a port
fields = ['id', 'mac_address']
- resp, body = self.client.show_port(self.port['id'],
- fields=fields)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_port(self.port['id'],
+ fields=fields)
port = body['port']
self.assertEqual(sorted(port.keys()), sorted(fields))
for field_name in fields:
@@ -106,8 +94,7 @@
@test.attr(type='smoke')
def test_list_ports(self):
# Verify the port exists in the list of all ports
- resp, body = self.client.list_ports()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_ports()
ports = [port['id'] for port in body['ports']
if port['id'] == self.port['id']]
self.assertNotEmpty(ports, "Created port not found in the list")
@@ -125,9 +112,7 @@
self.addCleanup(self.client.remove_router_interface_with_port_id,
router['id'], port['port']['id'])
# List ports filtered by router_id
- resp, port_list = self.client.list_ports(
- device_id=router['id'])
- self.assertEqual('200', resp['status'])
+ _, port_list = self.client.list_ports(device_id=router['id'])
ports = port_list['ports']
self.assertEqual(len(ports), 1)
self.assertEqual(ports[0]['id'], port['port']['id'])
@@ -137,8 +122,7 @@
def test_list_ports_fields(self):
# Verify specific fields of ports
fields = ['id', 'mac_address']
- resp, body = self.client.list_ports(fields=fields)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_ports(fields=fields)
ports = body['ports']
self.assertNotEmpty(ports, "Port list returned is empty")
# Asserting the fields returned are correct
@@ -190,8 +174,7 @@
def test_create_port_binding_ext_attr(self):
post_body = {"network_id": self.network['id'],
"binding:host_id": self.host_id}
- resp, body = self.admin_client.create_port(**post_body)
- self.assertEqual('201', resp['status'])
+ _, body = self.admin_client.create_port(**post_body)
port = body['port']
self.addCleanup(self.admin_client.delete_port, port['id'])
host_id = port['binding:host_id']
@@ -201,13 +184,11 @@
@test.attr(type='smoke')
def test_update_port_binding_ext_attr(self):
post_body = {"network_id": self.network['id']}
- resp, body = self.admin_client.create_port(**post_body)
- self.assertEqual('201', resp['status'])
+ _, body = self.admin_client.create_port(**post_body)
port = body['port']
self.addCleanup(self.admin_client.delete_port, port['id'])
update_body = {"binding:host_id": self.host_id}
- resp, body = self.admin_client.update_port(port['id'], **update_body)
- self.assertEqual('200', resp['status'])
+ _, body = self.admin_client.update_port(port['id'], **update_body)
updated_port = body['port']
host_id = updated_port['binding:host_id']
self.assertIsNotNone(host_id)
@@ -217,21 +198,18 @@
def test_list_ports_binding_ext_attr(self):
# Create a new port
post_body = {"network_id": self.network['id']}
- resp, body = self.admin_client.create_port(**post_body)
- self.assertEqual('201', resp['status'])
+ _, body = self.admin_client.create_port(**post_body)
port = body['port']
self.addCleanup(self.admin_client.delete_port, port['id'])
# Update the port's binding attributes so that is now 'bound'
# to a host
update_body = {"binding:host_id": self.host_id}
- resp, _ = self.admin_client.update_port(port['id'], **update_body)
- self.assertEqual('200', resp['status'])
+ self.admin_client.update_port(port['id'], **update_body)
# List all ports, ensure new port is part of list and its binding
# attributes are set and accurate
- resp, body = self.admin_client.list_ports()
- self.assertEqual('200', resp['status'])
+ _, body = self.admin_client.list_ports()
ports_list = body['ports']
pids_list = [p['id'] for p in ports_list]
self.assertIn(port['id'], pids_list)
@@ -243,13 +221,10 @@
@test.attr(type='smoke')
def test_show_port_binding_ext_attr(self):
- resp, body = self.admin_client.create_port(
- network_id=self.network['id'])
- self.assertEqual('201', resp['status'])
+ _, body = self.admin_client.create_port(network_id=self.network['id'])
port = body['port']
self.addCleanup(self.admin_client.delete_port, port['id'])
- resp, body = self.admin_client.show_port(port['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.admin_client.show_port(port['id'])
show_port = body['port']
self.assertEqual(port['binding:host_id'],
show_port['binding:host_id'])
@@ -269,10 +244,10 @@
_tenant_network_mask_bits = CONF.network.tenant_network_v6_mask_bits
@classmethod
+ @test.safe_setup
def setUpClass(cls):
super(PortsIpV6TestJSON, cls).setUpClass()
if not CONF.network_feature_enabled.ipv6:
- cls.tearDownClass()
skip_msg = "IPv6 Tests are disabled."
raise cls.skipException(skip_msg)
@@ -294,6 +269,5 @@
super(PortsAdminExtendedAttrsIpV6TestJSON, cls).setUpClass()
-class PortsAdminExtendedAttrsIpV6TestXML(
- PortsAdminExtendedAttrsIpV6TestJSON):
+class PortsAdminExtendedAttrsIpV6TestXML(PortsAdminExtendedAttrsIpV6TestJSON):
_interface = 'xml'
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index 878335d..bcd8113 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -54,11 +54,10 @@
# NOTE(salv-orlando): Do not invoke self.create_router
# as we need to check the response code
name = data_utils.rand_name('router-')
- resp, create_body = self.client.create_router(
+ _, create_body = self.client.create_router(
name, external_gateway_info={
"network_id": CONF.network.public_network_id},
admin_state_up=False)
- self.assertEqual('201', resp['status'])
self.addCleanup(self._delete_router, create_body['router']['id'])
self.assertEqual(create_body['router']['name'], name)
self.assertEqual(
@@ -66,26 +65,22 @@
CONF.network.public_network_id)
self.assertEqual(create_body['router']['admin_state_up'], False)
# Show details of the created router
- resp, show_body = self.client.show_router(
- create_body['router']['id'])
- self.assertEqual('200', resp['status'])
+ _, show_body = self.client.show_router(create_body['router']['id'])
self.assertEqual(show_body['router']['name'], name)
self.assertEqual(
show_body['router']['external_gateway_info']['network_id'],
CONF.network.public_network_id)
self.assertEqual(show_body['router']['admin_state_up'], False)
# List routers and verify if created router is there in response
- resp, list_body = self.client.list_routers()
- self.assertEqual('200', resp['status'])
+ _, list_body = self.client.list_routers()
routers_list = list()
for router in list_body['routers']:
routers_list.append(router['id'])
self.assertIn(create_body['router']['id'], routers_list)
# Update the name of router and verify if it is updated
updated_name = 'updated ' + name
- resp, update_body = self.client.update_router(
- create_body['router']['id'], name=updated_name)
- self.assertEqual('200', resp['status'])
+ _, update_body = self.client.update_router(create_body['router']['id'],
+ name=updated_name)
self.assertEqual(update_body['router']['name'], updated_name)
resp, show_body = self.client.show_router(
create_body['router']['id'])
@@ -97,15 +92,13 @@
test_tenant = data_utils.rand_name('test_tenant_')
test_description = data_utils.rand_name('desc_')
_, tenant = self.identity_admin_client.create_tenant(
- name=test_tenant,
- description=test_description)
+ name=test_tenant, description=test_description)
tenant_id = tenant['id']
self.addCleanup(self.identity_admin_client.delete_tenant, tenant_id)
name = data_utils.rand_name('router-')
- resp, create_body = self.admin_client.create_router(
- name, tenant_id=tenant_id)
- self.assertEqual('201', resp['status'])
+ _, create_body = self.admin_client.create_router(name,
+ tenant_id=tenant_id)
self.addCleanup(self.admin_client.delete_router,
create_body['router']['id'])
self.assertEqual(tenant_id, create_body['router']['tenant_id'])
@@ -131,9 +124,8 @@
external_gateway_info = {
'network_id': CONF.network.public_network_id,
'enable_snat': enable_snat}
- resp, create_body = self.admin_client.create_router(
+ _, create_body = self.admin_client.create_router(
name, external_gateway_info=external_gateway_info)
- self.assertEqual('201', resp['status'])
self.addCleanup(self.admin_client.delete_router,
create_body['router']['id'])
# Verify snat attributes after router creation
@@ -146,9 +138,8 @@
subnet = self.create_subnet(network)
router = self._create_router(data_utils.rand_name('router-'))
# Add router interface with subnet id
- resp, interface = self.client.add_router_interface_with_subnet_id(
+ _, interface = self.client.add_router_interface_with_subnet_id(
router['id'], subnet['id'])
- self.assertEqual('200', resp['status'])
self.addCleanup(self._remove_router_interface_with_subnet_id,
router['id'], subnet['id'])
self.assertIn('subnet_id', interface.keys())
@@ -167,9 +158,8 @@
resp, port_body = self.client.create_port(
network_id=network['id'])
# add router interface to port created above
- resp, interface = self.client.add_router_interface_with_port_id(
+ _, interface = self.client.add_router_interface_with_port_id(
router['id'], port_body['port']['id'])
- self.assertEqual('200', resp['status'])
self.addCleanup(self._remove_router_interface_with_port_id,
router['id'], port_body['port']['id'])
self.assertIn('subnet_id', interface.keys())
@@ -181,8 +171,7 @@
router['id'])
def _verify_router_gateway(self, router_id, exp_ext_gw_info=None):
- resp, show_body = self.admin_client.show_router(router_id)
- self.assertEqual('200', resp['status'])
+ _, show_body = self.admin_client.show_router(router_id)
actual_ext_gw_info = show_body['router']['external_gateway_info']
if exp_ext_gw_info is None:
self.assertIsNone(actual_ext_gw_info)
@@ -212,8 +201,7 @@
external_gateway_info={
'network_id': CONF.network.public_network_id})
# Verify operation - router
- resp, show_body = self.client.show_router(router['id'])
- self.assertEqual('200', resp['status'])
+ _, show_body = self.client.show_router(router['id'])
self._verify_router_gateway(
router['id'],
{'network_id': CONF.network.public_network_id})
@@ -297,16 +285,14 @@
cidr = netaddr.IPNetwork(self.subnet['cidr'])
next_hop = str(cidr[2])
destination = str(self.subnet['cidr'])
- resp, extra_route = self.client.update_extra_routes(
- self.router['id'], next_hop, destination)
- self.assertEqual('200', resp['status'])
+ _, extra_route = self.client.update_extra_routes(self.router['id'],
+ next_hop, destination)
self.assertEqual(1, len(extra_route['router']['routes']))
self.assertEqual(destination,
extra_route['router']['routes'][0]['destination'])
self.assertEqual(next_hop,
extra_route['router']['routes'][0]['nexthop'])
- resp, show_body = self.client.show_router(self.router['id'])
- self.assertEqual('200', resp['status'])
+ _, show_body = self.client.show_router(self.router['id'])
self.assertEqual(destination,
show_body['router']['routes'][0]['destination'])
self.assertEqual(next_hop,
@@ -320,12 +306,10 @@
self.router = self._create_router(data_utils.rand_name('router-'))
self.assertFalse(self.router['admin_state_up'])
# Update router admin state
- resp, update_body = self.client.update_router(self.router['id'],
- admin_state_up=True)
- self.assertEqual('200', resp['status'])
+ _, update_body = self.client.update_router(self.router['id'],
+ admin_state_up=True)
self.assertTrue(update_body['router']['admin_state_up'])
- resp, show_body = self.client.show_router(self.router['id'])
- self.assertEqual('200', resp['status'])
+ _, show_body = self.client.show_router(self.router['id'])
self.assertTrue(show_body['router']['admin_state_up'])
@test.attr(type='smoke')
@@ -348,8 +332,7 @@
interface02['port_id'])
def _verify_router_interface(self, router_id, subnet_id, port_id):
- resp, show_port_body = self.client.show_port(port_id)
- self.assertEqual('200', resp['status'])
+ _, show_port_body = self.client.show_port(port_id)
interface_port = show_port_body['port']
self.assertEqual(router_id, interface_port['device_id'])
self.assertEqual(subnet_id,
diff --git a/tempest/api/network/test_security_groups.py b/tempest/api/network/test_security_groups.py
index b98cea1..cea8344 100644
--- a/tempest/api/network/test_security_groups.py
+++ b/tempest/api/network/test_security_groups.py
@@ -33,8 +33,7 @@
@test.attr(type='smoke')
def test_list_security_groups(self):
# Verify the that security group belonging to tenant exist in list
- resp, body = self.client.list_security_groups()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_security_groups()
security_groups = body['security_groups']
found = None
for n in security_groups:
@@ -48,8 +47,7 @@
group_create_body, name = self._create_security_group()
# List security groups and verify if created group is there in response
- resp, list_body = self.client.list_security_groups()
- self.assertEqual('200', resp['status'])
+ _, list_body = self.client.list_security_groups()
secgroup_list = list()
for secgroup in list_body['security_groups']:
secgroup_list.append(secgroup['id'])
@@ -57,12 +55,11 @@
# Update the security group
new_name = data_utils.rand_name('security-')
new_description = data_utils.rand_name('security-description')
- resp, update_body = self.client.update_security_group(
+ _, update_body = self.client.update_security_group(
group_create_body['security_group']['id'],
name=new_name,
description=new_description)
# Verify if security group is updated
- self.assertEqual('200', resp['status'])
self.assertEqual(update_body['security_group']['name'], new_name)
self.assertEqual(update_body['security_group']['description'],
new_description)
@@ -80,18 +77,16 @@
# Create rules for each protocol
protocols = ['tcp', 'udp', 'icmp']
for protocol in protocols:
- resp, rule_create_body = self.client.create_security_group_rule(
+ _, rule_create_body = self.client.create_security_group_rule(
security_group_id=group_create_body['security_group']['id'],
protocol=protocol,
direction='ingress'
)
- self.assertEqual('201', resp['status'])
# Show details of the created security rule
- resp, show_rule_body = self.client.show_security_group_rule(
+ _, show_rule_body = self.client.show_security_group_rule(
rule_create_body['security_group_rule']['id']
)
- self.assertEqual('200', resp['status'])
create_dict = rule_create_body['security_group_rule']
for key, value in six.iteritems(create_dict):
self.assertEqual(value,
@@ -99,8 +94,7 @@
"%s does not match." % key)
# List rules and verify created rule is in response
- resp, rule_list_body = self.client.list_security_group_rules()
- self.assertEqual('200', resp['status'])
+ _, rule_list_body = self.client.list_security_group_rules()
rule_list = [rule['id']
for rule in rule_list_body['security_group_rules']]
self.assertIn(rule_create_body['security_group_rule']['id'],
@@ -117,7 +111,7 @@
protocol = 'tcp'
port_range_min = 77
port_range_max = 77
- resp, rule_create_body = self.client.create_security_group_rule(
+ _, rule_create_body = self.client.create_security_group_rule(
security_group_id=group_create_body['security_group']['id'],
direction=direction,
protocol=protocol,
@@ -125,7 +119,6 @@
port_range_max=port_range_max
)
- self.assertEqual('201', resp['status'])
sec_group_rule = rule_create_body['security_group_rule']
self.assertEqual(sec_group_rule['direction'], direction)
diff --git a/tempest/api/network/test_service_type_management.py b/tempest/api/network/test_service_type_management.py
index d272c47..dbb72fb 100644
--- a/tempest/api/network/test_service_type_management.py
+++ b/tempest/api/network/test_service_type_management.py
@@ -26,8 +26,7 @@
@test.attr(type='smoke')
def test_service_provider_list(self):
- resp, body = self.client.list_service_providers()
- self.assertEqual(resp['status'], '200')
+ _, body = self.client.list_service_providers()
self.assertIsInstance(body['service_providers'], list)
diff --git a/tempest/api/network/test_vpnaas_extensions.py b/tempest/api/network/test_vpnaas_extensions.py
index 0cc3f19..09e9640 100644
--- a/tempest/api/network/test_vpnaas_extensions.py
+++ b/tempest/api/network/test_vpnaas_extensions.py
@@ -61,8 +61,7 @@
for ike in all_ike['ikepolicies']:
ike_list.append(ike['id'])
if ike_policy_id in ike_list:
- resp, _ = self.client.delete_ikepolicy(ike_policy_id)
- self.assertEqual(204, resp.status)
+ self.client.delete_ikepolicy(ike_policy_id)
# Asserting that the policy is not found in list after deletion
resp, ikepolicies = self.client.list_ikepolicies()
ike_id_list = list()
@@ -85,8 +84,7 @@
self.assertEqual(value, actual[key])
def _delete_vpn_service(self, vpn_service_id):
- resp, _ = self.client.delete_vpnservice(vpn_service_id)
- self.assertEqual('204', resp['status'])
+ self.client.delete_vpnservice(vpn_service_id)
# Asserting if vpn service is found in the list after deletion
_, body = self.client.list_vpnservices()
vpn_services = [vs['id'] for vs in body['vpnservices']]
@@ -107,9 +105,8 @@
tenant_id = self._get_tenant_id()
# Create IPSec policy for the newly created tenant
name = data_utils.rand_name('ipsec-policy')
- resp, body = (self.admin_client.
- create_ipsecpolicy(name=name, tenant_id=tenant_id))
- self.assertEqual('201', resp['status'])
+ _, body = (self.admin_client.
+ create_ipsecpolicy(name=name, tenant_id=tenant_id))
ipsecpolicy = body['ipsecpolicy']
self.assertIsNotNone(ipsecpolicy['id'])
self.addCleanup(self.admin_client.delete_ipsecpolicy,
@@ -126,13 +123,12 @@
# Create vpn service for the newly created tenant
name = data_utils.rand_name('vpn-service')
- resp, body = self.admin_client.create_vpnservice(
+ _, body = self.admin_client.create_vpnservice(
subnet_id=self.subnet['id'],
router_id=self.router['id'],
name=name,
admin_state_up=True,
tenant_id=tenant_id)
- self.assertEqual('201', resp['status'])
vpnservice = body['vpnservice']
self.assertIsNotNone(vpnservice['id'])
self.addCleanup(self.admin_client.delete_vpnservice, vpnservice['id'])
@@ -148,12 +144,11 @@
# Create IKE policy for the newly created tenant
name = data_utils.rand_name('ike-policy')
- resp, body = (self.admin_client.
- create_ikepolicy(name=name, ike_version="v1",
- encryption_algorithm="aes-128",
- auth_algorithm="sha1",
- tenant_id=tenant_id))
- self.assertEqual('201', resp['status'])
+ _, body = (self.admin_client.
+ create_ikepolicy(name=name, ike_version="v1",
+ encryption_algorithm="aes-128",
+ auth_algorithm="sha1",
+ tenant_id=tenant_id))
ikepolicy = body['ikepolicy']
self.assertIsNotNone(ikepolicy['id'])
self.addCleanup(self.admin_client.delete_ikepolicy, ikepolicy['id'])
@@ -166,8 +161,7 @@
@test.attr(type='smoke')
def test_list_vpn_services(self):
# Verify the VPN service exists in the list of all VPN services
- resp, body = self.client.list_vpnservices()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_vpnservices()
vpnservices = body['vpnservices']
self.assertIn(self.vpnservice['id'], [v['id'] for v in vpnservices])
@@ -175,11 +169,10 @@
def test_create_update_delete_vpn_service(self):
# Creates a VPN service and sets up deletion
name = data_utils.rand_name('vpn-service')
- resp, body = self.client.create_vpnservice(subnet_id=self.subnet['id'],
- router_id=self.router['id'],
- name=name,
- admin_state_up=True)
- self.assertEqual('201', resp['status'])
+ _, body = self.client.create_vpnservice(subnet_id=self.subnet['id'],
+ router_id=self.router['id'],
+ name=name,
+ admin_state_up=True)
vpnservice = body['vpnservice']
self.addCleanup(self._delete_vpn_service, vpnservice['id'])
# Assert if created vpnservices are not found in vpnservices list
@@ -196,8 +189,7 @@
@test.attr(type='smoke')
def test_show_vpn_service(self):
# Verifies the details of a vpn service
- resp, body = self.client.show_vpnservice(self.vpnservice['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_vpnservice(self.vpnservice['id'])
vpnservice = body['vpnservice']
self.assertEqual(self.vpnservice['id'], vpnservice['id'])
self.assertEqual(self.vpnservice['name'], vpnservice['name'])
@@ -213,8 +205,7 @@
@test.attr(type='smoke')
def test_list_ike_policies(self):
# Verify the ike policy exists in the list of all IKE policies
- resp, body = self.client.list_ikepolicies()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_ikepolicies()
ikepolicies = body['ikepolicies']
self.assertIn(self.ikepolicy['id'], [i['id'] for i in ikepolicies])
@@ -222,12 +213,11 @@
def test_create_update_delete_ike_policy(self):
# Creates a IKE policy
name = data_utils.rand_name('ike-policy')
- resp, body = (self.client.create_ikepolicy(
- name=name,
- ike_version="v1",
- encryption_algorithm="aes-128",
- auth_algorithm="sha1"))
- self.assertEqual('201', resp['status'])
+ _, body = (self.client.create_ikepolicy(
+ name=name,
+ ike_version="v1",
+ encryption_algorithm="aes-128",
+ auth_algorithm="sha1"))
ikepolicy = body['ikepolicy']
self.assertIsNotNone(ikepolicy['id'])
self.addCleanup(self._delete_ike_policy, ikepolicy['id'])
@@ -239,8 +229,7 @@
'ike_version': "v2",
'pfs': "group14",
'lifetime': {'units': "seconds", 'value': 2000}}
- resp, _ = self.client.update_ikepolicy(ikepolicy['id'], **new_ike)
- self.assertEqual('200', resp['status'])
+ self.client.update_ikepolicy(ikepolicy['id'], **new_ike)
# Confirm that update was successful by verifying using 'show'
_, body = self.client.show_ikepolicy(ikepolicy['id'])
ike_policy = body['ikepolicy']
@@ -249,8 +238,7 @@
self.assertEqual(value, ike_policy[key])
# Verification of ike policy delete
- resp, _ = self.client.delete_ikepolicy(ikepolicy['id'])
- self.assertEqual('204', resp['status'])
+ self.client.delete_ikepolicy(ikepolicy['id'])
_, body = self.client.list_ikepolicies()
ikepolicies = [ikp['id'] for ikp in body['ikepolicies']]
self.assertNotIn(ike_policy['id'], ikepolicies)
@@ -258,8 +246,7 @@
@test.attr(type='smoke')
def test_show_ike_policy(self):
# Verifies the details of a ike policy
- resp, body = self.client.show_ikepolicy(self.ikepolicy['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_ikepolicy(self.ikepolicy['id'])
ikepolicy = body['ikepolicy']
self.assertEqual(self.ikepolicy['id'], ikepolicy['id'])
self.assertEqual(self.ikepolicy['name'], ikepolicy['name'])
@@ -281,8 +268,7 @@
@test.attr(type='smoke')
def test_list_ipsec_policies(self):
# Verify the ipsec policy exists in the list of all ipsec policies
- resp, body = self.client.list_ipsecpolicies()
- self.assertEqual('200', resp['status'])
+ _, body = self.client.list_ipsecpolicies()
ipsecpolicies = body['ipsecpolicies']
self.assertIn(self.ipsecpolicy['id'], [i['id'] for i in ipsecpolicies])
@@ -293,8 +279,7 @@
'pfs': 'group5',
'encryption_algorithm': "aes-128",
'auth_algorithm': 'sha1'}
- resp, resp_body = self.client.create_ipsecpolicy(**ipsec_policy_body)
- self.assertEqual('201', resp['status'])
+ _, resp_body = self.client.create_ipsecpolicy(**ipsec_policy_body)
ipsecpolicy = resp_body['ipsecpolicy']
self.addCleanup(self._delete_ipsec_policy, ipsecpolicy['id'])
self._assertExpected(ipsec_policy_body, ipsecpolicy)
@@ -304,22 +289,19 @@
'name': data_utils.rand_name("New-IPSec"),
'encryption_algorithm': "aes-256",
'lifetime': {'units': "seconds", 'value': '2000'}}
- resp, body = self.client.update_ipsecpolicy(ipsecpolicy['id'],
- **new_ipsec)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.update_ipsecpolicy(ipsecpolicy['id'],
+ **new_ipsec)
updated_ipsec_policy = body['ipsecpolicy']
self._assertExpected(new_ipsec, updated_ipsec_policy)
# Verification of ipsec policy delete
- resp, _ = self.client.delete_ipsecpolicy(ipsecpolicy['id'])
- self.assertEqual('204', resp['status'])
+ self.client.delete_ipsecpolicy(ipsecpolicy['id'])
self.assertRaises(exceptions.NotFound,
self.client.delete_ipsecpolicy, ipsecpolicy['id'])
@test.attr(type='smoke')
def test_show_ipsec_policy(self):
# Verifies the details of an ipsec policy
- resp, body = self.client.show_ipsecpolicy(self.ipsecpolicy['id'])
- self.assertEqual('200', resp['status'])
+ _, body = self.client.show_ipsecpolicy(self.ipsecpolicy['id'])
ipsecpolicy = body['ipsecpolicy']
self._assertExpected(self.ipsecpolicy, ipsecpolicy)
diff --git a/tempest/api/object_storage/test_object_temp_url.py b/tempest/api/object_storage/test_object_temp_url.py
index c597255..264a18a 100644
--- a/tempest/api/object_storage/test_object_temp_url.py
+++ b/tempest/api/object_storage/test_object_temp_url.py
@@ -185,3 +185,20 @@
resp, body = self.object_client.head(url)
self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'HEAD')
+
+ @test.attr(type='gate')
+ @test.requires_ext(extension='tempurl', service='object')
+ def test_get_object_using_temp_url_with_inline_query_parameter(self):
+ expires = self._get_expiry_date()
+
+ # get a temp URL for the created object
+ url = self._get_temp_url(self.container_name, self.object_name, "GET",
+ expires, self.key)
+ url = url + '&inline'
+
+ # trying to get object using temp url within expiry time
+ resp, body = self.object_client.get(url)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
+ self.assertHeaders(resp, 'Object', 'GET')
+ self.assertEqual(body, self.content)
+ self.assertEqual(resp['content-disposition'], 'inline')
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index cfebc2c..0b22de5 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -51,7 +51,7 @@
@classmethod
def _get_default_network(cls):
- __, networks = cls.network_client.list_networks()
+ _, networks = cls.network_client.list_networks()
for net in networks['networks']:
if net['name'] == CONF.compute.fixed_network_name:
return net
@@ -64,8 +64,10 @@
return admin_client
@classmethod
- def create_stack(cls, stack_name, template_data, parameters={},
+ def create_stack(cls, stack_name, template_data, parameters=None,
environment=None, files=None):
+ if parameters is None:
+ parameters = {}
resp, body = cls.client.create_stack(
stack_name,
template=template_data,
@@ -86,13 +88,16 @@
pass
for stack_identifier in cls.stacks:
- cls.client.wait_for_stack_status(
- stack_identifier, 'DELETE_COMPLETE')
+ try:
+ cls.client.wait_for_stack_status(
+ stack_identifier, 'DELETE_COMPLETE')
+ except exceptions.NotFound:
+ pass
@classmethod
def _create_keypair(cls, name_start='keypair-heat-'):
kp_name = data_utils.rand_name(name_start)
- __, body = cls.keypairs_client.create_keypair(kp_name)
+ _, body = cls.keypairs_client.create_keypair(kp_name)
cls.keypairs.append(kp_name)
return body
@@ -108,9 +113,9 @@
def _create_image(cls, name_start='image-heat-', container_format='bare',
disk_format='iso'):
image_name = data_utils.rand_name(name_start)
- __, body = cls.images_v2_client.create_image(image_name,
- container_format,
- disk_format)
+ _, body = cls.images_v2_client.create_image(image_name,
+ container_format,
+ disk_format)
image_id = body['id']
cls.images.append(image_id)
return body
@@ -159,8 +164,7 @@
def list_resources(self, stack_identifier):
"""Get a dict mapping of resource names to types."""
- resp, resources = self.client.list_resources(stack_identifier)
- self.assertEqual('200', resp['status'])
+ _, resources = self.client.list_resources(stack_identifier)
self.assertIsInstance(resources, list)
for res in resources:
self.assert_fields_in_dict(res, 'logical_resource_id',
@@ -171,6 +175,5 @@
for r in resources)
def get_stack_output(self, stack_identifier, output_key):
- resp, body = self.client.get_stack(stack_identifier)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.get_stack(stack_identifier)
return self.stack_output(body, output_key)
diff --git a/tempest/api/orchestration/stacks/test_neutron_resources.py b/tempest/api/orchestration/stacks/test_neutron_resources.py
index 26e3ac6..ffadb16 100644
--- a/tempest/api/orchestration/stacks/test_neutron_resources.py
+++ b/tempest/api/orchestration/stacks/test_neutron_resources.py
@@ -38,6 +38,7 @@
os = clients.Manager()
if not CONF.service_available.neutron:
raise cls.skipException("Neutron support is required")
+ cls.neutron_basic_template = cls.load_template('neutron_basic')
cls.network_client = os.network_client
cls.stack_name = data_utils.rand_name('heat')
template = cls.read_template('neutron_basic')
@@ -71,11 +72,11 @@
# attempt to log the server console to help with debugging
# the cause of the server not signalling the waitcondition
# to heat.
- resp, body = cls.client.get_resource(cls.stack_identifier,
- 'Server')
+ _, body = cls.client.get_resource(cls.stack_identifier,
+ 'Server')
server_id = body['physical_resource_id']
LOG.debug('Console output for %s', server_id)
- resp, output = cls.servers_client.get_console_output(
+ _, output = cls.servers_client.get_console_output(
server_id, None)
LOG.debug(output)
raise e
@@ -87,10 +88,14 @@
@test.attr(type='slow')
def test_created_resources(self):
"""Verifies created neutron resources."""
- resources = [('Network', 'OS::Neutron::Net'),
- ('Subnet', 'OS::Neutron::Subnet'),
- ('RouterInterface', 'OS::Neutron::RouterInterface'),
- ('Server', 'OS::Nova::Server')]
+ resources = [('Network', self.neutron_basic_template['resources'][
+ 'Network']['type']),
+ ('Subnet', self.neutron_basic_template['resources'][
+ 'Subnet']['type']),
+ ('RouterInterface', self.neutron_basic_template[
+ 'resources']['RouterInterface']['type']),
+ ('Server', self.neutron_basic_template['resources'][
+ 'Server']['type'])]
for resource_name, resource_type in resources:
resource = self.test_resources.get(resource_name, None)
self.assertIsInstance(resource, dict)
@@ -99,52 +104,56 @@
self.assertEqual('CREATE_COMPLETE', resource['resource_status'])
@test.attr(type='slow')
+ @test.services('network')
def test_created_network(self):
"""Verifies created network."""
network_id = self.test_resources.get('Network')['physical_resource_id']
- resp, body = self.network_client.show_network(network_id)
- self.assertEqual('200', resp['status'])
+ _, body = self.network_client.show_network(network_id)
network = body['network']
self.assertIsInstance(network, dict)
self.assertEqual(network_id, network['id'])
- self.assertEqual('NewNetwork', network['name'])
+ self.assertEqual(self.neutron_basic_template['resources'][
+ 'Network']['properties']['name'], network['name'])
@test.attr(type='slow')
+ @test.services('network')
def test_created_subnet(self):
"""Verifies created subnet."""
subnet_id = self.test_resources.get('Subnet')['physical_resource_id']
- resp, body = self.network_client.show_subnet(subnet_id)
- self.assertEqual('200', resp['status'])
+ _, body = self.network_client.show_subnet(subnet_id)
subnet = body['subnet']
network_id = self.test_resources.get('Network')['physical_resource_id']
self.assertEqual(subnet_id, subnet['id'])
self.assertEqual(network_id, subnet['network_id'])
- self.assertEqual('NewSubnet', subnet['name'])
+ self.assertEqual(self.neutron_basic_template['resources'][
+ 'Subnet']['properties']['name'], subnet['name'])
self.assertEqual(sorted(CONF.network.dns_servers),
sorted(subnet['dns_nameservers']))
- self.assertEqual(4, subnet['ip_version'])
+ self.assertEqual(self.neutron_basic_template['resources'][
+ 'Subnet']['properties']['ip_version'], subnet['ip_version'])
self.assertEqual(str(self.subnet_cidr), subnet['cidr'])
@test.attr(type='slow')
+ @test.services('network')
def test_created_router(self):
"""Verifies created router."""
router_id = self.test_resources.get('Router')['physical_resource_id']
- resp, body = self.network_client.show_router(router_id)
- self.assertEqual('200', resp['status'])
+ _, body = self.network_client.show_router(router_id)
router = body['router']
- self.assertEqual('NewRouter', router['name'])
+ self.assertEqual(self.neutron_basic_template['resources'][
+ 'Router']['properties']['name'], router['name'])
self.assertEqual(self.external_network_id,
router['external_gateway_info']['network_id'])
self.assertEqual(True, router['admin_state_up'])
@test.attr(type='slow')
+ @test.services('network')
def test_created_router_interface(self):
"""Verifies created router interface."""
router_id = self.test_resources.get('Router')['physical_resource_id']
network_id = self.test_resources.get('Network')['physical_resource_id']
subnet_id = self.test_resources.get('Subnet')['physical_resource_id']
- resp, body = self.network_client.list_ports()
- self.assertEqual('200', resp['status'])
+ _, body = self.network_client.list_ports()
ports = body['ports']
router_ports = filter(lambda port: port['device_id'] ==
router_id, ports)
@@ -161,13 +170,14 @@
router_interface_ip)
@test.attr(type='slow')
+ @test.services('compute', 'network')
def test_created_server(self):
"""Verifies created sever."""
server_id = self.test_resources.get('Server')['physical_resource_id']
- resp, server = self.servers_client.get_server(server_id)
- self.assertEqual('200', resp['status'])
+ _, server = self.servers_client.get_server(server_id)
self.assertEqual(self.keypair_name, server['key_name'])
self.assertEqual('ACTIVE', server['status'])
- network = server['addresses']['NewNetwork'][0]
+ network = server['addresses'][self.neutron_basic_template['resources'][
+ 'Network']['properties']['name']][0]
self.assertEqual(4, network['version'])
self.assertIn(netaddr.IPAddress(network['addr']), self.subnet_cidr)
diff --git a/tempest/api/orchestration/stacks/test_non_empty_stack.py b/tempest/api/orchestration/stacks/test_non_empty_stack.py
index a97c561..72ad5f5 100644
--- a/tempest/api/orchestration/stacks/test_non_empty_stack.py
+++ b/tempest/api/orchestration/stacks/test_non_empty_stack.py
@@ -45,8 +45,7 @@
cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
def _list_stacks(self, expected_num=None, **filter_kwargs):
- resp, stacks = self.client.list_stacks(params=filter_kwargs)
- self.assertEqual('200', resp['status'])
+ _, stacks = self.client.list_stacks(params=filter_kwargs)
self.assertIsInstance(stacks, list)
if expected_num is not None:
self.assertEqual(expected_num, len(stacks))
@@ -62,8 +61,7 @@
@test.attr(type='gate')
def test_stack_show(self):
"""Getting details about created stack should be possible."""
- resp, stack = self.client.get_stack(self.stack_name)
- self.assertEqual('200', resp['status'])
+ _, stack = self.client.get_stack(self.stack_name)
self.assertIsInstance(stack, dict)
self.assert_fields_in_dict(stack, 'stack_name', 'id', 'links',
'parameters', 'outputs', 'disable_rollback',
@@ -82,12 +80,10 @@
@test.attr(type='gate')
def test_suspend_resume_stack(self):
"""Suspend and resume a stack."""
- resp, suspend_stack = self.client.suspend_stack(self.stack_identifier)
- self.assertEqual('200', resp['status'])
+ _, suspend_stack = self.client.suspend_stack(self.stack_identifier)
self.client.wait_for_stack_status(self.stack_identifier,
'SUSPEND_COMPLETE')
- resp, resume_stack = self.client.resume_stack(self.stack_identifier)
- self.assertEqual('200', resp['status'])
+ _, resume_stack = self.client.resume_stack(self.stack_identifier)
self.client.wait_for_stack_status(self.stack_identifier,
'RESUME_COMPLETE')
@@ -101,8 +97,8 @@
@test.attr(type='gate')
def test_show_resource(self):
"""Getting details about created resource should be possible."""
- resp, resource = self.client.get_resource(self.stack_identifier,
- self.resource_name)
+ _, resource = self.client.get_resource(self.stack_identifier,
+ self.resource_name)
self.assertIsInstance(resource, dict)
self.assert_fields_in_dict(resource, 'resource_name', 'description',
'links', 'logical_resource_id',
@@ -115,18 +111,16 @@
@test.attr(type='gate')
def test_resource_metadata(self):
"""Getting metadata for created resources should be possible."""
- resp, metadata = self.client.show_resource_metadata(
+ _, metadata = self.client.show_resource_metadata(
self.stack_identifier,
self.resource_name)
- self.assertEqual('200', resp['status'])
self.assertIsInstance(metadata, dict)
self.assertEqual(['Tom', 'Stinky'], metadata.get('kittens', None))
@test.attr(type='gate')
def test_list_events(self):
"""Getting list of created events for the stack should be possible."""
- resp, events = self.client.list_events(self.stack_identifier)
- self.assertEqual('200', resp['status'])
+ _, events = self.client.list_events(self.stack_identifier)
self.assertIsInstance(events, list)
for event in events:
@@ -141,14 +135,13 @@
@test.attr(type='gate')
def test_show_event(self):
"""Getting details about an event should be possible."""
- resp, events = self.client.list_resource_events(self.stack_identifier,
- self.resource_name)
+ _, events = self.client.list_resource_events(self.stack_identifier,
+ self.resource_name)
self.assertNotEqual([], events)
events.sort(key=lambda event: event['event_time'])
event_id = events[0]['id']
- resp, event = self.client.show_event(self.stack_identifier,
- self.resource_name, event_id)
- self.assertEqual('200', resp['status'])
+ _, event = self.client.show_event(self.stack_identifier,
+ self.resource_name, event_id)
self.assertIsInstance(event, dict)
self.assert_fields_in_dict(event, 'resource_name', 'event_time',
'links', 'logical_resource_id',
diff --git a/tempest/api/orchestration/stacks/test_nova_keypair_resources.py b/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
index c6f880b..2f58611 100644
--- a/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
+++ b/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
@@ -70,8 +70,7 @@
@test.attr(type='gate')
def test_stack_keypairs_output(self):
- resp, stack = self.client.get_stack(self.stack_name)
- self.assertEqual('200', resp['status'])
+ _, stack = self.client.get_stack(self.stack_name)
self.assertIsInstance(stack, dict)
output_map = {}
diff --git a/tempest/api/orchestration/stacks/test_resource_types.py b/tempest/api/orchestration/stacks/test_resource_types.py
new file mode 100644
index 0000000..e204894
--- /dev/null
+++ b/tempest/api/orchestration/stacks/test_resource_types.py
@@ -0,0 +1,44 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.orchestration import base
+from tempest import test
+
+
+class ResourceTypesTest(base.BaseOrchestrationTest):
+
+ @test.attr(type='smoke')
+ def test_resource_type_list(self):
+ """Verify it is possible to list resource types."""
+ resource_types = self.client.list_resource_types()
+ self.assertIsInstance(resource_types, list)
+ self.assertIn('OS::Nova::Server', resource_types)
+
+ @test.attr(type='smoke')
+ def test_resource_type_show(self):
+ """Verify it is possible to get schema about resource types."""
+ resource_types = self.client.list_resource_types()
+ self.assertNotEmpty(resource_types)
+
+ for resource_type in resource_types:
+ type_schema = self.client.get_resource_type(resource_type)
+ self.assert_fields_in_dict(type_schema, 'properties',
+ 'attributes', 'resource_type')
+ self.assertEqual(resource_type, type_schema['resource_type'])
+
+ @test.attr(type='smoke')
+ def test_resource_type_template(self):
+ """Verify it is possible to get template about resource types."""
+ type_template = self.client.get_resource_type_template(
+ 'OS::Nova::Server')
+ self.assert_fields_in_dict(type_template, 'Outputs',
+ 'Parameters', 'Resources')
\ No newline at end of file
diff --git a/tempest/api/orchestration/stacks/test_stacks.py b/tempest/api/orchestration/stacks/test_stacks.py
index d5e66e8..8023f2c 100644
--- a/tempest/api/orchestration/stacks/test_stacks.py
+++ b/tempest/api/orchestration/stacks/test_stacks.py
@@ -28,8 +28,7 @@
@test.attr(type='smoke')
def test_stack_list_responds(self):
- resp, stacks = self.client.list_stacks()
- self.assertEqual('200', resp['status'])
+ _, stacks = self.client.list_stacks()
self.assertIsInstance(stacks, list)
@test.attr(type='smoke')
@@ -45,23 +44,22 @@
self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
# check for stack in list
- resp, stacks = self.client.list_stacks()
+ _, stacks = self.client.list_stacks()
list_ids = list([stack['id'] for stack in stacks])
self.assertIn(stack_id, list_ids)
# fetch the stack
- resp, stack = self.client.get_stack(stack_identifier)
+ _, stack = self.client.get_stack(stack_identifier)
self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
# fetch the stack by name
- resp, stack = self.client.get_stack(stack_name)
+ _, stack = self.client.get_stack(stack_name)
self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
# fetch the stack by id
- resp, stack = self.client.get_stack(stack_id)
+ _, stack = self.client.get_stack(stack_id)
self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
# delete the stack
- resp = self.client.delete_stack(stack_identifier)
- self.assertEqual('204', resp[0]['status'])
+ self.client.delete_stack(stack_identifier)
self.client.wait_for_stack_status(stack_identifier, 'DELETE_COMPLETE')
diff --git a/tempest/api/orchestration/stacks/test_swift_resources.py b/tempest/api/orchestration/stacks/test_swift_resources.py
index adab8c3..cbe62a1 100644
--- a/tempest/api/orchestration/stacks/test_swift_resources.py
+++ b/tempest/api/orchestration/stacks/test_swift_resources.py
@@ -61,15 +61,16 @@
self.assertEqual(resource_name, resource['logical_resource_id'])
self.assertEqual('CREATE_COMPLETE', resource['resource_status'])
+ @test.services('object_storage')
def test_created_containers(self):
params = {'format': 'json'}
- resp, container_list = \
+ _, container_list = \
self.account_client.list_account_containers(params=params)
- self.assertEqual('200', resp['status'])
self.assertEqual(2, len(container_list))
for cont in container_list:
self.assertTrue(cont['name'].startswith(self.stack_name))
+ @test.services('object_storage')
def test_acl(self):
acl_headers = ('x-container-meta-web-index', 'x-container-read')
@@ -86,6 +87,7 @@
for h in acl_headers:
self.assertIn(h, headers)
+ @test.services('object_storage')
def test_metadata(self):
swift_basic_template = self.load_template('swift_basic')
metadatas = swift_basic_template['resources']['SwiftContainerWebsite'][
diff --git a/tempest/api/orchestration/stacks/test_templates.py b/tempest/api/orchestration/stacks/test_templates.py
index 74950a9..0d6060d 100644
--- a/tempest/api/orchestration/stacks/test_templates.py
+++ b/tempest/api/orchestration/stacks/test_templates.py
@@ -39,15 +39,13 @@
@test.attr(type='gate')
def test_show_template(self):
"""Getting template used to create the stack."""
- resp, template = self.client.show_template(self.stack_identifier)
- self.assertEqual('200', resp['status'])
+ _, template = self.client.show_template(self.stack_identifier)
@test.attr(type='gate')
def test_validate_template(self):
"""Validating template passing it content."""
- resp, parameters = self.client.validate_template(self.template,
- self.parameters)
- self.assertEqual('200', resp['status'])
+ _, parameters = self.client.validate_template(self.template,
+ self.parameters)
class TemplateAWSTestJSON(TemplateYAMLTestJSON):
diff --git a/tempest/api/orchestration/stacks/test_update.py b/tempest/api/orchestration/stacks/test_update.py
index a9a43b6..791a19b 100644
--- a/tempest/api/orchestration/stacks/test_update.py
+++ b/tempest/api/orchestration/stacks/test_update.py
@@ -40,11 +40,10 @@
def update_stack(self, stack_identifier, template):
stack_name = stack_identifier.split('/')[0]
- resp = self.client.update_stack(
+ self.client.update_stack(
stack_identifier=stack_identifier,
name=stack_name,
template=template)
- self.assertEqual('202', resp[0]['status'])
self.client.wait_for_stack_status(stack_identifier, 'UPDATE_COMPLETE')
@test.attr(type='gate')
diff --git a/tempest/api/orchestration/stacks/test_volumes.py b/tempest/api/orchestration/stacks/test_volumes.py
index d422752..f371370 100644
--- a/tempest/api/orchestration/stacks/test_volumes.py
+++ b/tempest/api/orchestration/stacks/test_volumes.py
@@ -33,8 +33,7 @@
def _cinder_verify(self, volume_id, template):
self.assertIsNotNone(volume_id)
- resp, volume = self.volumes_client.get_volume(volume_id)
- self.assertEqual(200, resp.status)
+ _, volume = self.volumes_client.get_volume(volume_id)
self.assertEqual('available', volume.get('status'))
self.assertEqual(template['resources']['volume']['properties'][
'size'], volume.get('size'))
@@ -55,6 +54,7 @@
'name'], self.get_stack_output(stack_identifier, 'display_name'))
@test.attr(type='gate')
+ @test.services('volume')
def test_cinder_volume_create_delete(self):
"""Create and delete a volume via OS::Cinder::Volume."""
stack_name = data_utils.rand_name('heat')
@@ -79,11 +79,11 @@
def _cleanup_volume(self, volume_id):
"""Cleanup the volume direct with cinder."""
- resp = self.volumes_client.delete_volume(volume_id)
- self.assertEqual(202, resp[0].status)
+ self.volumes_client.delete_volume(volume_id)
self.volumes_client.wait_for_resource_deletion(volume_id)
@test.attr(type='gate')
+ @test.services('volume')
def test_cinder_volume_create_delete_retain(self):
"""Ensure the 'Retain' deletion policy is respected."""
stack_name = data_utils.rand_name('heat')
diff --git a/tempest/api/queuing/base.py b/tempest/api/queuing/base.py
index f4ff7f1..41a02f2 100644
--- a/tempest/api/queuing/base.py
+++ b/tempest/api/queuing/base.py
@@ -26,7 +26,7 @@
class BaseQueuingTest(test.BaseTestCase):
"""
- Base class for the Queuing tests that use the Tempest Marconi REST client
+ Base class for the Queuing tests that use the Tempest Zaqar REST client
It is assumed that the following option is defined in the
[service_available] section of etc/tempest.conf
@@ -37,8 +37,8 @@
@classmethod
def setUpClass(cls):
super(BaseQueuingTest, cls).setUpClass()
- if not CONF.service_available.marconi:
- raise cls.skipException("Marconi support is required")
+ if not CONF.service_available.zaqar:
+ raise cls.skipException("Zaqar support is required")
os = cls.get_client_manager()
cls.queuing_cfg = CONF.queuing
cls.client = os.queuing_client
diff --git a/tempest/api/telemetry/base.py b/tempest/api/telemetry/base.py
index b5b2bb1..8c2f37b 100644
--- a/tempest/api/telemetry/base.py
+++ b/tempest/api/telemetry/base.py
@@ -29,6 +29,7 @@
def setUpClass(cls):
if not CONF.service_available.ceilometer:
raise cls.skipException("Ceilometer support is required")
+ cls.set_network_resources()
super(BaseTelemetryTest, cls).setUpClass()
os = cls.get_client_manager()
cls.telemetry_client = os.telemetry_client
diff --git a/tempest/api/volume/admin/test_multi_backend.py b/tempest/api/volume/admin/test_multi_backend.py
index d451517..f3b1ad5 100644
--- a/tempest/api/volume/admin/test_multi_backend.py
+++ b/tempest/api/volume/admin/test_multi_backend.py
@@ -61,11 +61,11 @@
extra_specs = {spec_key_with_prefix: backend_name_key}
else:
extra_specs = {spec_key_without_prefix: backend_name_key}
- resp, self.type = self.client.create_volume_type(
+ _, self.type = self.client.create_volume_type(
type_name, extra_specs=extra_specs)
self.volume_type_id_list.append(self.type['id'])
- resp, self.volume = self.volume_client.create_volume(
+ _, self.volume = self.volume_client.create_volume(
size=1, display_name=vol_name, volume_type=type_name)
self.volume_client.wait_for_volume_status(
self.volume['id'], 'available')
@@ -130,8 +130,7 @@
# the multi backend feature has been enabled
# if multi-backend is enabled: os-vol-attr:host should be like:
# host@backend_name
- resp, volume = self.volume_client.get_volume(volume_id)
- self.assertEqual(200, resp.status)
+ _, volume = self.volume_client.get_volume(volume_id)
volume1_host = volume['os-vol-host-attr:host']
msg = ("multi-backend reporting incorrect values for volume %s" %
@@ -142,10 +141,10 @@
# this test checks that the two volumes created at setUp don't
# belong to the same backend (if they are, than the
# volume backend distinction is not working properly)
- resp, volume = self.volume_client.get_volume(volume1_id)
+ _, volume = self.volume_client.get_volume(volume1_id)
volume1_host = volume['os-vol-host-attr:host']
- resp, volume = self.volume_client.get_volume(volume2_id)
+ _, volume = self.volume_client.get_volume(volume2_id)
volume2_host = volume['os-vol-host-attr:host']
msg = ("volumes %s and %s were created in the same backend" %
diff --git a/tempest/api/volume/admin/test_snapshots_actions.py b/tempest/api/volume/admin/test_snapshots_actions.py
index 594c703..abbe1e9 100644
--- a/tempest/api/volume/admin/test_snapshots_actions.py
+++ b/tempest/api/volume/admin/test_snapshots_actions.py
@@ -32,14 +32,14 @@
# Create a test shared volume for tests
vol_name = data_utils.rand_name(cls.__name__ + '-Volume-')
- resp_vol, cls.volume = \
+ _, cls.volume = \
cls.volumes_client.create_volume(size=1, display_name=vol_name)
cls.volumes_client.wait_for_volume_status(cls.volume['id'],
'available')
# Create a test shared snapshot for tests
snap_name = data_utils.rand_name(cls.__name__ + '-Snapshot-')
- resp_snap, cls.snapshot = \
+ _, cls.snapshot = \
cls.client.create_snapshot(cls.volume['id'],
display_name=snap_name)
cls.client.wait_for_snapshot_status(cls.snapshot['id'],
@@ -70,12 +70,10 @@
# and force delete temp snapshot
temp_snapshot = self.create_snapshot(self.volume['id'])
if status:
- resp, body = self.admin_snapshots_client.\
+ _, body = self.admin_snapshots_client.\
reset_snapshot_status(temp_snapshot['id'], status)
- self.assertEqual(202, resp.status)
- resp_delete, volume_delete = self.admin_snapshots_client.\
+ _, volume_delete = self.admin_snapshots_client.\
force_delete_snapshot(temp_snapshot['id'])
- self.assertEqual(202, resp_delete.status)
self.client.wait_for_resource_deletion(temp_snapshot['id'])
def _get_progress_alias(self):
@@ -85,12 +83,10 @@
def test_reset_snapshot_status(self):
# Reset snapshot status to creating
status = 'creating'
- resp, body = self.admin_snapshots_client.\
+ _, body = self.admin_snapshots_client.\
reset_snapshot_status(self.snapshot['id'], status)
- self.assertEqual(202, resp.status)
- resp_get, snapshot_get \
+ _, snapshot_get \
= self.admin_snapshots_client.get_snapshot(self.snapshot['id'])
- self.assertEqual(200, resp_get.status)
self.assertEqual(status, snapshot_get['status'])
@test.attr(type='gate')
@@ -104,12 +100,10 @@
progress = '80%'
status = 'error'
progress_alias = self._get_progress_alias()
- resp, body = self.client.update_snapshot_status(self.snapshot['id'],
- status, progress)
- self.assertEqual(202, resp.status)
- resp_get, snapshot_get \
+ _, body = self.client.update_snapshot_status(self.snapshot['id'],
+ status, progress)
+ _, snapshot_get \
= self.admin_snapshots_client.get_snapshot(self.snapshot['id'])
- self.assertEqual(200, resp_get.status)
self.assertEqual(status, snapshot_get['status'])
self.assertEqual(progress, snapshot_get[progress_alias])
diff --git a/tempest/api/volume/admin/test_volume_hosts.py b/tempest/api/volume/admin/test_volume_hosts.py
index 01ba915..017363d 100644
--- a/tempest/api/volume/admin/test_volume_hosts.py
+++ b/tempest/api/volume/admin/test_volume_hosts.py
@@ -22,8 +22,7 @@
@test.attr(type='gate')
def test_list_hosts(self):
- resp, hosts = self.hosts_client.list_hosts()
- self.assertEqual(200, resp.status)
+ _, hosts = self.hosts_client.list_hosts()
self.assertTrue(len(hosts) >= 2, "No. of hosts are < 2,"
"response of list hosts is: % s" % hosts)
diff --git a/tempest/api/volume/admin/test_volume_quotas.py b/tempest/api/volume/admin/test_volume_quotas.py
index ecd8836..fa3b667 100644
--- a/tempest/api/volume/admin/test_volume_quotas.py
+++ b/tempest/api/volume/admin/test_volume_quotas.py
@@ -34,30 +34,28 @@
@test.attr(type='gate')
def test_list_quotas(self):
- resp, quotas = self.quotas_client.get_quota_set(self.demo_tenant_id)
- self.assertEqual(200, resp.status)
+ _, quotas = self.quotas_client.get_quota_set(self.demo_tenant_id)
for key in QUOTA_KEYS:
self.assertIn(key, quotas)
@test.attr(type='gate')
def test_list_default_quotas(self):
- resp, quotas = self.quotas_client.get_default_quota_set(
+ _, quotas = self.quotas_client.get_default_quota_set(
self.demo_tenant_id)
- self.assertEqual(200, resp.status)
for key in QUOTA_KEYS:
self.assertIn(key, quotas)
@test.attr(type='gate')
def test_update_all_quota_resources_for_tenant(self):
# Admin can update all the resource quota limits for a tenant
- resp, default_quota_set = self.quotas_client.get_default_quota_set(
+ _, default_quota_set = self.quotas_client.get_default_quota_set(
self.demo_tenant_id)
new_quota_set = {'gigabytes': 1009,
'volumes': 11,
'snapshots': 11}
# Update limits for all quota resources
- resp, quota_set = self.quotas_client.update_quota_set(
+ _, quota_set = self.quotas_client.update_quota_set(
self.demo_tenant_id,
**new_quota_set)
@@ -66,7 +64,6 @@
if k in QUOTA_KEYS)
self.addCleanup(self.quotas_client.update_quota_set,
self.demo_tenant_id, **cleanup_quota_set)
- self.assertEqual(200, resp.status)
# test that the specific values we set are actually in
# the final result. There is nothing here that ensures there
# would be no other values in there.
@@ -74,8 +71,7 @@
@test.attr(type='gate')
def test_show_quota_usage(self):
- resp, quota_usage = self.quotas_client.get_quota_usage(self.adm_tenant)
- self.assertEqual(200, resp.status)
+ _, quota_usage = self.quotas_client.get_quota_usage(self.adm_tenant)
for key in QUOTA_KEYS:
self.assertIn(key, quota_usage)
for usage_key in QUOTA_USAGE_KEYS:
@@ -83,17 +79,16 @@
@test.attr(type='gate')
def test_quota_usage(self):
- resp, quota_usage = self.quotas_client.get_quota_usage(
+ _, quota_usage = self.quotas_client.get_quota_usage(
self.demo_tenant_id)
volume = self.create_volume(size=1)
self.addCleanup(self.admin_volume_client.delete_volume,
volume['id'])
- resp, new_quota_usage = self.quotas_client.get_quota_usage(
+ _, new_quota_usage = self.quotas_client.get_quota_usage(
self.demo_tenant_id)
- self.assertEqual(200, resp.status)
self.assertEqual(quota_usage['volumes']['in_use'] + 1,
new_quota_usage['volumes']['in_use'])
@@ -115,9 +110,7 @@
self.quotas_client.update_quota_set(tenant_id,
volumes=(int(volume_default) + 5))
- resp, _ = self.quotas_client.delete_quota_set(tenant_id)
- self.assertEqual(200, resp.status)
-
+ self.quotas_client.delete_quota_set(tenant_id)
_, quota_set_new = self.quotas_client.get_quota_set(tenant_id)
self.assertEqual(volume_default, quota_set_new['volumes'])
diff --git a/tempest/api/volume/admin/test_volume_quotas_negative.py b/tempest/api/volume/admin/test_volume_quotas_negative.py
index ab88b90..515024f 100644
--- a/tempest/api/volume/admin/test_volume_quotas_negative.py
+++ b/tempest/api/volume/admin/test_volume_quotas_negative.py
@@ -32,7 +32,7 @@
# NOTE(gfidente): no need to restore original quota set
# after the tests as they only work with tenant isolation.
- resp, quota_set = cls.quotas_client.update_quota_set(
+ _, quota_set = cls.quotas_client.update_quota_set(
cls.demo_tenant_id,
**cls.shared_quota_set)
@@ -63,7 +63,7 @@
**self.shared_quota_set)
new_quota_set = {'gigabytes': 2, 'volumes': 2, 'snapshots': 1}
- resp, quota_set = self.quotas_client.update_quota_set(
+ _, quota_set = self.quotas_client.update_quota_set(
self.demo_tenant_id,
**new_quota_set)
self.assertRaises(exceptions.OverLimit,
@@ -71,7 +71,7 @@
size=1)
new_quota_set = {'gigabytes': 2, 'volumes': 1, 'snapshots': 2}
- resp, quota_set = self.quotas_client.update_quota_set(
+ _, quota_set = self.quotas_client.update_quota_set(
self.demo_tenant_id,
**self.shared_quota_set)
self.assertRaises(exceptions.OverLimit,
diff --git a/tempest/api/volume/admin/test_volume_services.py b/tempest/api/volume/admin/test_volume_services.py
index 012c231..4a68e05 100644
--- a/tempest/api/volume/admin/test_volume_services.py
+++ b/tempest/api/volume/admin/test_volume_services.py
@@ -28,21 +28,19 @@
def setUpClass(cls):
super(VolumesServicesTestJSON, cls).setUpClass()
cls.client = cls.os_adm.volume_services_client
- resp, cls.services = cls.client.list_services()
+ _, cls.services = cls.client.list_services()
cls.host_name = cls.services[0]['host']
cls.binary_name = cls.services[0]['binary']
@test.attr(type='gate')
def test_list_services(self):
- resp, services = self.client.list_services()
- self.assertEqual(200, resp.status)
+ _, services = self.client.list_services()
self.assertNotEqual(0, len(services))
@test.attr(type='gate')
def test_get_service_by_service_binary_name(self):
params = {'binary': self.binary_name}
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
+ _, services = self.client.list_services(params)
self.assertNotEqual(0, len(services))
for service in services:
self.assertEqual(self.binary_name, service['binary'])
@@ -53,7 +51,7 @@
service['host'] == self.host_name]
params = {'host': self.host_name}
- resp, services = self.client.list_services(params)
+ _, services = self.client.list_services(params)
# we could have a periodic job checkin between the 2 service
# lookups, so only compare binary lists.
@@ -67,8 +65,7 @@
def test_get_service_by_service_and_host_name(self):
params = {'host': self.host_name, 'binary': self.binary_name}
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
+ _, services = self.client.list_services(params)
self.assertEqual(1, len(services))
self.assertEqual(self.host_name, services[0]['host'])
self.assertEqual(self.binary_name, services[0]['binary'])
diff --git a/tempest/api/volume/admin/test_volume_types.py b/tempest/api/volume/admin/test_volume_types.py
index 3b8c214..070d38f 100644
--- a/tempest/api/volume/admin/test_volume_types.py
+++ b/tempest/api/volume/admin/test_volume_types.py
@@ -25,19 +25,16 @@
_interface = "json"
def _delete_volume(self, volume_id):
- resp, _ = self.volumes_client.delete_volume(volume_id)
- self.assertEqual(202, resp.status)
+ self.volumes_client.delete_volume(volume_id)
self.volumes_client.wait_for_resource_deletion(volume_id)
def _delete_volume_type(self, volume_type_id):
- resp, _ = self.client.delete_volume_type(volume_type_id)
- self.assertEqual(202, resp.status)
+ self.client.delete_volume_type(volume_type_id)
@test.attr(type='smoke')
def test_volume_type_list(self):
# List Volume types.
- resp, body = self.client.list_volume_types()
- self.assertEqual(200, resp.status)
+ _, body = self.client.list_volume_types()
self.assertIsInstance(body, list)
@test.attr(type='smoke')
@@ -51,17 +48,15 @@
extra_specs = {"storage_protocol": proto,
"vendor_name": vendor}
body = {}
- resp, body = self.client.create_volume_type(
+ _, body = self.client.create_volume_type(
vol_type_name,
extra_specs=extra_specs)
- self.assertEqual(200, resp.status)
self.assertIn('id', body)
self.addCleanup(self._delete_volume_type, body['id'])
self.assertIn('name', body)
- resp, volume = self.volumes_client.create_volume(
+ _, volume = self.volumes_client.create_volume(
size=1, display_name=vol_name,
volume_type=vol_type_name)
- self.assertEqual(200, resp.status)
self.assertIn('id', volume)
self.addCleanup(self._delete_volume, volume['id'])
self.assertIn('display_name', volume)
@@ -72,8 +67,7 @@
"Field volume id is empty or not found.")
self.volumes_client.wait_for_volume_status(volume['id'],
'available')
- resp, fetched_volume = self.volumes_client.get_volume(volume['id'])
- self.assertEqual(200, resp.status)
+ _, fetched_volume = self.volumes_client.get_volume(volume['id'])
self.assertEqual(vol_name, fetched_volume['display_name'],
'The fetched Volume is different '
'from the created Volume')
@@ -93,10 +87,9 @@
vendor = CONF.volume.vendor_name
extra_specs = {"storage_protocol": proto,
"vendor_name": vendor}
- resp, body = self.client.create_volume_type(
+ _, body = self.client.create_volume_type(
name,
extra_specs=extra_specs)
- self.assertEqual(200, resp.status)
self.assertIn('id', body)
self.addCleanup(self._delete_volume_type, body['id'])
self.assertIn('name', body)
@@ -105,8 +98,7 @@
"to the requested name")
self.assertTrue(body['id'] is not None,
"Field volume_type id is empty or not found.")
- resp, fetched_volume_type = self.client.get_volume_type(body['id'])
- self.assertEqual(200, resp.status)
+ _, fetched_volume_type = self.client.get_volume_type(body['id'])
self.assertEqual(name, fetched_volume_type['name'],
'The fetched Volume_type is different '
'from the created Volume_type')
@@ -123,15 +115,13 @@
provider = "LuksEncryptor"
control_location = "front-end"
name = data_utils.rand_name("volume-type-")
- resp, body = self.client.create_volume_type(name)
- self.assertEqual(200, resp.status)
+ _, body = self.client.create_volume_type(name)
self.addCleanup(self._delete_volume_type, body['id'])
# Create encryption type
- resp, encryption_type = self.client.create_encryption_type(
+ _, encryption_type = self.client.create_encryption_type(
body['id'], provider=provider,
control_location=control_location)
- self.assertEqual(200, resp.status)
self.assertIn('volume_type_id', encryption_type)
self.assertEqual(provider, encryption_type['provider'],
"The created encryption_type provider is not equal "
@@ -141,9 +131,8 @@
"equal to the requested control_location")
# Get encryption type
- resp, fetched_encryption_type = self.client.get_encryption_type(
+ _, fetched_encryption_type = self.client.get_encryption_type(
encryption_type['volume_type_id'])
- self.assertEqual(200, resp.status)
self.assertEqual(provider,
fetched_encryption_type['provider'],
'The fetched encryption_type provider is different '
@@ -154,13 +143,11 @@
'different from the created encryption_type')
# Delete encryption type
- resp, _ = self.client.delete_encryption_type(
+ self.client.delete_encryption_type(
encryption_type['volume_type_id'])
- self.assertEqual(202, resp.status)
resource = {"id": encryption_type['volume_type_id'],
"type": "encryption-type"}
self.client.wait_for_resource_deletion(resource)
- resp, deleted_encryption_type = self.client.get_encryption_type(
+ _, deleted_encryption_type = self.client.get_encryption_type(
encryption_type['volume_type_id'])
- self.assertEqual(200, resp.status)
self.assertEmpty(deleted_encryption_type)
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 06a0b34..c682866 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs.py
@@ -25,7 +25,7 @@
def setUpClass(cls):
super(VolumeTypesExtraSpecsTest, cls).setUpClass()
vol_type_name = data_utils.rand_name('Volume-type-')
- resp, cls.volume_type = cls.client.create_volume_type(vol_type_name)
+ _, cls.volume_type = cls.client.create_volume_type(vol_type_name)
@classmethod
def tearDownClass(cls):
@@ -36,14 +36,12 @@
def test_volume_type_extra_specs_list(self):
# List Volume types extra specs.
extra_specs = {"spec1": "val1"}
- resp, body = self.client.create_volume_type_extra_specs(
+ _, body = self.client.create_volume_type_extra_specs(
self.volume_type['id'], extra_specs)
- self.assertEqual(200, resp.status)
self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly created")
- resp, body = self.client.list_volume_types_extra_specs(
+ _, body = self.client.list_volume_types_extra_specs(
self.volume_type['id'])
- self.assertEqual(200, resp.status)
self.assertIsInstance(body, dict)
self.assertIn('spec1', body)
@@ -51,18 +49,16 @@
def test_volume_type_extra_specs_update(self):
# Update volume type extra specs
extra_specs = {"spec2": "val1"}
- resp, body = self.client.create_volume_type_extra_specs(
+ _, body = self.client.create_volume_type_extra_specs(
self.volume_type['id'], extra_specs)
- self.assertEqual(200, resp.status)
self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly created")
extra_spec = {"spec2": "val2"}
- resp, body = self.client.update_volume_type_extra_specs(
+ _, body = self.client.update_volume_type_extra_specs(
self.volume_type['id'],
extra_spec.keys()[0],
extra_spec)
- self.assertEqual(200, resp.status)
self.assertIn('spec2', body)
self.assertEqual(extra_spec['spec2'], body['spec2'],
"Volume type extra spec incorrectly updated")
@@ -71,21 +67,18 @@
def test_volume_type_extra_spec_create_get_delete(self):
# Create/Get/Delete volume type extra spec.
extra_specs = {"spec3": "val1"}
- resp, body = self.client.create_volume_type_extra_specs(
+ _, body = self.client.create_volume_type_extra_specs(
self.volume_type['id'],
extra_specs)
- self.assertEqual(200, resp.status)
self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly created")
- resp, _ = self.client.get_volume_type_extra_specs(
+ self.client.get_volume_type_extra_specs(
self.volume_type['id'],
extra_specs.keys()[0])
- self.assertEqual(200, resp.status)
self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly fetched")
- resp, _ = self.client.delete_volume_type_extra_specs(
+ self.client.delete_volume_type_extra_specs(
self.volume_type['id'],
extra_specs.keys()[0])
- self.assertEqual(202, resp.status)
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
index da421dc..ff4f113 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
@@ -29,7 +29,7 @@
super(ExtraSpecsNegativeTest, cls).setUpClass()
vol_type_name = data_utils.rand_name('Volume-type-')
cls.extra_specs = {"spec1": "val1"}
- resp, cls.volume_type = cls.client.create_volume_type(
+ _, cls.volume_type = cls.client.create_volume_type(
vol_type_name,
extra_specs=cls.extra_specs)
diff --git a/tempest/api/volume/admin/test_volumes_actions.py b/tempest/api/volume/admin/test_volumes_actions.py
index 008f739..d6db1df 100644
--- a/tempest/api/volume/admin/test_volumes_actions.py
+++ b/tempest/api/volume/admin/test_volumes_actions.py
@@ -33,8 +33,8 @@
# Create a test shared volume for tests
vol_name = utils.rand_name(cls.__name__ + '-Volume-')
- resp, cls.volume = cls.client.create_volume(size=1,
- display_name=vol_name)
+ _, cls.volume = cls.client.create_volume(size=1,
+ display_name=vol_name)
cls.client.wait_for_volume_status(cls.volume['id'], 'available')
@classmethod
@@ -47,9 +47,9 @@
def _reset_volume_status(self, volume_id, status):
# Reset the volume status
- resp, body = self.admin_volume_client.reset_volume_status(volume_id,
- status)
- return resp, body
+ _, body = self.admin_volume_client.reset_volume_status(volume_id,
+ status)
+ return _, body
def tearDown(self):
# Set volume's status to available after test
@@ -59,8 +59,8 @@
def _create_temp_volume(self):
# Create a temp volume for force delete tests
vol_name = utils.rand_name('Volume')
- resp, temp_volume = self.client.create_volume(size=1,
- display_name=vol_name)
+ _, temp_volume = self.client.create_volume(size=1,
+ display_name=vol_name)
self.client.wait_for_volume_status(temp_volume['id'], 'available')
return temp_volume
@@ -69,19 +69,16 @@
# Create volume, reset volume status, and force delete temp volume
temp_volume = self._create_temp_volume()
if status:
- resp, body = self._reset_volume_status(temp_volume['id'], status)
- self.assertEqual(202, resp.status)
- resp_delete, volume_delete = self.admin_volume_client.\
+ _, body = self._reset_volume_status(temp_volume['id'], status)
+ _, volume_delete = self.admin_volume_client.\
force_delete_volume(temp_volume['id'])
- self.assertEqual(202, resp_delete.status)
self.client.wait_for_resource_deletion(temp_volume['id'])
@test.attr(type='gate')
def test_volume_reset_status(self):
# test volume reset status : available->error->available
- resp, body = self._reset_volume_status(self.volume['id'], 'error')
- self.assertEqual(202, resp.status)
- resp_get, volume_get = self.admin_volume_client.get_volume(
+ _, body = self._reset_volume_status(self.volume['id'], 'error')
+ _, volume_get = self.admin_volume_client.get_volume(
self.volume['id'])
self.assertEqual('error', volume_get['status'])
diff --git a/tempest/api/volume/admin/test_volumes_backup.py b/tempest/api/volume/admin/test_volumes_backup.py
index f9fbe18..3699e9c 100644
--- a/tempest/api/volume/admin/test_volumes_backup.py
+++ b/tempest/api/volume/admin/test_volumes_backup.py
@@ -43,9 +43,8 @@
# Create backup
backup_name = data_utils.rand_name('Backup')
create_backup = self.backups_adm_client.create_backup
- resp, backup = create_backup(self.volume['id'],
- name=backup_name)
- self.assertEqual(202, resp.status)
+ _, backup = create_backup(self.volume['id'],
+ name=backup_name)
self.addCleanup(self.backups_adm_client.delete_backup,
backup['id'])
self.assertEqual(backup_name, backup['name'])
@@ -55,19 +54,16 @@
'available')
# Get a given backup
- resp, backup = self.backups_adm_client.get_backup(backup['id'])
- self.assertEqual(200, resp.status)
+ _, backup = self.backups_adm_client.get_backup(backup['id'])
self.assertEqual(backup_name, backup['name'])
# Get all backups with detail
- resp, backups = self.backups_adm_client.list_backups_with_detail()
- self.assertEqual(200, resp.status)
+ _, backups = self.backups_adm_client.list_backups_with_detail()
self.assertIn((backup['name'], backup['id']),
[(m['name'], m['id']) for m in backups])
# Restore backup
- resp, restore = self.backups_adm_client.restore_backup(backup['id'])
- self.assertEqual(202, resp.status)
+ _, restore = self.backups_adm_client.restore_backup(backup['id'])
# Delete backup
self.addCleanup(self.volumes_adm_client.delete_volume,
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index b7de767..3cd0827 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -63,8 +63,7 @@
cls.os.volume_availability_zone_client)
# Special fields and resp code for cinder v1
cls.special_fields = {'name_field': 'display_name',
- 'descrip_field': 'display_description',
- 'create_resp': 200}
+ 'descrip_field': 'display_description'}
elif cls._api_version == 2:
if not CONF.volume_feature_enabled.api_v2:
@@ -76,8 +75,7 @@
cls.os.volume_v2_availability_zone_client)
# Special fields and resp code for cinder v2
cls.special_fields = {'name_field': 'name',
- 'descrip_field': 'description',
- 'create_resp': 202}
+ 'descrip_field': 'description'}
else:
msg = ("Invalid Cinder API version (%s)" % cls._api_version)
@@ -96,11 +94,9 @@
name = data_utils.rand_name('Volume')
name_field = cls.special_fields['name_field']
- expect_status = cls.special_fields['create_resp']
kwargs[name_field] = name
- resp, volume = cls.volumes_client.create_volume(size, **kwargs)
- assert expect_status == resp.status
+ _, volume = cls.volumes_client.create_volume(size, **kwargs)
cls.volumes.append(volume)
cls.volumes_client.wait_for_volume_status(volume['id'], 'available')
@@ -109,9 +105,8 @@
@classmethod
def create_snapshot(cls, volume_id=1, **kwargs):
"""Wrapper utility that returns a test snapshot."""
- resp, snapshot = cls.snapshots_client.create_snapshot(volume_id,
- **kwargs)
- assert 200 == resp.status
+ _, snapshot = cls.snapshots_client.create_snapshot(volume_id,
+ **kwargs)
cls.snapshots.append(snapshot)
cls.snapshots_client.wait_for_snapshot_status(snapshot['id'],
'available')
diff --git a/tempest/api/volume/test_availability_zone.py b/tempest/api/volume/test_availability_zone.py
index 25b7b85..c026f71 100644
--- a/tempest/api/volume/test_availability_zone.py
+++ b/tempest/api/volume/test_availability_zone.py
@@ -31,8 +31,7 @@
@test.attr(type='gate')
def test_get_availability_zone_list(self):
# List of availability zone
- resp, availability_zone = self.client.get_availability_zone_list()
- self.assertEqual(200, resp.status)
+ _, availability_zone = self.client.get_availability_zone_list()
self.assertTrue(len(availability_zone) > 0)
diff --git a/tempest/api/volume/test_extensions.py b/tempest/api/volume/test_extensions.py
index ff00dd1..4fc6ee4 100644
--- a/tempest/api/volume/test_extensions.py
+++ b/tempest/api/volume/test_extensions.py
@@ -30,8 +30,7 @@
@test.attr(type='gate')
def test_list_extensions(self):
# List of all extensions
- resp, extensions = self.volumes_extension_client.list_extensions()
- self.assertEqual(200, resp.status)
+ _, extensions = self.volumes_extension_client.list_extensions()
if len(CONF.volume_feature_enabled.api_extensions) == 0:
raise self.skipException('There are not any extensions configured')
extension_list = [extension.get('alias') for extension in extensions]
diff --git a/tempest/api/volume/test_snapshot_metadata.py b/tempest/api/volume/test_snapshot_metadata.py
index d2c4ab7..94ba095 100644
--- a/tempest/api/volume/test_snapshot_metadata.py
+++ b/tempest/api/volume/test_snapshot_metadata.py
@@ -44,19 +44,15 @@
"key3": "value3"}
expected = {"key2": "value2",
"key3": "value3"}
- resp, body = self.client.create_snapshot_metadata(self.snapshot_id,
- metadata)
- self.assertEqual(200, resp.status)
+ _, body = self.client.create_snapshot_metadata(self.snapshot_id,
+ metadata)
# Get the metadata of the snapshot
- resp, body = self.client.get_snapshot_metadata(self.snapshot_id)
- self.assertEqual(200, resp.status)
+ _, body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(metadata, body)
# Delete one item metadata of the snapshot
- resp, body = self.client.delete_snapshot_metadata_item(
- self.snapshot_id,
- "key1")
- self.assertEqual(200, resp.status)
- resp, body = self.client.get_snapshot_metadata(self.snapshot_id)
+ self.client.delete_snapshot_metadata_item(
+ self.snapshot_id, "key1")
+ _, body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(expected, body)
@test.attr(type='gate')
@@ -68,21 +64,16 @@
update = {"key3": "value3_update",
"key4": "value4"}
# Create metadata for the snapshot
- resp, body = self.client.create_snapshot_metadata(self.snapshot_id,
- metadata)
- self.assertEqual(200, resp.status)
+ _, body = self.client.create_snapshot_metadata(self.snapshot_id,
+ metadata)
# Get the metadata of the snapshot
- resp, body = self.client.get_snapshot_metadata(self.snapshot_id)
- self.assertEqual(200, resp.status)
+ _, body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(metadata, body)
# Update metadata item
- resp, body = self.client.update_snapshot_metadata(
- self.snapshot_id,
- update)
- self.assertEqual(200, resp.status)
+ _, body = self.client.update_snapshot_metadata(
+ self.snapshot_id, update)
# Get the metadata of the snapshot
- resp, body = self.client.get_snapshot_metadata(self.snapshot_id)
- self.assertEqual(200, resp.status)
+ _, body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(update, body)
@test.attr(type='gate')
@@ -96,21 +87,16 @@
"key2": "value2",
"key3": "value3_update"}
# Create metadata for the snapshot
- resp, body = self.client.create_snapshot_metadata(self.snapshot_id,
- metadata)
- self.assertEqual(200, resp.status)
+ _, body = self.client.create_snapshot_metadata(self.snapshot_id,
+ metadata)
# Get the metadata of the snapshot
- resp, body = self.client.get_snapshot_metadata(self.snapshot_id)
+ _, body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(metadata, body)
# Update metadata item
- resp, body = self.client.update_snapshot_metadata_item(
- self.snapshot_id,
- "key3",
- update_item)
- self.assertEqual(200, resp.status)
+ _, body = self.client.update_snapshot_metadata_item(
+ self.snapshot_id, "key3", update_item)
# Get the metadata of the snapshot
- resp, body = self.client.get_snapshot_metadata(self.snapshot_id)
- self.assertEqual(200, resp.status)
+ _, body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(expect, body)
diff --git a/tempest/api/volume/test_volume_metadata.py b/tempest/api/volume/test_volume_metadata.py
index 0505f19..ac760aa 100644
--- a/tempest/api/volume/test_volume_metadata.py
+++ b/tempest/api/volume/test_volume_metadata.py
@@ -42,19 +42,15 @@
"key3": "value3",
"key4": "<value&special_chars>"}
- rsp, body = self.volumes_client.create_volume_metadata(self.volume_id,
- metadata)
- self.assertEqual(200, rsp.status)
+ _, body = self.volumes_client.create_volume_metadata(self.volume_id,
+ metadata)
# Get the metadata of the volume
- resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
- self.assertEqual(200, resp.status)
+ _, body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Delete one item metadata of the volume
- rsp, body = self.volumes_client.delete_volume_metadata_item(
- self.volume_id,
- "key1")
- self.assertEqual(200, rsp.status)
- resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
+ self.volumes_client.delete_volume_metadata_item(
+ self.volume_id, "key1")
+ _, body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertNotIn("key1", body)
del metadata["key1"]
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
@@ -70,22 +66,16 @@
"key1": "value1_update"}
# Create metadata for the volume
- resp, body = self.volumes_client.create_volume_metadata(
- self.volume_id,
- metadata)
- self.assertEqual(200, resp.status)
+ _, body = self.volumes_client.create_volume_metadata(
+ self.volume_id, metadata)
# Get the metadata of the volume
- resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
- self.assertEqual(200, resp.status)
+ _, body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Update metadata
- resp, body = self.volumes_client.update_volume_metadata(
- self.volume_id,
- update)
- self.assertEqual(200, resp.status)
+ _, body = self.volumes_client.update_volume_metadata(
+ self.volume_id, update)
# Get the metadata of the volume
- resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
- self.assertEqual(200, resp.status)
+ _, body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertThat(body.items(), matchers.ContainsAll(update.items()))
@test.attr(type='gate')
@@ -99,20 +89,14 @@
"key2": "value2",
"key3": "value3_update"}
# Create metadata for the volume
- resp, body = self.volumes_client.create_volume_metadata(
- self.volume_id,
- metadata)
- self.assertEqual(200, resp.status)
+ _, body = self.volumes_client.create_volume_metadata(
+ self.volume_id, metadata)
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Update metadata item
- resp, body = self.volumes_client.update_volume_metadata_item(
- self.volume_id,
- "key3",
- update_item)
- self.assertEqual(200, resp.status)
+ _, body = self.volumes_client.update_volume_metadata_item(
+ self.volume_id, "key3", update_item)
# Get the metadata of the volume
- resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
- self.assertEqual(200, resp.status)
+ _, body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertThat(body.items(), matchers.ContainsAll(expect.items()))
diff --git a/tempest/api/volume/test_volume_transfers.py b/tempest/api/volume/test_volume_transfers.py
index bf61222..4a6ba03 100644
--- a/tempest/api/volume/test_volume_transfers.py
+++ b/tempest/api/volume/test_volume_transfers.py
@@ -47,8 +47,7 @@
def _delete_volume(self, volume_id):
# Delete the specified volume using admin creds
- resp, _ = self.adm_client.delete_volume(volume_id)
- self.assertEqual(202, resp.status)
+ self.adm_client.delete_volume(volume_id)
self.adm_client.wait_for_resource_deletion(volume_id)
@test.attr(type='gate')
@@ -58,28 +57,24 @@
self.addCleanup(self._delete_volume, volume['id'])
# Create a volume transfer
- resp, transfer = self.client.create_volume_transfer(volume['id'])
- self.assertEqual(202, resp.status)
+ _, transfer = self.client.create_volume_transfer(volume['id'])
transfer_id = transfer['id']
auth_key = transfer['auth_key']
self.client.wait_for_volume_status(volume['id'],
'awaiting-transfer')
# Get a volume transfer
- resp, body = self.client.get_volume_transfer(transfer_id)
- self.assertEqual(200, resp.status)
+ _, body = self.client.get_volume_transfer(transfer_id)
self.assertEqual(volume['id'], body['volume_id'])
# List volume transfers, the result should be greater than
# or equal to 1
- resp, body = self.client.list_volume_transfers()
- self.assertEqual(200, resp.status)
+ _, body = self.client.list_volume_transfers()
self.assertThat(len(body), matchers.GreaterThan(0))
# Accept a volume transfer by alt_tenant
- resp, body = self.alt_client.accept_volume_transfer(transfer_id,
- auth_key)
- self.assertEqual(202, resp.status)
+ _, body = self.alt_client.accept_volume_transfer(transfer_id,
+ auth_key)
self.alt_client.wait_for_volume_status(volume['id'], 'available')
def test_create_list_delete_volume_transfer(self):
@@ -88,15 +83,13 @@
self.addCleanup(self._delete_volume, volume['id'])
# Create a volume transfer
- resp, body = self.client.create_volume_transfer(volume['id'])
- self.assertEqual(202, resp.status)
+ _, body = self.client.create_volume_transfer(volume['id'])
transfer_id = body['id']
self.client.wait_for_volume_status(volume['id'],
'awaiting-transfer')
# List all volume transfers (looking for the one we created)
- resp, body = self.client.list_volume_transfers()
- self.assertEqual(200, resp.status)
+ _, body = self.client.list_volume_transfers()
for transfer in body:
if volume['id'] == transfer['volume_id']:
break
@@ -104,8 +97,7 @@
self.fail('Transfer not found for volume %s' % volume['id'])
# Delete a volume transfer
- resp, body = self.client.delete_volume_transfer(transfer_id)
- self.assertEqual(202, resp.status)
+ self.client.delete_volume_transfer(transfer_id)
self.client.wait_for_volume_status(volume['id'], 'available')
diff --git a/tempest/api/volume/test_volumes_actions.py b/tempest/api/volume/test_volumes_actions.py
index 6fef564..c87878d 100644
--- a/tempest/api/volume/test_volumes_actions.py
+++ b/tempest/api/volume/test_volumes_actions.py
@@ -40,6 +40,10 @@
# Create a test shared volume for attach/detach tests
cls.volume = cls.create_volume()
+ def _delete_image_with_wait(self, image_id):
+ self.image_client.delete_image(image_id)
+ self.image_client.wait_for_resource_deletion(image_id)
+
@classmethod
def tearDownClass(cls):
# Delete the test instance
@@ -54,13 +58,11 @@
def test_attach_detach_volume_to_instance(self):
# Volume is attached and detached successfully from an instance
mountpoint = '/dev/vdc'
- resp, body = self.client.attach_volume(self.volume['id'],
- self.server['id'],
- mountpoint)
- self.assertEqual(202, resp.status)
+ _, body = self.client.attach_volume(self.volume['id'],
+ self.server['id'],
+ mountpoint)
self.client.wait_for_volume_status(self.volume['id'], 'in-use')
- resp, body = self.client.detach_volume(self.volume['id'])
- self.assertEqual(202, resp.status)
+ _, body = self.client.detach_volume(self.volume['id'])
self.client.wait_for_volume_status(self.volume['id'], 'available')
@test.stresstest(class_setup_per='process')
@@ -69,10 +71,9 @@
def test_get_volume_attachment(self):
# Verify that a volume's attachment information is retrieved
mountpoint = '/dev/vdc'
- resp, body = self.client.attach_volume(self.volume['id'],
- self.server['id'],
- mountpoint)
- self.assertEqual(202, resp.status)
+ _, body = self.client.attach_volume(self.volume['id'],
+ self.server['id'],
+ mountpoint)
self.client.wait_for_volume_status(self.volume['id'], 'in-use')
# NOTE(gfidente): added in reverse order because functions will be
# called in reverse order to the order they are added (LIFO)
@@ -80,8 +81,7 @@
self.volume['id'],
'available')
self.addCleanup(self.client.detach_volume, self.volume['id'])
- resp, volume = self.client.get_volume(self.volume['id'])
- self.assertEqual(200, resp.status)
+ _, volume = self.client.get_volume(self.volume['id'])
self.assertIn('attachments', volume)
attachment = self.client.get_attachment_from_volume(volume)
self.assertEqual(mountpoint, attachment['device'])
@@ -97,41 +97,25 @@
# there is no way to delete it from Cinder, so we delete it from Glance
# using the Glance image_client and from Cinder via tearDownClass.
image_name = data_utils.rand_name('Image-')
- resp, body = self.client.upload_volume(self.volume['id'],
- image_name,
- CONF.volume.disk_format)
+ _, body = self.client.upload_volume(self.volume['id'],
+ image_name,
+ CONF.volume.disk_format)
image_id = body["image_id"]
self.addCleanup(self.image_client.delete_image, image_id)
- self.assertEqual(202, resp.status)
self.image_client.wait_for_image_status(image_id, 'active')
self.client.wait_for_volume_status(self.volume['id'], 'available')
@test.attr(type='gate')
- def test_volume_extend(self):
- # Extend Volume Test.
- extend_size = int(self.volume['size']) + 1
- resp, body = self.client.extend_volume(self.volume['id'], extend_size)
- self.assertEqual(202, resp.status)
- self.client.wait_for_volume_status(self.volume['id'], 'available')
- resp, volume = self.client.get_volume(self.volume['id'])
- self.assertEqual(200, resp.status)
- self.assertEqual(int(volume['size']), extend_size)
-
- @test.attr(type='gate')
def test_reserve_unreserve_volume(self):
# Mark volume as reserved.
- resp, body = self.client.reserve_volume(self.volume['id'])
- self.assertEqual(202, resp.status)
+ _, body = self.client.reserve_volume(self.volume['id'])
# To get the volume info
- resp, body = self.client.get_volume(self.volume['id'])
- self.assertEqual(200, resp.status)
+ _, body = self.client.get_volume(self.volume['id'])
self.assertIn('attaching', body['status'])
# Unmark volume as reserved.
- resp, body = self.client.unreserve_volume(self.volume['id'])
- self.assertEqual(202, resp.status)
+ _, body = self.client.unreserve_volume(self.volume['id'])
# To get the volume info
- resp, body = self.client.get_volume(self.volume['id'])
- self.assertEqual(200, resp.status)
+ _, body = self.client.get_volume(self.volume['id'])
self.assertIn('available', body['status'])
def _is_true(self, val):
@@ -141,26 +125,21 @@
def test_volume_readonly_update(self):
# Update volume readonly true
readonly = True
- resp, body = self.client.update_volume_readonly(self.volume['id'],
- readonly)
- self.assertEqual(202, resp.status)
-
+ _, body = self.client.update_volume_readonly(self.volume['id'],
+ readonly)
# Get Volume information
- resp, fetched_volume = self.client.get_volume(self.volume['id'])
+ _, fetched_volume = self.client.get_volume(self.volume['id'])
bool_flag = self._is_true(fetched_volume['metadata']['readonly'])
- self.assertEqual(200, resp.status)
self.assertEqual(True, bool_flag)
# Update volume readonly false
readonly = False
- resp, body = self.client.update_volume_readonly(self.volume['id'],
- readonly)
- self.assertEqual(202, resp.status)
+ _, body = self.client.update_volume_readonly(self.volume['id'],
+ readonly)
# Get Volume information
- resp, fetched_volume = self.client.get_volume(self.volume['id'])
+ _, fetched_volume = self.client.get_volume(self.volume['id'])
bool_flag = self._is_true(fetched_volume['metadata']['readonly'])
- self.assertEqual(200, resp.status)
self.assertEqual(False, bool_flag)
diff --git a/tempest/api/volume/test_volumes_extend.py b/tempest/api/volume/test_volumes_extend.py
new file mode 100644
index 0000000..c9e80aa
--- /dev/null
+++ b/tempest/api/volume/test_volumes_extend.py
@@ -0,0 +1,51 @@
+# Copyright 2012 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.volume import base
+from tempest import config
+from tempest import test
+
+CONF = config.CONF
+
+
+class VolumesV2ExtendTest(base.BaseVolumeTest):
+
+ @classmethod
+ @test.safe_setup
+ def setUpClass(cls):
+ super(VolumesV2ExtendTest, cls).setUpClass()
+ cls.client = cls.volumes_client
+
+ @test.attr(type='gate')
+ def test_volume_extend(self):
+ # Extend Volume Test.
+ self.volume = self.create_volume()
+ extend_size = int(self.volume['size']) + 1
+ _, body = self.client.extend_volume(self.volume['id'], extend_size)
+ self.client.wait_for_volume_status(self.volume['id'], 'available')
+ _, volume = self.client.get_volume(self.volume['id'])
+ self.assertEqual(int(volume['size']), extend_size)
+
+
+class VolumesV2ExtendTestXML(VolumesV2ExtendTest):
+ _interface = "xml"
+
+
+class VolumesV1ExtendTest(VolumesV2ExtendTest):
+ _api_version = 1
+
+
+class VolumesV1ExtendTestXML(VolumesV1ExtendTest):
+ _interface = "xml"
diff --git a/tempest/api/volume/test_volumes_get.py b/tempest/api/volume/test_volumes_get.py
index 82208aa..a346a17 100644
--- a/tempest/api/volume/test_volumes_get.py
+++ b/tempest/api/volume/test_volumes_get.py
@@ -32,11 +32,9 @@
cls.name_field = cls.special_fields['name_field']
cls.descrip_field = cls.special_fields['descrip_field']
- cls.create_resp = cls.special_fields['create_resp']
def _delete_volume(self, volume_id):
- resp, _ = self.client.delete_volume(volume_id)
- self.assertEqual(202, resp.status)
+ self.client.delete_volume(volume_id)
self.client.wait_for_resource_deletion(volume_id)
def _is_true(self, val):
@@ -56,8 +54,7 @@
# Create a volume
kwargs[self.name_field] = v_name
kwargs['metadata'] = metadata
- resp, volume = self.client.create_volume(**kwargs)
- self.assertEqual(self.create_resp, resp.status)
+ _, volume = self.client.create_volume(**kwargs)
self.assertIn('id', volume)
self.addCleanup(self._delete_volume, volume['id'])
self.client.wait_for_volume_status(volume['id'], 'available')
@@ -68,8 +65,7 @@
self.assertTrue(volume['id'] is not None,
"Field volume id is empty or not found.")
# Get Volume information
- resp, fetched_volume = self.client.get_volume(volume['id'])
- self.assertEqual(200, resp.status)
+ _, fetched_volume = self.client.get_volume(volume['id'])
self.assertEqual(v_name,
fetched_volume[self.name_field],
'The fetched Volume name is different '
@@ -94,21 +90,18 @@
# Update Volume
# Test volume update when display_name is same with original value
params = {self.name_field: v_name}
- resp, update_volume = self.client.update_volume(volume['id'], **params)
- self.assertEqual(200, resp.status)
+ _, update_volume = self.client.update_volume(volume['id'], **params)
# Test volume update when display_name is new
new_v_name = data_utils.rand_name('new-Volume')
new_desc = 'This is the new description of volume'
params = {self.name_field: new_v_name,
self.descrip_field: new_desc}
- resp, update_volume = self.client.update_volume(volume['id'], **params)
+ _, update_volume = self.client.update_volume(volume['id'], **params)
# Assert response body for update_volume method
- self.assertEqual(200, resp.status)
self.assertEqual(new_v_name, update_volume[self.name_field])
self.assertEqual(new_desc, update_volume[self.descrip_field])
# Assert response body for get_volume method
- resp, updated_volume = self.client.get_volume(volume['id'])
- self.assertEqual(200, resp.status)
+ _, updated_volume = self.client.get_volume(volume['id'])
self.assertEqual(volume['id'], updated_volume['id'])
self.assertEqual(new_v_name, updated_volume[self.name_field])
self.assertEqual(new_desc, updated_volume[self.descrip_field])
@@ -123,17 +116,15 @@
new_v_desc = data_utils.rand_name('@#$%^* description')
params = {self.descrip_field: new_v_desc,
'availability_zone': volume['availability_zone']}
- resp, new_volume = self.client.create_volume(size=1, **params)
- self.assertEqual(self.create_resp, resp.status)
+ _, new_volume = self.client.create_volume(size=1, **params)
self.assertIn('id', new_volume)
self.addCleanup(self._delete_volume, new_volume['id'])
self.client.wait_for_volume_status(new_volume['id'], 'available')
params = {self.name_field: volume[self.name_field],
self.descrip_field: volume[self.descrip_field]}
- resp, update_volume = self.client.update_volume(new_volume['id'],
- **params)
- self.assertEqual(200, resp.status)
+ _, update_volume = self.client.update_volume(new_volume['id'],
+ **params)
# NOTE(jdg): Revert back to strict true/false checking
# after fix for bug #1227837 merges
diff --git a/tempest/api/volume/test_volumes_list.py b/tempest/api/volume/test_volumes_list.py
index ff225a2..272a41a 100644
--- a/tempest/api/volume/test_volumes_list.py
+++ b/tempest/api/volume/test_volumes_list.py
@@ -67,7 +67,7 @@
cls.metadata = {'Type': 'work'}
for i in range(3):
volume = cls.create_volume(metadata=cls.metadata)
- resp, volume = cls.client.get_volume(volume['id'])
+ _, volume = cls.client.get_volume(volume['id'])
cls.volume_list.append(volume)
cls.volume_id_list.append(volume['id'])
@@ -75,7 +75,7 @@
def tearDownClass(cls):
# Delete the created volumes
for volid in cls.volume_id_list:
- resp, _ = cls.client.delete_volume(volid)
+ cls.client.delete_volume(volid)
cls.client.wait_for_resource_deletion(volid)
super(VolumesV2ListTestJSON, cls).tearDownClass()
@@ -85,12 +85,11 @@
and validates result.
"""
if with_detail:
- resp, fetched_vol_list = \
+ _, fetched_vol_list = \
self.client.list_volumes_with_detail(params=params)
else:
- resp, fetched_vol_list = self.client.list_volumes(params=params)
+ _, fetched_vol_list = self.client.list_volumes(params=params)
- self.assertEqual(200, resp.status)
# Validating params of fetched volumes
# In v2, only list detail view includes items in params.
# In v1, list view and list detail view are same. So the
@@ -113,8 +112,7 @@
def test_volume_list(self):
# Get a list of Volumes
# Fetch all volumes
- resp, fetched_list = self.client.list_volumes()
- self.assertEqual(200, resp.status)
+ _, fetched_list = self.client.list_volumes()
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@@ -122,16 +120,14 @@
def test_volume_list_with_details(self):
# Get a list of Volumes with details
# Fetch all Volumes
- resp, fetched_list = self.client.list_volumes_with_detail()
- self.assertEqual(200, resp.status)
+ _, fetched_list = self.client.list_volumes_with_detail()
self.assertVolumesIn(fetched_list, self.volume_list)
@test.attr(type='gate')
def test_volume_list_by_name(self):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
params = {self.name: volume[self.name]}
- resp, fetched_vol = self.client.list_volumes(params)
- self.assertEqual(200, resp.status)
+ _, fetched_vol = self.client.list_volumes(params)
self.assertEqual(1, len(fetched_vol), str(fetched_vol))
self.assertEqual(fetched_vol[0][self.name],
volume[self.name])
@@ -140,8 +136,7 @@
def test_volume_list_details_by_name(self):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
params = {self.name: volume[self.name]}
- resp, fetched_vol = self.client.list_volumes_with_detail(params)
- self.assertEqual(200, resp.status)
+ _, fetched_vol = self.client.list_volumes_with_detail(params)
self.assertEqual(1, len(fetched_vol), str(fetched_vol))
self.assertEqual(fetched_vol[0][self.name],
volume[self.name])
@@ -149,8 +144,7 @@
@test.attr(type='gate')
def test_volumes_list_by_status(self):
params = {'status': 'available'}
- resp, fetched_list = self.client.list_volumes(params)
- self.assertEqual(200, resp.status)
+ _, fetched_list = self.client.list_volumes(params)
self._list_by_param_value_and_assert(params)
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@@ -158,8 +152,7 @@
@test.attr(type='gate')
def test_volumes_list_details_by_status(self):
params = {'status': 'available'}
- resp, fetched_list = self.client.list_volumes_with_detail(params)
- self.assertEqual(200, resp.status)
+ _, fetched_list = self.client.list_volumes_with_detail(params)
for volume in fetched_list:
self.assertEqual('available', volume['status'])
self.assertVolumesIn(fetched_list, self.volume_list)
@@ -169,8 +162,7 @@
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
zone = volume['availability_zone']
params = {'availability_zone': zone}
- resp, fetched_list = self.client.list_volumes(params)
- self.assertEqual(200, resp.status)
+ _, fetched_list = self.client.list_volumes(params)
self._list_by_param_value_and_assert(params)
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@@ -180,8 +172,7 @@
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
zone = volume['availability_zone']
params = {'availability_zone': zone}
- resp, fetched_list = self.client.list_volumes_with_detail(params)
- self.assertEqual(200, resp.status)
+ _, fetched_list = self.client.list_volumes_with_detail(params)
for volume in fetched_list:
self.assertEqual(zone, volume['availability_zone'])
self.assertVolumesIn(fetched_list, self.volume_list)
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index 8bd4c88..5f0cffa 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -225,44 +225,38 @@
@test.attr(type=['negative', 'gate'])
def test_reserve_volume_with_negative_volume_status(self):
# Mark volume as reserved.
- resp, body = self.client.reserve_volume(self.volume['id'])
- self.assertEqual(202, resp.status)
+ _, body = self.client.reserve_volume(self.volume['id'])
# Mark volume which is marked as reserved before
self.assertRaises(exceptions.BadRequest,
self.client.reserve_volume,
self.volume['id'])
# Unmark volume as reserved.
- resp, body = self.client.unreserve_volume(self.volume['id'])
- self.assertEqual(202, resp.status)
+ _, body = self.client.unreserve_volume(self.volume['id'])
@test.attr(type=['negative', 'gate'])
def test_list_volumes_with_nonexistent_name(self):
v_name = data_utils.rand_name('Volume-')
params = {self.name_field: v_name}
- resp, fetched_volume = self.client.list_volumes(params)
- self.assertEqual(200, resp.status)
+ _, fetched_volume = self.client.list_volumes(params)
self.assertEqual(0, len(fetched_volume))
@test.attr(type=['negative', 'gate'])
def test_list_volumes_detail_with_nonexistent_name(self):
v_name = data_utils.rand_name('Volume-')
params = {self.name_field: v_name}
- resp, fetched_volume = self.client.list_volumes_with_detail(params)
- self.assertEqual(200, resp.status)
+ _, fetched_volume = self.client.list_volumes_with_detail(params)
self.assertEqual(0, len(fetched_volume))
@test.attr(type=['negative', 'gate'])
def test_list_volumes_with_invalid_status(self):
params = {'status': 'null'}
- resp, fetched_volume = self.client.list_volumes(params)
- self.assertEqual(200, resp.status)
+ _, fetched_volume = self.client.list_volumes(params)
self.assertEqual(0, len(fetched_volume))
@test.attr(type=['negative', 'gate'])
def test_list_volumes_detail_with_invalid_status(self):
params = {'status': 'null'}
- resp, fetched_volume = self.client.list_volumes_with_detail(params)
- self.assertEqual(200, resp.status)
+ _, fetched_volume = self.client.list_volumes_with_detail(params)
self.assertEqual(0, len(fetched_volume))
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 26316d2..7db1ef1 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -47,14 +47,13 @@
and validates result.
"""
if with_detail:
- resp, fetched_snap_list = \
+ _, fetched_snap_list = \
self.snapshots_client.\
list_snapshots_with_detail(params=params)
else:
- resp, fetched_snap_list = \
+ _, fetched_snap_list = \
self.snapshots_client.list_snapshots(params=params)
- self.assertEqual(200, resp.status)
# Validating params of fetched snapshots
for snap in fetched_snap_list:
for key in params:
@@ -74,9 +73,8 @@
self.addCleanup(self.servers_client.delete_server, server['id'])
self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
mountpoint = '/dev/%s' % CONF.compute.volume_device_name
- resp, body = self.volumes_client.attach_volume(
+ _, body = self.volumes_client.attach_volume(
self.volume_origin['id'], server['id'], mountpoint)
- self.assertEqual(202, resp.status)
self.volumes_client.wait_for_volume_status(self.volume_origin['id'],
'in-use')
self.addCleanup(self._detach, self.volume_origin['id'])
@@ -85,7 +83,6 @@
force=True)
# Delete the snapshot
self.snapshots_client.delete_snapshot(snapshot['id'])
- self.assertEqual(202, resp.status)
self.snapshots_client.wait_for_resource_deletion(snapshot['id'])
self.snapshots.remove(snapshot)
@@ -97,40 +94,35 @@
display_name=s_name)
# Get the snap and check for some of its details
- resp, snap_get = self.snapshots_client.get_snapshot(snapshot['id'])
- self.assertEqual(200, resp.status)
+ _, snap_get = self.snapshots_client.get_snapshot(snapshot['id'])
self.assertEqual(self.volume_origin['id'],
snap_get['volume_id'],
"Referred volume origin mismatch")
# Compare also with the output from the list action
tracking_data = (snapshot['id'], snapshot['display_name'])
- resp, snaps_list = self.snapshots_client.list_snapshots()
- self.assertEqual(200, resp.status)
+ _, snaps_list = self.snapshots_client.list_snapshots()
snaps_data = [(f['id'], f['display_name']) for f in snaps_list]
self.assertIn(tracking_data, snaps_data)
# Updates snapshot with new values
new_s_name = data_utils.rand_name('new-snap')
new_desc = 'This is the new description of snapshot.'
- resp, update_snapshot = \
+ _, update_snapshot = \
self.snapshots_client.update_snapshot(snapshot['id'],
display_name=new_s_name,
display_description=new_desc)
# Assert response body for update_snapshot method
- self.assertEqual(200, resp.status)
self.assertEqual(new_s_name, update_snapshot['display_name'])
self.assertEqual(new_desc, update_snapshot['display_description'])
# Assert response body for get_snapshot method
- resp, updated_snapshot = \
+ _, updated_snapshot = \
self.snapshots_client.get_snapshot(snapshot['id'])
- self.assertEqual(200, resp.status)
self.assertEqual(new_s_name, updated_snapshot['display_name'])
self.assertEqual(new_desc, updated_snapshot['display_description'])
# Delete the snapshot
self.snapshots_client.delete_snapshot(snapshot['id'])
- self.assertEqual(200, resp.status)
self.snapshots_client.wait_for_resource_deletion(snapshot['id'])
self.snapshots.remove(snapshot)
@@ -177,13 +169,12 @@
@test.attr(type='gate')
def test_volume_from_snapshot(self):
# Create a temporary snap using wrapper method from base, then
- # create a snap based volume, check resp code and deletes it
+ # create a snap based volume and deletes it
snapshot = self.create_snapshot(self.volume_origin['id'])
# NOTE(gfidente): size is required also when passing snapshot_id
- resp, volume = self.volumes_client.create_volume(
+ _, volume = self.volumes_client.create_volume(
size=1,
snapshot_id=snapshot['id'])
- self.assertEqual(200, resp.status)
self.volumes_client.wait_for_volume_status(volume['id'], 'available')
self.volumes_client.delete_volume(volume['id'])
self.volumes_client.wait_for_resource_deletion(volume['id'])
diff --git a/tempest/api/volume/v2/test_volumes_list.py b/tempest/api/volume/v2/test_volumes_list.py
index 7ca8599..3ae227d 100644
--- a/tempest/api/volume/v2/test_volumes_list.py
+++ b/tempest/api/volume/v2/test_volumes_list.py
@@ -42,7 +42,7 @@
cls.metadata = {'Type': 'work'}
for i in range(3):
volume = cls.create_volume(metadata=cls.metadata)
- resp, volume = cls.client.get_volume(volume['id'])
+ _, volume = cls.client.get_volume(volume['id'])
cls.volume_list.append(volume)
cls.volume_id_list.append(volume['id'])
@@ -50,7 +50,7 @@
def tearDownClass(cls):
# Delete the created volumes
for volid in cls.volume_id_list:
- resp, _ = cls.client.delete_volume(volid)
+ cls.client.delete_volume(volid)
cls.client.wait_for_resource_deletion(volid)
super(VolumesV2ListTestJSON, cls).tearDownClass()
@@ -66,8 +66,7 @@
'sort_dir': sort_dir,
'sort_key': sort_key
}
- resp, fetched_volume = self.client.list_volumes_with_detail(params)
- self.assertEqual(200, resp.status)
+ _, fetched_volume = self.client.list_volumes_with_detail(params)
self.assertEqual(limit, len(fetched_volume),
"The count of volumes is %s, expected:%s " %
(len(fetched_volume), limit))
diff --git a/tempest/api_schema/request/compute/flavors.py b/tempest/api_schema/request/compute/flavors.py
index 36e5a19..8fe9e3a 100644
--- a/tempest/api_schema/request/compute/flavors.py
+++ b/tempest/api_schema/request/compute/flavors.py
@@ -30,3 +30,24 @@
}
}
}
+
+common_admin_flavor_create = {
+ "name": "flavor-create",
+ "http-method": "POST",
+ "admin_client": True,
+ "url": "flavors",
+ "default_result_code": 400,
+ "json-schema": {
+ "type": "object",
+ "properties": {
+ "name": {"type": "string"},
+ "ram": {"type": "integer", "minimum": 1},
+ "vcpus": {"type": "integer", "minimum": 1},
+ "disk": {"type": "integer"},
+ "id": {"type": "integer"},
+ "swap": {"type": "integer"},
+ "rxtx_factor": {"type": "integer"},
+ "OS-FLV-EXT-DATA:ephemeral": {"type": "integer"}
+ }
+ }
+}
diff --git a/tempest/api_schema/request/compute/servers.py b/tempest/api_schema/request/compute/servers.py
new file mode 100644
index 0000000..731649c
--- /dev/null
+++ b/tempest/api_schema/request/compute/servers.py
@@ -0,0 +1,36 @@
+# (c) 2014 Deutsche Telekom AG
+# 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.
+
+common_get_console_output = {
+ "name": "get-console-output",
+ "http-method": "POST",
+ "url": "servers/%s/action",
+ "resources": [
+ {"name": "server", "expected_result": 404}
+ ],
+ "json-schema": {
+ "type": "object",
+ "properties": {
+ "os-getConsoleOutput": {
+ "type": "object",
+ "properties": {
+ "length": {
+ "type": ["integer", "string"],
+ "minimum": 0
+ }
+ }
+ }
+ },
+ "additionalProperties": False
+ }
+}
diff --git a/tempest/api_schema/request/compute/v2/flavors.py b/tempest/api_schema/request/compute/v2/flavors.py
index 08f6c28..bc459ad 100644
--- a/tempest/api_schema/request/compute/v2/flavors.py
+++ b/tempest/api_schema/request/compute/v2/flavors.py
@@ -19,6 +19,8 @@
flavor_list = copy.deepcopy(flavors.common_flavor_list)
+flavor_create = copy.deepcopy(flavors.common_admin_flavor_create)
+
flavor_list["json-schema"]["properties"] = {
"minRam": {
"type": "integer",
diff --git a/tempest/api_schema/request/compute/v2/servers.py b/tempest/api_schema/request/compute/v2/servers.py
new file mode 100644
index 0000000..c9002ed
--- /dev/null
+++ b/tempest/api_schema/request/compute/v2/servers.py
@@ -0,0 +1,18 @@
+# (c) 2014 Deutsche Telekom AG
+# 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.api_schema.request.compute import servers
+
+get_console_output = copy.deepcopy(servers.common_get_console_output)
diff --git a/tempest/api_schema/response/compute/servers.py b/tempest/api_schema/response/compute/servers.py
index d6c2ddb..f9c957b 100644
--- a/tempest/api_schema/response/compute/servers.py
+++ b/tempest/api_schema/response/compute/servers.py
@@ -54,14 +54,15 @@
'id': {'type': 'string'},
'name': {'type': 'string'},
'status': {'type': 'string'},
- 'image': {
- 'type': 'object',
- 'properties': {
- 'id': {'type': 'string'},
- 'links': parameter_types.links
- },
- 'required': ['id', 'links']
- },
+ 'image': {'oneOf': [
+ {'type': 'object',
+ 'properties': {
+ 'id': {'type': 'string'},
+ 'links': parameter_types.links
+ },
+ 'required': ['id', 'links']},
+ {'type': ['string', 'null']}
+ ]},
'flavor': {
'type': 'object',
'properties': {
diff --git a/tempest/cli/simple_read_only/test_nova.py b/tempest/cli/simple_read_only/compute/test_nova.py
similarity index 100%
rename from tempest/cli/simple_read_only/test_nova.py
rename to tempest/cli/simple_read_only/compute/test_nova.py
diff --git a/tempest/cli/simple_read_only/test_nova_manage.py b/tempest/cli/simple_read_only/compute/test_nova_manage.py
similarity index 95%
rename from tempest/cli/simple_read_only/test_nova_manage.py
rename to tempest/cli/simple_read_only/compute/test_nova_manage.py
index dae0cf8..c27b12e 100644
--- a/tempest/cli/simple_read_only/test_nova_manage.py
+++ b/tempest/cli/simple_read_only/compute/test_nova_manage.py
@@ -79,10 +79,6 @@
def test_flavor_list(self):
self.assertNotEqual("", self.nova_manage('flavor list'))
- def test_db_archive_deleted_rows(self):
- # make sure command doesn't error out
- self.nova_manage('db archive_deleted_rows 50')
-
def test_db_sync(self):
# make sure command doesn't error out
self.nova_manage('db sync')
diff --git a/tempest/cli/simple_read_only/test_sahara.py b/tempest/cli/simple_read_only/data_processing/test_sahara.py
similarity index 100%
rename from tempest/cli/simple_read_only/test_sahara.py
rename to tempest/cli/simple_read_only/data_processing/test_sahara.py
diff --git a/tempest/cli/simple_read_only/test_keystone.py b/tempest/cli/simple_read_only/identity/test_keystone.py
similarity index 100%
rename from tempest/cli/simple_read_only/test_keystone.py
rename to tempest/cli/simple_read_only/identity/test_keystone.py
diff --git a/tempest/cli/simple_read_only/test_glance.py b/tempest/cli/simple_read_only/image/test_glance.py
similarity index 100%
rename from tempest/cli/simple_read_only/test_glance.py
rename to tempest/cli/simple_read_only/image/test_glance.py
diff --git a/tempest/cli/simple_read_only/test_neutron.py b/tempest/cli/simple_read_only/network/test_neutron.py
similarity index 100%
rename from tempest/cli/simple_read_only/test_neutron.py
rename to tempest/cli/simple_read_only/network/test_neutron.py
diff --git a/tempest/cli/simple_read_only/test_swift.py b/tempest/cli/simple_read_only/object_storage/test_swift.py
similarity index 100%
rename from tempest/cli/simple_read_only/test_swift.py
rename to tempest/cli/simple_read_only/object_storage/test_swift.py
diff --git a/tempest/cli/simple_read_only/test_heat.py b/tempest/cli/simple_read_only/orchestration/test_heat.py
similarity index 100%
rename from tempest/cli/simple_read_only/test_heat.py
rename to tempest/cli/simple_read_only/orchestration/test_heat.py
diff --git a/tempest/cli/simple_read_only/test_ceilometer.py b/tempest/cli/simple_read_only/telemetry/test_ceilometer.py
similarity index 100%
rename from tempest/cli/simple_read_only/test_ceilometer.py
rename to tempest/cli/simple_read_only/telemetry/test_ceilometer.py
diff --git a/tempest/cli/simple_read_only/test_cinder.py b/tempest/cli/simple_read_only/volume/test_cinder.py
similarity index 100%
rename from tempest/cli/simple_read_only/test_cinder.py
rename to tempest/cli/simple_read_only/volume/test_cinder.py
diff --git a/tempest/clients.py b/tempest/clients.py
index 0edcdf4..2b8b6fb 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -50,6 +50,7 @@
from tempest.services.compute.json.limits_client import LimitsClientJSON
from tempest.services.compute.json.migrations_client import \
MigrationsClientJSON
+from tempest.services.compute.json.networks_client import NetworksClientJSON
from tempest.services.compute.json.quotas_client import QuotaClassesClientJSON
from tempest.services.compute.json.quotas_client import QuotasClientJSON
from tempest.services.compute.json.security_group_default_rules_client import \
@@ -426,6 +427,7 @@
self.migrations_client = MigrationsClientJSON(self.auth_provider)
self.security_group_default_rules_client = (
SecurityGroupDefaultRulesClientJSON(self.auth_provider))
+ self.networks_client = NetworksClientJSON(self.auth_provider)
class AltManager(Manager):
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index 6761a69..f37bfdb 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -20,6 +20,7 @@
"""
import argparse
+import datetime
import logging
import os
import sys
@@ -30,12 +31,14 @@
import tempest.auth
from tempest import config
from tempest import exceptions
+from tempest.openstack.common import timeutils
from tempest.services.compute.json import flavors_client
from tempest.services.compute.json import servers_client
from tempest.services.identity.json import identity_client
from tempest.services.image.v2.json import image_client
from tempest.services.object_storage import container_client
from tempest.services.object_storage import object_client
+from tempest.services.telemetry.json import telemetry_client
from tempest.services.volume.json import volumes_client
OPTS = {}
@@ -44,6 +47,8 @@
LOG = None
+JAVELIN_START = datetime.datetime.utcnow()
+
class OSClient(object):
_creds = None
@@ -62,6 +67,7 @@
self.containers = container_client.ContainerClient(_auth)
self.images = image_client.ImageClientV2JSON(_auth)
self.flavors = flavors_client.FlavorsClientJSON(_auth)
+ self.telemetry = telemetry_client.TelemetryClientJSON(_auth)
self.volumes = volumes_client.VolumesClientJSON(_auth)
@@ -196,6 +202,7 @@
# TODO(sdague): Volumes not yet working, bring it back once the
# code is self testing.
# self.check_volumes()
+ self.check_telemetry()
def check_users(self):
"""Check that the users we expect to exist, do.
@@ -252,6 +259,26 @@
"Server %s is not pingable at %s" % (
server['name'], addr))
+ def check_telemetry(self):
+ """Check that ceilometer provides a sane sample.
+
+ Confirm that there are more than one sample and that they have the
+ expected metadata.
+
+ If in check mode confirm that the oldest sample available is from
+ before the upgrade.
+ """
+ LOG.info("checking telemetry")
+ for server in self.res['servers']:
+ client = client_for_user(server['owner'])
+ response, body = client.telemetry.list_samples(
+ 'instance',
+ query=('metadata.display_name', 'eq', server['name'])
+ )
+ self.assertEqual(response.status, 200)
+ self.assertTrue(len(body) >= 1, 'expecting at least one sample')
+ self._confirm_telemetry_sample(server, body[-1])
+
def check_volumes(self):
"""Check that the volumes are still there and attached."""
if not self.res.get('volumes'):
@@ -270,6 +297,26 @@
self.assertEqual(volume['id'], attachment['volume_id'])
self.assertEqual(server_id, attachment['server_id'])
+ def _confirm_telemetry_sample(self, server, sample):
+ """Check this sample matches the expected resource metadata."""
+ # Confirm display_name
+ self.assertEqual(server['name'],
+ sample['resource_metadata']['display_name'])
+ # Confirm instance_type of flavor
+ flavor = sample['resource_metadata'].get(
+ 'flavor.name',
+ sample['resource_metadata'].get('instance_type')
+ )
+ self.assertEqual(server['flavor'], flavor)
+ # Confirm the oldest sample was created before upgrade.
+ if OPTS.mode == 'check':
+ oldest_timestamp = timeutils.normalize_time(
+ timeutils.parse_isotime(sample['timestamp']))
+ self.assertTrue(
+ oldest_timestamp < JAVELIN_START,
+ 'timestamp should come before start of second javelin run'
+ )
+
#######################
#
diff --git a/tempest/cmd/verify_tempest_config.py b/tempest/cmd/verify_tempest_config.py
index 70fd27b..cd696a9 100755
--- a/tempest/cmd/verify_tempest_config.py
+++ b/tempest/cmd/verify_tempest_config.py
@@ -247,7 +247,7 @@
'data_processing': 'sahara',
'baremetal': 'ironic',
'identity': 'keystone',
- 'queuing': 'marconi',
+ 'queuing': 'zaqar',
'database': 'trove'
}
# Get catalog list for endpoints to use for validation
diff --git a/tempest/common/accounts.py b/tempest/common/accounts.py
index ad88ea2..b31c19a 100644
--- a/tempest/common/accounts.py
+++ b/tempest/common/accounts.py
@@ -52,8 +52,11 @@
hash_dict[temp_hash.hexdigest()] = account
return hash_dict
- def _create_hash_file(self, hash):
- path = os.path.join(os.path.join(self.accounts_dir, hash))
+ def is_multi_user(self):
+ return len(self.hash_dict) > 1
+
+ def _create_hash_file(self, hash_string):
+ path = os.path.join(os.path.join(self.accounts_dir, hash_string))
if not os.path.isfile(path):
open(path, 'w').close()
return True
@@ -66,20 +69,20 @@
# Create File from first hash (since none are in use)
self._create_hash_file(hashes[0])
return hashes[0]
- for hash in hashes:
- res = self._create_hash_file(hash)
+ for _hash in hashes:
+ res = self._create_hash_file(_hash)
if res:
- return hash
+ return _hash
msg = 'Insufficient number of users provided'
raise exceptions.InvalidConfiguration(msg)
def _get_creds(self):
- free_hash = self._get_free_hash(self.hashes.keys())
+ free_hash = self._get_free_hash(self.hash_dict.keys())
return self.hash_dict[free_hash]
@lockutils.synchronized('test_accounts_io', external=True)
- def remove_hash(self, hash):
- hash_path = os.path.join(self.accounts_dir, hash)
+ def remove_hash(self, hash_string):
+ hash_path = os.path.join(self.accounts_dir, hash_string)
if not os.path.isfile(hash_path):
LOG.warning('Expected an account lock file %s to remove, but '
'one did not exist')
@@ -89,40 +92,35 @@
os.rmdir(self.accounts_dir)
def get_hash(self, creds):
- for hash in self.hash_dict:
- # NOTE(mtreinish) Assuming with v3 that username, tenant, password
- # is unique enough
- cred_dict = {
- 'username': creds.username,
- 'tenant_name': creds.tenant_name,
- 'password': creds.password
- }
- if self.hash_dict[hash] == cred_dict:
- return hash
+ for _hash in self.hash_dict:
+ # Comparing on the attributes that are expected in the YAML
+ if all([getattr(creds, k) == self.hash_dict[_hash][k] for k in
+ creds.CONF_ATTRIBUTES]):
+ return _hash
raise AttributeError('Invalid credentials %s' % creds)
def remove_credentials(self, creds):
- hash = self.get_hash(creds)
- self.remove_hash(hash, self.accounts_dir)
+ _hash = self.get_hash(creds)
+ self.remove_hash(_hash)
def get_primary_creds(self):
- if self.credentials.get('primary'):
- return self.credentials.get('primary')
+ if self.isolated_creds.get('primary'):
+ return self.isolated_creds.get('primary')
creds = self._get_creds()
primary_credential = auth.get_credentials(**creds)
- self.credentials['primary'] = primary_credential
+ self.isolated_creds['primary'] = primary_credential
return primary_credential
def get_alt_creds(self):
- if self.credentials.get('alt'):
- return self.credentials.get('alt')
+ if self.isolated_creds.get('alt'):
+ return self.isolated_creds.get('alt')
creds = self._get_creds()
alt_credential = auth.get_credentials(**creds)
- self.credentials['alt'] = alt_credential
+ self.isolated_creds['alt'] = alt_credential
return alt_credential
def clear_isolated_creds(self):
- for creds in self.credentials.values():
+ for creds in self.isolated_creds.values():
self.remove_credentials(creds)
def get_admin_creds(self):
diff --git a/tempest/common/custom_matchers.py b/tempest/common/custom_matchers.py
index 996c365..39e3a67 100644
--- a/tempest/common/custom_matchers.py
+++ b/tempest/common/custom_matchers.py
@@ -14,6 +14,8 @@
import re
+from testtools import helpers
+
class ExistsAllResponseHeaders(object):
"""
@@ -172,3 +174,65 @@
def get_details(self):
return {}
+
+
+class MatchesDictExceptForKeys(object):
+ """Matches two dictionaries. Verifies all items are equals except for those
+ identified by a list of keys.
+ """
+
+ def __init__(self, expected, excluded_keys=None):
+ self.expected = expected
+ self.excluded_keys = excluded_keys if excluded_keys is not None else []
+
+ def match(self, actual):
+ filtered_expected = helpers.dict_subtract(self.expected,
+ self.excluded_keys)
+ filtered_actual = helpers.dict_subtract(actual,
+ self.excluded_keys)
+ if filtered_actual != filtered_expected:
+ return DictMismatch(filtered_expected, filtered_actual)
+
+
+class DictMismatch(object):
+ """Mismatch between two dicts describes deltas"""
+
+ def __init__(self, expected, actual):
+ self.expected = expected
+ self.actual = actual
+ self.intersect = set(self.expected) & set(self.actual)
+ self.symmetric_diff = set(self.expected) ^ set(self.actual)
+
+ def _format_dict(self, dict_to_format):
+ # Ensure the error string dict is printed in a set order
+ # NOTE(mtreinish): needed to ensure a deterministic error msg for
+ # testing. Otherwise the error message will be dependent on the
+ # dict ordering.
+ dict_string = "{"
+ for key in sorted(dict_to_format):
+ dict_string += "'%s': %s, " % (key, dict_to_format[key])
+ dict_string = dict_string[:-2] + '}'
+ return dict_string
+
+ def describe(self):
+ msg = ""
+ if self.symmetric_diff:
+ only_expected = helpers.dict_subtract(self.expected, self.actual)
+ only_actual = helpers.dict_subtract(self.actual, self.expected)
+ if only_expected:
+ msg += "Only in expected:\n %s\n" % self._format_dict(
+ only_expected)
+ if only_actual:
+ msg += "Only in actual:\n %s\n" % self._format_dict(
+ only_actual)
+ diff_set = set(o for o in self.intersect if
+ self.expected[o] != self.actual[o])
+ if diff_set:
+ msg += "Differences:\n"
+ for o in diff_set:
+ msg += " %s: expected %s, actual %s\n" % (
+ o, self.expected[o], self.actual[o])
+ return msg
+
+ def get_details(self):
+ return {}
diff --git a/tempest/common/generator/base_generator.py b/tempest/common/generator/base_generator.py
index 57b98f7..0398af1 100644
--- a/tempest/common/generator/base_generator.py
+++ b/tempest/common/generator/base_generator.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import functools
+
import jsonschema
from tempest.openstack.common import log as logging
@@ -39,6 +41,7 @@
"""
Decorator for simple generators that return one value
"""
+ @functools.wraps(fn)
def wrapped(self, schema):
result = fn(self, schema)
if result is not None:
diff --git a/tempest/common/generator/valid_generator.py b/tempest/common/generator/valid_generator.py
index a99bbc0..0d7b398 100644
--- a/tempest/common/generator/valid_generator.py
+++ b/tempest/common/generator/valid_generator.py
@@ -24,7 +24,7 @@
@base.generator_type("string")
@base.simple_generator
def generate_valid_string(self, schema):
- size = schema.get("minLength", 0)
+ size = schema.get("minLength", 1)
# TODO(dkr mko): handle format and pattern
return "x" * size
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index f711f2f..dca1f86 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -13,6 +13,7 @@
# under the License.
import netaddr
+from neutronclient.common import exceptions as n_exc
from tempest import auth
from tempest import clients
@@ -162,9 +163,11 @@
email = data_utils.rand_name(root) + suffix + "@example.com"
user = self._create_user(username, self.password,
tenant, email)
- # NOTE(andrey-mp): user needs this role to create containers in swift
- swift_operator_role = CONF.object_storage.operator_role
- self._assign_user_role(tenant, user, swift_operator_role)
+ if CONF.service_available.swift:
+ # NOTE(andrey-mp): user needs this role to create containers
+ # in swift
+ swift_operator_role = CONF.object_storage.operator_role
+ self._assign_user_role(tenant, user, swift_operator_role)
if admin:
self._assign_user_role(tenant, user, CONF.identity.admin_role)
return self._get_credentials(user, tenant)
@@ -261,7 +264,7 @@
body['subnet']['cidr'] = str(subnet_cidr)
resp_body = self.network_admin_client.create_subnet(body)
break
- except exceptions.BadRequest as e:
+ except (n_exc.BadRequest, exceptions.BadRequest) as e:
if 'overlaps with another subnet' not in str(e):
raise
else:
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index ff92b67..132d0a6 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -248,8 +248,10 @@
return resp[i]
return ""
- def _log_request_start(self, method, req_url, req_headers={},
+ def _log_request_start(self, method, req_url, req_headers=None,
req_body=None):
+ if req_headers is None:
+ req_headers = {}
caller_name = misc_utils.find_test_caller()
trace_regex = CONF.debug.trace_requests
if trace_regex and re.search(trace_regex, caller_name):
@@ -257,8 +259,10 @@
(caller_name, method, req_url))
def _log_request(self, method, req_url, resp,
- secs="", req_headers={},
+ secs="", req_headers=None,
req_body=None, resp_body=None):
+ if req_headers is None:
+ req_headers = {}
# if we have the request id, put it in the right part of the log
extra = dict(request_id=self._get_request_id(resp))
# NOTE(sdague): while we still have 6 callers to this function
diff --git a/tempest/common/xml_utils.py b/tempest/common/xml_utils.py
index b1bf789..7d460a4 100644
--- a/tempest/common/xml_utils.py
+++ b/tempest/common/xml_utils.py
@@ -14,6 +14,7 @@
# under the License.
import collections
+import copy
XMLNS_11 = "http://docs.openstack.org/compute/api/v1.1"
XMLNS_V3 = "http://docs.openstack.org/compute/api/v1.1"
@@ -78,16 +79,19 @@
class Document(Element):
def __init__(self, *args, **kwargs):
- if 'version' not in kwargs:
- kwargs['version'] = '1.0'
- if 'encoding' not in kwargs:
- kwargs['encoding'] = 'UTF-8'
Element.__init__(self, '?xml', *args, **kwargs)
def __str__(self):
- args = " ".join(['%s="%s"' %
- (k, v if v is not None else "")
- for k, v in self._attrs.items()])
+ attrs = copy.copy(self._attrs)
+ # pop the required standard attrs out and render in required
+ # order.
+ vers = attrs.pop('version', '1.0')
+ enc = attrs.pop('encoding', 'UTF-8')
+ args = 'version="%s" encoding="%s"' % (vers, enc)
+ if attrs:
+ args = " ".join([args] + ['%s="%s"' %
+ (k, v if v is not None else "")
+ for k, v in attrs.items()])
string = '<?xml %s?>\n' % args
for element in self._elements:
string += str(element)
diff --git a/tempest/config.py b/tempest/config.py
index af6dd7a..93d4874 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -52,7 +52,6 @@
default=False,
help="Set to True if using self-signed SSL certificates."),
cfg.StrOpt('uri',
- default=None,
help="Full URI of the OpenStack Identity API (Keystone), v2"),
cfg.StrOpt('uri_v3',
help='Full URI of the OpenStack Identity API (Keystone), v3'),
@@ -72,52 +71,40 @@
'publicURL', 'adminURL', 'internalURL'],
help="The endpoint type to use for the identity service."),
cfg.StrOpt('username',
- default=None,
help="Username to use for Nova API requests."),
cfg.StrOpt('tenant_name',
- default=None,
help="Tenant name to use for Nova API requests."),
cfg.StrOpt('admin_role',
default='admin',
help="Role required to administrate keystone."),
cfg.StrOpt('password',
- default=None,
help="API key to use when authenticating.",
secret=True),
cfg.StrOpt('domain_name',
- default=None,
help="Domain name for authentication (Keystone V3)."
"The same domain applies to user and project"),
cfg.StrOpt('alt_username',
- default=None,
help="Username of alternate user to use for Nova API "
"requests."),
cfg.StrOpt('alt_tenant_name',
- default=None,
help="Alternate user's Tenant name to use for Nova API "
"requests."),
cfg.StrOpt('alt_password',
- default=None,
help="API key to use when authenticating as alternate user.",
secret=True),
cfg.StrOpt('alt_domain_name',
- default=None,
help="Alternate domain name for authentication (Keystone V3)."
"The same domain applies to user and project"),
cfg.StrOpt('admin_username',
- default=None,
help="Administrative Username to use for "
"Keystone API requests."),
cfg.StrOpt('admin_tenant_name',
- default=None,
help="Administrative Tenant name to use for Keystone API "
"requests."),
cfg.StrOpt('admin_password',
- default=None,
help="API key to use when authenticating as admin.",
secret=True),
cfg.StrOpt('admin_domain_name',
- default=None,
help="Admin domain name for authentication (Keystone V3)."
"The same domain applies to user and project"),
]
@@ -246,7 +233,6 @@
default='computev3',
help="Catalog type of the Compute v3 service."),
cfg.StrOpt('path_to_private_key',
- default=None,
help="Path to a private key file for SSH access to remote "
"hosts"),
cfg.StrOpt('volume_device_name',
@@ -347,7 +333,11 @@
cfg.BoolOpt('interface_attach',
default=True,
help='Does the test environment support dynamic network '
- 'interface attachment?')
+ 'interface attachment?'),
+ cfg.BoolOpt('snapshot',
+ default=True,
+ help='Does the test environment support creating snapshot '
+ 'images of running instances?')
]
@@ -356,18 +346,14 @@
ComputeAdminGroup = [
cfg.StrOpt('username',
- default=None,
help="Administrative Username to use for Nova API requests."),
cfg.StrOpt('tenant_name',
- default=None,
help="Administrative Tenant name to use for Nova API "
"requests."),
cfg.StrOpt('password',
- default=None,
help="API key to use when authenticating as admin.",
secret=True),
cfg.StrOpt('domain_name',
- default=None,
help="Domain name for authentication as admin (Keystone V3)."
"The same domain applies to user and project"),
]
@@ -688,11 +674,9 @@
help="Instance type for tests. Needs to be big enough for a "
"full OS plus the test workload"),
cfg.StrOpt('image_ref',
- default=None,
help="Name of heat-cfntools enabled image to use when "
"launching test instances."),
cfg.StrOpt('keypair_name',
- default=None,
help="Name of existing keypair to launch servers with."),
cfg.IntOpt('max_template_size',
default=524288,
@@ -761,11 +745,9 @@
default="http://localhost:8080",
help="S3 URL"),
cfg.StrOpt('aws_secret',
- default=None,
help="AWS Secret Key",
secret=True),
cfg.StrOpt('aws_access',
- default=None,
help="AWS Access Key"),
cfg.StrOpt('aws_zone',
default="nova",
@@ -804,26 +786,20 @@
StressGroup = [
cfg.StrOpt('nova_logdir',
- default=None,
help='Directory containing log files on the compute nodes'),
cfg.IntOpt('max_instances',
default=16,
help='Maximum number of instances to create during test.'),
cfg.StrOpt('controller',
- default=None,
help='Controller host.'),
# new stress options
cfg.StrOpt('target_controller',
- default=None,
help='Controller host.'),
cfg.StrOpt('target_ssh_user',
- default=None,
help='ssh user.'),
cfg.StrOpt('target_private_key_path',
- default=None,
help='Path to private key.'),
cfg.StrOpt('target_logfiles',
- default=None,
help='regexp for list of log files.'),
cfg.IntOpt('log_check_interval',
default=60,
@@ -851,9 +827,15 @@
default='/opt/stack/new/devstack/files/images/'
'cirros-0.3.1-x86_64-uec',
help='Directory containing image files'),
- cfg.StrOpt('qcow2_img_file',
+ cfg.StrOpt('img_file', deprecated_name='qcow2_img_file',
default='cirros-0.3.1-x86_64-disk.img',
- help='QCOW2 image file name'),
+ help='Image file name'),
+ cfg.StrOpt('img_disk_format',
+ default='qcow2',
+ help='Image disk format'),
+ cfg.StrOpt('img_container_format',
+ default='bare',
+ help='Image container format'),
cfg.StrOpt('ami_img_file',
default='cirros-0.3.1-x86_64-blank.img',
help='AMI image file name'),
@@ -911,9 +893,9 @@
cfg.BoolOpt('trove',
default=False,
help="Whether or not Trove is expected to be available"),
- cfg.BoolOpt('marconi',
+ cfg.BoolOpt('zaqar',
default=False,
- help="Whether or not Marconi is expected to be available"),
+ help="Whether or not Zaqar is expected to be available"),
]
debug_group = cfg.OptGroup(name="debug",
@@ -1079,6 +1061,10 @@
DEFAULT_CONFIG_FILE = "tempest.conf"
+ def __getattr__(self, attr):
+ # Handles config options from the default group
+ return getattr(cfg.CONF, attr)
+
def _set_attrs(self):
self.auth = cfg.CONF.auth
self.compute = cfg.CONF.compute
diff --git a/tempest/hacking/checks.py b/tempest/hacking/checks.py
index 93329bc..abc60cb 100644
--- a/tempest/hacking/checks.py
+++ b/tempest/hacking/checks.py
@@ -20,13 +20,14 @@
PYTHON_CLIENTS = ['cinder', 'glance', 'keystone', 'nova', 'swift', 'neutron',
'trove', 'ironic', 'savanna', 'heat', 'ceilometer',
- 'marconi', 'sahara']
+ 'zaqar', 'sahara']
PYTHON_CLIENT_RE = re.compile('import (%s)client' % '|'.join(PYTHON_CLIENTS))
TEST_DEFINITION = re.compile(r'^\s*def test.*')
SETUPCLASS_DEFINITION = re.compile(r'^\s*def setUpClass')
SCENARIO_DECORATOR = re.compile(r'\s*@.*services\((.*)\)')
VI_HEADER_RE = re.compile(r"^#\s+vim?:.+")
+mutable_default_args = re.compile(r"^\s*def .+\((.+=\{\}|.+=\[\])")
def import_no_clients_in_api(physical_line, filename):
@@ -119,6 +120,16 @@
'tests')
+def no_mutable_default_args(logical_line):
+ """Check that mutable object isn't used as default argument
+
+ N322: Method's default argument shouldn't be mutable
+ """
+ msg = "N322: Method's default argument shouldn't be mutable!"
+ if mutable_default_args.match(logical_line):
+ yield (0, msg)
+
+
def factory(register):
register(import_no_clients_in_api)
register(scenario_tests_need_service_tags)
@@ -126,3 +137,4 @@
register(no_vi_headers)
register(service_tags_not_in_module_path)
register(no_official_client_manager_in_api_tests)
+ register(no_mutable_default_args)
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 57c07d1..dfd4658 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -39,6 +39,7 @@
from tempest import exceptions
from tempest.openstack.common import log
from tempest.openstack.common import timeutils
+from tempest.services.network import resources as net_resources
import tempest.test
CONF = config.CONF
@@ -54,16 +55,50 @@
class ScenarioTest(tempest.test.BaseTestCase):
+ """Replaces the OfficialClientTest base class.
+
+ Uses tempest own clients as opposed to OfficialClients.
+
+ Common differences:
+ - replace resource.attribute with resource['attribute']
+ - replace resouce.delete with delete_callable(resource['id'])
+ - replace local waiters with common / rest_client waiters
+ """
@classmethod
def setUpClass(cls):
super(ScenarioTest, cls).setUpClass()
+ # Using tempest client for isolated credentials as well
cls.isolated_creds = isolated_creds.IsolatedCreds(
cls.__name__, tempest_client=True,
network_resources=cls.network_resources)
cls.manager = clients.Manager(
credentials=cls.credentials()
)
+ cls.admin_manager = clients.Manager(cls.admin_credentials())
+ # Clients (in alphabetical order)
+ cls.floating_ips_client = cls.manager.floating_ips_client
+ # Glance image client v1
+ cls.image_client = cls.manager.image_client
+ # Compute image client
+ cls.images_client = cls.manager.images_client
+ cls.keypairs_client = cls.manager.keypairs_client
+ cls.networks_client = cls.admin_manager.networks_client
+ # Nova security groups client
+ cls.security_groups_client = cls.manager.security_groups_client
+ cls.servers_client = cls.manager.servers_client
+ cls.volumes_client = cls.manager.volumes_client
+ cls.snapshots_client = cls.manager.snapshots_client
+ cls.interface_client = cls.manager.interfaces_client
+ # Neutron network client
+ cls.network_client = cls.manager.network_client
+
+ @classmethod
+ def tearDownClass(cls):
+ # Isolated creds also manages network resources, which should
+ # be cleaned up at the end of the test case
+ cls.isolated_creds.clear_isolated_creds()
+ super(ScenarioTest, cls).tearDownClass()
@classmethod
def _get_credentials(cls, get_creds, ctype):
@@ -78,6 +113,818 @@
return cls._get_credentials(cls.isolated_creds.get_primary_creds,
'user')
+ @classmethod
+ def admin_credentials(cls):
+ return cls._get_credentials(cls.isolated_creds.get_admin_creds,
+ 'identity_admin')
+
+ # ## Methods to handle sync and async deletes
+
+ def setUp(self):
+ super(ScenarioTest, self).setUp()
+ self.cleanup_waits = []
+ # NOTE(mtreinish) This is safe to do in setUp instead of setUp class
+ # because scenario tests in the same test class should not share
+ # resources. If resources were shared between test cases then it
+ # should be a single scenario test instead of multiples.
+
+ # NOTE(yfried): this list is cleaned at the end of test_methods and
+ # not at the end of the class
+ self.addCleanup(self._wait_for_cleanups)
+
+ def delete_wrapper(self, delete_thing, *args, **kwargs):
+ """Ignores NotFound exceptions for delete operations.
+
+ @param delete_thing: delete method of a resource. method will be
+ executed as delete_thing(*args, **kwargs)
+
+ """
+ try:
+ # Tempest clients return dicts, so there is no common delete
+ # method available. Using a callable instead
+ delete_thing(*args, **kwargs)
+ except exceptions.NotFound:
+ # If the resource is already missing, mission accomplished.
+ pass
+
+ def addCleanup_with_wait(self, waiter_callable, thing_id, thing_id_param,
+ cleanup_callable, cleanup_args=None,
+ cleanup_kwargs=None, ignore_error=True):
+ """Adds wait for ansyc resource deletion at the end of cleanups
+
+ @param waiter_callable: callable to wait for the resource to delete
+ @param thing_id: the id of the resource to be cleaned-up
+ @param thing_id_param: the name of the id param in the waiter
+ @param cleanup_callable: method to load pass to self.addCleanup with
+ the following *cleanup_args, **cleanup_kwargs.
+ usually a delete method.
+ """
+ if cleanup_args is None:
+ cleanup_args = []
+ if cleanup_kwargs is None:
+ cleanup_kwargs = {}
+ self.addCleanup(cleanup_callable, *cleanup_args, **cleanup_kwargs)
+ wait_dict = {
+ 'waiter_callable': waiter_callable,
+ thing_id_param: thing_id
+ }
+ self.cleanup_waits.append(wait_dict)
+
+ def _wait_for_cleanups(self):
+ """To handle async delete actions, a list of waits is added
+ which will be iterated over as the last step of clearing the
+ cleanup queue. That way all the delete calls are made up front
+ and the tests won't succeed unless the deletes are eventually
+ successful. This is the same basic approach used in the api tests to
+ limit cleanup execution time except here it is multi-resource,
+ because of the nature of the scenario tests.
+ """
+ for wait in self.cleanup_waits:
+ waiter_callable = wait.pop('waiter_callable')
+ waiter_callable(**wait)
+
+ # ## Test functions library
+ #
+ # The create_[resource] functions only return body and discard the
+ # resp part which is not used in scenario tests
+
+ def create_keypair(self):
+ name = data_utils.rand_name(self.__class__.__name__)
+ # We don't need to create a keypair by pubkey in scenario
+ resp, body = self.keypairs_client.create_keypair(name)
+ self.addCleanup(self.keypairs_client.delete_keypair, name)
+ return body
+
+ def create_server(self, name=None, image=None, flavor=None,
+ wait_on_boot=True, wait_on_delete=True,
+ create_kwargs=None):
+ """Creates VM instance.
+
+ @param image: image from which to create the instance
+ @param wait_on_boot: wait for status ACTIVE before continue
+ @param wait_on_delete: force synchronous delete on cleanup
+ @param create_kwargs: additional details for instance creation
+ @return: server dict
+ """
+ if name is None:
+ name = data_utils.rand_name(self.__class__.__name__)
+ if image is None:
+ image = CONF.compute.image_ref
+ if flavor is None:
+ flavor = CONF.compute.flavor_ref
+ if create_kwargs is None:
+ create_kwargs = {}
+
+ fixed_network_name = CONF.compute.fixed_network_name
+ if 'nics' not in create_kwargs and fixed_network_name:
+ _, networks = self.networks_client.list_networks()
+ # If several networks found, set the NetID on which to connect the
+ # server to avoid the following error "Multiple possible networks
+ # found, use a Network ID to be more specific."
+ # See Tempest #1250866
+ if len(networks) > 1:
+ for network in networks:
+ if network['label'] == fixed_network_name:
+ create_kwargs['nics'] = [{'net-id': network['id']}]
+ break
+ # If we didn't find the network we were looking for :
+ else:
+ msg = ("The network on which the NIC of the server must "
+ "be connected can not be found : "
+ "fixed_network_name=%s. Starting instance without "
+ "specifying a network.") % fixed_network_name
+ LOG.info(msg)
+
+ LOG.debug("Creating a server (name: %s, image: %s, flavor: %s)",
+ name, image, flavor)
+ _, server = self.servers_client.create_server(name, image, flavor,
+ **create_kwargs)
+ if wait_on_delete:
+ self.addCleanup(self.servers_client.wait_for_server_termination,
+ server['id'])
+ self.addCleanup_with_wait(
+ waiter_callable=self.servers_client.wait_for_server_termination,
+ thing_id=server['id'], thing_id_param='server_id',
+ cleanup_callable=self.delete_wrapper,
+ cleanup_args=[self.servers_client.delete_server, server['id']])
+ if wait_on_boot:
+ self.servers_client.wait_for_server_status(server_id=server['id'],
+ status='ACTIVE')
+ # The instance retrieved on creation is missing network
+ # details, necessitating retrieval after it becomes active to
+ # ensure correct details.
+ _, server = self.servers_client.get_server(server['id'])
+ self.assertEqual(server['name'], name)
+ return server
+
+ def create_volume(self, size=1, name=None, snapshot_id=None,
+ imageRef=None, volume_type=None, wait_on_delete=True):
+ if name is None:
+ name = data_utils.rand_name(self.__class__.__name__)
+ _, volume = self.volumes_client.create_volume(
+ size=size, display_name=name, snapshot_id=snapshot_id,
+ imageRef=imageRef, volume_type=volume_type)
+ if wait_on_delete:
+ self.addCleanup(self.volumes_client.wait_for_resource_deletion,
+ volume['id'])
+ self.addCleanup_with_wait(
+ waiter_callable=self.volumes_client.wait_for_resource_deletion,
+ thing_id=volume['id'], thing_id_param='id',
+ cleanup_callable=self.delete_wrapper,
+ cleanup_args=[self.volumes_client.delete_volume, volume['id']])
+
+ self.assertEqual(name, volume['display_name'])
+ self.volumes_client.wait_for_volume_status(volume['id'], 'available')
+ # The volume retrieved on creation has a non-up-to-date status.
+ # Retrieval after it becomes active ensures correct details.
+ _, volume = self.volumes_client.get_volume(volume['id'])
+ return volume
+
+ def _create_loginable_secgroup_rule(self, secgroup_id=None):
+ _client = self.security_groups_client
+ if secgroup_id is None:
+ _, sgs = _client.list_security_groups()
+ for sg in sgs:
+ if sg['name'] == 'default':
+ secgroup_id = sg['id']
+
+ # These rules are intended to permit inbound ssh and icmp
+ # traffic from all sources, so no group_id is provided.
+ # Setting a group_id would only permit traffic from ports
+ # belonging to the same security group.
+ rulesets = [
+ {
+ # ssh
+ 'ip_proto': 'tcp',
+ 'from_port': 22,
+ 'to_port': 22,
+ 'cidr': '0.0.0.0/0',
+ },
+ {
+ # ping
+ 'ip_proto': 'icmp',
+ 'from_port': -1,
+ 'to_port': -1,
+ 'cidr': '0.0.0.0/0',
+ }
+ ]
+ rules = list()
+ for ruleset in rulesets:
+ _, sg_rule = _client.create_security_group_rule(secgroup_id,
+ **ruleset)
+ self.addCleanup(self.delete_wrapper,
+ _client.delete_security_group_rule,
+ sg_rule['id'])
+ rules.append(sg_rule)
+ return rules
+
+ def _create_security_group(self):
+ # Create security group
+ sg_name = data_utils.rand_name(self.__class__.__name__)
+ sg_desc = sg_name + " description"
+ _, secgroup = self.security_groups_client.create_security_group(
+ sg_name, sg_desc)
+ self.assertEqual(secgroup['name'], sg_name)
+ self.assertEqual(secgroup['description'], sg_desc)
+ self.addCleanup(self.delete_wrapper,
+ self.security_groups_client.delete_security_group,
+ secgroup['id'])
+
+ # Add rules to the security group
+ self._create_loginable_secgroup_rule(secgroup['id'])
+
+ return secgroup
+
+ def get_remote_client(self, server_or_ip, username=None, private_key=None):
+ if isinstance(server_or_ip, six.string_types):
+ ip = server_or_ip
+ else:
+ network_name_for_ssh = CONF.compute.network_for_ssh
+ ip = server_or_ip.networks[network_name_for_ssh][0]
+ if username is None:
+ username = CONF.scenario.ssh_user
+ if private_key is None:
+ private_key = self.keypair['private_key']
+ linux_client = remote_client.RemoteClient(ip, username,
+ pkey=private_key)
+ try:
+ linux_client.validate_authentication()
+ except exceptions.SSHTimeout:
+ LOG.exception('ssh connection to %s failed' % ip)
+ debug.log_net_debug()
+ raise
+
+ return linux_client
+
+ def _image_create(self, name, fmt, path, properties=None):
+ if properties is None:
+ properties = {}
+ name = data_utils.rand_name('%s-' % name)
+ image_file = open(path, 'rb')
+ self.addCleanup(image_file.close)
+ params = {
+ 'name': name,
+ 'container_format': fmt,
+ 'disk_format': fmt,
+ 'is_public': 'False',
+ }
+ params.update(properties)
+ _, image = self.image_client.create_image(**params)
+ self.addCleanup(self.image_client.delete_image, image['id'])
+ self.assertEqual("queued", image['status'])
+ self.image_client.update_image(image['id'], data=image_file)
+ return image['id']
+
+ def glance_image_create(self):
+ img_path = CONF.scenario.img_dir + "/" + CONF.scenario.img_file
+ aki_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.aki_img_file
+ ari_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ari_img_file
+ ami_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ami_img_file
+ img_container_format = CONF.scenario.img_container_format
+ img_disk_format = CONF.scenario.img_disk_format
+ LOG.debug("paths: img: %s, container_fomat: %s, disk_format: %s, "
+ "ami: %s, ari: %s, aki: %s" %
+ (img_path, img_container_format, img_disk_format,
+ ami_img_path, ari_img_path, aki_img_path))
+ try:
+ self.image = self._image_create('scenario-img',
+ img_container_format,
+ img_path,
+ properties={'disk_format':
+ img_disk_format})
+ except IOError:
+ LOG.debug("A qcow2 image was not found. Try to get a uec image.")
+ kernel = self._image_create('scenario-aki', 'aki', aki_img_path)
+ ramdisk = self._image_create('scenario-ari', 'ari', ari_img_path)
+ properties = {
+ 'properties': {'kernel_id': kernel, 'ramdisk_id': ramdisk}
+ }
+ self.image = self._image_create('scenario-ami', 'ami',
+ path=ami_img_path,
+ properties=properties)
+ LOG.debug("image:%s" % self.image)
+
+ def _log_console_output(self, servers=None):
+ if not CONF.compute_feature_enabled.console_output:
+ LOG.debug('Console output not supported, cannot log')
+ return
+ if not servers:
+ _, servers = self.servers_client.list_servers()
+ servers = servers['servers']
+ for server in servers:
+ LOG.debug('Console output for %s', server['id'])
+ LOG.debug(self.servers_client.get_console_output(server['id'],
+ length=None))
+
+ def create_server_snapshot(self, server, name=None):
+ # Glance client
+ _image_client = self.image_client
+ # Compute client
+ _images_client = self.images_client
+ if name is None:
+ name = data_utils.rand_name('scenario-snapshot-')
+ LOG.debug("Creating a snapshot image for server: %s", server['name'])
+ resp, image = _images_client.create_image(server['id'], name)
+ image_id = resp['location'].split('images/')[1]
+ _image_client.wait_for_image_status(image_id, 'active')
+ self.addCleanup_with_wait(
+ waiter_callable=_image_client.wait_for_resource_deletion,
+ thing_id=image_id, thing_id_param='id',
+ cleanup_callable=self.delete_wrapper,
+ cleanup_args=[_image_client.delete_image, image_id])
+ _, snapshot_image = _image_client.get_image_meta(image_id)
+ image_name = snapshot_image['name']
+ self.assertEqual(name, image_name)
+ LOG.debug("Created snapshot image %s for server %s",
+ image_name, server['name'])
+ return snapshot_image
+
+
+# TODO(yfried): change this class name to NetworkScenarioTest once client
+# migration is complete
+class NeutronScenarioTest(ScenarioTest):
+ """Base class for network scenario tests.
+ This class provide helpers for network scenario tests, using the neutron
+ API. Helpers from ancestor which use the nova network API are overridden
+ with the neutron API.
+
+ This Class also enforces using Neutron instead of novanetwork.
+ Subclassed tests will be skipped if Neutron is not enabled
+
+ """
+
+ @classmethod
+ def check_preconditions(cls):
+ if CONF.service_available.neutron:
+ cls.enabled = True
+ # verify that neutron_available is telling the truth
+ try:
+ cls.network_client.list_networks()
+ except exc.EndpointNotFound:
+ cls.enabled = False
+ raise
+ else:
+ cls.enabled = False
+ msg = 'Neutron not available'
+ raise cls.skipException(msg)
+
+ @classmethod
+ def setUpClass(cls):
+ super(NeutronScenarioTest, cls).setUpClass()
+ cls.tenant_id = cls.manager.identity_client.tenant_id
+ cls.check_preconditions()
+
+ def _create_network(self, tenant_id, namestart='network-smoke-'):
+ name = data_utils.rand_name(namestart)
+ _, result = self.network_client.create_network(name=name,
+ tenant_id=tenant_id)
+ network = net_resources.DeletableNetwork(client=self.network_client,
+ **result['network'])
+ self.assertEqual(network.name, name)
+ self.addCleanup(self.delete_wrapper, network.delete)
+ return network
+
+ def _list_networks(self, *args, **kwargs):
+ """List networks using admin creds """
+ return self._admin_lister('networks')(*args, **kwargs)
+
+ def _list_subnets(self, *args, **kwargs):
+ """List subnets using admin creds """
+ return self._admin_lister('subnets')(*args, **kwargs)
+
+ def _list_routers(self, *args, **kwargs):
+ """List routers using admin creds """
+ return self._admin_lister('routers')(*args, **kwargs)
+
+ def _list_ports(self, *args, **kwargs):
+ """List ports using admin creds """
+ return self._admin_lister('ports')(*args, **kwargs)
+
+ def _admin_lister(self, resource_type):
+ def temp(*args, **kwargs):
+ temp_method = self.admin_manager.network_client.__getattr__(
+ 'list_%s' % resource_type)
+ _, resource_list = temp_method(*args, **kwargs)
+ return resource_list[resource_type]
+ return temp
+
+ def _create_subnet(self, network, namestart='subnet-smoke-', **kwargs):
+ """
+ Create a subnet for the given network within the cidr block
+ configured for tenant networks.
+ """
+
+ def cidr_in_use(cidr, tenant_id):
+ """
+ :return True if subnet with cidr already exist in tenant
+ False else
+ """
+ cidr_in_use = self._list_subnets(tenant_id=tenant_id, cidr=cidr)
+ return len(cidr_in_use) != 0
+
+ tenant_cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
+ result = None
+ # Repeatedly attempt subnet creation with sequential cidr
+ # blocks until an unallocated block is found.
+ for subnet_cidr in tenant_cidr.subnet(
+ CONF.network.tenant_network_mask_bits):
+ str_cidr = str(subnet_cidr)
+ if cidr_in_use(str_cidr, tenant_id=network.tenant_id):
+ continue
+
+ subnet = dict(
+ name=data_utils.rand_name(namestart),
+ ip_version=4,
+ network_id=network.id,
+ tenant_id=network.tenant_id,
+ cidr=str_cidr,
+ **kwargs
+ )
+ try:
+ _, result = self.network_client.create_subnet(**subnet)
+ break
+ except exc.NeutronClientException as e:
+ is_overlapping_cidr = 'overlaps with another subnet' in str(e)
+ if not is_overlapping_cidr:
+ raise
+ self.assertIsNotNone(result, 'Unable to allocate tenant network')
+ subnet = net_resources.DeletableSubnet(client=self.network_client,
+ **result['subnet'])
+ self.assertEqual(subnet.cidr, str_cidr)
+ self.addCleanup(self.delete_wrapper, subnet.delete)
+ return subnet
+
+ def _create_port(self, network, namestart='port-quotatest'):
+ name = data_utils.rand_name(namestart)
+ _, result = self.network_client.create_port(
+ name=name,
+ network_id=network.id,
+ tenant_id=network.tenant_id)
+ self.assertIsNotNone(result, 'Unable to allocate port')
+ port = net_resources.DeletablePort(client=self.network_client,
+ **result['port'])
+ self.addCleanup(self.delete_wrapper, port.delete)
+ return port
+
+ def _get_server_port_id(self, server, ip_addr=None):
+ ports = self._list_ports(device_id=server['id'],
+ fixed_ip=ip_addr)
+ self.assertEqual(len(ports), 1,
+ "Unable to determine which port to target.")
+ return ports[0]['id']
+
+ def _get_network_by_name(self, network_name):
+ net = self._list_networks(name=network_name)
+ return net_common.AttributeDict(net[0])
+
+ def _create_floating_ip(self, thing, external_network_id, port_id=None):
+ if not port_id:
+ port_id = self._get_server_port_id(thing)
+ _, result = self.network_client.create_floatingip(
+ floating_network_id=external_network_id,
+ port_id=port_id,
+ tenant_id=thing['tenant_id']
+ )
+ floating_ip = net_resources.DeletableFloatingIp(
+ client=self.network_client,
+ **result['floatingip'])
+ self.addCleanup(self.delete_wrapper, floating_ip.delete)
+ return floating_ip
+
+ def _associate_floating_ip(self, floating_ip, server):
+ port_id = self._get_server_port_id(server)
+ floating_ip.update(port_id=port_id)
+ self.assertEqual(port_id, floating_ip.port_id)
+ return floating_ip
+
+ def _disassociate_floating_ip(self, floating_ip):
+ """
+ :param floating_ip: type DeletableFloatingIp
+ """
+ floating_ip.update(port_id=None)
+ self.assertIsNone(floating_ip.port_id)
+ return floating_ip
+
+ def _ping_ip_address(self, ip_address, should_succeed=True):
+ cmd = ['ping', '-c1', '-w1', ip_address]
+
+ def ping():
+ proc = subprocess.Popen(cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ proc.wait()
+ return (proc.returncode == 0) == should_succeed
+
+ return tempest.test.call_until_true(
+ ping, CONF.compute.ping_timeout, 1)
+
+ def _check_vm_connectivity(self, ip_address,
+ username=None,
+ private_key=None,
+ should_connect=True):
+ """
+ :param ip_address: server to test against
+ :param username: server's ssh username
+ :param private_key: server's ssh private key to be used
+ :param should_connect: True/False indicates positive/negative test
+ positive - attempt ping and ssh
+ negative - attempt ping and fail if succeed
+
+ :raises: AssertError if the result of the connectivity check does
+ not match the value of the should_connect param
+ """
+ if should_connect:
+ msg = "Timed out waiting for %s to become reachable" % ip_address
+ else:
+ msg = "ip address %s is reachable" % ip_address
+ self.assertTrue(self._ping_ip_address(ip_address,
+ should_succeed=should_connect),
+ msg=msg)
+ if should_connect:
+ # no need to check ssh for negative connectivity
+ self.get_remote_client(ip_address, username, private_key)
+
+ def _check_public_network_connectivity(self, ip_address, username,
+ private_key, should_connect=True,
+ msg=None, servers=None):
+ # The target login is assumed to have been configured for
+ # key-based authentication by cloud-init.
+ LOG.debug('checking network connections to IP %s with user: %s' %
+ (ip_address, username))
+ try:
+ self._check_vm_connectivity(ip_address,
+ username,
+ private_key,
+ should_connect=should_connect)
+ except Exception as e:
+ ex_msg = 'Public network connectivity check failed'
+ if msg:
+ ex_msg += ": " + msg
+ LOG.exception(ex_msg)
+ self._log_console_output(servers)
+ # network debug is called as part of ssh init
+ if not isinstance(e, exceptions.SSHTimeout):
+ debug.log_net_debug()
+ raise
+
+ def _check_tenant_network_connectivity(self, server,
+ username,
+ private_key,
+ should_connect=True,
+ servers_for_debug=None):
+ if not CONF.network.tenant_networks_reachable:
+ msg = 'Tenant networks not configured to be reachable.'
+ LOG.info(msg)
+ return
+ # The target login is assumed to have been configured for
+ # key-based authentication by cloud-init.
+ try:
+ for net_name, ip_addresses in server['networks'].iteritems():
+ for ip_address in ip_addresses:
+ self._check_vm_connectivity(ip_address,
+ username,
+ private_key,
+ should_connect=should_connect)
+ except Exception as e:
+ LOG.exception('Tenant network connectivity check failed')
+ self._log_console_output(servers_for_debug)
+ # network debug is called as part of ssh init
+ if not isinstance(e, exceptions.SSHTimeout):
+ debug.log_net_debug()
+ raise
+
+ def _check_remote_connectivity(self, source, dest, should_succeed=True):
+ """
+ check ping server via source ssh connection
+
+ :param source: RemoteClient: an ssh connection from which to ping
+ :param dest: and IP to ping against
+ :param should_succeed: boolean should ping succeed or not
+ :returns: boolean -- should_succeed == ping
+ :returns: ping is false if ping failed
+ """
+ def ping_remote():
+ try:
+ source.ping_host(dest)
+ except exceptions.SSHExecCommandFailed:
+ LOG.warn('Failed to ping IP: %s via a ssh connection from: %s.'
+ % (dest, source.ssh_client.host))
+ return not should_succeed
+ return should_succeed
+
+ return tempest.test.call_until_true(ping_remote,
+ CONF.compute.ping_timeout,
+ 1)
+
+ def _create_security_group(self, tenant_id, client=None,
+ namestart='secgroup-smoke'):
+ if client is None:
+ client = self.network_client
+ secgroup = self._create_empty_security_group(namestart=namestart,
+ client=client,
+ tenant_id=tenant_id)
+
+ # Add rules to the security group
+ rules = self._create_loginable_secgroup_rule(secgroup=secgroup)
+ for rule in rules:
+ self.assertEqual(tenant_id, rule.tenant_id)
+ self.assertEqual(secgroup.id, rule.security_group_id)
+ return secgroup
+
+ def _create_empty_security_group(self, tenant_id, client=None,
+ namestart='secgroup-smoke'):
+ """Create a security group without rules.
+
+ Default rules will be created:
+ - IPv4 egress to any
+ - IPv6 egress to any
+
+ :param tenant_id: secgroup will be created in this tenant
+ :returns: DeletableSecurityGroup -- containing the secgroup created
+ """
+ if client is None:
+ client = self.network_client
+ sg_name = data_utils.rand_name(namestart)
+ sg_desc = sg_name + " description"
+ sg_dict = dict(name=sg_name,
+ description=sg_desc)
+ sg_dict['tenant_id'] = tenant_id
+ _, result = client.create_security_group(**sg_dict)
+ secgroup = net_resources.DeletableSecurityGroup(
+ client=client,
+ **result['security_group']
+ )
+ self.assertEqual(secgroup.name, sg_name)
+ self.assertEqual(tenant_id, secgroup.tenant_id)
+ self.assertEqual(secgroup.description, sg_desc)
+ self.addCleanup(self.delete_wrapper, secgroup.delete)
+ return secgroup
+
+ def _default_security_group(self, tenant_id, client=None):
+ """Get default secgroup for given tenant_id.
+
+ :returns: DeletableSecurityGroup -- default secgroup for given tenant
+ """
+ if client is None:
+ client = self.network_client
+ sgs = [
+ sg for sg in client.list_security_groups().values()[0]
+ if sg['tenant_id'] == tenant_id and sg['name'] == 'default'
+ ]
+ msg = "No default security group for tenant %s." % (tenant_id)
+ self.assertTrue(len(sgs) > 0, msg)
+ if len(sgs) > 1:
+ msg = "Found %d default security groups" % len(sgs)
+ raise exc.NeutronClientNoUniqueMatch(msg=msg)
+ return net_resources.DeletableSecurityGroup(client=client,
+ **sgs[0])
+
+ def _create_security_group_rule(self, client=None, secgroup=None,
+ tenant_id=None, **kwargs):
+ """Create a rule from a dictionary of rule parameters.
+
+ Create a rule in a secgroup. if secgroup not defined will search for
+ default secgroup in tenant_id.
+
+ :param secgroup: type DeletableSecurityGroup.
+ :param secgroup_id: search for secgroup by id
+ default -- choose default secgroup for given tenant_id
+ :param tenant_id: if secgroup not passed -- the tenant in which to
+ search for default secgroup
+ :param kwargs: a dictionary containing rule parameters:
+ for example, to allow incoming ssh:
+ rule = {
+ direction: 'ingress'
+ protocol:'tcp',
+ port_range_min: 22,
+ port_range_max: 22
+ }
+ """
+ if client is None:
+ client = self.network_client
+ if secgroup is None:
+ secgroup = self._default_security_group(tenant_id)
+
+ ruleset = dict(security_group_id=secgroup.id,
+ tenant_id=secgroup.tenant_id)
+ ruleset.update(kwargs)
+
+ _, sg_rule = client.create_security_group_rule(**ruleset)
+ sg_rule = net_resources.DeletableSecurityGroupRule(
+ client=client,
+ **sg_rule['security_group_rule']
+ )
+ self.addCleanup(self.delete_wrapper, sg_rule.delete)
+ self.assertEqual(secgroup.tenant_id, sg_rule.tenant_id)
+ self.assertEqual(secgroup.id, sg_rule.security_group_id)
+
+ return sg_rule
+
+ def _create_loginable_secgroup_rule(self, client=None, secgroup=None):
+ """These rules are intended to permit inbound ssh and icmp
+ traffic from all sources, so no group_id is provided.
+ Setting a group_id would only permit traffic from ports
+ belonging to the same security group.
+ """
+
+ if client is None:
+ client = self.network_client
+ rules = []
+ rulesets = [
+ dict(
+ # ssh
+ protocol='tcp',
+ port_range_min=22,
+ port_range_max=22,
+ ),
+ dict(
+ # ping
+ protocol='icmp',
+ )
+ ]
+ for ruleset in rulesets:
+ for r_direction in ['ingress', 'egress']:
+ ruleset['direction'] = r_direction
+ try:
+ sg_rule = self._create_security_group_rule(
+ client=client, secgroup=secgroup, **ruleset)
+ except exceptions.Conflict as ex:
+ # if rule already exist - skip rule and continue
+ msg = 'Security group rule already exists'
+ if msg not in ex._error_string:
+ raise ex
+ else:
+ self.assertEqual(r_direction, sg_rule.direction)
+ rules.append(sg_rule)
+
+ return rules
+
+ def _ssh_to_server(self, server, private_key):
+ ssh_login = CONF.compute.image_ssh_user
+ return self.get_remote_client(server,
+ username=ssh_login,
+ private_key=private_key)
+
+ def _get_router(self, tenant_id):
+ """Retrieve a router for the given tenant id.
+
+ If a public router has been configured, it will be returned.
+
+ If a public router has not been configured, but a public
+ network has, a tenant router will be created and returned that
+ routes traffic to the public network.
+ """
+ router_id = CONF.network.public_router_id
+ network_id = CONF.network.public_network_id
+ if router_id:
+ result = self.network_client.show_router(router_id)
+ return net_resources.AttributeDict(**result['router'])
+ elif network_id:
+ router = self._create_router(tenant_id)
+ router.set_gateway(network_id)
+ return router
+ else:
+ raise Exception("Neither of 'public_router_id' or "
+ "'public_network_id' has been defined.")
+
+ def _create_router(self, tenant_id, namestart='router-smoke-'):
+ name = data_utils.rand_name(namestart)
+ _, result = self.network_client.create_router(name=name,
+ admin_state_up=True,
+ tenant_id=tenant_id, )
+ router = net_resources.DeletableRouter(client=self.network_client,
+ **result['router'])
+ self.assertEqual(router.name, name)
+ self.addCleanup(self.delete_wrapper, router.delete)
+ return router
+
+ def create_networks(self, tenant_id=None):
+ """Create a network with a subnet connected to a router.
+
+ The baremetal driver is a special case since all nodes are
+ on the same shared network.
+
+ :returns: network, subnet, router
+ """
+ if CONF.baremetal.driver_enabled:
+ # NOTE(Shrews): This exception is for environments where tenant
+ # credential isolation is available, but network separation is
+ # not (the current baremetal case). Likely can be removed when
+ # test account mgmt is reworked:
+ # https://blueprints.launchpad.net/tempest/+spec/test-accounts
+ network = self._get_network_by_name(
+ CONF.compute.fixed_network_name)
+ router = None
+ subnet = None
+ else:
+ if tenant_id is None:
+ tenant_id = self.tenant_id
+ network = self._create_network(tenant_id)
+ router = self._get_router(tenant_id)
+ subnet = self._create_subnet(network)
+ subnet.add_to_router(router.id)
+ return network, subnet, router
+
class OfficialClientTest(tempest.test.BaseTestCase):
"""
@@ -193,8 +1040,8 @@
def addCleanup_with_wait(self, things, thing_id,
error_status='ERROR',
exc_type=nova_exceptions.NotFound,
- cleanup_callable=None, cleanup_args=[],
- cleanup_kwargs={}):
+ cleanup_callable=None, cleanup_args=None,
+ cleanup_kwargs=None):
"""Adds wait for ansyc resource deletion at the end of cleanups
@param things: type of the resource to delete
@@ -206,6 +1053,10 @@
usually a delete method. if not used, will try to use:
things.delete(thing_id)
"""
+ if cleanup_args is None:
+ cleanup_args = []
+ if cleanup_kwargs is None:
+ cleanup_kwargs = {}
if cleanup_callable is None:
LOG.debug("no delete method passed. using {rclass}.delete({id}) as"
" default".format(rclass=things, id=thing_id))
@@ -323,11 +1174,25 @@
'cidr': '0.0.0.0/0',
},
{
+ # ssh -6
+ 'ip_protocol': 'tcp',
+ 'from_port': 22,
+ 'to_port': 22,
+ 'cidr': '::/0',
+ },
+ {
# ping
'ip_protocol': 'icmp',
'from_port': -1,
'to_port': -1,
'cidr': '0.0.0.0/0',
+ },
+ {
+ # ping6
+ 'ip_protocol': 'icmp',
+ 'from_port': -1,
+ 'to_port': -1,
+ 'cidr': '::/0',
}
]
rules = list()
@@ -373,7 +1238,7 @@
def create_server(self, client=None, name=None, image=None, flavor=None,
wait_on_boot=True, wait_on_delete=True,
- create_kwargs={}):
+ create_kwargs=None):
"""Creates VM instance.
@param client: compute client to create the instance
@@ -391,6 +1256,8 @@
image = CONF.compute.image_ref
if flavor is None:
flavor = CONF.compute.flavor_ref
+ if create_kwargs is None:
+ create_kwargs = {}
fixed_network_name = CONF.compute.fixed_network_name
if 'nics' not in create_kwargs and fixed_network_name:
@@ -520,7 +1387,9 @@
self.status_timeout(
self.volume_client.volumes, volume_id, status)
- def _image_create(self, name, fmt, path, properties={}):
+ def _image_create(self, name, fmt, path, properties=None):
+ if properties is None:
+ properties = {}
name = data_utils.rand_name('%s-' % name)
image_file = open(path, 'rb')
self.addCleanup(image_file.close)
@@ -538,19 +1407,22 @@
return image.id
def glance_image_create(self):
- qcow2_img_path = (CONF.scenario.img_dir + "/" +
- CONF.scenario.qcow2_img_file)
+ img_path = CONF.scenario.img_dir + "/" + CONF.scenario.img_file
aki_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.aki_img_file
ari_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ari_img_file
ami_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ami_img_file
- LOG.debug("paths: img: %s, ami: %s, ari: %s, aki: %s"
- % (qcow2_img_path, ami_img_path, ari_img_path, aki_img_path))
+ img_container_format = CONF.scenario.img_container_format
+ img_disk_format = CONF.scenario.img_disk_format
+ LOG.debug("paths: img: %s, container_fomat: %s, disk_format: %s, "
+ "ami: %s, ari: %s, aki: %s" %
+ (img_path, img_container_format, img_disk_format,
+ ami_img_path, ari_img_path, aki_img_path))
try:
self.image = self._image_create('scenario-img',
- 'bare',
- qcow2_img_path,
+ img_container_format,
+ img_path,
properties={'disk_format':
- 'qcow2'})
+ img_disk_format})
except IOError:
LOG.debug("A qcow2 image was not found. Try to get a uec image.")
kernel = self._image_create('scenario-aki', 'aki', aki_img_path)
@@ -919,6 +1791,10 @@
"Unable to determine which port to target.")
return ports[0]['id']
+ def _get_network_by_name(self, network_name):
+ net = self._list_networks(name=network_name)
+ return net_common.AttributeDict(net[0])
+
def _create_floating_ip(self, thing, external_network_id, port_id=None):
if not port_id:
port_id = self._get_server_port_id(thing)
@@ -1316,17 +2192,31 @@
self.addCleanup(self.delete_wrapper, router)
return router
- def _create_networks(self, tenant_id=None):
+ def create_networks(self, tenant_id=None):
"""Create a network with a subnet connected to a router.
+ The baremetal driver is a special case since all nodes are
+ on the same shared network.
+
:returns: network, subnet, router
"""
- if tenant_id is None:
- tenant_id = self.tenant_id
- network = self._create_network(tenant_id)
- router = self._get_router(tenant_id)
- subnet = self._create_subnet(network)
- subnet.add_to_router(router.id)
+ if CONF.baremetal.driver_enabled:
+ # NOTE(Shrews): This exception is for environments where tenant
+ # credential isolation is available, but network separation is
+ # not (the current baremetal case). Likely can be removed when
+ # test account mgmt is reworked:
+ # https://blueprints.launchpad.net/tempest/+spec/test-accounts
+ network = self._get_network_by_name(
+ CONF.compute.fixed_network_name)
+ router = None
+ subnet = None
+ else:
+ if tenant_id is None:
+ tenant_id = self.tenant_id
+ network = self._create_network(tenant_id)
+ router = self._get_router(tenant_id)
+ subnet = self._create_subnet(network)
+ subnet.add_to_router(router.id)
return network, subnet, router
@@ -1459,3 +2349,86 @@
self.client.stacks.delete(stack_identifier)
except heat_exceptions.HTTPNotFound:
pass
+
+
+class SwiftScenarioTest(ScenarioTest):
+ """
+ Provide harness to do Swift scenario tests.
+
+ Subclasses implement the tests that use the methods provided by this
+ class.
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ cls.set_network_resources()
+ super(SwiftScenarioTest, cls).setUpClass()
+ if not CONF.service_available.swift:
+ skip_msg = ("%s skipped as swift is not available" %
+ cls.__name__)
+ raise cls.skipException(skip_msg)
+ # Clients for Swift
+ cls.account_client = cls.manager.account_client
+ cls.container_client = cls.manager.container_client
+ cls.object_client = cls.manager.object_client
+
+ def _get_swift_stat(self):
+ """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):
+ name = container_name or data_utils.rand_name(
+ 'swift-scenario-container')
+ self.container_client.create_container(name)
+ # look for the container to assure it is created
+ self._list_and_check_container_objects(name)
+ LOG.debug('Container %s created' % (name))
+ return name
+
+ def _delete_container(self, container_name):
+ self.container_client.delete_container(container_name)
+ LOG.debug('Container %s deleted' % (container_name))
+
+ def _upload_object_to_container(self, container_name, obj_name=None):
+ obj_name = obj_name or data_utils.rand_name('swift-scenario-object')
+ obj_data = data_utils.arbitrary_string()
+ self.object_client.create_object(container_name, obj_name, obj_data)
+ return obj_name, obj_data
+
+ def _delete_object(self, container_name, filename):
+ self.object_client.delete_object(container_name, filename)
+ self._list_and_check_container_objects(container_name,
+ not_present_obj=[filename])
+
+ def _list_and_check_container_objects(self, container_name,
+ present_obj=None,
+ not_present_obj=None):
+ """
+ List objects for a given container and assert which are present and
+ which are not.
+ """
+ if present_obj is None:
+ present_obj = []
+ if not_present_obj is None:
+ not_present_obj = []
+ _, object_list = self.container_client.list_container_contents(
+ container_name)
+ if present_obj:
+ for obj in present_obj:
+ self.assertIn(obj, object_list)
+ if not_present_obj:
+ for obj in not_present_obj:
+ self.assertNotIn(obj, object_list)
+
+ def _change_container_acl(self, container_name, acl):
+ metadata_param = {'metadata_prefix': 'x-container-',
+ 'metadata': {'read': acl}}
+ self.container_client.update_container_metadata(container_name,
+ **metadata_param)
+ resp, _ = self.container_client.list_container_metadata(container_name)
+ self.assertEqual(resp['x-container-read'], acl)
+
+ def _download_and_verify(self, container_name, obj_name, expected_data):
+ _, obj = self.object_client.get_object(container_name, obj_name)
+ self.assertEqual(obj, expected_data)
diff --git a/tempest/scenario/test_aggregates_basic_ops.py b/tempest/scenario/test_aggregates_basic_ops.py
index 0059619..3ad5c69 100644
--- a/tempest/scenario/test_aggregates_basic_ops.py
+++ b/tempest/scenario/test_aggregates_basic_ops.py
@@ -23,7 +23,7 @@
LOG = logging.getLogger(__name__)
-class TestAggregatesBasicOps(manager.OfficialClientTest):
+class TestAggregatesBasicOps(manager.ScenarioTest):
"""
Creates an aggregate within an availability zone
Adds a host to the aggregate
@@ -33,74 +33,67 @@
Deletes aggregate
"""
@classmethod
+ def setUpClass(cls):
+ super(TestAggregatesBasicOps, cls).setUpClass()
+ cls.aggregates_client = cls.manager.aggregates_client
+ cls.hosts_client = cls.manager.hosts_client
+
+ @classmethod
def credentials(cls):
return cls.admin_credentials()
def _create_aggregate(self, **kwargs):
- aggregate = self.compute_client.aggregates.create(**kwargs)
+ _, aggregate = self.aggregates_client.create_aggregate(**kwargs)
+ self.addCleanup(self._delete_aggregate, aggregate)
aggregate_name = kwargs['name']
availability_zone = kwargs['availability_zone']
- self.assertEqual(aggregate.name, aggregate_name)
- self.assertEqual(aggregate.availability_zone, availability_zone)
- self.addCleanup(self._delete_aggregate, aggregate)
- LOG.debug("Aggregate %s created." % (aggregate.name))
+ self.assertEqual(aggregate['name'], aggregate_name)
+ self.assertEqual(aggregate['availability_zone'], availability_zone)
return aggregate
def _delete_aggregate(self, aggregate):
- self.compute_client.aggregates.delete(aggregate.id)
- LOG.debug("Aggregate %s deleted. " % (aggregate.name))
+ self.aggregates_client.delete_aggregate(aggregate['id'])
def _get_host_name(self):
- hosts = self.compute_client.hosts.list()
+ _, hosts = self.hosts_client.list_hosts()
self.assertTrue(len(hosts) >= 1)
- computes = [x for x in hosts if x.service == 'compute']
- return computes[0].host_name
+ computes = [x for x in hosts if x['service'] == 'compute']
+ return computes[0]['host_name']
- def _add_host(self, aggregate_name, host):
- aggregate = self.compute_client.aggregates.add_host(aggregate_name,
- host)
- self.addCleanup(self._remove_host, aggregate, host)
- self.assertIn(host, aggregate.hosts)
- LOG.debug("Host %s added to Aggregate %s." % (host, aggregate.name))
+ def _add_host(self, aggregate_id, host):
+ _, aggregate = self.aggregates_client.add_host(aggregate_id, host)
+ self.addCleanup(self._remove_host, aggregate['id'], host)
+ self.assertIn(host, aggregate['hosts'])
- def _remove_host(self, aggregate_name, host):
- aggregate = self.compute_client.aggregates.remove_host(aggregate_name,
- host)
- self.assertNotIn(host, aggregate.hosts)
- LOG.debug("Host %s removed to Aggregate %s." % (host, aggregate.name))
+ def _remove_host(self, aggregate_id, host):
+ _, aggregate = self.aggregates_client.remove_host(aggregate_id, host)
+ self.assertNotIn(host, aggregate['hosts'])
def _check_aggregate_details(self, aggregate, aggregate_name, azone,
hosts, metadata):
- aggregate = self.compute_client.aggregates.get(aggregate.id)
- self.assertEqual(aggregate_name, aggregate.name)
- self.assertEqual(azone, aggregate.availability_zone)
- self.assertEqual(aggregate.hosts, hosts)
+ _, aggregate = self.aggregates_client.get_aggregate(aggregate['id'])
+ self.assertEqual(aggregate_name, aggregate['name'])
+ self.assertEqual(azone, aggregate['availability_zone'])
+ self.assertEqual(hosts, aggregate['hosts'])
for meta_key in metadata.keys():
- self.assertIn(meta_key, aggregate.metadata)
- self.assertEqual(metadata[meta_key], aggregate.metadata[meta_key])
- LOG.debug("Aggregate %s details match." % aggregate.name)
+ self.assertIn(meta_key, aggregate['metadata'])
+ self.assertEqual(metadata[meta_key],
+ aggregate['metadata'][meta_key])
def _set_aggregate_metadata(self, aggregate, meta):
- aggregate = self.compute_client.aggregates.set_metadata(aggregate.id,
- meta)
+ _, aggregate = self.aggregates_client.set_metadata(aggregate['id'],
+ meta)
for key, value in meta.items():
- self.assertEqual(meta[key], aggregate.metadata[key])
- LOG.debug("Aggregate %s metadata updated successfully." %
- aggregate.name)
+ self.assertEqual(meta[key], aggregate['metadata'][key])
def _update_aggregate(self, aggregate, aggregate_name,
availability_zone):
- values = {}
- if aggregate_name:
- values.update({'name': aggregate_name})
- if availability_zone:
- values.update({'availability_zone': availability_zone})
- if values.keys():
- aggregate = self.compute_client.aggregates.update(aggregate.id,
- values)
- for key, values in values.items():
- self.assertEqual(getattr(aggregate, key), values)
+ _, aggregate = self.aggregates_client.update_aggregate(
+ aggregate['id'], name=aggregate_name,
+ availability_zone=availability_zone)
+ self.assertEqual(aggregate['name'], aggregate_name)
+ self.assertEqual(aggregate['availability_zone'], availability_zone)
return aggregate
@test.services('compute')
@@ -115,16 +108,17 @@
self._set_aggregate_metadata(aggregate, metadata)
host = self._get_host_name()
- self._add_host(aggregate, host)
+ self._add_host(aggregate['id'], host)
self._check_aggregate_details(aggregate, aggregate_name, az, [host],
metadata)
aggregate_name = data_utils.rand_name('renamed-aggregate-scenario')
- aggregate = self._update_aggregate(aggregate, aggregate_name, None)
+ # Updating the name alone. The az must be specified again otherwise
+ # the tempest client would send None in the put body
+ aggregate = self._update_aggregate(aggregate, aggregate_name, az)
- additional_metadata = {'foo': 'bar'}
- self._set_aggregate_metadata(aggregate, additional_metadata)
+ new_metadata = {'foo': 'bar'}
+ self._set_aggregate_metadata(aggregate, new_metadata)
- metadata.update(additional_metadata)
- self._check_aggregate_details(aggregate, aggregate.name, az, [host],
- metadata)
+ self._check_aggregate_details(aggregate, aggregate['name'], az,
+ [host], new_metadata)
diff --git a/tempest/scenario/test_load_balancer_basic.py b/tempest/scenario/test_load_balancer_basic.py
index a4ec3c9..35e50e8 100644
--- a/tempest/scenario/test_load_balancer_basic.py
+++ b/tempest/scenario/test_load_balancer_basic.py
@@ -73,6 +73,35 @@
self.server_ips = {}
self.server_fixed_ips = {}
self._create_security_group()
+ self._set_net_and_subnet()
+
+ def _set_net_and_subnet(self):
+ """
+ Query and set appropriate network and subnet attributes to be used
+ for the test. Existing tenant networks are used if they are found.
+ The configured private network and associated subnet is used as a
+ fallback in absence of tenant networking.
+ """
+ try:
+ tenant_net = self._list_networks(tenant_id=self.tenant_id)[0]
+ except IndexError:
+ tenant_net = None
+
+ if tenant_net:
+ tenant_subnet = self._list_subnets(tenant_id=self.tenant_id)[0]
+ self.subnet = net_common.DeletableSubnet(
+ client=self.network_client,
+ **tenant_subnet)
+ self.network = tenant_net
+ else:
+ self.network = self._get_network_by_name(
+ config.compute.fixed_network_name)
+ # TODO(adam_g): We are assuming that the first subnet associated
+ # with the fixed network is the one we want. In the future, we
+ # should instead pull a subnet id from config, which is set by
+ # devstack/admin/etc.
+ subnet = self._list_subnets(network_id=self.network['id'])[0]
+ self.subnet = net_common.AttributeDict(subnet)
def _create_security_group(self):
self.security_group = self._create_security_group_neutron(
@@ -96,10 +125,9 @@
def _create_server(self, name):
keypair = self.create_keypair(name='keypair-%s' % name)
security_groups = [self.security_group.name]
- net = self._list_networks(tenant_id=self.tenant_id)[0]
create_kwargs = {
'nics': [
- {'net-id': net['id']},
+ {'net-id': self.network['id']},
],
'key_name': keypair.name,
'security_groups': security_groups,
@@ -107,6 +135,7 @@
server = self.create_server(name=name,
create_kwargs=create_kwargs)
self.servers_keypairs[server.id] = keypair
+ net_name = self.network['name']
if (config.network.public_network_id and not
config.network.tenant_networks_reachable):
public_network_id = config.network.public_network_id
@@ -115,8 +144,8 @@
self.floating_ips[floating_ip] = server
self.server_ips[server.id] = floating_ip.floating_ip_address
else:
- self.server_ips[server.id] = server.networks[net['name']][0]
- self.server_fixed_ips[server.id] = server.networks[net['name']][0]
+ self.server_ips[server.id] = server.networks[net_name][0]
+ self.server_fixed_ips[server.id] = server.networks[net_name][0]
self.assertTrue(self.servers_keypairs)
return server
@@ -132,7 +161,6 @@
1. SSH to the instance
2. Start two http backends listening on ports 80 and 88 respectively
"""
-
for server_id, ip in self.server_ips.iteritems():
private_key = self.servers_keypairs[server_id].private_key
server_name = self.compute_client.servers.get(server_id).name
@@ -196,10 +224,6 @@
def _create_pool(self):
"""Create a pool with ROUND_ROBIN algorithm."""
- # get tenant subnet and verify there's only one
- subnet = self._list_subnets(tenant_id=self.tenant_id)[0]
- self.subnet = net_common.DeletableSubnet(client=self.network_client,
- **subnet)
self.pool = super(TestLoadBalancerBasic, self)._create_pool(
lb_method='ROUND_ROBIN',
protocol='HTTP',
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index 29fdc74..8a8e387 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest.common import custom_matchers
from tempest.common import debug
from tempest import config
from tempest.openstack.common import log as logging
@@ -24,7 +25,7 @@
LOG = logging.getLogger(__name__)
-class TestMinimumBasicScenario(manager.OfficialClientTest):
+class TestMinimumBasicScenario(manager.ScenarioTest):
"""
This is a basic minimum scenario test.
@@ -38,61 +39,69 @@
"""
def _wait_for_server_status(self, status):
- server_id = self.server.id
- self.status_timeout(
- self.compute_client.servers, server_id, status)
+ server_id = self.server['id']
+ # Raise on error defaults to True, which is consistent with the
+ # original function from scenario tests here
+ self.servers_client.wait_for_server_status(server_id, status)
def nova_keypair_add(self):
self.keypair = self.create_keypair()
def nova_boot(self):
- create_kwargs = {'key_name': self.keypair.name}
+ create_kwargs = {'key_name': self.keypair['name']}
self.server = self.create_server(image=self.image,
create_kwargs=create_kwargs)
def nova_list(self):
- servers = self.compute_client.servers.list()
- LOG.debug("server_list:%s" % servers)
- self.assertIn(self.server, servers)
+ _, servers = self.servers_client.list_servers()
+ # The list servers in the compute client is inconsistent...
+ servers = servers['servers']
+ self.assertIn(self.server['id'], [x['id'] for x in servers])
def nova_show(self):
- got_server = self.compute_client.servers.get(self.server)
- LOG.debug("got server:%s" % got_server)
- self.assertEqual(self.server, got_server)
+ _, got_server = self.servers_client.get_server(self.server['id'])
+ self.assertThat(
+ self.server, custom_matchers.MatchesDictExceptForKeys(
+ got_server, excluded_keys=['OS-EXT-AZ:availability_zone']))
def cinder_create(self):
self.volume = self.create_volume()
def cinder_list(self):
- volumes = self.volume_client.volumes.list()
- self.assertIn(self.volume, volumes)
+ _, volumes = self.volumes_client.list_volumes()
+ self.assertIn(self.volume['id'], [x['id'] for x in volumes])
def cinder_show(self):
- volume = self.volume_client.volumes.get(self.volume.id)
+ _, volume = self.volumes_client.get_volume(self.volume['id'])
self.assertEqual(self.volume, volume)
def nova_volume_attach(self):
- attach_volume_client = self.compute_client.volumes.create_server_volume
- volume = attach_volume_client(self.server.id,
- self.volume.id,
- '/dev/vdb')
- self.assertEqual(self.volume.id, volume.id)
- self.wait_for_volume_status('in-use')
+ volume_device_path = '/dev/' + CONF.compute.volume_device_name
+ _, volume_attachment = self.servers_client.attach_volume(
+ self.server['id'], self.volume['id'], volume_device_path)
+ volume = volume_attachment['volumeAttachment']
+ self.assertEqual(self.volume['id'], volume['id'])
+ self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
+ # Refresh the volume after the attachment
+ _, self.volume = self.volumes_client.get_volume(volume['id'])
def nova_reboot(self):
- self.server.reboot()
+ self.servers_client.reboot(self.server['id'], 'SOFT')
self._wait_for_server_status('ACTIVE')
def nova_floating_ip_create(self):
- self.floating_ip = self.compute_client.floating_ips.create()
- self.addCleanup(self.delete_wrapper, self.floating_ip)
+ _, self.floating_ip = self.floating_ips_client.create_floating_ip()
+ self.addCleanup(self.delete_wrapper,
+ self.floating_ips_client.delete_floating_ip,
+ self.floating_ip['id'])
def nova_floating_ip_add(self):
- self.server.add_floating_ip(self.floating_ip)
+ self.floating_ips_client.associate_floating_ip_to_server(
+ self.floating_ip['ip'], self.server['id'])
def ssh_to_server(self):
try:
- self.linux_client = self.get_remote_client(self.floating_ip.ip)
+ self.linux_client = self.get_remote_client(self.floating_ip['ip'])
except Exception as e:
LOG.exception('ssh to server failed')
self._log_console_output()
@@ -102,21 +111,24 @@
raise
def check_partitions(self):
+ # NOTE(andreaf) The device name may be different on different guest OS
partitions = self.linux_client.get_partitions()
- self.assertEqual(1, partitions.count('vdb'))
+ self.assertEqual(1, partitions.count(CONF.compute.volume_device_name))
def nova_volume_detach(self):
- detach_volume_client = self.compute_client.volumes.delete_server_volume
- detach_volume_client(self.server.id, self.volume.id)
- self.wait_for_volume_status('available')
+ self.servers_client.detach_volume(self.server['id'], self.volume['id'])
+ self.volumes_client.wait_for_volume_status(self.volume['id'],
+ 'available')
- volume = self.volume_client.volumes.get(self.volume.id)
- self.assertEqual('available', volume.status)
+ _, volume = self.volumes_client.get_volume(self.volume['id'])
+ self.assertEqual('available', volume['status'])
def create_and_add_security_group(self):
- secgroup = self._create_security_group_nova()
- self.server.add_security_group(secgroup.name)
- self.addCleanup(self.server.remove_security_group, secgroup.name)
+ secgroup = self._create_security_group()
+ self.servers_client.add_security_group(self.server['id'],
+ secgroup['name'])
+ self.addCleanup(self.servers_client.remove_security_group,
+ self.server['id'], secgroup['name'])
@test.services('compute', 'volume', 'image', 'network')
def test_minimum_basic_scenario(self):
diff --git a/tempest/scenario/test_network_advanced_server_ops.py b/tempest/scenario/test_network_advanced_server_ops.py
index 431de9a..47f2f1a 100644
--- a/tempest/scenario/test_network_advanced_server_ops.py
+++ b/tempest/scenario/test_network_advanced_server_ops.py
@@ -50,16 +50,13 @@
cls.enabled = False
raise cls.skipException(msg)
- def setUp(self):
- super(TestNetworkAdvancedServerOps, self).setUp()
+ def _setup_network_and_servers(self):
key_name = data_utils.rand_name('keypair-smoke-')
self.keypair = self.create_keypair(name=key_name)
security_group =\
self._create_security_group_neutron(tenant_id=self.tenant_id)
- network = self._create_network(self.tenant_id)
- router = self._get_router(self.tenant_id)
- subnet = self._create_subnet(network)
- subnet.add_to_router(router.id)
+ network, subnet, router = self.create_networks(self.tenant_id)
+
public_network_id = CONF.network.public_network_id
create_kwargs = {
'nics': [
@@ -68,11 +65,14 @@
'key_name': self.keypair.name,
'security_groups': [security_group.name],
}
- server_name = data_utils.rand_name('server-smoke-%d-')
+ server_name = data_utils.rand_name('server-smoke')
self.server = self.create_server(name=server_name,
create_kwargs=create_kwargs)
self.floating_ip = self._create_floating_ip(self.server,
public_network_id)
+ # Verify that we can indeed connect to the server before we mess with
+ # it's state
+ self._wait_server_status_and_check_network_connectivity()
def _check_network_connectivity(self, should_connect=True):
username = CONF.compute.image_ssh_user
@@ -92,6 +92,7 @@
@test.services('compute', 'network')
def test_server_connectivity_stop_start(self):
+ self._setup_network_and_servers()
self.server.stop()
self.status_timeout(self.compute_client.servers, self.server.id,
'SHUTOFF')
@@ -101,11 +102,13 @@
@test.services('compute', 'network')
def test_server_connectivity_reboot(self):
+ self._setup_network_and_servers()
self.server.reboot()
self._wait_server_status_and_check_network_connectivity()
@test.services('compute', 'network')
def test_server_connectivity_rebuild(self):
+ self._setup_network_and_servers()
image_ref_alt = CONF.compute.image_ref_alt
self.server.rebuild(image_ref_alt)
self._wait_server_status_and_check_network_connectivity()
@@ -114,6 +117,7 @@
'Pause is not available.')
@test.services('compute', 'network')
def test_server_connectivity_pause_unpause(self):
+ self._setup_network_and_servers()
self.server.pause()
self.status_timeout(self.compute_client.servers, self.server.id,
'PAUSED')
@@ -125,6 +129,7 @@
'Suspend is not available.')
@test.services('compute', 'network')
def test_server_connectivity_suspend_resume(self):
+ self._setup_network_and_servers()
self.server.suspend()
self.status_timeout(self.compute_client.servers, self.server.id,
'SUSPENDED')
@@ -140,6 +145,7 @@
if resize_flavor == CONF.compute.flavor_ref:
msg = "Skipping test - flavor_ref and flavor_ref_alt are identical"
raise self.skipException(msg)
+ self._setup_network_and_servers()
resize_flavor = CONF.compute.flavor_ref_alt
self.server.resize(resize_flavor)
self.status_timeout(self.compute_client.servers, self.server.id,
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index fc6c66c..21a5d1b 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -18,12 +18,13 @@
import testtools
-from tempest.api.network import common as net_common
from tempest.common import debug
from tempest.common.utils import data_utils
from tempest import config
+from tempest import exceptions
from tempest.openstack.common import log as logging
from tempest.scenario import manager
+from tempest.services.network import resources as net_resources
from tempest import test
CONF = config.CONF
@@ -33,7 +34,7 @@
['floating_ip', 'server'])
-class TestNetworkBasicOps(manager.NetworkScenarioTest):
+class TestNetworkBasicOps(manager.NeutronScenarioTest):
"""
This smoke test suite assumes that Nova has been configured to
@@ -95,21 +96,23 @@
if not test.is_extension_enabled(ext, 'network'):
msg = "%s extension not enabled." % ext
raise cls.skipException(msg)
- cls.check_preconditions()
def setUp(self):
super(TestNetworkBasicOps, self).setUp()
+ self.keypairs = {}
+ self.servers = []
+
+ def _setup_network_and_servers(self):
self.security_group = \
- self._create_security_group_neutron(tenant_id=self.tenant_id)
- self.network, self.subnet, self.router = self._create_networks()
+ self._create_security_group(tenant_id=self.tenant_id)
+ self.network, self.subnet, self.router = self.create_networks()
self.check_networks()
- self.servers = {}
+
name = data_utils.rand_name('server-smoke')
- serv_dict = self._create_server(name, self.network)
- self.servers[serv_dict['server']] = serv_dict['keypair']
+ server = self._create_server(name, self.network)
self._check_tenant_network_connectivity()
- self._create_and_associate_floating_ips()
+ self._create_and_associate_floating_ips(server)
def check_networks(self):
"""
@@ -123,47 +126,53 @@
self.assertIn(self.network.name, seen_names)
self.assertIn(self.network.id, seen_ids)
- seen_subnets = self._list_subnets()
- seen_net_ids = [n['network_id'] for n in seen_subnets]
- seen_subnet_ids = [n['id'] for n in seen_subnets]
- self.assertIn(self.network.id, seen_net_ids)
- self.assertIn(self.subnet.id, seen_subnet_ids)
+ if self.subnet:
+ seen_subnets = self._list_subnets()
+ seen_net_ids = [n['network_id'] for n in seen_subnets]
+ seen_subnet_ids = [n['id'] for n in seen_subnets]
+ self.assertIn(self.network.id, seen_net_ids)
+ self.assertIn(self.subnet.id, seen_subnet_ids)
- seen_routers = self._list_routers()
- seen_router_ids = [n['id'] for n in seen_routers]
- seen_router_names = [n['name'] for n in seen_routers]
- self.assertIn(self.router.name,
- seen_router_names)
- self.assertIn(self.router.id,
- seen_router_ids)
+ if self.router:
+ seen_routers = self._list_routers()
+ seen_router_ids = [n['id'] for n in seen_routers]
+ seen_router_names = [n['name'] for n in seen_routers]
+ self.assertIn(self.router.name,
+ seen_router_names)
+ self.assertIn(self.router.id,
+ seen_router_ids)
def _create_server(self, name, network):
- keypair = self.create_keypair(name='keypair-%s' % name)
- security_groups = [self.security_group.name]
+ keypair = self.create_keypair()
+ self.keypairs[keypair['name']] = keypair
+ security_groups = [self.security_group]
create_kwargs = {
'nics': [
{'net-id': network.id},
],
- 'key_name': keypair.name,
+ 'key_name': keypair['name'],
'security_groups': security_groups,
}
server = self.create_server(name=name, create_kwargs=create_kwargs)
- return dict(server=server, keypair=keypair)
+ self.servers.append(server)
+ return server
+
+ def _get_server_key(self, server):
+ return self.keypairs[server['key_name']]['private_key']
def _check_tenant_network_connectivity(self):
ssh_login = CONF.compute.image_ssh_user
- for server, key in self.servers.iteritems():
+ for server in self.servers:
# call the common method in the parent class
super(TestNetworkBasicOps, self).\
_check_tenant_network_connectivity(
- server, ssh_login, key.private_key,
- servers_for_debug=self.servers.keys())
+ server, ssh_login, self._get_server_key(server),
+ servers_for_debug=self.servers)
- def _create_and_associate_floating_ips(self):
+ def _create_and_associate_floating_ips(self, server):
public_network_id = CONF.network.public_network_id
- for server in self.servers.keys():
- floating_ip = self._create_floating_ip(server, public_network_id)
- self.floating_ip_tuple = Floating_IP_tuple(floating_ip, server)
+ floating_ip = self._create_floating_ip(server, public_network_id)
+ self.floating_ip_tuple = Floating_IP_tuple(floating_ip, server)
def _check_public_network_connectivity(self, should_connect=True,
msg=None):
@@ -172,11 +181,11 @@
ip_address = floating_ip.floating_ip_address
private_key = None
if should_connect:
- private_key = self.servers[server].private_key
+ private_key = self._get_server_key(server)
# call the common method in the parent class
super(TestNetworkBasicOps, self)._check_public_network_connectivity(
ip_address, ssh_login, private_key, should_connect, msg,
- self.servers.keys())
+ self.servers)
def _disassociate_floating_ips(self):
floating_ip, server = self.floating_ip_tuple
@@ -188,11 +197,10 @@
floating_ip, server = self.floating_ip_tuple
name = data_utils.rand_name('new_server-smoke-')
# create a new server for the floating ip
- serv_dict = self._create_server(name, self.network)
- self.servers[serv_dict['server']] = serv_dict['keypair']
- self._associate_floating_ip(floating_ip, serv_dict['server'])
+ server = self._create_server(name, self.network)
+ self._associate_floating_ip(floating_ip, server)
self.floating_ip_tuple = Floating_IP_tuple(
- floating_ip, serv_dict['server'])
+ floating_ip, server)
def _create_new_network(self):
self.new_net = self._create_network(self.tenant_id)
@@ -203,42 +211,50 @@
def _hotplug_server(self):
old_floating_ip, server = self.floating_ip_tuple
ip_address = old_floating_ip.floating_ip_address
- private_key = self.servers[server].private_key
+ private_key = self._get_server_key(server)
ssh_client = self.get_remote_client(ip_address,
private_key=private_key)
old_nic_list = self._get_server_nics(ssh_client)
# get a port from a list of one item
- port_list = self._list_ports(device_id=server.id)
+ port_list = self._list_ports(device_id=server['id'])
self.assertEqual(1, len(port_list))
old_port = port_list[0]
- self.compute_client.servers.interface_attach(server=server,
- net_id=self.new_net.id,
- port_id=None,
- fixed_ip=None)
- # move server to the head of the cleanup list
- self.addCleanup(self.delete_timeout,
- self.compute_client.servers,
- server.id)
- self.addCleanup(self.delete_wrapper, server)
+ _, interface = self.interface_client.create_interface(
+ server=server['id'],
+ network_id=self.new_net.id)
+ self.addCleanup(self.network_client.wait_for_resource_deletion,
+ 'port',
+ interface['port_id'])
+ self.addCleanup(self.delete_wrapper,
+ self.interface_client.delete_interface,
+ server['id'], interface['port_id'])
def check_ports():
- port_list = [port for port in
- self._list_ports(device_id=server.id)
- if port != old_port]
- return len(port_list) == 1
+ self.new_port_list = [port for port in
+ self._list_ports(device_id=server['id'])
+ if port != old_port]
+ return len(self.new_port_list) == 1
- test.call_until_true(check_ports, 60, 1)
- new_port_list = [p for p in
- self._list_ports(device_id=server.id)
- if p != old_port]
- self.assertEqual(1, len(new_port_list))
- new_port = new_port_list[0]
- new_port = net_common.DeletablePort(client=self.network_client,
- **new_port)
- new_nic_list = self._get_server_nics(ssh_client)
- diff_list = [n for n in new_nic_list if n not in old_nic_list]
- self.assertEqual(1, len(diff_list))
- num, new_nic = diff_list[0]
+ if not test.call_until_true(check_ports, CONF.network.build_timeout,
+ CONF.network.build_interval):
+ raise exceptions.TimeoutException("No new port attached to the "
+ "server in time (%s sec) !"
+ % CONF.network.build_timeout)
+ new_port = net_resources.DeletablePort(client=self.network_client,
+ **self.new_port_list[0])
+
+ def check_new_nic():
+ new_nic_list = self._get_server_nics(ssh_client)
+ self.diff_list = [n for n in new_nic_list if n not in old_nic_list]
+ return len(self.diff_list) == 1
+
+ if not test.call_until_true(check_new_nic, CONF.network.build_timeout,
+ CONF.network.build_interval):
+ raise exceptions.TimeoutException("Interface not visible on the "
+ "guest after %s sec"
+ % CONF.network.build_timeout)
+
+ num, new_nic = self.diff_list[0]
ssh_client.assign_static_ip(nic=new_nic,
addr=new_port.fixed_ips[0]['ip_address'])
ssh_client.turn_nic_on(nic=new_nic)
@@ -258,7 +274,7 @@
# get internal ports' ips:
# get all network ports in the new network
internal_ips = (p['fixed_ips'][0]['ip_address'] for p in
- self._list_ports(tenant_id=server.tenant_id,
+ self._list_ports(tenant_id=server['tenant_id'],
network_id=network.id)
if p['device_owner'].startswith('network'))
@@ -274,8 +290,8 @@
LOG.info(msg)
return
- subnet = self.network_client.list_subnets(
- network_id=CONF.network.public_network_id)['subnets']
+ subnet = self._list_subnets(
+ network_id=CONF.network.public_network_id)
self.assertEqual(1, len(subnet), "Found %d subnets" % len(subnet))
external_ips = [subnet[0]['gateway_ip']]
@@ -284,7 +300,7 @@
def _check_server_connectivity(self, floating_ip, address_list):
ip_address = floating_ip.floating_ip_address
- private_key = self.servers[self.floating_ip_tuple.server].private_key
+ private_key = self._get_server_key(self.floating_ip_tuple.server)
ssh_source = self._ssh_to_server(ip_address, private_key)
for remote_ip in address_list:
@@ -336,6 +352,7 @@
"""
+ self._setup_network_and_servers()
self._check_public_network_connectivity(should_connect=True)
self._check_network_internal_connectivity(network=self.network)
self._check_network_external_connectivity()
@@ -361,7 +378,7 @@
4. check VM can ping new network dhcp port
"""
-
+ self._setup_network_and_servers()
self._check_public_network_connectivity(should_connect=True)
self._create_new_network()
self._hotplug_server()
diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py
index 8058b3d..e9ca770 100644
--- a/tempest/scenario/test_security_groups_basic_ops.py
+++ b/tempest/scenario/test_security_groups_basic_ops.py
@@ -131,6 +131,10 @@
'public_network_id must be defined.')
cls.enabled = False
raise cls.skipException(msg)
+ if CONF.baremetal.driver_enabled:
+ msg = ('Not currently supported by baremetal.')
+ cls.enabled = False
+ raise cls.skipException(msg)
@classmethod
def setUpClass(cls):
@@ -213,10 +217,16 @@
myport = (tenant.router.id, tenant.subnet.id)
router_ports = [(i['device_id'], i['fixed_ips'][0]['subnet_id']) for i
in self.network_client.list_ports()['ports']
- if i['device_owner'] == 'network:router_interface']
+ if self._is_router_port(i)]
self.assertIn(myport, router_ports)
+ def _is_router_port(self, port):
+ """Return True if port is a router interface."""
+ # NOTE(armando-migliaccio): match device owner for both centralized
+ # and distributed routers; 'device_owner' is "" by default.
+ return port['device_owner'].startswith('network:router_interface')
+
def _create_server(self, name, tenant, security_groups=None):
"""
creates a server and assigns to security group
@@ -266,7 +276,7 @@
self.floating_ips.setdefault(server, floating_ip)
def _create_tenant_network(self, tenant):
- network, subnet, router = self._create_networks(tenant.creds.tenant_id)
+ network, subnet, router = self.create_networks(tenant.creds.tenant_id)
tenant.set_network(network, subnet, router)
def _set_compute_context(self, tenant):
diff --git a/tempest/scenario/test_server_advanced_ops.py b/tempest/scenario/test_server_advanced_ops.py
index 5a1dc04..463f5aa 100644
--- a/tempest/scenario/test_server_advanced_ops.py
+++ b/tempest/scenario/test_server_advanced_ops.py
@@ -25,7 +25,7 @@
LOG = logging.getLogger(__name__)
-class TestServerAdvancedOps(manager.OfficialClientTest):
+class TestServerAdvancedOps(manager.ScenarioTest):
"""
This test case stresses some advanced server instance operations:
@@ -49,19 +49,19 @@
def test_resize_server_confirm(self):
# We create an instance for use in this test
instance = self.create_server()
- instance_id = instance.id
+ instance_id = instance['id']
resize_flavor = CONF.compute.flavor_ref_alt
LOG.debug("Resizing instance %s from flavor %s to flavor %s",
- instance.id, instance.flavor, resize_flavor)
- instance.resize(resize_flavor)
- self.status_timeout(self.compute_client.servers, instance_id,
- 'VERIFY_RESIZE')
+ instance['id'], instance['flavor']['id'], resize_flavor)
+ self.servers_client.resize(instance_id, resize_flavor)
+ self.servers_client.wait_for_server_status(instance_id,
+ 'VERIFY_RESIZE')
LOG.debug("Confirming resize of instance %s", instance_id)
- instance.confirm_resize()
+ self.servers_client.confirm_resize(instance_id)
- self.status_timeout(
- self.compute_client.servers, instance_id, 'ACTIVE')
+ self.servers_client.wait_for_server_status(instance_id,
+ 'ACTIVE')
@testtools.skipUnless(CONF.compute_feature_enabled.suspend,
'Suspend is not available.')
@@ -69,24 +69,27 @@
def test_server_sequence_suspend_resume(self):
# We create an instance for use in this test
instance = self.create_server()
- instance_id = instance.id
+ instance_id = instance['id']
LOG.debug("Suspending instance %s. Current status: %s",
- instance_id, instance.status)
- instance.suspend()
- self.status_timeout(self.compute_client.servers, instance_id,
- 'SUSPENDED')
+ instance_id, instance['status'])
+ self.servers_client.suspend_server(instance_id)
+ self.servers_client.wait_for_server_status(instance_id,
+ 'SUSPENDED')
+ _, fetched_instance = self.servers_client.get_server(instance_id)
LOG.debug("Resuming instance %s. Current status: %s",
- instance_id, instance.status)
- instance.resume()
- self.status_timeout(self.compute_client.servers, instance_id,
- 'ACTIVE')
+ instance_id, fetched_instance['status'])
+ self.servers_client.resume_server(instance_id)
+ self.servers_client.wait_for_server_status(instance_id,
+ 'ACTIVE')
+ _, fetched_instance = self.servers_client.get_server(instance_id)
LOG.debug("Suspending instance %s. Current status: %s",
- instance_id, instance.status)
- instance.suspend()
- self.status_timeout(self.compute_client.servers, instance_id,
- 'SUSPENDED')
+ instance_id, fetched_instance['status'])
+ self.servers_client.suspend_server(instance_id)
+ self.servers_client.wait_for_server_status(instance_id,
+ 'SUSPENDED')
+ _, fetched_instance = self.servers_client.get_server(instance_id)
LOG.debug("Resuming instance %s. Current status: %s",
- instance_id, instance.status)
- instance.resume()
- self.status_timeout(self.compute_client.servers, instance_id,
- 'ACTIVE')
+ instance_id, fetched_instance['status'])
+ self.servers_client.resume_server(instance_id)
+ self.servers_client.wait_for_server_status(instance_id,
+ 'ACTIVE')
diff --git a/tempest/scenario/test_server_basic_ops.py b/tempest/scenario/test_server_basic_ops.py
index 38686d9..b38b1a3 100644
--- a/tempest/scenario/test_server_basic_ops.py
+++ b/tempest/scenario/test_server_basic_ops.py
@@ -26,7 +26,7 @@
load_tests = test_utils.load_tests_input_scenario_utils
-class TestServerBasicOps(manager.OfficialClientTest):
+class TestServerBasicOps(manager.ScenarioTest):
"""
This smoke test case follows this basic set of operations:
@@ -69,9 +69,9 @@
def boot_instance(self):
# Create server with image and flavor from input scenario
- security_groups = [self.security_group.name]
+ security_groups = [self.security_group]
create_kwargs = {
- 'key_name': self.keypair.id,
+ 'key_name': self.keypair['name'],
'security_groups': security_groups
}
self.instance = self.create_server(image=self.image_ref,
@@ -81,16 +81,19 @@
def verify_ssh(self):
if self.run_ssh:
# Obtain a floating IP
- floating_ip = self.compute_client.floating_ips.create()
- self.addCleanup(self.delete_wrapper, floating_ip)
+ _, floating_ip = self.floating_ips_client.create_floating_ip()
+ self.addCleanup(self.delete_wrapper,
+ self.floating_ips_client.delete_floating_ip,
+ floating_ip['id'])
# Attach a floating IP
- self.instance.add_floating_ip(floating_ip)
+ self.floating_ips_client.associate_floating_ip_to_server(
+ floating_ip['ip'], self.instance['id'])
# Check ssh
try:
self.get_remote_client(
- server_or_ip=floating_ip.ip,
+ server_or_ip=floating_ip['ip'],
username=self.image_utils.ssh_user(self.image_ref),
- private_key=self.keypair.private_key)
+ private_key=self.keypair['private_key'])
except Exception:
LOG.exception('ssh to server failed')
self._log_console_output()
@@ -99,7 +102,7 @@
@test.services('compute', 'network')
def test_server_basicops(self):
self.add_keypair()
- self.security_group = self._create_security_group_nova()
+ self.security_group = self._create_security_group()
self.boot_instance()
self.verify_ssh()
- self.instance.delete()
+ self.servers_client.delete_server(self.instance['id'])
diff --git a/tempest/scenario/test_snapshot_pattern.py b/tempest/scenario/test_snapshot_pattern.py
index 7dd662d..dc32edc 100644
--- a/tempest/scenario/test_snapshot_pattern.py
+++ b/tempest/scenario/test_snapshot_pattern.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import testtools
+
from tempest import config
from tempest.openstack.common import log
from tempest.scenario import manager
@@ -23,7 +25,7 @@
LOG = log.getLogger(__name__)
-class TestSnapshotPattern(manager.OfficialClientTest):
+class TestSnapshotPattern(manager.ScenarioTest):
"""
This test is for snapshotting an instance and booting with it.
The following is the scenario outline:
@@ -35,9 +37,9 @@
"""
def _boot_image(self, image_id):
- security_groups = [self.security_group.name]
+ security_groups = [self.security_group]
create_kwargs = {
- 'key_name': self.keypair.name,
+ 'key_name': self.keypair['name'],
'security_groups': security_groups
}
return self.create_server(image=image_id, create_kwargs=create_kwargs)
@@ -64,25 +66,30 @@
self.assertEqual(self.timestamp, got_timestamp)
def _create_floating_ip(self):
- floating_ip = self.compute_client.floating_ips.create()
- self.addCleanup(self.delete_wrapper, floating_ip)
+ _, floating_ip = self.floating_ips_client.create_floating_ip()
+ self.addCleanup(self.delete_wrapper,
+ self.floating_ips_client.delete_floating_ip,
+ floating_ip['id'])
return floating_ip
def _set_floating_ip_to_server(self, server, floating_ip):
- server.add_floating_ip(floating_ip)
+ self.floating_ips_client.associate_floating_ip_to_server(
+ floating_ip['ip'], server['id'])
+ @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
+ 'Snapshotting is not available.')
@test.services('compute', 'network', 'image')
def test_snapshot_pattern(self):
# prepare for booting a instance
self._add_keypair()
- self.security_group = self._create_security_group_nova()
+ self.security_group = self._create_security_group()
# boot a instance and create a timestamp file in it
server = self._boot_image(CONF.compute.image_ref)
if CONF.compute.use_floatingip_for_ssh:
fip_for_server = self._create_floating_ip()
self._set_floating_ip_to_server(server, fip_for_server)
- self._write_timestamp(fip_for_server.ip)
+ self._write_timestamp(fip_for_server['ip'])
else:
self._write_timestamp(server)
@@ -90,13 +97,13 @@
snapshot_image = self.create_server_snapshot(server=server)
# boot a second instance from the snapshot
- server_from_snapshot = self._boot_image(snapshot_image.id)
+ server_from_snapshot = self._boot_image(snapshot_image['id'])
# check the existence of the timestamp file in the second instance
if CONF.compute.use_floatingip_for_ssh:
fip_for_snapshot = self._create_floating_ip()
self._set_floating_ip_to_server(server_from_snapshot,
fip_for_snapshot)
- self._check_timestamp(fip_for_snapshot.ip)
+ self._check_timestamp(fip_for_snapshot['ip'])
else:
self._check_timestamp(server_from_snapshot)
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index be27024..4783273 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -16,6 +16,7 @@
import time
from cinderclient import exceptions as cinder_exceptions
+import testtools
from tempest.common.utils import data_utils
from tempest import config
@@ -150,6 +151,8 @@
self.assertEqual(self.timestamp, got_timestamp)
@tempest.test.skip_because(bug="1205344")
+ @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
+ 'Snapshotting is not available.')
@tempest.test.services('compute', 'network', 'volume', 'image')
def test_stamp_pattern(self):
# prepare for booting a instance
diff --git a/tempest/scenario/test_swift_basic_ops.py b/tempest/scenario/test_swift_basic_ops.py
index 86e0867..ad74ec4 100644
--- a/tempest/scenario/test_swift_basic_ops.py
+++ b/tempest/scenario/test_swift_basic_ops.py
@@ -13,8 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-
-from tempest.common.utils import data_utils
+from tempest.common import http
from tempest import config
from tempest.openstack.common import log as logging
from tempest.scenario import manager
@@ -25,80 +24,49 @@
LOG = logging.getLogger(__name__)
-class TestSwiftBasicOps(manager.OfficialClientTest):
+class TestSwiftBasicOps(manager.SwiftScenarioTest):
"""
- Test swift with the follow operations:
+ Test swift basic ops.
* get swift stat.
* create container.
* upload a file to the created container.
* list container's objects and assure that the uploaded file is present.
+ * download the object and check the content
* delete object from container.
* list container's objects and assure that the deleted file is gone.
* delete a container.
* list containers and assure that the deleted container is gone.
+ * change ACL of the container and make sure it works successfully
"""
- @classmethod
- def setUpClass(cls):
- cls.set_network_resources()
- super(TestSwiftBasicOps, cls).setUpClass()
- if not CONF.service_available.swift:
- skip_msg = ("%s skipped as swift is not available" %
- cls.__name__)
- raise cls.skipException(skip_msg)
-
- def _get_swift_stat(self):
- """get swift status for our user account."""
- self.object_storage_client.get_account()
- LOG.debug('Swift status information obtained successfully')
-
- def _create_container(self, container_name=None):
- name = container_name or data_utils.rand_name(
- 'swift-scenario-container')
- self.object_storage_client.put_container(name)
- # look for the container to assure it is created
- self._list_and_check_container_objects(name)
- LOG.debug('Container %s created' % (name))
- return name
-
- def _delete_container(self, container_name):
- self.object_storage_client.delete_container(container_name)
- LOG.debug('Container %s deleted' % (container_name))
-
- def _upload_object_to_container(self, container_name, obj_name=None):
- obj_name = obj_name or data_utils.rand_name('swift-scenario-object')
- self.object_storage_client.put_object(container_name, obj_name,
- data_utils.rand_name('obj_data'),
- content_type='text/plain')
- return obj_name
-
- def _delete_object(self, container_name, filename):
- self.object_storage_client.delete_object(container_name, filename)
- self._list_and_check_container_objects(container_name,
- not_present_obj=[filename])
-
- def _list_and_check_container_objects(self, container_name, present_obj=[],
- not_present_obj=[]):
- """
- List objects for a given container and assert which are present and
- which are not.
- """
- meta, response = self.object_storage_client.get_container(
- container_name)
- # create a list with file name only
- object_list = [obj['name'] for obj in response]
- if present_obj:
- for obj in present_obj:
- self.assertIn(obj, object_list)
- if not_present_obj:
- for obj in not_present_obj:
- self.assertNotIn(obj, object_list)
-
@test.services('object_storage')
def test_swift_basic_ops(self):
self._get_swift_stat()
container_name = self._create_container()
- obj_name = self._upload_object_to_container(container_name)
+ obj_name, obj_data = self._upload_object_to_container(container_name)
self._list_and_check_container_objects(container_name, [obj_name])
+ self._download_and_verify(container_name, obj_name, obj_data)
+ self._delete_object(container_name, obj_name)
+ self._delete_container(container_name)
+
+ @test.services('object_storage')
+ def test_swift_acl_anonymous_download(self):
+ """This test will cover below steps:
+ 1. Create container
+ 2. Upload object to the new container
+ 3. Change the ACL of the container
+ 4. Check if the object can be download by anonymous user
+ 5. Delete the object and container
+ """
+ container_name = self._create_container()
+ obj_name, _ = self._upload_object_to_container(container_name)
+ obj_url = '%s/%s/%s' % (self.object_client.base_url,
+ container_name, obj_name)
+ http_client = http.ClosingHttp()
+ resp, _ = http_client.request(obj_url, 'GET')
+ self.assertEqual(resp.status, 401)
+ self._change_container_acl(container_name, '.r:*')
+ resp, _ = http_client.request(obj_url, 'GET')
+ self.assertEqual(resp.status, 200)
self._delete_object(container_name, obj_name)
self._delete_container(container_name)
diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py
index bf5d1f6..fdda423 100644
--- a/tempest/scenario/test_volume_boot_pattern.py
+++ b/tempest/scenario/test_volume_boot_pattern.py
@@ -10,8 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from cinderclient import exceptions as cinder_exc
-
from tempest.common.utils import data_utils
from tempest import config
from tempest.openstack.common import log
@@ -23,7 +21,7 @@
LOG = log.getLogger(__name__)
-class TestVolumeBootPattern(manager.OfficialClientTest):
+class TestVolumeBootPattern(manager.ScenarioTest):
"""
This test case attempts to reproduce the following steps:
@@ -54,28 +52,32 @@
# dev_name=id:type:size:delete_on_terminate
# where type needs to be "snap" if the server is booted
# from a snapshot, size instead can be safely left empty
- bd_map = {
- 'vda': vol_id + ':::0'
- }
- security_groups = [self.security_group.name]
+ bd_map = [{
+ 'device_name': 'vda',
+ 'volume_id': vol_id,
+ 'delete_on_termination': '0'}]
+ self.security_group = self._create_security_group()
+ security_groups = [{'name': self.security_group['name']}]
create_kwargs = {
'block_device_mapping': bd_map,
- 'key_name': keypair.name,
+ 'key_name': keypair['name'],
'security_groups': security_groups
}
return self.create_server(image='', create_kwargs=create_kwargs)
def _create_snapshot_from_volume(self, vol_id):
- volume_snapshots = self.volume_client.volume_snapshots
snap_name = data_utils.rand_name('snapshot')
- snap = volume_snapshots.create(volume_id=vol_id,
- force=True,
- display_name=snap_name)
- self.addCleanup_with_wait(self.volume_client.volume_snapshots, snap.id,
- exc_type=cinder_exc.NotFound)
- self.status_timeout(volume_snapshots,
- snap.id,
- 'available')
+ _, snap = self.snapshots_client.create_snapshot(
+ volume_id=vol_id,
+ force=True,
+ display_name=snap_name)
+ self.addCleanup_with_wait(
+ waiter_callable=self.snapshots_client.wait_for_resource_deletion,
+ thing_id=snap['id'], thing_id_param='id',
+ cleanup_callable=self.delete_wrapper,
+ cleanup_args=[self.snapshots_client.delete_snapshot, snap['id']])
+ self.snapshots_client.wait_for_snapshot_status(snap['id'], 'available')
+ self.assertEqual(snap_name, snap['display_name'])
return snap
def _create_volume_from_snapshot(self, snap_id):
@@ -85,27 +87,26 @@
def _stop_instances(self, instances):
# NOTE(gfidente): two loops so we do not wait for the status twice
for i in instances:
- self.compute_client.servers.stop(i)
+ self.servers_client.stop(i['id'])
for i in instances:
- self.status_timeout(self.compute_client.servers,
- i.id,
- 'SHUTOFF')
+ self.servers_client.wait_for_server_status(i['id'], 'SHUTOFF')
def _detach_volumes(self, volumes):
# NOTE(gfidente): two loops so we do not wait for the status twice
for v in volumes:
- self.volume_client.volumes.detach(v)
+ self.volumes_client.detach_volume(v['id'])
for v in volumes:
- self.status_timeout(self.volume_client.volumes,
- v.id,
- 'available')
+ self.volumes_client.wait_for_volume_status(v['id'], 'available')
def _ssh_to_server(self, server, keypair):
if CONF.compute.use_floatingip_for_ssh:
- floating_ip = self.compute_client.floating_ips.create()
- self.addCleanup(self.delete_wrapper, floating_ip)
- server.add_floating_ip(floating_ip)
- ip = floating_ip.ip
+ _, floating_ip = self.floating_ips_client.create_floating_ip()
+ self.addCleanup(self.delete_wrapper,
+ self.floating_ips_client.delete_floating_ip,
+ floating_ip['id'])
+ self.floating_ips_client.associate_floating_ip_to_server(
+ floating_ip['ip'], server['id'])
+ ip = floating_ip['ip']
else:
network_name_for_ssh = CONF.compute.network_for_ssh
ip = server.networks[network_name_for_ssh][0]
@@ -113,10 +114,10 @@
try:
return self.get_remote_client(
ip,
- private_key=keypair.private_key)
+ private_key=keypair['private_key'])
except Exception:
LOG.exception('ssh to server failed')
- self._log_console_output()
+ self._log_console_output(servers=[server])
raise
def _get_content(self, ssh_client):
@@ -129,8 +130,8 @@
return self._get_content(ssh_client)
def _delete_server(self, server):
- self.compute_client.servers.delete(server)
- self.delete_timeout(self.compute_client.servers, server.id)
+ self.servers_client.delete_server(server['id'])
+ self.servers_client.wait_for_server_termination(server['id'])
def _check_content_of_written_file(self, ssh_client, expected):
actual = self._get_content(ssh_client)
@@ -139,11 +140,11 @@
@test.services('compute', 'volume', 'image')
def test_volume_boot_pattern(self):
keypair = self.create_keypair()
- self.security_group = self._create_security_group_nova()
+ self.security_group = self._create_security_group()
# create an instance from volume
volume_origin = self._create_volume_from_image()
- instance_1st = self._boot_instance_from_volume(volume_origin.id,
+ instance_1st = self._boot_instance_from_volume(volume_origin['id'],
keypair)
# write content to volume on instance
@@ -155,7 +156,7 @@
self._delete_server(instance_1st)
# create a 2nd instance from volume
- instance_2nd = self._boot_instance_from_volume(volume_origin.id,
+ instance_2nd = self._boot_instance_from_volume(volume_origin['id'],
keypair)
# check the content of written file
@@ -164,11 +165,11 @@
self._check_content_of_written_file(ssh_client_for_instance_2nd, text)
# snapshot a volume
- snapshot = self._create_snapshot_from_volume(volume_origin.id)
+ snapshot = self._create_snapshot_from_volume(volume_origin['id'])
# create a 3rd instance from snapshot
- volume = self._create_volume_from_snapshot(snapshot.id)
- instance_from_snapshot = self._boot_instance_from_volume(volume.id,
+ volume = self._create_volume_from_snapshot(snapshot['id'])
+ instance_from_snapshot = self._boot_instance_from_volume(volume['id'],
keypair)
# check the content of written file
@@ -186,10 +187,11 @@
bdms = [{'uuid': vol_id, 'source_type': 'volume',
'destination_type': 'volume', 'boot_index': 0,
'delete_on_termination': False}]
- security_groups = [self.security_group.name]
+ self.security_group = self._create_security_group()
+ security_groups = [{'name': self.security_group['name']}]
create_kwargs = {
'block_device_mapping_v2': bdms,
- 'key_name': keypair.name,
+ 'key_name': keypair['name'],
'security_groups': security_groups
}
return self.create_server(image='', create_kwargs=create_kwargs)
diff --git a/tempest/services/baremetal/base.py b/tempest/services/baremetal/base.py
index f98ecff..0b97f74 100644
--- a/tempest/services/baremetal/base.py
+++ b/tempest/services/baremetal/base.py
@@ -119,6 +119,7 @@
uri += "?%s" % urllib.urlencode(kwargs)
resp, body = self.get(uri)
+ self.expected_success(200, resp['status'])
return resp, self.deserialize(body)
@@ -135,6 +136,7 @@
else:
uri = self._get_uri(resource, uuid=uuid, permanent=permanent)
resp, body = self.get(uri)
+ self.expected_success(200, resp['status'])
return resp, self.deserialize(body)
@@ -153,6 +155,7 @@
uri = self._get_uri(resource)
resp, body = self.post(uri, body=body)
+ self.expected_success(201, resp['status'])
return resp, self.deserialize(body)
@@ -168,6 +171,7 @@
uri = self._get_uri(resource, uuid)
resp, body = self.delete(uri)
+ self.expected_success(204, resp['status'])
return resp, body
def _patch_request(self, resource, uuid, patch_object):
@@ -184,6 +188,7 @@
patch_body = json.dumps(patch_object)
resp, body = self.patch(uri, body=patch_body)
+ self.expected_success(200, resp['status'])
return resp, self.deserialize(body)
@handle_errors
@@ -212,4 +217,5 @@
put_body = json.dumps(put_object)
resp, body = self.put(uri, body=put_body)
+ self.expected_success(202, resp['status'])
return resp, body
diff --git a/tempest/services/baremetal/v1/base_v1.py b/tempest/services/baremetal/v1/base_v1.py
index 9c753c2..07eee8a 100644
--- a/tempest/services/baremetal/v1/base_v1.py
+++ b/tempest/services/baremetal/v1/base_v1.py
@@ -264,3 +264,47 @@
postf='validate')
return self._show_request('nodes', node_uuid, uri=uri)
+
+ @base.handle_errors
+ def set_node_boot_device(self, node_uuid, boot_device, persistent=False):
+ """
+ Set the boot device of the specified node.
+
+ :param node_uuid: The unique identifier of the node.
+ :param boot_device: The boot device name.
+ :param persistent: Boolean value. True if the boot device will
+ persist to all future boots, False if not.
+ Default: False.
+
+ """
+ request = {'boot_device': boot_device, 'persistent': persistent}
+ resp, body = self._put_request('nodes/%s/management/boot_device' %
+ node_uuid, request)
+ self.expected_success(204, resp.status)
+ return body
+
+ @base.handle_errors
+ def get_node_boot_device(self, node_uuid):
+ """
+ Get the current boot device of the specified node.
+
+ :param node_uuid: The unique identifier of the node.
+
+ """
+ path = 'nodes/%s/management/boot_device' % node_uuid
+ resp, body = self._list_request(path)
+ self.expected_success(200, resp.status)
+ return body
+
+ @base.handle_errors
+ def get_node_supported_boot_devices(self, node_uuid):
+ """
+ Get the supported boot devices of the specified node.
+
+ :param node_uuid: The unique identifier of the node.
+
+ """
+ path = 'nodes/%s/management/boot_device/supported' % node_uuid
+ resp, body = self._list_request(path)
+ self.expected_success(200, resp.status)
+ return body
diff --git a/tempest/services/compute/json/networks_client.py b/tempest/services/compute/json/networks_client.py
new file mode 100644
index 0000000..40eb1a6
--- /dev/null
+++ b/tempest/services/compute/json/networks_client.py
@@ -0,0 +1,40 @@
+# Copyright 2012 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import json
+
+from tempest.common import rest_client
+from tempest import config
+
+CONF = config.CONF
+
+
+class NetworksClientJSON(rest_client.RestClient):
+
+ def __init__(self, auth_provider):
+ super(NetworksClientJSON, self).__init__(auth_provider)
+ self.service = CONF.compute.catalog_type
+
+ def list_networks(self):
+ resp, body = self.get("os-networks")
+ body = json.loads(body)
+ self.expected_success(200, resp.status)
+ return resp, body['networks']
+
+ def get_network(self, network_id):
+ resp, body = self.get("os-networks/%s" % str(network_id))
+ body = json.loads(body)
+ self.expected_success(200, resp.status)
+ return resp, body['network']
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index f44be29..88b68d3 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -58,6 +58,7 @@
disk_config: Determines if user or admin controls disk configuration.
return_reservation_id: Enable/Disable the return of reservation id
block_device_mapping: Block device mapping for the server.
+ block_device_mapping_v2: Block device mapping V2 for the server.
"""
post_body = {
'name': name,
@@ -70,7 +71,8 @@
'availability_zone', 'accessIPv4', 'accessIPv6',
'min_count', 'max_count', ('metadata', 'meta'),
('OS-DCF:diskConfig', 'disk_config'),
- 'return_reservation_id', 'block_device_mapping']:
+ 'return_reservation_id', 'block_device_mapping',
+ 'block_device_mapping_v2']:
if isinstance(option, tuple):
post_param = option[0]
key = option[1]
@@ -80,6 +82,7 @@
value = kwargs.get(key)
if value is not None:
post_body[post_param] = value
+
post_body = {'server': post_body}
if 'sched_hints' in kwargs:
diff --git a/tempest/services/database/json/flavors_client.py b/tempest/services/database/json/flavors_client.py
index 2ec0405..f276a45 100644
--- a/tempest/services/database/json/flavors_client.py
+++ b/tempest/services/database/json/flavors_client.py
@@ -33,8 +33,10 @@
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
return resp, self._parse_resp(body)
def get_db_flavor_details(self, db_flavor_id):
resp, body = self.get("flavors/%s" % str(db_flavor_id))
+ self.expected_success(200, resp.status)
return resp, self._parse_resp(body)
diff --git a/tempest/services/database/json/versions_client.py b/tempest/services/database/json/versions_client.py
index 0269c43..81c0e6c 100644
--- a/tempest/services/database/json/versions_client.py
+++ b/tempest/services/database/json/versions_client.py
@@ -35,4 +35,5 @@
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
return resp, self._parse_resp(body)
diff --git a/tempest/services/identity/v3/json/identity_client.py b/tempest/services/identity/v3/json/identity_client.py
index d57b931..0522f37 100644
--- a/tempest/services/identity/v3/json/identity_client.py
+++ b/tempest/services/identity/v3/json/identity_client.py
@@ -525,7 +525,7 @@
def __init__(self):
super(V3TokenClientJSON, self).__init__(None)
auth_url = CONF.identity.uri_v3
- if not auth_url and CONF.identity_feature_enabled.api_v3:
+ if not auth_url:
raise exceptions.InvalidConfiguration('you must specify a v3 uri '
'if using the v3 identity '
'api')
diff --git a/tempest/services/identity/v3/xml/identity_client.py b/tempest/services/identity/v3/xml/identity_client.py
index c2bd77e..5b761b3 100644
--- a/tempest/services/identity/v3/xml/identity_client.py
+++ b/tempest/services/identity/v3/xml/identity_client.py
@@ -520,7 +520,7 @@
def __init__(self):
super(V3TokenClientXML, self).__init__(None)
auth_url = CONF.identity.uri_v3
- if not auth_url and CONF.identity_feature_enabled.api_v3:
+ if not auth_url:
raise exceptions.InvalidConfiguration('you must specify a v3 uri '
'if using the v3 identity '
'api')
diff --git a/tempest/services/image/v1/json/image_client.py b/tempest/services/image/v1/json/image_client.py
index 4a7c163..bc5e04a 100644
--- a/tempest/services/image/v1/json/image_client.py
+++ b/tempest/services/image/v1/json/image_client.py
@@ -235,7 +235,7 @@
def is_resource_deleted(self, id):
try:
- self.get_image(id)
+ self.get_image_meta(id)
except exceptions.NotFound:
return True
return False
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index 2e28bfe..16a4f5c 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -54,12 +54,14 @@
body = json.dumps(put_body)
uri = '%s/quotas/%s' % (self.uri_prefix, tenant_id)
resp, body = self.put(uri, body)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['quota']
def reset_quotas(self, tenant_id):
uri = '%s/quotas/%s' % (self.uri_prefix, tenant_id)
resp, body = self.delete(uri)
+ self.rest_client.expected_success(204, resp.status)
return resp, body
def create_router(self, name, admin_state_up=True, **kwargs):
@@ -69,12 +71,14 @@
body = json.dumps(post_body)
uri = '%s/routers' % (self.uri_prefix)
resp, body = self.post(uri, body)
+ self.rest_client.expected_success(201, resp.status)
body = json.loads(body)
return resp, body
def _update_router(self, router_id, set_enable_snat, **kwargs):
uri = '%s/routers/%s' % (self.uri_prefix, router_id)
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
update_body = {}
update_body['name'] = kwargs.get('name', body['router']['name'])
@@ -88,6 +92,7 @@
update_body = dict(router=update_body)
update_body = json.dumps(update_body)
resp, body = self.put(uri, update_body)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
@@ -114,6 +119,7 @@
update_body = {"subnet_id": subnet_id}
update_body = json.dumps(update_body)
resp, body = self.put(uri, update_body)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
@@ -123,6 +129,7 @@
update_body = {"port_id": port_id}
update_body = json.dumps(update_body)
resp, body = self.put(uri, update_body)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
@@ -132,6 +139,7 @@
update_body = {"subnet_id": subnet_id}
update_body = json.dumps(update_body)
resp, body = self.put(uri, update_body)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
@@ -141,6 +149,7 @@
update_body = {"port_id": port_id}
update_body = json.dumps(update_body)
resp, body = self.put(uri, update_body)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
@@ -155,6 +164,7 @@
uri = '%s/lb/pools/%s/health_monitors' % (self.uri_prefix,
pool_id)
resp, body = self.post(uri, body)
+ self.rest_client.expected_success(201, resp.status)
body = json.loads(body)
return resp, body
@@ -163,11 +173,13 @@
uri = '%s/lb/pools/%s/health_monitors/%s' % (self.uri_prefix, pool_id,
health_monitor_id)
resp, body = self.delete(uri)
+ self.rest_client.expected_success(204, resp.status)
return resp, body
def list_router_interfaces(self, uuid):
uri = '%s/ports?device_id=%s' % (self.uri_prefix, uuid)
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
@@ -180,12 +192,14 @@
agent = {"agent": agent_info}
body = json.dumps(agent)
resp, body = self.put(uri, body)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
def list_pools_hosted_by_one_lbaas_agent(self, agent_id):
uri = '%s/agents/%s/loadbalancer-pools' % (self.uri_prefix, agent_id)
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
@@ -193,18 +207,21 @@
uri = ('%s/lb/pools/%s/loadbalancer-agent' %
(self.uri_prefix, pool_id))
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
def list_routers_on_l3_agent(self, agent_id):
uri = '%s/agents/%s/l3-routers' % (self.uri_prefix, agent_id)
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
def list_l3_agents_hosting_router(self, router_id):
uri = '%s/routers/%s/l3-agents' % (self.uri_prefix, router_id)
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
@@ -213,6 +230,7 @@
post_body = {"router_id": router_id}
body = json.dumps(post_body)
resp, body = self.post(uri, body)
+ self.rest_client.expected_success(201, resp.status)
body = json.loads(body)
return resp, body
@@ -220,17 +238,20 @@
uri = '%s/agents/%s/l3-routers/%s' % (
self.uri_prefix, agent_id, router_id)
resp, body = self.delete(uri)
+ self.rest_client.expected_success(204, resp.status)
return resp, body
def list_dhcp_agent_hosting_network(self, network_id):
uri = '%s/networks/%s/dhcp-agents' % (self.uri_prefix, network_id)
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
def list_networks_hosted_by_one_dhcp_agent(self, agent_id):
uri = '%s/agents/%s/dhcp-networks' % (self.uri_prefix, agent_id)
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
@@ -238,6 +259,7 @@
uri = '%s/agents/%s/dhcp-networks/%s' % (self.uri_prefix, agent_id,
network_id)
resp, body = self.delete(uri)
+ self.rest_client.expected_success(204, resp.status)
return resp, body
def create_ikepolicy(self, name, **kwargs):
@@ -251,6 +273,7 @@
body = json.dumps(post_body)
uri = '%s/vpn/ikepolicies' % (self.uri_prefix)
resp, body = self.post(uri, body)
+ self.rest_client.expected_success(201, resp.status)
body = json.loads(body)
return resp, body
@@ -264,6 +287,7 @@
}
body = json.dumps(put_body)
resp, body = self.put(uri, body)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
@@ -277,12 +301,14 @@
}
body = json.dumps(put_body)
resp, body = self.put(uri, body)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
def list_lb_pool_stats(self, pool_id):
uri = '%s/lb/pools/%s/stats' % (self.uri_prefix, pool_id)
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
@@ -291,5 +317,6 @@
body = json.dumps(post_body)
uri = '%s/agents/%s/dhcp-networks' % (self.uri_prefix, agent_id)
resp, body = self.post(uri, body)
+ self.rest_client.expected_success(201, resp.status)
body = json.loads(body)
return resp, body
diff --git a/tempest/services/network/network_client_base.py b/tempest/services/network/network_client_base.py
index 4ee8302..94ba5aa 100644
--- a/tempest/services/network/network_client_base.py
+++ b/tempest/services/network/network_client_base.py
@@ -111,6 +111,7 @@
uri += '?' + urllib.urlencode(filters, doseq=1)
resp, body = self.get(uri)
result = {plural_name: self.deserialize_list(body)}
+ self.rest_client.expected_success(200, resp.status)
return resp, result
return _list
@@ -119,7 +120,9 @@
def _delete(resource_id):
plural = self.pluralize(resource_name)
uri = '%s/%s' % (self.get_uri(plural), resource_id)
- return self.delete(uri)
+ resp, body = self.delete(uri)
+ self.rest_client.expected_success(204, resp.status)
+ return resp, body
return _delete
@@ -134,6 +137,7 @@
uri += '?' + urllib.urlencode(fields, doseq=1)
resp, body = self.get(uri)
body = self.deserialize_single(body)
+ self.rest_client.expected_success(200, resp.status)
return resp, body
return _show
@@ -145,6 +149,7 @@
post_data = self.serialize({resource_name: kwargs})
resp, body = self.post(uri, post_data)
body = self.deserialize_single(body)
+ self.rest_client.expected_success(201, resp.status)
return resp, body
return _create
@@ -156,6 +161,7 @@
post_data = self.serialize({resource_name: kwargs})
resp, body = self.put(uri, post_data)
body = self.deserialize_single(body)
+ self.rest_client.expected_success(200, resp.status)
return resp, body
return _update
@@ -174,15 +180,14 @@
raise AttributeError(name)
# Common methods that are hard to automate
- def create_bulk_network(self, count, names):
- network_list = list()
- for i in range(count):
- network_list.append({'name': names[i]})
+ def create_bulk_network(self, names):
+ network_list = [{'name': name} for name in names]
post_data = {'networks': network_list}
body = self.serialize_list(post_data, "networks", "network")
uri = self.get_uri("networks")
resp, body = self.post(uri, body)
body = {'networks': self.deserialize_list(body)}
+ self.rest_client.expected_success(201, resp.status)
return resp, body
def create_bulk_subnet(self, subnet_list):
@@ -191,6 +196,7 @@
uri = self.get_uri('subnets')
resp, body = self.post(uri, body)
body = {'subnets': self.deserialize_list(body)}
+ self.rest_client.expected_success(201, resp.status)
return resp, body
def create_bulk_port(self, port_list):
@@ -199,6 +205,7 @@
uri = self.get_uri('ports')
resp, body = self.post(uri, body)
body = {'ports': self.deserialize_list(body)}
+ self.rest_client.expected_success(201, resp.status)
return resp, body
def wait_for_resource_deletion(self, resource_type, id):
diff --git a/tempest/services/network/resources.py b/tempest/services/network/resources.py
new file mode 100644
index 0000000..b2feb87
--- /dev/null
+++ b/tempest/services/network/resources.py
@@ -0,0 +1,163 @@
+# Copyright 2013 Hewlett-Packard Development Company, L.P.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import abc
+
+import six
+
+
+class AttributeDict(dict):
+
+ """
+ Provide attribute access (dict.key) to dictionary values.
+ """
+
+ def __getattr__(self, name):
+ """Allow attribute access for all keys in the dict."""
+ if name in self:
+ return self[name]
+ return super(AttributeDict, self).__getattribute__(name)
+
+
+@six.add_metaclass(abc.ABCMeta)
+class DeletableResource(AttributeDict):
+
+ """
+ Support deletion of neutron resources (networks, subnets) via a
+ delete() method, as is supported by keystone and nova resources.
+ """
+
+ def __init__(self, *args, **kwargs):
+ self.client = kwargs.pop('client', None)
+ super(DeletableResource, self).__init__(*args, **kwargs)
+
+ def __str__(self):
+ return '<%s id="%s" name="%s">' % (self.__class__.__name__,
+ self.id, self.name)
+
+ @abc.abstractmethod
+ def delete(self):
+ return
+
+ def __hash__(self):
+ return hash(self.id)
+
+
+class DeletableNetwork(DeletableResource):
+
+ def delete(self):
+ self.client.delete_network(self.id)
+
+
+class DeletableSubnet(DeletableResource):
+
+ def __init__(self, *args, **kwargs):
+ super(DeletableSubnet, self).__init__(*args, **kwargs)
+ self._router_ids = set()
+
+ def update(self, *args, **kwargs):
+ _, result = self.client.update_subnet(subnet=self.id, *args, **kwargs)
+ super(DeletableSubnet, self).update(**result['subnet'])
+
+ def add_to_router(self, router_id):
+ self._router_ids.add(router_id)
+ self.client.add_router_interface_with_subnet_id(router_id,
+ subnet_id=self.id)
+
+ def delete(self):
+ for router_id in self._router_ids.copy():
+ self.client.remove_router_interface_with_subnet_id(
+ router_id,
+ subnet_id=self.id)
+ self._router_ids.remove(router_id)
+ self.client.delete_subnet(self.id)
+
+
+class DeletableRouter(DeletableResource):
+
+ def set_gateway(self, network_id):
+ return self.update(external_gateway_info=dict(network_id=network_id))
+
+ def unset_gateway(self):
+ return self.update(external_gateway_info=dict())
+
+ def update(self, *args, **kwargs):
+ _, result = self.client.update_router(self.id,
+ *args,
+ **kwargs)
+ return super(DeletableRouter, self).update(**result['router'])
+
+ def delete(self):
+ self.unset_gateway()
+ self.client.delete_router(self.id)
+
+
+class DeletableFloatingIp(DeletableResource):
+
+ def update(self, *args, **kwargs):
+ _, result = self.client.update_floatingip(self.id,
+ *args,
+ **kwargs)
+ super(DeletableFloatingIp, self).update(**result['floatingip'])
+
+ def __repr__(self):
+ return '<%s addr="%s">' % (self.__class__.__name__,
+ self.floating_ip_address)
+
+ def __str__(self):
+ return '<"FloatingIP" addr="%s" id="%s">' % (self.floating_ip_address,
+ self.id)
+
+ def delete(self):
+ self.client.delete_floatingip(self.id)
+
+
+class DeletablePort(DeletableResource):
+
+ def delete(self):
+ self.client.delete_port(self.id)
+
+
+class DeletableSecurityGroup(DeletableResource):
+
+ def delete(self):
+ self.client.delete_security_group(self.id)
+
+
+class DeletableSecurityGroupRule(DeletableResource):
+
+ def __repr__(self):
+ return '<%s id="%s">' % (self.__class__.__name__, self.id)
+
+ def delete(self):
+ self.client.delete_security_group_rule(self.id)
+
+
+class DeletablePool(DeletableResource):
+
+ def delete(self):
+ self.client.delete_pool(self.id)
+
+
+class DeletableMember(DeletableResource):
+
+ def delete(self):
+ self.client.delete_member(self.id)
+
+
+class DeletableVip(DeletableResource):
+
+ def delete(self):
+ self.client.delete_vip(self.id)
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
index ea9dc77..17b1f8e 100644
--- a/tempest/services/network/xml/network_client.py
+++ b/tempest/services/network/xml/network_client.py
@@ -103,17 +103,21 @@
post_body.append(p1)
resp, body = self.post(uri, str(common.Document(post_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ self.rest_client.expected_success(201, resp.status)
return resp, body
def disassociate_health_monitor_with_pool(self, health_monitor_id,
pool_id):
uri = '%s/lb/pools/%s/health_monitors/%s' % (self.uri_prefix, pool_id,
health_monitor_id)
- return self.delete(uri)
+ resp, body = self.delete(uri)
+ self.rest_client.expected_success(204, resp.status)
+ return resp, body
def show_extension_details(self, ext_alias):
uri = '%s/extensions/%s' % (self.uri_prefix, str(ext_alias))
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -123,6 +127,7 @@
router.append(common.Element("name", name))
common.deep_dict_to_xml(router, kwargs)
resp, body = self.post(uri, str(common.Document(router)))
+ self.rest_client.expected_success(201, resp.status)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -132,6 +137,7 @@
for element, content in kwargs.iteritems():
router.append(common.Element(element, content))
resp, body = self.put(uri, str(common.Document(router)))
+ self.rest_client.expected_success(200, resp.status)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -140,6 +146,7 @@
router_id)
subnet = common.Element("subnet_id", subnet_id)
resp, body = self.put(uri, str(common.Document(subnet)))
+ self.rest_client.expected_success(200, resp.status)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -148,6 +155,7 @@
router_id)
port = common.Element("port_id", port_id)
resp, body = self.put(uri, str(common.Document(port)))
+ self.rest_client.expected_success(200, resp.status)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -156,6 +164,7 @@
router_id)
subnet = common.Element("subnet_id", subnet_id)
resp, body = self.put(uri, str(common.Document(subnet)))
+ self.rest_client.expected_success(200, resp.status)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -164,12 +173,14 @@
router_id)
port = common.Element("port_id", port_id)
resp, body = self.put(uri, str(common.Document(port)))
+ self.rest_client.expected_success(200, resp.status)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
def list_router_interfaces(self, uuid):
uri = '%s/ports?device_id=%s' % (self.uri_prefix, uuid)
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
ports = common.parse_array(etree.fromstring(body), self.PLURALS)
ports = {"ports": ports}
return resp, ports
@@ -181,12 +192,14 @@
p = common.Element(key, value)
agent.append(p)
resp, body = self.put(uri, str(common.Document(agent)))
+ self.rest_client.expected_success(200, resp.status)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
def list_pools_hosted_by_one_lbaas_agent(self, agent_id):
uri = '%s/agents/%s/loadbalancer-pools' % (self.uri_prefix, agent_id)
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
pools = common.parse_array(etree.fromstring(body))
body = {'pools': pools}
return resp, body
@@ -195,12 +208,14 @@
uri = ('%s/lb/pools/%s/loadbalancer-agent' %
(self.uri_prefix, pool_id))
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
def list_routers_on_l3_agent(self, agent_id):
uri = '%s/agents/%s/l3-routers' % (self.uri_prefix, agent_id)
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
routers = common.parse_array(etree.fromstring(body))
body = {'routers': routers}
return resp, body
@@ -208,6 +223,7 @@
def list_l3_agents_hosting_router(self, router_id):
uri = '%s/routers/%s/l3-agents' % (self.uri_prefix, router_id)
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
agents = common.parse_array(etree.fromstring(body))
body = {'agents': agents}
return resp, body
@@ -216,6 +232,7 @@
uri = '%s/agents/%s/l3-routers' % (self.uri_prefix, agent_id)
router = (common.Element("router_id", router_id))
resp, body = self.post(uri, str(common.Document(router)))
+ self.rest_client.expected_success(201, resp.status)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -223,11 +240,13 @@
uri = '%s/agents/%s/l3-routers/%s' % (
self.uri_prefix, agent_id, router_id)
resp, body = self.delete(uri)
+ self.rest_client.expected_success(204, resp.status)
return resp, body
def list_dhcp_agent_hosting_network(self, network_id):
uri = '%s/networks/%s/dhcp-agents' % (self.uri_prefix, network_id)
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
agents = common.parse_array(etree.fromstring(body))
body = {'agents': agents}
return resp, body
@@ -235,6 +254,7 @@
def list_networks_hosted_by_one_dhcp_agent(self, agent_id):
uri = '%s/agents/%s/dhcp-networks' % (self.uri_prefix, agent_id)
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
networks = common.parse_array(etree.fromstring(body))
body = {'networks': networks}
return resp, body
@@ -243,11 +263,13 @@
uri = '%s/agents/%s/dhcp-networks/%s' % (self.uri_prefix, agent_id,
network_id)
resp, body = self.delete(uri)
+ self.rest_client.expected_success(204, resp.status)
return resp, body
def list_lb_pool_stats(self, pool_id):
uri = '%s/lb/pools/%s/stats' % (self.uri_prefix, pool_id)
resp, body = self.get(uri)
+ self.rest_client.expected_success(200, resp.status)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -255,6 +277,7 @@
uri = '%s/agents/%s/dhcp-networks' % (self.uri_prefix, agent_id)
network = common.Element("network_id", network_id)
resp, body = self.post(uri, str(common.Document(network)))
+ self.rest_client.expected_success(201, resp.status)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
diff --git a/tempest/services/object_storage/account_client.py b/tempest/services/object_storage/account_client.py
index be0f888..eca57c0 100644
--- a/tempest/services/object_storage/account_client.py
+++ b/tempest/services/object_storage/account_client.py
@@ -32,11 +32,15 @@
def create_account(self, data=None,
params=None,
- metadata={},
- remove_metadata={},
+ metadata=None,
+ remove_metadata=None,
metadata_prefix='X-Account-Meta-',
remove_metadata_prefix='X-Remove-Account-Meta-'):
"""Create an account."""
+ if metadata is None:
+ metadata = {}
+ if remove_metadata is None:
+ remove_metadata = {}
url = ''
if params:
url += '?%s' % urllib.urlencode(params)
diff --git a/tempest/services/orchestration/json/orchestration_client.py b/tempest/services/orchestration/json/orchestration_client.py
index 46b0ec4..d3867cd 100644
--- a/tempest/services/orchestration/json/orchestration_client.py
+++ b/tempest/services/orchestration/json/orchestration_client.py
@@ -41,12 +41,15 @@
uri += '?%s' % urllib.urlencode(params)
resp, body = self.get(uri)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['stacks']
- def create_stack(self, name, disable_rollback=True, parameters={},
+ def create_stack(self, name, disable_rollback=True, parameters=None,
timeout_mins=60, template=None, template_url=None,
environment=None, files=None):
+ if parameters is None:
+ parameters = {}
headers, body = self._prepare_update_create(
name,
disable_rollback,
@@ -58,11 +61,14 @@
files)
uri = 'stacks'
resp, body = self.post(uri, headers=headers, body=body)
+ self.expected_success(201, resp.status)
return resp, body
def update_stack(self, stack_identifier, name, disable_rollback=True,
- parameters={}, timeout_mins=60, template=None,
+ parameters=None, timeout_mins=60, template=None,
template_url=None, environment=None, files=None):
+ if parameters is None:
+ parameters = {}
headers, body = self._prepare_update_create(
name,
disable_rollback,
@@ -74,12 +80,15 @@
uri = "stacks/%s" % stack_identifier
resp, body = self.put(uri, headers=headers, body=body)
+ self.expected_success(202, resp.status)
return resp, body
def _prepare_update_create(self, name, disable_rollback=True,
- parameters={}, timeout_mins=60,
+ parameters=None, timeout_mins=60,
template=None, template_url=None,
environment=None, files=None):
+ if parameters is None:
+ parameters = {}
post_body = {
"stack_name": name,
"disable_rollback": disable_rollback,
@@ -106,6 +115,7 @@
"""Returns the details of a single stack."""
url = "stacks/%s" % stack_identifier
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['stack']
@@ -114,6 +124,7 @@
url = 'stacks/%s/actions' % stack_identifier
body = {'suspend': None}
resp, body = self.post(url, json.dumps(body))
+ self.expected_success(200, resp.status)
return resp, body
def resume_stack(self, stack_identifier):
@@ -121,12 +132,14 @@
url = 'stacks/%s/actions' % stack_identifier
body = {'resume': None}
resp, body = self.post(url, json.dumps(body))
+ self.expected_success(200, resp.status)
return resp, body
def list_resources(self, stack_identifier):
"""Returns the details of a single resource."""
url = "stacks/%s/resources" % stack_identifier
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['resources']
@@ -134,12 +147,15 @@
"""Returns the details of a single resource."""
url = "stacks/%s/resources/%s" % (stack_identifier, resource_name)
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['resource']
def delete_stack(self, stack_identifier):
"""Deletes the specified Stack."""
- return self.delete("stacks/%s" % str(stack_identifier))
+ resp, _ = self.delete("stacks/%s" % str(stack_identifier))
+ self.expected_success(204, resp.status)
+ return resp
def wait_for_resource_status(self, stack_identifier, resource_name,
status, failure_pattern='^.*_FAILED$'):
@@ -208,6 +224,7 @@
url = ('stacks/{stack_identifier}/resources/{resource_name}'
'/metadata'.format(**locals()))
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['metadata']
@@ -215,6 +232,7 @@
"""Returns list of all events for a stack."""
url = 'stacks/{stack_identifier}/events'.format(**locals())
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['events']
@@ -223,6 +241,7 @@
url = ('stacks/{stack_identifier}/resources/{resource_name}'
'/events'.format(**locals()))
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['events']
@@ -231,6 +250,7 @@
url = ('stacks/{stack_identifier}/resources/{resource_name}/events'
'/{event_id}'.format(**locals()))
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['event']
@@ -238,6 +258,7 @@
"""Returns the template for the stack."""
url = ('stacks/{stack_identifier}/template'.format(**locals()))
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
@@ -245,25 +266,51 @@
"""Returns the validation request result."""
post_body = json.dumps(post_body)
resp, body = self.post('validate', post_body)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
- def validate_template(self, template, parameters={}):
+ def validate_template(self, template, parameters=None):
"""Returns the validation result for a template with parameters."""
+ if parameters is None:
+ parameters = {}
post_body = {
'template': template,
'parameters': parameters,
}
return self._validate_template(post_body)
- def validate_template_url(self, template_url, parameters={}):
+ def validate_template_url(self, template_url, parameters=None):
"""Returns the validation result for a template with parameters."""
+ if parameters is None:
+ parameters = {}
post_body = {
'template_url': template_url,
'parameters': parameters,
}
return self._validate_template(post_body)
+ def list_resource_types(self):
+ """List resource types."""
+ resp, body = self.get('resource_types')
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return body['resource_types']
+
+ def get_resource_type(self, resource_type_name):
+ """Return the schema of a resource type."""
+ url = 'resource_types/%s' % resource_type_name
+ resp, body = self.get(url)
+ self.expected_success(200, resp.status)
+ return json.loads(body)
+
+ def get_resource_type_template(self, resource_type_name):
+ """Return the template of a resource type."""
+ url = 'resource_types/%s/template' % resource_type_name
+ resp, body = self.get(url)
+ self.expected_success(200, resp.status)
+ return json.loads(body)
+
def create_software_config(self, name=None, config=None, group=None,
inputs=None, outputs=None, options=None):
headers, body = self._prep_software_config_create(
@@ -271,7 +318,7 @@
url = 'software_configs'
resp, body = self.post(url, headers=headers, body=body)
- self.expected_success(200, resp)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return body
@@ -279,7 +326,7 @@
"""Returns a software configuration resource."""
url = 'software_configs/%s' % str(conf_id)
resp, body = self.get(url)
- self.expected_success(200, resp)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return body
@@ -287,7 +334,7 @@
"""Deletes a specific software configuration."""
url = 'software_configs/%s' % str(conf_id)
resp, _ = self.delete(url)
- self.expected_success(204, resp)
+ self.expected_success(204, resp.status)
def create_software_deploy(self, server_id=None, config_id=None,
action=None, status=None,
@@ -300,7 +347,7 @@
url = 'software_deployments'
resp, body = self.post(url, headers=headers, body=body)
- self.expected_success(200, resp)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return body
@@ -315,7 +362,7 @@
url = 'software_deployments/%s' % str(deploy_id)
resp, body = self.put(url, headers=headers, body=body)
- self.expected_success(200, resp)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return body
@@ -323,7 +370,7 @@
"""Returns a list of all deployments."""
url = 'software_deployments'
resp, body = self.get(url)
- self.expected_success(200, resp)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return body
@@ -331,7 +378,7 @@
"""Returns a specific software deployment."""
url = 'software_deployments/%s' % str(deploy_id)
resp, body = self.get(url)
- self.expected_success(200, resp)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return body
@@ -339,7 +386,7 @@
"""Return a config metadata for a specific server."""
url = 'software_deployments/metadata/%s' % server_id
resp, body = self.get(url)
- self.expected_success(200, resp)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return body
@@ -347,7 +394,7 @@
"""Deletes a specific software deployment."""
url = 'software_deployments/%s' % str(deploy_id)
resp, _ = self.delete(url)
- self.expected_success(204, resp)
+ self.expected_success(204, resp.status)
def _prep_software_config_create(self, name=None, conf=None, group=None,
inputs=None, outputs=None, options=None):
diff --git a/tempest/services/volume/json/admin/volume_hosts_client.py b/tempest/services/volume/json/admin/volume_hosts_client.py
index 84e4705..b3a22b5 100644
--- a/tempest/services/volume/json/admin/volume_hosts_client.py
+++ b/tempest/services/volume/json/admin/volume_hosts_client.py
@@ -43,4 +43,5 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['hosts']
diff --git a/tempest/services/volume/json/admin/volume_quotas_client.py b/tempest/services/volume/json/admin/volume_quotas_client.py
index 7b3e5de..90790e3 100644
--- a/tempest/services/volume/json/admin/volume_quotas_client.py
+++ b/tempest/services/volume/json/admin/volume_quotas_client.py
@@ -42,6 +42,7 @@
url = 'os-quota-sets/%s/defaults' % tenant_id
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
return resp, self._parse_resp(body)
def get_quota_set(self, tenant_id, params=None):
@@ -52,12 +53,14 @@
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
return resp, self._parse_resp(body)
def get_quota_usage(self, tenant_id):
"""List the quota set for a tenant."""
resp, body = self.get_quota_set(tenant_id, params={'usage': True})
+ self.expected_success(200, resp.status)
return resp, body
def update_quota_set(self, tenant_id, gigabytes=None, volumes=None,
@@ -75,8 +78,10 @@
post_body = jsonutils.dumps({'quota_set': post_body})
resp, body = self.put('os-quota-sets/%s' % tenant_id, post_body)
+ self.expected_success(200, resp.status)
return resp, self._parse_resp(body)
def delete_quota_set(self, tenant_id):
"""Delete the tenant's quota set."""
- return self.delete('os-quota-sets/%s' % tenant_id)
+ resp, body = self.delete('os-quota-sets/%s' % tenant_id)
+ self.expected_success(200, resp.status)
diff --git a/tempest/services/volume/json/admin/volume_services_client.py b/tempest/services/volume/json/admin/volume_services_client.py
index d43c04a..c9b8bcc 100644
--- a/tempest/services/volume/json/admin/volume_services_client.py
+++ b/tempest/services/volume/json/admin/volume_services_client.py
@@ -35,4 +35,5 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['services']
diff --git a/tempest/services/volume/json/admin/volume_types_client.py b/tempest/services/volume/json/admin/volume_types_client.py
index 65ecc67..44ef9fe 100644
--- a/tempest/services/volume/json/admin/volume_types_client.py
+++ b/tempest/services/volume/json/admin/volume_types_client.py
@@ -63,6 +63,7 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['volume_types']
def get_volume_type(self, volume_id):
@@ -70,6 +71,7 @@
url = "types/%s" % str(volume_id)
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['volume_type']
def create_volume_type(self, name, **kwargs):
@@ -87,11 +89,13 @@
post_body = json.dumps({'volume_type': post_body})
resp, body = self.post('types', post_body)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['volume_type']
def delete_volume_type(self, volume_id):
"""Deletes the Specified Volume_type."""
- return self.delete("types/%s" % str(volume_id))
+ resp, body = self.delete("types/%s" % str(volume_id))
+ self.expected_success(202, resp.status)
def list_volume_types_extra_specs(self, vol_type_id, params=None):
"""List all the volume_types extra specs created."""
@@ -101,6 +105,7 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['extra_specs']
def get_volume_type_extra_specs(self, vol_type_id, extra_spec_name):
@@ -109,6 +114,7 @@
str(extra_spec_name))
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body
def create_volume_type_extra_specs(self, vol_type_id, extra_spec):
@@ -121,12 +127,14 @@
post_body = json.dumps({'extra_specs': extra_spec})
resp, body = self.post(url, post_body)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['extra_specs']
def delete_volume_type_extra_specs(self, vol_id, extra_spec_name):
"""Deletes the Specified Volume_type extra spec."""
- return self.delete("types/%s/extra_specs/%s" % ((str(vol_id)),
- str(extra_spec_name)))
+ resp, body = self.delete("types/%s/extra_specs/%s" % (
+ (str(vol_id)), str(extra_spec_name)))
+ self.expected_success(202, resp.status)
def update_volume_type_extra_specs(self, vol_type_id, extra_spec_name,
extra_spec):
@@ -142,6 +150,7 @@
put_body = json.dumps(extra_spec)
resp, body = self.put(url, put_body)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body
def get_encryption_type(self, vol_type_id):
@@ -152,6 +161,7 @@
url = "/types/%s/encryption" % str(vol_type_id)
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body
def create_encryption_type(self, vol_type_id, **kwargs):
@@ -170,8 +180,11 @@
post_body = json.dumps({'encryption': post_body})
resp, body = self.post(url, post_body)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['encryption']
def delete_encryption_type(self, vol_type_id):
"""Delete the encryption type for the specified volume-type."""
- return self.delete("/types/%s/encryption/provider" % str(vol_type_id))
+ resp, body = self.delete(
+ "/types/%s/encryption/provider" % str(vol_type_id))
+ self.expected_success(202, resp.status)
diff --git a/tempest/services/volume/json/availability_zone_client.py b/tempest/services/volume/json/availability_zone_client.py
index f2e7c5c..5ad2287 100644
--- a/tempest/services/volume/json/availability_zone_client.py
+++ b/tempest/services/volume/json/availability_zone_client.py
@@ -31,6 +31,7 @@
def get_availability_zone_list(self):
resp, body = self.get('os-availability-zone')
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['availabilityZoneInfo']
diff --git a/tempest/services/volume/json/backups_client.py b/tempest/services/volume/json/backups_client.py
index 183d06b..63fc646 100644
--- a/tempest/services/volume/json/backups_client.py
+++ b/tempest/services/volume/json/backups_client.py
@@ -47,6 +47,7 @@
post_body = json.dumps({'backup': post_body})
resp, body = self.post('backups', post_body)
body = json.loads(body)
+ self.expected_success(202, resp.status)
return resp, body['backup']
def restore_backup(self, backup_id, volume_id=None):
@@ -55,11 +56,13 @@
post_body = json.dumps({'restore': post_body})
resp, body = self.post('backups/%s/restore' % (backup_id), post_body)
body = json.loads(body)
+ self.expected_success(202, resp.status)
return resp, body['restore']
def delete_backup(self, backup_id):
"""Delete a backup of volume."""
resp, body = self.delete('backups/%s' % (str(backup_id)))
+ self.expected_success(202, resp.status)
return resp, body
def get_backup(self, backup_id):
@@ -67,6 +70,7 @@
url = "backups/%s" % str(backup_id)
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['backup']
def list_backups_with_detail(self):
@@ -74,6 +78,7 @@
url = "backups/detail"
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['backups']
def wait_for_backup_status(self, backup_id, status):
diff --git a/tempest/services/volume/json/extensions_client.py b/tempest/services/volume/json/extensions_client.py
index e3ff00b..c84b186 100644
--- a/tempest/services/volume/json/extensions_client.py
+++ b/tempest/services/volume/json/extensions_client.py
@@ -31,6 +31,7 @@
url = 'extensions'
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['extensions']
diff --git a/tempest/services/volume/json/snapshots_client.py b/tempest/services/volume/json/snapshots_client.py
index 2dff63d..f50ba2f 100644
--- a/tempest/services/volume/json/snapshots_client.py
+++ b/tempest/services/volume/json/snapshots_client.py
@@ -42,6 +42,7 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['snapshots']
def list_snapshots_with_detail(self, params=None):
@@ -52,6 +53,7 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['snapshots']
def get_snapshot(self, snapshot_id):
@@ -59,6 +61,7 @@
url = "snapshots/%s" % str(snapshot_id)
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['snapshot']
def create_snapshot(self, volume_id, **kwargs):
@@ -74,6 +77,7 @@
post_body = json.dumps({'snapshot': post_body})
resp, body = self.post('snapshots', post_body)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['snapshot']
def update_snapshot(self, snapshot_id, **kwargs):
@@ -81,6 +85,7 @@
put_body = json.dumps({'snapshot': kwargs})
resp, body = self.put('snapshots/%s' % snapshot_id, put_body)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['snapshot']
# NOTE(afazekas): just for the wait function
@@ -122,7 +127,8 @@
def delete_snapshot(self, snapshot_id):
"""Delete Snapshot."""
- return self.delete("snapshots/%s" % str(snapshot_id))
+ resp, body = self.delete("snapshots/%s" % str(snapshot_id))
+ self.expected_success(202, resp.status)
def is_resource_deleted(self, id):
try:
@@ -135,6 +141,7 @@
"""Reset the specified snapshot's status."""
post_body = json.dumps({'os-reset_status': {"status": status}})
resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body)
+ self.expected_success(202, resp.status)
return resp, body
def update_snapshot_status(self, snapshot_id, status, progress):
@@ -146,6 +153,7 @@
post_body = json.dumps({'os-update_snapshot_status': post_body})
url = 'snapshots/%s/action' % str(snapshot_id)
resp, body = self.post(url, post_body)
+ self.expected_success(202, resp.status)
return resp, body
def create_snapshot_metadata(self, snapshot_id, metadata):
@@ -154,6 +162,7 @@
url = "snapshots/%s/metadata" % str(snapshot_id)
resp, body = self.post(url, put_body)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['metadata']
def get_snapshot_metadata(self, snapshot_id):
@@ -161,6 +170,7 @@
url = "snapshots/%s/metadata" % str(snapshot_id)
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['metadata']
def update_snapshot_metadata(self, snapshot_id, metadata):
@@ -169,6 +179,7 @@
url = "snapshots/%s/metadata" % str(snapshot_id)
resp, body = self.put(url, put_body)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['metadata']
def update_snapshot_metadata_item(self, snapshot_id, id, meta_item):
@@ -177,16 +188,18 @@
url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
resp, body = self.put(url, put_body)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['meta']
def delete_snapshot_metadata_item(self, snapshot_id, id):
"""Delete metadata item for the snapshot."""
url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
resp, body = self.delete(url)
- return resp, body
+ self.expected_success(200, resp.status)
def force_delete_snapshot(self, snapshot_id):
"""Force Delete Snapshot."""
post_body = json.dumps({'os-force_delete': {}})
resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body)
+ self.expected_success(202, resp.status)
return resp, body
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index 6c97497..c3a9269 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -35,6 +35,7 @@
self.service = CONF.volume.catalog_type
self.build_interval = CONF.volume.build_interval
self.build_timeout = CONF.volume.build_timeout
+ self.create_resp = 200
def get_attachment_from_volume(self, volume):
"""Return the element 'attachment' from input volumes."""
@@ -48,6 +49,7 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['volumes']
def list_volumes_with_detail(self, params=None):
@@ -58,6 +60,7 @@
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['volumes']
def get_volume(self, volume_id):
@@ -65,6 +68,7 @@
url = "volumes/%s" % str(volume_id)
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['volume']
def create_volume(self, size=None, **kwargs):
@@ -88,6 +92,7 @@
post_body = json.dumps({'volume': post_body})
resp, body = self.post('volumes', post_body)
body = json.loads(body)
+ self.expected_success(self.create_resp, resp.status)
return resp, body['volume']
def update_volume(self, volume_id, **kwargs):
@@ -95,11 +100,13 @@
put_body = json.dumps({'volume': kwargs})
resp, body = self.put('volumes/%s' % volume_id, put_body)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['volume']
def delete_volume(self, volume_id):
"""Deletes the Specified Volume."""
- return self.delete("volumes/%s" % str(volume_id))
+ resp, body = self.delete("volumes/%s" % str(volume_id))
+ self.expected_success(202, resp.status)
def upload_volume(self, volume_id, image_name, disk_format):
"""Uploads a volume in Glance."""
@@ -111,6 +118,7 @@
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
body = json.loads(body)
+ self.expected_success(202, resp.status)
return resp, body['os-volume_upload_image']
def attach_volume(self, volume_id, instance_uuid, mountpoint):
@@ -122,6 +130,7 @@
post_body = json.dumps({'os-attach': post_body})
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
+ self.expected_success(202, resp.status)
return resp, body
def detach_volume(self, volume_id):
@@ -130,6 +139,7 @@
post_body = json.dumps({'os-detach': post_body})
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
+ self.expected_success(202, resp.status)
return resp, body
def reserve_volume(self, volume_id):
@@ -138,6 +148,7 @@
post_body = json.dumps({'os-reserve': post_body})
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
+ self.expected_success(202, resp.status)
return resp, body
def unreserve_volume(self, volume_id):
@@ -146,6 +157,7 @@
post_body = json.dumps({'os-unreserve': post_body})
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
+ self.expected_success(202, resp.status)
return resp, body
def wait_for_volume_status(self, volume_id, status):
@@ -183,24 +195,30 @@
post_body = json.dumps({'os-extend': post_body})
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
+ self.expected_success(202, resp.status)
return resp, body
def reset_volume_status(self, volume_id, status):
"""Reset the Specified Volume's Status."""
post_body = json.dumps({'os-reset_status': {"status": status}})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
+ self.expected_success(202, resp.status)
return resp, body
def volume_begin_detaching(self, volume_id):
"""Volume Begin Detaching."""
+ # ref cinder/api/contrib/volume_actions.py#L158
post_body = json.dumps({'os-begin_detaching': {}})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
+ self.expected_success(202, resp.status)
return resp, body
def volume_roll_detaching(self, volume_id):
"""Volume Roll Detaching."""
+ # cinder/api/contrib/volume_actions.py#L170
post_body = json.dumps({'os-roll_detaching': {}})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
+ self.expected_success(202, resp.status)
return resp, body
def create_volume_transfer(self, vol_id, display_name=None):
@@ -213,6 +231,7 @@
post_body = json.dumps({'transfer': post_body})
resp, body = self.post('os-volume-transfer', post_body)
body = json.loads(body)
+ self.expected_success(202, resp.status)
return resp, body['transfer']
def get_volume_transfer(self, transfer_id):
@@ -220,6 +239,7 @@
url = "os-volume-transfer/%s" % str(transfer_id)
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['transfer']
def list_volume_transfers(self, params=None):
@@ -229,11 +249,13 @@
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['transfers']
def delete_volume_transfer(self, transfer_id):
"""Delete a volume transfer."""
- return self.delete("os-volume-transfer/%s" % str(transfer_id))
+ resp, body = self.delete("os-volume-transfer/%s" % str(transfer_id))
+ self.expected_success(202, resp.status)
def accept_volume_transfer(self, transfer_id, transfer_auth_key):
"""Accept a volume transfer."""
@@ -244,6 +266,7 @@
post_body = json.dumps({'accept': post_body})
resp, body = self.post(url, post_body)
body = json.loads(body)
+ self.expected_success(202, resp.status)
return resp, body['transfer']
def update_volume_readonly(self, volume_id, readonly):
@@ -254,12 +277,14 @@
post_body = json.dumps({'os-update_readonly_flag': post_body})
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
+ self.expected_success(202, resp.status)
return resp, body
def force_delete_volume(self, volume_id):
"""Force Delete Volume."""
post_body = json.dumps({'os-force_delete': {}})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
+ self.expected_success(202, resp.status)
return resp, body
def create_volume_metadata(self, volume_id, metadata):
@@ -268,6 +293,7 @@
url = "volumes/%s/metadata" % str(volume_id)
resp, body = self.post(url, put_body)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['metadata']
def get_volume_metadata(self, volume_id):
@@ -275,6 +301,7 @@
url = "volumes/%s/metadata" % str(volume_id)
resp, body = self.get(url)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['metadata']
def update_volume_metadata(self, volume_id, metadata):
@@ -283,6 +310,7 @@
url = "volumes/%s/metadata" % str(volume_id)
resp, body = self.put(url, put_body)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['metadata']
def update_volume_metadata_item(self, volume_id, id, meta_item):
@@ -291,13 +319,14 @@
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
resp, body = self.put(url, put_body)
body = json.loads(body)
+ self.expected_success(200, resp.status)
return resp, body['meta']
def delete_volume_metadata_item(self, volume_id, id):
"""Delete metadata item for the volume."""
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
resp, body = self.delete(url)
- return resp, body
+ self.expected_success(200, resp.status)
class VolumesClientJSON(BaseVolumesClientJSON):
diff --git a/tempest/services/volume/v2/json/volumes_client.py b/tempest/services/volume/v2/json/volumes_client.py
index 1f16ead..ac4342e 100644
--- a/tempest/services/volume/v2/json/volumes_client.py
+++ b/tempest/services/volume/v2/json/volumes_client.py
@@ -25,3 +25,4 @@
super(VolumesV2ClientJSON, self).__init__(auth_provider)
self.api_version = "v2"
+ self.create_resp = 202
diff --git a/tempest/services/volume/v2/xml/volumes_client.py b/tempest/services/volume/v2/xml/volumes_client.py
index c1bcf6e..b3133af 100644
--- a/tempest/services/volume/v2/xml/volumes_client.py
+++ b/tempest/services/volume/v2/xml/volumes_client.py
@@ -30,6 +30,7 @@
super(VolumesV2ClientXML, self).__init__(auth_provider)
self.api_version = "v2"
+ self.create_resp = 202
def _parse_volume(self, body):
vol = dict((attr, body.get(attr)) for attr in body.keys())
@@ -61,6 +62,7 @@
volumes += [self._parse_volume(vol) for vol in list(body)]
for v in volumes:
v = self._check_if_bootable(v)
+ self.expected_success(200, resp.status)
return resp, volumes
def get_volume(self, volume_id):
@@ -69,4 +71,5 @@
resp, body = self.get(url)
body = self._parse_volume(etree.fromstring(body))
body = self._check_if_bootable(body)
+ self.expected_success(200, resp.status)
return resp, body
diff --git a/tempest/services/volume/xml/admin/volume_hosts_client.py b/tempest/services/volume/xml/admin/volume_hosts_client.py
index 967c7c2..98a7c58 100644
--- a/tempest/services/volume/xml/admin/volume_hosts_client.py
+++ b/tempest/services/volume/xml/admin/volume_hosts_client.py
@@ -69,5 +69,6 @@
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = self._parse_array(etree.fromstring(body))
return resp, body
diff --git a/tempest/services/volume/xml/admin/volume_quotas_client.py b/tempest/services/volume/xml/admin/volume_quotas_client.py
index a8c92fc..acf9102 100644
--- a/tempest/services/volume/xml/admin/volume_quotas_client.py
+++ b/tempest/services/volume/xml/admin/volume_quotas_client.py
@@ -48,6 +48,7 @@
"""List the quota set for a tenant."""
resp, body = self.get_quota_set(tenant_id, params={'usage': True})
+ self.expected_success(200, resp.status)
return resp, self._format_quota(body)
def update_quota_set(self, tenant_id, gigabytes=None, volumes=None,
@@ -68,8 +69,10 @@
resp, body = self.put('os-quota-sets/%s' % tenant_id,
str(xml.Document(element)))
body = xml.xml_to_json(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, self._format_quota(body)
def delete_quota_set(self, tenant_id):
"""Delete the tenant's quota set."""
- return self.delete('os-quota-sets/%s' % tenant_id)
+ resp, body = self.delete('os-quota-sets/%s' % tenant_id)
+ self.expected_success(200, resp.status)
diff --git a/tempest/services/volume/xml/admin/volume_services_client.py b/tempest/services/volume/xml/admin/volume_services_client.py
index 7bad16d..2ecb590 100644
--- a/tempest/services/volume/xml/admin/volume_services_client.py
+++ b/tempest/services/volume/xml/admin/volume_services_client.py
@@ -39,4 +39,5 @@
resp, body = self.get(url)
node = etree.fromstring(body)
body = [xml_utils.xml_to_json(x) for x in node.getchildren()]
+ self.expected_success(200, resp.status)
return resp, body
diff --git a/tempest/services/volume/xml/admin/volume_types_client.py b/tempest/services/volume/xml/admin/volume_types_client.py
index 90897ee..679d097 100644
--- a/tempest/services/volume/xml/admin/volume_types_client.py
+++ b/tempest/services/volume/xml/admin/volume_types_client.py
@@ -75,6 +75,7 @@
if body is not None:
volume_types += [self._parse_volume_type(vol)
for vol in list(body)]
+ self.expected_success(200, resp.status)
return resp, volume_types
def get_volume_type(self, type_id):
@@ -82,6 +83,7 @@
url = "types/%s" % str(type_id)
resp, body = self.get(url)
body = etree.fromstring(body)
+ self.expected_success(200, resp.status)
return resp, self._parse_volume_type(body)
def create_volume_type(self, name, **kwargs):
@@ -107,11 +109,13 @@
resp, body = self.post('types', str(common.Document(vol_type)))
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, body
def delete_volume_type(self, type_id):
"""Deletes the Specified Volume_type."""
- return self.delete("types/%s" % str(type_id))
+ resp, body = self.delete("types/%s" % str(type_id))
+ self.expected_success(202, resp.status)
def list_volume_types_extra_specs(self, vol_type_id, params=None):
"""List all the volume_types extra specs created."""
@@ -126,6 +130,7 @@
if body is not None:
extra_specs += [self._parse_volume_type_extra_specs(spec)
for spec in list(body)]
+ self.expected_success(200, resp.status)
return resp, extra_specs
def get_volume_type_extra_specs(self, vol_type_id, extra_spec_name):
@@ -134,6 +139,7 @@
str(extra_spec_name))
resp, body = self.get(url)
body = etree.fromstring(body)
+ self.expected_success(200, resp.status)
return resp, self._parse_volume_type_extra_specs(body)
def create_volume_type_extra_specs(self, vol_type_id, extra_spec):
@@ -158,12 +164,15 @@
resp, body = self.post(url, str(common.Document(extra_specs)))
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, body
def delete_volume_type_extra_specs(self, vol_id, extra_spec_name):
"""Deletes the Specified Volume_type extra spec."""
- return self.delete("types/%s/extra_specs/%s" % ((str(vol_id)),
- str(extra_spec_name)))
+ resp, body = self.delete("types/%s/extra_specs/%s" % (
+ (str(vol_id)), str(extra_spec_name)))
+ self.expected_success(202, resp.status)
+ return resp, body
def update_volume_type_extra_specs(self, vol_type_id, extra_spec_name,
extra_spec):
@@ -187,6 +196,7 @@
resp, body = self.put(url, str(common.Document(extra_specs)))
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, body
def is_resource_deleted(self, id):
diff --git a/tempest/services/volume/xml/availability_zone_client.py b/tempest/services/volume/xml/availability_zone_client.py
index a883ef5..b956d3f 100644
--- a/tempest/services/volume/xml/availability_zone_client.py
+++ b/tempest/services/volume/xml/availability_zone_client.py
@@ -36,6 +36,7 @@
def get_availability_zone_list(self):
resp, body = self.get('os-availability-zone')
availability_zone = self._parse_array(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, availability_zone
diff --git a/tempest/services/volume/xml/extensions_client.py b/tempest/services/volume/xml/extensions_client.py
index fe8b7cb..f2b2e02 100644
--- a/tempest/services/volume/xml/extensions_client.py
+++ b/tempest/services/volume/xml/extensions_client.py
@@ -39,6 +39,7 @@
url = 'extensions'
resp, body = self.get(url)
body = self._parse_array(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, body
diff --git a/tempest/services/volume/xml/snapshots_client.py b/tempest/services/volume/xml/snapshots_client.py
index 4b1ba25..7636707 100644
--- a/tempest/services/volume/xml/snapshots_client.py
+++ b/tempest/services/volume/xml/snapshots_client.py
@@ -49,6 +49,7 @@
snapshots = []
for snap in body:
snapshots.append(common.xml_to_json(snap))
+ self.expected_success(200, resp.status)
return resp, snapshots
def list_snapshots_with_detail(self, params=None):
@@ -63,6 +64,7 @@
snapshots = []
for snap in body:
snapshots.append(common.xml_to_json(snap))
+ self.expected_success(200, resp.status)
return resp, snapshots
def get_snapshot(self, snapshot_id):
@@ -70,6 +72,7 @@
url = "snapshots/%s" % str(snapshot_id)
resp, body = self.get(url)
body = etree.fromstring(body)
+ self.expected_success(200, resp.status)
return resp, common.xml_to_json(body)
def create_snapshot(self, volume_id, **kwargs):
@@ -87,6 +90,7 @@
resp, body = self.post('snapshots',
str(common.Document(snapshot)))
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, body
def update_snapshot(self, snapshot_id, **kwargs):
@@ -96,6 +100,7 @@
resp, body = self.put('snapshots/%s' % snapshot_id,
str(common.Document(put_body)))
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, body
# NOTE(afazekas): just for the wait function
@@ -137,7 +142,8 @@
def delete_snapshot(self, snapshot_id):
"""Delete Snapshot."""
- return self.delete("snapshots/%s" % str(snapshot_id))
+ resp, body = self.delete("snapshots/%s" % str(snapshot_id))
+ self.expected_success(202, resp.status)
def is_resource_deleted(self, id):
try:
@@ -153,6 +159,7 @@
resp, body = self.post(url, str(common.Document(post_body)))
if body:
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(202, resp.status)
return resp, body
def update_snapshot_status(self, snapshot_id, status, progress):
@@ -165,6 +172,7 @@
resp, body = self.post(url, str(common.Document(post_body)))
if body:
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(202, resp.status)
return resp, body
def _metadata_body(self, meta):
@@ -188,6 +196,7 @@
resp, body = self.post('snapshots/%s/metadata' % snapshot_id,
str(common.Document(post_body)))
body = self._parse_key_value(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, body
def get_snapshot_metadata(self, snapshot_id):
@@ -195,6 +204,7 @@
url = "snapshots/%s/metadata" % str(snapshot_id)
resp, body = self.get(url)
body = self._parse_key_value(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, body
def update_snapshot_metadata(self, snapshot_id, metadata):
@@ -203,6 +213,7 @@
url = "snapshots/%s/metadata" % str(snapshot_id)
resp, body = self.put(url, str(common.Document(put_body)))
body = self._parse_key_value(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, body
def update_snapshot_metadata_item(self, snapshot_id, id, meta_item):
@@ -213,12 +224,15 @@
url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
resp, body = self.put(url, str(common.Document(put_body)))
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, body
def delete_snapshot_metadata_item(self, snapshot_id, id):
"""Delete metadata item for the snapshot."""
url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
- return self.delete(url)
+ resp, body = self.delete(url)
+ self.expected_success(200, resp.status)
+ return resp, body
def force_delete_snapshot(self, snapshot_id):
"""Force Delete Snapshot."""
@@ -227,4 +241,5 @@
resp, body = self.post(url, str(common.Document(post_body)))
if body:
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(202, resp.status)
return resp, body
diff --git a/tempest/services/volume/xml/volumes_client.py b/tempest/services/volume/xml/volumes_client.py
index 89947fb..a8c1ae5 100644
--- a/tempest/services/volume/xml/volumes_client.py
+++ b/tempest/services/volume/xml/volumes_client.py
@@ -43,6 +43,7 @@
self.service = CONF.volume.catalog_type
self.build_interval = CONF.compute.build_interval
self.build_timeout = CONF.compute.build_timeout
+ self.create_resp = 200
def _translate_attributes_to_json(self, volume):
volume_host_attr = '{' + VOLUME_HOST_NS + '}host'
@@ -114,6 +115,7 @@
volumes = []
if body is not None:
volumes += [self._parse_volume(vol) for vol in list(body)]
+ self.expected_success(200, resp.status)
return resp, volumes
def list_volumes_with_detail(self, params=None):
@@ -128,6 +130,7 @@
volumes = []
if body is not None:
volumes += [self._parse_volume(vol) for vol in list(body)]
+ self.expected_success(200, resp.status)
return resp, volumes
def get_volume(self, volume_id):
@@ -135,6 +138,7 @@
url = "volumes/%s" % str(volume_id)
resp, body = self.get(url)
body = self._parse_volume(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, body
def create_volume(self, size=None, **kwargs):
@@ -176,6 +180,7 @@
resp, body = self.post('volumes', str(common.Document(volume)))
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(self.create_resp, resp.status)
return resp, body
def update_volume(self, volume_id, **kwargs):
@@ -185,11 +190,14 @@
resp, body = self.put('volumes/%s' % volume_id,
str(common.Document(put_body)))
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, body
def delete_volume(self, volume_id):
"""Deletes the Specified Volume."""
- return self.delete("volumes/%s" % str(volume_id))
+ resp, body = self.delete("volumes/%s" % str(volume_id))
+ self.expected_success(202, resp.status)
+ return resp, body
def wait_for_volume_status(self, volume_id, status):
"""Waits for a Volume to reach a given status."""
@@ -228,6 +236,7 @@
resp, body = self.post(url, str(common.Document(post_body)))
if body:
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(202, resp.status)
return resp, body
def detach_volume(self, volume_id):
@@ -237,6 +246,7 @@
resp, body = self.post(url, str(common.Document(post_body)))
if body:
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(202, resp.status)
return resp, body
def upload_volume(self, volume_id, image_name, disk_format):
@@ -247,6 +257,7 @@
url = 'volumes/%s/action' % str(volume_id)
resp, body = self.post(url, str(common.Document(post_body)))
volume = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(202, resp.status)
return resp, volume
def extend_volume(self, volume_id, extend_size):
@@ -257,6 +268,7 @@
resp, body = self.post(url, str(common.Document(post_body)))
if body:
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(202, resp.status)
return resp, body
def reset_volume_status(self, volume_id, status):
@@ -268,6 +280,7 @@
resp, body = self.post(url, str(common.Document(post_body)))
if body:
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(202, resp.status)
return resp, body
def volume_begin_detaching(self, volume_id):
@@ -295,6 +308,7 @@
resp, body = self.post(url, str(common.Document(post_body)))
if body:
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(202, resp.status)
return resp, body
def unreserve_volume(self, volume_id):
@@ -304,6 +318,7 @@
resp, body = self.post(url, str(common.Document(post_body)))
if body:
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(202, resp.status)
return resp, body
def create_volume_transfer(self, vol_id, display_name=None):
@@ -315,6 +330,7 @@
resp, body = self.post('os-volume-transfer',
str(common.Document(post_body)))
volume = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(202, resp.status)
return resp, volume
def get_volume_transfer(self, transfer_id):
@@ -322,6 +338,7 @@
url = "os-volume-transfer/%s" % str(transfer_id)
resp, body = self.get(url)
volume = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, volume
def list_volume_transfers(self, params=None):
@@ -335,6 +352,7 @@
volumes = []
if body is not None:
volumes += [self._parse_volume_transfer(vol) for vol in list(body)]
+ self.expected_success(200, resp.status)
return resp, volumes
def _parse_volume_transfer(self, body):
@@ -348,7 +366,9 @@
def delete_volume_transfer(self, transfer_id):
"""Delete a volume transfer."""
- return self.delete("os-volume-transfer/%s" % str(transfer_id))
+ resp, body = self.delete("os-volume-transfer/%s" % str(transfer_id))
+ self.expected_success(202, resp.status)
+ return resp, body
def accept_volume_transfer(self, transfer_id, transfer_auth_key):
"""Accept a volume transfer."""
@@ -356,6 +376,7 @@
url = 'os-volume-transfer/%s/accept' % transfer_id
resp, body = self.post(url, str(common.Document(post_body)))
volume = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(202, resp.status)
return resp, volume
def update_volume_readonly(self, volume_id, readonly):
@@ -366,6 +387,7 @@
resp, body = self.post(url, str(common.Document(post_body)))
if body:
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(202, resp.status)
return resp, body
def force_delete_volume(self, volume_id):
@@ -375,6 +397,7 @@
resp, body = self.post(url, str(common.Document(post_body)))
if body:
body = common.xml_to_json(etree.fromstring(body))
+ self.expected_success(202, resp.status)
return resp, body
def _metadata_body(self, meta):
@@ -399,6 +422,7 @@
resp, body = self.post('volumes/%s/metadata' % volume_id,
str(common.Document(post_body)))
body = self._parse_key_value(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, body
def get_volume_metadata(self, volume_id):
@@ -406,6 +430,7 @@
url = "volumes/%s/metadata" % str(volume_id)
resp, body = self.get(url)
body = self._parse_key_value(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, body
def update_volume_metadata(self, volume_id, metadata):
@@ -414,6 +439,7 @@
url = "volumes/%s/metadata" % str(volume_id)
resp, body = self.put(url, str(common.Document(put_body)))
body = self._parse_key_value(etree.fromstring(body))
+ self.expected_success(200, resp.status)
return resp, body
def update_volume_metadata_item(self, volume_id, id, meta_item):
@@ -423,13 +449,16 @@
put_body.append(common.Text(v))
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
resp, body = self.put(url, str(common.Document(put_body)))
+ self.expected_success(200, resp.status)
body = common.xml_to_json(etree.fromstring(body))
return resp, body
def delete_volume_metadata_item(self, volume_id, id):
"""Delete metadata item for the volume."""
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
- return self.delete(url)
+ resp, body = self.delete(url)
+ self.expected_success(200, resp.status)
+ return resp, body
class VolumesClientXML(BaseVolumesClientXML):
diff --git a/tempest/stress/stressaction.py b/tempest/stress/stressaction.py
index f6770ab..286e022 100644
--- a/tempest/stress/stressaction.py
+++ b/tempest/stress/stressaction.py
@@ -12,12 +12,16 @@
# License for the specific language governing permissions and limitations
# under the License.
+import abc
import signal
import sys
+import six
+
from tempest.openstack.common import log as logging
+@six.add_metaclass(abc.ABCMeta)
class StressAction(object):
def __init__(self, manager, max_runs=None, stop_on_error=False):
@@ -83,6 +87,7 @@
self.tearDown()
sys.exit(1)
+ @abc.abstractmethod
def run(self):
"""This method is where the stress test code runs."""
- raise NotImplemented()
+ return
diff --git a/tempest/test.py b/tempest/test.py
index 1e67d18..f34933e 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -70,7 +70,7 @@
"""A decorator used to wrap the setUpClass for cleaning up resources
when setUpClass failed.
"""
-
+ @functools.wraps(f)
def decorator(cls):
try:
f(cls)
@@ -107,7 +107,7 @@
'identity': True,
'object_storage': CONF.service_available.swift,
'dashboard': CONF.service_available.horizon,
- 'ceilometer': CONF.service_available.ceilometer,
+ 'telemetry': CONF.service_available.ceilometer,
'data_processing': CONF.service_available.sahara
}
@@ -399,25 +399,6 @@
cls.admin_client = os_admin.negative_client
@staticmethod
- def load_schema(file_or_dict):
- """
- Loads a schema from a file_or_dict on a specified location.
-
- :param file_or_dict: just a dict or filename
- """
- # NOTE(mkoderer): we will get rid of this function when all test are
- # ported to dicts
- if isinstance(file_or_dict, dict):
- return file_or_dict
-
- # NOTE(mkoderer): must be extended for xml support
- fn = os.path.join(
- os.path.abspath(os.path.dirname(os.path.dirname(__file__))),
- "etc", "schemas", file_or_dict)
- LOG.debug("Open schema file: %s" % (fn))
- return json.load(open(fn))
-
- @staticmethod
def load_tests(*args):
"""
Wrapper for testscenarios to set the mandatory scenarios variable
@@ -460,7 +441,6 @@
the data is used to generate query strings appended to the url,
otherwise for the body of the http call.
"""
- description = NegativeAutoTest.load_schema(description)
LOG.debug(description)
generator = importutils.import_class(
CONF.negative.test_generator)()
@@ -514,7 +494,6 @@
otherwise for the body of the http call.
"""
- description = NegativeAutoTest.load_schema(description)
LOG.info("Executing %s" % description["name"])
LOG.debug(description)
method = description["http-method"]
@@ -604,8 +583,6 @@
"""
@attr(type=['negative', 'gate'])
def generic_test(self):
- if hasattr(self, '_schema_file'):
- self.execute(self._schema_file)
if hasattr(self, '_schema'):
self.execute(self._schema)
diff --git a/tempest/tests/cmd/test_verify_tempest_config.py b/tempest/tests/cmd/test_verify_tempest_config.py
index d0140dd..a28684e 100644
--- a/tempest/tests/cmd/test_verify_tempest_config.py
+++ b/tempest/tests/cmd/test_verify_tempest_config.py
@@ -238,8 +238,8 @@
'neutron', {})
self.assertIn('neutron', results)
self.assertIn('extensions', results['neutron'])
- self.assertEqual(['fake1', 'fake2', 'not_fake'],
- results['neutron']['extensions'])
+ self.assertEqual(sorted(['fake1', 'fake2', 'not_fake']),
+ sorted(results['neutron']['extensions']))
def test_verify_extensions_cinder(self):
def fake_list_extensions():
@@ -277,8 +277,8 @@
'cinder', {})
self.assertIn('cinder', results)
self.assertIn('extensions', results['cinder'])
- self.assertEqual(['fake1', 'fake2', 'not_fake'],
- results['cinder']['extensions'])
+ self.assertEqual(sorted(['fake1', 'fake2', 'not_fake']),
+ sorted(results['cinder']['extensions']))
def test_verify_extensions_nova(self):
def fake_list_extensions():
@@ -316,8 +316,8 @@
'nova', {})
self.assertIn('nova', results)
self.assertIn('extensions', results['nova'])
- self.assertEqual(['fake1', 'fake2', 'not_fake'],
- results['nova']['extensions'])
+ self.assertEqual(sorted(['fake1', 'fake2', 'not_fake']),
+ sorted(results['nova']['extensions']))
def test_verify_extensions_nova_v3(self):
def fake_list_extensions():
@@ -355,8 +355,8 @@
'nova_v3', {})
self.assertIn('nova_v3', results)
self.assertIn('extensions', results['nova_v3'])
- self.assertEqual(['fake1', 'fake2', 'not_fake'],
- results['nova_v3']['extensions'])
+ self.assertEqual(sorted(['fake1', 'fake2', 'not_fake']),
+ sorted(results['nova_v3']['extensions']))
def test_verify_extensions_swift(self):
def fake_list_extensions():
@@ -395,5 +395,5 @@
'swift', {})
self.assertIn('swift', results)
self.assertIn('extensions', results['swift'])
- self.assertEqual(['not_fake', 'fake1', 'fake2'],
- results['swift']['extensions'])
+ self.assertEqual(sorted(['not_fake', 'fake1', 'fake2']),
+ sorted(results['swift']['extensions']))
diff --git a/tempest/tests/common/test_accounts.py b/tempest/tests/common/test_accounts.py
index c24bfb6..feafbf5 100644
--- a/tempest/tests/common/test_accounts.py
+++ b/tempest/tests/common/test_accounts.py
@@ -185,3 +185,15 @@
hash_list[2])
remove_mock.mock.assert_called_once_with(hash_path)
rmdir_mock.mock.assert_not_called()
+
+ def test_is_multi_user(self):
+ test_accounts_class = accounts.Accounts('test_name')
+ self.assertTrue(test_accounts_class.is_multi_user())
+
+ def test_is_not_multi_user(self):
+ self.test_accounts = [self.test_accounts[0]]
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.accounts.read_accounts_yaml',
+ return_value=self.test_accounts))
+ test_accounts_class = accounts.Accounts('test_name')
+ self.assertFalse(test_accounts_class.is_multi_user())
diff --git a/tempest/tests/common/test_custom_matchers.py b/tempest/tests/common/test_custom_matchers.py
new file mode 100644
index 0000000..57217e3
--- /dev/null
+++ b/tempest/tests/common/test_custom_matchers.py
@@ -0,0 +1,66 @@
+# Copyright 2014 Hewlett-Packard Development Company, L.P.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.common import custom_matchers
+from tempest.tests import base
+
+from testtools.tests.matchers import helpers
+
+
+class TestMatchesDictExceptForKeys(base.TestCase,
+ helpers.TestMatchersInterface):
+
+ matches_matcher = custom_matchers.MatchesDictExceptForKeys(
+ {'a': 1, 'b': 2, 'c': 3, 'd': 4}, ['c', 'd'])
+ matches_matches = [
+ {'a': 1, 'b': 2, 'c': 3, 'd': 4},
+ {'a': 1, 'b': 2, 'c': 5},
+ {'a': 1, 'b': 2},
+ ]
+ matches_mismatches = [
+ {},
+ {'foo': 1},
+ {'a': 1, 'b': 3},
+ {'a': 1, 'b': 2, 'foo': 1},
+ {'a': 1, 'b': None, 'foo': 1},
+ ]
+
+ str_examples = []
+ describe_examples = [
+ ("Only in expected:\n"
+ " {'a': 1, 'b': 2}\n",
+ {},
+ matches_matcher),
+ ("Only in expected:\n"
+ " {'a': 1, 'b': 2}\n"
+ "Only in actual:\n"
+ " {'foo': 1}\n",
+ {'foo': 1},
+ matches_matcher),
+ ("Differences:\n"
+ " b: expected 2, actual 3\n",
+ {'a': 1, 'b': 3},
+ matches_matcher),
+ ("Only in actual:\n"
+ " {'foo': 1}\n",
+ {'a': 1, 'b': 2, 'foo': 1},
+ matches_matcher),
+ ("Only in actual:\n"
+ " {'foo': 1}\n"
+ "Differences:\n"
+ " b: expected 2, actual None\n",
+ {'a': 1, 'b': None, 'foo': 1},
+ matches_matcher)
+ ]
\ No newline at end of file
diff --git a/tempest/tests/negative/test_negative_auto_test.py b/tempest/tests/negative/test_negative_auto_test.py
index edff3a8..dddd083 100644
--- a/tempest/tests/negative/test_negative_auto_test.py
+++ b/tempest/tests/negative/test_negative_auto_test.py
@@ -13,10 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
-
-import mock
-
from tempest import config
import tempest.test as test
from tempest.tests import base
@@ -58,11 +54,9 @@
for entry in entries:
self.assertIsNotNone(entry[1]['resource'])
- @mock.patch('tempest.test.NegativeAutoTest.load_schema')
- def test_generate_scenario(self, open_mock):
- open_mock.return_value = self.fake_input_desc
+ def test_generate_scenario(self):
scenarios = test.NegativeAutoTest.\
- generate_scenario(None)
+ generate_scenario(self.fake_input_desc)
self.assertIsInstance(scenarios, list)
for scenario in scenarios:
@@ -72,13 +66,3 @@
self._check_prop_entries(scenarios, "prop_minRam")
self._check_prop_entries(scenarios, "prop_minDisk")
self._check_resource_entries(scenarios, "inv_res")
-
- def test_load_schema(self):
- json_schema = json.dumps(self.fake_input_desc)
- with mock.patch('tempest.test.open',
- mock.mock_open(read_data=json_schema),
- create=True):
- return_file = test.NegativeAutoTest.load_schema('filename')
- self.assertEqual(return_file, self.fake_input_desc)
- return_dict = test.NegativeAutoTest.load_schema(self.fake_input_desc)
- self.assertEqual(return_file, return_dict)
diff --git a/tempest/tests/test_credentials.py b/tempest/tests/test_credentials.py
index 9da5f92..ea576c4 100644
--- a/tempest/tests/test_credentials.py
+++ b/tempest/tests/test_credentials.py
@@ -128,12 +128,22 @@
creds = self._get_credentials()
self.assertTrue(creds.is_valid())
- def test_is_not_valid(self):
+ def _test_is_not_valid(self, ignore_key):
creds = self._get_credentials()
for attr in self.attributes.keys():
+ if attr == ignore_key:
+ continue
+ temp_attr = getattr(creds, attr)
delattr(creds, attr)
self.assertFalse(creds.is_valid(),
"Credentials should be invalid without %s" % attr)
+ setattr(creds, attr, temp_attr)
+
+ def test_is_not_valid(self):
+ # NOTE(mtreinish): A KeystoneV2 credential object is valid without
+ # a tenant_name. So skip that check. See tempest.auth for the valid
+ # credential requirements
+ self._test_is_not_valid('tenant_name')
def test_default(self):
self.useFixture(fixtures.LockFixture('auth_version'))
@@ -205,6 +215,12 @@
config_value = 'fake_' + attr
self.assertEqual(getattr(creds, attr), config_value)
+ def test_is_not_valid(self):
+ # NOTE(mtreinish) For a Keystone V3 credential object a project name
+ # is not required to be valid, so we skip that check. See tempest.auth
+ # for the valid credential requirements
+ self._test_is_not_valid('project_name')
+
def test_synced_attributes(self):
attributes = self.attributes
# Create V3 credentials with tenant instead of project, and user_domain
diff --git a/tempest/tests/test_decorators.py b/tempest/tests/test_decorators.py
index 6b678f7..12104ec 100644
--- a/tempest/tests/test_decorators.py
+++ b/tempest/tests/test_decorators.py
@@ -237,7 +237,7 @@
class TestSimpleNegativeDecorator(BaseDecoratorsTest):
@test.SimpleNegativeAutoTest
class FakeNegativeJSONTest(test.NegativeAutoTest):
- _schema_file = 'fake/schemas/file.json'
+ _schema = {}
def test_testfunc_exist(self):
self.assertIn("test_fake_negative", dir(self.FakeNegativeJSONTest))
@@ -247,4 +247,4 @@
obj = self.FakeNegativeJSONTest("test_fake_negative")
self.assertIn("test_fake_negative", dir(obj))
obj.test_fake_negative()
- mock.assert_called_once_with(self.FakeNegativeJSONTest._schema_file)
+ mock.assert_called_once_with(self.FakeNegativeJSONTest._schema)
diff --git a/tempest/tests/test_hacking.py b/tempest/tests/test_hacking.py
index 52fdf7e..9c13013 100644
--- a/tempest/tests/test_hacking.py
+++ b/tempest/tests/test_hacking.py
@@ -107,3 +107,16 @@
self.assertFalse(checks.no_official_client_manager_in_api_tests(
"cls.official_client = clients.OfficialClientManager(credentials)",
"tempest/scenario/fake_test.py"))
+
+ def test_no_mutable_default_args(self):
+ self.assertEqual(1, len(list(checks.no_mutable_default_args(
+ " def function1(para={}):"))))
+
+ self.assertEqual(1, len(list(checks.no_mutable_default_args(
+ "def function2(para1, para2, para3=[])"))))
+
+ self.assertEqual(0, len(list(checks.no_mutable_default_args(
+ "defined = []"))))
+
+ self.assertEqual(0, len(list(checks.no_mutable_default_args(
+ "defined, undefined = [], {}"))))
diff --git a/tempest/tests/test_xml_utils.py b/tempest/tests/test_xml_utils.py
new file mode 100644
index 0000000..53e31c4
--- /dev/null
+++ b/tempest/tests/test_xml_utils.py
@@ -0,0 +1,35 @@
+#
+# Copyright 2014 Hewlett-Packard Development Company, L.P.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.common import xml_utils
+from tempest.tests import base
+
+
+class TestDocumentXML(base.TestCase):
+ def test_xml_document_ordering_version_encoding(self):
+ expected = '<?xml version="1.0" encoding="UTF-8"?>'
+ xml_out = str(xml_utils.Document())
+ self.assertEqual(expected, xml_out.strip())
+
+ xml_out = str(xml_utils.Document(encoding='UTF-8', version='1.0'))
+ self.assertEqual(expected, xml_out.strip())
+
+ xml_out = str(xml_utils.Document(version='1.0', encoding='UTF-8'))
+ self.assertEqual(expected, xml_out.strip())
+
+ def test_xml_document_additonal_attrs(self):
+ expected = '<?xml version="1.0" encoding="UTF-8" foo="bar"?>'
+ xml_out = str(xml_utils.Document(foo='bar'))
+ self.assertEqual(expected, xml_out.strip())
diff --git a/tools/check_logs.py b/tools/check_logs.py
index eab9f73..917aaaf 100755
--- a/tools/check_logs.py
+++ b/tools/check_logs.py
@@ -26,8 +26,9 @@
import yaml
-is_grenade = (os.environ.get('DEVSTACK_GATE_GRENADE', "0") == "1" or
- os.environ.get('DEVSTACK_GATE_GRENADE_FORWARD', "0") == "1")
+# DEVSTACK_GATE_GRENADE is either unset if grenade is not running
+# or a string describing what type of grenade run to perform.
+is_grenade = os.environ.get('DEVSTACK_GATE_GRENADE') is not None
dump_all_errors = True
# As logs are made clean, add to this set
diff --git a/tox.ini b/tox.ini
index b3d4397..a071d4b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -32,7 +32,6 @@
[testenv:all]
sitepackages = True
-setenv = VIRTUAL_ENV={envdir}
commands =
bash tools/pretty_tox.sh '{posargs}'
@@ -111,7 +110,8 @@
# H402 skipped because some docstrings aren't sentences
# E123 skipped because it is ignored by default in the default pep8
# E129 skipped because it is too limiting when combined with other rules
+# H305 skipped because it is inconsistent between python versions
# Skipped because of new hacking 0.9: H405,H904
-ignore = E125,H402,E123,E129,H404,H405,H904
+ignore = E125,H402,E123,E129,H404,H405,H904,H305
show-source = True
exclude = .git,.venv,.tox,dist,doc,openstack,*egg