This is a general question regarding bolts and pins for testing modules in a storm topology written in Java.
What is the recommended practice and guide for Unit-testing (JUnit?) Bolts and drainage devices?
For example, I could write a JUnit test for Bolt , but without a complete understanding of the structure (for example, the Bolt life cycle) and the consequences of serialization, it is easy to make the mistake of creating constructor-based non-serializable member variables. In JUnit, this test will pass, but in the topology it will not work. I fully imagine that you need to consider a lot of test points (for example, this example with serialization and a life cycle).
Therefore, is it recommended that you use unit tests based on JUnit, do you run a small topology topology ( LocalMode ?) And check the implied contract for Bolt (or Spout ) in this topology? Or, is it okay to use JUnit, but does it mean that we have to simulate the Bolt life cycle (creating it, calling prepare() , mocking Config , etc.)? In this case, what common test points for the tested class (Bolt / Spout) should be considered?
What have other developers done to create the right unit tests?
I noticed that there is a topology testing API (see https://github.com/xumingming/storm-lib/blob/master/src/jvm/storm/TestingApiDemo.java ). Is it better to use any of these APIs and get “test topologies” for each individual Bolt and Spout (and check the implicit contract that Bolt should provide, for example, announced outputs)?
thank
unit-testing junit apache-storm
Jack May 14 '13 at 17:26 2013-05-14 17:26
source share