Search in sources :

Example 21 with SingularityAgent

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());
    }
}
Also used : MesosMasterStateObject(com.hubspot.mesos.json.MesosMasterStateObject) SingularityAgent(com.hubspot.singularity.SingularityAgent) Test(org.junit.jupiter.api.Test)

Example 22 with SingularityAgent

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());
        }
    }
}
Also used : MesosMasterStateObject(com.hubspot.mesos.json.MesosMasterStateObject) SingularityAgent(com.hubspot.singularity.SingularityAgent) Test(org.junit.jupiter.api.Test)

Example 23 with SingularityAgent

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

Example 24 with SingularityAgent

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

Example 25 with SingularityAgent

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

Aggregations

SingularityAgent (com.hubspot.singularity.SingularityAgent)26 Test (org.junit.jupiter.api.Test)13 SingularityMachineChangeRequest (com.hubspot.singularity.api.SingularityMachineChangeRequest)6 MesosMasterStateObject (com.hubspot.mesos.json.MesosMasterStateObject)4 MachineState (com.hubspot.singularity.MachineState)4 SingularityRack (com.hubspot.singularity.SingularityRack)4 ArrayList (java.util.ArrayList)4 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)3 MesosMasterAgentObject (com.hubspot.mesos.json.MesosMasterAgentObject)2 SingularityMachineStateHistoryUpdate (com.hubspot.singularity.SingularityMachineStateHistoryUpdate)2 SingularityPendingTaskId (com.hubspot.singularity.SingularityPendingTaskId)2 SingularityTask (com.hubspot.singularity.SingularityTask)2 HashSet (java.util.HashSet)2 Optional (java.util.Optional)2 Timed (com.codahale.metrics.annotation.Timed)1 HashMultiset (com.google.common.collect.HashMultiset)1 Multiset (com.google.common.collect.Multiset)1 Inject (com.google.inject.Inject)1 Singleton (com.google.inject.Singleton)1 AgentPlacement (com.hubspot.singularity.AgentPlacement)1