Search in sources :

Example 26 with AgentIdentifier

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));
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) GoConfigDao(com.thoughtworks.go.config.GoConfigDao) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentConfig(com.thoughtworks.go.config.AgentConfig) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) AgentsUpdateCommand(com.thoughtworks.go.config.update.AgentsUpdateCommand) Test(org.junit.Test)

Example 27 with AgentIdentifier

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);
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 28 with AgentIdentifier

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);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) UpstreamPipelineResolver(com.thoughtworks.go.server.service.UpstreamPipelineResolver) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) FakeWork(com.thoughtworks.go.work.FakeWork) Before(org.junit.Before)

Example 29 with AgentIdentifier

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));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 30 with AgentIdentifier

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"));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Aggregations

AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)73 Test (org.junit.Test)53 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)31 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)11 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)10 File (java.io.File)9 Before (org.junit.Before)8 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)7 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)6 AgentInstance (com.thoughtworks.go.domain.AgentInstance)4 AgentInstruction (com.thoughtworks.go.remote.AgentInstruction)4 NoWork (com.thoughtworks.go.remote.work.NoWork)4 Work (com.thoughtworks.go.remote.work.Work)4 AgentConfig (com.thoughtworks.go.config.AgentConfig)3 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)3 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)2 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)2 AgentCookie (com.thoughtworks.go.server.domain.AgentCookie)2 AgentInstances (com.thoughtworks.go.server.domain.AgentInstances)2