Skip to content

Commit

Permalink
Bug fix for suite execution & additional logging (#103)
Browse files Browse the repository at this point in the history
Co-authored-by: noconnor <niall.oconnor@yahooinc.com>
  • Loading branch information
noconnor and noconnor authored Jun 25, 2023
1 parent bb20734 commit d6f6587
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.noconnor.junitperf.statistics.StatisticsCalculator;
import com.google.common.util.concurrent.RateLimiter;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;

import java.util.function.Supplier;

Expand All @@ -11,6 +12,7 @@
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;

@Slf4j
final class EvaluationTask implements Runnable {

private final TestStatement statement;
Expand Down Expand Up @@ -76,7 +78,7 @@ private void evaluateStatement(long startMeasurements) {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (Throwable throwable) {
// IGNORE
log.trace("Warmup error", throwable);
}
} else {

Expand All @@ -85,6 +87,7 @@ private void evaluateStatement(long startMeasurements) {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (Throwable throwable) {
log.trace("Setup error", throwable);
throw new IllegalStateException("Before method failed", throwable);
}

Expand All @@ -101,13 +104,15 @@ private void evaluateStatement(long startMeasurements) {
stats.incrementErrorCount();
stats.addLatencyMeasurement(nanoTime() - startTimeNs);
}
log.trace("Execution error", throwable);
}

try {
statement.runAfters();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (Throwable throwable) {
log.trace("Teardown error", throwable);
throw new IllegalStateException("After method failed", throwable);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ public void interceptTestMethod(Invocation<Void> invocation,
test.setMeasurementsStartTimeMs(currentTimeMillis() + perfTestAnnotation.warmUpMs());
test.setContext(context);

SimpleTestStatement testStatement = () -> method.invoke(
extensionContext.getRequiredTestInstance(),
invocationContext.getArguments().toArray()
);
SimpleTestStatement testStatement = () -> {
method.setAccessible(true);
method.invoke(
extensionContext.getRequiredTestInstance(),
invocationContext.getArguments().toArray()
);
};

PerformanceEvaluationStatement parallelExecution = test.getStatementBuilder()
.baseStatement(testStatement)
Expand Down Expand Up @@ -198,7 +201,7 @@ private static void proceedQuietly(Invocation<Void> invocation) throws Throwable
// Must be called for framework to proceed
invocation.proceed();
} catch (Throwable e) {
// Ignore
log.trace("Proceed error", e);
}
}

Expand Down

0 comments on commit d6f6587

Please sign in to comment.