use of com.thoughtworks.go.remote.work.BuildWork in project gocd by gocd.
the class JobRunnerTest method getWork.
private BuildWork getWork(JobConfig jobConfig) {
CruiseConfig config = new BasicCruiseConfig();
config.server().setArtifactsDir("logs");
String stageName = "mingle";
String pipelineName = "pipeline1";
config.addPipeline(BasicPipelineConfigs.DEFAULT_GROUP, new PipelineConfig(new CaseInsensitiveString(pipelineName), new MaterialConfigs(), new StageConfig(new CaseInsensitiveString(stageName), new JobConfigs(jobConfig))));
String pipelineLabel = "100";
JobPlan jobPlan = JobInstanceMother.createJobPlan(jobConfig, new JobIdentifier(pipelineName, -2, pipelineLabel, stageName, "100", JOB_PLAN_NAME, 0L), new DefaultSchedulingContext());
jobPlan.setFetchMaterials(true);
jobPlan.setCleanWorkingDir(false);
List<Builder> builder = BuilderMother.createBuildersAssumingAllExecTasks(config, pipelineName, stageName, JOB_PLAN_NAME);
BuildAssignment buildAssignment = BuildAssignment.create(jobPlan, BuildCause.createWithEmptyModifications(), builder, new File(CruiseConfig.WORKING_BASE_DIR + pipelineName));
return new BuildWork(buildAssignment);
}
use of com.thoughtworks.go.remote.work.BuildWork in project gocd by gocd.
the class WorkAssignmentPerformanceLogger method retrievedWorkForAgent.
public void retrievedWorkForAgent(AgentRuntimeInfo agentRuntimeInfo, Work work, long retrieveWorkStartTime, long retrieveWorkEndTime) {
if (work == null || !(work instanceof BuildWork)) {
performanceLogger.log("WORK-NOWORK {} {} {}", agentRuntimeInfo.getIdentifier().getUuid(), retrieveWorkStartTime, retrieveWorkEndTime);
return;
}
BuildWork buildWork = (BuildWork) work;
performanceLogger.log("WORK-RETRIEVED {} {} {} {}", agentRuntimeInfo.getIdentifier().getUuid(), buildWork.identifierForLogging(), retrieveWorkStartTime, retrieveWorkEndTime);
}
use of com.thoughtworks.go.remote.work.BuildWork in project gocd by gocd.
the class JobInstanceStatusMonitorTest method shouldSendCancelMessageIfJobIsRescheduled.
@Test
public void shouldSendCancelMessageIfJobIsRescheduled() throws Exception {
AgentConfig agentConfig = AgentMother.remoteAgent();
configHelper.addAgent(agentConfig);
fixture.createPipelineWithFirstStageScheduled();
AgentRuntimeInfo info = AgentRuntimeInfo.fromServer(agentConfig, true, "location", 1000000l, "OS", false);
info.setCookie("cookie");
agentRemoteHandler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
buildAssignmentService.onTimer();
assertThat(agent.messages.size(), is(1));
assertThat(MessageEncoding.decodeWork(agent.messages.get(0).getData()), instanceOf(BuildWork.class));
BuildWork work = (BuildWork) MessageEncoding.decodeWork(agent.messages.get(0).getData());
BuildAssignment assignment = work.getAssignment();
final JobInstance instance = jobInstanceService.buildByIdWithTransitions(assignment.getJobIdentifier().getBuildId());
scheduleService.rescheduleJob(instance);
assertThat(agent.messages.size(), is(2));
assertThat(agent.messages.get(1).getAction(), is(Action.cancelBuild));
}
use of com.thoughtworks.go.remote.work.BuildWork in project gocd by gocd.
the class BuildAssignmentServiceIntegrationTest method shouldBeAbleToSerializeAndDeserializeBuildWork.
@Test
public void shouldBeAbleToSerializeAndDeserializeBuildWork() throws Exception {
Pipeline pipeline1 = instanceFactory.createPipelineInstance(evolveConfig, modifySomeFiles(evolveConfig), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
dbHelper.savePipelineWithStagesAndMaterials(pipeline1);
buildAssignmentService.onTimer();
BuildWork work = (BuildWork) buildAssignmentService.assignWorkToAgent(agent(AgentMother.localAgent()));
BuildWork deserialized = (BuildWork) SerializationTester.serializeAndDeserialize(work);
assertThat(deserialized.getAssignment().materialRevisions(), is(work.getAssignment().materialRevisions()));
assertThat(deserialized.getAssignment(), is(work.getAssignment()));
assertThat(deserialized, is(work));
}
use of com.thoughtworks.go.remote.work.BuildWork in project gocd by gocd.
the class BuildAssignmentServiceIntegrationTest method shouldCreateWorkWithFetchMaterialsFlagFromStageConfig.
@Test
public void shouldCreateWorkWithFetchMaterialsFlagFromStageConfig() throws Exception {
evolveConfig.getFirstStageConfig().setFetchMaterials(true);
Pipeline pipeline1 = instanceFactory.createPipelineInstance(evolveConfig, modifySomeFiles(evolveConfig), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
dbHelper.savePipelineWithStagesAndMaterials(pipeline1);
buildAssignmentService.onTimer();
BuildWork work = (BuildWork) buildAssignmentService.assignWorkToAgent(agent(AgentMother.localAgent()));
assertThat("should have set fetchMaterials on assignment", work.getAssignment().shouldFetchMaterials(), is(true));
}
Aggregations