Browse Source

compare endpoint_status in Azure profiles

pull/780/head
Viranch Mehta 4 years ago
parent
commit
0d543d9b78
No known key found for this signature in database GPG Key ID: D83D1392AE9F93B4
2 changed files with 12 additions and 3 deletions
  1. +4
    -1
      octodns/provider/azuredns.py
  2. +8
    -2
      tests/test_octodns_provider_azuredns.py

+ 4
- 1
octodns/provider/azuredns.py View File

@ -375,8 +375,11 @@ def _profile_is_match(have, desired):
desired_endpoints = desired.endpoints
endpoints = zip(have_endpoints, desired_endpoints)
for have_endpoint, desired_endpoint in endpoints:
have_status = have_endpoint.endpoint_status or 'Enabled'
desired_status = desired_endpoint.endpoint_status or 'Enabled'
if have_endpoint.name != desired_endpoint.name or \
have_endpoint.type != desired_endpoint.type:
have_endpoint.type != desired_endpoint.type or \
have_status != desired_status:
return false(have_endpoint, desired_endpoint, have.name)
target_type = have_endpoint.type.split('/')[-1]
if target_type == 'externalEndpoints':


+ 8
- 2
tests/test_octodns_provider_azuredns.py View File

@ -473,6 +473,7 @@ class Test_ProfileIsMatch(TestCase):
endpoints = 1,
endpoint_name = 'name',
endpoint_type = 'profile/nestedEndpoints',
endpoint_status = None,
target = 'target.unit.tests',
target_id = 'resource/id',
geos = ['GEO-AF'],
@ -490,6 +491,7 @@ class Test_ProfileIsMatch(TestCase):
endpoints=[Endpoint(
name=endpoint_name,
type=endpoint_type,
endpoint_status=endpoint_status,
target=target,
target_resource_id=target_id,
geo_mapping=geos,
@ -506,6 +508,9 @@ class Test_ProfileIsMatch(TestCase):
self.assertFalse(is_match(profile(), profile(monitor_proto='HTTP')))
self.assertFalse(is_match(profile(), profile(endpoint_name='a')))
self.assertFalse(is_match(profile(), profile(endpoint_type='b')))
self.assertFalse(
is_match(profile(), profile(endpoint_status='Disabled'))
)
self.assertFalse(
is_match(profile(endpoint_type='b'), profile(endpoint_type='b'))
)
@ -1760,7 +1765,7 @@ class TestAzureDnsProvider(TestCase):
self.assertEqual(profiles[0].endpoints[0].endpoint_status, 'Disabled')
self.assertEqual(profiles[1].endpoints[0].endpoint_status, 'Disabled')
# # test that same record gets populated back from traffic managers
# test that same record gets populated back from traffic managers
tm_list = provider._tm_client.profiles.list_by_resource_group
tm_list.return_value = profiles
azrecord = RecordSet(
@ -1772,7 +1777,8 @@ class TestAzureDnsProvider(TestCase):
record2 = provider._populate_record(zone, azrecord)
self.assertEqual(record1.dynamic._data(), record2.dynamic._data())
# _process_desired_zone shouldn't change anything when not needed
# _process_desired_zone shouldn't change anything when status value is
# supported
zone1 = Zone(zone.name, sub_zones=[])
zone1.add_record(record1)
zone2 = provider._process_desired_zone(zone1.copy())


Loading…
Cancel
Save