Stop attempting share type deletions that'd fail

You can't delete a share type that's in use
by shares. Add this logic to the cleanup script
handler so we stop seeing unnecessary cleanup
attempts. Failed cleanups are always, unfortunately,
the test runner's responsibility since we can't
understand why something failed to be deleted.

Change-Id: I1a5ae086b68f34f3761b61f7b4cfdcbf717ab1da
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index c23e3be..d811ce0 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -930,6 +930,25 @@
                             client.delete_security_service(res_id)
                             client.wait_for_resource_deletion(ss_id=res_id)
                         elif res["type"] == "share_type":
+                            # Check if there are still shares using this
+                            # share type before attempting deletion to avoid
+                            # cascading cleanup issues
+                            shares_using_type = []
+                            try:
+                                shares_using_type = client.list_shares(
+                                    params={'share_type_id': res_id}
+                                )['shares']
+                            except Exception:
+                                pass
+                            if shares_using_type:
+                                # Skip deletion if any shares exist
+                                LOG.warning("Skipping share type deletion "
+                                            "for %s , still has %d shares "
+                                            "using it.",
+                                            res_id,
+                                            len(shares_using_type))
+                                res["deleted"] = True
+                                continue
                             client.delete_share_type(res_id)
                             client.wait_for_resource_deletion(st_id=res_id)
                         elif res["type"] == "share_group":