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()));
}
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());
}
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());
}
}
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());
}
}
}
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()));
}
Aggregations