diff options
author | zhouhenglc <zhouhenglc@inspur.com> | 2019-09-26 10:19:59 +0800 |
---|---|---|
committer | Erik Olof Gunnar Andersson <eandersson@blizzard.com> | 2019-10-03 07:37:43 +0000 |
commit | 2f86440507a05fab7bebefac2c17999c3f78b945 (patch) | |
tree | e09fcdcbf8988d09a8f78fbd898a1680429f7025 | |
parent | d910d7816220113d8758ae1492bb200060c0d372 (diff) | |
download | designate-2f86440507a05fab7bebefac2c17999c3f78b945.tar.gz |
fix Secondary zone can not xfr
``DesignateObject update`` method not judged whether the value
has changed, but directly override. ``zone name`` will be marked
as changed. But central api not allow update name. zone will be
PENDING for a long time and will eventually become ERROR.
Change-Id: Id67fbb9adee7593a03475f3bbabbb15d9a9cd4bd
-rw-r--r-- | designate/mdns/xfr.py | 1 | ||||
-rw-r--r-- | designate/tests/unit/mdns/test_xfr.py | 56 |
2 files changed, 57 insertions, 0 deletions
diff --git a/designate/mdns/xfr.py b/designate/mdns/xfr.py index 11751bb0..0785e6b3 100644 --- a/designate/mdns/xfr.py +++ b/designate/mdns/xfr.py @@ -50,6 +50,7 @@ class XFRMixin(object): zone.transferred_at = timeutils.utcnow() + zone.obj_reset_changes(["name"]) self.central_api.update_zone(context, zone, increment_serial=False) finally: metrics.timing('mdns.xfr.zone_sync', time.time() - start_time) diff --git a/designate/tests/unit/mdns/test_xfr.py b/designate/tests/unit/mdns/test_xfr.py new file mode 100644 index 00000000..88cc9d52 --- /dev/null +++ b/designate/tests/unit/mdns/test_xfr.py @@ -0,0 +1,56 @@ +# Copyright 2019 Inspur +# +# Author: ZhouHeng <zhouhenglc@inspur.com> +# +# 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. +import mock +from oslo_config import cfg +from oslo_config import fixture as cfg_fixture +import oslotest.base + + +from designate import objects +from designate import dnsutils +from designate.mdns import xfr +from designate.tests import fixtures + + +CONF = cfg.CONF + + +class MdnsXFRMixinTest(oslotest.base.BaseTestCase): + def setUp(self): + super(MdnsXFRMixinTest, self).setUp() + self.stdlog = fixtures.StandardLogging() + self.useFixture(self.stdlog) + self.useFixture(cfg_fixture.Config(CONF)) + self.context = mock.Mock() + self.tg = mock.Mock() + self.xfrMixin = xfr.XFRMixin() + self.xfrMixin.central_api = mock.Mock() + + def test_zone_sync_not_change_name(self): + zone = objects.Zone(id='7592878e-4ade-40de-8b8d-699b871ee6fa', + name="example.com.", + serial=1, + masters=objects.ZoneMasterList.from_list([ + {'host': '127.0.0.1', 'port': 53}, ])) + + with mock.patch.object(dnsutils, 'do_axfr') as mock_axfr, \ + mock.patch.object(dnsutils, 'from_dnspython_zone') as mock2: + mock_axfr.return_value = mock.Mock() + mock2.return_value = zone + self.xfrMixin.zone_sync(self.context, zone) + + self.assertIn("transferred_at", zone.obj_what_changed()) + self.assertNotIn("name", zone.obj_what_changed()) |