use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentInstanceTest method shouldBeAbleToDenyAgentThatIsRunningCancelledJob.
@Test
public void shouldBeAbleToDenyAgentThatIsRunningCancelledJob() {
AgentConfig config = new AgentConfig("UUID", "A", "127.0.0.1");
AgentInstance agent = new AgentInstance(config, LOCAL, systemEnvironment, mock(AgentStatusChangeListener.class));
agent.cancel();
AgentBuildingInfo cancelled = agent.getBuildingInfo();
assertThat(agent.canDisable(), is(true));
agent.deny();
assertThat(config.isDisabled(), is(true));
assertThat(agent.getStatus(), is(AgentStatus.Disabled));
assertThat(agent.getBuildingInfo(), is(cancelled));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentInstanceTest method shouldNotMatchJobPlanIfTheAgentWasLaunchedByADifferentPluginFromThatConfiguredForTheJob.
@Test
public void shouldNotMatchJobPlanIfTheAgentWasLaunchedByADifferentPluginFromThatConfiguredForTheJob() {
AgentConfig agentConfig = new AgentConfig("uuid");
agentConfig.setElasticAgentId("elastic-agent-id-1");
String elasticPluginId = "elastic-plugin-id-1";
agentConfig.setElasticPluginId(elasticPluginId);
AgentInstance agentInstance = new AgentInstance(agentConfig, REMOTE, mock(SystemEnvironment.class), null);
DefaultJobPlan jobPlan1 = new DefaultJobPlan();
jobPlan1.setElasticProfile(new ElasticProfile("foo", "elastic-plugin-id-2"));
List<JobPlan> jobPlans = asList(jobPlan1, new DefaultJobPlan());
assertThat(agentInstance.firstMatching(jobPlans), is(nullValue()));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentInstanceTest method shouldSetAgentToIdleWhenItIsApproved.
@Test
public void shouldSetAgentToIdleWhenItIsApproved() {
AgentInstance pending = AgentInstanceMother.pending();
AgentConfig config = new AgentConfig(pending.getUuid(), pending.getHostname(), pending.getIpAddress());
pending.syncConfig(config);
AgentStatus status = pending.getStatus();
assertThat(status, is(AgentStatus.Idle));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentInstanceTest method shouldNotReturnAJobWithMismatchedUuid.
@Test
public void shouldNotReturnAJobWithMismatchedUuid() throws Exception {
AgentConfig config = agentConfig("linux, mercurial");
AgentInstance agentInstance = new AgentInstance(config, LOCAL, systemEnvironment, null);
final JobPlan job = jobPlan("pipeline-name", "job-name", "linux", config.getUuid() + "-ensure-doesn't-match");
JobPlan matchingJob = agentInstance.firstMatching(new ArrayList<JobPlan>() {
{
add(job);
}
});
assertThat(matchingJob, is(nullValue()));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentInstanceTest method shouldDenyAgentWhenAgentIsDeniedInConfigFile.
@Test
public void shouldDenyAgentWhenAgentIsDeniedInConfigFile() throws Exception {
AgentInstance original = AgentInstance.createFromConfig(agentConfig, systemEnvironment, mock(AgentStatusChangeListener.class));
original.update(buildingRuntimeInfo());
AgentConfig newAgentConfig = new AgentConfig(agentConfig.getUuid(), agentConfig.getHostname(), agentConfig.getIpAddress());
newAgentConfig.disable();
original.syncConfig(newAgentConfig);
assertThat(original.getStatus(), is(AgentStatus.Disabled));
}
Aggregations