Commit 5cea4cfb authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[1372] covered a bit unusual case: get_journal_reader() fails with

NO_SUCH_ZONE.
parent 1af57091
......@@ -123,7 +123,8 @@ class MockDataSrcClient:
soa_rrset = self.__create_soa()
soa_rrset.add_rdata(soa_rrset.get_rdata()[0])
return (ZoneFinder.SUCCESS, soa_rrset)
raise ValueError('Unexpected input to mock finder: bug in test case?')
else:
return (ZoneFinder.SUCCESS, self.__create_soa())
def get_iterator(self, zone_name, adjust_ttl=False):
if zone_name == Name('notauth.example.com'):
......@@ -140,8 +141,10 @@ class MockDataSrcClient:
return soa_rrset
def get_journal_reader(self, zone_name, begin_serial, end_serial):
if zone_name == Name('notauth2.example.com'):
return isc.datasrc.ZoneJournalReader.NO_SUCH_ZONE, None
if begin_serial == IXFR_NG_VERSION:
return isc.datasrc.ZoneJournalReader.NO_SUCH_VERSION, self
return isc.datasrc.ZoneJournalReader.NO_SUCH_VERSION, None
return isc.datasrc.ZoneJournalReader.SUCCESS, self
class MyCCSession(isc.config.ConfigData):
......@@ -710,6 +713,10 @@ class TestXfroutSession(TestXfroutSessionBase):
# Failure cases
self.assertEqual(self.xfrsess._xfrout_setup(
self.getmsg(), Name('notauth.example.com')), Rcode.NOTAUTH())
# this is a strange case: zone's SOA will be found but the journal
# reader won't be created due to 'no such zone'.
self.assertEqual(self.xfrsess._xfrout_setup(
self.getmsg(), Name('notauth2.example.com')), Rcode.NOTAUTH())
self.assertEqual(self.xfrsess._xfrout_setup(
self.getmsg(), Name('nosoa.example.com')), Rcode.SERVFAIL())
self.assertEqual(self.xfrsess._xfrout_setup(
......
......@@ -382,12 +382,17 @@ class XfroutSession():
if rcode != Rcode.NOERROR():
return rcode
code, self._jnl_reader = self._datasrc_client.get_journal_reader(
remote_soa.get_name(), get_soa_serial(remote_soa.get_rdata()[0]),
zone_name, get_soa_serial(remote_soa.get_rdata()[0]),
get_soa_serial(self._soa.get_rdata()[0]))
if code == ZoneJournalReader.NO_SUCH_VERSION:
# fallback to AXFR-style IXFR
self._jnl_reader = None # clear it just in case
return self.__setup_axfr(zone_name)
if code == ZoneJournalReader.NO_SUCH_ZONE:
# this is quite unexpected as we know zone's SOA exists.
# It might be a bug or the data source is somehow broken,
# but it can still happen if someone has removed the zone
# between these two operations. We treat it as NOTAUTH.
return Rcode.NOTAUTH()
return Rcode.NOERROR()
......
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