Search in sources :

Example 6 with BuildWork

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);
}
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 BuildWork

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);
}
Also used : BuildWork(com.thoughtworks.go.remote.work.BuildWork)

Example 8 with BuildWork

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));
}
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)

Example 9 with BuildWork

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));
}
Also used : BuildWork(com.thoughtworks.go.remote.work.BuildWork)

Example 10 with BuildWork

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));
}
Also used : BuildWork(com.thoughtworks.go.remote.work.BuildWork)

Aggregations

BuildWork (com.thoughtworks.go.remote.work.BuildWork)11 BuildAssignment (com.thoughtworks.go.remote.work.BuildAssignment)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 Builder (com.thoughtworks.go.domain.builder.Builder)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 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)1 JobPlan (com.thoughtworks.go.domain.JobPlan)1 FetchArtifactBuilder (com.thoughtworks.go.domain.builder.FetchArtifactBuilder)1 Work (com.thoughtworks.go.remote.work.Work)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1