private ComputeState createComputeState(ResourcePoolState placementZone) throws Throwable { return createComputeState(placementZone, false); }
@Test public void testUpdateDockerPZInUseByMultipleVicHostsToSchedulerPZShouldPass() throws Throwable { // First create a docker placement zone. ResourcePoolState createdPlacementZone = createPlacementZone("docker-placement-zone", false); assertNotNull(createdPlacementZone); // Now create 2 VIC hosts that use this placement zone. This can be achieved if the VIC // hosts were initially declared as docker but were later on marked as VIC createComputeState(createdPlacementZone); createComputeState(createdPlacementZone); // Now create a PATCH that updates the type of the zone to scheduler. This should fail // because there will be multiple container in the placement zone (even if they are all // schedulers) ResourcePoolState patchState = new ResourcePoolState(); markSchedulerPlacementZone(patchState); try { doPatch(patchState, createdPlacementZone.documentSelfLink); Assert.fail( "PATCH should fail to update the type of a docker placement " + "zone to a scheduler zone when the placement zone is in use by multiple scheduler hosts"); } catch (Exception ex) { verifyExceptionMessage(ex, SchedulerPlacementZoneInterceptor.MULTIPLE_HOSTS_IN_PLACEMENT_ZONE_MESSAGE); } }
@Test public void testPutSchedulerPZInUseToDockerPZShouldFail() throws Throwable { // First create a docker placement zone. ResourcePoolState createdPlacementZone = createPlacementZone("scheduler-placement-zone", true); assertNotNull(createdPlacementZone); // Now create a compute state that uses this placement zone createComputeState(createdPlacementZone, true); // Now update the type of the zone to docker and issue a PUT. This should fail markDockerPlacementZone(createdPlacementZone); try { doPut(createdPlacementZone); Assert.fail( "PUT should fail to update the type of a used " + "scheduler placement zone to a docker zone"); } catch (Exception ex) { verifyExceptionMessage(ex, SchedulerPlacementZoneInterceptor.SCHEDULER_HOSTS_IN_PLACEMENT_ZONE_MESSAGE); } }
@Test public void testPutDockerPZInUseToSchedulerPZShouldFail() throws Throwable { // First create a docker placement zone. ResourcePoolState createdPlacementZone = createPlacementZone("docker-placement-zone", false); assertNotNull(createdPlacementZone); // Now create a compute state that uses this placement zone createComputeState(createdPlacementZone); // Now update the type of the zone to scheduler and issue a PUT. This should fail markSchedulerPlacementZone(createdPlacementZone); try { doPut(createdPlacementZone); Assert.fail( "PUT should fail to update the type of a used " + "docker placement zone to a scheduler zone"); } catch (Exception ex) { verifyExceptionMessage(ex, SchedulerPlacementZoneInterceptor.NON_SCHEDULER_HOST_IN_PLACEMENT_ZONE_MESSAGE); } }
@Test public void testUpdateDockerPZInUseToSchedulerPZShouldFail() throws Throwable { // First create a docker placement zone. ResourcePoolState createdPlacementZone = createPlacementZone("docker-placement-zone", false); assertNotNull(createdPlacementZone); // Now create a compute state that uses this placement zone createComputeState(createdPlacementZone); // Now create a PATCH that updates the type of the zone to scheduler. This should fail ResourcePoolState patchState = new ResourcePoolState(); markSchedulerPlacementZone(patchState); try { doPatch(patchState, createdPlacementZone.documentSelfLink); Assert.fail( "PATCH should fail to update the type of a used " + "docker placement zone to a scheduler zone"); } catch (Exception ex) { verifyExceptionMessage(ex, SchedulerPlacementZoneInterceptor.NON_SCHEDULER_HOST_IN_PLACEMENT_ZONE_MESSAGE); } }
@Test public void testUpdateSchedulerPZInUseToDockerPZShouldFail() throws Throwable { // First create a docker placement zone. ResourcePoolState createdPlacementZone = createPlacementZone("scheduler-placement-zone", true); assertNotNull(createdPlacementZone); // Now create a compute state that uses this placement zone createComputeState(createdPlacementZone, true); // Now create a PATCH that updates the type of the zone to docker. This should fail ResourcePoolState patchState = new ResourcePoolState(); markDockerPlacementZone(patchState); try { doPatch(patchState, createdPlacementZone.documentSelfLink); Assert.fail( "PATCH should fail to update the type of a used " + "scheduler placement zone to a docker zone"); } catch (Exception ex) { verifyExceptionMessage(ex, SchedulerPlacementZoneInterceptor.SCHEDULER_HOSTS_IN_PLACEMENT_ZONE_MESSAGE); } }