use of com.hubspot.singularity.api.SingularityMachineChangeRequest in project Singularity by HubSpot.
the class SingularityMachineStatesTest method testCannotUseStateReservedForSystem.
@Test(expected = WebApplicationException.class)
public void testCannotUseStateReservedForSystem() {
SingularitySlave slave = getSingleSlave();
slaveResource.freezeSlave(singularityUser, slave.getId(), new SingularityMachineChangeRequest(Optional.of(1L), Optional.absent(), Optional.absent(), Optional.of(MachineState.DEAD), Optional.absent()));
}
use of com.hubspot.singularity.api.SingularityMachineChangeRequest in project Singularity by HubSpot.
the class SingularityMachineStatesTest method testSystemChangeClearsExpiringChangeIfInvalid.
@Test
public void testSystemChangeClearsExpiringChangeIfInvalid() {
SingularitySlave slave = getSingleSlave();
slaveResource.freezeSlave(singularityUser, slave.getId(), null);
slaveResource.activateSlave(singularityUser, slave.getId(), new SingularityMachineChangeRequest(Optional.of(1L), Optional.absent(), Optional.absent(), Optional.of(MachineState.FROZEN), Optional.absent()));
Assert.assertTrue(slaveManager.getExpiringObject(slave.getId()).isPresent());
slaveResource.decommissionSlave(singularityUser, slave.getId(), null);
Assert.assertFalse(slaveManager.getExpiringObject(slave.getId()).isPresent());
}
use of com.hubspot.singularity.api.SingularityMachineChangeRequest in project Singularity by HubSpot.
the class SingularityMachineStatesTest method testInvalidTransitionToDecommissioned.
@Test(expected = WebApplicationException.class)
public void testInvalidTransitionToDecommissioned() {
SingularitySlave slave = getSingleSlave();
slaveResource.decommissionSlave(singularityUser, slave.getId(), new SingularityMachineChangeRequest(Optional.of(1L), Optional.absent(), Optional.absent(), Optional.of(MachineState.DECOMMISSIONED), Optional.absent()));
}
use of com.hubspot.singularity.api.SingularityMachineChangeRequest in project Singularity by HubSpot.
the class SingularityMachineStatesTest method testValidTransitionToDecommissioned.
@Test
public void testValidTransitionToDecommissioned() {
initRequest();
initFirstDeploy();
requestResource.postRequest(request.toBuilder().setInstances(Optional.of(2)).build(), singularityUser);
scheduler.drainPendingQueue();
resourceOffers(1);
SingularitySlave slave = slaveManager.getObjects().get(0);
slaveResource.decommissionSlave(singularityUser, slave.getId(), new SingularityMachineChangeRequest(Optional.of(1L), Optional.absent(), Optional.absent(), Optional.of(MachineState.DECOMMISSIONED), Optional.of(true)));
Assert.assertEquals(MachineState.STARTING_DECOMMISSION, slaveManager.getObjects().get(0).getCurrentState().getState());
scheduler.checkForDecomissions();
scheduler.drainPendingQueue();
Assert.assertEquals(TaskCleanupType.DECOMISSIONING, taskManager.getCleanupTasks().get(0).getCleanupType());
expiringUserActionPoller.runActionOnPoll();
Assert.assertEquals(MachineState.DECOMMISSIONED, slaveManager.getObjects().get(0).getCurrentState().getState());
Assert.assertEquals(TaskCleanupType.DECOMMISSION_TIMEOUT, taskManager.getCleanupTasks().get(0).getCleanupType());
}
use of com.hubspot.singularity.api.SingularityMachineChangeRequest in project Singularity by HubSpot.
the class SingularityMachineStatesTest method testBadExpiringStateTransition.
@Test(expected = WebApplicationException.class)
public void testBadExpiringStateTransition() {
SingularitySlave slave = getSingleSlave();
slaveResource.decommissionSlave(singularityUser, slave.getId(), new SingularityMachineChangeRequest(Optional.of(1L), Optional.absent(), Optional.absent(), Optional.of(MachineState.FROZEN), Optional.absent()));
}
Aggregations