pull op template logic into adapters-api

This commit is contained in:
Jonathan Shook 2022-06-22 22:53:56 -05:00
parent f65f9b3c7d
commit 7cf070bdae
51 changed files with 35 additions and 19 deletions

View File

@ -1,3 +1,19 @@
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@ -20,6 +36,12 @@
<dependencies>
<dependency>
<groupId>io.nosqlbench</groupId>
<artifactId>nb-spectest</artifactId>
<version>4.17.15-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.nosqlbench</groupId>
<artifactId>nb-api</artifactId>

View File

@ -43,9 +43,7 @@ public class StatementsLoader {
StmtsDocList layered = new StmtsDocList(rawDocList);
transformer.checkpointAccesses().forEach((k,v) -> {
layered.addTemplateVariable(k,v);
if (params.containsKey(k)) {
params.remove(k);
}
params.remove(k);
});
return layered;
}
@ -61,9 +59,7 @@ public class StatementsLoader {
StmtsDocList layered = new StmtsDocList(rawStmtsDocList);
transformer.checkpointAccesses().forEach((k,v) -> {
layered.addTemplateVariable(k,v);
if (params.containsKey(k)) {
params.remove(k);
}
params.remove(k);
});
return layered;
}

View File

@ -16,7 +16,6 @@
package io.nosqlbench.engine.api.activityconfig.rawyaml;
import io.nosqlbench.engine.api.activityimpl.ActivityInitializationError;
import io.nosqlbench.engine.api.templating.StrInterpolator;
import io.nosqlbench.nb.api.content.Content;
import io.nosqlbench.nb.api.content.NBIO;
@ -55,7 +54,7 @@ public class RawStmtsLoader {
data = transformer.apply(data);
}
} catch (Exception e) {
RuntimeException t = new ActivityInitializationError("Error applying string transforms to input", e);
RuntimeException t = new OpConfigError("Error applying string transforms to input", e);
throw t;
}
@ -107,7 +106,7 @@ public class RawStmtsLoader {
if (logger != null) logger.trace("Applying string transformer to yaml data:" + xform);
data = xform.apply(data);
} catch (Exception e) {
RuntimeException t = new ActivityInitializationError("Error applying string transforms to input", e);
RuntimeException t = new OpConfigError("Error applying string transforms to input", e);
throw t;
}
}

View File

@ -16,11 +16,11 @@
package io.nosqlbench.engine.api.activityconfig.rawyaml;
import io.nosqlbench.engine.api.activityimpl.ActivityInitializationError;
import io.nosqlbench.engine.api.templating.StrInterpolator;
import io.nosqlbench.nb.api.content.Content;
import io.nosqlbench.nb.api.content.NBIO;
import io.nosqlbench.nb.api.errors.BasicError;
import io.nosqlbench.nb.api.errors.OpConfigError;
import org.apache.logging.log4j.Logger;
import org.yaml.snakeyaml.Yaml;
@ -50,7 +50,7 @@ public class RawYamlLoader {
data = transformer.apply(data);
}
} catch (Exception e) {
RuntimeException t = new ActivityInitializationError("Error applying string transforms to input", e);
RuntimeException t = new OpConfigError("Error applying string transforms to input", e);
throw t;
}
@ -95,7 +95,7 @@ public class RawYamlLoader {
if (logger != null) logger.trace("Applying string transformer to yaml data:" + xform);
data = xform.apply(data);
} catch (Exception e) {
RuntimeException t = new ActivityInitializationError("Error applying string transforms to input", e);
RuntimeException t = new OpConfigError("Error applying string transforms to input", e);
throw t;
}
}

View File

@ -31,14 +31,13 @@ import io.nosqlbench.nb.spectest.testtypes.STNodeReference;
import io.nosqlbench.nb.spectest.types.STAssemblyValidator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.assertj.core.api.Assertions;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
/**
* <P>This validator looks at a {@link STNodeAssembly} as a sequence of
* 6 parsed nodes, interpreted as 3 2-tuples of name and content,
@ -119,7 +118,7 @@ public class YamlSpecValidator implements STAssemblyValidator {
List<OpTemplate> stmts = stmtsDocs.getStmts();
List<Map<String, Object>> stmt_objs = stmts.stream().map(OpTemplate::asData).collect(Collectors.toList());
assertThat(stmt_objs).isEqualTo(expectedList);
Assertions.assertThat(stmt_objs).isEqualTo(expectedList);
}
@ -158,13 +157,13 @@ public class YamlSpecValidator implements STAssemblyValidator {
Type type = new TypeToken<List<Map<String, Object>>>() {
}.getType();
List<Map<String, Object>> expectedList = gson.fromJson(json, type);
assertThat(docmaps).isEqualTo(expectedList);
Assertions.assertThat(docmaps).isEqualTo(expectedList);
System.out.println("OK");
} else if (elem.isJsonObject()) {
Map<String, Object> expectedSingle = gson.fromJson(json, Map.class);
compareEach(expectedSingle, docmaps.get(0));
assertThat(docmaps.get(0)).isEqualTo(expectedSingle);
Assertions.assertThat(docmaps.get(0)).isEqualTo(expectedSingle);
if (docmaps.size() != 1) {
throw new RuntimeException("comparator expected a single object, but found " + docmaps.size());
}
@ -187,11 +186,11 @@ public class YamlSpecValidator implements STAssemblyValidator {
}
private void compareEach(List<Map<String, Object>> expected, List<Map<String, Object>> docmaps) {
assertThat(docmaps).isEqualTo(expected);
Assertions.assertThat(docmaps).isEqualTo(expected);
}
private void compareEach(Map<String, Object> structure, Map<String, Object> stringObjectMap) {
assertThat(stringObjectMap).isEqualTo(structure);
Assertions.assertThat(stringObjectMap).isEqualTo(structure);
}
}