Search in sources :

Example 16 with AgentIdentifier

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

the class AgentServiceIntegrationTest method shouldUpdateAgentStatus.

@Test
public void shouldUpdateAgentStatus() throws Exception {
    AgentInstance instance = AgentInstanceMother.building();
    AgentService agentService = getAgentService(new AgentInstances(null, new SystemEnvironment(), instance));
    AgentInstances agents = agentService.findRegisteredAgents();
    String uuid = instance.agentConfig().getUuid();
    assertThat(agents.findAgentAndRefreshStatus(uuid).getStatus(), is(AgentStatus.Building));
    AgentIdentifier agentIdentifier = instance.agentConfig().getAgentIdentifier();
    String cookie = agentService.assignCookie(agentIdentifier);
    agentService.updateRuntimeInfo(new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), cookie, false));
    agents = agentService.findRegisteredAgents();
    assertThat(agents.findAgentAndRefreshStatus(uuid).getStatus(), is(AgentStatus.Idle));
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) AgentInstances(com.thoughtworks.go.server.domain.AgentInstances) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 17 with AgentIdentifier

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

the class AgentSubprocessExecutionContextTest method shouldReturnDigestOfMaterialFingerprintConcatinatedWithAgentUUID.

@Test
public void shouldReturnDigestOfMaterialFingerprintConcatinatedWithAgentUUID() {
    AgentIdentifier agentIdentifier = mock(AgentIdentifier.class);
    String uuid = "agent-uuid";
    when(agentIdentifier.getUuid()).thenReturn(uuid);
    String fingerprint = "material-fingerprint";
    String workingDirectory = "working-folder-full-path";
    AgentSubprocessExecutionContext execCtx = new AgentSubprocessExecutionContext(agentIdentifier, workingDirectory);
    String workspaceName = execCtx.getProcessNamespace(fingerprint);
    assertThat(workspaceName, is(CachedDigestUtils.sha256Hex(fingerprint + uuid + workingDirectory)));
    assertThat(workspaceName.length(), is(64));
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 18 with AgentIdentifier

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

the class MaterialAgentFactoryTest method shouldCreateMaterialAgent_withAgentsUuidAsSubprocessExecutionContextNamespace.

@Test
public void shouldCreateMaterialAgent_withAgentsUuidAsSubprocessExecutionContextNamespace() {
    String agentUuid = "uuid-01783738";
    File workingDirectory = tempFiles.createUniqueFolder("");
    MaterialAgentFactory factory = new MaterialAgentFactory(new ProcessOutputStreamConsumer(new DevNull(), new DevNull()), workingDirectory, new AgentIdentifier("host", "1.1.1.1", agentUuid), packageRepositoryExtension, scmExtension);
    GitMaterial gitMaterial = new GitMaterial("http://foo", "master", "dest_folder");
    MaterialAgent agent = factory.createAgent(new MaterialRevision(gitMaterial));
    assertThat(agent, is(instanceOf(AbstractMaterialAgent.class)));
    SubprocessExecutionContext execCtx = (SubprocessExecutionContext) ReflectionUtil.getField(agent, "execCtx");
    assertThat(execCtx.getProcessNamespace("fingerprint"), is(CachedDigestUtils.sha256Hex(String.format("%s%s%s", "fingerprint", agentUuid, gitMaterial.workingdir(workingDirectory)))));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) DevNull(com.thoughtworks.go.util.command.DevNull) SubprocessExecutionContext(com.thoughtworks.go.config.materials.SubprocessExecutionContext) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) PackageMaterialAgent(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialAgent) PluggableSCMMaterialAgent(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialAgent) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) File(java.io.File) ProcessOutputStreamConsumer(com.thoughtworks.go.util.command.ProcessOutputStreamConsumer) Test(org.junit.Test)

Example 19 with AgentIdentifier

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

the class BuildWorkArtifactFetchingTest method setUp.

@Before
public void setUp() throws IOException {
    buildWorkingDirectory = new File("tmp");
    PipelineConfigMother.createPipelineConfig(PIPELINE_NAME, STAGE_NAME, JOB_NAME);
    agentIdentifier = new AgentIdentifier("localhost", "127.0.0.1", AGENT_UUID);
    buildRepository = new com.thoughtworks.go.remote.work.BuildRepositoryRemoteStub();
    environmentVariableContext = new EnvironmentVariableContext();
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) File(java.io.File) Before(org.junit.Before)

Example 20 with AgentIdentifier

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

the class BuildWorkArtifactUploadingTest method shouldUploadEachMatchedFile.

@Test
public void shouldUploadEachMatchedFile() throws Exception {
    ArtifactPlans artifactPlans = new ArtifactPlans();
    artifactPlans.add(new ArtifactPlan("**/*.png", "mypic"));
    BuildAssignment buildAssigment = createAssignment(artifactPlans, new String[] { "logs/pic/fail.png", "logs/pic/pass.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/pass.png"), "mypic/logs/pic"));
    assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic/fail.png"), "mypic/logs/pic"));
}
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