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

View File

@ -36,11 +36,11 @@ blocks:
prepared: false
ops:
create-keyspace: |
create keyspace if not exists TEMPLATE(keyspace:baselines)
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 'TEMPLATE(rf:1)'}
create keyspace if not exists TEMPLATE(keyspace,baselines)
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 'TEMPLATE(rf,1)'}
AND durable_writes = true;
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,
value text,
PRIMARY KEY (key)
@ -50,14 +50,14 @@ blocks:
prepared: false
statements:
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,
value text,
PRIMARY KEY (key)
);
rampup:
params:
cl: TEMPLATE(write_cl:LOCAL_QUORUM)
cl: TEMPLATE(write_cl,LOCAL_QUORUM)
ops:
rampup-insert: |
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}
limit TEMPLATE(limit,10)
main-write:
type: write
params:
ratio: TEMPLATE(write_ratio,9)
cl: TEMPLATE(write_cl,LOCAL_QUORUM)

View File

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

View File

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

View File

@ -423,7 +423,10 @@ public class NBCLIScenarioParser {
String match = matcher.group(1);
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) {
// 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 baz;