Search in sources :

Example 6 with BuildAssignment

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);
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) Builder(com.thoughtworks.go.domain.builder.Builder) BuildAssignment(com.thoughtworks.go.remote.work.BuildAssignment) BuildWork(com.thoughtworks.go.remote.work.BuildWork) File(java.io.File)

Example 7 with 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));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Message(com.thoughtworks.go.websocket.Message) JobInstance(com.thoughtworks.go.domain.JobInstance) BuildAssignment(com.thoughtworks.go.remote.work.BuildAssignment) BuildWork(com.thoughtworks.go.remote.work.BuildWork)

Aggregations

BuildAssignment (com.thoughtworks.go.remote.work.BuildAssignment)7 BuildWork (com.thoughtworks.go.remote.work.BuildWork)6 File (java.io.File)4 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)3 AgentConfig (com.thoughtworks.go.config.AgentConfig)2 ArtifactStores (com.thoughtworks.go.config.ArtifactStores)2 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)2 JobInstance (com.thoughtworks.go.domain.JobInstance)2 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)2 Message (com.thoughtworks.go.websocket.Message)2 IOException (java.io.IOException)2 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1 Materials (com.thoughtworks.go.config.materials.Materials)1 JobPlan (com.thoughtworks.go.domain.JobPlan)1 Builder (com.thoughtworks.go.domain.builder.Builder)1 Work (com.thoughtworks.go.remote.work.Work)1 BuildComposer (com.thoughtworks.go.server.domain.BuildComposer)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1