2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-22 02:02:14 +00:00

64 lines
2.0 KiB
Python
Raw Normal View History

2018-07-27 10:18:29 -04:00
from hamcrest import *
from vinyldns_client import VinylDNSClient
from vinyldns_context import VinylDNSTestContext
import time
def test_sync_zone_success():
"""
Test syncing a zone
"""
zone_name = 'small'
client = VinylDNSClient()
zones = client.list_zones()['zones']
zone = [z for z in zones if z['name'] == zone_name + "."]
lastLatestSync = []
new = True
if zone:
zone = zone[0]
lastLatestSync = zone['latestSync']
new = False
else:
# create zone if it doesnt exist
zone = {
'name': zone_name,
'email': 'test@test.com',
'connection': {
'name': 'vinyldns.',
'keyName': VinylDNSTestContext.dns_key_name,
'key': VinylDNSTestContext.dns_key,
'primaryServer': VinylDNSTestContext.dns_ip
},
'transferConnection': {
'name': 'vinyldns.',
'keyName': VinylDNSTestContext.dns_key_name,
'key': VinylDNSTestContext.dns_key,
'primaryServer': VinylDNSTestContext.dns_ip
}
}
zone_change = client.create_zone(zone, status=202)
zone = zone_change['zone']
client.wait_until_zone_exists(zone_change)
zone_id = zone['id']
# run sync
change = client.sync_zone(zone_id, status=202)
# brief wait for zone status change. Can't use getZoneHistory here to check on the changeset itself,
# the action times out (presumably also querying the same record change table that the sync itself
# is interacting with)
time.sleep(0.5)
client.wait_until_zone_status(zone_id, 'Active')
# confirm zone has been updated
get_result = client.get_zone(zone_id)
synced_zone = get_result['zone']
latestSync = synced_zone['latestSync']
assert_that(synced_zone['updated'], is_not(none()))
assert_that(latestSync, is_not(none()))
if not new:
assert_that(latestSync, is_not(lastLatestSync))