use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class BuildWorkArtifactUploadingTest method shouldReportUploadFailuresWhenTheyHappen.
@Test
public void shouldReportUploadFailuresWhenTheyHappen() throws Exception {
List<ArtifactPlan> artifactPlans = new ArrayList<>();
artifactPlans.add(new ArtifactPlan(ArtifactType.file, "**/*.png", "mypic"));
BuildAssignment buildAssigment = createAssignment(artifactPlans, new String[] { "logs/pic/pass.png", "logs/pic-1/pass.png" });
BuildWork work = new BuildWork(buildAssigment, systemEnvironment.consoleLogCharset());
GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub(new ArrayList<>(), new ArrayList<>(), new HttpServiceStub(), new URLService(), new ZipUtilThatRunsOutOfMemory());
AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, new FakeBuildRepositoryRemote(), manipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
List<UploadEntry> entries = manipulator.uploadEntries();
assertThat(entries.isEmpty(), is(true));
assertThat(manipulator.consoleOut(), containsString("Failed to upload [**/*.png]"));
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class BuildWorkEnvironmentVariablesTest method doWorkWithMaterials.
private EnvironmentVariableContext doWorkWithMaterials(Materials materials) throws IOException {
pipelineConfig.setMaterialConfigs(materials.convertToConfigs());
BuildAssignment buildAssigment = createAssignment(null);
BuildWork work = new BuildWork(buildAssigment, systemEnvironment.consoleLogCharset());
EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, new FakeBuildRepositoryRemote(), new GoArtifactsManipulatorStub(), new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension, null, null));
return environmentVariableContext;
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class BuildWorkEnvironmentVariablesTest method shouldUseSvnMaterialNameIfPresent.
@Test
public void shouldUseSvnMaterialNameIfPresent() throws IOException {
svnMaterial.setName(new CaseInsensitiveString("Cruise"));
pipelineConfig.setMaterialConfigs(new MaterialConfigs(svnMaterial.config()));
BuildAssignment buildAssigment = createAssignment(null);
BuildWork work = new BuildWork(buildAssigment, systemEnvironment.consoleLogCharset());
EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
new SystemEnvironment().setProperty("serviceUrl", "some_random_place");
AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, new FakeBuildRepositoryRemote(), new GoArtifactsManipulatorStub(), new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension, null, null));
assertThat(environmentVariableContext.getProperty("GO_REVISION_CRUISE"), is("3"));
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class BuildWorkEnvironmentVariablesTest method shouldMergeEnvironmentVariablesFromInitialContext.
@Test
public void shouldMergeEnvironmentVariablesFromInitialContext() throws IOException {
pipelineConfig.setMaterialConfigs(new MaterialConfigs());
BuildAssignment buildAssignment = createAssignment(new EnvironmentVariableContext("foo", "bar"));
BuildWork work = new BuildWork(buildAssignment, systemEnvironment.consoleLogCharset());
EnvironmentVariableContext environmentContext = new EnvironmentVariableContext();
AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
work.doWork(environmentContext, new AgentWorkContext(agentIdentifier, new FakeBuildRepositoryRemote(), new GoArtifactsManipulatorStub(), new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension, null, null));
assertEnvironmentContext(environmentContext, "foo", is("bar"));
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class BuildWorkEnvironmentVariablesTest method shouldSetUpP4ClientEnvironmentVariableEnvironmentContextCorrectly.
@Test
public void shouldSetUpP4ClientEnvironmentVariableEnvironmentContextCorrectly() {
new SystemEnvironment().setProperty("serviceUrl", "some_random_place");
BuildWork work = getBuildWorkWithP4MaterialRevision(p4Material);
EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, new FakeBuildRepositoryRemote(), new GoArtifactsManipulatorStub(), new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension, null, null));
assertThat(environmentVariableContext.getProperty("GO_REVISION"), is("10"));
assertThat(environmentVariableContext.getProperty("GO_SERVER_URL"), is("some_random_place"));
assertThat(environmentVariableContext.getProperty("GO_TRIGGER_USER"), is(TRIGGERED_BY_USER));
assertThat(environmentVariableContext.getProperty("GO_P4_CLIENT"), is(p4Material.clientName(dir)));
}
Aggregations