storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject [06/47] storm git commit: Provide a method to override default test timeout
Date Wed, 12 Nov 2014 16:45:07 GMT
Provide a method to override default test timeout

* System Property: STORM_TEST_TIMEOUT_MS
* If it doesn't exist, it uses default value (currently 5000)


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/00d90510
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/00d90510
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/00d90510

Branch: refs/heads/security
Commit: 00d905103c73e485e4c898163bd9a9a1755ff6be
Parents: c6aabd4
Author: Jungtaek Lim <kabhwan@gmail.com>
Authored: Fri Oct 3 09:35:53 2014 +0900
Committer: Jungtaek Lim <kabhwan@gmail.com>
Committed: Fri Oct 3 09:35:53 2014 +0900

----------------------------------------------------------------------
 storm-core/src/clj/backtype/storm/testing.clj       | 12 +++++++-----
 storm-core/test/clj/backtype/storm/metrics_test.clj |  2 +-
 2 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/00d90510/storm-core/src/clj/backtype/storm/testing.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/testing.clj b/storm-core/src/clj/backtype/storm/testing.clj
index 9b4f4bb..6da243f 100644
--- a/storm-core/src/clj/backtype/storm/testing.clj
+++ b/storm-core/src/clj/backtype/storm/testing.clj
@@ -187,7 +187,9 @@
       ;; on windows, the host process still holds lock on the logfile
       (catch Exception e (log-message (.getMessage e)))) ))
 
-(def TEST-TIMEOUT-MS 5000)
+(defn default-test-timeout-ms []
+  (let [timeout-ms (System/getProperty "STORM_TEST_TIMEOUT_MS")]
+    (if (not-nil? timeout-ms) (Long/parseLong timeout-ms) 5000)))
 
 (defmacro while-timeout [timeout-ms condition & body]
   `(let [end-time# (+ (System/currentTimeMillis) ~timeout-ms)]
@@ -198,7 +200,7 @@
 
 (defn wait-until-cluster-waiting
   "Wait until the cluster is idle. Should be used with time simulation."
-  ([cluster-map] (wait-until-cluster-waiting cluster-map TEST-TIMEOUT-MS))
+  ([cluster-map] (wait-until-cluster-waiting cluster-map (default-test-timeout-ms)))
   ([cluster-map timeout-ms]
   ;; wait until all workers, supervisors, and nimbus is waiting
   (let [supervisors @(:supervisors cluster-map)
@@ -457,7 +459,7 @@
    :storm-conf {}
    :cleanup-state true
    :topology-name nil
-   :timeout-ms TEST-TIMEOUT-MS]
+   :timeout-ms (default-test-timeout-ms)]
   ;; TODO: the idea of mocking for transactional topologies should be done an
   ;; abstraction level above... should have a complete-transactional-topology for this
   (let [{topology :topology capturer :capturer} (capture-topology topology)
@@ -583,9 +585,9 @@
 (defn tracked-wait
   "Waits until topology is idle and 'amt' more tuples have been emitted by spouts."
   ([tracked-topology]
-     (tracked-wait tracked-topology 1 TEST-TIMEOUT-MS))
+     (tracked-wait tracked-topology 1 (default-test-timeout-ms)))
   ([tracked-topology amt]
-     (tracked-wait tracked-topology amt TEST-TIMEOUT-MS))
+     (tracked-wait tracked-topology amt (default-test-timeout-ms)))
   ([tracked-topology amt timeout-ms]
       (let [target (+ amt @(:last-spout-emit tracked-topology))
             track-id (-> tracked-topology :cluster ::track-id)

http://git-wip-us.apache.org/repos/asf/storm/blob/00d90510/storm-core/test/clj/backtype/storm/metrics_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/backtype/storm/metrics_test.clj b/storm-core/test/clj/backtype/storm/metrics_test.clj
index 4356d30..a17b8f8 100644
--- a/storm-core/test/clj/backtype/storm/metrics_test.clj
+++ b/storm-core/test/clj/backtype/storm/metrics_test.clj
@@ -71,7 +71,7 @@
 (def metrics-data backtype.storm.metric.testing/buffer)
 
 (defn wait-for-atleast-N-buckets! [N comp-id metric-name cluster]
-  (while-timeout TEST-TIMEOUT-MS
+  (while-timeout (default-test-timeout-ms)
       (let [taskid->buckets (-> @metrics-data (get comp-id) (get metric-name))]
         (or
          (and (not= N 0) (nil? taskid->buckets))


Mime
View raw message