Commit ebfebb1b authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[1414] apply suggested patch with one makefile fix

Patch introduces use of SPECFILE_LOCATION in the tests, which only gets the correct value within the source tree if B10_FROM_BUILD is set when calling the test
parent 936855eb
......@@ -20,6 +20,7 @@ endif
for pytest in $(PYTESTS) ; do \
echo Running test: $$pytest ; \
$(LIBRARY_PATH_PLACEHOLDER) \
B10_FROM_BUILD=$(abs_top_builddir) \
PYTHONPATH=$(COMMON_PYTHON_PATH):$(abs_top_builddir)/src/bin/zonemgr:$(abs_top_builddir)/src/lib/dns/python/.libs:$(abs_top_builddir)/src/lib/xfr/.libs \
$(PYCOVERAGE_RUN) $(abs_srcdir)/$$pytest || exit ; \
done
......@@ -48,46 +48,16 @@ class MySession():
def group_recvmsg(self, nonblock, seq):
return None, None
class FakeConfig:
class FakeCCSession(isc.config.ConfigData):
def __init__(self):
self.zone_list = []
self.set_zone_list_from_name_classes([ZONE_NAME_CLASS1_IN,
ZONE_NAME_CLASS2_CH])
def set_zone_list_from_name_classes(self, zones):
self.zone_list = map(lambda nc: {"name": nc[0], "class": nc[1]}, zones)
def get(self, name):
if name == 'lowerbound_refresh':
return LOWERBOUND_REFRESH
elif name == 'lowerbound_retry':
return LOWERBOUND_RETRY
elif name == 'max_transfer_timeout':
return MAX_TRANSFER_TIMEOUT
elif name == 'refresh_jitter':
return REFRESH_JITTER
elif name == 'reload_jitter':
return RELOAD_JITTER
elif name == 'secondary_zones':
return self.zone_list
else:
raise ValueError('Uknown config option')
class FakeCCSession:
def __init__(self):
self.config = FakeConfig()
def get_full_config(self):
return {'lowerbound_refresh': LOWERBOUND_REFRESH,
'lowerbound_retry': LOWERBOUND_RETRY,
'max_transfer_timeout': MAX_TRANSFER_TIMEOUT,
'refresh_jitter': REFRESH_JITTER,
'reload_jitter': RELOAD_JITTER,
'secondary_zones': [] }
def get_default_value(self, identifier):
return "IN"
module_spec = isc.config.module_spec_from_file(SPECFILE_LOCATION)
ConfigData.__init__(self, module_spec)
def get_remote_config_value(self, module_name, identifier):
if module_name == "Auth" and identifier == "database_file":
return "initdb.file", False
else:
return "unknown", False
class MyZonemgrRefresh(ZonemgrRefresh):
def __init__(self):
......@@ -571,27 +541,34 @@ class TestZonemgrRefresh(unittest.TestCase):
self.assertFalse(listener.is_alive())
def test_secondary_zones(self):
def zone_list_from_name_classes(zones):
return map(lambda nc: {"name": nc[0], "class": nc[1]}, zones)
"""Test that we can modify the list of secondary zones"""
config = FakeConfig()
config.zone_list = []
config = self.cc_session.get_full_config()
config['secondary_zones'] = []
# First, remove everything
self.zone_refresh.update_config_data(config, self.cc_session)
self.assertEqual(self.zone_refresh._zonemgr_refresh_info, {})
# Put something in
config.set_zone_list_from_name_classes([ZONE_NAME_CLASS1_IN])
#config.set_zone_list_from_name_classes([ZONE_NAME_CLASS1_IN])
config['secondary_zones'] = \
zone_list_from_name_classes([ZONE_NAME_CLASS1_IN])
self.zone_refresh.update_config_data(config, self.cc_session)
self.assertTrue(("example.net.", "IN") in
self.zone_refresh._zonemgr_refresh_info)
# This one does not exist
config.set_zone_list_from_name_classes(["example.net", "CH"])
config['secondary_zones'] = \
zone_list_from_name_classes(["example.net", "CH"])
self.zone_refresh.update_config_data(config, self.cc_session)
self.assertFalse(("example.net.", "CH") in
self.zone_refresh._zonemgr_refresh_info)
self.zone_refresh._zonemgr_refresh_info)
# Simply skip loading soa for the zone, the other configs should be updated successful
self.assertFalse(("example.net.", "IN") in
self.zone_refresh._zonemgr_refresh_info)
self.zone_refresh._zonemgr_refresh_info)
# Make sure it works even when we "accidentally" forget the final dot
config.set_zone_list_from_name_classes([("example.net", "IN")])
config['secondary_zones'] = \
zone_list_from_name_classes([("example.net", "IN")])
self.zone_refresh.update_config_data(config, self.cc_session)
self.assertTrue(("example.net.", "IN") in
self.zone_refresh._zonemgr_refresh_info)
......@@ -599,18 +576,6 @@ class TestZonemgrRefresh(unittest.TestCase):
def tearDown(self):
sys.stderr= self.stderr_backup
class MyCCSession():
def __init__(self):
pass
def get_remote_config_value(self, module_name, identifier):
if module_name == "Auth" and identifier == "database_file":
return "initdb.file", False
else:
return "unknown", False
class MyZonemgr(Zonemgr):
def __init__(self):
......@@ -618,7 +583,7 @@ class MyZonemgr(Zonemgr):
self._zone_refresh = None
self._shutdown_event = threading.Event()
self._cc = MySession()
self._module_cc = MyCCSession()
self._module_cc = FakeCCSession()
self._config_data = {
"lowerbound_refresh" : 10,
"lowerbound_retry" : 5,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment