use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentInstanceTest method shouldNotMatchJobPlanIfJobRequiresElasticAgent_MatchingIsManagedByBuildAssignmentService.
@Test
public void shouldNotMatchJobPlanIfJobRequiresElasticAgent_MatchingIsManagedByBuildAssignmentService() {
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", elasticPluginId));
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 DefaultSchedulingContextTest method shouldOnlyFindAgentsThatMatchResourcesSpecified.
@Test
public void shouldOnlyFindAgentsThatMatchResourcesSpecified() throws Exception {
AgentConfig linux = agent("uuid1", "linux");
AgentConfig windows = agent("uuid2", "windows");
Agents matchingAgents = new Agents(linux, windows);
DefaultSchedulingContext context = new DefaultSchedulingContext("approved", matchingAgents);
assertThat(context.findAgentsMatching(resources("linux")), is(new Agents(linux)));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class DefaultSchedulingContextTest method shouldFindNoAgentsIfNoneMatch.
@Test
public void shouldFindNoAgentsIfNoneMatch() throws Exception {
AgentConfig linux = agent("uuid1", "linux");
AgentConfig windows = agent("uuid2", "windows");
Agents matchingAgents = new Agents(linux, windows);
DefaultSchedulingContext context = new DefaultSchedulingContext("approved", matchingAgents);
assertThat(context.findAgentsMatching(resources("macosx")), is(new Agents()));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class ElasticAgentRequestProcessorTest method shouldProcessDeleteAgentRequest.
@Test
public void shouldProcessDeleteAgentRequest() throws Exception {
AgentMetadata agent = new AgentMetadata("foo", null, null, null);
DefaultGoApiRequest goPluginApiRequest = new DefaultGoApiRequest(PROCESS_DELETE_AGENTS, "1.0", pluginIdentifier);
goPluginApiRequest.setRequestBody(extension.getElasticAgentMessageConverter(goPluginApiRequest.apiVersion()).listAgentsResponseBody(Arrays.asList(agent)));
AgentInstance agentInstance = AgentInstance.createFromConfig(new AgentConfig("uuid"), null);
when(agentService.findElasticAgent("foo", "docker")).thenReturn(agentInstance);
processor.process(pluginDescriptor, goPluginApiRequest);
verify(agentConfigService).deleteAgents(processor.usernameFor(pluginDescriptor), agentInstance);
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentRuntimeInfoTest method shouldNotUpdateStatusWhenOldValueIsEqualToNewValue.
@Test
public void shouldNotUpdateStatusWhenOldValueIsEqualToNewValue() {
AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromServer(new AgentConfig("uuid", "localhost", "176.19.4.1"), true, "/var/lib", 0L, "linux", false);
assertThat(agentRuntimeInfo.getRuntimeStatus(), is(AgentRuntimeStatus.Idle));
AgentRuntimeStatus.ChangeListener listener = mock(AgentRuntimeStatus.ChangeListener.class);
agentRuntimeInfo.setRuntimeStatus(AgentRuntimeStatus.Idle, listener);
verify(listener, never()).statusUpdateRequested(any(AgentRuntimeInfo.class), any(AgentRuntimeStatus.class));
assertThat(agentRuntimeInfo.getRuntimeStatus(), is(AgentRuntimeStatus.Idle));
}
Aggregations