Fixed multiple leaking tests

- Fixed multiple issues with cleanups.
- Fixed tld never being removed.
- Added some additional waiters.

Change-Id: I2a83c7c2c276be6c0d4fac82e0beaa157362dca0
diff --git a/designate_tempest_plugin/tests/api/v2/test_ptrs.py b/designate_tempest_plugin/tests/api/v2/test_ptrs.py
index e46f3f8..cfd9685 100644
--- a/designate_tempest_plugin/tests/api/v2/test_ptrs.py
+++ b/designate_tempest_plugin/tests/api/v2/test_ptrs.py
@@ -26,7 +26,7 @@
 
 class BasePtrTest(base.BaseDnsV2Test):
     excluded_keys = ['created_at', 'updated_at', 'version', 'links',
-                    'status', 'action']
+                     'status', 'action']
 
 
 class DesignatePtrRecord(BasePtrTest, tempest.test.BaseTestCase):
@@ -45,10 +45,13 @@
         cls.primary_floating_ip_client = cls.os_primary.floating_ips_client
 
     def _set_ptr(self):
-        fip_id = self.primary_floating_ip_client.create_floatingip(
-            floating_network_id=CONF.network.public_network_id)[
-            'floatingip']['id']
+        fip = self.primary_floating_ip_client.create_floatingip(
+            floating_network_id=CONF.network.public_network_id)['floatingip']
+        fip_id = fip['id']
+        self.addCleanup(self.primary_floating_ip_client.delete_floatingip,
+                        fip_id)
         ptr = self.primary_ptr_client.set_ptr_record(fip_id)
+        self.addCleanup(self.primary_ptr_client.unset_ptr_record, fip_id)
         self.assertEqual('CREATE', ptr['action'])
         self.assertEqual('PENDING', ptr['status'])
         return fip_id, ptr
@@ -102,12 +105,16 @@
 
     def _set_ptr(self, ptr_name=None, ttl=None, description=None,
                  headers=None):
-        fip_id = self.primary_floating_ip_client.create_floatingip(
+        fip = self.primary_floating_ip_client.create_floatingip(
             floating_network_id=CONF.network.public_network_id)[
-            'floatingip']['id']
+            'floatingip']
+        fip_id = fip['id']
+        self.addCleanup(self.primary_floating_ip_client.delete_floatingip,
+                        fip_id)
         ptr = self.primary_ptr_client.set_ptr_record(
             fip_id, ptr_name=ptr_name, ttl=ttl, description=description,
             headers=headers)
+        self.addCleanup(self.primary_ptr_client.unset_ptr_record, fip_id)
         self.assertEqual('CREATE', ptr['action'])
         self.assertEqual('PENDING', ptr['status'])
         return fip_id, ptr
diff --git a/designate_tempest_plugin/tests/api/v2/test_recordset.py b/designate_tempest_plugin/tests/api/v2/test_recordset.py
index b8f59fb..70e74c6 100644
--- a/designate_tempest_plugin/tests/api/v2/test_recordset.py
+++ b/designate_tempest_plugin/tests/api/v2/test_recordset.py
@@ -557,9 +557,8 @@
         cls.alt_zone_client = cls.os_alt.zones_client
         cls.admin_client = cls.os_admin.recordset_client
 
-    def _create_client_recordset(self, clients_list=None):
+    def _create_client_recordset(self, clients_list):
         """Create a zone and asoociated recordset using given credentials
-
         :param clients_list: supported credentials are: 'primary' and 'alt'.
         :return: dictionary of created recordsets.
         """
diff --git a/designate_tempest_plugin/tests/api/v2/test_tld.py b/designate_tempest_plugin/tests/api/v2/test_tld.py
index 380d224..f14d4ed 100644
--- a/designate_tempest_plugin/tests/api/v2/test_tld.py
+++ b/designate_tempest_plugin/tests/api/v2/test_tld.py
@@ -43,8 +43,14 @@
     @classmethod
     def resource_setup(cls):
         super(TldAdminTest, cls).resource_setup()
-        cls.tld = cls.admin_client.create_tld(tld_name='com',
-                      ignore_errors=lib_exc.Conflict)
+        cls.tld = cls.admin_client.create_tld(
+            tld_name='com', ignore_errors=lib_exc.Conflict
+        )
+
+    @classmethod
+    def resource_cleanup(cls):
+        cls.admin_client.delete_tld(cls.tld[1]['id'])
+        super(TldAdminTest, cls).resource_cleanup()
 
     @decorators.idempotent_id('52a4bb4b-4eff-4591-9dd3-ad98316806c3')
     def test_create_tld(self):
diff --git a/designate_tempest_plugin/tests/api/v2/test_transfer_accepts.py b/designate_tempest_plugin/tests/api/v2/test_transfer_accepts.py
index 5f43ed6..831619e 100644
--- a/designate_tempest_plugin/tests/api/v2/test_transfer_accepts.py
+++ b/designate_tempest_plugin/tests/api/v2/test_transfer_accepts.py
@@ -59,7 +59,9 @@
         LOG.info('Create a zone')
         _, zone = self.prm_zone_client.create_zone()
         self.addCleanup(
-            self.wait_zone_delete, self.prm_zone_client, zone['id'])
+            self.wait_zone_delete, self.admin_zone_client, zone['id'],
+            headers={'x-auth-all-projects': True},
+            ignore_errors=lib_exc.NotFound)
 
         LOG.info('Create a zone transfer_request')
         _, transfer_request = self.prm_request_client.create_transfer_request(
@@ -83,7 +85,9 @@
         LOG.info('Create a zone')
         _, zone = self.prm_zone_client.create_zone()
         self.addCleanup(
-            self.wait_zone_delete, self.prm_zone_client, zone['id'])
+            self.wait_zone_delete, self.admin_zone_client, zone['id'],
+            headers={'x-auth-all-projects': True},
+            ignore_errors=lib_exc.NotFound)
 
         LOG.info('Create a zone transfer_request')
         _, transfer_request = self.prm_request_client.create_transfer_request(
@@ -113,8 +117,10 @@
 
         LOG.info('Create a Primary zone')
         zone = self.prm_zone_client.create_zone()[1]
-        self.addCleanup(self.wait_zone_delete, self.prm_zone_client,
-                        zone['id'], ignore_errors=lib_exc.NotFound)
+        self.addCleanup(
+            self.wait_zone_delete, self.admin_zone_client, zone['id'],
+            headers={'x-auth-all-projects': True},
+            ignore_errors=lib_exc.NotFound)
 
         LOG.info('Create a Primary zone transfer_request')
         transfer_request = self.prm_request_client.create_transfer_request(
@@ -153,8 +159,10 @@
 
             LOG.info('Create a Primary zone')
             zone = self.prm_zone_client.create_zone()[1]
-            self.addCleanup(self.wait_zone_delete, self.prm_zone_client,
-                            zone['id'], ignore_errors=lib_exc.NotFound)
+            self.addCleanup(
+                self.wait_zone_delete, self.admin_zone_client, zone['id'],
+                headers={'x-auth-all-projects': True},
+                ignore_errors=lib_exc.NotFound)
 
             LOG.info('Create a Primary zone transfer_request')
             transfer_request = self.prm_request_client.create_transfer_request(
diff --git a/designate_tempest_plugin/tests/api/v2/test_zone_tasks.py b/designate_tempest_plugin/tests/api/v2/test_zone_tasks.py
index 5816cd4..12eea8c 100644
--- a/designate_tempest_plugin/tests/api/v2/test_zone_tasks.py
+++ b/designate_tempest_plugin/tests/api/v2/test_zone_tasks.py
@@ -53,9 +53,10 @@
 
     @decorators.idempotent_id('287e2cd0-a0e7-11eb-b962-74e5f9e2a801')
     def test_zone_abandon(self):
-
         LOG.info('Create a PRIMARY zone')
         pr_zone = self.client.create_zone()[1]
+        self.addCleanup(self.wait_zone_delete, self.client, pr_zone['id'])
+        waiters.wait_for_zone_status(self.client, pr_zone['id'], 'ACTIVE')
 
         LOG.info('Ensure we respond with CREATE+PENDING')
         self.assertEqual('CREATE', pr_zone['action'])
@@ -85,6 +86,7 @@
         LOG.info('Create a PRIMARY zone and add to the cleanup')
         pr_zone = self.client.create_zone()[1]
         self.addCleanup(self.wait_zone_delete, self.client, pr_zone['id'])
+        waiters.wait_for_zone_status(self.client, pr_zone['id'], 'ACTIVE')
 
         LOG.info('Ensure we respond with CREATE+PENDING')
         self.assertEqual('CREATE', pr_zone['action'])
@@ -138,6 +140,7 @@
         LOG.info('Create a PRIMARY zone')
         pr_zone = self.client.create_zone()[1]
         self.addCleanup(self.wait_zone_delete, self.client, pr_zone['id'])
+        waiters.wait_for_zone_status(self.client, pr_zone['id'], 'ACTIVE')
 
         LOG.info('Ensure we respond with CREATE+PENDING')
         self.assertEqual('CREATE', pr_zone['action'])
diff --git a/designate_tempest_plugin/tests/api/v2/test_zones_imports.py b/designate_tempest_plugin/tests/api/v2/test_zones_imports.py
index 950e021..b139742 100644
--- a/designate_tempest_plugin/tests/api/v2/test_zones_imports.py
+++ b/designate_tempest_plugin/tests/api/v2/test_zones_imports.py
@@ -62,7 +62,6 @@
         LOG.info('Create a zone import')
         _, zone_import = self.client.create_zone_import()
         self.addCleanup(self.clean_up_resources, zone_import['id'])
-
         LOG.info('Ensure we respond with PENDING')
         self.assertEqual(const.PENDING, zone_import['status'])
 
diff --git a/designate_tempest_plugin/tests/base.py b/designate_tempest_plugin/tests/base.py
index 6d33d81..a44db45 100644
--- a/designate_tempest_plugin/tests/base.py
+++ b/designate_tempest_plugin/tests/base.py
@@ -99,13 +99,17 @@
             callable_(*args, **kwargs)
 
     def wait_zone_delete(self, zone_client, zone_id, **kwargs):
-        zone_client.delete_zone(zone_id, **kwargs)
+        self._delete_zone(zone_client, zone_id, **kwargs)
         utils.call_until_true(self._check_zone_deleted,
                               CONF.dns.build_timeout,
                               CONF.dns.build_interval,
                               zone_client,
                               zone_id)
 
+    def _delete_zone(self, zone_client, zone_id, **kwargs):
+        return utils.call_and_ignore_notfound_exc(zone_client.delete_zone,
+                                                  zone_id, **kwargs)
+
     def _check_zone_deleted(self, zone_client, zone_id):
         return utils.call_and_ignore_notfound_exc(zone_client.show_zone,
                                                   zone_id) is None