mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
Verify expected result with MVEL
This commit is contained in:
@@ -23,7 +23,9 @@ import io.nosqlbench.engine.api.activityimpl.uniform.DriverAdapter;
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.engine.api.metrics.ThreadLocalNamedTimers;
|
||||
import io.nosqlbench.engine.api.templating.ParsedOp;
|
||||
import org.mvel2.MVEL;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@@ -38,6 +40,7 @@ import java.util.concurrent.TimeUnit;
|
||||
public abstract class BaseOpDispenser<T extends Op, S> implements OpDispenser<T> {
|
||||
|
||||
private final String opName;
|
||||
private Serializable expectedResultExpression;
|
||||
protected final DriverAdapter<T, S> adapter;
|
||||
private boolean instrument;
|
||||
private Histogram resultSizeHistogram;
|
||||
@@ -63,6 +66,17 @@ public abstract class BaseOpDispenser<T extends Op, S> implements OpDispenser<T>
|
||||
}
|
||||
}
|
||||
configureInstrumentation(op);
|
||||
configureExpectations(op);
|
||||
}
|
||||
|
||||
private void configureExpectations(ParsedOp op) {
|
||||
op.getOptionalStaticValue("expected-result", String.class)
|
||||
.map(MVEL::compileExpression)
|
||||
.ifPresent(result -> this.expectedResultExpression = result);
|
||||
}
|
||||
|
||||
public Serializable getExpectedResultExpression() {
|
||||
return expectedResultExpression;
|
||||
}
|
||||
|
||||
String getOpName() {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
/**
|
||||
@@ -81,5 +82,6 @@ public interface OpDispenser<T> extends LongFunction<T>, OpResultTracker {
|
||||
*/
|
||||
|
||||
T apply(long value);
|
||||
Serializable getExpectedResultExpression();
|
||||
|
||||
}
|
||||
|
||||
@@ -33,4 +33,7 @@ package io.nosqlbench.engine.api.activityimpl.uniform.flowtypes;
|
||||
*/
|
||||
// TODO: optimize the runtime around the specific op type
|
||||
public interface Op extends OpResultSize {
|
||||
default boolean verified() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user