Search in sources :

Example 86 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.

the class BuildWorkArtifactUploadingTest method shouldFailBuildWhenSourceDirectoryDoesNotExist.

@Test
public void shouldFailBuildWhenSourceDirectoryDoesNotExist() throws Exception {
    List<ArtifactPlan> artifactPlans = new ArrayList<>();
    artifactPlans.add(new ArtifactPlan(ArtifactType.file, "not-Exist-Folder", "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, systemEnvironment.consoleLogCharset());
    GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
    BuildRepositoryRemoteStub repository = new BuildRepositoryRemoteStub();
    AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
    work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, repository, manipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
    List<UploadEntry> entries = manipulator.uploadEntries();
    assertThat(entries.size(), is(0));
    assertThat(repository.states, containsResult(JobState.Building));
    assertThat(repository.states, containsResult(JobState.Completing));
    assertThat(repository.results, containsResult(JobResult.Failed));
    assertThat(manipulator.consoleOut(), printedRuleDoesNotMatchFailure(buildWorkingDirectory.getPath(), "not-Exist-Folder"));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) UploadEntry(com.thoughtworks.go.matchers.UploadEntry) ArrayList(java.util.ArrayList) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 87 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo 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]"));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) UploadEntry(com.thoughtworks.go.matchers.UploadEntry) URLService(com.thoughtworks.go.util.URLService) ArrayList(java.util.ArrayList) FakeBuildRepositoryRemote(com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 88 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo 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;
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) FakeBuildRepositoryRemote(com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext)

Example 89 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo 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"));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) FakeBuildRepositoryRemote(com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 90 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo 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"));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) FakeBuildRepositoryRemote(com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Aggregations

AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)123 Test (org.junit.Test)101 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)34 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)26 File (java.io.File)16 AgentInstruction (com.thoughtworks.go.remote.AgentInstruction)13 StringContains.containsString (org.hamcrest.core.StringContains.containsString)13 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)12 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)11 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)10 AgentBuildingInfo (com.thoughtworks.go.server.service.AgentBuildingInfo)10 ArrayList (java.util.ArrayList)10 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)9 AgentInstance (com.thoughtworks.go.domain.AgentInstance)7 Before (org.junit.Before)7 Expectations (org.jmock.Expectations)4 RunIf (com.googlecode.junit.ext.RunIf)3 AgentConfig (com.thoughtworks.go.config.AgentConfig)3 Date (java.util.Date)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3