use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentInstanceTest method shouldReturnAJobPlanWithMatchingUuidSet.
@Test
void shouldReturnAJobPlanWithMatchingUuidSet() {
Agent agent = agent("linux, mercurial");
AgentInstance agentInstance = new AgentInstance(agent, LOCAL, systemEnvironment, null);
final JobPlan job = jobPlan("pipeline-name", "job-name", "resource", agent.getUuid());
JobPlan matchingJob = agentInstance.firstMatching(new ArrayList<JobPlan>() {
{
add(job);
}
});
assertThat(matchingJob).isEqualTo(job);
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentInstanceTest method buildingMethodShouldUpdateAgentRuntimeStatusToBuildingAndSetSpecifiedBuildInfoInItsRuntimeInfo.
@Test
void buildingMethodShouldUpdateAgentRuntimeStatusToBuildingAndSetSpecifiedBuildInfoInItsRuntimeInfo() {
Agent mockAgent = mock(Agent.class);
AgentRuntimeInfo mockAgentRuntimeInfo = mock(AgentRuntimeInfo.class);
AgentBuildingInfo mockAgentBuildingInfo = mock(AgentBuildingInfo.class);
SystemEnvironment mockSysEnv = mock(SystemEnvironment.class);
AgentStatusChangeListener mockAgentStatusChangeListener = mock(AgentStatusChangeListener.class);
when(mockAgent.isFromLocalHost()).thenReturn(true);
when(mockAgentRuntimeInfo.agent()).thenReturn(mockAgent);
when(mockSysEnv.isAutoRegisterLocalAgentEnabled()).thenReturn(true);
when(mockAgentRuntimeInfo.isCancelled()).thenReturn(false);
doNothing().when(mockAgentRuntimeInfo).busy(mockAgentBuildingInfo);
AgentInstance agentInstance = createFromLiveAgent(mockAgentRuntimeInfo, mockSysEnv, mockAgentStatusChangeListener);
agentInstance.building(mockAgentBuildingInfo);
verify(mockAgentRuntimeInfo, atLeastOnce()).getRuntimeStatus();
verify(mockAgentRuntimeInfo).setRuntimeStatus(Building);
verify(mockAgentRuntimeInfo).busy(mockAgentBuildingInfo);
verify(mockAgentStatusChangeListener).onAgentStatusChange(agentInstance);
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentInstanceTest method shouldSyncIPWithConfig.
@Test
void shouldSyncIPWithConfig() {
AgentInstance originalAgentInstance = AgentInstance.createFromAgent(agent, systemEnvironment, mock(AgentStatusChangeListener.class));
originalAgentInstance.update(new AgentRuntimeInfo(new AgentIdentifier("CCeDev01", "10.18.5.2", "uuid2"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"));
assertThat(originalAgentInstance.getAgent()).isEqualTo(new Agent("uuid2", "CCeDev01", "10.18.5.2"));
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentInstanceTest method shouldNotMatchJobPlanIfTheAgentIsElasticAndJobHasResourcesDefined.
@Test
void shouldNotMatchJobPlanIfTheAgentIsElasticAndJobHasResourcesDefined() {
Agent agent = new Agent("uuid", "hostname", "11.1.1.1", singletonList("r1"));
agent.setElasticAgentId("elastic-agent-id-1");
String elasticPluginId = "elastic-plugin-id-1";
agent.setElasticPluginId(elasticPluginId);
AgentInstance agentInstance = new AgentInstance(agent, REMOTE, mock(SystemEnvironment.class), null);
DefaultJobPlan jobPlan1 = new DefaultJobPlan();
jobPlan1.setResources(asList(new Resource("r1")));
List<JobPlan> jobPlans = asList(jobPlan1, new DefaultJobPlan());
assertThat(agentInstance.firstMatching(jobPlans)).isNull();
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentInstanceMother method idleWith.
public static AgentInstance idleWith(String uuid, String hostname, String ipAddress, String location, long space, String os, List<String> resourceList, String agentBootstrapperVersion, String agentVersion) {
Agent agent = new Agent(uuid, hostname, ipAddress);
agent.setResourcesFromList(resourceList);
AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(agent.getAgentIdentifier(), AgentRuntimeStatus.Idle, location, "cookie");
agentRuntimeInfo.idle();
agentRuntimeInfo.setUsableSpace(space);
agentRuntimeInfo.setOperatingSystem(os);
agentRuntimeInfo.updateAgentVersion(agentVersion);
agentRuntimeInfo.updateBootstrapperVersion(agentBootstrapperVersion);
AgentInstance agentInstance = createFromLiveAgent(agentRuntimeInfo, new SystemEnvironment(), mock(AgentStatusChangeListener.class));
agentInstance.idle();
agentInstance.update(agentRuntimeInfo);
agentInstance.syncAgentFrom(agent);
return agentInstance;
}
Aggregations