Port 'RecordsetCrossZoneTest' to plugin
These tests were for the /v2/recordsets endpoint, so I've augmented
the tests that currently exist.
Ported:
`test_get_single_recordset` -> `test_get_single_zones_recordsets`
`test_list_recordsets` -> `test_list_zones_recordsets_zone_names`
`test_filter_recordsets` augmented `test_list_filter_zones_recordsets`
Change-Id: Ie79f201bc7b92328b77ce05fd0b0eebc63330c9f
diff --git a/designate_tempest_plugin/services/dns/v2/json/recordset_client.py b/designate_tempest_plugin/services/dns/v2/json/recordset_client.py
index 3363e0c..28ec56a 100644
--- a/designate_tempest_plugin/services/dns/v2/json/recordset_client.py
+++ b/designate_tempest_plugin/services/dns/v2/json/recordset_client.py
@@ -26,7 +26,7 @@
:param zone_uuid: Unique identifier of the zone in UUID format..
:param recordset_data: A dictionary that represents the recordset
- data.
+ data.
:param params: A Python dict that represents the query paramaters to
include in the request URI.
:return: A tuple with the server response and the created zone.
@@ -44,6 +44,28 @@
return resp, body
@base.handle_errors
+ def update_recordset(self, zone_uuid, recordset_uuid,
+ recordet_data, params=None):
+ """Update the recordset related to the specified zone.
+ :param zone_uuid: Unique identifier of the zone in UUID format.
+ :param recordset_uuid: Unique identifier of the recordset in UUID
+ format.
+ :param recordset_data: A dictionary that represents the recordset
+ data.
+ :param params: A Python dict that represents the query paramaters to
+ include in the request URI.
+ :return: A tuple with the server response and the created zone.
+ """
+ resp, body = self._put_request(
+ 'zones/{0}/recordsets'.format(zone_uuid), recordset_uuid,
+ data=recordet_data, params=params)
+
+ # Update Recordset should Return a HTTP 202
+ self.expected_success(202, resp.status)
+
+ return resp, body
+
+ @base.handle_errors
def show_recordset(self, zone_uuid, recordset_uuid, params=None):
"""Gets a specific recordset related to a specific zone.
:param zone_uuid: Unique identifier of the zone in UUID format.
@@ -87,6 +109,24 @@
'zones/{0}/recordsets'.format(uuid), params=params)
@base.handle_errors
+ def show_zones_recordset(self, recordset_uuid, params=None):
+ """Gets a single recordset, using the cross_zone endpoint
+ :param recordset_uuid: Unique identifier of the recordset in UUID
+ format.
+ :param params: A Python dict that represents the query paramaters to
+ include in the request URI.
+ :return: A tuple with the server response and the response body.
+ """
+ resp, body = self._show_request(
+ 'recordsets', recordset_uuid,
+ params=params)
+
+ # Show recordsets/id should return a HTTP 301
+ self.expected_success(301, resp.status)
+
+ return resp, body
+
+ @base.handle_errors
def list_zones_recordsets(self, params=None):
"""List recordsets across all zones.
:param params: A Python dict that represents the query paramaters to
@@ -95,23 +135,3 @@
"""
return self._list_request(
'recordsets', params=params)
-
- @base.handle_errors
- def update_recordset(self, zone_uuid, recordset_uuid,
- recordset_model, params=None):
- """Update the recordset related to the specified zone.
- :param zone_uuid: Unique identifier of the zone in UUID format..
- :param recordset_uuid: Unique identifier of the records in UUID format.
- :param recordset_model: .
- :param params: A Python dict that represents the query paramaters to
- include in the request URI.
- :return: A tuple with the server response and the created zone.
- """
- resp, body = self._put_request(
- 'zones/{0}/recordsets'.format(zone_uuid), recordset_uuid,
- data=recordset_model, params=params)
-
- # Update Recordset should Return a HTTP 202
- self.expected_success(202, resp.status)
-
- return resp, body
diff --git a/designate_tempest_plugin/tests/api/v2/test_recordset.py b/designate_tempest_plugin/tests/api/v2/test_recordset.py
index c1600c7..b7a8a16 100644
--- a/designate_tempest_plugin/tests/api/v2/test_recordset.py
+++ b/designate_tempest_plugin/tests/api/v2/test_recordset.py
@@ -281,17 +281,22 @@
self.assertGreater(len(body['recordsets']), 0)
+ @decorators.skip_because(bug="1616892")
+ @decorators.idempotent_id('65ec0495-81d9-4cfb-8007-9d93b32ae883')
+ def test_get_single_zones_recordsets(self):
+ recordset_data = data_utils.rand_recordset_data(
+ record_type='A', zone_name=self.zone['name'], records=['10.1.0.2'])
+
+ LOG.info('Create a Recordset')
+ resp, zone_recordset = self.client.create_recordset(
+ self.zone['id'], recordset_data)
+
+ self.client.show_zones_recordset(zone_recordset['id'])
+
@decorators.idempotent_id('a8e41020-65be-453b-a8c1-2497d539c345')
def test_list_filter_zones_recordsets(self):
- recordset_data = {
- "name": self.zone['name'],
- "description": "This is an example record set.",
- "type": "A",
- "ttl": 3600,
- "records": [
- "10.1.0.2"
- ]
- }
+ recordset_data = data_utils.rand_recordset_data(
+ record_type='A', zone_name=self.zone['name'], records=['10.0.1.2'])
LOG.info('Create a Recordset')
resp, zone_recordset = self.client.create_recordset(
@@ -301,12 +306,44 @@
_, zone2 = self.zone_client.create_zone()
self.addCleanup(self.zone_client.delete_zone, zone2['id'])
+ LOG.info('Create another Recordset')
+ recordset_data = data_utils.rand_recordset_data(
+ record_type='A', zone_name=zone2['name'],
+ records=['10.0.1.3'])
+ resp, zone_recordset2 = self.client.create_recordset(
+ zone2['id'], recordset_data)
+
LOG.info('List recordsets')
- _, body = self.client.list_zones_recordsets(params={"data": "10.1.*"})
+ _, body = self.client.list_zones_recordsets(params={"data": "10.0.*"})
recordsets = body['recordsets']
- self.assertEqual(zone_recordset['id'], recordsets[0]['id'])
+ ids = [r['id'] for r in recordsets]
+ self.assertIn(zone_recordset['id'], ids)
+ self.assertIn(zone_recordset2['id'], ids)
+ # Ensure that every rrset has a record with the filtered data
+ for r in recordsets:
+ one_record_has_data = False
+ for record in r['records']:
+ if record.startswith('10.0.'):
+ one_record_has_data = True
+ self.assertTrue(one_record_has_data)
+
+ @decorators.idempotent_id('7f4970bf-9aeb-4a3c-9afd-02f5a7178d35')
+ def test_list_zones_recordsets_zone_names(self):
+ LOG.info('Create another zone')
+ _, zone2 = self.zone_client.create_zone()
+ self.addCleanup(self.zone_client.delete_zone, zone2['id'])
+
+ LOG.info('List recordsets')
+ _, body = self.client.list_zones_recordsets()
+
+ recordsets = body['recordsets']
+ zone_names = set()
+ for r in recordsets:
+ zone_names.add(r['zone_name'])
+
+ self.assertGreaterEqual(len(zone_names), 2)
class RecordsetOwnershipTest(BaseRecordsetsTest):