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
4626c46cd9
@ -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
|
||||
|
@ -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
Block a user