Browse Source

Merge branch 'octodns:master' into NA-limitation-fix

pull/731/head
Sham 5 years ago
committed by GitHub
parent
commit
9e085e9f4e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 79 additions and 7 deletions
  1. +2
    -1
      octodns/manager.py
  2. +12
    -3
      octodns/provider/azuredns.py
  3. +59
    -1
      tests/test_octodns_provider_azuredns.py
  4. +5
    -1
      tests/test_octodns_provider_ultra.py
  5. +1
    -1
      tests/test_octodns_source_envvar.py

+ 2
- 1
octodns/manager.py View File

@ -261,7 +261,8 @@ class Manager(object):
try:
source.populate(zone, lenient=lenient)
except TypeError as e:
if "keyword argument 'lenient'" not in text_type(e):
if ("unexpected keyword argument 'lenient'"
not in text_type(e)):
raise
self.log.warn('provider %s does not accept lenient '
'param', source.__class__.__name__)


+ 12
- 3
octodns/provider/azuredns.py View File

@ -837,8 +837,8 @@ class AzureProvider(BaseProvider):
pool['fallback'] = pool_name
if pool_name in pools:
# we've already populated the pool
continue
# we've already populated this and subsequent pools
break
# populate the pool from Weighted profile
# these should be leaf node entries with no further nesting
@ -922,6 +922,16 @@ class AzureProvider(BaseProvider):
for profile in profiles:
name = profile.name
endpoints = set()
for ep in profile.endpoints:
if not ep.target:
continue
if ep.target in endpoints:
msg = '{} contains duplicate endpoint {}'
raise AzureException(msg.format(name, ep.target))
endpoints.add(ep.target)
if name in seen_profiles:
# exit if a possible collision is detected, even though
# we've tried to ensure unique mapping
@ -1053,7 +1063,6 @@ class AzureProvider(BaseProvider):
while pool_name:
# iterate until we reach end of fallback chain
default_seen = False
pool = pools[pool_name].data
if len(pool['values']) > 1:
# create Weighted profile for multi-value pool


+ 59
- 1
tests/test_octodns_provider_azuredns.py View File

@ -999,6 +999,51 @@ class TestAzureDnsProvider(TestCase):
'Collision in Traffic Manager'
))
@patch(
'octodns.provider.azuredns.AzureProvider._generate_traffic_managers')
def test_extra_changes_non_last_fallback_contains_default(self, mock_gtm):
provider = self._get_provider()
desired = Zone(zone.name, sub_zones=[])
record = Record.new(desired, 'foo', {
'type': 'CNAME',
'ttl': 60,
'value': 'default.unit.tests.',
'dynamic': {
'pools': {
'one': {
'values': [{'value': 'one.unit.tests.'}],
'fallback': 'def',
},
'def': {
'values': [{'value': 'default.unit.tests.'}],
'fallback': 'two',
},
'two': {
'values': [{'value': 'two.unit.tests.'}],
},
},
'rules': [
{'pool': 'one'},
]
}
})
desired.add_record(record)
changes = [Create(record)]
# assert that no exception is raised
provider._extra_changes(zone, desired, changes)
# simulate duplicate endpoint and assert exception
endpoint = Endpoint(target='dup.unit.tests.')
mock_gtm.return_value = [Profile(
name='test-profile',
endpoints=[endpoint, endpoint],
)]
with self.assertRaises(AzureException) as ctx:
provider._extra_changes(zone, desired, changes)
self.assertTrue('duplicate endpoint' in text_type(ctx))
def test_extra_changes_invalid_dynamic_A(self):
provider = self._get_provider()
@ -1642,6 +1687,12 @@ class TestAzureDnsProvider(TestCase):
'value': 'default.unit.tests.',
'dynamic': {
'pools': {
'sto': {
'values': [
{'value': 'sto.unit.tests.'},
],
'fallback': 'iad',
},
'iad': {
'values': [
{'value': 'iad.unit.tests.'},
@ -1657,13 +1708,14 @@ class TestAzureDnsProvider(TestCase):
'rules': [
{'geos': ['EU'], 'pool': 'iad'},
{'geos': ['EU-GB'], 'pool': 'lhr'},
{'geos': ['EU-SE'], 'pool': 'sto'},
{'pool': 'lhr'},
],
}
})
profiles = provider._generate_traffic_managers(record)
self.assertEqual(len(profiles), 3)
self.assertEqual(len(profiles), 4)
self.assertTrue(_profile_is_match(profiles[-1], Profile(
name='foo--unit--tests',
traffic_routing_method='Geographic',
@ -1683,6 +1735,12 @@ class TestAzureDnsProvider(TestCase):
target_resource_id=profiles[1].id,
geo_mapping=['GB', 'WORLD'],
),
Endpoint(
name='rule-sto',
type=nested,
target_resource_id=profiles[2].id,
geo_mapping=['SE'],
),
],
)))


+ 5
- 1
tests/test_octodns_provider_ultra.py View File

@ -1,8 +1,11 @@
from __future__ import unicode_literals
from mock import Mock, call
from os.path import dirname, join
from requests import HTTPError
from requests_mock import ANY, mock as requests_mock
from six import text_type
from six.moves.urllib import parse
from unittest import TestCase
from json import load as json_load
@ -55,7 +58,8 @@ class TestUltraProvider(TestCase):
self.assertEquals(1, mock.call_count)
expected_payload = "grant_type=password&username=user&"\
"password=rightpass"
self.assertEquals(mock.last_request.text, expected_payload)
self.assertEquals(parse.parse_qs(mock.last_request.text),
parse.parse_qs(expected_payload))
def test_get_zones(self):
provider = _get_provider()


+ 1
- 1
tests/test_octodns_source_envvar.py View File

@ -1,6 +1,6 @@
from mock import patch
from six import text_type
from unittest import TestCase
from unittest.mock import patch
from octodns.source.envvar import EnvVarSource
from octodns.source.envvar import EnvironmentVariableNotFoundException


Loading…
Cancel
Save