Merge "Add line for PyCharm IDE in gitignore file"
diff --git a/README.rst b/README.rst
index ca88f76..0a2d95b 100644
--- a/README.rst
+++ b/README.rst
@@ -7,7 +7,8 @@
Tempest plugin to test Manila's features
* Free software: Apache license
-* Documentation: https://docs.openstack.org/developer/openstack
+* Documentation: https://docs.openstack.org/manila/latest/
+* Release notes: https://docs.openstack.org/releasenotes/manila/
* Source: https://git.openstack.org/cgit/openstack/manila-tempest-plugin
* Bugs: https://bugs.launchpad.net/manila-tempest-plugin
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index d8bd45a..401c089 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -26,7 +26,6 @@
from tempest import config
from tempest.lib.common import dynamic_creds
from tempest.lib.common.utils import data_utils
-from tempest.lib.common.utils import test_utils
from tempest.lib import exceptions
from tempest import test
@@ -127,9 +126,6 @@
# Will be cleaned up in resource_cleanup
class_resources = []
- # Will be cleaned up in clear_net_resources
- class_net_resources = []
-
# Will be cleaned up in tearDown method
method_resources = []
@@ -314,14 +310,12 @@
super(BaseSharesTest, self).setUp()
self.addCleanup(self.clear_isolated_creds)
self.addCleanup(self.clear_resources)
- self.addCleanup(self.clear_net_resources)
verify_test_has_appropriate_tags(self)
@classmethod
def resource_cleanup(cls):
cls.clear_resources(cls.class_resources)
cls.clear_isolated_creds(cls.class_isolated_creds)
- cls.clear_net_resources(cls.class_net_resources)
super(BaseSharesTest, cls).resource_cleanup()
@classmethod
@@ -399,24 +393,6 @@
network, subnet, router = net_data
net_id = network["id"]
subnet_id = subnet["id"]
- network_res = {
- "type": "network",
- "resource": network,
- "client": ic,
- }
- subnet_res = {
- "type": "subnet",
- "resource": subnet,
- "client": ic,
- }
- router_res = {
- "type": "router",
- "resource": router,
- "client": ic,
- }
- cls.class_net_resources.insert(0, network_res)
- cls.class_net_resources.insert(0, subnet_res)
- cls.class_net_resources.insert(0, router_res)
# Try get suitable share-network
share_networks = sc.list_share_networks_with_detail()
@@ -446,58 +422,6 @@
return share_network_id
@classmethod
- def clear_net_resources(cls, resources=None):
- if resources is None:
- resources = cls.class_net_resources
- for res in resources:
- if "deleted" not in res.keys():
- res["deleted"] = False
- if not (res["deleted"]):
- if res["type"] is "router":
- cls.clear_router(res['client'], res['resource'])
- elif res["type"] is "subnet":
- cls.clear_subnet(res['client'], res['resource'])
- elif res["type"] is "network":
- cls.clear_network(res['client'], res['resource'])
- else:
- LOG.warning("Provided unsupported resource type for "
- "cleanup '%s'. Skipping." % res["type"])
- res["deleted"] = True
-
- @classmethod
- def clear_router(cls, ic, router):
- body = ic.ports_admin_client.list_ports(device_id=router['id'])
- interfaces = body['ports']
- for i in interfaces:
- test_utils.call_and_ignore_notfound_exc(
- ic.routers_admin_client.remove_router_interface, router['id'],
- subnet_id=i['fixed_ips'][0]['subnet_id'])
-
- try:
- ic.routers_admin_client.delete_router(router['id'])
- except exceptions.NotFound:
- LOG.warning('router with name: %s not found for delete' %
- router['name'])
-
- @classmethod
- def clear_subnet(cls, ic, subnet):
- client = ic.subnets_admin_client
- try:
- client.delete_subnet(subnet['id'])
- except exceptions.NotFound:
- LOG.warning('subnet with name: %s not found for delete' %
- subnet['name'])
-
- @classmethod
- def clear_network(cls, ic, network):
- net_client = ic.networks_admin_client
- try:
- net_client.delete_network(network['id'])
- except exceptions.NotFound:
- LOG.warning('network with name: %s not found for delete' %
- network['name'])
-
- @classmethod
def _create_share(cls, share_protocol=None, size=None, name=None,
snapshot_id=None, description=None, metadata=None,
share_network_id=None, share_type_id=None,
@@ -991,8 +915,8 @@
client.wait_for_resource_deletion(snapshot_id=res_id)
elif (res["type"] is "share_network" and
res_id != CONF.share.share_network_id):
- client.delete_share_network(res_id)
- client.wait_for_resource_deletion(sn_id=res_id)
+ client.delete_share_network(res_id)
+ client.wait_for_resource_deletion(sn_id=res_id)
elif res["type"] is "security_service":
client.delete_security_service(res_id)
client.wait_for_resource_deletion(ss_id=res_id)
diff --git a/manila_tempest_tests/tests/api/test_rules_negative.py b/manila_tempest_tests/tests/api/test_rules_negative.py
index 22f232f..19db6bb 100644
--- a/manila_tempest_tests/tests/api/test_rules_negative.py
+++ b/manila_tempest_tests/tests/api/test_rules_negative.py
@@ -124,6 +124,39 @@
rule_id=rule["id"], share_id=self.share["id"], version=version)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
+ @ddt.data("10.20.30.40", "fd8c:b029:bba6:ac54::1",
+ "fd2c:b029:bba6:df54::1/128", "10.10.30.40/32")
+ def test_create_duplicate_single_host_rules(self, access_to):
+ """Test rules for individual clients with and without max-prefix."""
+ if ':' in access_to and utils.is_microversion_lt(
+ '2.38', CONF.share.max_api_microversion):
+ reason = ("Skipped. IPv6 rules are accepted from and beyond "
+ "API version 2.38, the configured maximum API version "
+ "is %s" % CONF.share.max_api_microversion)
+ raise self.skipException(reason)
+
+ rule = self.shares_v2_client.create_access_rule(
+ self.share["id"], "ip", access_to)
+ self.addCleanup(self.shares_v2_client.delete_access_rule,
+ self.share["id"], rule['id'])
+ self.shares_v2_client.wait_for_share_status(
+ self.share["id"], "active", status_attr='access_rules_status')
+
+ self.assertRaises(lib_exc.BadRequest,
+ self.shares_v2_client.create_access_rule,
+ self.share["id"], "ip", access_to)
+
+ if '/' in access_to:
+ access_to = access_to.split("/")[0]
+ else:
+ access_to = ('%s/32' % access_to if '.' in access_to else
+ '%s/128' % access_to)
+
+ self.assertRaises(lib_exc.BadRequest,
+ self.shares_v2_client.create_access_rule,
+ self.share["id"], "ip", access_to)
+
+ @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
def test_add_access_rule_on_share_with_no_host(self):
access_type, access_to = self._get_access_rule_data_from_config()
extra_specs = self.add_extra_specs_to_dict(
diff --git a/manila_tempest_tests/tests/api/test_snapshot_rules_negative.py b/manila_tempest_tests/tests/api/test_snapshot_rules_negative.py
index 2991acd..2f3f193 100644
--- a/manila_tempest_tests/tests/api/test_snapshot_rules_negative.py
+++ b/manila_tempest_tests/tests/api/test_snapshot_rules_negative.py
@@ -21,6 +21,7 @@
from manila_tempest_tests.tests.api import base
from manila_tempest_tests.tests.api import test_snapshot_rules
+from manila_tempest_tests import utils
CONF = config.CONF
@@ -58,14 +59,22 @@
self.snap["id"], "ip", target)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
- def test_create_duplicate_of_ip_rule(self):
- self._test_duplicate_rules()
- self._test_duplicate_rules()
+ @ddt.data("1.2.3.4", "fd8c:b029:bba6:ac54::1",
+ "fd8c:b029:bba6:ac54::1/128", "1.2.3.4/32")
+ def test_create_duplicate_of_ip_rule(self, access_to):
+ self._test_duplicate_rules(access_to)
+ self._test_duplicate_rules(access_to)
- def _test_duplicate_rules(self):
+ def _test_duplicate_rules(self, access_to):
+ if ':' in access_to and utils.is_microversion_lt(
+ '2.38', CONF.share.max_api_microversion):
+ reason = ("Skipped. IPv6 rules are accepted from and beyond "
+ "API version 2.38, the configured maximum API version "
+ "is %s" % CONF.share.max_api_microversion)
+ raise self.skipException(reason)
+
# test data
access_type = "ip"
- access_to = "1.2.3.4"
# create rule
rule = self.shares_v2_client.create_snapshot_access_rule(
@@ -79,6 +88,16 @@
self.shares_v2_client.create_snapshot_access_rule,
self.snap["id"], access_type, access_to)
+ # try alternate notation
+ if '/' in access_to:
+ access_to = access_to.split("/")[0]
+ else:
+ access_to = ('%s/32' % access_to if '.' in access_to else
+ '%s/128' % access_to)
+ self.assertRaises(lib_exc.BadRequest,
+ self.shares_v2_client.create_snapshot_access_rule,
+ self.snap["id"], access_type, access_to)
+
# delete rule and wait for deletion
self.shares_v2_client.delete_snapshot_access_rule(self.snap['id'],
rule['id'])
diff --git a/manila_tempest_tests/tests/scenario/manager.py b/manila_tempest_tests/tests/scenario/manager.py
index 73a6693..0aa1b9e 100644
--- a/manila_tempest_tests/tests/scenario/manager.py
+++ b/manila_tempest_tests/tests/scenario/manager.py
@@ -18,7 +18,6 @@
import netaddr
from oslo_log import log
-from oslo_serialization import jsonutils as json
from oslo_utils import netutils
import six
@@ -81,13 +80,6 @@
cls.security_group_rules_client = (
cls.os_primary.security_group_rules_client)
- if CONF.volume_feature_enabled.api_v2:
- cls.volumes_client = cls.os_primary.volumes_v2_client
- cls.snapshots_client = cls.os_primary.snapshots_v2_client
- else:
- cls.volumes_client = cls.os_primary.volumes_client
- cls.snapshots_client = cls.os_primary.snapshots_client
-
# ## Test functions library
#
# The create_[resource] functions only return body and discard the
@@ -214,61 +206,6 @@
server = clients.servers_client.show_server(body['id'])['server']
return server
- def create_volume(self, size=None, name=None, snapshot_id=None,
- imageRef=None, volume_type=None):
- if size is None:
- size = CONF.volume.volume_size
- if imageRef:
- image = self.compute_images_client.show_image(imageRef)['image']
- min_disk = image.get('minDisk')
- size = max(size, min_disk)
- if name is None:
- name = data_utils.rand_name(self.__class__.__name__ + "-volume")
- kwargs = {'display_name': name,
- 'snapshot_id': snapshot_id,
- 'imageRef': imageRef,
- 'volume_type': volume_type,
- 'size': size}
- volume = self.volumes_client.create_volume(**kwargs)['volume']
-
- self.addCleanup(self.volumes_client.wait_for_resource_deletion,
- volume['id'])
- self.addCleanup(test_utils.call_and_ignore_notfound_exc,
- self.volumes_client.delete_volume, volume['id'])
-
- # NOTE(e0ne): Cinder API v2 uses name instead of display_name
- if 'display_name' in volume:
- self.assertEqual(name, volume['display_name'])
- else:
- self.assertEqual(name, volume['name'])
- waiters.wait_for_volume_resource_status(self.volumes_client,
- 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.show_volume(volume['id'])['volume']
- return volume
-
- def create_volume_type(self, client=None, name=None, backend_name=None):
- if not client:
- client = self.admin_volume_types_client
- if not name:
- class_name = self.__class__.__name__
- name = data_utils.rand_name(class_name + '-volume-type')
- randomized_name = data_utils.rand_name('scenario-type-' + name)
-
- LOG.debug("Creating a volume type: %s on backend %s",
- randomized_name, backend_name)
- extra_specs = {}
- if backend_name:
- extra_specs = {"volume_backend_name": backend_name}
-
- body = client.create_volume_type(name=randomized_name,
- extra_specs=extra_specs)
- volume_type = body['volume_type']
- self.assertIn('id', volume_type)
- self.addCleanup(client.delete_volume_type, volume_type['id'])
- return volume_type
-
def _create_loginable_secgroup_rule(self, secgroup_id=None):
_client = self.compute_security_groups_client
_client_rules = self.compute_security_group_rules_client
@@ -443,72 +380,6 @@
if not isinstance(exc, lib_exc.SSHTimeout):
LOG.debug('Network information on a devstack host')
- def create_server_snapshot(self, server, name=None):
- # Glance client
- _image_client = self.image_client
- # Compute client
- _images_client = self.compute_images_client
- if name is None:
- name = data_utils.rand_name(self.__class__.__name__ + 'snapshot')
- LOG.debug("Creating a snapshot image for server: %s", server['name'])
- image = _images_client.create_image(server['id'], name=name)
- image_id = image.response['location'].split('images/')[1]
- waiters.wait_for_image_status(_image_client, image_id, 'active')
-
- self.addCleanup(_image_client.wait_for_resource_deletion,
- image_id)
- self.addCleanup(test_utils.call_and_ignore_notfound_exc,
- _image_client.delete_image, image_id)
-
- if CONF.image_feature_enabled.api_v1:
- # In glance v1 the additional properties are stored in the headers.
- resp = _image_client.check_image(image_id)
- snapshot_image = common_image.get_image_meta_from_headers(resp)
- image_props = snapshot_image.get('properties', {})
- else:
- # In glance v2 the additional properties are flattened.
- snapshot_image = _image_client.show_image(image_id)
- image_props = snapshot_image
-
- bdm = image_props.get('block_device_mapping')
- if bdm:
- bdm = json.loads(bdm)
- if bdm and 'snapshot_id' in bdm[0]:
- snapshot_id = bdm[0]['snapshot_id']
- self.addCleanup(
- self.snapshots_client.wait_for_resource_deletion,
- snapshot_id)
- self.addCleanup(test_utils.call_and_ignore_notfound_exc,
- self.snapshots_client.delete_snapshot,
- snapshot_id)
- waiters.wait_for_volume_resource_status(self.snapshots_client,
- snapshot_id,
- 'available')
- 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
-
- def nova_volume_attach(self, server, volume_to_attach):
- volume = self.servers_client.attach_volume(
- server['id'], volumeId=volume_to_attach['id'], device='/dev/%s'
- % CONF.compute.volume_device_name)['volumeAttachment']
- self.assertEqual(volume_to_attach['id'], volume['id'])
- waiters.wait_for_volume_resource_status(self.volumes_client,
- volume['id'], 'in-use')
-
- # Return the updated volume after the attachment
- return self.volumes_client.show_volume(volume['id'])['volume']
-
- def nova_volume_detach(self, server, volume):
- self.servers_client.detach_volume(server['id'], volume['id'])
- waiters.wait_for_volume_resource_status(self.volumes_client,
- volume['id'], 'available')
-
- volume = self.volumes_client.show_volume(volume['id'])['volume']
- self.assertEqual('available', volume['status'])
-
def rebuild_server(self, server_id, image=None,
preserve_ephemeral=False, wait=True,
rebuild_kwargs=None):