Browse Source

Fix deleting zones after tests

these tests create zones as part of the test but do clean them up
afterward slowly. This leads to these and following tests in the thread
to fail with over quota when default zone quota is sufficiently low.

Change-Id: Iebe15ca6d0d3101237a92e011b081c38647a8de6
Maksym Shalamov 4 months ago
parent
commit
2da1d6e6c9

+ 17
- 11
designate_tempest_plugin/tests/api/v2/test_recordset.py View File

@@ -40,11 +40,11 @@ class BaseRecordsetsTest(base.BaseDnsV2Test):
40 40
 
41 41
     @classmethod
42 42
     def resource_cleanup(cls):
43
-        super(BaseRecordsetsTest, cls).resource_cleanup()
44
-
45 43
         cls.zone_client.delete_zone(
46 44
             cls.zone['id'], ignore_errors=lib_exc.NotFound)
47 45
 
46
+        super(BaseRecordsetsTest, cls).resource_cleanup()
47
+
48 48
 
49 49
 @ddt.ddt
50 50
 class RecordsetsTest(BaseRecordsetsTest):
@@ -244,7 +244,7 @@ class RecordsetsNegativeTest(BaseRecordsetsTest):
244 244
     def test_get_nonexistent_recordset(self):
245 245
         LOG.info('Create a zone')
246 246
         _, zone = self.zone_client.create_zone()
247
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
247
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
248 248
 
249 249
         LOG.info('Attempt to get an invalid Recordset')
250 250
         with self.assertRaisesDns(
@@ -255,7 +255,7 @@ class RecordsetsNegativeTest(BaseRecordsetsTest):
255 255
     def test_get_nonexistent_recordset_invalid_id(self):
256 256
         LOG.info('Create a zone')
257 257
         _, zone = self.zone_client.create_zone()
258
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
258
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
259 259
 
260 260
         LOG.info('Attempt to get an invalid Recordset')
261 261
         with self.assertRaisesDns(lib_exc.BadRequest, 'invalid_uuid', 400):
@@ -265,7 +265,7 @@ class RecordsetsNegativeTest(BaseRecordsetsTest):
265 265
     def test_update_nonexistent_recordset(self):
266 266
         LOG.info('Create a zone')
267 267
         _, zone = self.zone_client.create_zone()
268
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
268
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
269 269
 
270 270
         recordset_data = data_utils.rand_recordset_data('A', zone['name'])
271 271
 
@@ -279,7 +279,7 @@ class RecordsetsNegativeTest(BaseRecordsetsTest):
279 279
     def test_update_nonexistent_recordset_invalid_id(self):
280 280
         LOG.info('Create a zone')
281 281
         _, zone = self.zone_client.create_zone()
282
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
282
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
283 283
 
284 284
         recordset_data = data_utils.rand_recordset_data('A', zone['name'])
285 285
 
@@ -292,7 +292,7 @@ class RecordsetsNegativeTest(BaseRecordsetsTest):
292 292
     def test_delete_nonexistent_recordset(self):
293 293
         LOG.info('Create a zone')
294 294
         _, zone = self.zone_client.create_zone()
295
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
295
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
296 296
 
297 297
         LOG.info('Attempt to delete an invalid Recordset')
298 298
         with self.assertRaisesDns(
@@ -304,7 +304,7 @@ class RecordsetsNegativeTest(BaseRecordsetsTest):
304 304
     def test_delete_nonexistent_recordset_invalid_id(self):
305 305
         LOG.info('Create a zone')
306 306
         _, zone = self.zone_client.create_zone()
307
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
307
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
308 308
 
309 309
         LOG.info('Attempt to get an invalid Recordset')
310 310
         with self.assertRaisesDns(lib_exc.BadRequest, 'invalid_uuid', 400):
@@ -363,7 +363,7 @@ class RootRecordsetsTests(BaseRecordsetsTest):
363 363
 
364 364
         LOG.info('Create another zone')
365 365
         _, zone2 = self.zone_client.create_zone()
366
-        self.addCleanup(self.zone_client.delete_zone, zone2['id'])
366
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone2['id'])
367 367
 
368 368
         LOG.info('Create another Recordset')
369 369
         recordset_data = data_utils.rand_recordset_data(
@@ -392,7 +392,7 @@ class RootRecordsetsTests(BaseRecordsetsTest):
392 392
     def test_list_zones_recordsets_zone_names(self):
393 393
         LOG.info('Create another zone')
394 394
         _, zone2 = self.zone_client.create_zone()
395
-        self.addCleanup(self.zone_client.delete_zone, zone2['id'])
395
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone2['id'])
396 396
 
397 397
         LOG.info('List recordsets')
398 398
         _, body = self.client.list_zones_recordsets()
@@ -443,7 +443,7 @@ class RecordsetOwnershipTest(BaseRecordsetsTest):
443 443
 
444 444
         LOG.info('Create a zone as a default user')
445 445
         _, zone = self.zone_client.create_zone(name='a.b.' + zone_name)
446
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
446
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
447 447
 
448 448
         rrset_data = data_utils.rand_recordset_data(
449 449
             record_type='A', zone_name=zone_name)
@@ -458,6 +458,12 @@ class RecordsetOwnershipTest(BaseRecordsetsTest):
458 458
     def test_no_create_recordset_via_alt_domain(self):
459 459
         _, zone = self.zone_client.create_zone()
460 460
         _, alt_zone = self.alt_zone_client.create_zone()
461
+        self.addCleanup(self.wait_zone_delete,
462
+                        self.zone_client,
463
+                        zone['id'])
464
+        self.addCleanup(self.wait_zone_delete,
465
+                        self.alt_zone_client,
466
+                        alt_zone['id'])
461 467
 
462 468
         # alt attempts to create record with name A12345.{zone}
463 469
         recordset_data = data_utils.rand_recordset_data(

+ 3
- 1
designate_tempest_plugin/tests/api/v2/test_recordset_validation.py View File

@@ -60,7 +60,9 @@ class RecordsetValidationTest(base.BaseDnsV2Test):
60 60
             zone_data = data_utils.rand_zone_data()
61 61
             resp, body = self.zones_client.create_zone(**zone_data)
62 62
             self._zone = body
63
-            self.addCleanup(self.zones_client.delete_zone, body['id'])
63
+            self.addCleanup(self.wait_zone_delete,
64
+                            self.zones_client,
65
+                            body['id'])
64 66
         return self._zone
65 67
 
66 68
     def create_recordset(self, data):

+ 2
- 2
designate_tempest_plugin/tests/api/v2/test_transfer_accepts.py View File

@@ -43,7 +43,7 @@ class TransferAcceptTest(BaseTransferAcceptTest):
43 43
     def test_create_transfer_accept(self):
44 44
         LOG.info('Create a zone')
45 45
         _, zone = self.zone_client.create_zone()
46
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
46
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
47 47
 
48 48
         LOG.info('Create a zone transfer_request')
49 49
         _, transfer_request = self.request_client.create_transfer_request(
@@ -65,7 +65,7 @@ class TransferAcceptTest(BaseTransferAcceptTest):
65 65
     def test_show_transfer_accept(self):
66 66
         LOG.info('Create a zone')
67 67
         _, zone = self.zone_client.create_zone()
68
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
68
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
69 69
 
70 70
         LOG.info('Create a zone transfer_request')
71 71
         _, transfer_request = self.request_client.create_transfer_request(

+ 8
- 8
designate_tempest_plugin/tests/api/v2/test_transfer_request.py View File

@@ -47,7 +47,7 @@ class TransferRequestTest(BaseTransferRequestTest):
47 47
     def test_create_transfer_request(self):
48 48
         LOG.info('Create a zone')
49 49
         _, zone = self.zone_client.create_zone()
50
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
50
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
51 51
 
52 52
         LOG.info('Create a zone transfer_request')
53 53
         _, transfer_request = self.client.create_transfer_request(zone['id'])
@@ -61,7 +61,7 @@ class TransferRequestTest(BaseTransferRequestTest):
61 61
     def test_create_transfer_request_scoped(self):
62 62
         LOG.info('Create a zone')
63 63
         _, zone = self.zone_client.create_zone()
64
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
64
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
65 65
 
66 66
         transfer_request_data = dns_data_utils.rand_transfer_request_data(
67 67
             target_project_id=self.os_alt.credentials.project_id)
@@ -79,7 +79,7 @@ class TransferRequestTest(BaseTransferRequestTest):
79 79
     def test_create_transfer_request_empty_body(self):
80 80
         LOG.info('Create a zone')
81 81
         _, zone = self.zone_client.create_zone()
82
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
82
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
83 83
         LOG.info('Create a zone transfer_request')
84 84
         _, transfer_request = self.client.create_transfer_request_empty_body(
85 85
             zone['id'])
@@ -93,7 +93,7 @@ class TransferRequestTest(BaseTransferRequestTest):
93 93
     def test_show_transfer_request(self):
94 94
         LOG.info('Create a zone')
95 95
         _, zone = self.zone_client.create_zone()
96
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
96
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
97 97
 
98 98
         LOG.info('Create a zone transfer_request')
99 99
         _, transfer_request = self.client.create_transfer_request(zone['id'])
@@ -113,7 +113,7 @@ class TransferRequestTest(BaseTransferRequestTest):
113 113
         # the request.
114 114
         LOG.info('Create a zone')
115 115
         _, zone = self.zone_client.create_zone()
116
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
116
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
117 117
 
118 118
         transfer_request_data = dns_data_utils.rand_transfer_request_data(
119 119
             target_project_id=self.os_alt.credentials.project_id)
@@ -137,7 +137,7 @@ class TransferRequestTest(BaseTransferRequestTest):
137 137
     def test_delete_transfer_request(self):
138 138
         LOG.info('Create a zone')
139 139
         _, zone = self.zone_client.create_zone()
140
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
140
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
141 141
 
142 142
         LOG.info('Create a transfer_request')
143 143
         _, transfer_request = self.client.create_transfer_request(zone['id'])
@@ -154,7 +154,7 @@ class TransferRequestTest(BaseTransferRequestTest):
154 154
     def test_list_transfer_requests(self):
155 155
         LOG.info('Create a zone')
156 156
         _, zone = self.zone_client.create_zone()
157
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
157
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
158 158
 
159 159
         LOG.info('Create a zone transfer_request')
160 160
         _, transfer_request = self.client.create_transfer_request(zone['id'])
@@ -170,7 +170,7 @@ class TransferRequestTest(BaseTransferRequestTest):
170 170
     def test_update_transfer_request(self):
171 171
         LOG.info('Create a zone')
172 172
         _, zone = self.zone_client.create_zone()
173
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
173
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
174 174
 
175 175
         LOG.info('Create a zone transfer_request')
176 176
         _, transfer_request = self.client.create_transfer_request(zone['id'])

+ 5
- 5
designate_tempest_plugin/tests/api/v2/test_tsigkey.py View File

@@ -45,7 +45,7 @@ class TsigkeyAdminTest(BaseTsigkeyTest):
45 45
     def test_create_tsigkey(self):
46 46
         LOG.info('Create a resource')
47 47
         _, zone = self.zone_client.create_zone()
48
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
48
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
49 49
 
50 50
         tsigkey_data = {
51 51
                         "name": "Example tsigkey",
@@ -67,7 +67,7 @@ class TsigkeyAdminTest(BaseTsigkeyTest):
67 67
     def test_list_tsigkey(self):
68 68
         LOG.info('Create a resource')
69 69
         _, zone = self.zone_client.create_zone()
70
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
70
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
71 71
         LOG.info('Create a tsigkey')
72 72
         _, tsigkey = self.admin_client.create_tsigkey(resource_id=zone['id'])
73 73
         self.addCleanup(self.admin_client.delete_tsigkey, tsigkey['id'])
@@ -78,7 +78,7 @@ class TsigkeyAdminTest(BaseTsigkeyTest):
78 78
     def test_show_tsigkey(self):
79 79
         LOG.info('Create a resource')
80 80
         _, zone = self.zone_client.create_zone()
81
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
81
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
82 82
 
83 83
         LOG.info('Create a tsigkey')
84 84
         _, tsigkey = self.admin_client.create_tsigkey(resource_id=zone['id'])
@@ -94,7 +94,7 @@ class TsigkeyAdminTest(BaseTsigkeyTest):
94 94
     def test_update_tsigkey(self):
95 95
         LOG.info('Create a resource')
96 96
         _, zone = self.zone_client.create_zone()
97
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
97
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
98 98
 
99 99
         LOG.info('Create a tsigkey')
100 100
         _, tsigkey = self.admin_client.create_tsigkey(resource_id=zone['id'])
@@ -119,7 +119,7 @@ class TsigkeyAdminTest(BaseTsigkeyTest):
119 119
     def test_delete_tsigkey(self):
120 120
         LOG.info('Create a resource')
121 121
         _, zone = self.zone_client.create_zone()
122
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
122
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
123 123
 
124 124
         LOG.info('Create a tsigkey')
125 125
         _, tsigkey = self.admin_client.create_tsigkey(resource_id=zone['id'])

+ 9
- 9
designate_tempest_plugin/tests/api/v2/test_zones.py View File

@@ -44,7 +44,7 @@ class ZonesTest(BaseZonesTest):
44 44
     def test_create_zone(self):
45 45
         LOG.info('Create a zone')
46 46
         _, zone = self.client.create_zone()
47
-        self.addCleanup(self.client.delete_zone, zone['id'])
47
+        self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
48 48
 
49 49
         LOG.info('Ensure we respond with CREATE+PENDING')
50 50
         self.assertEqual('CREATE', zone['action'])
@@ -54,7 +54,7 @@ class ZonesTest(BaseZonesTest):
54 54
     def test_show_zone(self):
55 55
         LOG.info('Create a zone')
56 56
         _, zone = self.client.create_zone()
57
-        self.addCleanup(self.client.delete_zone, zone['id'])
57
+        self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
58 58
 
59 59
         LOG.info('Fetch the zone')
60 60
         _, body = self.client.show_zone(zone['id'])
@@ -67,7 +67,7 @@ class ZonesTest(BaseZonesTest):
67 67
     def test_delete_zone(self):
68 68
         LOG.info('Create a zone')
69 69
         _, zone = self.client.create_zone()
70
-        self.addCleanup(self.client.delete_zone, zone['id'],
70
+        self.addCleanup(self.wait_zone_delete, self.client, zone['id'],
71 71
                         ignore_errors=lib_exc.NotFound)
72 72
 
73 73
         LOG.info('Delete the zone')
@@ -81,7 +81,7 @@ class ZonesTest(BaseZonesTest):
81 81
     def test_list_zones(self):
82 82
         LOG.info('Create a zone')
83 83
         _, zone = self.client.create_zone()
84
-        self.addCleanup(self.client.delete_zone, zone['id'])
84
+        self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
85 85
 
86 86
         LOG.info('List zones')
87 87
         _, body = self.client.list_zones()
@@ -94,7 +94,7 @@ class ZonesTest(BaseZonesTest):
94 94
     def test_update_zone(self):
95 95
         LOG.info('Create a zone')
96 96
         _, zone = self.client.create_zone()
97
-        self.addCleanup(self.client.delete_zone, zone['id'])
97
+        self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
98 98
 
99 99
         # Generate a random description
100 100
         description = data_utils.rand_name()
@@ -138,7 +138,7 @@ class ZonesAdminTest(BaseZonesTest):
138 138
     def test_get_other_tenant_zone(self):
139 139
         LOG.info('Create a zone as a user')
140 140
         _, zone = self.client.create_zone()
141
-        self.addCleanup(self.client.delete_zone, zone['id'])
141
+        self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
142 142
 
143 143
         LOG.info('Fetch the zone as an admin')
144 144
         _, body = self.admin_client.show_zone(
@@ -168,7 +168,7 @@ class ZoneOwnershipTest(BaseZonesTest):
168 168
     def test_no_create_duplicate_domain(self):
169 169
         LOG.info('Create a zone as a default user')
170 170
         _, zone = self.client.create_zone()
171
-        self.addCleanup(self.client.delete_zone, zone['id'])
171
+        self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
172 172
 
173 173
         LOG.info('Create a zone as an default with existing domain')
174 174
         self.assertRaises(lib_exc.Conflict,
@@ -182,7 +182,7 @@ class ZoneOwnershipTest(BaseZonesTest):
182 182
     def test_no_create_subdomain_by_alt_user(self):
183 183
         LOG.info('Create a zone as a default user')
184 184
         _, zone = self.client.create_zone()
185
-        self.addCleanup(self.client.delete_zone, zone['id'])
185
+        self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
186 186
 
187 187
         LOG.info('Create a zone as an alt user with existing subdomain')
188 188
         self.assertRaises(lib_exc.Forbidden,
@@ -196,7 +196,7 @@ class ZoneOwnershipTest(BaseZonesTest):
196 196
 
197 197
         LOG.info('Create a zone as a default user')
198 198
         _, zone = self.client.create_zone(name='a.b.' + zone_name)
199
-        self.addCleanup(self.client.delete_zone, zone['id'])
199
+        self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
200 200
 
201 201
         LOG.info('Create a zone as an alt user with existing superdomain')
202 202
         self.assertRaises(lib_exc.Forbidden,

+ 7
- 4
designate_tempest_plugin/tests/api/v2/test_zones_exports.py View File

@@ -44,10 +44,11 @@ class ZonesExportTest(BaseZoneExportsTest):
44 44
     def test_create_zone_export(self):
45 45
         LOG.info('Create a zone')
46 46
         _, zone = self.zone_client.create_zone()
47
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
47
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
48 48
 
49 49
         LOG.info('Create a zone export')
50 50
         _, zone_export = self.client.create_zone_export(zone['id'])
51
+        self.addCleanup(self.client.delete_zone_export, zone_export['id'])
51 52
 
52 53
         LOG.info('Ensure we respond with PENDING')
53 54
         self.assertEqual('PENDING', zone_export['status'])
@@ -57,10 +58,11 @@ class ZonesExportTest(BaseZoneExportsTest):
57 58
     def test_show_zone_export(self):
58 59
         LOG.info('Create a zone')
59 60
         _, zone = self.zone_client.create_zone()
60
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
61
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
61 62
 
62 63
         LOG.info('Create a zone export')
63 64
         resp, zone_export = self.client.create_zone_export(zone['id'])
65
+        self.addCleanup(self.client.delete_zone_export, zone_export['id'])
64 66
 
65 67
         LOG.info('Re-Fetch the zone export')
66 68
         _, body = self.client.show_zone_export(zone_export['id'])
@@ -72,7 +74,7 @@ class ZonesExportTest(BaseZoneExportsTest):
72 74
     def test_delete_zone_export(self):
73 75
         LOG.info('Create a zone')
74 76
         _, zone = self.zone_client.create_zone()
75
-        self.addCleanup(self.zone_client.delete_zone, zone['id'],
77
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'],
76 78
                         ignore_errors=lib_exc.NotFound)
77 79
 
78 80
         LOG.info('Create a zone export')
@@ -89,9 +91,10 @@ class ZonesExportTest(BaseZoneExportsTest):
89 91
     def test_list_zone_exports(self):
90 92
         LOG.info('Create a zone')
91 93
         _, zone = self.zone_client.create_zone()
92
-        self.addCleanup(self.zone_client.delete_zone, zone['id'])
94
+        self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
93 95
 
94 96
         _, export = self.client.create_zone_export(zone['id'])
97
+        self.addCleanup(self.client.delete_zone_export, export['id'])
95 98
 
96 99
         LOG.info('List zone exports')
97 100
         _, body = self.client.list_zone_exports()

+ 20
- 3
designate_tempest_plugin/tests/api/v2/test_zones_imports.py View File

@@ -16,6 +16,7 @@ from oslo_log import log as logging
16 16
 from tempest.lib import decorators
17 17
 from tempest.lib import exceptions as lib_exc
18 18
 
19
+from designate_tempest_plugin.common import waiters
19 20
 from designate_tempest_plugin.tests import base
20 21
 
21 22
 LOG = logging.getLogger(__name__)
@@ -36,13 +37,22 @@ class ZonesImportTest(BaseZonesImportTest):
36 37
     @classmethod
37 38
     def setup_clients(cls):
38 39
         super(ZonesImportTest, cls).setup_clients()
40
+
39 41
         cls.client = cls.os_primary.zone_imports_client
42
+        cls.zone_client = cls.os_primary.zones_client
43
+
44
+    def clean_up_resources(self, zone_import_id):
45
+        waiters.wait_for_zone_import_status(self.client, zone_import_id,
46
+                                            "COMPLETE")
47
+        _, zone_import = self.client.show_zone_import(zone_import_id)
48
+        self.client.delete_zone_import(zone_import['id'])
49
+        self.wait_zone_delete(self.zone_client, zone_import['zone_id'])
40 50
 
41 51
     @decorators.idempotent_id('2e2d907d-0609-405b-9c96-3cb2b87e3dce')
42 52
     def test_create_zone_import(self):
43 53
         LOG.info('Create a zone import')
44 54
         _, zone_import = self.client.create_zone_import()
45
-        self.addCleanup(self.client.delete_zone_import, zone_import['id'])
55
+        self.addCleanup(self.clean_up_resources, zone_import['id'])
46 56
 
47 57
         LOG.info('Ensure we respond with PENDING')
48 58
         self.assertEqual('PENDING', zone_import['status'])
@@ -52,7 +62,7 @@ class ZonesImportTest(BaseZonesImportTest):
52 62
     def test_show_zone_import(self):
53 63
         LOG.info('Create a zone import')
54 64
         _, zone_import = self.client.create_zone_import()
55
-        self.addCleanup(self.client.delete_zone_import, zone_import['id'])
65
+        self.addCleanup(self.clean_up_resources, zone_import['id'])
56 66
 
57 67
         LOG.info('Re-Fetch the zone import')
58 68
         resp, body = self.client.show_zone_import(zone_import['id'])
@@ -64,6 +74,12 @@ class ZonesImportTest(BaseZonesImportTest):
64 74
     def test_delete_zone_import(self):
65 75
         LOG.info('Create a zone import')
66 76
         _, zone_import = self.client.create_zone_import()
77
+        waiters.wait_for_zone_import_status(self.client, zone_import['id'],
78
+                                            "COMPLETE")
79
+        _, zone_import = self.client.show_zone_import(zone_import['id'])
80
+        self.addCleanup(self.wait_zone_delete,
81
+                        self.zone_client,
82
+                        zone_import['zone_id'])
67 83
 
68 84
         LOG.info('Delete the zone')
69 85
         resp, body = self.client.delete_zone_import(zone_import['id'])
@@ -75,7 +91,8 @@ class ZonesImportTest(BaseZonesImportTest):
75 91
     @decorators.idempotent_id('9eab76af-1995-485f-a2ef-8290c1863aba')
76 92
     def test_list_zones_imports(self):
77 93
         LOG.info('Create a zone import')
78
-        _, zone = self.client.create_zone_import()
94
+        _, zone_import = self.client.create_zone_import()
95
+        self.addCleanup(self.clean_up_resources, zone_import['id'])
79 96
 
80 97
         LOG.info('List zones imports')
81 98
         _, body = self.client.list_zone_imports()

+ 13
- 0
designate_tempest_plugin/tests/base.py View File

@@ -14,6 +14,7 @@
14 14
 import six
15 15
 from tempest import test
16 16
 from tempest import config
17
+from tempest.lib.common.utils import test_utils as utils
17 18
 
18 19
 from designate_tempest_plugin import clients
19 20
 
@@ -97,6 +98,18 @@ class BaseDnsTest(test.BaseTestCase):
97 98
         with context:
98 99
             callable_(*args, **kwargs)
99 100
 
101
+    def wait_zone_delete(self, zone_client, zone_id, **kwargs):
102
+        zone_client.delete_zone(zone_id, **kwargs)
103
+        utils.call_until_true(self._check_zone_deleted,
104
+                              CONF.dns.build_timeout,
105
+                              CONF.dns.build_interval,
106
+                              zone_client,
107
+                              zone_id)
108
+
109
+    def _check_zone_deleted(self, zone_client, zone_id):
110
+        return utils.call_and_ignore_notfound_exc(zone_client.show_zone,
111
+                                                  zone_id) is None
112
+
100 113
 
101 114
 class BaseDnsV1Test(BaseDnsTest):
102 115
     """Base class for DNS V1 API tests."""

+ 4
- 4
designate_tempest_plugin/tests/scenario/v2/test_zones.py View File

@@ -38,7 +38,7 @@ class ZonesTest(base.BaseDnsV2Test):
38 38
     def test_create_and_delete_zone(self):
39 39
         LOG.info('Create a zone')
40 40
         _, zone = self.client.create_zone()
41
-        self.addCleanup(self.client.delete_zone, zone['id'],
41
+        self.addCleanup(self.wait_zone_delete, self.client, zone['id'],
42 42
                         ignore_errors=lib_exc.NotFound)
43 43
 
44 44
         LOG.info('Ensure we respond with CREATE+PENDING')
@@ -69,7 +69,7 @@ class ZonesTest(base.BaseDnsV2Test):
69 69
     def test_delete_zone_pending_create(self):
70 70
         LOG.info('Create a zone')
71 71
         _, zone = self.client.create_zone()
72
-        self.addCleanup(self.client.delete_zone, zone['id'],
72
+        self.addCleanup(self.wait_zone_delete, self.client, zone['id'],
73 73
                         ignore_errors=lib_exc.NotFound)
74 74
 
75 75
         # NOTE(kiall): This is certainly a little racey, it's entirely
@@ -94,7 +94,7 @@ class ZonesTest(base.BaseDnsV2Test):
94 94
     def test_zone_create_propagates_to_nameservers(self):
95 95
         LOG.info('Create a zone')
96 96
         _, zone = self.client.create_zone()
97
-        self.addCleanup(self.client.delete_zone, zone['id'])
97
+        self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
98 98
 
99 99
         waiters.wait_for_zone_status(self.client, zone['id'], "ACTIVE")
100 100
         waiters.wait_for_query(self.query_client, zone['name'], "SOA")
@@ -107,7 +107,7 @@ class ZonesTest(base.BaseDnsV2Test):
107 107
     def test_zone_delete_propagates_to_nameservers(self):
108 108
         LOG.info('Create a zone')
109 109
         _, zone = self.client.create_zone()
110
-        self.addCleanup(self.client.delete_zone, zone['id'],
110
+        self.addCleanup(self.wait_zone_delete, self.client, zone['id'],
111 111
                         ignore_errors=lib_exc.NotFound)
112 112
 
113 113
         waiters.wait_for_zone_status(self.client, zone['id'], "ACTIVE")

+ 4
- 1
designate_tempest_plugin/tests/scenario/v2/test_zones_export.py View File

@@ -36,10 +36,12 @@ class ZonesExportTest(BaseZoneExportsTest):
36 36
     def test_create_zone_export_and_show_exported_zonefile(self):
37 37
         LOG.info('Create a zone to be exported')
38 38
         _, zone = self.zones_client.create_zone()
39
-        self.addCleanup(self.zones_client.delete_zone, zone['id'])
39
+        self.addCleanup(self.wait_zone_delete, self.zones_client, zone['id'])
40 40
 
41 41
         LOG.info('Create a zone export')
42 42
         _, zone_export = self.client.create_zone_export(zone['id'])
43
+        self.addCleanup(self.client.delete_zone_export, zone_export['id'])
44
+
43 45
         self.assertEqual('PENDING', zone_export['status'])
44 46
         self.assertEqual(zone['id'], zone_export['zone_id'])
45 47
         self.assertIsNone(zone_export['links'].get('export'))
@@ -51,6 +53,7 @@ class ZonesExportTest(BaseZoneExportsTest):
51 53
 
52 54
         LOG.info('Check the zone export looks good')
53 55
         _, zone_export = self.client.show_zone_export(zone_export['id'])
56
+
54 57
         self.assertEqual('COMPLETE', zone_export['status'])
55 58
         self.assertEqual(zone['id'], zone_export['zone_id'])
56 59
         self.assertIsNotNone(zone_export['links'].get('export'))

+ 5
- 0
designate_tempest_plugin/tests/scenario/v2/test_zones_import.py View File

@@ -27,6 +27,7 @@ class ZonesImportTest(BaseZonesImportTest):
27 27
     @classmethod
28 28
     def setup_clients(cls):
29 29
         super(ZonesImportTest, cls).setup_clients()
30
+
30 31
         cls.client = cls.os_primary.zone_imports_client
31 32
         cls.zones_client = cls.os_primary.zones_client
32 33
 
@@ -46,6 +47,10 @@ class ZonesImportTest(BaseZonesImportTest):
46 47
 
47 48
         LOG.info('Check the zone import looks good')
48 49
         _, zone_import = self.client.show_zone_import(zone_import['id'])
50
+        self.addCleanup(self.wait_zone_delete,
51
+                        self.zones_client,
52
+                        zone_import['zone_id'])
53
+
49 54
         self.assertEqual('COMPLETE', zone_import['status'])
50 55
         self.assertIsNotNone(zone_import['zone_id'])
51 56
         self.assertIsNotNone(zone_import['links'].get('zone'))

+ 7
- 4
designate_tempest_plugin/tests/scenario/v2/test_zones_transfer.py View File

@@ -37,14 +37,14 @@ class ZonesTransferTest(base.BaseDnsV2Test):
37 37
     def test_zone_transfer(self):
38 38
         LOG.info('Create a zone as primary tenant')
39 39
         _, zone = self.zones_client.create_zone()
40
-        self.addCleanup(self.zones_client.delete_zone, zone['id'],
41
-                        ignore_errors=lib_exc.NotFound)
42
-        self.addCleanup(self.alt_zones_client.delete_zone, zone['id'],
40
+        self.addCleanup(self.wait_zone_delete, self.zones_client, zone['id'],
43 41
                         ignore_errors=lib_exc.NotFound)
44 42
 
45 43
         LOG.info('Create a zone transfer_request for zone as primary tenant')
46 44
         _, transfer_request = \
47 45
             self.request_client.create_transfer_request_empty_body(zone['id'])
46
+        self.addCleanup(self.request_client.delete_transfer_request,
47
+                        transfer_request['id'])
48 48
 
49 49
         accept_data = {
50 50
                  "key": transfer_request['key'],
@@ -55,7 +55,10 @@ class ZonesTransferTest(base.BaseDnsV2Test):
55 55
         self.alt_accept_client.create_transfer_accept(accept_data)
56 56
 
57 57
         LOG.info('Fetch the zone as alt tenant')
58
-        self.alt_zones_client.show_zone(zone['id'])
58
+        _, alt_zone = self.alt_zones_client.show_zone(zone['id'])
59
+        self.addCleanup(self.wait_zone_delete,
60
+                        self.alt_zones_client,
61
+                        alt_zone['id'])
59 62
 
60 63
         LOG.info('Ensure 404 when fetching the zone as primary tenant')
61 64
         self.assertRaises(lib_exc.NotFound,

Loading…
Cancel
Save