1

I'm new to apache storm and I was looking for methods to test a bolt without actually building the complete topology. Just wanted to avoid Mock testing. Instead I tried to call the methods of the bolt to emit the output in the OutputCollector object. But I was trying to find a method to get the data from the OutputCollector object and found no method as such. Is there any way I can simply access the values emitted in the OutputCollector object?

  • you can see example here..https://github.com/kartikbha/log-processing-by-grouping/blob/master/src/com/poc/standard/LogGenerationSpout.java – kartik Mar 11 '15 at 17:33
  • https://github.com/kartikbha/log-processing-by-grouping/tree/master/src/com/poc/standard/topology/test – kartik Mar 11 '15 at 17:35

2 Answers2

2

One approach to test bolt logic is to write FakeDataGeneratorSpout which mimic the actual source of your topology. Build Test Main Topology Builder Class which can use FakeDataGeneratorSpout for Testing purpose.

Second you can keep bolt logic in simple Java class and write junit for them then later call that tested method from actual bolts.

kartik
  • 2,097
  • 3
  • 21
  • 31
1

If you are testing only from storm perspective then

junit

would do it. But if you are trying to test from a distributed computing perspective

mrunit

testing tool should be helpful.

Raghuveer
  • 2,859
  • 7
  • 34
  • 66
  • I think mrunit is for apache hadoop testing.. its for map reduce jobs.. Anyway I was following junit framework.. But I was concerned about the collection of tuples emitted to OutputCollector object – Nishtha Rai Feb 05 '15 at 11:50
  • read [link](http://stackoverflow.com/questions/10996963/hadoop-how-does-outputcollector-work-during-mapreduce) to understand what is got in OutputCollector. I think thats not what you are looking for... – Raghuveer Feb 06 '15 at 07:59