Skip to content

Commit 95b7a74

Browse files
committed
Do not test branch ordering with ForkScanner for incomplete build with nested parallelism
1 parent ebe0969 commit 95b7a74

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/test/java/org/jenkinsci/plugins/workflow/graphanalysis/ForkScannerTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
import org.junit.Ignore;
6565
import static org.hamcrest.MatcherAssert.assertThat;
66-
import static org.hamcrest.Matchers.contains;
66+
import static org.hamcrest.Matchers.equalTo;
6767

6868
/**
6969
* Tests for internals of ForkScanner
@@ -1029,7 +1029,8 @@ public void inProgressParallelInParallel() throws Exception {
10291029
SemaphoreStep.waitForStart("innerA/1", b);
10301030
ForkScanner scanner = new ForkScanner();
10311031
sanityTestIterationAndVisiter(b.getExecution().getCurrentHeads());
1032-
assertBranchOrder(b.getExecution(), "innerB", "innerA", "outerC", "outerB", "outerA");
1032+
// Observed to flake with innerA coming first in some cases.
1033+
// assertBranchOrder(b.getExecution(), "innerB", "innerA", "outerC", "outerB", "outerA");
10331034
SemaphoreStep.success("outerA/1", null);
10341035
SemaphoreStep.success("innerA/1", null);
10351036
r.assertBuildStatusSuccess(r.waitForCompletion(b));
@@ -1092,11 +1093,12 @@ public void parallelBranchOrdering() throws Exception {
10921093
private static void assertBranchOrder(FlowExecution execution, String... expectedBranchNames) {
10931094
ForkScanner scanner = new ForkScanner();
10941095
scanner.setup(execution.getCurrentHeads());
1095-
List<String> branches = StreamSupport.stream(scanner.spliterator(), false)
1096+
String[] branches = StreamSupport.stream(scanner.spliterator(), false)
10961097
.map(n -> n.getPersistentAction(ThreadNameAction.class))
10971098
.filter(Objects::nonNull)
10981099
.map(ThreadNameAction::getThreadName)
1099-
.collect(Collectors.toList());
1100-
assertThat(branches, contains(expectedBranchNames));
1100+
.collect(Collectors.toList())
1101+
.toArray(String[]::new);
1102+
assertThat(branches, equalTo(expectedBranchNames));
11011103
}
11021104
}

0 commit comments

Comments
 (0)