Skip to content

Commit 941ef63

Browse files
author
Nathan Marz
committed
tests for throwing failedbatchexception in finishedId
1 parent b904e96 commit 941ef63

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

test/clj/backtype/storm/drpc_test.clj

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
(:use [clojure test])
33
(:import [backtype.storm.drpc ReturnResults DRPCSpout
44
LinearDRPCTopologyBuilder])
5-
(:import [backtype.storm.coordination CoordinatedBolt$FinishedCallback])
5+
(:import [backtype.storm.coordination CoordinatedBolt$FinishedCallback FailedBatchException])
66
(:import [backtype.storm LocalDRPC LocalCluster])
77
(:import [backtype.storm.tuple Fields])
8+
(:import [backtype.storm.generated DRPCExecutionException])
89
(:use [backtype.storm bootstrap testing])
910
(:use [backtype.storm.daemon common])
1011
(:use [backtype.storm clojure])
@@ -29,7 +30,7 @@
2930
exclamation-bolt)
3031
"3" (bolt-spec {"2" :shuffle}
3132
(ReturnResults.))})]
32-
(.submitTopology cluster "test" {TOPOLOGY-DEBUG true} topology)
33+
(.submitTopology cluster "test" {} topology)
3334

3435
(is (= "aaa!!!" (.execute drpc "test" "aaa")))
3536
(is (= "b!!!" (.execute drpc "test" "b")))
@@ -55,7 +56,7 @@
5556
(.addBolt builder exclamation-bolt-drpc 3)
5657
(.submitTopology cluster
5758
"builder-test"
58-
{TOPOLOGY-DEBUG true}
59+
{}
5960
(.createLocalTopology builder drpc))
6061
(is (= "aaa!!!" (.execute drpc "test" "aaa")))
6162
(is (= "b!!!" (.execute drpc "test" "b")))
@@ -173,3 +174,31 @@
173174
(.shutdown cluster)
174175
(.shutdown drpc)
175176
))
177+
178+
(defbolt fail-finish-bolt ["request" "result"] {:prepare true}
179+
[conf context collector]
180+
(bolt
181+
(execute [tuple]
182+
(ack! collector tuple))
183+
CoordinatedBolt$FinishedCallback
184+
(finishedId [this id]
185+
(throw (FailedBatchException.))
186+
)))
187+
188+
(deftest test-drpc-fail-finish
189+
(let [drpc (LocalDRPC.)
190+
cluster (LocalCluster.)
191+
builder (LinearDRPCTopologyBuilder. "fail2")
192+
]
193+
(.addBolt builder fail-finish-bolt 3)
194+
195+
(.submitTopology cluster
196+
"fail2"
197+
{}
198+
(.createLocalTopology builder drpc))
199+
200+
(is (thrown? DRPCExecutionException (.execute drpc "fail2" "2")))
201+
202+
(.shutdown cluster)
203+
(.shutdown drpc)
204+
))

0 commit comments

Comments
 (0)