Add zone serial tests.
Regarding to #914749 need to check that it's possible to create zones with serial in a different formats including unix timestamp and integer formats and update zone with a serial in different formats. Closes-bug: #2053022 Change-Id: I8004d84709836e9bf00bcbb8a1c0c034ae2badf6 Signed-off-by: Mikhail Samoylov <mikhailsamoiloff@gmail.com>
This commit is contained in:
parent
347fdbc9b4
commit
939bff8e30
|
@ -27,8 +27,8 @@ class ZonesClient(base.DnsClientV2Base):
|
|||
def create_zone(self, name=None, email=None, ttl=None, description=None,
|
||||
attributes=None, wait_until=False,
|
||||
zone_type=const.PRIMARY_ZONE_TYPE,
|
||||
primaries=None, params=None, project_id=None):
|
||||
|
||||
primaries=None, params=None, project_id=None,
|
||||
serial=None):
|
||||
"""Create a zone with the specified parameters.
|
||||
|
||||
:param name: The name of the zone.
|
||||
|
@ -39,6 +39,8 @@ class ZonesClient(base.DnsClientV2Base):
|
|||
Default: Random Value
|
||||
:param description: A description of the zone.
|
||||
Default: Random Value
|
||||
:param serial: A serial of the zone.
|
||||
Default: Random Value
|
||||
:param attributes: Key:Value pairs of information about this zone,
|
||||
and the pool the user would like to place the zone in.
|
||||
This information can be used by the scheduler to place
|
||||
|
@ -67,6 +69,8 @@ class ZonesClient(base.DnsClientV2Base):
|
|||
'attributes': attributes or {
|
||||
'attribute_key': data_utils.rand_name('attribute_value')}
|
||||
}
|
||||
if serial:
|
||||
zone['serial'] = serial
|
||||
# If SECONDARY, "email" and "ttl" cannot be supplied
|
||||
if zone_type == const.SECONDARY_ZONE_TYPE:
|
||||
zone['type'] = zone_type
|
||||
|
@ -159,7 +163,7 @@ class ZonesClient(base.DnsClientV2Base):
|
|||
@base.handle_errors
|
||||
def update_zone(self, uuid, email=None, ttl=None,
|
||||
description=None, wait_until=False, params=None,
|
||||
headers=None):
|
||||
headers=None, serial=None):
|
||||
"""Update a zone with the specified parameters.
|
||||
:param uuid: The unique identifier of the zone.
|
||||
:param email: The email for the zone.
|
||||
|
@ -168,6 +172,8 @@ class ZonesClient(base.DnsClientV2Base):
|
|||
Default: Random Value
|
||||
:param description: A description of the zone.
|
||||
Default: Random Value
|
||||
:param serial: A serial of the zone.
|
||||
Default: Random Value
|
||||
:param wait_until: Block until the zone reaches the desiered status
|
||||
:param params: A Python dict that represents the query parameters to
|
||||
include in the request URI.
|
||||
|
@ -179,7 +185,8 @@ class ZonesClient(base.DnsClientV2Base):
|
|||
'ttl': ttl or dns_data_utils.rand_ttl(),
|
||||
'description': description or data_utils.rand_name('test-zone'),
|
||||
}
|
||||
|
||||
if serial:
|
||||
zone['serial'] = serial
|
||||
resp, body = self._update_request('zones', uuid, zone, params=params,
|
||||
headers=headers)
|
||||
|
||||
|
|
|
@ -539,6 +539,109 @@ class ZonesTest(BaseZonesTest):
|
|||
"Failed, actual Zone's TTL:{} "
|
||||
"is not Zero".format(body['ttl']))
|
||||
|
||||
@decorators.idempotent_id('b58b3086-a575-49d9-9379-92de88097742')
|
||||
def test_create_zone_serial_yyyymmddss(self):
|
||||
serial = 2024080201
|
||||
LOG.info('Create a zone')
|
||||
zone_name = dns_data_utils.rand_zone_name(
|
||||
name="serial_yyyymmddss", suffix=self.tld_name)
|
||||
_, zone = self.zones_client.create_zone(name=zone_name, serial=serial)
|
||||
self.addCleanup(self.wait_zone_delete, self.zones_client, zone['id'])
|
||||
|
||||
LOG.info('Ensure we respond with a right serial')
|
||||
self.assertEqual(serial - 1, zone['serial'])
|
||||
|
||||
LOG.info('Fetch the zone')
|
||||
_, body = self.zones_client.show_zone(zone['id'])
|
||||
|
||||
LOG.info('Ensure we respond with updated serial')
|
||||
self.assertEqual(serial - 1, body['serial'])
|
||||
|
||||
@decorators.idempotent_id('5b288927-42b3-4c2d-b0b5-29a8092eaa01')
|
||||
def test_create_zone_serial_unixtime(self):
|
||||
serial = 1369550494
|
||||
zone_name = dns_data_utils.rand_zone_name(
|
||||
name="serial_unixtime", suffix=self.tld_name)
|
||||
_, zone = self.zones_client.create_zone(name=zone_name, serial=serial)
|
||||
self.addCleanup(self.wait_zone_delete, self.zones_client, zone['id'])
|
||||
|
||||
LOG.info('Ensure we respond with a right serial')
|
||||
self.assertEqual(serial - 1, zone['serial'])
|
||||
|
||||
LOG.info('Fetch the zone')
|
||||
_, body = self.zones_client.show_zone(zone['id'])
|
||||
|
||||
LOG.info('Ensure we respond with updated serial')
|
||||
self.assertEqual(serial - 1, body['serial'])
|
||||
|
||||
@decorators.idempotent_id('4779dea3-0591-4219-a1d8-6581f907ecb1')
|
||||
def test_create_zone_serial_number(self):
|
||||
serial = 1234567
|
||||
zone_name = dns_data_utils.rand_zone_name(
|
||||
name="serial_number", suffix=self.tld_name)
|
||||
_, zone = self.zones_client.create_zone(name=zone_name, serial=serial)
|
||||
self.addCleanup(self.wait_zone_delete, self.zones_client, zone['id'])
|
||||
|
||||
LOG.info('Ensure we respond with a right serial')
|
||||
self.assertEqual(serial - 1, zone['serial'])
|
||||
|
||||
LOG.info('Fetch the zone')
|
||||
_, body = self.zones_client.show_zone(zone['id'])
|
||||
|
||||
LOG.info('Ensure we respond with updated serial')
|
||||
self.assertEqual(serial - 1, body['serial'])
|
||||
|
||||
@decorators.idempotent_id('4283f440-990e-4097-9a92-7f8aa1638630')
|
||||
def test_update_zone_serial_to_unixtime(self):
|
||||
serial = 12345
|
||||
LOG.info('Create a zone')
|
||||
zone_name = dns_data_utils.rand_zone_name(
|
||||
name="serial_to_unixtime", suffix=self.tld_name)
|
||||
_, zone = self.zones_client.create_zone(name=zone_name, serial=serial)
|
||||
self.addCleanup(self.wait_zone_delete, self.zones_client, zone['id'])
|
||||
|
||||
LOG.info('Update the zone')
|
||||
_, zone = self.zones_client.update_zone(zone['id'], description="New description")
|
||||
|
||||
LOG.info('Ensure we respond with UPDATE+PENDING')
|
||||
self.assertEqual('UPDATE', zone['action'])
|
||||
self.assertEqual('PENDING', zone['status'])
|
||||
|
||||
LOG.info('Ensure we respond with updated values')
|
||||
self.assertNotEqual(serial, zone['serial'])
|
||||
|
||||
LOG.info('Fetch the zone')
|
||||
_, body = self.zones_client.show_zone(zone['id'])
|
||||
|
||||
LOG.info('Ensure we respond with updated serial')
|
||||
self.assertNotEqual(serial, body['serial'])
|
||||
|
||||
@decorators.idempotent_id('b4ef30c2-823f-47ca-9ef2-84348a77818c')
|
||||
def test_update_zone_serial_to_number(self):
|
||||
serial = 2147483646
|
||||
LOG.info('Create a zone')
|
||||
zone_name = dns_data_utils.rand_zone_name(
|
||||
name="serial_to_number", suffix=self.tld_name)
|
||||
_, zone = self.zones_client.create_zone(name=zone_name, serial=serial)
|
||||
self.addCleanup(self.wait_zone_delete, self.zones_client, zone['id'])
|
||||
|
||||
LOG.info('Update the zone')
|
||||
_, zone = self.zones_client.update_zone(
|
||||
zone['id'], serial=serial)
|
||||
|
||||
LOG.info('Ensure we respond with UPDATE+PENDING')
|
||||
self.assertEqual('UPDATE', zone['action'])
|
||||
self.assertEqual('PENDING', zone['status'])
|
||||
|
||||
LOG.info('Ensure we respond with updated values')
|
||||
self.assertEqual(serial - 1, zone['serial'])
|
||||
|
||||
LOG.info('Fetch the zone')
|
||||
_, body = self.zones_client.show_zone(zone['id'])
|
||||
|
||||
LOG.info('Ensure we respond with updated serial')
|
||||
self.assertEqual(serial - 1, body['serial'])
|
||||
|
||||
|
||||
class ZonesAdminTest(BaseZonesTest):
|
||||
credentials = ["primary", "admin", "system_admin", "alt"]
|
||||
|
|
Loading…
Reference in New Issue