use of org.apache.heron.spi.packing.PackingPlan 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.spi.packing.PackingPlan in project heron by twitter.
the class UpdateTopologyManagerTest method init.
@Before
public void init() {
Integer[] instanceIndexA = new Integer[] { 37, 48, 59 };
Integer[] instanceIndexB = new Integer[] { 17, 22 };
currentContainerPlan = buildContainerSet(new Integer[] { 1, 2, 3, 4 }, instanceIndexA);
proposedContainerPlan = buildContainerSet(new Integer[] { 1, 3, 5, 6 }, instanceIndexB);
expectedContainersToAdd = buildContainerSet(new Integer[] { 5, 6 }, instanceIndexB);
expectedContainersToRemove = buildContainerSet(new Integer[] { 2, 4 }, instanceIndexA);
PackingPlanProtoSerializer serializer = new PackingPlanProtoSerializer();
PackingPlan currentPacking = new PackingPlan("current", currentContainerPlan);
proposedPacking = new PackingPlan("proposed", proposedContainerPlan);
currentProtoPlan = serializer.toProto(currentPacking);
proposedProtoPlan = serializer.toProto(proposedPacking);
testTopology = TopologyTests.createTopology(TOPOLOGY_NAME, new org.apache.heron.api.Config(), "spoutname", "boltname", 1, 1);
assertEquals(TopologyAPI.TopologyState.RUNNING, testTopology.getState());
}
use of org.apache.heron.spi.packing.PackingPlan in project heron by twitter.
the class MesosSchedulerTest method testGetBaseContainer.
@Test
public void testGetBaseContainer() throws Exception {
final double CPU = 0.5;
final ByteAmount MEM = ByteAmount.fromMegabytes(100);
final ByteAmount DISK = ByteAmount.fromMegabytes(100);
Resource containerResources = new Resource(CPU, MEM, DISK);
PackingPlan.ContainerPlan containerPlan = new PackingPlan.ContainerPlan(0, new HashSet<PackingPlan.InstancePlan>(), containerResources);
Set<PackingPlan.ContainerPlan> containerPlans = new HashSet<>();
containerPlans.add(containerPlan);
PackingPlan packingPlan = new PackingPlan(TOPOLOGY_NAME, containerPlans);
BaseContainer container = scheduler.getBaseContainer(0, packingPlan);
// Assert we have constructed the correct BaseContainer structure
Assert.assertEquals(ROLE, container.runAsUser);
Assert.assertEquals(CPU, container.cpu, 0.01);
Assert.assertEquals(MEM, ByteAmount.fromMegabytes(((Double) container.memInMB).longValue()));
Assert.assertEquals(DISK, ByteAmount.fromMegabytes(((Double) container.diskInMB).longValue()));
Assert.assertEquals(SchedulerUtils.ExecutorPort.getRequiredPorts().size(), container.ports);
Assert.assertEquals(2, container.dependencies.size());
Assert.assertTrue(container.dependencies.contains(CORE_PACKAGE_URI));
Assert.assertTrue(container.dependencies.contains(TOPOLOGY_PACKAGE_URI));
Assert.assertTrue(container.environmentVariables.isEmpty());
Assert.assertTrue(container.name.startsWith("container_0"));
// Convert to JSON
String str = container.toString();
String json = BaseContainer.getJobDefinitionInJSON(container);
Assert.assertEquals(json, str);
// Convert the JSON back to BaseContainer
BaseContainer newContainer = BaseContainer.getJobFromJSONString(json);
Assert.assertEquals(json, BaseContainer.getJobDefinitionInJSON(newContainer));
}
use of org.apache.heron.spi.packing.PackingPlan in project heron by twitter.
the class SlurmSchedulerTest method testOnSchedule.
/**
* Test the schedule method
* @throws Exception
*/
@Test
public void testOnSchedule() throws Exception {
SlurmController controller = Mockito.mock(SlurmController.class);
Mockito.doReturn(controller).when(scheduler).getController();
Config config = createRunnerConfig();
Config runtime = Mockito.mock(Config.class);
PowerMockito.spy(SlurmContext.class);
PowerMockito.doReturn(WORKING_DIRECTORY).when(SlurmContext.class, "workingDirectory", config);
scheduler.initialize(config, runtime);
// Fail to schedule due to null PackingPlan
Assert.assertFalse(scheduler.onSchedule(null));
PackingPlan plan = new PackingPlan(PACKING_PLAN_ID, new HashSet<PackingPlan.ContainerPlan>());
Assert.assertTrue(plan.getContainers().isEmpty());
// Fail to schedule due to PackingPlan is empty
Assert.assertFalse(scheduler.onSchedule(plan));
// Construct valid PackingPlan
Set<PackingPlan.ContainerPlan> containers = new HashSet<>();
containers.add(Mockito.mock(PackingPlan.ContainerPlan.class));
PackingPlan validPlan = new PackingPlan(PACKING_PLAN_ID, containers);
// Failed to create job via controller
Mockito.doReturn(false).when(controller).createJob(Mockito.anyString(), Mockito.anyString(), Matchers.any(String[].class), Mockito.anyString(), Mockito.anyInt());
Assert.assertFalse(scheduler.onSchedule(validPlan));
Mockito.verify(controller).createJob(Mockito.eq(SLURM_PATH), Mockito.anyString(), Matchers.any(String[].class), Mockito.anyString(), Mockito.anyInt());
// Happy path
Mockito.doReturn(true).when(controller).createJob(Mockito.anyString(), Mockito.anyString(), Matchers.any(String[].class), Mockito.anyString(), Mockito.anyInt());
Assert.assertTrue(scheduler.onSchedule(validPlan));
Mockito.verify(controller, Mockito.times(2)).createJob(Mockito.anyString(), Mockito.anyString(), Matchers.any(String[].class), Mockito.anyString(), Mockito.anyInt());
}
use of org.apache.heron.spi.packing.PackingPlan 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