Browse Source

Testing for manager's use of list_zones for dynamically configured zones

pull/1026/head
Ross McFarland 2 years ago
parent
commit
4b4b907584
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
4 changed files with 75 additions and 1 deletions
  1. +1
    -1
      octodns/manager.py
  2. +21
    -0
      tests/config/dynamic-config-no-list-zones.yaml
  3. +21
    -0
      tests/config/dynamic-config.yaml
  4. +32
    -0
      tests/test_octodns_manager.py

+ 1
- 1
octodns/manager.py View File

@ -528,7 +528,7 @@ class Manager(object):
for source in sources:
if not hasattr(source, 'list_zones'):
raise ManagerException(
f'dynamic zone={name} includes a source that does not support `list_zones`',
f'dynamic zone={name} includes a source that does not support `list_zones`'
)
for zone_name in source.list_zones():
if zone_name in zones:


+ 21
- 0
tests/config/dynamic-config-no-list-zones.yaml View File

@ -0,0 +1,21 @@
providers:
in:
# does not support list_zones
class: helpers.SimpleProvider
dump:
class: octodns.provider.yaml.YamlProvider
directory: env/YAML_TMP_DIR
zones:
'*':
sources:
- in
targets:
- dump
subzone.unit.tests.:
sources:
- in
targets:
- dump

+ 21
- 0
tests/config/dynamic-config.yaml View File

@ -0,0 +1,21 @@
providers:
in:
class: octodns.provider.yaml.YamlProvider
directory: tests/config
dump:
class: octodns.provider.yaml.YamlProvider
directory: env/YAML_TMP_DIR
zones:
'*':
sources:
- in
targets:
- dump
subzone.unit.tests.:
sources:
- in
targets:
- dump

+ 32
- 0
tests/test_octodns_manager.py View File

@ -961,6 +961,38 @@ class TestManager(TestCase):
tc = manager.sync(dry_run=False)
self.assertEqual(26, tc)
def test_dynamic_config(self):
with TemporaryDirectory() as tmpdir:
environ['YAML_TMP_DIR'] = tmpdir.dirname
manager = Manager(get_config_filename('dynamic-config.yaml'))
# just unit.tests. which should have been dynamically configured via
# list_zones
self.assertEqual(
23, manager.sync(eligible_zones=['unit.tests.'], dry_run=False)
)
# just subzone.unit.tests. which was explicitly configured
self.assertEqual(
3,
manager.sync(
eligible_zones=['subzone.unit.tests.'], dry_run=False
),
)
# should sync everything across all zones, total of 32 records
self.assertEqual(32, manager.sync(dry_run=False))
def test_dynamic_config_unsupported_zone(self):
manager = Manager(
get_config_filename('dynamic-config-no-list-zones.yaml')
)
with self.assertRaises(ManagerException) as ctx:
manager.sync()
self.assertTrue('does not support `list_zones`' in str(ctx.exception))
class TestMainThreadExecutor(TestCase):
def test_success(self):


Loading…
Cancel
Save