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) {
|
public ErrorDetail handleError(String name, Throwable t, long cycle, long durationInNanos, ErrorDetail detail) {
|
||||||
if (t instanceof ExpectedResultVerificationError erve) {
|
if (t instanceof ExpectedResultVerificationError erve) {
|
||||||
if (erve.getTriesLeft() == 0) {
|
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();
|
exceptionExpectedResultVerificationMetrics.countVerificationErrors();
|
||||||
} else {
|
} else {
|
||||||
logger.info("Cycle: {} Verification of result did not pass. {} retries left.", cycle, erve.getTriesLeft());
|
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)) {
|
if (shouldVerifyExpectedResultFor(op, expectedResultExpression)) {
|
||||||
var verified = MVEL.executeExpression(expectedResultExpression, result, boolean.class);
|
var verified = MVEL.executeExpression(expectedResultExpression, result, boolean.class);
|
||||||
if (!verified) {
|
if (!verified) {
|
||||||
throw new ExpectedResultVerificationError(maxTries - tries, expectedResultExpression, result);
|
throw new ExpectedResultVerificationError(maxTries - tries, expectedResultExpression);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -205,13 +205,13 @@ class NBErrorHandlerTest {
|
|||||||
appender.cleanup(logger);
|
appender.cleanup(logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static Stream<Arguments> testExpectedResultVerificationErrorHandler() {
|
private static Stream<Arguments> testExpectedResultVerificationErrorHandler() {
|
||||||
Logger logger = (Logger) LogManager.getLogger("VERIFY");
|
Logger logger = (Logger) LogManager.getLogger("VERIFY");
|
||||||
var obj = new Object();
|
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
Arguments.of(
|
Arguments.of(
|
||||||
"retries left",
|
"retries left",
|
||||||
new ExpectedResultVerificationError(5, "expected", obj),
|
new ExpectedResultVerificationError(5, "expected"),
|
||||||
"Cycle: 1 Verification of result did not pass. 5 retries left.",
|
"Cycle: 1 Verification of result did not pass. 5 retries left.",
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
@ -219,13 +219,13 @@ class NBErrorHandlerTest {
|
|||||||
),
|
),
|
||||||
Arguments.of(
|
Arguments.of(
|
||||||
"no retries left",
|
"no retries left",
|
||||||
new ExpectedResultVerificationError(0, "expected", obj),
|
new ExpectedResultVerificationError(0, "expected"),
|
||||||
String.format("Cycle: 1 Verification of result %s did not pass following expression: %s", obj.toString(), "expected"),
|
"Cycle: 1 Verification of result did not pass following expression: expected",
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
logger
|
logger
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,10 @@ import java.io.Serializable;
|
|||||||
public class ExpectedResultVerificationError extends RuntimeException {
|
public class ExpectedResultVerificationError extends RuntimeException {
|
||||||
private final int triesLeft;
|
private final int triesLeft;
|
||||||
private final Serializable expectedResultExpression;
|
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.triesLeft = triesLeft;
|
||||||
this.expectedResultExpression = expectedResultExpression;
|
this.expectedResultExpression = expectedResultExpression;
|
||||||
this.result = result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTriesLeft() {
|
public int getTriesLeft() {
|
||||||
@ -37,7 +35,4 @@ public class ExpectedResultVerificationError extends RuntimeException {
|
|||||||
return expectedResultExpression;
|
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