Search in sources :

Example 1 with SingularityMachineChangeRequest

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()));
}
Also used : SingularitySlave(com.hubspot.singularity.SingularitySlave) SingularityMachineChangeRequest(com.hubspot.singularity.api.SingularityMachineChangeRequest) Test(org.junit.Test)

Example 2 with SingularityMachineChangeRequest

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());
}
Also used : SingularitySlave(com.hubspot.singularity.SingularitySlave) SingularityMachineChangeRequest(com.hubspot.singularity.api.SingularityMachineChangeRequest) Test(org.junit.Test)

Example 3 with SingularityMachineChangeRequest

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()));
}
Also used : SingularitySlave(com.hubspot.singularity.SingularitySlave) SingularityMachineChangeRequest(com.hubspot.singularity.api.SingularityMachineChangeRequest) Test(org.junit.Test)

Example 4 with SingularityMachineChangeRequest

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());
}
Also used : SingularitySlave(com.hubspot.singularity.SingularitySlave) SingularityMachineChangeRequest(com.hubspot.singularity.api.SingularityMachineChangeRequest) Test(org.junit.Test)

Example 5 with SingularityMachineChangeRequest

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()));
}
Also used : SingularitySlave(com.hubspot.singularity.SingularitySlave) SingularityMachineChangeRequest(com.hubspot.singularity.api.SingularityMachineChangeRequest) Test(org.junit.Test)

Aggregations

SingularityMachineChangeRequest (com.hubspot.singularity.api.SingularityMachineChangeRequest)7 SingularitySlave (com.hubspot.singularity.SingularitySlave)6 Test (org.junit.Test)6 MesosMasterStateObject (com.hubspot.mesos.json.MesosMasterStateObject)1 MachineState (com.hubspot.singularity.MachineState)1 SingularityExpiringMachineState (com.hubspot.singularity.expiring.SingularityExpiringMachineState)1