use of org.apache.heron.packing.roundrobin.RoundRobinPacking in project heron by twitter.
the class PackingPlanProviderTest method fetchesAndCachesPackingFromStateMgr.
@Test
public void fetchesAndCachesPackingFromStateMgr() {
PackingPlans.PackingPlan proto = PackingTestUtils.testProtoPackingPlan(topologyName, new RoundRobinPacking());
SchedulerStateManagerAdaptor adaptor = mock(SchedulerStateManagerAdaptor.class);
when(adaptor.getPackingPlan(topologyName)).thenReturn(proto);
PackingPlanProvider provider = new PackingPlanProvider(adaptor, eventManager, topologyName);
PackingPlan packing = provider.get();
Assert.assertEquals(1, packing.getContainers().size());
// once fetched it is cached
provider.get();
verify(adaptor, times(1)).getPackingPlan(topologyName);
}
use of org.apache.heron.packing.roundrobin.RoundRobinPacking in project heron by twitter.
the class RuntimeManagerRunnerTest method doupdateTopologyComponentParallelismTest.
private void doupdateTopologyComponentParallelismTest(String newParallelism, boolean expectedResult) {
ISchedulerClient client = mock(ISchedulerClient.class);
SchedulerStateManagerAdaptor manager = mock(SchedulerStateManagerAdaptor.class);
RuntimeManagerRunner runner = newRuntimeManagerRunner(Command.UPDATE, client);
PowerMockito.mockStatic(Runtime.class);
PowerMockito.when(Runtime.schedulerStateManagerAdaptor(runtime)).thenReturn(manager);
RoundRobinPacking packing = new RoundRobinPacking();
PackingPlans.PackingPlan currentPlan = PackingTestUtils.testProtoPackingPlan(TOPOLOGY_NAME, packing);
PackingPlans.PackingPlan proposedPlan = PackingTestUtils.testProtoPackingPlan(TOPOLOGY_NAME, packing);
Map<String, Integer> changeRequests = runner.parseNewParallelismParam(newParallelism);
when(manager.getPackingPlan(eq(TOPOLOGY_NAME))).thenReturn(currentPlan);
doReturn(proposedPlan).when(runner).buildNewPackingPlan(eq(currentPlan), eq(changeRequests), any(), any(TopologyAPI.Topology.class));
Scheduler.UpdateTopologyRequest updateTopologyRequest = Scheduler.UpdateTopologyRequest.newBuilder().setCurrentPackingPlan(currentPlan).setProposedPackingPlan(proposedPlan).build();
when(client.updateTopology(updateTopologyRequest)).thenReturn(true);
try {
runner.updateTopologyComponentParallelism(TOPOLOGY_NAME, newParallelism);
} finally {
int expectedClientUpdateCalls = expectedResult ? 1 : 0;
verify(client, times(expectedClientUpdateCalls)).updateTopology(updateTopologyRequest);
}
}
use of org.apache.heron.packing.roundrobin.RoundRobinPacking in project heron by twitter.
the class SubmitterMainTest method setUp.
@Before
public void setUp() throws Exception {
// Mock objects to be verified
IPacking packing = mock(IPacking.class);
statemgr = mock(IStateManager.class);
launcher = mock(ILauncher.class);
uploader = mock(IUploader.class);
// Mock ReflectionUtils stuff
PowerMockito.spy(ReflectionUtils.class);
PowerMockito.doReturn(statemgr).when(ReflectionUtils.class, "newInstance", STATE_MANAGER_CLASS);
PowerMockito.doReturn(launcher).when(ReflectionUtils.class, "newInstance", LAUNCHER_CLASS);
PowerMockito.doReturn(packing).when(ReflectionUtils.class, "newInstance", PACKING_CLASS);
PowerMockito.doReturn(uploader).when(ReflectionUtils.class, "newInstance", UPLOADER_CLASS);
config = mock(Config.class);
when(config.getStringValue(Key.STATE_MANAGER_CLASS)).thenReturn(STATE_MANAGER_CLASS);
when(config.getStringValue(Key.LAUNCHER_CLASS)).thenReturn(LAUNCHER_CLASS);
when(config.getStringValue(Key.PACKING_CLASS)).thenReturn(PACKING_CLASS);
when(config.getStringValue(Key.UPLOADER_CLASS)).thenReturn(UPLOADER_CLASS);
when(packing.pack()).thenReturn(PackingTestUtils.testPackingPlan(TOPOLOGY_NAME, new RoundRobinPacking()));
topology = TopologyAPI.Topology.getDefaultInstance();
}
use of org.apache.heron.packing.roundrobin.RoundRobinPacking in project heron by twitter.
the class SchedulerMainTest method getTestPacking.
private SettableFuture<PackingPlans.PackingPlan> getTestPacking() {
PackingPlans.PackingPlan packingPlan = PackingTestUtils.testProtoPackingPlan("testTopology", new RoundRobinPacking());
final SettableFuture<PackingPlans.PackingPlan> future = SettableFuture.create();
assertTrue(future.set(packingPlan));
return future;
}
use of org.apache.heron.packing.roundrobin.RoundRobinPacking in project heron by twitter.
the class HeronMasterDriverTest method scheduleHeronWorkersAddsContainers.
@Test
public void scheduleHeronWorkersAddsContainers() throws Exception {
PackingPlan packingPlan = PackingTestUtils.testPackingPlan("test", new RoundRobinPacking());
spyDriver.scheduleHeronWorkers(packingPlan);
verify(spyDriver, times(1)).requestContainerForWorker(eq(1), anyHeronWorker());
verify(mockRequestor, times(1)).submit(any(EvaluatorRequest.class));
Set<PackingPlan.ContainerPlan> toBeAddedContainerPlans = new HashSet<>();
toBeAddedContainerPlans.add(PackingTestUtils.testContainerPlan(2));
toBeAddedContainerPlans.add(PackingTestUtils.testContainerPlan(3));
spyDriver.scheduleHeronWorkers(toBeAddedContainerPlans);
verify(spyDriver, times(1)).requestContainerForWorker(eq(2), anyHeronWorker());
verify(spyDriver, times(1)).requestContainerForWorker(eq(3), anyHeronWorker());
verify(mockRequestor, times(3)).submit(any(EvaluatorRequest.class));
}
Aggregations