Search in sources :

Example 1 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class AgentInstanceTest method shouldNotChangePendingAgentIpAddress.

@Test
public void shouldNotChangePendingAgentIpAddress() throws Exception {
    AgentInstance pending = AgentInstance.createFromLiveAgent(new AgentRuntimeInfo(agentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), systemEnvironment);
    AgentRuntimeInfo info = new AgentRuntimeInfo(new AgentIdentifier("ccedev01", "10.18.7.52", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
    assertThat(pending.isIpChangeRequired(info.getIpAdress()), is(false));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 2 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class AgentHTTPClientController method retrieveWork.

void retrieveWork() {
    AgentIdentifier agentIdentifier = agentIdentifier();
    LOG.debug("[Agent Loop] {} is checking for work from Go", agentIdentifier);
    Work work;
    try {
        getAgentRuntimeInfo().idle();
        work = server.getWork(getAgentRuntimeInfo());
        if (!(work instanceof NoWork)) {
            LOG.debug("[Agent Loop] Got work from server: [{}]", work.description());
        }
        runner = new JobRunner();
        runner.run(work, agentIdentifier, server, manipulator, getAgentRuntimeInfo(), packageRepositoryExtension, scmExtension, taskExtension);
    } catch (UnregisteredAgentException e) {
        LOG.warn("[Agent Loop] Invalid agent certificate with fingerprint {}. Registering with server on next iteration.", e.getUuid());
        sslInfrastructureService.invalidateAgentCertificate();
    } finally {
        getAgentRuntimeInfo().idle();
    }
}
Also used : UnregisteredAgentException(com.thoughtworks.go.domain.exception.UnregisteredAgentException) Work(com.thoughtworks.go.remote.work.Work) NoWork(com.thoughtworks.go.remote.work.NoWork) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) NoWork(com.thoughtworks.go.remote.work.NoWork)

Example 3 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class DependencyMaterialAgentTest method shouldBeCreatedByAgentFactory.

@Test
public void shouldBeCreatedByAgentFactory() {
    MaterialAgentFactory factory = new MaterialAgentFactory(ProcessOutputStreamConsumer.inMemoryConsumer(), new File("blah"), new AgentIdentifier("", "", ""), null, null);
    MaterialAgent createdAgent = factory.createAgent(materialRevision("pipeline-name", 1, "pipeline-label", "stage-name", 1));
    assertThat(createdAgent, instanceOf(DependencyMaterialAgent.class));
}
Also used : MaterialAgentFactory(com.thoughtworks.go.domain.materials.MaterialAgentFactory) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) MaterialAgent(com.thoughtworks.go.domain.materials.MaterialAgent) File(java.io.File) Test(org.junit.Test)

Example 4 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class ReportTest method encodeAndDecodeAsMessageData.

@Test
public void encodeAndDecodeAsMessageData() throws Exception {
    AgentRuntimeInfo info = new AgentRuntimeInfo(new AgentIdentifier("HostName", "ipAddress", "uuid"), AgentRuntimeStatus.Idle, null, null, true);
    JobIdentifier jobIdentifier = new JobIdentifier("pipeline", 1, "pipelinelabel", "stagename", "1", "job", 1L);
    Report report = new Report(info, jobIdentifier, JobResult.Passed);
    assertThat(MessageEncoding.decodeData(MessageEncoding.encodeData(report), Report.class), is(report));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Test(org.junit.Test)

Example 5 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class BuildWorkArtifactUploadingTest method shouldUploadFolderWhenTrimedPathDirectMatch.

@Test
public void shouldUploadFolderWhenTrimedPathDirectMatch() throws Exception {
    ArtifactPlans artifactPlans = new ArtifactPlans();
    artifactPlans.add(new ArtifactPlan("logs/pic-1 ", "mypic"));
    BuildAssignment buildAssigment = createAssignment(artifactPlans, new String[] { "logs/pic-1/fail.png", "logs/pic-1/pass.png", "logs/pic-2/cancel.png", "logs/pic-2/complete.png", "README" });
    BuildWork work = new BuildWork(buildAssigment);
    GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
    AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
    work.doWork(agentIdentifier, new FakeBuildRepositoryRemote(), manipulator, environmentVariableContext, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension);
    List<UploadEntry> entries = manipulator.uploadEntries();
    assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-1"), "mypic"));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) UploadEntry(com.thoughtworks.go.matchers.UploadEntry) FakeBuildRepositoryRemote(com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) File(java.io.File) 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