Skip to content

Commit

Permalink
Add test that nimbus methods use correct conf
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Dagit committed Aug 20, 2013
1 parent eb63cce commit 6da8a91
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions storm-core/test/clj/backtype/storm/nimbus_test.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns backtype.storm.nimbus-test
(:use [clojure test])
(:require [backtype.storm [util :as util]])
(:require [backtype.storm.daemon [nimbus :as nimbus]])

(:import [backtype.storm.testing TestWordCounter TestWordSpout TestGlobalCount TestAggregatesCounter])
(:import [backtype.storm.scheduler INimbus])
(:use [backtype.storm bootstrap testing])
Expand Down Expand Up @@ -892,26 +892,32 @@
(testing "getTopologyConf calls check-authorization! with the correct parameters."
(let [expected-operation "getTopologyConf"]
(stubbing [nimbus/check-authorization! nil
nimbus/try-read-storm-conf expected-conf]
nimbus/try-read-storm-conf expected-conf
util/to-json nil]
(try
(.getTopologyConf nimbus "fake-id")
(catch NotAliveException e)
(finally
(verify-first-call-args-for-indices
nimbus/check-authorization!
[1 2 3] expected-name expected-conf expected-operation))))))
nimbus/check-authorization!
[1 2 3] expected-name expected-conf expected-operation)
(verify-first-call-args-for util/to-json expected-conf))))))

(testing "getTopology calls check-authorization! with the correct parameters."
(let [expected-operation "getTopology"]
(stubbing [nimbus/check-authorization! nil
nimbus/try-read-storm-conf expected-conf]
nimbus/try-read-storm-conf expected-conf
nimbus/try-read-storm-topology nil
system-topology! nil]
(try
(.getTopology nimbus "fake-id")
(catch NotAliveException e)
(finally
(verify-first-call-args-for-indices
nimbus/check-authorization!
[1 2 3] expected-name expected-conf expected-operation))))))
nimbus/check-authorization!
[1 2 3] expected-name expected-conf expected-operation)
(verify-first-call-args-for-indices
system-topology! [0] expected-conf))))))

(testing "getUserTopology calls check-authorization with the correct parameters."
(let [expected-operation "getUserTopology"]
Expand All @@ -923,8 +929,10 @@
(catch NotAliveException e)
(finally
(verify-first-call-args-for-indices
nimbus/check-authorization!
[1 2 3] expected-name expected-conf expected-operation))))))))))
nimbus/check-authorization!
[1 2 3] expected-name expected-conf expected-operation)
(verify-first-call-args-for-indices
nimbus/try-read-storm-topology [0] expected-conf))))))))))

(deftest test-nimbus-iface-getTopology-methods-throw-correctly
(with-local-cluster [cluster]
Expand Down

0 comments on commit 6da8a91

Please sign in to comment.