Search in sources :

Example 26 with Pair

use of com.twitter.heron.common.basics.Pair in project incubator-heron by apache.

the class PackingPlanBuilderTest method testAddToPackingPlan.

@Test
public void testAddToPackingPlan() throws ResourceExceededException {
    PackingPlan plan = doCreatePackingPlanTest(testContainerInstances);
    @SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, InstanceId>[] added = new Pair[] { new Pair<>(1, new InstanceId("componentB", 4, 1)), new Pair<>(4, new InstanceId("componentA", 5, 2)) };
    PackingPlan updatedPlan = PackingTestHelper.addToTestPackingPlan(TOPOLOGY_ID, plan, PackingTestHelper.toContainerIdComponentNames(added), 0);
    Pair<Integer, InstanceId>[] expected = concat(testContainerInstances, added);
    AssertPacking.assertPackingPlan(TOPOLOGY_ID, expected, updatedPlan);
}
Also used : InstanceId(com.twitter.heron.spi.packing.InstanceId) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) Pair(com.twitter.heron.common.basics.Pair) Test(org.junit.Test)

Example 27 with Pair

use of com.twitter.heron.common.basics.Pair in project incubator-heron by apache.

the class PackingPlanBuilderTest method testRemoveFromPackingPlan.

@Test
public void testRemoveFromPackingPlan() throws ResourceExceededException {
    PackingPlan plan = doCreatePackingPlanTest(testContainerInstances);
    @SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, String>[] removed = new Pair[] { new Pair<>(1, "componentA"), new Pair<>(3, "componentA") };
    PackingPlan updatedPlan = PackingTestHelper.removeFromTestPackingPlan(TOPOLOGY_ID, plan, removed, 0);
    @SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, InstanceId>[] expected = new Pair[] { new Pair<>(3, new InstanceId("componentB", 3, 0)) };
    AssertPacking.assertPackingPlan(TOPOLOGY_ID, expected, updatedPlan);
}
Also used : InstanceId(com.twitter.heron.spi.packing.InstanceId) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) Pair(com.twitter.heron.common.basics.Pair) Test(org.junit.Test)

Aggregations

Pair (com.twitter.heron.common.basics.Pair)27 Test (org.junit.Test)18 InstanceId (com.twitter.heron.spi.packing.InstanceId)12 PackingPlan (com.twitter.heron.spi.packing.PackingPlan)12 HashMap (java.util.HashMap)7 InetSocketAddress (java.net.InetSocketAddress)6 Config (com.twitter.heron.spi.common.Config)5 ArrayList (java.util.ArrayList)4 ContainerPlan (com.twitter.heron.spi.packing.PackingPlan.ContainerPlan)2 NetworkUtils (com.twitter.heron.spi.utils.NetworkUtils)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 List (java.util.List)2 POST (javax.ws.rs.POST)2 Produces (javax.ws.rs.Produces)2 Before (org.junit.Before)2 Mockito.anyString (org.mockito.Mockito.anyString)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 SubmitDryRunResponse (com.twitter.heron.scheduler.dryrun.SubmitDryRunResponse)1 File (java.io.File)1