egor-ryashin commented on a change in pull request #6349: maintenance mode for 
Historical
URL: https://github.com/apache/incubator-druid/pull/6349#discussion_r221228691
 
 

 ##########
 File path: 
server/src/test/java/org/apache/druid/server/coordinator/DruidCoordinatorBalancerTest.java
 ##########
 @@ -195,6 +201,186 @@ public void testMoveToEmptyServerBalancer()
     Assert.assertEquals(2, 
params.getCoordinatorStats().getTieredStat("movedCount", "normal"));
   }
 
+  /**
+   * Server 1 has 2 segments.
+   * Server 2 (maintenance) has 2 segments.
+   * Server 3 is empty.
+   * Maintenance has priority 7.
+   * Max segments to move is 3.
+   * 2 (of 2) segments should be moved from Server 2 and 1 (of 2) from Server 
1.
+   */
+  @Test
+  public void testMoveMaintenancePriority()
+  {
+    mockDruidServer(druidServer1, "1", "normal", 30L, 100L, 
ImmutableMap.of(segment1.getIdentifier(), segment1, segment2.getIdentifier(), 
segment2));
+    mockDruidServer(druidServer2, "2", "normal", 30L, 100L, 
ImmutableMap.of(segment3.getIdentifier(), segment3, segment4.getIdentifier(), 
segment4));
+    mockDruidServer(druidServer3, "3", "normal", 0L, 100L, 
Collections.emptyMap());
+
+    EasyMock.replay(druidServer4);
+
+    mockCoordinator(coordinator);
+
+    BalancerStrategy strategy = EasyMock.createMock(BalancerStrategy.class);
+    EasyMock.expect(strategy.pickSegmentToMove(ImmutableList.of(new 
ServerHolder(druidServer2, peon2, false))))
+            .andReturn(new BalancerSegmentHolder(druidServer2, segment3))
+            .andReturn(new BalancerSegmentHolder(druidServer2, segment4));
+    EasyMock.expect(strategy.pickSegmentToMove(anyObject()))
+            .andReturn(new BalancerSegmentHolder(druidServer1, segment1))
+            .andReturn(new BalancerSegmentHolder(druidServer1, segment2));
+
+    EasyMock.expect(strategy.findNewSegmentHomeBalancer(anyObject(), 
anyObject())).andReturn(new ServerHolder(druidServer3, peon3)).anyTimes();
+    replay(strategy);
+
+    DruidCoordinatorRuntimeParams params = defaultRuntimeParamsBuilder(
+        ImmutableList.of(druidServer1, druidServer2, druidServer3),
+        ImmutableList.of(peon1, peon2, peon3),
+        ImmutableList.of(false, true, false)
+    )
+        .withDynamicConfigs(
+            CoordinatorDynamicConfig.builder()
 
 Review comment:
   :white_check_mark:

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to