Parcourir la source

[trac930] raise StatsError including errors in the stats spec file

Naoki Kambe il y a 13 ans
Parent
commit
c6948a6df9
2 fichiers modifiés avec 8 ajouts et 4 suppressions
  1. 7 3
      src/bin/stats/stats.py.in
  2. 1 1
      src/bin/stats/tests/b10-stats_test.py

+ 7 - 3
src/bin/stats/stats.py.in

@@ -165,7 +165,8 @@ class Stats:
             boot_time=get_datetime(_BASETIME)
             )
         if errors:
-            raise StatsError("stats spec file is incorrect")
+            raise StatsError("stats spec file is incorrect: "
+                             + ", ".join(errors))
 
         while self.running:
             self.mccs.check_command(False)
@@ -293,7 +294,9 @@ class Stats:
             timestamp=get_timestamp(),
             report_time=get_datetime()
             )
-        if errors: raise StatsError("stats spec file is incorrect")
+        if errors:
+            raise StatsError("stats spec file is incorrect: "
+                             + ", ".join(errors))
         ret = self.get_statistics_data(owner, name)
         if ret is not None:
             return isc.config.create_answer(0, ret)
@@ -352,7 +355,8 @@ class Stats:
         errors = self.update_statistics_data(
             self.module_name, last_update_time=get_datetime() )
         if errors:
-            raise StatsError("stats spec file is incorrect")
+            raise StatsError("stats spec file is incorrect: "
+                             + ", ".join(errors))
         return isc.config.create_answer(0)
 
 if __name__ == "__main__":

+ 1 - 1
src/bin/stats/tests/b10-stats_test.py

@@ -191,7 +191,7 @@ class TestStats(unittest.TestCase):
 
     def test_start_with_err(self):
         statsd = stats.Stats()
-        statsd.update_statistics_data = lambda x,**y: [1]
+        statsd.update_statistics_data = lambda x,**y: ['an error']
         self.assertRaises(stats.StatsError, statsd.start)
 
     def test_config_handler(self):