Skip to content

Commit

Permalink
Merge pull request #1048 from hcoles/feature/process_hang_mitigation
Browse files Browse the repository at this point in the history
mitigation for process hangs
  • Loading branch information
hcoles authored Jul 6, 2022
2 parents 92a3439 + 2a522d0 commit bb727d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void run() {
new TimeOutDecoratedTestSource(paramsFromParent.timeoutStrategy,
tests, this.reporter));

this.reporter.done(ExitCode.OK);
repeatedlySendDoneSignal();
} catch (final Throwable ex) {
ex.printStackTrace(System.out);
LOG.log(Level.WARNING, "Error during mutation test", ex);
Expand All @@ -109,6 +109,17 @@ public void run() {

}

private void repeatedlySendDoneSignal() throws InterruptedException {
// there have been reports of the done signal getting lost, causing the main process
// to hang. The root cause of this issue has not been found, this attempts to mitigate it
// by resending the signal. We don't want to spend too long doing this, as it is better for
// the minion to end naturally, than be killed by the main process.
for (int i = 0; i != 10; i++) {
this.reporter.done(ExitCode.OK);
Thread.sleep(100);
}
}

private void configureVerbosity(MinionArguments paramsFromParent) {
Log.setVerbose(paramsFromParent.verbosity());
if (!paramsFromParent.verbosity().showMinionOutput()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.pitest.mutationtest.execute;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.pitest.mutationtest.LocationMother.aMutationId;
Expand Down Expand Up @@ -85,7 +86,7 @@ public void setup() {
@Test
public void shouldReportNoErrorWhenNoMutationsSupplied() {
this.testee.run();
verify(this.reporter).done(ExitCode.OK);
verify(this.reporter, atLeastOnce()).done(ExitCode.OK);
}

@Test
Expand Down

0 comments on commit bb727d6

Please sign in to comment.