public void testCreateStartModifyOneCluster() throws Exception {
TestContainerAllocator allocator = new TestContainerAllocator();
TestContainerLauncher launcher = new TestContainerLauncher();
TestManagedContainerClusterAppmaster appmaster = createTestAppmaster(allocator, launcher);
appmaster.setStateMachineFactory(stateMachineFactory);
ProjectionData projectionData = new ProjectionData(1, null, null, "any", 0);
// create
GridProjection projection = appmaster.createContainerCluster("foo", projectionData).getGridProjection();
assertDoTask(appmaster, null, null, null, null, "foo");
// start
appmaster.startContainerCluster("foo");
assertDoTask(appmaster, 1, 0, 0, 0, "foo");
// allocate container 1
Container container1 = allocateContainer(appmaster, 1);
assertThat(projection.getMembers().size(), is(1));
assertDoTask(appmaster, null, null, null, null, "foo");
// modify - ramp up to 2
appmaster.modifyContainerCluster("foo", new ProjectionData(2));
assertDoTask(appmaster, 1, 0, 0, 0, "foo");
// allocate container 2
allocateContainer(appmaster, 2);
assertThat(projection.getMembers().size(), is(2));
assertDoTask(appmaster, null, null, null, null, "foo");
// modify - ramp up to 4
appmaster.modifyContainerCluster("foo", new ProjectionData(4));
assertDoTask(appmaster, 2, 0, 0, 0, "foo");
// allocate container 3 and 4
allocateContainer(appmaster, 3);
allocateContainer(appmaster, 4);