incremental updates

This commit is contained in:
Jonathan Shook 2021-05-24 10:48:39 -05:00
parent 020fe51dd9
commit a667f95e56
8 changed files with 34 additions and 9 deletions

View File

@ -1,27 +1,51 @@
package io.nosqlbench.engine.api.activityconfig.rawyaml; package io.nosqlbench.engine.api.activityconfig.rawyaml;
import com.vladsch.flexmark.ast.FencedCodeBlock; import com.vladsch.flexmark.ast.FencedCodeBlock;
import com.vladsch.flexmark.util.ast.Node;
import java.nio.file.Path;
import java.util.Objects; import java.util.Objects;
final class TestSet { final class TestSet {
private final String desc; private final String desc;
private final Path path;
private final int line;
public CharSequence info; public CharSequence info;
public CharSequence text; public CharSequence text;
public TestSet(String description, CharSequence info, CharSequence text) { public TestSet(String desc, Node infoNode, Node dataNode, Path path) {
this.desc = desc;
this.info = infoNode.getChars();
this.text = dataNode.getFirstChild().getChars();
this.line = dataNode.getFirstChild().getLineNumber();
this.path = path;
}
public TestSet(String description, CharSequence info, CharSequence text, Path path, int line) {
this.desc = description; this.desc = description;
this.info = info; this.info = info;
this.text = text; this.text = text;
this.path = path;
this.line = line;
} }
public TestSet(String description, FencedCodeBlock node) { public TestSet(String description, FencedCodeBlock node, Path path) {
this.desc = description; this.desc = description;
this.info = node.getInfo(); this.info = node.getInfo();
text = Objects.requireNonNull(node.getFirstChild()).getChars(); text = Objects.requireNonNull(node.getFirstChild()).getChars();
this.path = path;
this.line = node.getLineNumber();
} }
public String getDesc() { public String getDesc() {
return desc; return desc;
} }
public Path getPath() {
return path;
}
public int getLine() {
return line;
}
} }

View File

@ -77,7 +77,7 @@ public class UniformYamlRawReaderTest {
LinkedList<TestSet> tests = new LinkedList<>(); LinkedList<TestSet> tests = new LinkedList<>();
List<Content<?>> yaml = NBIO.fs().prefix("target/test-classes/workload_definition/").name("templated_workloads").extension("md").list(); List<Content<?>> yaml = NBIO.fs().prefix("target/classes/workload_definition/").name("templated_workloads").extension("md").list();
Pattern emphasis = Pattern.compile("\\*(.*?)\\*\n"); Pattern emphasis = Pattern.compile("\\*(.*?)\\*\n");
Class<?> fcbclass = FencedCodeBlock.class; Class<?> fcbclass = FencedCodeBlock.class;
@ -98,14 +98,15 @@ public class UniformYamlRawReaderTest {
node = node.getNext(); node = node.getNext();
index=0; index=0;
} }
if (p.test(node)) { if (p.test(node)) {
List<Node> found = p.get(); List<Node> found = p.get();
// System.out.println(summarize(found)); // System.out.println(summarize(found));
String label = heading + String.format("-%02d", (++index)); String label = heading + String.format("-%02d", (++index));
testblocks.add(new TestBlock( testblocks.add(new TestBlock(
new TestSet(label,found.get(0).getChars(),found.get(1).getFirstChild().getChars()), new TestSet(label,found.get(0),found.get(1),content.asPath()),
new TestSet(label,found.get(2).getChars(),found.get(3).getFirstChild().getChars()), new TestSet(label,found.get(2),found.get(3),content.asPath()),
new TestSet(label,found.get(4).getChars(),found.get(5).getFirstChild().getChars()) new TestSet(label,found.get(4),found.get(5),content.asPath())
)); ));
node=found.get(found.size()-1); node=found.get(found.size()-1);
} }
@ -285,12 +286,12 @@ public class UniformYamlRawReaderTest {
*/ */
private void validateYamlWithJson(String desc, String yaml, String json) { private void validateYamlWithJson(String desc, String yaml, String json) {
System.out.format("%-40s","- checking yaml->json"); System.out.format("%-40s","- checking yaml->json");
List<Map<String, Object>> docmaps = new RawYamlLoader().loadString(logger, yaml);
StmtsDocList stmts = StatementsLoader.loadString(yaml); // StmtsDocList stmts = StatementsLoader.loadString(yaml);
JsonParser parser = new JsonParser(); JsonParser parser = new JsonParser();
try { try {
List<Map<String, Object>> docmaps = new RawYamlLoader().loadString(logger, yaml);
JsonElement elem = parser.parse(json); JsonElement elem = parser.parse(json);
if (elem.isJsonArray()) { if (elem.isJsonArray()) {
Type type = new TypeToken<List<Map<String, Object>>>() { Type type = new TypeToken<List<Map<String, Object>>>() {

View File

@ -500,7 +500,7 @@ public class GrafanaClient {
try { try {
response = client.send(rq, HttpResponse.BodyHandlers.ofString()); response = client.send(rq, HttpResponse.BodyHandlers.ofString());
} catch (Exception e) { } catch (Exception e) {
if (e.getMessage().contains("WWW-Authenticate header missing")) { if (e.getMessage()!=null && e.getMessage().contains("WWW-Authenticate header missing")) {
throw new RuntimeException("Java HttpClient was not authorized, and it saw no WWW-Authenticate header" + throw new RuntimeException("Java HttpClient was not authorized, and it saw no WWW-Authenticate header" +
" in the response, so this is probably Grafana telling you that the auth scheme failed. Normally " + " in the response, so this is probably Grafana telling you that the auth scheme failed. Normally " +
"this error would be thrown by Java HttpClient:" + e.getMessage()); "this error would be thrown by Java HttpClient:" + e.getMessage());