use of io.druid.indexing.overlord.RemoteTaskRunner in project druid by druid-io.
the class PendingTaskBasedResourceManagementStrategyTest method testSomethingTerminating.
@Test
public void testSomethingTerminating() throws Exception {
EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(0).times(1);
EasyMock.expect(autoScaler.ipToIdLookup(EasyMock.<List<String>>anyObject())).andReturn(Lists.<String>newArrayList("ip")).times(2);
EasyMock.expect(autoScaler.terminate(EasyMock.<List<String>>anyObject())).andReturn(new AutoScalingData(Lists.<String>newArrayList("ip")));
EasyMock.replay(autoScaler);
RemoteTaskRunner runner = EasyMock.createMock(RemoteTaskRunner.class);
EasyMock.expect(runner.getWorkers()).andReturn(Arrays.asList(new TestZkWorker(testTask).toImmutable())).times(2);
EasyMock.expect(runner.getLazyWorkers()).andReturn(Lists.<Worker>newArrayList()).times(2);
EasyMock.expect(runner.markWorkersLazy((Predicate<ImmutableWorkerInfo>) EasyMock.anyObject(), EasyMock.anyInt())).andReturn(Arrays.asList(new TestZkWorker(testTask).toImmutable().getWorker()));
EasyMock.replay(runner);
boolean terminatedSomething = strategy.doTerminate(runner);
Assert.assertTrue(terminatedSomething);
Assert.assertTrue(strategy.getStats().toList().size() == 1);
Assert.assertTrue(strategy.getStats().toList().get(0).getEvent() == ScalingStats.EVENT.TERMINATE);
terminatedSomething = strategy.doTerminate(runner);
Assert.assertFalse(terminatedSomething);
Assert.assertTrue(strategy.getStats().toList().size() == 1);
Assert.assertTrue(strategy.getStats().toList().get(0).getEvent() == ScalingStats.EVENT.TERMINATE);
EasyMock.verify(autoScaler);
EasyMock.verify(runner);
}
use of io.druid.indexing.overlord.RemoteTaskRunner in project druid by druid-io.
the class PendingTaskBasedResourceManagementStrategyTest method testSuccessfulMinWorkersProvisionWithOldVersionNodeRunning.
@Test
public void testSuccessfulMinWorkersProvisionWithOldVersionNodeRunning() throws Exception {
EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(3);
EasyMock.expect(autoScaler.getMaxNumWorkers()).andReturn(5);
EasyMock.expect(autoScaler.ipToIdLookup(EasyMock.<List<String>>anyObject())).andReturn(Lists.<String>newArrayList());
RemoteTaskRunner runner = EasyMock.createMock(RemoteTaskRunner.class);
// No pending tasks
EasyMock.expect(runner.getPendingTaskPayloads()).andReturn(Lists.<Task>newArrayList());
// 1 node already running, only provision 2 more.
EasyMock.expect(runner.getWorkers()).andReturn(Arrays.<ImmutableWorkerInfo>asList(new TestZkWorker(testTask).toImmutable(), // Invalid version node
new TestZkWorker(testTask, "h1", "n1", INVALID_VERSION).toImmutable()));
EasyMock.expect(runner.getConfig()).andReturn(new RemoteTaskRunnerConfig());
EasyMock.expect(autoScaler.provision()).andReturn(new AutoScalingData(Lists.<String>newArrayList("aNode"))).times(2);
EasyMock.replay(runner, autoScaler);
boolean provisionedSomething = strategy.doProvision(runner);
Assert.assertTrue(provisionedSomething);
Assert.assertTrue(strategy.getStats().toList().size() == 2);
for (ScalingStats.ScalingEvent event : strategy.getStats().toList()) {
Assert.assertTrue(event.getEvent() == ScalingStats.EVENT.PROVISION);
}
}
use of io.druid.indexing.overlord.RemoteTaskRunner in project druid by druid-io.
the class PendingTaskBasedResourceManagementStrategyTest method testNullWorkerConfig.
@Test
public void testNullWorkerConfig() throws Exception {
workerConfig.set(null);
EasyMock.replay(autoScaler);
RemoteTaskRunner runner = EasyMock.createMock(RemoteTaskRunner.class);
EasyMock.expect(runner.getPendingTaskPayloads()).andReturn(Arrays.<Task>asList(NoopTask.create())).times(1);
EasyMock.expect(runner.getWorkers()).andReturn(Arrays.asList(new TestZkWorker(null).toImmutable())).times(2);
EasyMock.replay(runner);
boolean terminatedSomething = strategy.doTerminate(runner);
boolean provisionedSomething = strategy.doProvision(runner);
Assert.assertFalse(terminatedSomething);
Assert.assertFalse(provisionedSomething);
EasyMock.verify(autoScaler);
EasyMock.verify(runner);
}
Aggregations