Merge branch 'master' into releases

This commit is contained in:
Jonathan Shook 2020-03-17 12:47:59 -05:00
commit f249a438be
19 changed files with 756 additions and 138 deletions

View File

@ -0,0 +1,39 @@
# You can run this file with this command line to see the values printed to stdout:
# ./ebdse run type=stdout yaml=bindings/date.yaml cycles=10
# This file demonstrates different types of timestamp recipes
# that you can use with virtdata. (The bindings used in ebdse)
# If you want to control the output, uncomment and edit the statement template below
# and modify the named anchors to suit your output requirements.
#statements:
# example1: "{fullname}\n"
bindings:
# All uncommented lines under this are indented, so they become named bindings below
# the entry above
# Normally, the value that you get with a cycle starts at 0.
cycleNum: Identity();
# here we convert the cycle number to a Date by casting.
id: Identity(); ToDate();
# Date during 2017 (number of milliseconds in a year: 31,536,000,000)
date: StartingEpochMillis('2017-01-01 23:59:59'); AddHashRange(0L,31536000000L); StringDateWrapper("YYYY-MM-dd")
# Example output:
# date : 2017-09-17
# date : 2017-08-01
# date : 2017-04-22
# date : 2017-04-09
# date : 2017-05-28
# date : 2017-08-06
# date : 2017-07-05
# date : 2017-02-07
# date : 2017-05-25
# date : 2017-12-02

View File

@ -0,0 +1,39 @@
# You can run this file with this command line to see the values printed to stdout:
# ./ebdse run type=stdout yaml=bindings/double.yaml cycles=10
# This file demonstrates different types of timestamp recipes
# that you can use with virtdata. (The bindings used in ebdse)
# If you want to control the output, uncomment and edit the statement template below
# and modify the named anchors to suit your output requirements.
#statements:
# example1: "{fullname}\n"
bindings:
# All uncommented lines under this are indented, so they become named bindings below
# the entry above
# Normally, the value that you get with a cycle starts at 0.
cycleNum: Identity();
# here we convert the cycle number to a double by casting.
id: Identity(); ToDouble()
## Sensor value
sensor_value: Normal(0.0,5.0); Add(100.0) -> double
# Example output:
# sensor_value : 97.65195455640468
# sensor_value : 102.36957817450308
# sensor_value : 106.1618147543308
# sensor_value : 105.69436460281086
# sensor_value : 95.76439295584129
# sensor_value : 99.79975449386073
# sensor_value : 102.3330464938251
# sensor_value : 100.58103001489948
# sensor_value : 99.15058382227814
# sensor_value : 97.17512591189272

View File

@ -0,0 +1,28 @@
# You can run this file with this command line to see the values printed to stdout:
# ./ebdse run type=stdout yaml=bindings/expr.yaml cycles=10
# This file demonstrates different types of timestamp recipes
# that you can use with virtdata. (The bindings used in ebdse)
# If you want to control the output, uncomment and edit the statement template below
# and modify the named anchors to suit your output requirements.
#statements:
# example1: "{fullname}\n"
bindings:
# flight times based on hour / minute / second computation
hour: HashRange(0,2); ToInt()
minute: Shuffle(0,2); ToInt()
second: HashRange(0,60); ToInt()
flightDate: HashRange(0,2); Mul(3600000); Save('hour'); Shuffle(0,2); Mul(60000); Save('minute'); HashRange(0,60); Mul(1000); Save('second'); Expr('hour + minute + second'); StartingEpochMillis('2018-10-02 04:00:00'); ToDate(); ToString()
flightDateFixed: Save('cycle'); HashRange(0,2); Mul(3600000); Load('cycle'); Save('hour'); Shuffle(0,2); Mul(60000); Save('minute'); Load('cycle'); HashRange(0,60); Mul(1000); Save('second'); Expr('hour + minute + second'); StartingEpochMillis('2018-10-02 04:00:00'); ToDate(); ToString()
flightDateLong: Save('cycle'); HashRange(0,2); Mul(3600000); Load('cycle'); Save('hour'); Shuffle(0,2); Mul(60000); Save('minute'); Load('cycle'); HashRange(0,60); Mul(1000); Save('second'); Expr('hour + minute + second'); ToString()
# status that depends on score
riskScore: Normal(0.0,5.0); Clamp(1, 100); Save('riskScore') -> int
status: |
Expr('riskScore > 90 ? 0 : 1') -> long; ToBoolean(); ToString()
status_2: |
ToInt(); Expr('riskScore >90 ? 0 : 1') -> int; WeightedStrings('accepted:1;rejected:1')

View File

@ -0,0 +1,36 @@
# You can run this file with this command line to see the values printed to stdout:
# ./ebdse run type=stdout yaml=bindings/timestamp.yaml cycles=10
# This file demonstrates different types of timestamp recipes
# that you can use with virtdata. (The bindings used in ebdse)
# If you want to control the output, uncomment and edit the statement template below
# and modify the named anchors to suit your output requirements.
#statements:
# example1: "{epochMillis}\n"
bindings:
# All uncommented lines under this are indented, so they become named bindings below
# the entry above
# Normally, the value that you get with a cycle starts at 0.
cycleNum: Identity();
# All uncommented lines under this are indented, so they become named bindings below
# the entry above
# You can offset the start of your millis to some formatted date.
# Notice, that in this case, the result is still in millis since the epoch
randomMillisStartingFeb2018: StartingEpochMillis('2018-02-01 05:00:00');
# You can randomly offset the value by some amount as shown below.
# In this case, the AddHashRange(...) function is internally hashing
# the input value and down-sampling it to the range specified, and then
# adding the resulting value to the input. The range is selected as
# 0,2419200000 because that is how many milliseconds there are in February.
randomMillisWithinFeb2018: AddHashRange(0,2419200000L); StartingEpochMillis('2018-02-01 05:00:00');

View File

@ -0,0 +1,172 @@
# You can run this file with this command line to see the values printed to stdout:
# ./ebdse run type=stdout yaml=bindings/text.yaml cycles=10
# This file demonstrates different types of timestamp recipes
# that you can use with virtdata. (The bindings used in ebdse)
# If you want to control the output, uncomment and edit the statement template below
# and modify the named anchors to suit your output requirements.
#statements:
# example1: "{fullname}\n"
bindings:
# All uncommented lines under this are indented, so they become named bindings below
# the entry above
# Normally, the value that you get with a cycle starts at 0.
cycleNum: Identity();
# here we convert the cycle number to a text by casting.
id: Identity(); ToString()
## Names
# See http://docs.virtdata.io/functions/funcref_premade/
# Full name
fullname: FullNames()
# Example output:
# fullname : Norman Wolf
# fullname : Lisa Harris
# fullname : John Williams
# fullname : Freda Gaytan
# fullname : Violet Ferguson
# fullname : Larry Roberts
# fullname : Andrew Daniels
# fullname : Jean Keys
# fullname : Mark Cole
# fullname : Roberta Bounds
# Name with last name first
fullname_lastname_first: Template('{}, {}', LastNames(), FirstNames())
# Example output:
# fullname_lastname_first : Miracle, Lisa
# fullname_lastname_first : Wolf, John
# fullname_lastname_first : Harris, Freda
# fullname_lastname_first : Williams, Violet
# fullname_lastname_first : Gaytan, Larry
# fullname_lastname_first : Ferguson, Andrew
# fullname_lastname_first : Roberts, Jean
# fullname_lastname_first : Daniels, Mark
# fullname_lastname_first : Keys, Roberta
# fullname_lastname_first : Cole, Timothy
# Phone
phone: compose HashRange(10000000000L,99999999999L); Combinations('0-9;0-9;0-9;-;0-9;0-9;0-9;-;0-9;0-9;0-9;0-9')
# Example output:
# $ ebdse run type=stdout yaml=example-bindings format=readout cycles=10
# phone : 241-478-6787
# phone : 784-482-7668
# phone : 804-068-5502
# phone : 044-195-5579
# phone : 237-202-5601
# phone : 916-390-8911
# phone : 550-943-7851
# phone : 762-031-1362
# phone : 234-050-2563
# phone : 312-672-0039
## Career
career: HashedLineToString('data/careers.txt')
# Example output:
# career : Paper Goods Machine Setters, Operators, and Tenders
# career : Training and Development Specialists
# career : Embossing Machine Set-Up Operators
# career : Airframe-and-Power-Plant Mechanics
# career : Sales Representatives, Agricultural
# career : Automotive Body and Related Repairers
# career : Community Health Workers
# career : Billing, Posting, and Calculating Machine Operators
# career : Data Processing Equipment Repairers
# career : Sawing Machine Setters and Set-Up Operators
## Job Description
jobdescription: Add(0); HashedLineToString('data/jobdescription.txt')
# Example output:
# jobdescription: Add(0); HashedLineToString('data/jobdescription.txt')
## Weighted enumerated values
# Sorting hat (even distribution)
house: WeightedStrings('Gryffindor:0.2;Hufflepuff:0.2;Ravenclaw:0.2;Slytherin:0.2')
# Example output:
# house : Hufflepuff
# house : Ravenclaw
# house : Slytherin
# house : Slytherin
# house : Gryffindor
# house : Hufflepuff
# house : Ravenclaw
# house : Ravenclaw
# house : Hufflepuff
# house : Hufflepuff
## Weighted prefixes
prefix: WeightedStrings('Mr:0.45;Mrs:0.25;Ms:0.1;Miss:0.1;Dr:0.05')
# Example output:
# prefix : Mr
# prefix : Mrs
# prefix : Miss
# prefix : Miss
# prefix : Mr
# prefix : Mrs
# prefix : Mrs
# prefix : Mrs
# prefix : Mr
# prefix : Mr
# prefix : Mr
# prefix : Mr
# prefix : Mrs
# prefix : Mrs
# prefix : Mr
# prefix : Mr
# prefix : Mrs
# prefix : Miss
# prefix : Ms
# prefix : Dr
## Current Employer
current_employer: HashedLineToString('data/companies.txt')
# Example output:
# current_employer : Monsanto Company
# current_employer : International Flavors & Fragrances
# current_employer : Carpenter Technology Corporation
# current_employer : Union Pacific Corporation
# current_employer : Rush Enterprises
# current_employer : Peabody Energy Corporation
# current_employer : Rockwell Automation
# current_employer : Auto-Owners Insurance Group
# current_employer : ArcBest Corporation
# current_employer : WGL Holdings
## Sensor
sensor_name: HashedLineToString('data/variable_words.txt')
# Example output:
# sensor_name : rotational_latency
# sensor_name : half_life
# sensor_name : clarity
# sensor_name : fairness
# sensor_name : diversity
# sensor_name : turbulence
# sensor_name : mode
# sensor_name : current
# sensor_name : rating
# sensor_name : stall_speed

View File

@ -0,0 +1,72 @@
# You can run this file with this command line to see the values printed to stdout:
# ./ebdse run type=stdout yaml=bindings/timestamp.yaml cycles=10
# This file demonstrates different types of timestamp recipes
# that you can use with virtdata. (The bindings used in ebdse)
# If you want to control the output, uncomment and edit the statement template below
# and modify the named anchors to suit your output requirements.
#statements:
# example1: "{epochMillis}\n"
bindings:
# All uncommented lines under this are indented, so they become named bindings below
# the entry above
# Normally, the value that you get with a cycle starts at 0.
cycleNum: Identity();
# So far, we've only been dealing in milliseconds. This is important to get working
# before adding the next step, converting to a more specific type.
# You can take any millisecond output and add conversion functions as shown below.
# this one converts to a java.util.Time
randomDateWithinFeb2018: AddHashRange(0,2419200000L); StartingEpochMillis('2018-02-01 05:00:00'); ToDate();
# ToDate(...) supports a few argument forms that you can experiment with.
# ToDate(int) will space the dates apart by this many milliseconds.
# ToDate(int,int) will space the dates apart by some millis and also repeat the value for some number of cycles.
# Alternately, you might want to use a org.joda.time.DateTime instead of a java.util.Time:
randomJodaDateWithinFeb2018: AddHashRange(0,2419200000L); StartingEpochMillis('2018-02-01 05:00:00'); ToJodaDateTime();
# ToJodaDateTime(...) also supports the space and repeat forms as shown above for ToDate(...)
# You can also have the dates in order, but with some limited out-of-order pertubation.
# In this case, we are swizzling the offset by some pseudo-random amount, up to an hour (in millis)
randomDateWithinFeb2018Jittery: AddHashRange(0,3600000L); StartingEpochMillis('2018-02-01 05:00:00'); ToDate();
# If you want to have the result be a string-formatted date representation for testing, try this:
# You can use any formatter from here: http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html
timeuuid_string: AddHashRange(0,2419200000L); StartingEpochMillis('2018-02-01 05:00:00'); StringDateWrapper("yyyy-MM-dd HH:mm:ss.SSS");
# ebdse bundles some specialized mapping functions in addition to those explained above, which
# come with eb. These are shown below.
# You can create a com.datastax.driver.core.LocalDate for use with the java driver.
# This takes as its input, the number of days since the unix epoch.
localdate: LongToLocalDateDays()
# You can also take the millis from any of the examples above which provide epoch millis,
# and convert the output to a millisecond-stable value, analogous to the CQL functions
# that do the same.
minUUID: AddHashRange(0,3600000); StartingEpochMillis('2018-02-01 05:00:00'); ToTimeUUIDMin();
maxUUID: AddHashRange(0,3600000); StartingEpochMillis('2018-02-01 05:00:00'); ToTimeUUIDMax();
# If you find useful recipes which are needed by others, please contribute them back to our examples!

View File

@ -0,0 +1,62 @@
# You can run this file with this command line to see the values printed to stdout:
# ./ebdse run type=stdout yaml=bindings/timeuuid.yaml cycles=10
# This file demonstrates different types of timestamp recipes
# that you can use with virtdata. (The bindings used in ebdse)
# If you want to control the output, uncomment and edit the statement template below
# and modify the named anchors to suit your output requirements.
#statements:
# example1: "{fullname}\n"
bindings:
# All uncommented lines under this are indented, so they become named bindings below
# the entry above
# Normally, the value that you get with a cycle starts at 0.
cycleNum: Identity();
# here we convert the cycle number to a TIMEUUID by casting.
id: Identity(); ToEpochTimeUUID()
## Client ID
client_id: AddHashRange(0L, 2000000000000L); ToEpochTimeUUID()
# Example output:
# client_id : 4eb369b0-91de-11bd-8000-000000000000
# client_id : 0b9edab0-5401-11e7-8000-000000000000
# client_id : 58f21c30-0eec-11f3-8000-000000000000
# client_id : 4f547e60-a48a-11ca-8000-000000000000
# client_id : 42db8510-cad8-11bb-8000-000000000000
# client_id : 78cc7790-529c-11d6-8000-000000000000
# client_id : 55382200-9cfd-11d7-8000-000000000000
# client_id : 1ebdbef0-b6dc-11b7-8000-000000000000
# client_id : 8bc58ba0-57fe-11da-8000-000000000000
# client_id : 03d1b690-ba64-11f5-8000-000000000000
# If you wanted a java.util.UUID instead of a java.util.Date type, you can use something like below.
# This form avoids setting the non-time fields in the timeuuid value. This makes testing determinstically
# possible, when the basic data type as used in practice, is designed specifically to avoid repeatability.
timeuuid1: AddHashRange(0,2419200000L); StartingEpochMillis('2018-02-01 05:00:00'); ToEpochTimeUUID();
# There is a shortcut for this version supported directly by ToEpochTimeUUID(..) as seen here:
timeuuid2: AddHashRange(0,2419200000L); ToEpochTimeUUID('2018-02-01 05:00:00');
# You can also access the finest level of resolution of the timeuuid type, where each cycle value represents
# the smallest possible change for a timeuuid. Bear in mind that this represents many many sub-millisecond
# level timestamp values which may not be easy to see in normal timestamp formats. In this case, millisecond
# semantics are not appropriate, so make sure you adjust the input values accordingly.
timeuuid_finest1: ToFinestTimeUUID();
# However, since starting at some reference time is a popular option, ToFinestTimeUUID(...) also supports
# the shortcut version just like ToEpochTimeUUID(). This is provided because converting between epoch
# millis and timeuuid ticks is not fun.
timeuuid_finest_relative: ToFinestTimeUUID('2018-02-01 05:00:00');

View File

@ -0,0 +1,39 @@
# You can run this file with this command line to see the values printed to stdout:
# ./ebdse run type=stdout yaml=bindings/uuid.yaml cycles=10
# This file demonstrates different types of timestamp recipes
# that you can use with virtdata. (The bindings used in ebdse)
# If you want to control the output, uncomment and edit the statement template below
# and modify the named anchors to suit your output requirements.
#statements:
# example1: "{fullname}\n"
bindings:
# All uncommented lines under this are indented, so they become named bindings below
# the entry above
# Normally, the value that you get with a cycle starts at 0.
cycleNum: Identity();
# here we convert the cycle number to a UUID by casting.
id: Identity(); ToHashedUUID()
## Station ID (100 unique UUID values, can override stations on the command-line)
station_id: Mod(<<stations:100>>); ToHashedUUID()
# Example output:
# station_id : 28df63b7-cc57-43cb-9752-fae69d1653da
# station_id : 5752fae6-9d16-43da-b20f-557a1dd5c571
# station_id : 720f557a-1dd5-4571-afb2-0dd47d657943
# station_id : 6fb20dd4-7d65-4943-9967-459343efafdd
# station_id : 19674593-43ef-4fdd-bdf4-98b19568b584
# station_id : 3df498b1-9568-4584-96fd-76f6081da01a
# station_id : 56fd76f6-081d-401a-85eb-b1d9e5bba058
# station_id : 45ebb1d9-e5bb-4058-b75d-d51547d31952
# station_id : 375dd515-47d3-4952-a49d-236be9a5c070
# station_id : 249d236b-e9a5-4070-9afa-8fae9060d959

View File

@ -9383,7 +9383,7 @@
"bundled": true,
"optional": true,
"requires": {
"minipass": "^2.6.0"
"minipass": "2.9.0"
}
},
"fs.realpath": {
@ -9411,12 +9411,12 @@
"bundled": true,
"optional": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
"inherits": "2.0.4",
"minimatch": "3.0.4",
"once": "1.4.0",
"path-is-absolute": "1.0.1"
}
},
"has-unicode": {
@ -9445,8 +9445,8 @@
"bundled": true,
"optional": true,
"requires": {
"once": "^1.3.0",
"wrappy": "1"
"once": "1.4.0",
"wrappy": "1.0.2"
}
},
"inherits": {
@ -9490,8 +9490,8 @@
"bundled": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
"safe-buffer": "5.1.2",
"yallist": "3.1.1"
}
},
"minizlib": {
@ -9499,7 +9499,7 @@
"bundled": true,
"optional": true,
"requires": {
"minipass": "^2.9.0"
"minipass": "2.9.0"
}
},
"mkdirp": {
@ -9530,16 +9530,16 @@
"bundled": true,
"optional": true,
"requires": {
"detect-libc": "^1.0.2",
"mkdirp": "^0.5.1",
"needle": "^2.2.1",
"nopt": "^4.0.1",
"npm-packlist": "^1.1.6",
"npmlog": "^4.0.2",
"rc": "^1.2.7",
"rimraf": "^2.6.1",
"semver": "^5.3.0",
"tar": "^4.4.2"
"detect-libc": "1.0.3",
"mkdirp": "0.5.1",
"needle": "2.4.0",
"nopt": "4.0.1",
"npm-packlist": "1.4.7",
"npmlog": "4.1.2",
"rc": "1.2.8",
"rimraf": "2.7.1",
"semver": "5.7.1",
"tar": "4.4.13"
}
},
"nopt": {
@ -9668,7 +9668,7 @@
"bundled": true,
"optional": true,
"requires": {
"glob": "^7.1.3"
"glob": "7.1.6"
}
},
"safe-buffer": {
@ -9737,13 +9737,13 @@
"bundled": true,
"optional": true,
"requires": {
"chownr": "^1.1.1",
"fs-minipass": "^1.2.5",
"minipass": "^2.8.6",
"minizlib": "^1.2.1",
"mkdirp": "^0.5.0",
"safe-buffer": "^5.1.2",
"yallist": "^3.0.3"
"chownr": "1.1.3",
"fs-minipass": "1.2.7",
"minipass": "2.9.0",
"minizlib": "1.3.3",
"mkdirp": "0.5.1",
"safe-buffer": "5.1.2",
"yallist": "3.1.1"
}
},
"util-deprecate": {

View File

@ -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);
}
}

View File

@ -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 getRawScenarios() {
return this.scenarios;
}
public void setScenarios(RawScenarios scenarios) {
this.scenarios = scenarios;
}
}

View File

@ -0,0 +1,21 @@
package io.nosqlbench.engine.api.activityconfig.yaml;
import io.nosqlbench.engine.api.activityconfig.rawyaml.RawScenarios;
import java.util.List;
public class Scenarios {
private RawScenarios rawScenarios;
public Scenarios(RawScenarios rawScenarios) {
this.rawScenarios = rawScenarios;
}
public List<String> getScenarioNames() {
return rawScenarios.getScenarioNames();
}
public List<String> getNamedScneario(String scenarioName) {
return rawScenarios.getNamedScenario(scenarioName);
}
}

View File

@ -104,4 +104,8 @@ public class StmtsDoc implements Tagged, Iterable<StmtsBlock> {
}
public Scenarios getScenarios() {
return new Scenarios(rawStmtsDoc.getRawScenarios());
}
}

View File

@ -17,6 +17,7 @@
package io.nosqlbench.engine.api.activityconfig.yaml;
import io.nosqlbench.engine.api.activityconfig.rawyaml.RawScenarios;
import io.nosqlbench.engine.api.activityconfig.rawyaml.RawStmtsDocList;
import io.nosqlbench.engine.api.util.TagFilter;
@ -82,4 +83,8 @@ public class StmtsDocList implements Iterable<StmtsDoc> {
.forEach(docBindings::putAll);
return docBindings;
}
public List<Scenarios> getDocScenarios() {
return this.getStmtDocs().stream().map(StmtsDoc::getScenarios).collect(Collectors.toList());
}
}

View File

@ -19,6 +19,7 @@ package io.nosqlbench.engine.api.util;
import java.io.*;
import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Optional;
@ -58,6 +59,30 @@ public class NosqlBenchFiles {
return Optional.empty();
}
public static Optional<Path> findOptionalPath(String basename, String extension, String... searchPaths) {
boolean needsExtension = (extension != null && !extension.isEmpty() && !basename.endsWith("." + extension));
String filename = basename + (needsExtension ? "." + extension : "");
ArrayList<String> paths = new ArrayList<String>() {{
add(filename);
if (!isRemote(basename)) {
addAll(Arrays.stream(searchPaths).map(s -> s + File.separator + filename)
.collect(Collectors.toCollection(ArrayList::new)));
}
}};
for (String path : paths) {
Optional<InputStream> stream = getInputStream(path);
if (stream.isPresent()) {
return Optional.of(Path.of(path));
}
}
return Optional.empty();
}
private static boolean isRemote(String path) {
return (path.toLowerCase().startsWith("http:")
|| path.toLowerCase().startsWith("https:"));

View File

@ -30,7 +30,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 +56,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.getRawScenarios();
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");
}
}

View File

@ -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

View File

@ -40,6 +40,13 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core-java8</artifactId>

View File

@ -8,6 +8,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.nio.file.Path;
import java.security.InvalidParameterException;
import java.util.*;
import java.util.stream.Collectors;
@ -313,12 +314,26 @@ public class NBCLIOptions {
Cmd script = parseScriptCmd(arglist);
cmdList.add(script);
} else {
throw new InvalidParameterException("unrecognized option:" + word);
Optional<Path> path = NosqlBenchFiles.findOptionalPath(word, "yaml", "activities");
if(path.isPresent()){
arglist.removeFirst();
arglist.addFirst("yaml="+path.toString());
Cmd script = parseWorkloladYamlCmd(arglist);
cmdList.add(script);
}
else {
throw new InvalidParameterException("unrecognized option:" + word);
}
}
}
}
}
private Cmd parseWorkloladYamlCmd(LinkedList<String> arglist) {
return null;
}
private Map<String, Level> parseLogLevelOverrides(String levelsSpec) {
Map<String,Level> levels = new HashMap<>();
Arrays.stream(levelsSpec.split("[,;]")).forEach(kp -> {
@ -549,100 +564,100 @@ public class NBCLIOptions {
histoLoggerConfigs.add(String.format("%s:%s:%s",file,pattern,interval));
}
public static enum CmdType {
start,
start2,
run,
run2,
stop,
await,
script,
fragment,
waitmillis,
public static enum CmdType {
start,
start2,
run,
run2,
stop,
await,
script,
fragment,
waitmillis,
}
public static class Cmd {
private CmdType cmdType;
private String cmdSpec;
private Map<String, String> cmdArgs;
public Cmd(CmdType cmdType, String cmdSpec) {
this.cmdSpec = cmdSpec;
this.cmdType = cmdType;
}
public static class Cmd {
private CmdType cmdType;
private String cmdSpec;
private Map<String, String> cmdArgs;
public Cmd(CmdType cmdType, String cmdSpec, Map<String, String> cmdArgs) {
this(cmdType, cmdSpec);
this.cmdArgs = cmdArgs;
}
public Cmd(CmdType cmdType, String cmdSpec) {
this.cmdSpec = cmdSpec;
this.cmdType = cmdType;
public String getCmdSpec() {
if (cmdSpec.startsWith("'") && cmdSpec.endsWith("'")) {
return cmdSpec.substring(1,cmdSpec.length()-1);
}
public Cmd(CmdType cmdType, String cmdSpec, Map<String, String> cmdArgs) {
this(cmdType, cmdSpec);
this.cmdArgs = cmdArgs;
if (cmdSpec.startsWith("\"") && cmdSpec.endsWith("\"")) {
return cmdSpec.substring(1,cmdSpec.length()-1);
}
return cmdSpec;
}
public String getCmdSpec() {
public CmdType getCmdType() {
return cmdType;
}
if (cmdSpec.startsWith("'") && cmdSpec.endsWith("'")) {
return cmdSpec.substring(1,cmdSpec.length()-1);
}
if (cmdSpec.startsWith("\"") && cmdSpec.endsWith("\"")) {
return cmdSpec.substring(1,cmdSpec.length()-1);
}
return cmdSpec;
}
public void setCmdType(CmdType cmdType) {
this.cmdType = cmdType;
}
public CmdType getCmdType() {
return cmdType;
}
public Map<String, String> getCmdArgs() {
return cmdArgs;
}
public void setCmdType(CmdType cmdType) {
this.cmdType = cmdType;
}
public String toString() {
return "type:" + cmdType + ";spec=" + cmdSpec
+ ((cmdArgs != null) ? ";cmdArgs=" + cmdArgs.toString() : "");
}
}
public Map<String, String> getCmdArgs() {
return cmdArgs;
}
public static class LoggerConfig {
public String file = "";
public String pattern = ".*";
public String interval = "30 seconds";
public String toString() {
return "type:" + cmdType + ";spec=" + cmdSpec
+ ((cmdArgs != null) ? ";cmdArgs=" + cmdArgs.toString() : "");
public LoggerConfig(String histoLoggerSpec) {
String[] words = histoLoggerSpec.split(":");
switch (words.length) {
case 3:
interval = words[2].isEmpty() ? interval : words[2];
case 2:
pattern = words[1].isEmpty() ? pattern : words[1];
case 1:
file = words[0];
if (file.isEmpty()) {
throw new RuntimeException("You must not specify an empty file here for logging data.");
}
break;
default:
throw new RuntimeException(
LOG_HISTO +
" options must be in either 'regex:filename:interval' or 'regex:filename' or 'filename' format"
);
}
}
public static class LoggerConfig {
public String file = "";
public String pattern = ".*";
public String interval = "30 seconds";
public LoggerConfig(String histoLoggerSpec) {
String[] words = histoLoggerSpec.split(":");
switch (words.length) {
case 3:
interval = words[2].isEmpty() ? interval : words[2];
case 2:
pattern = words[1].isEmpty() ? pattern : words[1];
case 1:
file = words[0];
if (file.isEmpty()) {
throw new RuntimeException("You must not specify an empty file here for logging data.");
}
break;
default:
throw new RuntimeException(
LOG_HISTO +
" options must be in either 'regex:filename:interval' or 'regex:filename' or 'filename' format"
);
}
}
public String getFilename() {
return file;
}
public String getFilename() {
return file;
}
}
private static class ProgressSpec {
public String intervalSpec;
public IndicatorMode indicatorMode;
public String toString() {
return indicatorMode.toString()+":" + intervalSpec;
}
private static class ProgressSpec {
public String intervalSpec;
public IndicatorMode indicatorMode;
public String toString() {
return indicatorMode.toString()+":" + intervalSpec;
}
}
private ProgressSpec parseProgressSpec(String interval) {
ProgressSpec progressSpec = new ProgressSpec();