Correct share group tests cleanup order

Some share group tests were taking advantage of a bug in Manila.
Share network subnets were being allowed to be deleted even when
its share servers were tied to a share group. With that bug being
fixed, we need to ensure that the share groups are deleted before
the share network subnet alongside the share servers are.

Related-Bug: #2004212
Change-Id: I05607883c34bca586c795c7efab1df8d0edd6cff
diff --git a/manila_tempest_tests/tests/api/test_share_groups.py b/manila_tempest_tests/tests/api/test_share_groups.py
index b203481..ab6b9d1 100644
--- a/manila_tempest_tests/tests/api/test_share_groups.py
+++ b/manila_tempest_tests/tests/api/test_share_groups.py
@@ -45,7 +45,7 @@
     @classmethod
     def resource_setup(cls):
         super(ShareGroupsTest, cls).resource_setup()
-        # create share type
+        # create share  type
         extra_specs = {}
         if CONF.share.capability_snapshot_support:
             extra_specs.update({'snapshot_support': True})
@@ -208,6 +208,16 @@
             new_share_group['share_network_id'],
             msg)
 
+        # Delete the share group snapshot and wait
+        self.shares_v2_client.delete_share_group_snapshot(
+            sg_snapshot["id"], version=constants.MIN_SHARE_GROUP_MICROVERSION)
+        self.shares_v2_client.wait_for_resource_deletion(
+            share_group_snapshot_id=sg_snapshot["id"])
+
+        # Delete share group, so share network subnet deletion does not fail
+        self.shares_v2_client.delete_share_group(
+            share_group['id'], version=constants.MIN_SHARE_GROUP_MICROVERSION)
+
     @utils.skip_if_microversion_not_supported("2.34")
     @decorators.idempotent_id('14fd6d88-87ff-4af2-ad17-f95dbd8dcd61')
     @tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
@@ -387,6 +397,11 @@
             params=params,
             version=constants.MIN_SHARE_GROUP_MICROVERSION)
         self.shares_client.wait_for_resource_deletion(share_id=share['id'])
+
+        # Delete share group
+        self.shares_v2_client.delete_share_group(
+            share_group['id'], version=constants.MIN_SHARE_GROUP_MICROVERSION)
+
         # Delete subnet
         self.shares_v2_client.delete_subnet(
             new_share_network_id, subnet1['id'])