Skip to content

Commit

Permalink
Merge pull request #310 from dwnusbaum/flaky-test
Browse files Browse the repository at this point in the history
Do not test branch ordering with ForkScanner for incomplete build with nested parallelism
  • Loading branch information
jglick committed Sep 11, 2023
2 parents ebe0969 + 95b7a74 commit 526907f
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

import org.junit.Ignore;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.equalTo;

/**
* Tests for internals of ForkScanner
Expand Down Expand Up @@ -1029,7 +1029,8 @@ public void inProgressParallelInParallel() throws Exception {
SemaphoreStep.waitForStart("innerA/1", b);
ForkScanner scanner = new ForkScanner();
sanityTestIterationAndVisiter(b.getExecution().getCurrentHeads());
assertBranchOrder(b.getExecution(), "innerB", "innerA", "outerC", "outerB", "outerA");
// Observed to flake with innerA coming first in some cases.
// assertBranchOrder(b.getExecution(), "innerB", "innerA", "outerC", "outerB", "outerA");
SemaphoreStep.success("outerA/1", null);
SemaphoreStep.success("innerA/1", null);
r.assertBuildStatusSuccess(r.waitForCompletion(b));
Expand Down Expand Up @@ -1092,11 +1093,12 @@ public void parallelBranchOrdering() throws Exception {
private static void assertBranchOrder(FlowExecution execution, String... expectedBranchNames) {
ForkScanner scanner = new ForkScanner();
scanner.setup(execution.getCurrentHeads());
List<String> branches = StreamSupport.stream(scanner.spliterator(), false)
String[] branches = StreamSupport.stream(scanner.spliterator(), false)
.map(n -> n.getPersistentAction(ThreadNameAction.class))
.filter(Objects::nonNull)
.map(ThreadNameAction::getThreadName)
.collect(Collectors.toList());
assertThat(branches, contains(expectedBranchNames));
.collect(Collectors.toList())
.toArray(String[]::new);
assertThat(branches, equalTo(expectedBranchNames));
}
}

0 comments on commit 526907f

Please sign in to comment.