Search in sources :

Example 31 with Agent

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

the class JobInstanceModelTest method shouldReturnFalseForLiveAgentIfAgentInfoIsConstructedFromDb.

@Test
public void shouldReturnFalseForLiveAgentIfAgentInfoIsConstructedFromDb() {
    JobInstanceModel instance = new JobInstanceModel(JobInstanceMother.building("cruise"), JobDurationStrategy.ALWAYS_ZERO, new Agent("uuid", "hostname", "ip", "cookie"));
    assertThat(instance.hasLiveAgent(), is(false));
}
Also used : Agent(com.thoughtworks.go.config.Agent) Test(org.junit.jupiter.api.Test)

Example 32 with Agent

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

the class AgentInstanceMother method updateElasticPluginId.

public static AgentInstance updateElasticPluginId(AgentInstance agentInstance, String elasticPluginId) {
    Agent agent = agentInstance.getAgent();
    agent.setElasticPluginId(elasticPluginId);
    agentInstance.syncAgentFrom(agent);
    return agentInstance;
}
Also used : AgentInstance.createFromLiveAgent(com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent) Agent(com.thoughtworks.go.config.Agent)

Example 33 with Agent

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

the class AgentInstanceMother method updateLocation.

public static AgentInstance updateLocation(AgentInstance agentInstance, String location) {
    Agent agent = agentInstance.getAgent();
    agentInstance.update(fromServer(agent, true, location, agentInstance.getUsableSpace(), "linux"));
    return agentInstance;
}
Also used : AgentInstance.createFromLiveAgent(com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent) Agent(com.thoughtworks.go.config.Agent)

Example 34 with Agent

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

the class AgentInstanceMother method disabledWith.

public static AgentInstance disabledWith(String uuid) {
    final AgentInstance disabled = disabled();
    disabled.syncAgentFrom(new Agent(uuid, disabled.getHostname(), disabled.getIpAddress()));
    return disabled;
}
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)

Example 35 with Agent

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

the class AgentInstanceMother method idle.

public static AgentInstance idle(final Date lastHeardAt, final String hostname, SystemEnvironment systemEnvironment) {
    Agent idleAgentConfig = new Agent("uuid2", hostname, "10.18.5.1");
    AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(idleAgentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie");
    agentRuntimeInfo.setLocation("/var/lib/foo");
    agentRuntimeInfo.idle();
    agentRuntimeInfo.setUsableSpace(10 * 1024l);
    AgentInstance agentInstance = createFromLiveAgent(agentRuntimeInfo, systemEnvironment, mock(AgentStatusChangeListener.class));
    agentInstance.idle();
    agentInstance.update(agentRuntimeInfo);
    ReflectionUtil.setField(agentInstance, "lastHeardTime", lastHeardAt);
    return agentInstance;
}
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) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener)

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