summaryrefslogtreecommitdiff
path: root/designate/tests/test_manage/test_update_pool.py
diff options
context:
space:
mode:
authorJorge Niedbalski <jorge.niedbalski@canonical.com>2020-05-28 14:57:49 -0400
committerNicolas Bock <nicolas.bock@canonical.com>2021-04-23 13:31:08 -0600
commit0b5634643b4b69cd0a7d5499f258602604741d22 (patch)
treeb713bf09655041ebaec882711746786bcaf6fdb8 /designate/tests/test_manage/test_update_pool.py
parentacc82755f1e8df8bb8f0ab7b4524f691637a312e (diff)
downloaddesignate-0b5634643b4b69cd0a7d5499f258602604741d22.tar.gz
Update zones masters using pool target masters.stein-eolstable/stein
This change enforces the update of the zone masters for all zones that belongs to a particular pool, using the pool's defined target(s) masters and forcing a update_zone call. This change also, moves the backend base class update_zone method as an abstract method, allowing to each backend implementation to create its own update logic. For the case of bind9 its extended to allow running a rndc modzone with the new given masters for the zone fixing the behavior exposed on LP: #1879798. Fixes-Bug: #1879798 Change-Id: I9dddd4130a0cbb29311eeb52e077e216c8c03f3a Signed-off-by: Jorge Niedbalski <jorge.niedbalski@canonical.com> Signed-off-by: Nicolas Bock <nicolas.bock@canonical.com> (cherry picked from commit 3756fc51e71aaf0ba7cfb9155ca5d1de26ab78bc)
Diffstat (limited to 'designate/tests/test_manage/test_update_pool.py')
-rw-r--r--designate/tests/test_manage/test_update_pool.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/designate/tests/test_manage/test_update_pool.py b/designate/tests/test_manage/test_update_pool.py
new file mode 100644
index 00000000..d5b21fbc
--- /dev/null
+++ b/designate/tests/test_manage/test_update_pool.py
@@ -0,0 +1,65 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+from oslo_log import log as logging
+
+import mock
+from designate.tests.test_manage import DesignateManageTestCase
+from designate.manage.pool import PoolCommands
+from designate.tests import fixtures
+from designate import objects
+
+LOG = logging.getLogger(__name__)
+
+
+class UpdatePoolTestCase(DesignateManageTestCase):
+ def setUp(self):
+ super(DesignateManageTestCase, self).setUp()
+ self.stdlog = fixtures.StandardLogging()
+ self.useFixture(self.stdlog)
+
+ def hydrate_pool_targets(self, targets):
+ pool_targets = objects.PoolTargetList()
+ masters = objects.PoolTargetMasterList()
+ for target in targets:
+ masters.append(target)
+ target = objects.PoolTarget(masters=masters)
+ target.masters = masters
+ pool_targets.append(target)
+ return pool_targets
+
+ def test_update_pools_zones(self):
+ values = dict(
+ name='example.com.',
+ email='info@example.com',
+ type='PRIMARY'
+ )
+
+ zone = self.central_service.create_zone(
+ self.admin_context, zone=objects.Zone.from_dict(values))
+
+ # Ensure the correct NS Records are in place
+ pool = self.central_service.get_pool(
+ self.admin_context, zone.pool_id)
+
+ pool.targets = self.hydrate_pool_targets([objects.PoolTargetMaster(
+ pool_target_id=pool.id,
+ host="127.0.0.1",
+ port="53")])
+
+ command = PoolCommands()
+ command.context = self.admin_context
+ command.central_api = self.central_service
+
+ with mock.patch.object(self.central_service,
+ "update_zone") as mock_update_zone:
+ command._update_zones(pool)
+ mock_update_zone.assert_called_once()