mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-11-23 01:06:47 -06:00
TagFilter Error Advisor (#2097)
* TagFilter Error Advisor * Fix comment detection bug * Fix the pattern
This commit is contained in:
parent
6e83655b57
commit
86b2495aed
@ -24,6 +24,7 @@ import org.apache.logging.log4j.LogManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ public class StrInterpolator implements Function<String, String> {
|
|||||||
.setEnableSubstitutionInVariables(true)
|
.setEnableSubstitutionInVariables(true)
|
||||||
.setEnableUndefinedVariableException(true)
|
.setEnableUndefinedVariableException(true)
|
||||||
.setDisableSubstitutionInValues(true);
|
.setDisableSubstitutionInValues(true);
|
||||||
|
private final Pattern COMMENT = Pattern.compile("^\\s*#.*");
|
||||||
|
|
||||||
public StrInterpolator(ActivityDef... activityDefs) {
|
public StrInterpolator(ActivityDef... activityDefs) {
|
||||||
Arrays.stream(activityDefs)
|
Arrays.stream(activityDefs)
|
||||||
@ -47,6 +49,10 @@ public class StrInterpolator implements Function<String, String> {
|
|||||||
multimap.add(basicMap);
|
multimap.add(basicMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isComment(String line) {
|
||||||
|
return line != null && COMMENT.matcher(line).matches();
|
||||||
|
}
|
||||||
|
|
||||||
// for testing
|
// for testing
|
||||||
protected StrInterpolator(List<Map<String, String>> maps) {
|
protected StrInterpolator(List<Map<String, String>> maps) {
|
||||||
maps.forEach(multimap::add);
|
maps.forEach(multimap::add);
|
||||||
@ -58,7 +64,7 @@ public class StrInterpolator implements Function<String, String> {
|
|||||||
boolean endsWithNewline = raw.endsWith("\n");
|
boolean endsWithNewline = raw.endsWith("\n");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
if (!line.startsWith("#")) {
|
if (!isComment(line)) {
|
||||||
String result = matchTemplates(line);
|
String result = matchTemplates(line);
|
||||||
if (!result.equals(line)) {
|
if (!result.equals(line)) {
|
||||||
lines[i] = result;
|
lines[i] = result;
|
||||||
|
@ -113,8 +113,18 @@ public class StrInterpolatorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldMatchWithComments() {
|
public void shouldMatchWithComments() {
|
||||||
StrInterpolator interp = new StrInterpolator(abcd);
|
StrInterpolator interp = new StrInterpolator(abcd);
|
||||||
String a = interp.apply("TEMPLATE(start,START)\n# TEMPLATE(blahblah,blah)\nTEMPLATE(keydist,Uniform(0,1000000000)->int);");
|
String a = interp.apply("""
|
||||||
assertThat(a).isEqualTo("START\n# TEMPLATE(blahblah,blah)\nUniform(0,1000000000)->int;");
|
TEMPLATE(start,START)
|
||||||
|
# TEMPLATE(blahblah,blah)
|
||||||
|
TEMPLATE(keydist,Uniform(0,1000000000)->int);
|
||||||
|
# TEMPLATE(blahblah,blah)
|
||||||
|
""");
|
||||||
|
assertThat(a).isEqualTo("""
|
||||||
|
START
|
||||||
|
# TEMPLATE(blahblah,blah)
|
||||||
|
Uniform(0,1000000000)->int;
|
||||||
|
# TEMPLATE(blahblah,blah)
|
||||||
|
""");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -126,6 +136,10 @@ public class StrInterpolatorTest {
|
|||||||
assertThat(b).isEqualTo("-setme-setyou-");
|
assertThat(b).isEqualTo("-setme-setyou-");
|
||||||
String c = interp.apply("-${setkey:=setme}-${setkey3:+setme}-${setkey:+setyou}-");
|
String c = interp.apply("-${setkey:=setme}-${setkey3:+setme}-${setkey:+setyou}-");
|
||||||
assertThat(c).isEqualTo("-setme-setme-setyou-");
|
assertThat(c).isEqualTo("-setme-setme-setyou-");
|
||||||
|
String d = interp.apply("-${setkey:+${setkey3:+setme}}-");
|
||||||
|
assertThat(d).isEqualTo("-setme-");
|
||||||
|
String e = interp.apply("-${${setkey3:+setkey}}-");
|
||||||
|
assertThat(e).isEqualTo("-setme-");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -41,6 +41,7 @@ import io.nosqlbench.engine.api.activityapi.planning.SequencerType;
|
|||||||
import io.nosqlbench.engine.api.activityapi.simrate.*;
|
import io.nosqlbench.engine.api.activityapi.simrate.*;
|
||||||
import io.nosqlbench.engine.api.activityimpl.motor.RunStateTally;
|
import io.nosqlbench.engine.api.activityimpl.motor.RunStateTally;
|
||||||
import io.nosqlbench.engine.core.lifecycle.scenario.container.InvokableResult;
|
import io.nosqlbench.engine.core.lifecycle.scenario.container.InvokableResult;
|
||||||
|
import io.nosqlbench.nb.api.advisor.NBAdvisorOutput;
|
||||||
import io.nosqlbench.nb.api.components.core.NBComponent;
|
import io.nosqlbench.nb.api.components.core.NBComponent;
|
||||||
import io.nosqlbench.nb.api.components.events.ParamChange;
|
import io.nosqlbench.nb.api.components.events.ParamChange;
|
||||||
import io.nosqlbench.nb.api.components.status.NBStatusComponent;
|
import io.nosqlbench.nb.api.components.status.NBStatusComponent;
|
||||||
@ -467,8 +468,10 @@ public class SimpleActivity extends NBStatusComponent implements Activity, Invok
|
|||||||
// But if there were no ops, and there was no default driver provided, we can't continue
|
// But if there were no ops, and there was no default driver provided, we can't continue
|
||||||
// There were no ops, and it was because they were all filtered out
|
// There were no ops, and it was because they were all filtered out
|
||||||
if (!unfilteredOps.isEmpty()) {
|
if (!unfilteredOps.isEmpty()) {
|
||||||
throw new BasicError("There were no active op templates with tag filter '"
|
String message = "There were no active op templates with tag filter '"+ tagfilter + "', since all " +
|
||||||
+ tagfilter + "', since all " + unfilteredOps.size() + " were filtered out.");
|
unfilteredOps.size() + " were filtered out. Examine the session log for details";
|
||||||
|
NBAdvisorOutput.test(message);
|
||||||
|
//throw new BasicError(message);
|
||||||
}
|
}
|
||||||
if (defaultDriverAdapter instanceof SyntheticOpTemplateProvider sotp) {
|
if (defaultDriverAdapter instanceof SyntheticOpTemplateProvider sotp) {
|
||||||
filteredOps = sotp.getSyntheticOpTemplates(opsDocList, this.activityDef.getParams());
|
filteredOps = sotp.getSyntheticOpTemplates(opsDocList, this.activityDef.getParams());
|
||||||
|
Loading…
Reference in New Issue
Block a user