(ns backtype.storm.util-test
  (:import [backtype.storm Config])
  (:import [backtype.storm.utils Utils])
  (:import [com.netflix.curator.retry ExponentialBackoffRetry])
  (:use [backtype.storm util])
  (:use [clojure test])
)

(deftest test-new-curator-uses-exponential-backoff
  (let [expected_interval 2400
        expected_retries 10
        expected_ceiling 5000
        conf (merge (clojurify-structure (Utils/readDefaultConfig))
          {Config/STORM_ZOOKEEPER_RETRY_INTERVAL expected_interval
           Config/STORM_ZOOKEEPER_RETRY_TIMES expected_retries
           Config/STORM_ZOOKEEPER_RETRY_INTERVAL_CEILING expected_ceiling})
        servers ["bogus_server"]
        arbitrary_port 42
        curator (Utils/newCurator conf servers arbitrary_port)
        retry (-> curator .getZookeeperClient .getRetryPolicy)
       ]
    (is (.isAssignableFrom ExponentialBackoffRetry (.getClass retry)))
    (is (= (.getBaseSleepTimeMs retry) expected_interval)) 
    (is (= (.getN retry) expected_retries)) 
    (is (= (.getMaxRetryInterval retry) expected_ceiling)) 
    ; It would be very unlikely for this to fail three times.
    (is (or
          (= (.getSleepTimeMs retry 10 0) expected_ceiling)
          (= (.getSleepTimeMs retry 10 0) expected_ceiling)
          (= (.getSleepTimeMs retry 10 0) expected_ceiling)
        ))
  )
)

(ns backtype.storm.util-test
  (:import [backtype.storm Config])
  (:import [backtype.storm.utils Utils])
  (:import [com.netflix.curator.retry ExponentialBackoffRetry])
  (:use [backtype.storm util])
  (:use [clojure test])
)

(deftest test-new-curator-uses-exponential-backoff
  (let [expected_interval 2400
        expected_retries 10
        expected_ceiling (/ expected_interval 2)
        conf (merge (clojurify-structure (Utils/readDefaultConfig))
          {Config/STORM_ZOOKEEPER_RETRY_INTERVAL expected_interval
           Config/STORM_ZOOKEEPER_RETRY_TIMES expected_retries
           Config/STORM_ZOOKEEPER_RETRY_INTERVAL_CEILING expected_ceiling})
        servers ["bogus_server"]
        arbitrary_port 42
        curator (Utils/newCurator conf servers arbitrary_port)
        retry (-> curator .getZookeeperClient .getRetryPolicy)
       ]
    (is (.isAssignableFrom ExponentialBackoffRetry (.getClass retry)))
    (is (= (.getBaseSleepTimeMs retry) expected_interval)) 
    (is (= (.getN retry) expected_retries)) 
    (is (= (.getMaxRetryInterval retry) expected_ceiling)) 
    (is (= (.getSleepTimeMs retry 10 0) expected_ceiling))
  )
)

Change ceiling test to be deterministic
Change ceiling test to be deterministic

rahulkavale/storm,taoguan/storm-1,carl34/storm,erikdw/storm,0x726d77/storm,kamleshbhatt/storm,0x726d77/storm,erikdw/storm,kamleshbhatt/storm,3manuek/storm-1,srdo/storm,rahulkavale/storm,mesosphere/storm,ferrero-zhang/storm,kamleshbhatt/storm,revans2/storm,metamx/incubator-storm,cluo512/storm,ujfjhz/storm,nathanmarz/storm,kishorvpatil/incubator-storm,cherryleer/storm,cluo512/storm,adityasharad/storm,d2r/storm-marz,ujfjhz/storm,srdo/storm,raviperi/storm,elancom/storm,mesosphere/storm,ujfjhz/storm,elancom/storm,kishorvpatil/incubator-storm,kevpeek/storm,konfer/storm,jamesmarva/storm,allenjin/storm,adityasharad/storm,ferrero-zhang/storm,carl34/storm,hmcl/storm-apache,gongsm/storm,Crim/storm,roshannaik/storm,taoguan/storm-1,erikdw/storm,lcp0578/storm,revans2/incubator-storm,revans2/incubator-storm,roshannaik/storm,kevinconaway/storm,srishtyagrawal/storm,ujfjhz/storm,cluo512/storm,roshannaik/storm,ferrero-zhang/storm,knusbaum/incubator-storm,lcp0578/storm,carl34/storm,jamesmarva/storm,adityasharad/storm,raviperi/storm,sakanaou/storm,knusbaum/incubator-storm,hilfialkaff/storm,3manuek/storm-1,kevpeek/storm,cherryleer/storm,revans2/incubator-storm,gongsm/storm,kevpeek/storm,rahulkavale/storm,praisondani/storm,knusbaum/incubator-storm,F30/storm,konfer/storm,revans2/storm,raviperi/storm,Crim/storm,roshannaik/storm,srishtyagrawal/storm,srishtyagrawal/storm,kishorvpatil/incubator-storm,hmcc/storm,pczb/storm,3manuek/storm-1,sakanaou/storm,kishorvpatil/incubator-storm,F30/storm,erikdw/storm,chrismoulton/storm,erikdw/storm,Aloomaio/incubator-storm,F30/storm,kevpeek/storm,taoguan/storm-1,carl34/storm,Crim/storm,kevpeek/storm,mesosphere/storm,revans2/storm,kamleshbhatt/storm,revans2/incubator-storm,nathanmarz/storm,raviperi/storm,metamx/incubator-storm,Aloomaio/incubator-storm,F30/storm,jamesmarva/storm,Crim/storm,metamx/incubator-storm,hilfialkaff/storm,pczb/storm,kevpeek/storm,Aloomaio/incubator-storm,cherryleer/storm,roshannaik/storm,Crim/storm,elancom/storm,3manuek/storm-1,d2r/storm-marz,nathanmarz/storm,d2r/storm-marz,kevinconaway/storm,rahulkavale/storm,srishtyagrawal/storm,sakanaou/storm,d2r/storm-marz,chrismoulton/storm,raviperi/storm,kevpeek/storm,sakanaou/storm,3manuek/storm-1,nathanmarz/storm,Crim/storm,allenjin/storm,lcp0578/storm,cluo512/storm,ujfjhz/storm,0x726d77/storm,ujfjhz/storm,taoguan/storm-1,adityasharad/storm,elancom/storm,pczb/storm,adityasharad/storm,revans2/storm,metamx/incubator-storm,metamx/incubator-storm,gongsm/storm,carl34/storm,praisondani/storm,praisondani/storm,roshannaik/storm,hmcc/storm,taoguan/storm-1,0x726d77/storm,allenjin/storm,0x726d77/storm,nathanmarz/storm,hmcl/storm-apache,cluo512/storm,hmcc/storm,hmcl/storm-apache,srdo/storm,konfer/storm,kamleshbhatt/storm,srdo/storm,Aloomaio/incubator-storm,ferrero-zhang/storm,F30/storm,cluo512/storm,Aloomaio/incubator-storm,kishorvpatil/incubator-storm,erikdw/storm,raviperi/storm,elancom/storm,revans2/storm,srishtyagrawal/storm,cluo512/storm,hilfialkaff/storm,chrismoulton/storm,konfer/storm,carl34/storm,ferrero-zhang/storm,mesosphere/storm,mesosphere/storm,lcp0578/storm,jamesmarva/storm,hmcc/storm,Aloomaio/incubator-storm,hmcc/storm,adityasharad/storm,kishorvpatil/incubator-storm,chrismoulton/storm,kishorvpatil/incubator-storm,kamleshbhatt/storm,hmcl/storm-apache,hilfialkaff/storm,Aloomaio/incubator-storm,d2r/storm-marz,hmcc/storm,hmcl/storm-apache,praisondani/storm,lcp0578/storm,adityasharad/storm,kevinconaway/storm,0x726d77/storm,allenjin/storm,srdo/storm,kevinconaway/storm,cherryleer/storm,kevinconaway/storm,pczb/storm,srdo/storm,knusbaum/incubator-storm,F30/storm,knusbaum/incubator-storm,raviperi/storm,cherryleer/storm,srishtyagrawal/storm,jamesmarva/storm,gongsm/storm,gongsm/storm,hmcl/storm-apache,mesosphere/storm,konfer/storm,revans2/incubator-storm,kevinconaway/storm,roshannaik/storm,Crim/storm,praisondani/storm,hilfialkaff/storm,sakanaou/storm,hmcc/storm,rahulkavale/storm,hmcl/storm-apache,carl34/storm,kevinconaway/storm,erikdw/storm,pczb/storm,kamleshbhatt/storm,sakanaou/storm,pczb/storm,srdo/storm,srishtyagrawal/storm,knusbaum/incubator-storm,sakanaou/storm,ujfjhz/storm,allenjin/storm,chrismoulton/storm,pczb/storm,0x726d77/storm,knusbaum/incubator-storm,F30/storm