MCPcopy Create free account
hub / github.com/apache/storm / TestingTest

Class TestingTest

storm-server/src/test/java/org/apache/storm/TestingTest.java:37–124  ·  view source on GitHub ↗

Test that the testing class does what it should do.

Source from the content-addressed store, hash-verified

35 * Test that the testing class does what it should do.
36 */
37@IntegrationTest
38public class TestingTest {
39
40 private static final TestJob COMPLETE_TOPOLOGY_TESTJOB = (cluster) -> {
41 TopologyBuilder tb = new TopologyBuilder();
42 tb.setSpout("spout", new TestWordSpout(true), 3);
43 tb.setBolt("2", new TestWordCounter(), 4)
44 .fieldsGrouping("spout", new Fields("word"));
45 tb.setBolt("3", new TestGlobalCount())
46 .globalGrouping("spout");
47 tb.setBolt("4", new TestAggregatesCounter())
48 .globalGrouping("2");
49
50 MockedSources mocked = new MockedSources();
51 mocked.addMockData("spout",
52 new Values("nathan"),
53 new Values("bob"),
54 new Values("joey"),
55 new Values("nathan"));
56
57 Config topoConf = new Config();
58 topoConf.setNumWorkers(2);
59
60 CompleteTopologyParam ctp = new CompleteTopologyParam();
61 ctp.setMockedSources(mocked);
62 ctp.setStormConf(topoConf);
63
64 Map<String, List<FixedTuple>> results = Testing.completeTopology(cluster, tb.createTopology(), ctp);
65 List<List<Object>> spoutTuples = Testing.readTuples(results, "spout");
66 List<List<Object>> expectedSpoutTuples = Arrays.asList(Arrays.asList("nathan"), Arrays.asList("bob"), Arrays.asList("joey"),
67 Arrays.asList("nathan"));
68 assertTrue(Testing.multiseteq(expectedSpoutTuples, spoutTuples), expectedSpoutTuples + " expected, but found " + spoutTuples);
69
70 List<List<Object>> twoTuples = Testing.readTuples(results, "2");
71 List<List<Object>> expectedTwoTuples = Arrays.asList(Arrays.asList("nathan", 1), Arrays.asList("nathan", 2),
72 Arrays.asList("bob", 1), Arrays.asList("joey", 1));
73 assertTrue(Testing.multiseteq(expectedTwoTuples, twoTuples), expectedTwoTuples + " expected, but found " + twoTuples);
74
75 List<List<Object>> threeTuples = Testing.readTuples(results, "3");
76 List<List<Object>> expectedThreeTuples = Arrays.asList(Arrays.asList(1), Arrays.asList(2),
77 Arrays.asList(3), Arrays.asList(4));
78 assertTrue(Testing.multiseteq(expectedThreeTuples, threeTuples), expectedThreeTuples + " expected, but found " + threeTuples);
79
80 List<List<Object>> fourTuples = Testing.readTuples(results, "4");
81 List<List<Object>> expectedFourTuples = Arrays.asList(Arrays.asList(1), Arrays.asList(2),
82 Arrays.asList(3), Arrays.asList(4));
83 assertTrue(Testing.multiseteq(expectedFourTuples, fourTuples), expectedFourTuples + " expected, but found " + fourTuples);
84 };
85
86 @Test
87 public void testCompleteTopologyNettySimulated() throws Exception {
88 Config daemonConf = new Config();
89 daemonConf.put(Config.STORM_LOCAL_MODE_ZMQ, true);
90 MkClusterParam param = new MkClusterParam();
91 param.setSupervisors(4);
92 param.setDaemonConf(daemonConf);
93
94 Testing.withSimulatedTimeLocalCluster(param, COMPLETE_TOPOLOGY_TESTJOB);

Callers

nothing calls this directly

Calls 12

completeTopologyMethod · 0.95
readTuplesMethod · 0.95
multiseteqMethod · 0.95
addMockDataMethod · 0.80
setNumWorkersMethod · 0.80
setMockedSourcesMethod · 0.80
setStormConfMethod · 0.80
fieldsGroupingMethod · 0.65
globalGroupingMethod · 0.65
setSpoutMethod · 0.45
setBoltMethod · 0.45
createTopologyMethod · 0.45

Tested by

no test coverage detected