use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentInstanceTest method shouldSetAgentToIdleWhenItIsApproved.
@Test
void shouldSetAgentToIdleWhenItIsApproved() {
AgentInstance pendingAgentInstance = AgentInstanceMother.pending();
Agent agent = new Agent(pendingAgentInstance.getUuid(), pendingAgentInstance.getHostname(), pendingAgentInstance.getIpAddress());
pendingAgentInstance.syncAgentFrom(agent);
AgentStatus status = pendingAgentInstance.getStatus();
assertThat(status).isEqualTo(AgentStatus.Idle);
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentInstanceTest method shouldNotMatchJobPlanIfJobRequiresElasticAgent_MatchingIsManagedByBuildAssignmentService.
@Test
void shouldNotMatchJobPlanIfJobRequiresElasticAgent_MatchingIsManagedByBuildAssignmentService() {
Agent agent = new Agent("uuid");
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.setElasticProfile(new ElasticProfile("foo", "prod-cluster"));
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 AgentInstanceTest method shouldNotReturnAJobWithMismatchedUuid.
@Test
void shouldNotReturnAJobWithMismatchedUuid() {
Agent agent = agent("linux, mercurial");
AgentInstance agentInstance = new AgentInstance(agent, LOCAL, systemEnvironment, null);
final JobPlan job = jobPlan("pipeline-name", "job-name", "linux", agent.getUuid() + "-ensure-doesn't-match");
JobPlan matchingJob = agentInstance.firstMatching(new ArrayList<JobPlan>() {
{
add(job);
}
});
assertThat(matchingJob).isNull();
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentInstanceTest method shouldBeAbleToDenyAgentThatIsRunningCancelledJob.
@Test
void shouldBeAbleToDenyAgentThatIsRunningCancelledJob() {
Agent agent = new Agent("UUID", "A", "127.0.0.1");
AgentInstance agentInstance = new AgentInstance(agent, LOCAL, systemEnvironment, mock(AgentStatusChangeListener.class));
agentInstance.cancel();
AgentBuildingInfo cancelled = agentInstance.getBuildingInfo();
assertThat(agentInstance.canDisable()).isTrue();
agentInstance.deny();
assertThat(agent.isDisabled()).isTrue();
assertThat(agentInstance.getStatus()).isEqualTo(AgentStatus.Disabled);
assertThat(agentInstance.getBuildingInfo()).isEqualTo(cancelled);
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentInstanceTest method shouldNotMatchJobPlanIfTheAgentWasLaunchedByADifferentPluginFromThatConfiguredForTheJob.
@Test
void shouldNotMatchJobPlanIfTheAgentWasLaunchedByADifferentPluginFromThatConfiguredForTheJob() {
Agent agent = new Agent("uuid");
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.setElasticProfile(new ElasticProfile("foo", "prod-cluster"));
List<JobPlan> jobPlans = asList(jobPlan1, new DefaultJobPlan());
assertThat(agentInstance.firstMatching(jobPlans)).isNull();
}
Aggregations