Fix compare volume stats for storage_protocols
The change [1] added to scheduler a list of
storage_protocols upon reception of the stats from
volume. Scheduler can handle a list of storage
protocol variants for NFS, NVMeOF, iSCSI and FC.
The test_backends_capabilities compare volume
stats from list_pools and
show_backend_capabilities without check if the
procotols are in the list. Once change [1]
standardized some storage_protocols
with a default value, list_pools will show the
standard protocol defined by the position zero
from the list, and show_backend_capabilities
will return the protocol defined by user as
backend. Even if, the protocol returned by
show_backend_capabilities are in the list of
allowed protocols the test will fail if this
protocol is not equal the default position
zero from the list.
This patch provide a check if
show_backend_capabilities returns
valid storage_protocols using the list of allowed
variants and set the preferred protocol to it.
This fix is needed for third-party CI systems that
may not be running tempest in a greenfield
environment. So while cinder change [2] fixed
drivers to report the canonical storage protocol
name, we can't assume that the drivers being
tested contain that fix.
[1]https://review.opendev.org/c/openstack/cinder/+/836069
[2]https://review.opendev.org/c/openstack/cinder/+/839063
Change-Id: I04d0eaa1f6dba16bd11052f91a3d1d0967029ea6
diff --git a/tempest/api/volume/admin/test_backends_capabilities.py b/tempest/api/volume/admin/test_backends_capabilities.py
index 3c76eca..9a85ed4 100644
--- a/tempest/api/volume/admin/test_backends_capabilities.py
+++ b/tempest/api/volume/admin/test_backends_capabilities.py
@@ -47,6 +47,11 @@
'volume_backend_name',
'storage_protocol')
+ # List of storage protocols variants defined in cinder.common.constants
+ # The canonical name for storage protocol comes first in the list
+ VARIANTS = [['iSCSI', 'iscsi'], ['FC', 'fibre_channel', 'fc'],
+ ['NFS', 'nfs'], ['NVMe-oF', 'NVMeOF', 'nvmeof']]
+
# Get list backend capabilities using show_pools
cinder_pools = [
pool['capabilities'] for pool in
@@ -64,4 +69,23 @@
cinder_pools)))
observed_list = sorted(list(map(operator.itemgetter(*VOLUME_STATS),
capabilities)))
+
+ # Cinder Bug #1966103: Some drivers were reporting different strings
+ # to represent the same storage protocol. For backward compatibility,
+ # the scheduler can handle the variants, but to standardize this for
+ # operators (who may need to refer to the protocol in volume-type
+ # extra-specs), the get-pools response was changed by I07d74078dbb1
+ # to only report the canonical name for a storage protocol. Thus, the
+ # expected_list (which we got from the get-pools call) will only
+ # contain canonical names, while the observed_list (which we got
+ # from the driver capabilities call) may contain a variant. So before
+ # comparing the lists, we need to look for known variants in the
+ # observed_list elements and replace them with their canonical values
+ for item in range(len(observed_list)):
+ for variants in VARIANTS:
+ if observed_list[item][2] in variants:
+ observed_list[item] = (observed_list[item][0],
+ observed_list[item][1],
+ variants[0])
+
self.assertEqual(expected_list, observed_list)