From e299ceced245af72b6195954556022be42813478 Mon Sep 17 00:00:00 2001 From: Sachi King Date: Thu, 23 Jun 2022 18:40:01 +1000 Subject: [PATCH] Prepare tests with failing "managed subzone" error The is not a zone between delegated.subzone.unit.tests. and unit.tests., however we get a delegated subzone error. This modifies the tests to succeed with the added record, however the tests fail as it incorrectly throws the managed subzone error. Change the name of delegated.subzone, and the tests will pass cleanly. --- tests/config/simple.yaml | 5 +++++ tests/config/sub.txt.unit.tests.yaml | 1 + tests/config/unit.tests.yaml | 5 +++++ tests/test_octodns_manager.py | 14 +++++++------- tests/test_octodns_provider_yaml.py | 9 +++++---- 5 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 tests/config/sub.txt.unit.tests.yaml diff --git a/tests/config/simple.yaml b/tests/config/simple.yaml index fc4ad9f..4cd19c8 100644 --- a/tests/config/simple.yaml +++ b/tests/config/simple.yaml @@ -33,6 +33,11 @@ zones: targets: - dump - dump2 + sub.txt.unit.tests.: + sources: + - in + targets: + - dump empty.: sources: - in diff --git a/tests/config/sub.txt.unit.tests.yaml b/tests/config/sub.txt.unit.tests.yaml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/tests/config/sub.txt.unit.tests.yaml @@ -0,0 +1 @@ +--- diff --git a/tests/config/unit.tests.yaml b/tests/config/unit.tests.yaml index aa28ee5..b88ff82 100644 --- a/tests/config/unit.tests.yaml +++ b/tests/config/unit.tests.yaml @@ -162,6 +162,11 @@ sub: values: - 6.2.3.4. - 7.2.3.4. +sub.txt: + type: 'NS' + values: + - ns1.test. + - ns2.test. txt: ttl: 600 type: TXT diff --git a/tests/test_octodns_manager.py b/tests/test_octodns_manager.py index 1c01af9..64aab9a 100644 --- a/tests/test_octodns_manager.py +++ b/tests/test_octodns_manager.py @@ -121,12 +121,12 @@ class TestManager(TestCase): environ['YAML_TMP_DIR'] = tmpdir.dirname tc = Manager(get_config_filename('simple.yaml')) \ .sync(dry_run=False) - self.assertEqual(26, tc) + self.assertEqual(27, tc) # try with just one of the zones tc = Manager(get_config_filename('simple.yaml')) \ .sync(dry_run=False, eligible_zones=['unit.tests.']) - self.assertEqual(20, tc) + self.assertEqual(21, tc) # the subzone, with 2 targets tc = Manager(get_config_filename('simple.yaml')) \ @@ -141,18 +141,18 @@ class TestManager(TestCase): # Again with force tc = Manager(get_config_filename('simple.yaml')) \ .sync(dry_run=False, force=True) - self.assertEqual(26, tc) + self.assertEqual(27, tc) # Again with max_workers = 1 tc = Manager(get_config_filename('simple.yaml'), max_workers=1) \ .sync(dry_run=False, force=True) - self.assertEqual(26, tc) + self.assertEqual(27, tc) # Include meta tc = Manager(get_config_filename('simple.yaml'), max_workers=1, include_meta=True) \ .sync(dry_run=False, force=True) - self.assertEqual(30, tc) + self.assertEqual(32, tc) def test_eligible_sources(self): with TemporaryDirectory() as tmpdir: @@ -220,13 +220,13 @@ class TestManager(TestCase): # compare doesn't use _process_desired_zone and thus doesn't filter # out root NS records, that seems fine/desirable changes = manager.compare(['in'], ['dump'], 'unit.tests.') - self.assertEqual(21, len(changes)) + self.assertEqual(22, len(changes)) # Compound sources with varying support changes = manager.compare(['in', 'nosshfp'], ['dump'], 'unit.tests.') - self.assertEqual(20, len(changes)) + self.assertEqual(21, len(changes)) with self.assertRaises(ManagerException) as ctx: manager.compare(['nope'], ['dump'], 'unit.tests.') diff --git a/tests/test_octodns_provider_yaml.py b/tests/test_octodns_provider_yaml.py index 51e55eb..05fe90b 100644 --- a/tests/test_octodns_provider_yaml.py +++ b/tests/test_octodns_provider_yaml.py @@ -34,7 +34,7 @@ class TestYamlProvider(TestCase): # without it we see everything source.populate(zone) - self.assertEqual(23, len(zone.records)) + self.assertEqual(24, len(zone.records)) source.populate(dynamic_zone) self.assertEqual(6, len(dynamic_zone.records)) @@ -57,12 +57,12 @@ class TestYamlProvider(TestCase): # We add everything plan = target.plan(zone) - self.assertEqual(20, len([c for c in plan.changes + self.assertEqual(21, len([c for c in plan.changes if isinstance(c, Create)])) self.assertFalse(isfile(yaml_file)) # Now actually do it - self.assertEqual(20, target.apply(plan)) + self.assertEqual(21, target.apply(plan)) self.assertTrue(isfile(yaml_file)) # Dynamic plan @@ -90,7 +90,7 @@ class TestYamlProvider(TestCase): # A 2nd sync should still create everything plan = target.plan(zone) - self.assertEqual(20, len([c for c in plan.changes + self.assertEqual(21, len([c for c in plan.changes if isinstance(c, Create)])) with open(yaml_file) as fh: @@ -111,6 +111,7 @@ class TestYamlProvider(TestCase): self.assertTrue('values' in data.pop('txt')) self.assertTrue('values' in data.pop('loc')) self.assertTrue('values' in data.pop('urlfwd')) + self.assertTrue('values' in data.pop('sub.txt')) # these are stored as singular 'value' self.assertTrue('value' in data.pop('_imap._tcp')) self.assertTrue('value' in data.pop('_pop3._tcp'))