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));
}
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));
}
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)))));
}
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();
}
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"));
}
Aggregations