Skip to content

Commit

Permalink
PLANNER-297 Don't pollute the test log with a stacktrace
Browse files Browse the repository at this point in the history
  • Loading branch information
ge0ffrey committed Jun 24, 2015
1 parent 8186761 commit 341cfb3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
public class PlannerBenchmarkRunner implements PlannerBenchmark {

protected final transient Logger logger = LoggerFactory.getLogger(getClass());
protected final transient Logger singleBenchmarkRunnerExceptionLogger = LoggerFactory.getLogger(
getClass().getName() + ".singleBenchmarkRunnerException");

private final PlannerBenchmarkResult plannerBenchmarkResult;

Expand Down Expand Up @@ -141,7 +143,8 @@ private void warmUp() {
}
}

protected long warmUp(ProblemBenchmarkResult problemBenchmarkResult, long startingTimeMillis, long warmUpTimeMillisSpentLimit, long timeLeft) {
protected long warmUp(ProblemBenchmarkResult problemBenchmarkResult,
long startingTimeMillis, long warmUpTimeMillisSpentLimit, long timeLeft) {
for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
SolverBenchmarkResult solverBenchmarkResult = singleBenchmarkResult.getSolverBenchmarkResult();
TerminationConfig originalTerminationConfig = solverBenchmarkResult.getSolverConfig().getTerminationConfig();
Expand All @@ -154,7 +157,8 @@ protected long warmUp(ProblemBenchmarkResult problemBenchmarkResult, long starti
Solver solver = solverBenchmarkResult.getSolverConfig().buildSolver();
solver.solve(problemBenchmarkResult.readPlanningProblem());
} catch (RuntimeException e) {
logger.error("The warmUp of singleBenchmark (" + singleBenchmarkResult.getName() + ") failed.", e);
singleBenchmarkRunnerExceptionLogger.warn("The warmUp of singleBenchmark ("
+ singleBenchmarkResult.getName() + ") failed.", e);
// TODO update firstFailureSingleBenchmarkRunner (when warmups happen in a Runner too in parallel)
}

Expand Down Expand Up @@ -195,11 +199,12 @@ protected void runSingleBenchmarks() {
failureThrowable = e;
} catch (ExecutionException e) {
Throwable cause = e.getCause();
logger.error("The singleBenchmarkRunner (" + singleBenchmarkRunner.getName() + ") failed.", cause);
singleBenchmarkRunnerExceptionLogger.warn("The singleBenchmarkRunner ("
+ singleBenchmarkRunner.getName() + ") failed.", cause);
failureThrowable = cause;
} catch (IllegalStateException e) {
// TODO WORKAROUND Remove when PLANNER-46 is fixed.
logger.error("The singleBenchmarkRunner (" + singleBenchmarkRunner.getName() + ") failed.", e);
singleBenchmarkRunnerExceptionLogger.warn("The singleBenchmarkRunner (" + singleBenchmarkRunner.getName() + ") failed.", e);
failureThrowable = e;
}
if (failureThrowable == null) {
Expand Down
2 changes: 2 additions & 0 deletions optaplanner-examples/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
</appender>

<logger name="org.optaplanner" level="info"/>
<!-- Don't pollute the test log with a stacktrace -->
<logger name="org.optaplanner.benchmark.impl.PlannerBenchmarkRunner.singleBenchmarkRunnerException" level="error"/>

<root level="warn">
<appender-ref ref="consoleAppender" />
Expand Down

0 comments on commit 341cfb3

Please sign in to comment.