mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-16 17:34:52 -06:00
support for Scenarios properties in Yaml Loader
This commit is contained in:
parent
6eaf35d386
commit
ef1983e2f6
@ -0,0 +1,16 @@
|
||||
package io.nosqlbench.engine.api.activityconfig.rawyaml;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class RawScenarios extends LinkedHashMap<String, LinkedList<String>> {
|
||||
|
||||
public List<String> getScenarioNames() {
|
||||
return new LinkedList<>(this.keySet());
|
||||
}
|
||||
|
||||
public List<String> getNamedScenario(String scenarioName) {
|
||||
return this.get(scenarioName);
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ import java.util.List;
|
||||
*/
|
||||
public class RawStmtsDoc extends StatementsOwner {
|
||||
|
||||
private RawScenarios scenarios = new RawScenarios();
|
||||
private List<RawStmtsBlock> blocks = new ArrayList<>();
|
||||
|
||||
/**
|
||||
@ -57,4 +58,12 @@ public class RawStmtsDoc extends StatementsOwner {
|
||||
this.blocks.clear();
|
||||
this.blocks.addAll(blocks);
|
||||
}
|
||||
|
||||
public RawScenarios getScenarios() {
|
||||
return this.scenarios;
|
||||
}
|
||||
|
||||
public void setScenarios(RawScenarios scenarios) {
|
||||
this.scenarios = scenarios;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@ -30,7 +31,7 @@ public class RawYamlStatementLoaderTest {
|
||||
private final static Logger logger = LoggerFactory.getLogger(RawYamlStatementLoaderTest.class);
|
||||
|
||||
@Test
|
||||
public void tetLoadPropertiesBlock() {
|
||||
public void testLoadPropertiesBlock() {
|
||||
RawYamlStatementLoader ysl = new RawYamlStatementLoader();
|
||||
RawStmtsDocList rawBlockDocs = ysl.load(logger, "testdocs/rawblock.yaml");
|
||||
assertThat(rawBlockDocs.getStmtsDocs()).hasSize(1);
|
||||
@ -56,5 +57,28 @@ public class RawYamlStatementLoaderTest {
|
||||
assertThat(rawStmtsBlock.getName()).isEqualTo("block0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadScenarios() {
|
||||
RawYamlStatementLoader ysl = new RawYamlStatementLoader();
|
||||
RawStmtsDocList erthing = ysl.load(logger, "testdocs/docs_blocks_stmts.yaml");
|
||||
List<RawStmtsDoc> rawStmtsDocs = erthing.getStmtsDocs();
|
||||
assertThat(rawStmtsDocs).hasSize(2);
|
||||
RawStmtsDoc rawStmtsDoc = rawStmtsDocs.get(0);
|
||||
List<RawStmtsBlock> blocks = rawStmtsDoc.getBlocks();
|
||||
RawScenarios rawScenarios = rawStmtsDoc.getScenarios();
|
||||
assertThat(rawScenarios.getScenarioNames()).containsExactly("default", "schema-only");
|
||||
List<String> defaultScenario = rawScenarios.getNamedScenario("default");
|
||||
assertThat(defaultScenario).containsExactly("run type=stdout alias=step1","run type=stdout alias=step2");
|
||||
List<String> schemaOnlyScenario = rawScenarios.getNamedScenario("schema-only");
|
||||
assertThat(schemaOnlyScenario).containsExactly("run type=blah tags=phase:schema");
|
||||
|
||||
assertThat(rawStmtsDoc.getName()).isEqualTo("doc1");
|
||||
assertThat(blocks).hasSize(1);
|
||||
RawStmtsBlock rawStmtsBlock = blocks.get(0);
|
||||
assertThat(rawStmtsBlock.getName()).isEqualTo("block0");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,40 +1,46 @@
|
||||
scenarios:
|
||||
default:
|
||||
- run type=stdout alias=step1
|
||||
- run type=stdout alias=step2
|
||||
schema-only:
|
||||
- run type=blah tags=phase:schema
|
||||
tags:
|
||||
atagname: atagvalue
|
||||
atagname: atagvalue
|
||||
name: doc1
|
||||
statements:
|
||||
- s1
|
||||
- s2
|
||||
- s1
|
||||
- s2
|
||||
bindings:
|
||||
b1 : b1d
|
||||
b2 : b2d
|
||||
b1: b1d
|
||||
b2: b2d
|
||||
params:
|
||||
param1: value1
|
||||
param1: value1
|
||||
---
|
||||
name: doc2
|
||||
tags:
|
||||
root1: val1
|
||||
root2: val2
|
||||
root1: val1
|
||||
root2: val2
|
||||
blocks:
|
||||
- name: block1
|
||||
tags:
|
||||
block1tag: tag-value1
|
||||
params:
|
||||
timeout: 23423
|
||||
foobar: baz
|
||||
bindings:
|
||||
b11: override-b11
|
||||
foobar: overized-beez
|
||||
statements:
|
||||
- s11
|
||||
- s12
|
||||
- name: block2
|
||||
tags:
|
||||
root1: value23
|
||||
statements:
|
||||
s13: statement thirteen
|
||||
s14: statement fourteen
|
||||
- name: block1
|
||||
tags:
|
||||
block1tag: tag-value1
|
||||
params:
|
||||
timeout: 23423
|
||||
foobar: baz
|
||||
bindings:
|
||||
b11: override-b11
|
||||
foobar: overized-beez
|
||||
statements:
|
||||
- s11
|
||||
- s12
|
||||
- name: block2
|
||||
tags:
|
||||
root1: value23
|
||||
statements:
|
||||
s13: statement thirteen
|
||||
s14: statement fourteen
|
||||
params:
|
||||
foobar: beez
|
||||
foobar: beez
|
||||
bindings:
|
||||
b11: b11d
|
||||
b12: b12d
|
||||
b11: b11d
|
||||
b12: b12d
|
||||
|
Loading…
Reference in New Issue
Block a user