HeartSaVioR commented on a change in pull request #2961: STORM-3344 prevent 
blacklist scheduler runtime exeception removing fr…
URL: https://github.com/apache/storm/pull/2961#discussion_r264458651
 
 

 ##########
 File path: 
storm-server/src/test/java/org/apache/storm/scheduler/blacklist/TestBlacklistScheduler.java
 ##########
 @@ -329,11 +329,51 @@ public void removeLongTimeDisappearFromCache(){
         Assert.assertEquals(cached, bs.cachedSupervisors.keySet());
         cluster = new Cluster(iNimbus, resourceMetrics, supMap, new 
HashMap<String, SchedulerAssignmentImpl>(), topologies, config);
         bs.schedule(topologies,cluster);
-        cluster = new Cluster(iNimbus, resourceMetrics, 
TestUtilsForBlacklistScheduler.removePortFromSupervisors(supMap,"sup-0",0),TestUtilsForBlacklistScheduler.assignmentMapToImpl(cluster.getAssignments()),
 topologies, config);
+        cluster = new Cluster(iNimbus, resourceMetrics, 
TestUtilsForBlacklistScheduler.modifyPortFromSupervisors(supMap,"sup-0",0, 
false),TestUtilsForBlacklistScheduler.assignmentMapToImpl(cluster.getAssignments()),
 topologies, config);
         for (int i = 0 ;i < 20 ; i++){
             bs.schedule(topologies, cluster);
         }
         Set<Integer> cachedPorts = Sets.newHashSet(1, 2, 3);
         Assert.assertEquals(cachedPorts, bs.cachedSupervisors.get("sup-0"));
     }
+
+    @Test
+    public void blacklistSupervisorWithAddedPort() {
+        Config config = new Config();
+        config.putAll(Utils.readDefaultConfig());
+        config.put(DaemonConfig.BLACKLIST_SCHEDULER_TOLERANCE_TIME,10);
+        config.put(DaemonConfig.BLACKLIST_SCHEDULER_TOLERANCE_COUNT,2);
+        config.put(DaemonConfig.BLACKLIST_SCHEDULER_RESUME_TIME,300);
+
+        StormMetricsRegistry metricsRegistry = new StormMetricsRegistry();
+        scheduler = new BlacklistScheduler(new DefaultScheduler(), 
metricsRegistry);
+        scheduler.prepare(config);
+
+        Map<String, TopologyDetails> topoMap = new HashMap<>();
+        TopologyDetails topo1 = 
TestUtilsForBlacklistScheduler.getTopology("topo-1", config, 5,
+                15, 1, 1, currentTime - 2,true);
+        topoMap.put(topo1.getId(), topo1);
+        Topologies topologies = new Topologies(topoMap);
+
+        INimbus iNimbus = new TestUtilsForBlacklistScheduler.INimbusTest();
+        ResourceMetrics resourceMetrics = new ResourceMetrics(metricsRegistry);
+        Map<String, SupervisorDetails> supMap = 
TestUtilsForBlacklistScheduler.genSupervisors(3,4);
+        Cluster cluster = new Cluster(iNimbus, resourceMetrics, supMap, new 
HashMap<String, SchedulerAssignmentImpl>(),
+                topologies, config);
+
+        // allow blacklist scheduler to cache the supervisor
+        scheduler.schedule(topologies, cluster);
+        cluster = new Cluster(iNimbus, resourceMetrics, 
TestUtilsForBlacklistScheduler.modifyPortFromSupervisors(supMap,
 
 Review comment:
   nit: space after each `,`

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to