mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
engine and nb api changes for vector branch
This commit is contained in:
@@ -19,6 +19,7 @@ package io.nosqlbench.engine.api.activityapi.cyclelog.outputs.logger;
|
||||
import io.nosqlbench.engine.api.activityapi.core.Activity;
|
||||
import io.nosqlbench.engine.api.activityapi.output.Output;
|
||||
import io.nosqlbench.engine.api.activityapi.output.OutputDispenser;
|
||||
import io.nosqlbench.engine.api.activityapi.core.Activity;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -157,9 +157,9 @@ public class HybridRateLimiter implements RateLimiter {
|
||||
|
||||
|
||||
protected void init(final NBLabeledElement activityDef) {
|
||||
delayGauge = ActivityMetrics.gauge(activityDef, this.label + ".waittime", new WaitTimeGauge(this));
|
||||
avgRateGauge = ActivityMetrics.gauge(activityDef, this.label + ".config.cyclerate", new RateGauge(this));
|
||||
burstRateGauge = ActivityMetrics.gauge(activityDef, this.label + ".config.burstrate", new BurstRateGauge(this));
|
||||
delayGauge = ActivityMetrics.gauge(activityDef, this.label + ".waittime", new RateLimiters.WaitTimeGauge(this));
|
||||
avgRateGauge = ActivityMetrics.gauge(activityDef, this.label + ".config.cyclerate", new RateLimiters.RateGauge(this));
|
||||
burstRateGauge = ActivityMetrics.gauge(activityDef, this.label + ".config.burstrate", new RateLimiters.BurstRateGauge(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -294,10 +294,10 @@ public class InlineTokenPool {
|
||||
|
||||
if (debugthis) {
|
||||
System.out.print(this);
|
||||
System.out.print(ANSI_BrightBlue + " adding=" + allocatedToActivePool);
|
||||
System.out.print(Colors.ANSI_BrightBlue + " adding=" + allocatedToActivePool);
|
||||
if (0 < allocatedToOverflowPool)
|
||||
System.out.print(ANSI_Red + " OVERFLOW:" + allocatedToOverflowPool + ANSI_Reset);
|
||||
if (0 < burstFill) System.out.print(ANSI_BrightGreen + " BACKFILL:" + burstFill + ANSI_Reset);
|
||||
System.out.print(Colors.ANSI_Red + " OVERFLOW:" + allocatedToOverflowPool + Colors.ANSI_Reset);
|
||||
if (0 < burstFill) System.out.print(Colors.ANSI_BrightGreen + " BACKFILL:" + burstFill + Colors.ANSI_Reset);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.marker;
|
||||
|
||||
import io.nosqlbench.engine.api.activityapi.cyclelog.buffers.results.CycleResultsSegment;
|
||||
import io.nosqlbench.engine.api.activityapi.cyclelog.buffers.CycleResultSegmentsReadable;
|
||||
import io.nosqlbench.engine.api.activityapi.cyclelog.buffers.results.CycleResultsSegment;
|
||||
|
||||
|
||||
@@ -107,12 +107,16 @@ public class StandardAction<A extends StandardActivity<R, ?>, R extends Op> impl
|
||||
throw new RuntimeException("The op implementation did not implement any active logic. Implement " +
|
||||
"one of [RunnableOp, CycleOp, or ChainingOp]");
|
||||
}
|
||||
var expectedResultExpression = dispenser.getExpectedResultExpression();
|
||||
if (shouldVerifyExpectedResultFor(op, expectedResultExpression)) {
|
||||
var verified = MVEL.executeExpression(expectedResultExpression, result, boolean.class);
|
||||
if (!verified) {
|
||||
throw new ExpectedResultVerificationError(maxTries - tries, expectedResultExpression);
|
||||
|
||||
CycleFunction<Boolean> verifier = dispenser.getVerifier();
|
||||
try {
|
||||
verifier.setVariable("result", result);
|
||||
Boolean isGood = verifier.apply(cycle);
|
||||
if (!isGood) {
|
||||
throw new ResultVerificationError("result verification failed", maxTries - tries, verifier.getExpressionDetails());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ResultVerificationError(e, maxTries - tries, verifier.getExpressionDetails());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
error = e;
|
||||
@@ -150,7 +154,4 @@ public class StandardAction<A extends StandardActivity<R, ?>, R extends Op> impl
|
||||
public void onActivityDefUpdate(ActivityDef activityDef) {
|
||||
}
|
||||
|
||||
private boolean shouldVerifyExpectedResultFor(Op op, Serializable expectedResultExpression) {
|
||||
return !(op instanceof RunnableOp) && expectedResultExpression != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,13 @@ import io.nosqlbench.api.errors.ExpectedResultVerificationError;
|
||||
import io.nosqlbench.engine.api.activityapi.errorhandling.ErrorMetrics;
|
||||
import io.nosqlbench.engine.api.activityapi.errorhandling.modular.handlers.CountErrorHandler;
|
||||
import io.nosqlbench.engine.api.activityapi.errorhandling.modular.handlers.CounterErrorHandler;
|
||||
import io.nosqlbench.api.config.NBLabeledElement;
|
||||
import io.nosqlbench.util.NBMock;
|
||||
import io.nosqlbench.util.NBMock.LogAppender;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.core.Logger;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
@@ -188,15 +190,15 @@ class NBErrorHandlerTest {
|
||||
var retries = errorMetrics.getExceptionExpectedResultVerificationMetrics().getVerificationRetries();
|
||||
var errors = errorMetrics.getExceptionExpectedResultVerificationMetrics().getVerificationErrors();
|
||||
|
||||
assertThat(retries.getCount()).isEqualTo(0);
|
||||
assertThat(errors.getCount()).isEqualTo(0);
|
||||
Assertions.assertThat(retries.getCount()).isEqualTo(0);
|
||||
Assertions.assertThat(errors.getCount()).isEqualTo(0);
|
||||
|
||||
// when
|
||||
eh.handleError(error, 1, 2);
|
||||
|
||||
// then
|
||||
assertThat(retries.getCount()).isEqualTo(retriesCount);
|
||||
assertThat(errors.getCount()).isEqualTo(errorsCount);
|
||||
Assertions.assertThat(retries.getCount()).isEqualTo(retriesCount);
|
||||
Assertions.assertThat(errors.getCount()).isEqualTo(errorsCount);
|
||||
|
||||
logger.getContext().stop(); // force any async appenders to flush
|
||||
logger.getContext().start(); // resume processing
|
||||
@@ -211,7 +213,7 @@ class NBErrorHandlerTest {
|
||||
return Stream.of(
|
||||
Arguments.of(
|
||||
"retries left",
|
||||
new ExpectedResultVerificationError(5, "expected"),
|
||||
new ResultMismatchError("error-message", 5, "<expression>"),
|
||||
"Cycle: 1 Verification of result did not pass. 5 retries left.",
|
||||
1,
|
||||
0,
|
||||
@@ -219,8 +221,8 @@ class NBErrorHandlerTest {
|
||||
),
|
||||
Arguments.of(
|
||||
"no retries left",
|
||||
new ExpectedResultVerificationError(0, "expected"),
|
||||
"Cycle: 1 Verification of result did not pass following expression: expected",
|
||||
new ResultMismatchError("error-message", 0, "<expression>"),
|
||||
"Cycle: 1 Verification of result did not pass following expression: <expression>",
|
||||
0,
|
||||
1,
|
||||
logger
|
||||
|
||||
Reference in New Issue
Block a user