mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
Code review adjustments
This commit is contained in:
@@ -33,19 +33,17 @@ import java.util.function.Supplier;
|
||||
*/
|
||||
@Service(value = ErrorHandler.class, selector = "verifyexpected")
|
||||
public class ExpectedResultVerificationErrorHandler implements ErrorHandler, ErrorMetrics.Aware {
|
||||
private static final Logger logger = LogManager.getLogger(ExpectedResultVerificationErrorHandler.class);
|
||||
private static final Logger logger = LogManager.getLogger("VERIFY");
|
||||
private ExceptionExpectedResultVerificationMetrics exceptionExpectedResultVerificationMetrics;
|
||||
|
||||
@Override
|
||||
public ErrorDetail handleError(String name, Throwable t, long cycle, long durationInNanos, ErrorDetail detail) {
|
||||
if (t instanceof ExpectedResultVerificationError erve) {
|
||||
if (erve.getTriesLeft() == 0) {
|
||||
logger.warn("Verification of result did not pass. All retries exhausted.");
|
||||
logger.warn("Cycle: {} Verification of result {} did not pass following expression: {}", cycle, erve.getResultAsString(), erve.getExpectedResultExpression());
|
||||
exceptionExpectedResultVerificationMetrics.countVerificationErrors();
|
||||
} else {
|
||||
logger.info("Cycle: {} Verification of result did not pass. {} retries left.", cycle, erve.getTriesLeft());
|
||||
// TODO/MVEL: I think we should designate a separate logging channel for verification logic
|
||||
// TODO JK: Should this be done via a dedicated logger in the LoggerConfig class? log4j2.xml files seem to be overridden?
|
||||
exceptionExpectedResultVerificationMetrics.countVerificationRetries();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,11 +110,8 @@ public class StandardAction<A extends StandardActivity<R, ?>, R extends Op> impl
|
||||
var expectedResultExpression = dispenser.getExpectedResultExpression();
|
||||
if (shouldVerifyExpectedResultFor(op, expectedResultExpression)) {
|
||||
var verified = MVEL.executeExpression(expectedResultExpression, result, boolean.class);
|
||||
// TODO/MVEL: Wherever this logic lives, we might want to have a symbolic description which
|
||||
// is emitted for logging our metrics purposes indicating the success or failure outcomes.
|
||||
// perhaps something like expected-name: .... and metrics could be then <expected-name>-success and <expected-name>-error
|
||||
if (!verified) {
|
||||
throw new ExpectedResultVerificationError(maxTries - tries);
|
||||
throw new ExpectedResultVerificationError(maxTries - tries, expectedResultExpression, result);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -125,6 +122,7 @@ public class StandardAction<A extends StandardActivity<R, ?>, R extends Op> impl
|
||||
if (error == null) {
|
||||
resultSuccessTimer.update(nanos, TimeUnit.NANOSECONDS);
|
||||
dispenser.onSuccess(cycle, nanos, op.getResultSize());
|
||||
break;
|
||||
} else {
|
||||
ErrorDetail detail = errorHandler.handleError(error, cycle, nanos);
|
||||
dispenser.onError(cycle, nanos, error);
|
||||
|
||||
@@ -207,11 +207,12 @@ class NBErrorHandlerTest {
|
||||
}
|
||||
|
||||
private static Stream<Arguments> testExpectedResultVerificationErrorHandler() {
|
||||
Logger logger = (Logger) LogManager.getLogger(ExpectedResultVerificationErrorHandler.class);
|
||||
Logger logger = (Logger) LogManager.getLogger("VERIFY");
|
||||
var obj = new Object();
|
||||
return Stream.of(
|
||||
Arguments.of(
|
||||
"retries left",
|
||||
new ExpectedResultVerificationError(5),
|
||||
new ExpectedResultVerificationError(5, "expected", obj),
|
||||
"Cycle: 1 Verification of result did not pass. 5 retries left.",
|
||||
1,
|
||||
0,
|
||||
@@ -219,8 +220,8 @@ class NBErrorHandlerTest {
|
||||
),
|
||||
Arguments.of(
|
||||
"no retries left",
|
||||
new ExpectedResultVerificationError(0),
|
||||
"Verification of result did not pass. All retries exhausted.",
|
||||
new ExpectedResultVerificationError(0, "expected", obj),
|
||||
String.format("Cycle: 1 Verification of result %s did not pass following expression: %s", obj.toString(), "expected"),
|
||||
0,
|
||||
1,
|
||||
logger
|
||||
|
||||
Reference in New Issue
Block a user