Add a zone export scenario test
This renames a couple of the zone export client methods. It also
fixes an issue with the (newly named) `show_exported_zone` function
which wasn't passing the right number of arguments.
Change-Id: Ie0cce8710e0ef17dc391cb5bdd150a63b57d2f72
diff --git a/designate_tempest_plugin/common/waiters.py b/designate_tempest_plugin/common/waiters.py
index efd3625..d13465d 100644
--- a/designate_tempest_plugin/common/waiters.py
+++ b/designate_tempest_plugin/common/waiters.py
@@ -116,6 +116,39 @@
raise lib_exc.TimeoutException(message)
+def wait_for_zone_export_status(client, zone_export_id, status):
+ """Waits for an exported zone to reach the given status."""
+ LOG.info('Waiting for zone export %s to reach %s', zone_export_id, status)
+
+ _, zone_export = client.show_zone_export(zone_export_id)
+ start = int(time.time())
+
+ while zone_export['status'] != status:
+ time.sleep(client.build_interval)
+ _, zone_export = client.show_zone_export(zone_export_id)
+ status_curr = zone_export['status']
+ if status_curr == status:
+ LOG.info('Zone export %s reached %s', zone_export_id, status)
+ return
+
+ if int(time.time()) - start >= client.build_timeout:
+ message = ('Zone export %(zone_export_id)s failed to reach '
+ 'status=%(status)s within the required time '
+ '(%(timeout)s s). Current '
+ 'status: %(status_curr)s' %
+ {'zone_export_id': zone_export_id,
+ 'status': status,
+ 'status_curr': status_curr,
+ 'timeout': client.build_timeout})
+
+ caller = misc_utils.find_test_caller()
+
+ if caller:
+ message = '(%s) %s' % (caller, message)
+
+ raise lib_exc.TimeoutException(message)
+
+
def wait_for_recordset_status(client, recordset_id, status):
"""Waits for a recordset to reach the given status."""
LOG.info('Waiting for recordset %s to reach %s',
diff --git a/designate_tempest_plugin/services/dns/v2/json/zone_exports_client.py b/designate_tempest_plugin/services/dns/v2/json/zone_exports_client.py
index 15c8339..3bbd6c9 100644
--- a/designate_tempest_plugin/services/dns/v2/json/zone_exports_client.py
+++ b/designate_tempest_plugin/services/dns/v2/json/zone_exports_client.py
@@ -21,6 +21,7 @@
@base.handle_errors
def create_zone_export(self, uuid, params=None, wait_until=False):
"""Create a zone export.
+
:param uuid: Unique identifier of the zone in UUID format.
:param params: A Python dict that represents the query paramaters to
include in the request URI.
@@ -42,9 +43,10 @@
return resp, body
@base.handle_errors
- def show_zone_export_records(self, uuid, params=None):
- """Gets a specific exported zone.
- :param uuid: Unique identifier of the exported zone in UUID format.
+ def show_zone_export(self, uuid, params=None):
+ """Get the zone export task
+
+ :param uuid: Unique identifier of the zone export task in UUID format.
:param params: A Python dict that represents the query paramaters to
include in the request URI.
:return: Serialized exported zone as a dictionary.
@@ -53,9 +55,10 @@
'zones/tasks/exports', uuid, params=params)
@base.handle_errors
- def show_zone_exported(self, uuid, params=None):
- """Gets a specific exported zone.
- :param uuid: Unique identifier of the exported zone in UUID format.
+ def show_exported_zonefile(self, uuid, params=None):
+ """Get the exported zone file
+
+ :param uuid: Unique identifier of the zone exprot task in UUID format.
:param params: A Python dict that represents the query paramaters to
include in the request URI.
:return: Serialized exported zone as a dictionary.
@@ -63,12 +66,13 @@
headers = {'Accept': 'text/dns'}
return self._show_request(
- 'zones/tasks/exports/{0}/export'.format(uuid),
+ 'zones/tasks/exports/{0}/export'.format(uuid), uuid='',
headers=headers, params=params)
@base.handle_errors
- def list_zones_exports(self, params=None):
- """Gets all the exported zones
+ def list_zone_exports(self, params=None):
+ """List zone export tasks
+
:param params: A Python dict that represents the query paramaters to
include in the request URI.
:return: Serialized exported zone as a list.
@@ -78,7 +82,8 @@
@base.handle_errors
def delete_zone_export(self, uuid, params=None):
- """Deletes an exported zone having the specified UUID.
+ """Deletes the zone export task with the specified UUID.
+
:param uuid: The unique identifier of the exported zone.
:param params: A Python dict that represents the query paramaters to
include in the request URI.
diff --git a/designate_tempest_plugin/tests/api/v2/test_zones_exports.py b/designate_tempest_plugin/tests/api/v2/test_zones_exports.py
index 05cb9e8..3723aca 100644
--- a/designate_tempest_plugin/tests/api/v2/test_zones_exports.py
+++ b/designate_tempest_plugin/tests/api/v2/test_zones_exports.py
@@ -57,11 +57,10 @@
LOG.info('Create a zone export')
resp, zone_export = self.client.create_zone_export(zone['id'])
- LOG.info('Re-Fetch the zone export records')
- _, body = self.client.show_zone_export_records(str(zone_export['id']))
+ LOG.info('Re-Fetch the zone export')
+ _, body = self.client.show_zone_export(zone_export['id'])
- LOG.info('Ensure the fetched response matches the records of '
- 'exported zone')
+ LOG.info('Ensure the fetched response matches the zone export')
self.assertExpected(zone_export, body, self.excluded_keys)
@test.attr(type='smoke')
@@ -75,23 +74,23 @@
LOG.info('Create a zone export')
_, zone_export = self.client.create_zone_export(zone['id'])
- LOG.info('Delete the exported zone')
+ LOG.info('Delete the zone export')
_, body = self.client.delete_zone_export(zone_export['id'])
- LOG.info('Ensure the exported zone has been successfully deleted')
+ LOG.info('Ensure the zone export has been successfully deleted')
self.assertRaises(lib_exc.NotFound,
- lambda: self.client.show_zone_export_records(zone_export['id']))
+ lambda: self.client.show_zone_export(zone_export['id']))
@test.attr(type='smoke')
@test.idempotent_id('476bfdfe-58c8-46e2-b376-8403c0fff440')
- def test_list_zones_exports(self):
+ def test_list_zone_exports(self):
LOG.info('Create a zone')
_, zone = self.zone_client.create_zone()
self.addCleanup(self.zone_client.delete_zone, zone['id'])
_, export = self.client.create_zone_export(zone['id'])
- LOG.info('List zones exports')
- _, body = self.client.list_zones_exports()
+ LOG.info('List zone exports')
+ _, body = self.client.list_zone_exports()
self.assertGreater(len(body['exports']), 0)
diff --git a/designate_tempest_plugin/tests/scenario/v2/test_zones_export.py b/designate_tempest_plugin/tests/scenario/v2/test_zones_export.py
new file mode 100644
index 0000000..b5a1214
--- /dev/null
+++ b/designate_tempest_plugin/tests/scenario/v2/test_zones_export.py
@@ -0,0 +1,62 @@
+# Copyright 2016 Rackspace
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from oslo_log import log as logging
+from tempest import test
+
+from designate_tempest_plugin.common import waiters
+from designate_tempest_plugin.tests.api.v2.test_zones_exports import \
+ BaseZoneExportsTest
+
+LOG = logging.getLogger(__name__)
+
+
+class ZonesExportTest(BaseZoneExportsTest):
+
+ @classmethod
+ def setup_clients(cls):
+ super(ZonesExportTest, cls).setup_clients()
+
+ cls.zones_client = cls.os.zones_client
+ cls.client = cls.os.zone_exports_client
+
+ @test.attr(type='slow')
+ @test.idempotent_id('0484c3c4-df57-458e-a6e5-6eb63e0475e0')
+ def test_create_zone_export_and_show_exported_zonefile(self):
+ LOG.info('Create a zone to be exported')
+ _, zone = self.zones_client.create_zone()
+ self.addCleanup(self.zones_client.delete_zone, zone['id'])
+
+ LOG.info('Create a zone export')
+ _, zone_export = self.client.create_zone_export(zone['id'])
+ self.assertEqual('PENDING', zone_export['status'])
+ self.assertEqual(zone['id'], zone_export['zone_id'])
+ self.assertIsNone(zone_export['links'].get('export'))
+ self.assertIsNone(zone_export['location'])
+
+ LOG.info('Wait for the zone export to COMPLETE')
+ waiters.wait_for_zone_export_status(
+ self.client, zone_export['id'], 'COMPLETE')
+
+ LOG.info('Check the zone export looks good')
+ _, zone_export = self.client.show_zone_export(zone_export['id'])
+ self.assertEqual('COMPLETE', zone_export['status'])
+ self.assertEqual(zone['id'], zone_export['zone_id'])
+ self.assertIsNotNone(zone_export['links'].get('export'))
+ self.assertIsNotNone(zone_export['location'])
+
+ LOG.info('Fetch the exported zonefile')
+ _, zonefile = self.client.show_exported_zonefile(zone_export['id'])
+ self.assertEqual(zone['name'], zonefile.origin)
+ self.assertEqual(zone['ttl'], zonefile.ttl)