[checkmk-commits] crawl test: detect incomplete runs by comparing number of URLs with last run

Lars Michelsen lm at mathias-kettner.de
Mon Nov 7 21:31:02 CET 2016


Module: check_mk
Branch: master
Commit: e0dffc5089059b2cf13a4f66ff0f1af0328bc297
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e0dffc5089059b2cf13a4f66ff0f1af0328bc297

Author: Lars Michelsen <lm at mathias-kettner.de>
Date:   Mon Nov  7 21:11:23 2016 +0100

crawl test: detect incomplete runs by comparing number of URLs with last run

---

 tests/web/test_crawl.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tests/web/test_crawl.py b/tests/web/test_crawl.py
index 7d09f93..32a178f 100644
--- a/tests/web/test_crawl.py
+++ b/tests/web/test_crawl.py
@@ -313,12 +313,21 @@ class TestCrawler(object):
 
     def update_total_stats(self, finished):
         stats = self.stats.setdefault("_TOTAL_", {})
+
         stats["last_num_visited"] = len(self.visited)
         stats["last_duration"]    = time.time() - self.started
         stats["last_errors"]      = self.errors
         stats["last_finished"]    = finished
 
         if finished:
+            if stats.get("last_finished_num_visited", 0) > 0:
+                perc = float(stats["last_num_visited"]) * 100 / stats["last_finished_num_visited"]
+                if perc < 80.0:
+                    self.error("Finished and walked %d URLs, previous run walked %d URLs. That "
+                               "is %0.2f %% of the previous run. Something seems to be wrong."
+                                 % (stats["last_num_visited"], stats["last_finished_num_visited"],
+                                    perc))
+
             stats["last_finished_num_visited"] = stats["last_num_visited"]
             stats["last_finished_duration"]    = stats["last_duration"]
             stats["last_finished_errors"]      = stats["last_errors"]



More information about the checkmk-commits mailing list