use of com.thoughtworks.go.remote.work.BuildAssignment 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.BuildAssignment 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));
}
Aggregations