mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
Do not pretty-print the result object in case of a verification error
This commit is contained in:
parent
63cfa5d85d
commit
c48dcb1848
@ -40,7 +40,7 @@ public class ExpectedResultVerificationErrorHandler implements ErrorHandler, Err
|
||||
public ErrorDetail handleError(String name, Throwable t, long cycle, long durationInNanos, ErrorDetail detail) {
|
||||
if (t instanceof ExpectedResultVerificationError erve) {
|
||||
if (erve.getTriesLeft() == 0) {
|
||||
logger.warn("Cycle: {} Verification of result {} did not pass following expression: {}", cycle, erve.getResultAsString(), erve.getExpectedResultExpression());
|
||||
logger.warn("Cycle: {} Verification of result did not pass following expression: {}", cycle, erve.getExpectedResultExpression());
|
||||
exceptionExpectedResultVerificationMetrics.countVerificationErrors();
|
||||
} else {
|
||||
logger.info("Cycle: {} Verification of result did not pass. {} retries left.", cycle, erve.getTriesLeft());
|
||||
|
@ -111,7 +111,7 @@ public class StandardAction<A extends StandardActivity<R, ?>, R extends Op> impl
|
||||
if (shouldVerifyExpectedResultFor(op, expectedResultExpression)) {
|
||||
var verified = MVEL.executeExpression(expectedResultExpression, result, boolean.class);
|
||||
if (!verified) {
|
||||
throw new ExpectedResultVerificationError(maxTries - tries, expectedResultExpression, result);
|
||||
throw new ExpectedResultVerificationError(maxTries - tries, expectedResultExpression);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -205,13 +205,13 @@ class NBErrorHandlerTest {
|
||||
appender.cleanup(logger);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static Stream<Arguments> testExpectedResultVerificationErrorHandler() {
|
||||
Logger logger = (Logger) LogManager.getLogger("VERIFY");
|
||||
var obj = new Object();
|
||||
return Stream.of(
|
||||
Arguments.of(
|
||||
"retries left",
|
||||
new ExpectedResultVerificationError(5, "expected", obj),
|
||||
new ExpectedResultVerificationError(5, "expected"),
|
||||
"Cycle: 1 Verification of result did not pass. 5 retries left.",
|
||||
1,
|
||||
0,
|
||||
@ -219,8 +219,8 @@ class NBErrorHandlerTest {
|
||||
),
|
||||
Arguments.of(
|
||||
"no retries left",
|
||||
new ExpectedResultVerificationError(0, "expected", obj),
|
||||
String.format("Cycle: 1 Verification of result %s did not pass following expression: %s", obj.toString(), "expected"),
|
||||
new ExpectedResultVerificationError(0, "expected"),
|
||||
"Cycle: 1 Verification of result did not pass following expression: expected",
|
||||
0,
|
||||
1,
|
||||
logger
|
||||
|
@ -21,12 +21,10 @@ import java.io.Serializable;
|
||||
public class ExpectedResultVerificationError extends RuntimeException {
|
||||
private final int triesLeft;
|
||||
private final Serializable expectedResultExpression;
|
||||
private final Object result;
|
||||
|
||||
public ExpectedResultVerificationError(int triesLeft, Serializable expectedResultExpression, Object result) {
|
||||
public ExpectedResultVerificationError(int triesLeft, Serializable expectedResultExpression) {
|
||||
this.triesLeft = triesLeft;
|
||||
this.expectedResultExpression = expectedResultExpression;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public int getTriesLeft() {
|
||||
@ -37,7 +35,4 @@ public class ExpectedResultVerificationError extends RuntimeException {
|
||||
return expectedResultExpression;
|
||||
}
|
||||
|
||||
public String getResultAsString() {
|
||||
return result.toString(); // TODO JK how to traverse the first x characters of the result? parse to json? via reflection?
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user