use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class ElasticAgentRequestProcessorTest method shouldProcessDisableAgentRequest.
@Test
public void shouldProcessDisableAgentRequest() throws Exception {
AgentMetadata agent = new AgentMetadata("foo", null, null, null);
DefaultGoApiRequest goPluginApiRequest = new DefaultGoApiRequest(PROCESS_DISABLE_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).disableAgents(processor.usernameFor(pluginDescriptor), agentInstance);
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class DefaultSchedulingContext method permittedAgent.
public SchedulingContext permittedAgent(String permittedAgentUuid) {
Agents permitted = new Agents();
for (AgentConfig agent : agents) {
if (agent.getUuid().equals(permittedAgentUuid)) {
permitted.add(agent);
}
}
DefaultSchedulingContext context = new DefaultSchedulingContext(approvedBy, permitted, profiles);
context.variables = variables.overrideWith(new EnvironmentVariablesConfig());
context.rerun = rerun;
return context;
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class UpdateAgentStatusTest method setUp.
@Before
public void setUp() throws Exception {
dbHelper.onSetUp();
configHelper.onSetUp();
configHelper.usingCruiseConfigDao(goConfigDao);
preCondition = new PipelineWithTwoStages(materialRepository, transactionTemplate);
preCondition.usingConfigHelper(configHelper).usingDbHelper(dbHelper).onSetUp();
agentService.clearAll();
agentService.requestRegistration(new Username("bob"), AgentRuntimeInfo.fromServer(new AgentConfig(agentId, "CCEDev01", "10.81.2.1"), false, "/var/lib", 0L, "linux", false));
agentService.approve(agentId);
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentConfigServiceTest method shouldEnableMultipleAgents.
@Test
public void shouldEnableMultipleAgents() {
AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromAgent(new AgentIdentifier("remote-host", "50.40.30.20", "abc"), AgentRuntimeStatus.Unknown, "cookie", false);
AgentInstance pending = AgentInstance.createFromLiveAgent(agentRuntimeInfo, new SystemEnvironment());
AgentConfig agentConfig = new AgentConfig("UUID2", "remote-host", "50.40.30.20");
agentConfig.disable();
AgentInstance fromConfigFile = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment());
when(goConfigService.hasAgent(fromConfigFile.getUuid())).thenReturn(true);
when(goConfigService.hasAgent(pending.getUuid())).thenReturn(false);
agentConfigService.enableAgents(Username.ANONYMOUS, pending, fromConfigFile);
GoConfigDao.CompositeConfigCommand command = new GoConfigDao.CompositeConfigCommand(new AgentConfigService.AddAgentCommand(pending.agentConfig()), new AgentConfigService.UpdateAgentApprovalStatus("UUID2", false));
ArgumentCaptor<AgentsUpdateCommand> captor = ArgumentCaptor.forClass(AgentsUpdateCommand.class);
verify(goConfigService).updateConfig(captor.capture(), eq(Username.ANONYMOUS));
AgentsUpdateCommand updateCommand = captor.getValue();
assertThat(ReflectionUtil.getField(updateCommand, "command"), is(command));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentServiceTest method shouldUnderstandFilteringAgentListBasedOnUuid.
@Test
public void shouldUnderstandFilteringAgentListBasedOnUuid() {
AgentInstance instance1 = AgentInstance.createFromLiveAgent(AgentRuntimeInfo.fromServer(new AgentConfig("uuid-1", "host-1", "192.168.1.2"), true, "/foo/bar", 100l, "linux", false), new SystemEnvironment());
AgentInstance instance3 = AgentInstance.createFromLiveAgent(AgentRuntimeInfo.fromServer(new AgentConfig("uuid-3", "host-3", "192.168.1.4"), true, "/baz/quux", 300l, "linux", false), new SystemEnvironment());
when(agentInstances.filter(Arrays.asList("uuid-1", "uuid-3"))).thenReturn(Arrays.asList(instance1, instance3));
AgentsViewModel agents = agentService.filter(Arrays.asList("uuid-1", "uuid-3"));
AgentViewModel view1 = new AgentViewModel(instance1);
AgentViewModel view2 = new AgentViewModel(instance3);
assertThat(agents, is(new AgentsViewModel(view1, view2)));
verify(agentInstances).filter(Arrays.asList("uuid-1", "uuid-3"));
}
Aggregations