Search in sources :

Example 1 with MemoryFlowChunk

use of org.jenkinsci.plugins.workflow.graphanalysis.MemoryFlowChunk in project blueocean-plugin by jenkinsci.

the class PipelineNodeTest method testBlockedStep.

@Test
public void testBlockedStep() throws Exception {
    String script = "node {\n" + "    stage(\"one\"){\n" + "        echo '1'\n" + "    }\n" + "    stage(\"two\") {\n" + "            node('blah'){\n" + "                sh 'blah'\n" + "            }\n" + "        }\n" + "\n" + "}";
    WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");
    job1.setDefinition(new CpsFlowDefinition(script, false));
    QueueTaskFuture<WorkflowRun> runQueueTaskFuture = job1.scheduleBuild2(0);
    WorkflowRun run = runQueueTaskFuture.getStartCondition().get();
    CpsFlowExecution e = (CpsFlowExecution) run.getExecutionPromise().get();
    if (waitForItemToAppearInQueue(1000 * 300)) {
        // 5 min timeout
        List<FlowNode> nodes = getStages(NodeGraphBuilder.NodeGraphBuilderFactory.getInstance(run));
        if (nodes.size() == 2) {
            List<Map> stepsResp = get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/11/steps/", List.class);
            assertEquals(1, stepsResp.size());
            assertEquals("QUEUED", stepsResp.get(0).get("state"));
        }
    } else {
        // Avoid spurious code coverage failures
        final FlowNode node = new FlowNode(null, "fake") {

            @Override
            protected String getTypeDisplayName() {
                return "fake";
            }
        };
        final MemoryFlowChunk chunk = new MemoryFlowChunk() {

            @Override
            public FlowNode getFirstNode() {
                return node;
            }
        };
        new PipelineStepVisitor.LocalAtomNode(chunk, "fake");
    }
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) MemoryFlowChunk(org.jenkinsci.plugins.workflow.graphanalysis.MemoryFlowChunk) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) Map(java.util.Map) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) CpsFlowExecution(org.jenkinsci.plugins.workflow.cps.CpsFlowExecution) FlowNode(org.jenkinsci.plugins.workflow.graph.FlowNode) Test(org.junit.Test)

Aggregations

Map (java.util.Map)1 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)1 CpsFlowExecution (org.jenkinsci.plugins.workflow.cps.CpsFlowExecution)1 FlowNode (org.jenkinsci.plugins.workflow.graph.FlowNode)1 MemoryFlowChunk (org.jenkinsci.plugins.workflow.graphanalysis.MemoryFlowChunk)1 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)1 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)1 Test (org.junit.Test)1