Commit d87cdaba authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2380] also renamed load_iteration_limit to report_interval

as it means what it's really meant, and less confusing regarding the
previous commit.
parent d1f88a92
......@@ -110,7 +110,7 @@ class LoadZoneRunner:
self._datasrc_type = None
self._log_severity = 'INFO'
self._log_debuglevel = 0
self._load_iteration_limit = LOAD_INTERVAL_DEFAULT
self._report_interval = LOAD_INTERVAL_DEFAULT
self._config_log()
......@@ -161,11 +161,11 @@ class LoadZoneRunner:
raise BadArgument("RR class is not supported: " +
str(self._zone_class))
self._load_iteration_limit = int(options.report_interval)
if self._load_iteration_limit < 0:
self._report_interval = int(options.report_interval)
if self._report_interval < 0:
raise BadArgument(
'Invalid report interval (must be non negative): %d' %
self._load_iteration_limit)
self._report_interval)
if len(args) != 2:
raise BadArgument('Unexpected number of arguments: %d (must be 2)'
......@@ -228,17 +228,16 @@ class LoadZoneRunner:
loader = ZoneLoader(datasrc_client, self._zone_name,
self._zone_file)
self.__start_time = time.time()
if self._load_iteration_limit > 0:
limit = self._load_iteration_limit
if self._report_interval > 0:
limit = self._report_interval
else:
# configured limit value of 0 has a special meaning of
# "no report". but we still do it incrementally so we won't
# delay catching signals too long.
# Even if progress report is suppressed, we still load
# incrementally so we won't delay catching signals too long.
limit = LOAD_INTERVAL_DEFAULT
while (not self.__interrupted and
not loader.load_incremental(limit)):
self.__loaded_rrs += self._load_iteration_limit
if self._load_iteration_limit > 0:
self.__loaded_rrs += self._report_interval
if self._report_interval > 0:
self._report_progress(self.__loaded_rrs)
if self.__interrupted:
raise LoadFailure('loading interrupted by signal')
......
......@@ -67,7 +67,7 @@ class TestLoadZoneRunner(unittest.TestCase):
self.assertIsNone(self.__runner._zone_file)
self.assertIsNone(self.__runner._datasrc_config)
self.assertIsNone(self.__runner._datasrc_type)
self.assertEqual(10000, self.__runner._load_iteration_limit)
self.assertEqual(10000, self.__runner._report_interval)
self.assertEqual('INFO', self.__runner._log_severity)
self.assertEqual(0, self.__runner._log_debuglevel)
......@@ -77,7 +77,7 @@ class TestLoadZoneRunner(unittest.TestCase):
self.assertEqual(NEW_ZONE_TXT_FILE, self.__runner._zone_file)
self.assertEqual(DATASRC_CONFIG, self.__runner._datasrc_config)
self.assertEqual('sqlite3', self.__runner._datasrc_type) # default
self.assertEqual(10000, self.__runner._load_iteration_limit) # default
self.assertEqual(10000, self.__runner._report_interval) # default
self.assertEqual(RRClass.IN(), self.__runner._zone_class) # default
self.assertEqual('INFO', self.__runner._log_severity) # default
self.assertEqual(0, self.__runner._log_debuglevel)
......@@ -132,7 +132,7 @@ class TestLoadZoneRunner(unittest.TestCase):
self.__runner._zone_file = NEW_ZONE_TXT_FILE
self.__runner._datasrc_type = 'sqlite3'
self.__runner._datasrc_config = DATASRC_CONFIG
self.__runner._load_iteration_limit = 1
self.__runner._report_interval = 1
self.__reports = []
self.__runner._report_progress = lambda x: self.__reports.append(x)
......@@ -171,14 +171,14 @@ class TestLoadZoneRunner(unittest.TestCase):
def test_load_update_skipped_report(self):
'''successful loading, with reports for every 2 RRs'''
self.__common_load_setup()
self.__runner._load_iteration_limit = 2
self.__runner._report_interval = 2
self.__runner._do_load()
self.assertEqual([2], self.__reports)
def test_load_update_no_report(self):
'''successful loading, without progress reports'''
self.__common_load_setup()
self.__runner._load_iteration_limit = 0
self.__runner._report_interval = 0
self.__runner._do_load()
self.assertEqual([], self.__reports) # no report
self.__check_zone_soa(NEW_SOA_TXT) # but load is completed
......
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