use of com.hubspot.singularity.SingularityAgent in project Singularity by HubSpot.
the class SingularityMachinesTest method testLoadSlavesFromMasterDataOnStartup.
@Test
public void testLoadSlavesFromMasterDataOnStartup() {
MesosMasterStateObject state = getMasterState(3);
singularityAgentAndRackManager.loadAgentsAndRacksFromMaster(state, true);
List<SingularityAgent> agents = agentManager.getObjects();
Assertions.assertEquals(3, agents.size());
for (SingularityAgent agent : agents) {
Assertions.assertEquals(MachineState.ACTIVE, agent.getCurrentState().getState());
}
}
use of com.hubspot.singularity.SingularityAgent in project Singularity by HubSpot.
the class SingularityMachinesTest method testReconcileSlaves.
@Test
public void testReconcileSlaves() {
// Load 3 agents on startup
MesosMasterStateObject state = getMasterState(3);
singularityAgentAndRackManager.loadAgentsAndRacksFromMaster(state, true);
// 2 agents, third has died
MesosMasterStateObject newState = getMasterState(2);
singularityAgentAndRackManager.loadAgentsAndRacksFromMaster(newState, false);
List<SingularityAgent> agents = agentManager.getObjects();
Assertions.assertEquals(3, agents.size());
for (SingularityAgent agent : agents) {
if (agent.getId().equals("2")) {
Assertions.assertEquals(MachineState.DEAD, agent.getCurrentState().getState());
} else {
Assertions.assertEquals(MachineState.ACTIVE, agent.getCurrentState().getState());
}
}
}
use of com.hubspot.singularity.SingularityAgent in project Singularity by HubSpot.
the class SingularityMachinesTest method testCannotUseStateReservedForSystem.
@Test
public void testCannotUseStateReservedForSystem() {
SingularityAgent agent = getSingleSlave();
Assertions.assertThrows(WebApplicationException.class, () -> agentResource.freezeAgent(singularityUser, agent.getId(), new SingularityMachineChangeRequest(Optional.of(1L), Optional.empty(), Optional.empty(), Optional.of(MachineState.DEAD), Optional.empty())));
}
use of com.hubspot.singularity.SingularityAgent in project Singularity by HubSpot.
the class SingularityMachinesTest method testValidTransitionToDecommissioned.
@Test
public void testValidTransitionToDecommissioned() {
initRequest();
initFirstDeploy();
requestResource.postRequest(request.toBuilder().setInstances(Optional.of(2)).build(), singularityUser);
scheduler.drainPendingQueue();
resourceOffers(1);
SingularityAgent agent = agentManager.getObjects().get(0);
agentResource.decommissionAgent(singularityUser, agent.getId(), new SingularityMachineChangeRequest(Optional.of(1L), Optional.empty(), Optional.empty(), Optional.of(MachineState.DECOMMISSIONED), Optional.of(true)));
Assertions.assertEquals(MachineState.STARTING_DECOMMISSION, agentManager.getObjects().get(0).getCurrentState().getState());
scheduler.checkForDecomissions();
scheduler.drainPendingQueue();
Assertions.assertEquals(TaskCleanupType.DECOMISSIONING, taskManager.getCleanupTasks().get(0).getCleanupType());
expiringUserActionPoller.runActionOnPoll();
Assertions.assertEquals(MachineState.DECOMMISSIONED, agentManager.getObjects().get(0).getCurrentState().getState());
Assertions.assertEquals(TaskCleanupType.DECOMMISSION_TIMEOUT, taskManager.getCleanupTasks().get(0).getCleanupType());
}
use of com.hubspot.singularity.SingularityAgent in project Singularity by HubSpot.
the class SingularityMachinesTest method testInvalidTransitionToDecommissioned.
@Test
public void testInvalidTransitionToDecommissioned() {
SingularityAgent agent = getSingleSlave();
Assertions.assertThrows(WebApplicationException.class, () -> agentResource.decommissionAgent(singularityUser, agent.getId(), new SingularityMachineChangeRequest(Optional.of(1L), Optional.empty(), Optional.empty(), Optional.of(MachineState.DECOMMISSIONED), Optional.empty())));
}
Aggregations