[checkmk-commits] Fixed get_graph test

Lars Michelsen lm at mathias-kettner.de
Mon Dec 5 11:52:55 CET 2016


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

Author: Lars Michelsen <lm at mathias-kettner.de>
Date:   Mon Dec  5 11:52:52 2016 +0100

Fixed get_graph test

---

 tests/testlib/__init__.py |  4 ----
 tests/web/test_webapi.py  | 16 +++++++++++++++-
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/tests/testlib/__init__.py b/tests/testlib/__init__.py
index 454c33a..2f1b5c7 100644
--- a/tests/testlib/__init__.py
+++ b/tests/testlib/__init__.py
@@ -682,10 +682,6 @@ class CMKWebSession(WebSession):
             assert response["result_code"] == 0, \
                    "An error occured: %r" % response
         else:
-            assert response["result_code"] == 1, \
-                   "No error occured, but was expected: %r" % response
-
-            print repr(response["result"])
             raise APIError(response["result"])
 
         return response["result"]
diff --git a/tests/web/test_webapi.py b/tests/web/test_webapi.py
index de03f96..ad8efe8 100644
--- a/tests/web/test_webapi.py
+++ b/tests/web/test_webapi.py
@@ -84,7 +84,21 @@ def test_get_graph(web, site):
 
         # Issue a reschedule
         site.live.command("SCHEDULE_FORCED_SERVICE_CHECK;test-host-get-graph;Check_MK;%d" % int(time.time()))
-        time.sleep(1)
+
+        # Wait for RRD file creation
+        # Isn't this a bug that the graph is not instantly available?
+        timeout = 10
+        print "Checking for graph..."
+        while timeout and not site.file_exists("var/check_mk/rrd/test-host-get-graph/Check_MK.rrd"):
+            try:
+                data = web.get_regular_graph("test-host-get-graph", "Check_MK", 0, expect_error=True)
+            except Exception:
+                pass
+            timeout -= 1
+            time.sleep(1)
+            print "Checking for graph..."
+        assert site.file_exists("var/check_mk/rrd/test-host-get-graph/Check_MK.rrd"), \
+                        "RRD %s is still missing" % "var/check_mk/rrd/test-host-get-graph/Check_MK.rrd"
 
         # Now we get a graph
         data = web.get_regular_graph("test-host-get-graph", "Check_MK", 0)



More information about the checkmk-commits mailing list