[Share Groups] Add two new fields to SG API object
Previous change [1] added logic for handling of availability zones with
share groups and [2] for scheduling with share group capability
to create consistent snapshots. Those two added two new DB fields
for 'share_groups' DB model, but not to API response that requires
microversion bump. So, add these fields to API and bump microversion.
Following two new fields will be available with new microversion:
- 'availability_zone_id'
- 'consistent_snapshot_support'
Also, add tempest tests to these API changes.
[1] I000adeb53fe8435465cbedc3c539e6aaae6503c5
[2] I05553c308ae40c4ddc2c6469ff1c1a3da36a87da
Partially-Implements BP manila-share-groups
Change-Id: I343d0c6f3a5c7b58d88e95dba4af984fae738954
diff --git a/manila_tempest_tests/config.py b/manila_tempest_tests/config.py
index 3be873f..e54dd48 100644
--- a/manila_tempest_tests/config.py
+++ b/manila_tempest_tests/config.py
@@ -30,7 +30,7 @@
help="The minimum api microversion is configured to be the "
"value of the minimum microversion supported by Manila."),
cfg.StrOpt("max_api_microversion",
- default="2.33",
+ default="2.34",
help="The maximum api microversion is configured to be the "
"value of the latest microversion supported by Manila."),
cfg.StrOpt("region",
diff --git a/manila_tempest_tests/tests/api/test_share_groups.py b/manila_tempest_tests/tests/api/test_share_groups.py
index 98d29e4..68ff647 100644
--- a/manila_tempest_tests/tests/api/test_share_groups.py
+++ b/manila_tempest_tests/tests/api/test_share_groups.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import ddt
from tempest import config
from tempest.lib import exceptions as lib_exc
import testtools
@@ -27,6 +28,7 @@
@testtools.skipUnless(
CONF.share.run_share_group_tests, 'Share Group tests disabled.')
@base.skip_if_microversion_lt(constants.MIN_SHARE_GROUP_MICROVERSION)
+@ddt.ddt
class ShareGroupsTest(base.BaseSharesTest):
"""Covers share group functionality."""
@@ -163,3 +165,58 @@
share_group['share_network_id'],
new_share_group['share_network_id'],
msg)
+
+ @base.skip_if_microversion_lt("2.34")
+ @tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
+ @ddt.data(
+ 'sg', 'sg_and_share', 'none',
+ )
+ def test_create_sg_and_share_specifying_az(self, where_specify_az):
+ # Get list of existing availability zones, at least one always
+ # should exist
+ azs = self.shares_v2_client.list_availability_zones()
+
+ sg_kwargs = {
+ 'version': '2.34',
+ 'cleanup_in_class': False,
+ }
+ if where_specify_az in ('sg', 'sg_and_share'):
+ sg_kwargs['availability_zone'] = azs[0]['name']
+
+ # Create share group
+ share_group = self.create_share_group(**sg_kwargs)
+
+ # Get latest share group info
+ share_group = self.shares_v2_client.get_share_group(
+ share_group['id'], '2.34')
+
+ self.assertIn('availability_zone', share_group)
+ if where_specify_az in ('sg', 'sg_and_share'):
+ self.assertEqual(azs[0]['name'], share_group['availability_zone'])
+ else:
+ self.assertIn(
+ share_group['availability_zone'], [az['name'] for az in azs])
+
+ # Test 'consistent_snapshot_support' as part of 2.33 API change
+ self.assertIn('consistent_snapshot_support', share_group)
+ self.assertIn(
+ share_group['consistent_snapshot_support'], ('host', 'pool', None))
+
+ s_kwargs = {
+ 'share_group_id': share_group['id'],
+ 'version': '2.33',
+ 'cleanup_in_class': False,
+ 'experimental': True,
+ }
+ if where_specify_az == 'sg_and_share':
+ s_kwargs['availability_zone'] = azs[0]['name']
+
+ # Create share in share group
+ share = self.create_share(**s_kwargs)
+
+ # Get latest share info
+ share = self.shares_v2_client.get_share(share['id'], '2.34')
+
+ # Verify that share always has the same AZ as share group does
+ self.assertEqual(
+ share_group['availability_zone'], share['availability_zone'])
diff --git a/manila_tempest_tests/tests/api/test_share_groups_negative.py b/manila_tempest_tests/tests/api/test_share_groups_negative.py
index b33eca9..af29879 100644
--- a/manila_tempest_tests/tests/api/test_share_groups_negative.py
+++ b/manila_tempest_tests/tests/api/test_share_groups_negative.py
@@ -237,3 +237,37 @@
version=constants.MIN_SHARE_GROUP_MICROVERSION,
)
self.assertEqual(0, len(shares), 'Incorrect number of shares returned')
+
+ @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
+ def test_create_sg_with_nonexistent_az_min(self):
+ self.assertRaises(
+ lib_exc.NotFound,
+ self.shares_v2_client.create_share_group,
+ name='tempest_sg',
+ description='tempest_sg_desc',
+ availability_zone='fake_nonexistent_az',
+ version=constants.MIN_SHARE_GROUP_MICROVERSION)
+
+ @base.skip_if_microversion_lt("2.34")
+ @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
+ def test_create_sg_and_share_with_different_azs(self):
+ azs = self.shares_v2_client.list_availability_zones()
+
+ if len(azs) < 2:
+ raise self.skipException(
+ 'Test requires presence of at least 2 availability zones.')
+ else:
+ share_group = self.shares_v2_client.get_share_group(
+ self.share_group['id'], '2.34')
+ different_az = [
+ az['name']
+ for az in azs
+ if az['name'] != share_group['availability_zone']
+ ][0]
+
+ self.assertRaises(
+ lib_exc.BadRequest,
+ self.create_share,
+ share_group_id=self.share_group['id'],
+ availability_zone=different_az,
+ version='2.34')