use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project blueocean-plugin by jenkinsci.
the class BlueJUnitTestResultTest method createsTestResult.
@Test
public void createsTestResult() throws Exception {
URL resource = getClass().getResource("BlueJUnitTestResultTest.jenkinsfile");
String jenkinsFile = IOUtils.toString(resource, StandardCharsets.UTF_8);
WorkflowJob p = j.createProject(WorkflowJob.class, "project");
p.setDefinition(new CpsFlowDefinition(jenkinsFile, false));
p.save();
Run r = p.scheduleBuild2(0).waitForStart();
j.waitUntilNoActivity();
BlueRun test = BlueRunFactory.getRun(r, () -> new Link("test"));
Assert.assertEquals(3, IterableUtils.size(test.getTests()));
BluePipelineNode node = mock(BluePipelineNode.class);
when(node.getId()).thenReturn("6");
}
use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project blueocean-plugin by jenkinsci.
the class BlueTrendsApiTest method getJUnitTrends.
@Test
public void getJUnitTrends() throws Exception {
URL resource = getClass().getResource("BlueJUnitTestResultTest.jenkinsfile");
String jenkinsFile = IOUtils.toString(resource, StandardCharsets.UTF_8);
WorkflowJob p = j.createProject(WorkflowJob.class, "project");
p.setDefinition(new CpsFlowDefinition(jenkinsFile, false));
p.save();
Run run;
for (int i = 0; i < 10; i++) {
run = p.scheduleBuild2(0).waitForStart();
j.waitForCompletion(run);
}
Map trend = new RequestBuilder(baseUrl).get("/organizations/jenkins/pipelines/" + p.getName() + "/trends/junit/").build(Map.class);
List rows;
Map testRow;
Assert.assertNotNull(trend);
Map columns = (Map) trend.get("columns");
Assert.assertNotNull(columns);
Assert.assertEquals(7, columns.keySet().size());
rows = new RequestBuilder(baseUrl).get("/organizations/jenkins/pipelines/" + p.getName() + "/trends/junit/rows").build(List.class);
Assert.assertNotNull(rows);
Assert.assertEquals(10, rows.size());
testRow = (Map) rows.get(0);
Assert.assertEquals("10", testRow.get(BlueTableRow.ID));
Assert.assertEquals(3, testRow.get(BlueJUnitTrend.TOTAL));
Assert.assertEquals(2, testRow.get(BlueJUnitTrend.PASSED));
Assert.assertEquals(1, testRow.get(BlueJUnitTrend.FAILED));
Assert.assertEquals(1, testRow.get(BlueJUnitTrend.EXISTING_FAILED));
Assert.assertEquals(0, testRow.get(BlueJUnitTrend.FIXED));
Assert.assertEquals(0, testRow.get(BlueJUnitTrend.REGRESSIONS));
Assert.assertEquals(0, testRow.get(BlueJUnitTrend.SKIPPED));
rows = new RequestBuilder(baseUrl).get("/organizations/jenkins/pipelines/" + p.getName() + "/trends/junit/rows?start=5&limit=5").build(List.class);
Assert.assertNotNull(rows);
Assert.assertEquals(5, rows.size());
testRow = (Map) rows.get(0);
Assert.assertEquals("5", testRow.get(BlueTableRow.ID));
}
use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project blueocean-plugin by jenkinsci.
the class RunMultiThreadLoadTest method load_runs_multi_threaded.
@Test
public void load_runs_multi_threaded() throws Exception {
URL resource = getClass().getResource("RunMultiThreadLoadTest.jenkinsfile");
String jenkinsFile = IOUtils.toString(resource, StandardCharsets.UTF_8);
WorkflowJob p = j.createProject(WorkflowJob.class, "project1");
p.setDefinition(new CpsFlowDefinition(jenkinsFile, false));
p.save();
for (int i = 0; i < 10; i++) {
j.waitForCompletion(p.scheduleBuild2(0).waitForStart());
}
Iterable<BlueRun> blueRuns = RunSearch.findRuns(p, null, 0, 20);
List<BlueRun> runs = StreamSupport.stream(blueRuns.spliterator(), false).collect(Collectors.toList());
Assert.assertFalse(runs.isEmpty());
Assert.assertEquals(10, runs.size());
}
use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project blueocean-plugin by jenkinsci.
the class RunMultiThreadLoadTest method load_runs_multi_threaded_no_runs.
@Test
@Issue("JENKINS-52101")
public void load_runs_multi_threaded_no_runs() throws Exception {
URL resource = getClass().getResource("RunMultiThreadLoadTest.jenkinsfile");
String jenkinsFile = IOUtils.toString(resource, StandardCharsets.UTF_8);
WorkflowJob p = j.createProject(WorkflowJob.class, "project2");
p.setDefinition(new CpsFlowDefinition(jenkinsFile, false));
p.save();
Iterable<BlueRun> blueRuns = RunSearch.findRuns(p, null, 0, 0);
List<BlueRun> runs = StreamSupport.stream(blueRuns.spliterator(), false).collect(Collectors.toList());
Assert.assertTrue(runs.isEmpty());
Assert.assertEquals(0, runs.size());
}
use of org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition in project htmlpublisher-plugin by jenkinsci.
the class PublishHTMLStepTest method setupAndRunProject.
private void setupAndRunProject(@NonNull HtmlPublisherTarget target) throws Exception {
// Test node for the workflow
r.jenkins.addNode(new DumbSlave("slave", "dummy", testWorkspace.getPath(), "1", Node.Mode.NORMAL, "", r.createComputerLauncher(null), RetentionStrategy.NOOP, // TODO JENKINS-26398 clumsy
Collections.emptyList()));
job = r.jenkins.createProject(WorkflowJob.class, TEST_PROJECT_NAME);
job.setDefinition(new CpsFlowDefinition("" + "node('slave') {\n" + " publishHTML(target: [allowMissing: " + target.getAllowMissing() + ", keepAll: " + target.getKeepAll() + ", reportDir: '" + target.getReportDir() + "', reportFiles: '" + target.getReportFiles() + "', reportName: '" + target.getReportName() + "']) \n" + "}", true));
QueueTaskFuture<WorkflowRun> runFuture = job.scheduleBuild2(0);
assertThat("build was actually scheduled", runFuture, Matchers.notNullValue());
run = runFuture.get();
}
Aggregations