use of com.hubspot.singularity.SingularityTaskCleanup in project Singularity by HubSpot.
the class SingularitySlavePlacementTest method testRackPlacementOnScaleDown.
@Test
public void testRackPlacementOnScaleDown() {
try {
configuration.setRebalanceRacksOnScaleDown(true);
// Set up 3 active racks
sms.resourceOffers(Arrays.asList(createOffer(1, 128, 1024, "slave1", "host1", Optional.of("rack1"))));
sms.resourceOffers(Arrays.asList(createOffer(1, 128, 1024, "slave2", "host2", Optional.of("rack2"))));
sms.resourceOffers(Arrays.asList(createOffer(1, 128, 1024, "slave3", "host3", Optional.of("rack3"))));
initRequest();
initFirstDeploy();
saveAndSchedule(request.toBuilder().setInstances(Optional.of(7)).setRackSensitive(Optional.of(true)));
sms.resourceOffers(Arrays.asList(createOffer(2, 256, 2048, "slave1", "host1", Optional.of("rack1"))));
sms.resourceOffers(Arrays.asList(createOffer(2, 256, 2048, "slave2", "host2", Optional.of("rack2"))));
sms.resourceOffers(Arrays.asList(createOffer(3, 384, 3072, "slave3", "host3", Optional.of("rack3"))));
Assert.assertEquals(7, taskManager.getActiveTaskIds().size());
requestResource.postRequest(request.toBuilder().setInstances(Optional.of(4)).setRackSensitive(Optional.of(true)).build(), singularityUser);
scheduler.drainPendingQueue();
Assert.assertEquals(4, taskManager.getNumCleanupTasks());
int rebalanceRackCleanups = 0;
for (SingularityTaskCleanup cleanup : taskManager.getCleanupTasks()) {
if (cleanup.getCleanupType() == TaskCleanupType.REBALANCE_RACKS) {
rebalanceRackCleanups++;
}
}
Assert.assertEquals(1, rebalanceRackCleanups);
Assert.assertEquals(1, taskManager.getPendingTaskIds().size());
} finally {
configuration.setRebalanceRacksOnScaleDown(false);
}
}
Aggregations