mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
merge fixups
This commit is contained in:
commit
0c9091714c
11
.github/workflows/build.yml
vendored
11
.github/workflows/build.yml
vendored
@ -25,9 +25,6 @@ jobs:
|
||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: ${{ runner.os }}-m2
|
||||
|
||||
- name: mvn verify
|
||||
run: mvn verify
|
||||
|
||||
- name: Installing dependencies
|
||||
run: mvn clean install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
|
||||
|
||||
@ -37,21 +34,21 @@ jobs:
|
||||
- name: Collecting reports
|
||||
run: tar -cvf codecov-report.tar target/coverage-report/**/*
|
||||
|
||||
- name: Uploading [nosqlbench] test coverage
|
||||
- name: Uploading test coverage
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: codecov-report
|
||||
path: codecov-report.tar
|
||||
|
||||
- name: Collecting [nosqlbench] logfiles
|
||||
- name: Collecting logfiles
|
||||
if: success() || failure()
|
||||
run: tar -cvf logfiles.tar [a-zA-Z]**/logs/*
|
||||
|
||||
- name: Uploading test result log files
|
||||
- name: Uploading log files
|
||||
if: success() || failure()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: test-results
|
||||
name: nb-logs
|
||||
path: logfiles.tar
|
||||
|
||||
- name: export docs
|
||||
|
@ -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.
|
||||
@ -34,15 +34,16 @@ import org.apache.logging.log4j.Logger;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service(value= DriverAdapter.class,selector = "stdout")
|
||||
@Service(value = DriverAdapter.class, selector = "stdout")
|
||||
public class StdoutDriverAdapter extends BaseDriverAdapter<StdoutOp, StdoutSpace> implements SyntheticOpTemplateProvider {
|
||||
private final static Logger logger = LogManager.getLogger(StdoutDriverAdapter.class);
|
||||
|
||||
@Override
|
||||
public OpMapper<StdoutOp> getOpMapper() {
|
||||
DriverSpaceCache<? extends StdoutSpace> ctxCache = getSpaceCache();
|
||||
return new StdoutOpMapper(this,ctxCache);
|
||||
return new StdoutOpMapper(this, ctxCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,15 +59,18 @@ public class StdoutDriverAdapter extends BaseDriverAdapter<StdoutOp, StdoutSpace
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OpTemplate> getSyntheticOpTemplates(StmtsDocList stmtsDocList, Map<String,Object> cfg) {
|
||||
Set<String> activeBindingNames = new LinkedHashSet<>();
|
||||
public List<OpTemplate> getSyntheticOpTemplates(StmtsDocList stmtsDocList, Map<String, Object> cfg) {
|
||||
Set<String> activeBindingNames = new LinkedHashSet<>(stmtsDocList.getDocBindings().keySet());
|
||||
|
||||
if (activeBindingNames.size()==0) {
|
||||
logger.warn("Unable to synthesize op for driver=" + this.getAdapterName() + " with zero bindings.");
|
||||
return List.of();
|
||||
}
|
||||
|
||||
String bindings = Optional.ofNullable(cfg.get("bindings")).map(Object::toString).orElse("doc");
|
||||
activeBindingNames.addAll(stmtsDocList.getDocBindings().keySet());
|
||||
|
||||
Pattern bindingsFilter = Pattern.compile(bindings.equalsIgnoreCase("doc") ? ".*" : bindings);
|
||||
Set<String> filteredBindingNames = new LinkedHashSet<>();
|
||||
activeBindingNames
|
||||
|
||||
Set<String> filteredBindingNames = activeBindingNames
|
||||
.stream()
|
||||
.filter(n -> {
|
||||
if (bindingsFilter.matcher(n).matches()) {
|
||||
@ -77,16 +81,20 @@ public class StdoutDriverAdapter extends BaseDriverAdapter<StdoutOp, StdoutSpace
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.forEach(filteredBindingNames::add);
|
||||
activeBindingNames = filteredBindingNames;
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (filteredBindingNames.size() == 0) {
|
||||
logger.warn("Unable to synthesize op for driver="+getAdapterName()+" when " + activeBindingNames.size()+"/"+activeBindingNames.size() + " bindings were filtered out with bindings=" + bindings);
|
||||
return List.of();
|
||||
}
|
||||
|
||||
OpData op = new OpData("synthetic", "synthetic", Map.of(), stmtsDocList.getDocBindings(), cfg,
|
||||
Map.of("stmt", genStatementTemplate(activeBindingNames, cfg)));
|
||||
Map.of("stmt", genStatementTemplate(filteredBindingNames, cfg)));
|
||||
|
||||
return List.of(op);
|
||||
}
|
||||
|
||||
private String genStatementTemplate(Set<String> keySet, Map<String,Object> cfg) {
|
||||
private String genStatementTemplate(Set<String> keySet, Map<String, Object> cfg) {
|
||||
TemplateFormat format = Optional.ofNullable(cfg.get("format"))
|
||||
.map(Object::toString)
|
||||
.map(TemplateFormat::valueOf)
|
||||
|
@ -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.
|
||||
@ -31,6 +31,10 @@ public class RawStmtsDocList {
|
||||
return new RawStmtsDocList(List.of(rawStmtsDoc));
|
||||
}
|
||||
|
||||
public static RawStmtsDocList none() {
|
||||
return new RawStmtsDocList(List.of());
|
||||
}
|
||||
|
||||
public List<RawStmtsDoc> getStmtsDocs() {
|
||||
return rawStmtsDocList;
|
||||
}
|
||||
|
@ -41,6 +41,17 @@ public class StmtsDocList implements Iterable<StmtsDoc> {
|
||||
this.rawStmtsDocList = rawStmtsDocList;
|
||||
}
|
||||
|
||||
public static StmtsDocList none() {
|
||||
return new StmtsDocList(RawStmtsDocList.none());
|
||||
}
|
||||
|
||||
public List<StmtsDoc> getStmtDocs(String tagFilter) {
|
||||
TagFilter tf = new TagFilter(tagFilter);
|
||||
return getStmtDocs().stream()
|
||||
.filter(tf::matchesTagged)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<StmtsDoc> getStmtDocs() {
|
||||
return rawStmtsDocList.getStmtsDocs().stream()
|
||||
.map(StmtsDoc::new)
|
||||
@ -58,17 +69,14 @@ public class StmtsDocList implements Iterable<StmtsDoc> {
|
||||
*/
|
||||
public List<OpTemplate> getStmts(String tagFilterSpec) {
|
||||
TagFilter ts = new TagFilter(tagFilterSpec);
|
||||
List<OpTemplate> opTemplates = new ArrayList<>();
|
||||
|
||||
List<OpTemplate> allOpTemplates = getStmtDocs().stream()
|
||||
getStmtDocs().stream()
|
||||
.flatMap(d -> d.getStmts().stream())
|
||||
.collect(Collectors.toList());
|
||||
.filter(ts::matchesTagged)
|
||||
.forEach(opTemplates::add);
|
||||
|
||||
List<OpTemplate> filteredOpTemplates = ts.filter(allOpTemplates);
|
||||
for (String log : ts.filterLog(allOpTemplates)) {
|
||||
logger.debug(log);
|
||||
}
|
||||
|
||||
return filteredOpTemplates;
|
||||
return opTemplates;
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,7 +194,7 @@ public class SimpleActivity implements Activity, ProgressCapable, ActivityDefObs
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getAlias()+":"+getRunState()+":"+getRunStateTally().toString();
|
||||
return getAlias() + ":" + getRunState() + ":" + getRunStateTally().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -487,7 +487,7 @@ public class SimpleActivity implements Activity, ProgressCapable, ActivityDefObs
|
||||
.orElse(SequencerType.bucket);
|
||||
SequencePlanner<OpDispenser<? extends O>> planner = new SequencePlanner<>(sequencerType);
|
||||
|
||||
int dryrunCount=0;
|
||||
int dryrunCount = 0;
|
||||
for (int i = 0; i < pops.size(); i++) {
|
||||
long ratio = ratios.get(i);
|
||||
ParsedOp pop = pops.get(i);
|
||||
@ -511,7 +511,7 @@ public class SimpleActivity implements Activity, ProgressCapable, ActivityDefObs
|
||||
// }
|
||||
planner.addOp((OpDispenser<? extends O>) dispenser, ratio);
|
||||
}
|
||||
if (dryrunCount>0) {
|
||||
if (dryrunCount > 0) {
|
||||
logger.warn("initialized " + dryrunCount + " op templates for dry run only. These ops will be synthesized for each cycle, but will not be executed.");
|
||||
}
|
||||
|
||||
@ -548,7 +548,6 @@ public class SimpleActivity implements Activity, ProgressCapable, ActivityDefObs
|
||||
protected List<OpTemplate> loadOpTemplates(Optional<DriverAdapter> defaultDriverAdapter) {
|
||||
|
||||
String tagfilter = activityDef.getParams().getOptionalString("tags").orElse("");
|
||||
// StrInterpolator interp = new StrInterpolator(activityDef);
|
||||
|
||||
StmtsDocList stmtsDocList = loadStmtsDocList();
|
||||
|
||||
@ -556,13 +555,26 @@ public class SimpleActivity implements Activity, ProgressCapable, ActivityDefObs
|
||||
List<OpTemplate> filteredOps = stmtsDocList.getStmts(tagfilter);
|
||||
|
||||
if (filteredOps.size() == 0) {
|
||||
if (unfilteredOps.size() > 0) {
|
||||
if (unfilteredOps.size() > 0) { // There were no ops, and it was because they were all filtered out
|
||||
throw new BasicError("There were no active statements with tag filter '"
|
||||
+ tagfilter + "', since all " + unfilteredOps.size() + " were filtered out.");
|
||||
} else {
|
||||
// There were no ops, and it *wasn't* because they were all filtered out.
|
||||
|
||||
// In this case, let's try to synthesize the ops as long as at least a default driver was provided
|
||||
if (defaultDriverAdapter.isPresent() && defaultDriverAdapter.get() instanceof SyntheticOpTemplateProvider sotp) {
|
||||
filteredOps = sotp.getSyntheticOpTemplates(stmtsDocList, getActivityDef().getParams());
|
||||
Objects.requireNonNull(filteredOps);
|
||||
if (filteredOps.size() == 0) {
|
||||
throw new BasicError("Attempted to create synthetic ops from driver '" + defaultDriverAdapter.get().getAdapterName() + "'" +
|
||||
" but no ops were created. You must provide either a workload or an op parameter. Activities require op templates.");
|
||||
}
|
||||
} else { // But if there were no ops, and there was no default driver provided, we can't continue
|
||||
throw new BasicError("""
|
||||
No op templates were provided. You must provide one of these activity parameters:
|
||||
1) workload=some.yaml
|
||||
2) op='inline template
|
||||
3) driver=stdout (or any other drive that can synthesize ops)""");
|
||||
}
|
||||
}
|
||||
if (filteredOps.size() == 0) {
|
||||
@ -652,18 +664,17 @@ public class SimpleActivity implements Activity, ProgressCapable, ActivityDefObs
|
||||
protected StmtsDocList loadStmtsDocList() {
|
||||
|
||||
try {
|
||||
StmtsDocList stmtsDocList = new StmtsDocList(new RawStmtsDocList(List.of()));
|
||||
|
||||
Optional<String> stmt = activityDef.getParams().getOptionalString("op", "stmt", "statement");
|
||||
Optional<String> op_yaml_loc = activityDef.getParams().getOptionalString("yaml", "workload");
|
||||
if (stmt.isPresent()) {
|
||||
stmtsDocList = StatementsLoader.loadStmt(logger, stmt.get(), activityDef.getParams());
|
||||
workloadSource = "commandline:" + stmt.get();
|
||||
return StatementsLoader.loadStmt(logger, stmt.get(), activityDef.getParams());
|
||||
} else if (op_yaml_loc.isPresent()) {
|
||||
stmtsDocList = StatementsLoader.loadPath(logger, op_yaml_loc.get(), activityDef.getParams(), "activities");
|
||||
workloadSource = "yaml:" + op_yaml_loc.get();
|
||||
return StatementsLoader.loadPath(logger, op_yaml_loc.get(), activityDef.getParams(), "activities");
|
||||
}
|
||||
return stmtsDocList;
|
||||
|
||||
return StmtsDocList.none();
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new OpConfigError("Error loading op templates: " + e, workloadSource, e);
|
||||
|
@ -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.
|
||||
@ -54,7 +54,6 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
|
||||
|
||||
public StandardActivity(ActivityDef activityDef) {
|
||||
super(activityDef);
|
||||
this.adapters.putAll(adapters);
|
||||
|
||||
Optional<String> yaml_loc = activityDef.getParams().getOptionalString("yaml", "workload");
|
||||
if (yaml_loc.isPresent()) {
|
||||
@ -69,11 +68,14 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
|
||||
Optional<DriverAdapter> defaultAdapter = activityDef.getParams().getOptionalString("driver")
|
||||
.flatMap(s -> ServiceSelector.of(s, adapterLoader).get());
|
||||
|
||||
// HERE, op templates are loaded before drivers are loaded
|
||||
List<OpTemplate> opTemplates = loadOpTemplates(defaultAdapter);
|
||||
|
||||
|
||||
List<ParsedOp> pops = new ArrayList<>();
|
||||
List<DriverAdapter> adapterlist = new ArrayList<>();
|
||||
NBConfigModel supersetConfig = ConfigModel.of(StandardActivity.class).add(yamlmodel);
|
||||
|
||||
for (OpTemplate ot : opTemplates) {
|
||||
ParsedOp incompleteOpDef = new ParsedOp(ot, NBConfiguration.empty(), List.of());
|
||||
String driverName = incompleteOpDef.takeOptionalStaticValue("driver", String.class)
|
||||
@ -94,6 +96,8 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
|
||||
|
||||
if (adapter instanceof NBConfigurable configurable) {
|
||||
NBConfigModel adapterModel = configurable.getConfigModel();
|
||||
supersetConfig.add(adapterModel);
|
||||
|
||||
combinedModel = adapterModel.add(yamlmodel);
|
||||
combinedConfig = combinedModel.matchConfig(activityDef.getParams());
|
||||
configurable.applyConfig(combinedConfig);
|
||||
@ -101,6 +105,8 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
|
||||
adapters.put(driverName, adapter);
|
||||
mappers.put(driverName, adapter.getOpMapper());
|
||||
}
|
||||
supersetConfig.assertValidConfig(activityDef.getParams().getStringStringMap());
|
||||
|
||||
|
||||
DriverAdapter adapter = adapters.get(driverName);
|
||||
adapterlist.add(adapter);
|
||||
|
@ -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.
|
||||
@ -21,7 +21,6 @@ import io.nosqlbench.engine.api.activityconfig.rawyaml.RawStmtsLoader;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.Scenarios;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList;
|
||||
import io.nosqlbench.engine.api.templating.StrInterpolator;
|
||||
import io.nosqlbench.api.config.params.Synonyms;
|
||||
import io.nosqlbench.api.content.Content;
|
||||
import io.nosqlbench.api.content.NBIO;
|
||||
import io.nosqlbench.api.content.NBPathsAPI;
|
||||
@ -94,7 +93,6 @@ public class NBCLIScenarioParser {
|
||||
&& arglist.peekFirst().contains("=")
|
||||
&& !arglist.peekFirst().startsWith("-")) {
|
||||
String[] arg = arglist.removeFirst().split("=", 2);
|
||||
arg[0] = Synonyms.canonicalize(arg[0], logger);
|
||||
if (userProvidedParams.containsKey(arg[0])) {
|
||||
throw new BasicError("duplicate occurrence of option on command line: " + arg[0]);
|
||||
}
|
||||
@ -236,7 +234,6 @@ public class NBCLIScenarioParser {
|
||||
throw new BasicError("Unable to recognize scenario cmd spec in '" + commandFragment + "'");
|
||||
}
|
||||
String commandName = matcher.group("name");
|
||||
commandName = Synonyms.canonicalize(commandName, logger);
|
||||
String assignmentOp = matcher.group("oper");
|
||||
String assignedValue = matcher.group("val");
|
||||
parsedStep.put(commandName, new CmdArg(commandName, assignmentOp, assignedValue));
|
||||
|
@ -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.
|
||||
@ -255,16 +255,6 @@ public class ParamsParser {
|
||||
throw new RuntimeException("Unable to parse input:" + input);
|
||||
}
|
||||
|
||||
if (canonicalize) {
|
||||
List<String> keys = new ArrayList<>(parms.keySet());
|
||||
for (String key : keys) {
|
||||
String properkey = Synonyms.canonicalize(key, logger);
|
||||
if (!key.equals(properkey)) {
|
||||
parms.put(properkey, parms.get(key));
|
||||
parms.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
return parms;
|
||||
}
|
||||
|
||||
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.api.config.params;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* This class is just a central reference point for the names of parameters
|
||||
* or other configuration-level primitives which have been given better names.
|
||||
* For the sake of backwards compatibility, the old names are retained, but
|
||||
* deprecated and warned against.
|
||||
*/
|
||||
public class Synonyms {
|
||||
|
||||
/**
|
||||
* Each entry in this list is a list of synonyms in configuration.
|
||||
*/
|
||||
public final static Map<String, Set<String>> PARAM_SYNONYMS = new HashMap<>() {{
|
||||
put("hosts", Set.of("host" ));
|
||||
put("workload", Set.of("yaml" ));
|
||||
put("driver", Set.of("type" ));
|
||||
put("rate", Set.of("targetrate", "cyclerate" ));
|
||||
put("parameterized", Set.of("parametrized" )); // mispelling safety net
|
||||
}};
|
||||
|
||||
/**
|
||||
* use this method to convert deprecated
|
||||
* @param input A configuration string from a user or file
|
||||
* @param synonyms A list of known synonym lists with the preferred values first, like {@link #PARAM_SYNONYMS}
|
||||
* @param warnings An BiConsumer which can handle (deprecated, preferred) for subsitutions.
|
||||
* @return The configuration string in canonicalized form, with the preferred names used where possible
|
||||
*/
|
||||
public static String canonicalize(String input, Map<String, Set<String>> synonyms, BiConsumer<String,String> warnings) {
|
||||
String replaced = input;
|
||||
for (Map.Entry<String, Set<String>> syns : synonyms.entrySet()) {
|
||||
String preferred = syns.getKey();
|
||||
for (String deprecated : syns.getValue()) {
|
||||
Pattern p = Pattern.compile("\\b" + deprecated + "\\b");
|
||||
String prior = replaced;
|
||||
replaced = replaced.replaceAll(p.pattern(),preferred);
|
||||
if (!prior.equals(replaced) && warnings!=null) {
|
||||
warnings.accept(deprecated,preferred);
|
||||
}
|
||||
}
|
||||
}
|
||||
return replaced;
|
||||
}
|
||||
|
||||
public static String canonicalize(String arg, Logger logger) {
|
||||
return canonicalize(arg, PARAM_SYNONYMS, (d, p) -> logger.debug(() ->
|
||||
"rewrote synonym to canonical term (" + d +" => " + p +")"
|
||||
));
|
||||
}
|
||||
}
|
@ -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.
|
||||
@ -16,7 +16,6 @@
|
||||
|
||||
package io.nosqlbench.api.config.standard;
|
||||
|
||||
import io.nosqlbench.api.engine.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.api.errors.BasicError;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -47,14 +46,6 @@ public class ConfigModel implements NBConfigModel {
|
||||
return new ConfigModel(ofType);
|
||||
}
|
||||
|
||||
public static NBConfiguration defacto(ActivityDef def) {
|
||||
ConfigModel configModel = new ConfigModel(Object.class);
|
||||
for (Map.Entry<String, Object> entry : def.getParams().entrySet()) {
|
||||
configModel.add(Param.defaultTo(entry.getKey(), entry.getValue().toString()));
|
||||
}
|
||||
return configModel.apply(def.getParams());
|
||||
}
|
||||
|
||||
public <T> ConfigModel add(Param<T> param) {
|
||||
this.params.add(param);
|
||||
for (String name : param.getNames()) {
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.nb.api.config;
|
||||
|
||||
import io.nosqlbench.api.config.params.Synonyms;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class SynonymsTest {
|
||||
|
||||
@Test
|
||||
public void testCanonicalizeText() {
|
||||
String before = "test yaml ayamlfoo type btype typea targetrate";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String result = Synonyms.canonicalize(before, Synonyms.PARAM_SYNONYMS,
|
||||
(s, s2) -> sb.append("replaced ").append(s).append(" with ").append(s2).append("\n"));
|
||||
assertThat(result).isEqualTo("test workload ayamlfoo driver btype typea rate");
|
||||
assertThat(sb.toString()).isEqualTo("replaced type with driver\n" +
|
||||
"replaced targetrate with rate\n" +
|
||||
"replaced yaml with workload\n");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user