Fix export location used for extend/shrink tests
Instead of using the first export location, use the first export
location matching the address family (IPv4 or IPv6) to be used
for the mount.
Closes-Bug: #1848278
Change-Id: Ia2a0fefc34085e21e521acb7ccfdeecef7fda186
diff --git a/manila_tempest_tests/tests/scenario/manager_share.py b/manila_tempest_tests/tests/scenario/manager_share.py
index 23fc4c4..d0e82c5 100644
--- a/manila_tempest_tests/tests/scenario/manager_share.py
+++ b/manila_tempest_tests/tests/scenario/manager_share.py
@@ -377,6 +377,13 @@
locations = [x['path'] for x in exports]
return locations
+ def _get_snapshot_export_locations(self, snapshot):
+ exports = (self.shares_v2_client.
+ list_snapshot_export_locations(snapshot['id']))
+ locations = [x['path'] for x in exports]
+
+ return locations
+
def _get_ipv6_server_ip(self, instance):
ipv6_addrs = []
for network_name, nic_list in instance['addresses'].items():
@@ -579,3 +586,51 @@
LOG.info('Creating Glance image using the downloaded image file')
return self._image_create('centos', 'bare', imagepath, 'qcow2')
+
+ def get_share_export_location_for_mount(self, share):
+ exports = self.get_user_export_locations(
+ share=share,
+ error_on_invalid_ip_version=True)
+ return exports[0]
+
+ def get_user_export_locations(self, share=None, snapshot=None,
+ error_on_invalid_ip_version=False):
+ locations = None
+ if share:
+ locations = self.get_share_export_locations(share)
+ elif snapshot:
+ locations = self._get_snapshot_export_locations(snapshot)
+
+ self.assertNotEmpty(locations)
+ locations = self._get_export_locations_according_to_ip_version(
+ locations, error_on_invalid_ip_version)
+ self.assertNotEmpty(locations)
+
+ return locations
+
+ def _get_export_locations_according_to_ip_version(
+ self, all_locations, error_on_invalid_ip_version):
+ locations = [
+ x for x in all_locations
+ if self.get_ip_and_version_from_export_location(
+ x)[1] == self.ip_version]
+
+ if len(locations) == 0 and not error_on_invalid_ip_version:
+ message = ("Configured backend does not support "
+ "ip_version %s" % self.ip_version)
+ raise self.skipException(message)
+ return locations
+
+ def get_ip_and_version_from_export_location(self, export):
+ export = export.replace('[', '').replace(']', '')
+ if self.protocol == 'nfs' and ':/' in export:
+ ip = export.split(':/')[0]
+ version = 6 if ip.count(':') > 1 else 4
+ elif self.protocol == 'cifs' and export.startswith(r'\\'):
+ ip = export.split('\\')[2]
+ version = 6 if (ip.count(':') > 1 or
+ ip.endswith('ipv6-literal.net')) else 4
+ else:
+ message = ("Protocol %s is not supported" % self.protocol)
+ raise self.skipException(message)
+ return ip, version
diff --git a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
index 5603fab..8a55b2e 100644
--- a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
+++ b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
@@ -52,20 +52,6 @@
cls.protocol)
raise cls.skipException(message)
- def get_ip_and_version_from_export_location(self, export):
- export = export.replace('[', '').replace(']', '')
- if self.protocol == 'nfs' and ':/' in export:
- ip = export.split(':/')[0]
- version = 6 if ip.count(':') > 1 else 4
- elif self.protocol == 'cifs' and export.startswith(r'\\'):
- ip = export.split('\\')[2]
- version = 6 if (ip.count(':') > 1 or
- ip.endswith('ipv6-literal.net')) else 4
- else:
- message = ("Protocol %s is not supported" % self.protocol)
- raise self.skipException(message)
- return ip, version
-
def _ping_host_from_export_location(self, export, remote_client):
ip, version = self.get_ip_and_version_from_export_location(export)
if version == 6:
@@ -73,46 +59,11 @@
else:
remote_client.exec_command("ping -c 5 %s" % ip)
- def _get_export_locations_according_to_ip_version(
- self, all_locations, error_on_invalid_ip_version):
- locations = [
- x for x in all_locations
- if self.get_ip_and_version_from_export_location(
- x)[1] == self.ip_version]
-
- if len(locations) == 0 and not error_on_invalid_ip_version:
- message = ("Configured backend does not support "
- "ip_version %s" % self.ip_version)
- raise self.skipException(message)
- return locations
-
- def _get_user_export_locations(self, share=None, snapshot=None,
- error_on_invalid_ip_version=False):
- locations = None
- if share:
- locations = self.get_share_export_locations(share)
- elif snapshot:
- locations = self._get_snapshot_export_locations(snapshot)
-
- self.assertNotEmpty(locations)
- locations = self._get_export_locations_according_to_ip_version(
- locations, error_on_invalid_ip_version)
- self.assertNotEmpty(locations)
-
- return locations
-
- def _get_snapshot_export_locations(self, snapshot):
- exports = (self.shares_v2_client.
- list_snapshot_export_locations(snapshot['id']))
- locations = [x['path'] for x in exports]
-
- return locations
-
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
def test_mount_share_one_vm(self):
instance = self.boot_instance(wait_until="BUILD")
self.create_share()
- locations = self._get_user_export_locations(self.share)
+ locations = self.get_user_export_locations(self.share)
instance = self.wait_for_active_instance(instance["id"])
remote_client = self.init_remote_client(instance)
self.provide_access_to_auxiliary_instance(instance)
@@ -128,7 +79,7 @@
instance = self.boot_instance(wait_until="BUILD")
self.create_share()
- location = self._get_user_export_locations(self.share)[0]
+ location = self.get_user_export_locations(self.share)[0]
instance = self.wait_for_active_instance(instance["id"])
remote_client_inst = self.init_remote_client(instance)
@@ -156,7 +107,7 @@
instance1 = self.boot_instance(wait_until="BUILD")
instance2 = self.boot_instance(wait_until="BUILD")
self.create_share()
- location = self._get_user_export_locations(self.share)[0]
+ location = self.get_user_export_locations(self.share)[0]
instance1 = self.wait_for_active_instance(instance1["id"])
instance2 = self.wait_for_active_instance(instance2["id"])
@@ -213,7 +164,7 @@
instance = self.boot_instance(wait_until="BUILD")
self.create_share()
- exports = self._get_user_export_locations(self.share)
+ exports = self.get_user_export_locations(self.share)
instance = self.wait_for_active_instance(instance["id"])
self.share = self.shares_admin_v2_client.get_share(self.share['id'])
@@ -269,7 +220,7 @@
self.share = self.migration_complete(self.share['id'], dest_pool)
- new_exports = self._get_user_export_locations(
+ new_exports = self.get_user_export_locations(
self.share, error_on_invalid_ip_version=True)
self.assertEqual(dest_pool, self.share['host'])
@@ -307,7 +258,7 @@
self.provide_access_to_auxiliary_instance(instance, parent_share)
# 5 - Try mount S1 to UVM, ok, mounted
- user_export_location = self._get_user_export_locations(parent_share)[0]
+ user_export_location = self.get_user_export_locations(parent_share)[0]
parent_share_dir = "/mnt/parent"
remote_client.exec_command("sudo mkdir -p %s" % parent_share_dir)
@@ -329,7 +280,7 @@
# 10 - Try mount S2 - fail, access denied. We test that child share
# did not get access rules from parent share.
- user_export_location = self._get_user_export_locations(child_share)[0]
+ user_export_location = self.get_user_export_locations(child_share)[0]
child_share_dir = "/mnt/child"
remote_client.exec_command("sudo mkdir -p %s" % child_share_dir)
@@ -391,7 +342,7 @@
self.provide_access_to_auxiliary_instance(instance, parent_share)
# 5 - Try mount S1 to UVM, ok, mounted
- user_export_location = self._get_user_export_locations(parent_share)[0]
+ user_export_location = self.get_user_export_locations(parent_share)[0]
parent_share_dir = "/mnt/parent"
snapshot_dir = "/mnt/snapshot_dir"
remote_client.exec_command("sudo mkdir -p %s" % parent_share_dir)
@@ -414,7 +365,7 @@
self.provide_access_to_auxiliary_instance(instance, snapshot=snapshot)
# 10 - Mount SS1
- user_export_location = self._get_user_export_locations(
+ user_export_location = self.get_user_export_locations(
snapshot=snapshot)[0]
self.mount_share(user_export_location, remote_client, snapshot_dir)
self.addCleanup(self.unmount_share, remote_client, snapshot_dir)
diff --git a/manila_tempest_tests/tests/scenario/test_share_extend.py b/manila_tempest_tests/tests/scenario/test_share_extend.py
index 66d4a87..7827b75 100644
--- a/manila_tempest_tests/tests/scenario/test_share_extend.py
+++ b/manila_tempest_tests/tests/scenario/test_share_extend.py
@@ -71,10 +71,9 @@
LOG.debug('Step 4 - grant access')
self.provide_access_to_auxiliary_instance(instance, share=share)
- locations = self.get_share_export_locations(share)
-
LOG.debug('Step 5 - mount')
- self.mount_share(locations[0], remote_client)
+ location = self.get_share_export_location_for_mount(share)
+ self.mount_share(location, remote_client)
total_blocks = (units.Ki * default_share_size) / 64
three_quarter_blocks = (total_blocks / 4) * 3
@@ -107,7 +106,7 @@
self.assertEqual(extended_share_size, int(share["size"]))
LOG.debug('Step 8 - writing more data, should succeed')
- self.write_data_with_remount(locations[0], remote_client, '/mnt/t3',
+ self.write_data_with_remount(location, remote_client, '/mnt/t3',
'64M', over_one_quarter_blocks)
ls_result = remote_client.exec_command("sudo ls -lAh /mnt/")
LOG.debug(ls_result)
diff --git a/manila_tempest_tests/tests/scenario/test_share_shrink.py b/manila_tempest_tests/tests/scenario/test_share_shrink.py
index 1595fbc..0036296 100644
--- a/manila_tempest_tests/tests/scenario/test_share_shrink.py
+++ b/manila_tempest_tests/tests/scenario/test_share_shrink.py
@@ -74,10 +74,9 @@
LOG.debug('Step 4 - grant access')
self.provide_access_to_auxiliary_instance(instance)
- locations = self.get_share_export_locations(share)
-
LOG.debug('Step 5 - mount')
- self.mount_share(locations[0], remote_client)
+ location = self.get_share_export_location_for_mount(share)
+ self.mount_share(location, remote_client)
total_blocks = (1024 * default_share_size) / 64
blocks = total_blocks + 4
diff --git a/releasenotes/notes/bug-1848278-a37290750e6ac248.yaml b/releasenotes/notes/bug-1848278-a37290750e6ac248.yaml
new file mode 100644
index 0000000..f0ce109
--- /dev/null
+++ b/releasenotes/notes/bug-1848278-a37290750e6ac248.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+ - |
+ Instead of using the first export location, use the first export location
+ matching the address family (IPv4 or IPv6) matching that to be used for the
+ mount.