Skip to content

Commit

Permalink
Merge pull request #54 from jglick/getLogPrefix-JENKINS-28222
Browse files Browse the repository at this point in the history
[JENKINS-28222] Moving getLogPrefix test to workflow-job, where this is implemented anyway
  • Loading branch information
jglick committed Sep 16, 2016
2 parents 788eccc + 1b586ec commit b5b1ed0
Showing 1 changed file with 0 additions and 65 deletions.
Expand Up @@ -466,69 +466,4 @@ public void invisibleParallelBranch() throws Exception {
});
}

@Test
@Issue("JENKINS-26122")
public void parallelBranchLabels() {
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
p = jenkins().createProject(WorkflowJob.class, "demo");
p.setDefinition(new CpsFlowDefinition(join(
"node {\n" +
" parallel( \n" +
" a: { \n" +
" echo('echo a');\n" +
" echo('echo a');\n" +
" }, \n" +
" b: { \n" +
" echo('echo b'); \n" +
" echo('echo b'); \n" +
" }\n" +
" )\n" +
"}\n"
)));

startBuilding().get();
assertBuildCompletedSuccessfully();

// Check that the individual labeled lines are as expected
//System.out.println(b.getLog());
List<String> logLines = b.getLog(50);
assertGoodLabeledLogs(logLines);

// Check that the logs are printed in the right sequence e.g. that a
// "[a] Running: Print Message" is followed by a "[a] echo a"
assertGoodSequence("a", logLines);
assertGoodSequence("b", logLines);
}
private void assertGoodLabeledLogs(List<String> logLines) {
for (int i = 0; i < logLines.size(); i++) {
String logLine = logLines.get(i);
if (logLine.startsWith("[a] ")) {
assertGoodLabeledLog("a", logLine);
} else if (logLine.startsWith("[b] ")) {
assertGoodLabeledLog("b", logLine);
}
}
}
private void assertGoodLabeledLog(String label, String logLine) {
List<String> possibleLogLines = Arrays.asList(
String.format("[%s] Running: Parallel branch: %s", label, label),
String.format("[%s] Running: Print Message", label),
String.format("[%s] echo %s", label, label)
);
boolean contains = possibleLogLines.contains(logLine);
assertTrue(contains);
}
private void assertGoodSequence(String label, List<String> logLines) {
String running = String.format("[%s] Running: Print Message", label);
String echo = String.format("[%s] echo %s", label, label);

for (int i = 0; i < logLines.size() - 1; i++) { // skip the last log line in this loop
if (logLines.get(i).equals(running)) {
assertEquals(echo, logLines.get(i + 1));
}
}
}
});
}
}

0 comments on commit b5b1ed0

Please sign in to comment.