Skip to content

Commit

Permalink
Improve error message and fail behavior of ParallelBuildChainTest #657
Browse files Browse the repository at this point in the history
The ParallelBuildChainTest has some flaws in error message design and
failure handling, which are addressed by this change:
1. The timeout for builds to start/finish is higher than the execution
time of a long running build. Thus in case builds are unexpectedly not
run in parallel, the assertion for timely build start/finish is not
evaluated as expected.
2. In case an error occurs before starting a build operation, the number
of expected builds in the TimerBuilder may be higher than the number of
builds that will every be executed. Since the TimerBuilder abortion
tries to wait for all expected builds indefinitely, the operation (and
thus test tear down) may never terminate.
  • Loading branch information
HeikoKlare committed Sep 11, 2023
1 parent 8ec6c71 commit 27ab521
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class ParallelBuildChainTest extends AbstractBuilderTest {

private static final int MAXIMUM_NUMBER_OF_CONCURRENT_BUILDS = 3;

private static final int TIMEOUT_IN_MILLIS = 60_000;
private static final int TIMEOUT_IN_MILLIS = 20_000;

private static enum BuildDurationType {
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class TimerBuilder extends IncrementalProjectBuilder {
public static final String DURATION_ARG = "duration";
public static final String RULE_TYPE_ARG = "ruleType";

private static final int SHUTDOWN_TIMEOUT_IN_MILLIS = 60_000;

private static BuildExecutionState executionState = new BuildExecutionState(-1);

private static class BuildExecutionState {
Expand Down Expand Up @@ -72,11 +74,14 @@ private synchronized void endedExcecutingProject(IProject project) {

private synchronized void abortAndWaitForAllBuilds() {
shallAbort = true;
while (isExecuting()) {
long durationInMillis = 0;
long waitingStartTimeInMillis = System.currentTimeMillis();
while (isExecuting() && durationInMillis < SHUTDOWN_TIMEOUT_IN_MILLIS) {
try {
wait();
wait(SHUTDOWN_TIMEOUT_IN_MILLIS);
} catch (InterruptedException e) {
}
durationInMillis = System.currentTimeMillis() - waitingStartTimeInMillis;
}
}

Expand Down

0 comments on commit 27ab521

Please sign in to comment.