Search in sources :

Example 1 with SingularitySlave

use of com.hubspot.singularity.SingularitySlave 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 SingularitySlave

use of com.hubspot.singularity.SingularitySlave 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 SingularitySlave

use of com.hubspot.singularity.SingularitySlave in project Singularity by HubSpot.

the class SingularityMachineStatesTest method testLoadSlavesFromMasterDataOnStartup.

@Test
public void testLoadSlavesFromMasterDataOnStartup() {
    MesosMasterStateObject state = getMasterState(3);
    singularitySlaveAndRackManager.loadSlavesAndRacksFromMaster(state, true);
    List<SingularitySlave> slaves = slaveManager.getObjects();
    Assert.assertEquals(3, slaves.size());
    for (SingularitySlave slave : slaves) {
        Assert.assertEquals(MachineState.ACTIVE, slave.getCurrentState().getState());
    }
}
Also used : SingularitySlave(com.hubspot.singularity.SingularitySlave) MesosMasterStateObject(com.hubspot.mesos.json.MesosMasterStateObject) Test(org.junit.Test)

Example 4 with SingularitySlave

use of com.hubspot.singularity.SingularitySlave in project Singularity by HubSpot.

the class SingularityMachineStatesTest method testReconcileSlaves.

@Test
public void testReconcileSlaves() {
    // Load 3 slaves on startup
    MesosMasterStateObject state = getMasterState(3);
    singularitySlaveAndRackManager.loadSlavesAndRacksFromMaster(state, true);
    // 2 slaves, third has died
    MesosMasterStateObject newState = getMasterState(2);
    singularitySlaveAndRackManager.loadSlavesAndRacksFromMaster(newState, false);
    List<SingularitySlave> slaves = slaveManager.getObjects();
    Assert.assertEquals(3, slaves.size());
    for (SingularitySlave slave : slaves) {
        if (slave.getId().equals("2")) {
            Assert.assertEquals(MachineState.DEAD, slave.getCurrentState().getState());
        } else {
            Assert.assertEquals(MachineState.ACTIVE, slave.getCurrentState().getState());
        }
    }
}
Also used : SingularitySlave(com.hubspot.singularity.SingularitySlave) MesosMasterStateObject(com.hubspot.mesos.json.MesosMasterStateObject) Test(org.junit.Test)

Example 5 with SingularitySlave

use of com.hubspot.singularity.SingularitySlave 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)

Aggregations

SingularitySlave (com.hubspot.singularity.SingularitySlave)22 Test (org.junit.Test)10 SingularityMachineChangeRequest (com.hubspot.singularity.api.SingularityMachineChangeRequest)6 SingularityRack (com.hubspot.singularity.SingularityRack)4 MesosMasterStateObject (com.hubspot.mesos.json.MesosMasterStateObject)3 ArrayList (java.util.ArrayList)3 MachineState (com.hubspot.singularity.MachineState)2 SingularityTask (com.hubspot.singularity.SingularityTask)2 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)2 HashSet (java.util.HashSet)2 Timed (com.codahale.metrics.annotation.Timed)1 Optional (com.google.common.base.Optional)1 MesosMasterSlaveObject (com.hubspot.mesos.json.MesosMasterSlaveObject)1 SingularityDeleteResult (com.hubspot.singularity.SingularityDeleteResult)1 SingularityDeployMarker (com.hubspot.singularity.SingularityDeployMarker)1 SingularityDisasterDataPoint (com.hubspot.singularity.SingularityDisasterDataPoint)1 SingularityHostState (com.hubspot.singularity.SingularityHostState)1 SingularityMachineStateHistoryUpdate (com.hubspot.singularity.SingularityMachineStateHistoryUpdate)1 SingularityPendingDeploy (com.hubspot.singularity.SingularityPendingDeploy)1 SingularityPendingRequest (com.hubspot.singularity.SingularityPendingRequest)1