Search in sources :

Example 61 with Agent

use of com.thoughtworks.go.config.Agent in project gocd by gocd.

the class AgentInstanceMother method lostContact.

public static AgentInstance lostContact(String buildLocator) {
    Agent agent = new Agent("1234", "localhost", "192.168.0.1");
    AgentInstance instance = AgentInstance.createFromAgent(agent, new SystemEnvironment(), mock(AgentStatusChangeListener.class));
    AgentRuntimeInfo newRuntimeInfo = AgentRuntimeInfo.initialState(agent);
    newRuntimeInfo.setStatus(AgentStatus.LostContact);
    newRuntimeInfo.setUsableSpace(1000L);
    newRuntimeInfo.setBuildingInfo(new AgentBuildingInfo("buildInfo", buildLocator));
    instance.update(newRuntimeInfo);
    return instance;
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) NullAgentInstance(com.thoughtworks.go.domain.NullAgentInstance) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentInstance.createFromLiveAgent(com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent) Agent(com.thoughtworks.go.config.Agent) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentBuildingInfo(com.thoughtworks.go.server.service.AgentBuildingInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener)

Example 62 with Agent

use of com.thoughtworks.go.config.Agent in project gocd by gocd.

the class TriStateSelectionTest method shouldHaveActionRemoveIfNoAgentsHaveResource.

@Test
public void shouldHaveActionRemoveIfNoAgentsHaveResource() {
    resourceConfigs.add(new ResourceConfig("none"));
    agents.add(new Agent("uuid1", "host1", "127.0.0.1", singletonList("one")));
    agents.add(new Agent("uuid2", "host2", "127.0.0.2", singletonList("two")));
    List<TriStateSelection> selections = TriStateSelection.forAgentsResources(resourceConfigs, agents);
    assertThat(selections, hasItem(new TriStateSelection("none", TriStateSelection.Action.remove)));
}
Also used : Agent(com.thoughtworks.go.config.Agent) ResourceConfig(com.thoughtworks.go.config.ResourceConfig) Test(org.junit.jupiter.api.Test)

Example 63 with Agent

use of com.thoughtworks.go.config.Agent in project gocd by gocd.

the class TriStateSelectionTest method shouldBeNoChangeIfAllAgentsHaveThatResource.

@Test
public void shouldBeNoChangeIfAllAgentsHaveThatResource() {
    resourceConfigs.add(new ResourceConfig("some"));
    agents.add(new Agent("uuid1", "host1", "127.0.0.1", singletonList("some")));
    agents.add(new Agent("uuid2", "host2", "127.0.0.2", emptyList()));
    List<TriStateSelection> selections = TriStateSelection.forAgentsResources(resourceConfigs, agents);
    assertThat(selections, hasItem(new TriStateSelection("some", TriStateSelection.Action.nochange)));
}
Also used : Agent(com.thoughtworks.go.config.Agent) ResourceConfig(com.thoughtworks.go.config.ResourceConfig) Test(org.junit.jupiter.api.Test)

Example 64 with Agent

use of com.thoughtworks.go.config.Agent in project gocd by gocd.

the class AgentInstanceMother method disabled.

public static AgentInstance disabled(String ip, SystemEnvironment systemEnvironment) {
    AgentInstance denied = AgentInstance.createFromAgent(new Agent("uuid5", "CCeDev04", ip), systemEnvironment, mock(AgentStatusChangeListener.class));
    denied.enable();
    denied.deny();
    return denied;
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) NullAgentInstance(com.thoughtworks.go.domain.NullAgentInstance) AgentInstance.createFromLiveAgent(com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent) Agent(com.thoughtworks.go.config.Agent) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener)

Example 65 with Agent

use of com.thoughtworks.go.config.Agent in project gocd by gocd.

the class AgentInstanceMother method updateHostname.

public static AgentInstance updateHostname(AgentInstance agentInstance, String hostname) {
    Agent original = agentInstance.getAgent();
    agentInstance.syncAgentFrom(new Agent(original.getUuid(), hostname, original.getIpaddress(), original.getResourcesAsList()));
    return agentInstance;
}
Also used : AgentInstance.createFromLiveAgent(com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent) Agent(com.thoughtworks.go.config.Agent)

Aggregations

Agent (com.thoughtworks.go.config.Agent)100 Test (org.junit.jupiter.api.Test)52 AgentInstance.createFromLiveAgent (com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent)36 AgentInstance (com.thoughtworks.go.domain.AgentInstance)20 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)19 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)16 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)13 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)11 JobInstance (com.thoughtworks.go.domain.JobInstance)8 ResponseEntity (org.springframework.http.ResponseEntity)8 ServerConfig (com.thoughtworks.go.config.ServerConfig)6 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)6 Username (com.thoughtworks.go.server.domain.Username)5 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)5 AgentInstance.createFromAgent (com.thoughtworks.go.domain.AgentInstance.createFromAgent)4 AgentBuildingInfo (com.thoughtworks.go.server.service.AgentBuildingInfo)4 Query (org.hibernate.Query)4 TransactionCallback (org.springframework.transaction.support.TransactionCallback)4 Gson (com.google.gson.Gson)3 ResourceConfig (com.thoughtworks.go.config.ResourceConfig)3