use of com.thoughtworks.go.remote.AgentIdentifier 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.remote.AgentIdentifier in project gocd by gocd.
the class AgentRemoteHandlerTest method reportCompleted.
@Test
public void reportCompleted() throws Exception {
AgentRuntimeInfo info = new AgentRuntimeInfo(new AgentIdentifier("HostName", "ipAddress", "uuid"), AgentRuntimeStatus.Idle, null, null, false);
JobIdentifier jobIdentifier = new JobIdentifier();
handler.process(agent, new Message(Action.reportCompleted, MessageEncoding.encodeData(new Report(info, jobIdentifier, JobResult.Passed))));
verify(remote).reportCompleted(info, jobIdentifier, JobResult.Passed);
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class JobRunnerTest method setUp.
@Before
public void setUp() throws Exception {
runner = new JobRunner();
work = new FakeWork();
consoleOut = new ArrayList<>();
statesAndResult = new ArrayList<>();
properties = new ArrayList<>();
agentIdentifier = new AgentIdentifier("localhost", "127.0.0.1", "uuid");
new SystemEnvironment().setProperty("serviceUrl", SERVER_URL);
resolver = mock(UpstreamPipelineResolver.class);
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class AgentInstanceTest method shouldChangeIpWhenSameAgentIpChanged.
@Test
public void shouldChangeIpWhenSameAgentIpChanged() throws Exception {
AgentInstance instance = AgentInstance.createFromConfig(agentConfig, systemEnvironment);
AgentRuntimeInfo info = new AgentRuntimeInfo(new AgentIdentifier("ccedev01", "10.18.7.52", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
assertThat(instance.isIpChangeRequired(info.getIpAdress()), is(true));
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class AgentInstanceTest method shouldUpdateIPForPhysicalMachineWhenUpChanged.
@Test
public void shouldUpdateIPForPhysicalMachineWhenUpChanged() throws Exception {
AgentInstance agentInstance = AgentInstance.createFromConfig(agentConfig, systemEnvironment);
agentInstance.update(new AgentRuntimeInfo(new AgentIdentifier("ccedev01", "10.18.7.52", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false));
assertThat(agentInstance.agentConfig().getIpAddress(), is("10.18.7.52"));
}
Aggregations