'''
def __init__(self, command_args):
self.__command_args = command_args
- self.__loaded_rrs = 0
self.__interrupted = False # will be set to True on receiving signal
# system-wide log configuration. We need to configure logging this
[{"output": "stderr",
"destination": "console"}]}]}
- # These are essentially private, and defined as "protected" for the
+ # These are essentially private, but defined as "protected" for the
# convenience of tests inspecting them
+ self._loaded_rrs = 0
self._zone_class = None
self._zone_name = None
self._zone_file = None
limit = LOAD_INTERVAL_DEFAULT
while (not self.__interrupted and
not loader.load_incremental(limit)):
- self.__loaded_rrs += self._report_interval
+ self._loaded_rrs += self._report_interval
if self._report_interval > 0:
- self._report_progress(self.__loaded_rrs)
+ self._report_progress(self._loaded_rrs)
if self.__interrupted:
raise LoadFailure('loading interrupted by signal')
# On successful completion, add final '\n' to the progress
# report output (on failure don't bother to make it prettier).
if (self._report_interval > 0 and
- self.__loaded_rrs >= self._report_interval):
+ self._loaded_rrs >= self._report_interval):
sys.stdout.write('\n')
+ # record the final count of the loaded RRs for logging
+ self._loaded_rrs = loader.get_rr_count()
except Exception as ex:
# release any remaining lock held in the loader
loader = None
self._parse_args()
self._do_load()
total_elapsed_txt = "%.2f" % (time.time() - self.__start_time)
- logger.info(LOADZONE_DONE, self.__loaded_rrs, self._zone_name,
+ logger.info(LOADZONE_DONE, self._loaded_rrs, self._zone_name,
self._zone_class, total_elapsed_txt)
return 0
except BadArgument as ex:
failed. The newly created zone has been removed from the data source,
so that the data source will go back to the original state.
-% LOADZONE_DONE Loaded (at least) %1 RRs into zone %2/%3 in %4 seconds
+% LOADZONE_DONE Loaded %1 RRs into zone %2/%3 in %4 seconds
b10-loadzone has successfully loaded the specified zone. If there was
an old version of the zone in the data source, it is now deleted.
-It also prints (a lower bound of) the number of RRs that have been loaded
-and the time spent for the loading. Due to a limitation of the
-current implementation of the underlying library however, it cannot show the
-exact number of the loaded RRs; it's counted for every N-th RR where N
-is the value of the -i command line option. So, for smaller zones that
-don't even contain N RRs, the reported value will be 0. This will be
-improved in a future version.
+It also prints the number of RRs that have been loaded
+and the time spent for the loading.
% LOADZONE_LOAD_ERROR Failed to load zone %1/%2: %3
Loading a zone by b10-loadzone fails for some reason in the middle of
# be 3 RRs
self.assertEqual([1, 2, 3], self.__reports)
self.__check_zone_soa(NEW_SOA_TXT)
+ self.assertEqual(3, self.__runner._loaded_rrs)
def test_load_update_skipped_report(self):
'''successful loading, with reports for every 2 RRs'''
self.__runner._report_interval = 2
self.__runner._do_load()
self.assertEqual([2], self.__reports)
+ # total RRs should still be set the actual value
+ self.assertEqual(3, self.__runner._loaded_rrs)
def test_load_update_no_report(self):
'''successful loading, without progress reports'''
self.__runner._do_load()
self.assertEqual([], self.__reports) # no report
self.__check_zone_soa(NEW_SOA_TXT) # but load is completed
+ self.assertEqual(3, self.__runner._loaded_rrs)
def test_create_and_load(self):
'''successful case to loading contents to a new zone (created).'''