Fix manage tempest test validation

Tempest test test_manage_with_type_invalid always passes
because if scheduler mistakenly accept the share type and
host combination, manage operation will fail in the backend
and test would assume it failed for the correct reason.

Part of the fix is ensuring share being managed exists, so
status becomes 'available' if scheduler accepts the share.
Since this test, which is originally a negative test, requires
the resource in the backend to exist and be cleaned up, share needs
to properly be managed again to be deleted. This is exactly what
another separate test does. Originally both test cases were merged
in a single tempest test, possibly for this purpose, so this change
addresses the bug by merging them back.

Change-Id: I05b89dccb703c3be28a27732fef810100945cbc8
Closes-bug: #1564505
diff --git a/manila_tempest_tests/tests/api/admin/test_share_manage.py b/manila_tempest_tests/tests/api/admin/test_share_manage.py
index a9ad4a6..80c2982 100644
--- a/manila_tempest_tests/tests/api/admin/test_share_manage.py
+++ b/manila_tempest_tests/tests/api/admin/test_share_manage.py
@@ -157,44 +157,43 @@
         self._test_manage(share=self.shares[0])
 
     @test.attr(type=["gate", "smoke", "negative", ])
-    def test_manage_with_type_invalid(self):
-        # Manage share with invalid type
+    def test_manage_invalid(self):
+        # Try to manage share with invalid parameters, it should not succeed
+        # because the scheduler will reject it. If it succeeds, then this test
+        # case failed. Then, in order to remove the resource from backend, we
+        # need to manage it again, properly, so we can delete it. Consequently
+        # the second part of this test also tests that manage operation with a
+        # proper share type works.
+
+        def _delete_share(share_id):
+            self.shares_v2_client.reset_state(share_id)
+            self.shares_v2_client.delete_share(share_id)
+            self.shares_v2_client.wait_for_resource_deletion(share_id=share_id)
+            self.assertRaises(lib_exc.NotFound,
+                              self.shares_v2_client.get_share,
+                              share_id)
 
         share = self.shares_v2_client.manage_share(
             service_host=self.shares[1]['host'],
             export_path=self.shares[1]['export_locations'][0],
             protocol=self.shares[1]['share_proto'],
             share_type_id=self.st_invalid['share_type']['id'])
+        self.addCleanup(_delete_share, share['id'])
 
-        # Wait for failure
-        self.shares_v2_client.wait_for_share_status(share['id'],
-                                                    'manage_error')
+        self.shares_v2_client.wait_for_share_status(
+            share['id'], 'manage_error')
 
-        # Delete share
-        self.shares_v2_client.reset_state(share['id'])
-        self.shares_v2_client.delete_share(share['id'])
-        self.shares_v2_client.wait_for_resource_deletion(share_id=share['id'])
-        self.assertRaises(lib_exc.NotFound, self.shares_v2_client.get_share,
-                          share['id'])
-
-    @test.attr(type=["gate", "smoke", ])
-    def test_manage_with_type(self):
-        # Manage share with type
-
+        # Delete resource from backend. We need to manage the share properly
+        # so it can be removed.
         share = self.shares_v2_client.manage_share(
             service_host=self.shares[1]['host'],
             export_path=self.shares[1]['export_locations'][0],
             protocol=self.shares[1]['share_proto'],
             share_type_id=self.st['share_type']['id'])
+        self.addCleanup(_delete_share, share['id'])
 
-        # Wait for success
-        self.shares_v2_client.wait_for_share_status(share['id'], 'available')
-
-        # Delete share
-        self.shares_v2_client.delete_share(share['id'])
-        self.shares_v2_client.wait_for_resource_deletion(share_id=share['id'])
-        self.assertRaises(lib_exc.NotFound, self.shares_v2_client.get_share,
-                          share['id'])
+        self.shares_v2_client.wait_for_share_status(
+            share['id'], 'available')
 
 
 class ManageCIFSShareTest(ManageNFSShareTest):