use of org.jenkinsci.plugins.workflow.support.visualization.table.FlowGraphTable in project blueocean-plugin by jenkinsci.
the class PipelineNodeTest method getPipelineJobRunNodeTest.
@Test
public void getPipelineJobRunNodeTest() throws Exception {
WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");
job1.setDefinition(new CpsFlowDefinition("stage 'build'\n" + "node{\n" + " echo \"Building...\"\n" + "}\n" + "\n" + "stage 'test'\n" + "parallel 'unit':{\n" + " node{\n" + " echo \"Unit testing...\"\n" + " }\n" + "},'integration':{\n" + " node{\n" + " echo \"Integration testing...\"\n" + " }\n" + "}, 'ui':{\n" + " node{\n" + " echo \"UI testing...\"\n" + " }\n" + "}\n" + "\n" + "stage 'deploy'\n" + "node{\n" + " echo \"Deploying\"\n" + "}"));
WorkflowRun b1 = job1.scheduleBuild2(0).get();
j.assertBuildStatusSuccess(b1);
FlowGraphTable nodeGraphTable = new FlowGraphTable(b1.getExecution());
nodeGraphTable.build();
List<FlowNode> nodes = getStages(nodeGraphTable);
List<FlowNode> parallelNodes = getParallelNodes(nodeGraphTable);
Assert.assertEquals(6, nodes.size());
Assert.assertEquals(3, parallelNodes.size());
// get all nodes for pipeline1
List<Map> resp = get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/", List.class);
Assert.assertEquals(nodes.size(), resp.size());
//Get a node detail
FlowNode n = nodes.get(0);
Map node = get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/" + n.getId());
List<Map> edges = (List<Map>) node.get("edges");
Assert.assertEquals(n.getId(), node.get("id"));
Assert.assertEquals(getNodeName(n), node.get("displayName"));
Assert.assertEquals("SUCCESS", node.get("result"));
Assert.assertEquals(1, edges.size());
Assert.assertEquals(nodes.get(1).getId(), edges.get(0).get("id"));
//Get a parllel node detail
node = get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/" + parallelNodes.get(0).getId());
n = parallelNodes.get(0);
edges = (List<Map>) node.get("edges");
Assert.assertEquals(n.getId(), node.get("id"));
Assert.assertEquals(getNodeName(n), node.get("displayName"));
Assert.assertEquals("SUCCESS", node.get("result"));
Assert.assertEquals(1, edges.size());
Assert.assertEquals(nodes.get(nodes.size() - 1).getId(), edges.get(0).get("id"));
}
use of org.jenkinsci.plugins.workflow.support.visualization.table.FlowGraphTable in project blueocean-plugin by jenkinsci.
the class PipelineNodeTest method getPipelineWihNodesAllStepsTest.
@Test
public void getPipelineWihNodesAllStepsTest() throws Exception {
WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");
job1.setDefinition(new CpsFlowDefinition("stage 'build'\n" + "node{\n" + " sh \"echo Building...\"\n" + "}\n" + "\n" + "stage 'test'\n" + "parallel 'unit':{\n" + " node{\n" + " echo \"Unit testing...\"\n" + " sh \"echo Tests running\"\n" + " sh \"echo Tests completed\"\n" + " }\n" + "},'integration':{\n" + " node{\n" + " echo \"Integration testing...\"\n" + " }\n" + "}, 'ui':{\n" + " node{\n" + " echo \"UI testing...\"\n" + " }\n" + "}\n" + "\n" + "node{\n" + " echo \"Done Testing\"\n" + "}" + "\n" + "stage 'deploy'\n" + "node{\n" + " echo \"Deploying\"\n" + "}" + "\n" + "stage 'deployToProd'\n" + "node{\n" + " echo \"Deploying to production\"\n" + "}"));
WorkflowRun b1 = job1.scheduleBuild2(0).get();
j.assertBuildStatusSuccess(b1);
FlowGraphTable nodeGraphTable = new FlowGraphTable(b1.getExecution());
nodeGraphTable.build();
List<FlowNode> nodes = getStages(nodeGraphTable);
List<FlowNode> parallelNodes = getParallelNodes(nodeGraphTable);
Assert.assertEquals(7, nodes.size());
Assert.assertEquals(3, parallelNodes.size());
List<Map> resp = get("/organizations/jenkins/pipelines/pipeline1/runs/1/steps/", List.class);
Assert.assertEquals(9, resp.size());
}
use of org.jenkinsci.plugins.workflow.support.visualization.table.FlowGraphTable in project blueocean-plugin by jenkinsci.
the class PipelineNodeTest method getPipelineJobRunNodeLogTest.
@Test
public void getPipelineJobRunNodeLogTest() throws Exception {
WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");
job1.setDefinition(new CpsFlowDefinition("stage 'build'\n" + "node{\n" + " echo \"Building...\"\n" + "}\n" + "\n" + "stage 'test'\n" + "parallel 'unit':{\n" + " node{\n" + " echo \"Unit testing...\"\n" + " }\n" + "},'integration':{\n" + " node{\n" + " echo \"Integration testing...\"\n" + " }\n" + "}, 'ui':{\n" + " node{\n" + " echo \"UI testing...\"\n" + " }\n" + "}\n" + "\n" + "stage 'deploy'\n" + "node{\n" + " echo \"Deploying\"\n" + "}"));
WorkflowRun b1 = job1.scheduleBuild2(0).get();
j.assertBuildStatusSuccess(b1);
FlowGraphTable nodeGraphTable = new FlowGraphTable(b1.getExecution());
nodeGraphTable.build();
List<FlowNode> nodes = getStages(nodeGraphTable);
List<FlowNode> parallelNodes = getParallelNodes(nodeGraphTable);
Assert.assertEquals(6, nodes.size());
Assert.assertEquals(3, parallelNodes.size());
String output = get("/organizations/jenkins/pipelines/pipeline1/runs/1/log", String.class);
assertNotNull(output);
System.out.println(output);
}
use of org.jenkinsci.plugins.workflow.support.visualization.table.FlowGraphTable in project blueocean-plugin by jenkinsci.
the class PipelineNodeTest method getPipelineStepsTest.
@Test
public void getPipelineStepsTest() throws Exception {
WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");
job1.setDefinition(new CpsFlowDefinition("stage 'build'\n" + "node{\n" + " sh \"echo Building...\"\n" + "}\n" + "\n" + "stage 'test'\n" + "parallel 'unit':{\n" + " node{\n" + " echo \"Unit testing...\"\n" + " sh \"echo Tests running\"\n" + " sh \"echo Tests completed\"\n" + " }\n" + "},'integration':{\n" + " node{\n" + " echo \"Integration testing...\"\n" + " }\n" + "}, 'ui':{\n" + " node{\n" + " echo \"UI testing...\"\n" + " }\n" + "}\n" + "\n" + "node{\n" + " echo \"Done Testing\"\n" + "}" + "\n" + "stage 'deploy'\n" + "node{\n" + " echo \"Deploying\"\n" + "}" + "\n" + "stage 'deployToProd'\n" + "node{\n" + " echo \"Deploying to production\"\n" + "}"));
WorkflowRun b1 = job1.scheduleBuild2(0).get();
j.assertBuildStatusSuccess(b1);
FlowGraphTable nodeGraphTable = new FlowGraphTable(b1.getExecution());
nodeGraphTable.build();
List<FlowNode> nodes = getStages(nodeGraphTable);
List<FlowNode> parallelNodes = getParallelNodes(nodeGraphTable);
Assert.assertEquals(7, nodes.size());
Assert.assertEquals(3, parallelNodes.size());
List<Map> resp = get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/" + nodes.get(1).getId() + "/steps/", List.class);
Assert.assertEquals(6, resp.size());
Map step = get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/" + parallelNodes.get(0).getId() + "/steps/" + resp.get(0).get("id"), Map.class);
assertNotNull(step);
String stepLog = get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/" + parallelNodes.get(0).getId() + "/steps/" + resp.get(0).get("id") + "/log", String.class);
assertNotNull(stepLog);
}
Aggregations