bipinprasad commented on a change in pull request #3322:
URL: https://github.com/apache/storm/pull/3322#discussion_r480451764



##########
File path: storm-client/test/jvm/org/apache/storm/utils/UtilsTest.java
##########
@@ -237,4 +247,167 @@ public void checkVersionInfo() {
         assertNotNull(found);
         assertEquals(key, found.getVersion());
     }
+
+    @Test
+    public void testFindComponentCycles() {
+        class CycleDetectionScenario {
+            final String testName;
+            final String testDescription;
+            final StormTopology topology;
+            final int expectedCycles;
+
+            CycleDetectionScenario() {
+                testName = "dummy";
+                testDescription = "dummy test";
+                topology = null;
+                expectedCycles = 0;
+            }
+
+            CycleDetectionScenario(String testName, String testDescription, 
StormTopology topology, int expectedCycles) {
+                this.testName = testName.replace(' ', '-');
+                this.testDescription = testDescription;
+                this.topology = topology;
+                this.expectedCycles = expectedCycles;
+            }
+
+            public List<CycleDetectionScenario> createTestScenarios() {
+                List<CycleDetectionScenario> ret = new ArrayList<>();
+                int testNo = 0;
+                CycleDetectionScenario s;
+                TopologyBuilder tb;
+
+                // Base case
+                {
+                    testNo++;
+                    tb = new TopologyBuilder();
+                    tb.setSpout("spout1", new TestWordSpout(), 10);
+                    tb.setBolt("bolt1", new TestWordCounter(), 
10).shuffleGrouping("spout1");
+                    tb.setBolt("bolt2", new TestWordCounter(), 
10).shuffleGrouping("spout1");
+                    tb.setBolt("bolt11", new TestWordCounter(), 
10).shuffleGrouping("bolt1");
+                    tb.setBolt("bolt12", new TestWordCounter(), 
10).shuffleGrouping("bolt1");
+                    tb.setBolt("bolt21", new TestWordCounter(), 
10).shuffleGrouping("bolt2");
+                    tb.setBolt("bolt22", new TestWordCounter(), 
10).shuffleGrouping("bolt2");
+                    s = new CycleDetectionScenario(String.format("(%d) Base", 
testNo),
+                            "Three level component hierarchy with no loops",
+                            tb.createTopology(),
+                            0);
+                    ret.add(s);
+                }
+
+                // single loop with one bolt
+                {
+                    testNo++;
+                    tb = new TopologyBuilder();
+                    tb.setSpout("spout1", new TestWordSpout(), 10);
+                    tb.setBolt("bolt1", new TestWordCounter(), 
10).shuffleGrouping("spout1");
+                    tb.setBolt("bolt2", new TestWordCounter(), 
10).shuffleGrouping("spout1");
+                    tb.setBolt("bolt11", new TestWordCounter(), 
10).shuffleGrouping("bolt1");
+                    tb.setBolt("bolt12", new TestWordCounter(), 
10).shuffleGrouping("bolt1");
+                    tb.setBolt("bolt21", new TestWordCounter(), 
10).shuffleGrouping("bolt2");
+                    tb.setBolt("bolt22", new TestWordCounter(), 
10).shuffleGrouping("bolt2");
+                    // loop bolt 3  (also connect bolt3 to spout 1)
+                    tb.setBolt("bolt3", new TestWordCounter(), 
10).shuffleGrouping("spout1").shuffleGrouping("bolt3");
+                    ret.add(new CycleDetectionScenario(String.format("(%d) One 
Loop", testNo),
+                            "Four level component hierarchy with 1 cycle in 
bolt3",

Review comment:
       Yes. Fixed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to