fix parser issues with empty template vars, make matching more relaxed

This commit is contained in:
Jonathan Shook 2022-06-30 17:25:34 -05:00
parent 2e4776f893
commit 4c34c1b2be
7 changed files with 64 additions and 76 deletions

View File

@ -13,8 +13,10 @@ scenarios:
schema: run driver=cql tags==phase:schema-astra threads==1 cycles==UNDEF schema: run driver=cql tags==phase:schema-astra threads==1 cycles==UNDEF
rampup: run driver=cql tags==phase:rampup cycles===TEMPLATE(rampup-cycles,10000000) threads=auto rampup: run driver=cql tags==phase:rampup cycles===TEMPLATE(rampup-cycles,10000000) threads=auto
main: run driver=cql tags==phase:main cycles===TEMPLATE(main-cycles,10000000) threads=auto main: run driver=cql tags==phase:main cycles===TEMPLATE(main-cycles,10000000) threads=auto
params: params:
instrument: TEMPLATE(instrument,false) instrument: TEMPLATE(instrument,false)
bindings: bindings:
machine_id: Mod(<<sources:10000>>); ToHashedUUID() -> java.util.UUID machine_id: Mod(<<sources:10000>>); ToHashedUUID() -> java.util.UUID
sensor_name: HashedLineToString('data/variable_words.txt') sensor_name: HashedLineToString('data/variable_words.txt')
@ -24,18 +26,15 @@ bindings:
station_id: Div(<<sources:10000>>);Mod(<<stations:100>>); ToHashedUUID() -> java.util.UUID station_id: Div(<<sources:10000>>);Mod(<<stations:100>>); ToHashedUUID() -> java.util.UUID
data: HashedFileExtractToString('data/lorem_ipsum_full.txt',800,1200) data: HashedFileExtractToString('data/lorem_ipsum_full.txt',800,1200)
blocks: blocks:
- tags: schema:
phase: schema
params: params:
prepared: false prepared: false
statements: ops:
- create-keyspace: | create-keyspace: |
create keyspace if not exists <<keyspace:baselines>> create keyspace if not exists <<keyspace:baselines>>
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '<<rf:1>>'} WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '<<rf:1>>'}
AND durable_writes = true; AND durable_writes = true;
tags: create-table: |
name: create-keyspace
- create-table : |
create table if not exists <<keyspace:baselines>>.<<table:iot>> ( create table if not exists <<keyspace:baselines>>.<<table:iot>> (
machine_id UUID, // source machine machine_id UUID, // source machine
sensor_name text, // sensor name sensor_name text, // sensor name
@ -51,18 +50,13 @@ blocks:
'compaction_window_size': <<expiry_minutes:60>>, 'compaction_window_size': <<expiry_minutes:60>>,
'compaction_window_unit': 'MINUTES' 'compaction_window_unit': 'MINUTES'
}; };
tags: truncate-table: |
name: create-table truncate table <<keyspace:baselines>>.<<table:iot>>;
- truncate-table: | schema-astra:
truncate table <<keyspace:baselines>>.<<table:iot>>;
tags:
name: truncate-table
- tags:
phase: schema-astra
params: params:
prepared: false prepared: false
statements: ops:
- create-table-astra : | create-table-astra: |
create table if not exists <<keyspace:baselines>>.<<table:iot>> ( create table if not exists <<keyspace:baselines>>.<<table:iot>> (
machine_id UUID, // source machine machine_id UUID, // source machine
sensor_name text, // sensor name sensor_name text, // sensor name
@ -72,69 +66,47 @@ blocks:
data text, data text,
PRIMARY KEY ((machine_id, sensor_name), time) PRIMARY KEY ((machine_id, sensor_name), time)
) WITH CLUSTERING ORDER BY (time DESC); ) WITH CLUSTERING ORDER BY (time DESC);
tags: rampup:
name: create-table-astra
- tags:
phase: rampup
params: params:
cl: <<write_cl:LOCAL_QUORUM>> cl: <<write_cl:LOCAL_QUORUM>>
statements: instrument: TEMPLATE(instrument-writes,TEMPLATE(instrument,false))
- insert-rampup: | idempotent: true
ops:
insert-rampup: |
insert into <<keyspace:baselines>>.<<table:iot>> insert into <<keyspace:baselines>>.<<table:iot>>
(machine_id, sensor_name, time, sensor_value, station_id, data) (machine_id, sensor_name, time, sensor_value, station_id, data)
values ({machine_id}, {sensor_name}, {time}, {sensor_value}, {station_id}, {data}) values ({machine_id}, {sensor_name}, {time}, {sensor_value}, {station_id}, {data})
using timestamp {cell_timestamp} using timestamp {cell_timestamp}
tags: verify:
name: insert-rampup
params:
instrument: TEMPLATE(instrument-writes,TEMPLATE(instrument,false))
idempotent: true
- tags:
phase: verify
type: read
params: params:
ratio: 1 ratio: 1
cl: <<read_cl:LOCAL_QUORUM>> cl: <<read_cl:LOCAL_QUORUM>>
statements: verify-fields: "*, -cell_timestamp"
- select-verify: | instrument: TEMPLATE(instrument-reads,TEMPLATE(instrument,false))
select * from <<keyspace:baselines>>.<<table:iot>> ops:
where machine_id={machine_id} and sensor_name={sensor_name} and time={time}; select-verify: |
verify-fields: "*, -cell_timestamp" select * from <<keyspace:baselines>>.<<table:iot>>
tags: where machine_id={machine_id} and sensor_name={sensor_name} and time={time};
name: select-verify main-read:
params:
instrument: TEMPLATE(instrument-reads,TEMPLATE(instrument,false))
- tags:
phase: main
type: read
params: params:
ratio: <<read_ratio:1>> ratio: <<read_ratio:1>>
cl: <<read_cl:LOCAL_QUORUM>> cl: <<read_cl:LOCAL_QUORUM>>
statements: instrument: TEMPLATE(instrument-reads,TEMPLATE(instrument,false))
- select-read: | ops:
select * from <<keyspace:baselines>>.<<table:iot>> select-read: |
where machine_id={machine_id} and sensor_name={sensor_name} select * from <<keyspace:baselines>>.<<table:iot>>
limit <<limit:10>> where machine_id={machine_id} and sensor_name={sensor_name}
tags: limit <<limit:10>>
name: select-read main-write:
params:
instrument: TEMPLATE(instrument-reads,TEMPLATE(instrument,false))
- tags:
phase: main
type: write
params: params:
ratio: <<write_ratio:9>> ratio: <<write_ratio:9>>
cl: <<write_cl:LOCAL_QUORUM>> cl: <<write_cl:LOCAL_QUORUM>>
statements: idempotent: true
- insert-main: | instrument: TEMPLATE(instrument-writes,TEMPLATE(instrument,false))
ops:
insert-main: |
insert into <<keyspace:baselines>>.<<table:iot>> insert into <<keyspace:baselines>>.<<table:iot>>
(machine_id, sensor_name, time, sensor_value, station_id, data) (machine_id, sensor_name, time, sensor_value, station_id, data)
values ({machine_id}, {sensor_name}, {time}, {sensor_value}, {station_id}, {data}) values ({machine_id}, {sensor_name}, {time}, {sensor_value}, {station_id}, {data})
using timestamp {cell_timestamp} using timestamp {cell_timestamp}
idempotent: true
tags:
name: insert-main
params:
instrument: TEMPLATE(instrument-writes,TEMPLATE(instrument,false))

View File

@ -36,11 +36,11 @@ blocks:
prepared: false prepared: false
ops: ops:
create-keyspace: | create-keyspace: |
create keyspace if not exists TEMPLATE(keyspace:baselines) create keyspace if not exists TEMPLATE(keyspace,baselines)
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 'TEMPLATE(rf:1)'} WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 'TEMPLATE(rf,1)'}
AND durable_writes = true; AND durable_writes = true;
create-table: | create-table: |
create table if not exists TEMPLATE(keyspace:baselines).TEMPLATE(table:keyvalue) ( create table if not exists TEMPLATE(keyspace,baselines).TEMPLATE(table,keyvalue) (
key text, key text,
value text, value text,
PRIMARY KEY (key) PRIMARY KEY (key)
@ -50,14 +50,14 @@ blocks:
prepared: false prepared: false
statements: statements:
create-table: | create-table: |
create table if not exists TEMPLATE(keyspace:baselines).TEMPLATE(table:keyvalue) ( create table if not exists TEMPLATE(keyspace,baselines).TEMPLATE(table,keyvalue) (
key text, key text,
value text, value text,
PRIMARY KEY (key) PRIMARY KEY (key)
); );
rampup: rampup:
params: params:
cl: TEMPLATE(write_cl:LOCAL_QUORUM) cl: TEMPLATE(write_cl,LOCAL_QUORUM)
ops: ops:
rampup-insert: | rampup-insert: |
insert into TEMPLATE(keyspace,baselines).TEMPLATE(table,keyvalue) insert into TEMPLATE(keyspace,baselines).TEMPLATE(table,keyvalue)

View File

@ -98,7 +98,6 @@ blocks:
where machine_id={machine_id} and sensor_name={sensor_name} where machine_id={machine_id} and sensor_name={sensor_name}
limit TEMPLATE(limit,10) limit TEMPLATE(limit,10)
main-write: main-write:
type: write
params: params:
ratio: TEMPLATE(write_ratio,9) ratio: TEMPLATE(write_ratio,9)
cl: TEMPLATE(write_cl,LOCAL_QUORUM) cl: TEMPLATE(write_cl,LOCAL_QUORUM)

View File

@ -59,11 +59,11 @@ blocks:
'compaction_window_size': <<expiry_minutes:60>>, 'compaction_window_size': <<expiry_minutes:60>>,
'compaction_window_unit': 'MINUTES' 'compaction_window_unit': 'MINUTES'
}; };
truncate-table: | truncate-table: |
truncate table <<keyspace:baselines>>.<<table:iot>>; truncate table <<keyspace:baselines>>.<<table:iot>>;
schema-astra: schema-astra:
ops: ops:
create-table-astra : | create-table-astra: |
create table if not exists <<keyspace:baselines>>.<<table:iot>> ( create table if not exists <<keyspace:baselines>>.<<table:iot>> (
machine_id UUID, // source machine machine_id UUID, // source machine
sensor_name text, // sensor name sensor_name text, // sensor name

View File

@ -43,8 +43,6 @@ blocks:
create keyspace if not exists <<keyspace:gqlcf_iot>> create keyspace if not exists <<keyspace:gqlcf_iot>>
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '<<rf:1>>'} WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '<<rf:1>>'}
AND durable_writes = true; AND durable_writes = true;
tags:
name: create-keyspace
create-table : | create-table : |
create table if not exists <<keyspace:gqlcf_iot>>.<<table:iot>> ( create table if not exists <<keyspace:gqlcf_iot>>.<<table:iot>> (
machine_id UUID, // source machine machine_id UUID, // source machine

View File

@ -423,7 +423,10 @@ public class NBCLIScenarioParser {
String match = matcher.group(1); String match = matcher.group(1);
Matcher innerMatcher = innerTemplatePattern.matcher(match); Matcher innerMatcher = innerTemplatePattern.matcher(match);
String[] matchArray = match.split(","); String[] matchArray = match.split("[,:]");
if (matchArray.length==1) {
matchArray = new String[]{matchArray[0],""};
}
// if (matchArray.length!=2) { // if (matchArray.length!=2) {
// throw new BasicError("TEMPLATE form must have two arguments separated by a comma, like 'TEMPLATE(a,b), not '" + match +"'"); // throw new BasicError("TEMPLATE form must have two arguments separated by a comma, like 'TEMPLATE(a,b), not '" + match +"'");
// } // }

View File

@ -1,3 +1,19 @@
let foo=TEMPLATE(parameter1:value1); /*
* 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.
*/
let foo=TEMPLATE(parameter1,value1);
let bar=TEMPLATE(parameter2); let bar=TEMPLATE(parameter2);
let baz; let baz;