diff --git a/adapter-http/src/main/resources/activities/baselines/http-rest-keyvalue.yaml b/adapter-http/src/main/resources/activities/baselines/http-rest-keyvalue.yaml index 44ccddde0..52af568af 100644 --- a/adapter-http/src/main/resources/activities/baselines/http-rest-keyvalue.yaml +++ b/adapter-http/src/main/resources/activities/baselines/http-rest-keyvalue.yaml @@ -1,6 +1,6 @@ -min_version: "5.17.1" +min_version: "5.17.3" -description: | +description: >2 This workload emulates a key-value data model and access patterns. This should be identical to the cql variant except for: - There is no instrumentation with the http driver. @@ -15,9 +15,9 @@ scenarios: bindings: - weighted_hosts: ToString(); WeightedStrings('<>'); ToString(); + weighted_hosts: ToString(); WeightedStrings('<>'); ToString(); request_id: ToHashedUUID(); ToString(); - auto_gen_token: Discard(); StargateToken('http://localhost:8081/v1/auth'); ToString(); + token: Discard(); Token('<>','<>', '<>', '<>'); seq_key: Mod(<>); ToString() -> String seq_value: Hash(); Mod(<>); ToString() -> String @@ -33,7 +33,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/schemas/keyspaces Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -45,7 +45,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/schemas/keyspaces/<>/tables/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" ok-status: "[2-4][0-9][0-9]" @@ -54,7 +54,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/schemas/keyspaces/<>/tables Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -84,7 +84,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/schemas/keyspaces/<>/tables Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -113,7 +113,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/keyspaces/<>/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -130,7 +130,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/keyspaces/<>/<>/{rw_key} Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" ok-status: "[2-4][0-9][0-9]" @@ -143,7 +143,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/keyspaces/<>/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { diff --git a/adapter-http/src/main/resources/activities/baselines/http-rest-starter.yaml b/adapter-http/src/main/resources/activities/baselines/http-rest-starter.yaml new file mode 100644 index 000000000..7ccde1b13 --- /dev/null +++ b/adapter-http/src/main/resources/activities/baselines/http-rest-starter.yaml @@ -0,0 +1,123 @@ +min_version: "5.17.3" + +description: | + This starter workload uses an open source data gateway called Stargate, + which works with a simple key-value data model. + 1. Create a keyspace. + 2. Drop table if existing. + 3. Create table + +scenarios: + default: + schema: run driver=http tags==block:"schema.*" threads==1 cycles==UNDEF + rampup: run driver=http tags==block:"rampup.*" cycles===10 threads=auto + main: run driver=http tags==block:"main.*" cycles===10 threads=auto + +bindings: + request_id: ToHashedUUID(); ToString(); + token: Discard(); Token('<>','<>', '<>', '<>'); + + seq_key: Mod(10000000); ToString() -> String + seq_value: Hash(); Mod(1000000000); ToString() -> String + + rw_key: Uniform(0,10000000)->int; ToString() -> String + rw_value: Hash(); Uniform(0,1000000000)->int; ToString() -> String + + +blocks: + schema: + ops: + create-keyspace: + method: POST + uri: http://<>:8082/v2/schemas/keyspaces + Accept: "application/json" + X-Cassandra-Request-Id: "{request_id}" + X-Cassandra-Token: "{token}" + Content-Type: "application/json" + body: >2 + { + "name": "starter", + "replicas": 1 + } + + drop-table: + method: DELETE + uri: http://<>:8082/v2/schemas/keyspaces/starter/tables/http_rest_starter + Accept: "application/json" + X-Cassandra-Request-Id: "{request_id}" + X-Cassandra-Token: "{token}" + Content-Type: "application/json" + ok-status: "[2-4][0-9][0-9]" + + create-table: + method: POST + uri: http://<>:8082/v2/schemas/keyspaces/starter/tables + Accept: "application/json" + X-Cassandra-Request-Id: "{request_id}" + X-Cassandra-Token: "{token}" + Content-Type: "application/json" + body: >2 + { + "name": "http_rest_starter", + "columnDefinitions": [ + { + "name": "key", + "typeDefinition": "text" + }, + { + "name": "value", + "typeDefinition": "text" + } + ], + "primaryKey": { + "partitionKey": [ + "key" + ] + }, + "ifNotExists": true + } + + rampup: + ops: + rampup-insert: + method: POST + uri: http://<>:8082/v2/keyspaces/starter/http_rest_starter + Accept: "application/json" + X-Cassandra-Request-Id: "{request_id}" + X-Cassandra-Token: "{token}" + Content-Type: "application/json" + body: >2 + { + "key": "{seq_key}", + "value": "{seq_value}" + } + + main-read: + params: + ratio: 5 + ops: + main-select: + method: GET + uri: http://<>:8082/v2/keyspaces/starter/http_rest_starter/{rw_key} + Accept: "application/json" + X-Cassandra-Request-Id: "{request_id}" + X-Cassandra-Token: "{token}" + Content-Type: "application/json" + ok-status: "[2-4][0-9][0-9]" + + main-write: + params: + ratio: 5 + ops: + main-write: + method: POST + uri: http://<>:8082/v2/keyspaces/starter/http_rest_starter + Accept: "application/json" + X-Cassandra-Request-Id: "{request_id}" + X-Cassandra-Token: "{token}" + Content-Type: "application/json" + body: >2 + { + "key": "{rw_key}", + "value": "{rw_value}" + } \ No newline at end of file diff --git a/adapter-http/src/main/resources/activities/baselines/http-rest-tabular.yaml b/adapter-http/src/main/resources/activities/baselines/http-rest-tabular.yaml index a7c4e7384..82ad8bccc 100644 --- a/adapter-http/src/main/resources/activities/baselines/http-rest-tabular.yaml +++ b/adapter-http/src/main/resources/activities/baselines/http-rest-tabular.yaml @@ -1,4 +1,4 @@ -min_version: "5.17.1" +min_version: "5.17.3" description: | This workload emulates a tabular workload with partitions, clusters, and data fields. @@ -15,9 +15,9 @@ scenarios: main: run driver=http tags==block:"main.*" cycles===TEMPLATE(main-cycles,10) threads=auto bindings: - weighted_hosts: WeightedStrings('<>') + weighted_hosts: WeightedStrings('<>') request_id: ToHashedUUID(); ToString(); - auto_gen_token: Discard(); StargateToken('http://localhost:8081/v1/auth'); ToString(); + token: Discard(); Token('<>','<>', '<>', '<>'); # for ramp-up and verify part_layout: Div(<>); ToString() -> String @@ -42,7 +42,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/schemas/keyspaces Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -55,7 +55,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/schemas/keyspaces/<>/tables/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" ok-status: "[2-4][0-9][0-9]" @@ -64,7 +64,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/schemas/keyspaces/<>/tables Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -101,7 +101,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/keyspaces/<>/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -119,7 +119,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/keyspaces/<>/<>/{part_read}&page-size={limit} Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" main-write: @@ -131,7 +131,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/keyspaces/<>/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { diff --git a/adapter-http/src/main/resources/activities/baselines/http-rest-timeseries.yaml b/adapter-http/src/main/resources/activities/baselines/http-rest-timeseries.yaml index 026c6246f..1d4f4867a 100644 --- a/adapter-http/src/main/resources/activities/baselines/http-rest-timeseries.yaml +++ b/adapter-http/src/main/resources/activities/baselines/http-rest-timeseries.yaml @@ -1,6 +1,6 @@ -min_version: "5.17.1" +min_version: "5.17.3" -description: | +description: >2 NOTE: THIS VERSION IS NOT FUNCTIONING FULLY AND HAS AN OPEN TICKET TO INVESTIGATE: See here: https://github.com/nosqlbench/nosqlbench/issues/1148 @@ -17,14 +17,13 @@ description: | scenarios: default: schema: run driver=http tags==block:"schema.*" threads==1 cycles==UNDEF - rampup: run driver=http tags==block:"rampup.*" cycles===TEMPLATE(rampup-cycles,1) threads=auto + rampup: run driver=http tags==block:"rampup.*" cycles===TEMPLATE(rampup-cycles,3) threads=auto main: run driver=http tags==block:"main.*" cycles===TEMPLATE(main-cycles,10) threads=auto bindings: - weighted_hosts: WeightedStrings('<>') + weighted_hosts: WeightedStrings('<>') request_id: ToHashedUUID(); ToString(); - auto_gen_token: Discard(); StargateToken('http://localhost:8081/v1/auth'); ToString(); - + token: Discard(); Token('<>', '<>', '<>', '<>'); machine_id: Mod(<>); ToHashedUUID() -> java.util.UUID sensor_name: HashedLineToString('data/variable_words.txt'); time: Mul(<>L); Div(<>L); StringDateWrapper("yyyy-MM-dd'T'hh:mm:ss'Z"); @@ -40,7 +39,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/keyspaces/<>/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -51,6 +50,7 @@ blocks: "station_id": "{station_id}", "data": "{data}" } + schema: ops: create-keyspace: @@ -58,7 +58,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/schemas/keyspaces Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -71,7 +71,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/schemas/keyspaces/<>/tables/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" ok-status: "[2-4][0-9][0-9]" @@ -80,12 +80,12 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/schemas/keyspaces/<>/tables Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { "name": "<>", - "columnDefinitions": |- + "columnDefinitions": [ { "name": "machine_id", @@ -112,21 +112,21 @@ blocks: "typeDefinition": "text" } ], - "primaryKey": |- + "primaryKey": { - "partitionKey": |- + "partitionKey": [ "machine_id", "sensor_name" ], - "clusteringKey": |- + "clusteringKey": [ "time" ] }, - "tableOptions": |- + "tableOptions": { - "clusteringExpression": |- + "clusteringExpression": [ { "column": "time", @@ -146,7 +146,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/keyspaces/<>/<>?where=URLENCODE[[{"machine_id":{"$eq":"{machine_id}"},"sensor_name":{"$eq":"{sensor_name}"}}]]&page-size=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" main-write: @@ -158,7 +158,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/keyspaces/<>/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { diff --git a/adapter-http/src/main/resources/activities/baselines/http-rest.md b/adapter-http/src/main/resources/activities/baselines/http-rest.md index 54bdd1119..43a11803f 100644 --- a/adapter-http/src/main/resources/activities/baselines/http-rest.md +++ b/adapter-http/src/main/resources/activities/baselines/http-rest.md @@ -16,13 +16,15 @@ Currently supporting Stargate, with plans to make more generic where REST tokens can be commented out. Otherwise, the default automatic token generation is used. ### auto_gen_token -Use the `StargateToken('url')` unary string binding function, which auto-generates, caches, and returns a token with automatic refresh upon expiry. +Use the `Token('<>','<>', '<>', '<>');` string binding function, which auto-generates, caches, and returns a token with automatic refresh upon expiry. +When the `auth_token` is provided only that token value will be used (i.e. not auto-generated) and the rest of the passed in values for uri, uid, and pswd are ignored. -### Example -* auto_gen_token: Discard(); StargateToken('http://localhost:8081/v1/auth'); +### Example using all defaults. +token=Discard(); Token('<>','<>', '<>', '<>'); -Here `Discard()` will ignore the long input value received (by default for the binding), then the StargateToken function automates a check for a cached Stargate token. -If not already discovered, a request to the local running Stargate service will be invoked. Each subsequent cycles utilizes the cached value until a timeout occurs or the workload is restarted. +Here `Discard()` will ignore the long input value received (by default for the binding), then the Token function automates a check for a cached tokens from the endpoint provided. +If not already discovered, a request to the local running token service will be invoked. +Each subsequent cycles utilizes the cached value until a timeout occurs (default 30m) or the workload is restarted. Regardless of the option used, both will be considered to determine the value for the following: ```yaml diff --git a/adapter-http/src/main/resources/activities/documents-api/http-docsapi-crud-basic.yaml b/adapter-http/src/main/resources/activities/documents-api/http-docsapi-crud-basic.yaml index 436533ed3..7c189fb65 100644 --- a/adapter-http/src/main/resources/activities/documents-api/http-docsapi-crud-basic.yaml +++ b/adapter-http/src/main/resources/activities/documents-api/http-docsapi-crud-basic.yaml @@ -1,6 +1,6 @@ -min_version: "5.17.1" +min_version: "5.17.3" -description: | +description: >2 This workload emulates CRUD operations for the Stargate Documents API. It generates a simple JSON document to be used for writes and updates. Note that docsapi_port should reflect the port where the Docs API is exposed (defaults to 8180). @@ -22,7 +22,7 @@ bindings: weighted_hosts: WeightedStrings('<>') # http request id request_id: ToHashedUUID(); ToString(); - auto_gen_token: Discard(); StargateToken('http://localhost:8081/v1/auth'); ToString(); + token: Discard(); Token('<>','<>', '<>', '<>'); seq_key: Mod(<>); ToString() -> String random_key: Uniform(0,<>); ToString() -> String @@ -46,7 +46,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/schemas/namespaces Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -60,7 +60,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" ok-status: "[2-4][0-9][0-9]" create-docs-collection: @@ -68,7 +68,7 @@ blocks: method: POST Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -82,7 +82,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{seq_key} Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -116,7 +116,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{random_key} Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" ok-status: "[2-4][0-9][0-9]" update: @@ -126,7 +126,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{random_key} Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -159,5 +159,5 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{seq_key} Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" ok-status: "[2-4][0-9][0-9]" \ No newline at end of file diff --git a/adapter-http/src/main/resources/activities/documents-api/http-docsapi-crud-dataset.yaml b/adapter-http/src/main/resources/activities/documents-api/http-docsapi-crud-dataset.yaml index 95898531d..5b8365cc7 100644 --- a/adapter-http/src/main/resources/activities/documents-api/http-docsapi-crud-dataset.yaml +++ b/adapter-http/src/main/resources/activities/documents-api/http-docsapi-crud-dataset.yaml @@ -1,4 +1,4 @@ -min_version: "5.17.1" +min_version: "5.17.3" description: | This workload emulates CRUD operations for the Stargate Documents API. @@ -9,21 +9,12 @@ scenarios: default: schema: run driver=http tags==block:"schema.*" threads==1 cycles==UNDEF main: run driver=http tags==block:"main.*" cycles===TEMPLATE(main-cycles,TEMPLATE(docscount,10)) threads=auto errors=timer,warn - # write: run driver=http tags==block:"write.*" cycles===TEMPLATE(write-cycles,TEMPLATE(docscount,10)) threads=auto errors=timer,warn - # read: run driver=http tags==block:"read.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) threads=auto errors=timer,warn - # update: run driver=http tags==block:"update.*" cycles===TEMPLATE(update-cycles,TEMPLATE(docscount,10)) threads=auto errors=timer,warn - # delete: run driver=http tags==block:"delete.*" cycles===TEMPLATE(delete-cycles,TEMPLATE(docscount,10)) threads=auto errors=timer,warn bindings: - # To enable an optional weighted set of hosts in place of a load balancer - # Examples - # single host: docsapi_host=host1 - # multiple hosts: docsapi_host=host1,host2,host3 - # multiple weighted hosts: docsapi_host=host1:3,host2:7 weighted_hosts: WeightedStrings('<>') # http request id request_id: ToHashedUUID(); ToString(); - auto_gen_token: Discard(); StargateToken('http://localhost:8081/v1/auth'); ToString(); + token: Discard(); Token('<>','<>', '<>', '<>'); seq_key: Mod(<>); ToString() -> String random_key: Uniform(0,<>); ToString() -> String @@ -37,7 +28,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/schemas/namespaces Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -51,7 +42,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" ok-status: "[2-4][0-9][0-9]" create-docs-collection: @@ -59,7 +50,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -72,7 +63,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{seq_key} Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: "{document_json}" @@ -81,7 +72,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{random_key} Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" ok-status: "[2-4][0-9][0-9]" # TODO - what is the purpose of this? does it overwrite? is there a way to make sure it is actually overwriting existing documents? @@ -90,7 +81,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{random_key} Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: "{document_json}" @@ -99,5 +90,5 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{seq_key} Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" ok-status: "[2-4][0-9][0-9]" diff --git a/adapter-http/src/main/resources/activities/documents-api/http-docsapi-keyvalue.yaml b/adapter-http/src/main/resources/activities/documents-api/http-docsapi-keyvalue.yaml index 9c6f17892..b1f5f2135 100644 --- a/adapter-http/src/main/resources/activities/documents-api/http-docsapi-keyvalue.yaml +++ b/adapter-http/src/main/resources/activities/documents-api/http-docsapi-keyvalue.yaml @@ -1,4 +1,4 @@ -min_version: "5.17.1" +min_version: "5.17.3" description: | This workload emulates a key-value data model and access patterns. @@ -11,21 +11,13 @@ description: | scenarios: default: schema: run driver=http tags==block:"schema.*" threads==1 cycles==UNDEF - rampup: run driver=http tags==block:rampup cycles===TEMPLATE(rampup-cycles,10000000) threads=auto - main: run driver=http tags==block:main cycles===TEMPLATE(main-cycles,10000000) threads=auto + rampup: run driver=http tags==block:rampup cycles===TEMPLATE(rampup-cycles,3) threads=auto + main: run driver=http tags==block:main cycles===TEMPLATE(main-cycles,10) threads=auto bindings: - # To enable an optional weighted set of hosts in place of a load balancer - # Examples - # single host: docsapi_host=host1 - # multiple hosts: docsapi_host=host1,host2,host3 - # multiple weighted hosts: docsapi_host=host1:3,host2:7 weighted_hosts: WeightedStrings('<>') - # http request id request_id: ToHashedUUID(); ToString(); - - auto_gen_token: Discard(); StargateToken('http://localhost:8081/v1/auth'); ToString(); - + token: Discard(); Token('<>','<>', '<>', '<>'); seq_key: Mod(<>); ToString() -> String seq_value: Hash(); Mod(<>); ToString() -> String rw_key: <>)->int>>; ToString() -> String @@ -39,7 +31,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/schemas/namespaces Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -53,7 +45,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" ok-status: "[2-4][0-9][0-9]" create-docs-collection: @@ -61,7 +53,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -75,7 +67,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{seq_key} Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -91,7 +83,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{rw_key} Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" ok-status: "[2-4][0-9][0-9]" main-write: @@ -99,10 +91,9 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{rw_key} Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { "{rw_key}":"{rw_value}" - } - + } \ No newline at end of file diff --git a/adapter-http/src/main/resources/activities/documents-api/http-docsapi-search-advanced.yaml b/adapter-http/src/main/resources/activities/documents-api/http-docsapi-search-advanced.yaml index 3be55a49e..2137175b8 100644 --- a/adapter-http/src/main/resources/activities/documents-api/http-docsapi-search-advanced.yaml +++ b/adapter-http/src/main/resources/activities/documents-api/http-docsapi-search-advanced.yaml @@ -1,6 +1,6 @@ -min_version: "5.17.1" +min_version: "5.17.3" -description: | +description: >2 This workload emulates advanced search filter combinations for the Stargate Documents API. During the rampup phase, it generates documents, writes them to a collection, and then warms up the search paths. During the main phase it performs various basic search filters and times their execution. @@ -16,27 +16,41 @@ description: | # complex3: (match1 LTE 0 AND match2 EQ "true") OR (match2 EQ "false" AND match3 EQ true) scenarios: schema: run driver=http tags==block:"schema.*" threads==<> cycles==UNDEF - rampup: - write: run driver=http tags==block:"rampup-put.*" cycles===TEMPLATE(docscount,10) docpadding=TEMPLATE(docpadding,0) match-ratio=TEMPLATE(match-ratio,0.01) threads=<> errors=timer,warn - read: run driver=http tags==block:"rampup-get.*" cycles===TEMPLATE(rampup-cycles, 10) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn - main: - all: run driver=http tags==block:"main.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn - get-in: run driver=http tags==block:main-get-in,filter:in cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn - get-not-in: run driver=http tags==block:main-get-not-in cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn - get-mem-and: run driver=http tags==block:main-get-mem-and cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn - get-mem-or: run driver=http tags==block:main-get-mem-or cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn - get-complex1: run driver=http tags==block:main-get-complex1 cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn - get-complex2: run driver=http tags==block:main-get-complex2 cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn - get-complex3: run driver=http tags==block:main-get-complex3 cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + + rampup-write: >- + run driver=http tags==block:"rampup-put.*" cycles===TEMPLATE(docscount,10) docpadding=TEMPLATE(docpadding,0) + match-ratio=TEMPLATE(match-ratio,0.01) threads=<> errors=timer,warn + rampup-read: >- + run driver=http tags==block:"rampup-get.*" cycles===TEMPLATE(rampup-cycles,10) page-size=TEMPLATE(page-size,3) + fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + + main-all: >- + run driver=http tags==block:"main-get.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) + page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + main-get-in: >- + run driver=http tags==block:"main-get-in.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) + page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + main-get-not-in: >- + run driver=http tags==block:"main-get-not-in.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) + page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + main-get-mem-and: >- + run driver=http tags==block:"main-get-mem-and.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) + page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + main-get-mem-or: >- + run driver=http tags==block:"main-get-mem-or.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) + page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + main-get-complex1: >- + run driver=http tags==block:"main-get-complex1.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) + page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + main-get-complex2: >- + run driver=http tags==block:"main-get-complex2.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) + page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + main-get-complex3: >- + run driver=http tags==block:"main-get-complex3.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) + page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn bindings: - # To enable an optional weighted set of hosts in place of a load balancer - # Examples - # single host: docsapi_host=host1 - # multiple hosts: docsapi_host=host1,host2,host3 - # multiple weighted hosts: docsapi_host=host1:3,host2:7 weighted_hosts: WeightedStrings('<>') - # http request id request_id: ToHashedUUID(); ToString(); seq_key: Mod(<>); ToString() -> String @@ -56,9 +70,9 @@ bindings: match2: Identity(); CoinFunc(<>, FixedValue("true"), FixedValue("false")) match3: Identity(); CoinFunc(<>, FixedValue("true"), FixedValue("false")) + token: Discard(); Token('<>','<>', '<>', '<>'); additional_fields: ListSizedStepped(<>,Template("\"{}\":{}",Identity(),Identity())); ToString(); ReplaceAll('\[\"', ',\"'); ReplaceAll('\[', ''); ReplaceAll('\]', '') -> String - auto_gen_token: Discard(); StargateToken('http://localhost:8081/v1/auth'); ToString(); - + blocks: schema: ops: @@ -67,7 +81,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/schemas/namespaces Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -81,7 +95,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" ok-status: "[2-4][0-9][0-9]" create-docs-collection: @@ -89,21 +103,21 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - body: | + body: >2 { "name": "<>" } - rampup: + rampup-put: ops: - rampup-put: + action: method: PUT uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{seq_key} Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -133,131 +147,156 @@ blocks: {additional_fields} } - # where={"match1":{"$in":[0]}} - rampup-get-in: - driver: http + # where={"match1":{"$in":[0]}} + rampup-get-in: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"match1":{"$in":[0]}}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - # where={"match2":{"$nin":["false"]}} - rampup-get-not-in: + # where={"match2":{"$nin":["false"]}} + rampup-get-not-in: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"match2":{"$nin":["false"]}}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - # where={"match2":{"$eq":"true"},"match3":{"$ne": false}} - rampup-get-mem-and: + # where={"match2":{"$eq":"true"},"match3":{"$ne": false}} + rampup-get-mem-and: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"match2":{"$eq":"true"},"match3":{"$ne":false}}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - rampup-get-mem-or: + rampup-get-mem-or: + ops: + action: # where={"$or":[{"match1":{"$lt":1}},{"match3":{"$exists":true}}]} method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"$or":[{"match1":{"$lt":1}},{"match3":{"$exists":true}}]}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - # where={"$and":[{"match1":{"$eq":0}},{"$or":[{"match2":{"$eq":"true"}},{"match3":{"$eq":false}}]}]} - rampup-get-complex1: + # where={"$and":[{"match1":{"$eq":0}},{"$or":[{"match2":{"$eq":"true"}},{"match3":{"$eq":false}}]}]} + rampup-get-complex1: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"$and":[{"match1":{"$eq":0}},{"$or":[{"match2":{"$eq":"true"}},{"match3":{"$eq":false}}]}]}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - rampup-get-complex2: - # where={"$and":[{"$or":[{"match1":{"$lte":0}},{"match2":{"$eq":"false"}}]},{"$or":[{"match2":{"$eq":"false"}},{"match3":{"$eq":true}}]}]} + # where={"$and":[{"$or":[{"match1":{"$lte":0}},{"match2":{"$eq":"false"}}]},{"$or":[{"match2":{"$eq":"false"}},{"match3":{"$eq":true}}]}]} + rampup-get-complex2: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"$and":[{"$or":[{"match1":{"$lte":0}},{"match2":{"$eq":"false"}}]},{"$or":[{"match2":{"$eq":"false"}},{"match3":{"$eq":true}}]}]}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - # where={"$or":[{"$and":[{"match1":{"$lte":0}},{"match2":{"$eq":"true"}}]},{"$and":[{"match2":{"$eq":"false"}},{"match3":{"$eq":true}}]}]} - rampup-get-complex3: + # where={"$or":[{"$and":[{"match1":{"$lte":0}},{"match2":{"$eq":"true"}}]},{"$and":[{"match2":{"$eq":"false"}},{"match3":{"$eq":true}}]}]} + rampup-get-complex3: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"$or":[{"$and":[{"match1":{"$lte":0}},{"match2":{"$eq":"true"}}]},{"$and":[{"match2":{"$eq":"false"}},{"match3":{"$eq":true}}]}]}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - main: + # where={"match1":{"$in":[0]}} + main-get-in: ops: - # where={"match1":{"$in":[0]}} - main-get-in: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"match1":{"$in":[0]}}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - # where={"match2":{"$nin":["false"]}} - main-get-not-in: + # where={"match2":{"$nin":["false"]}} + main-get-not-in: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"match2":{"$nin":["false"]}}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - # where={"match2":{"$eq":"true"},"match3":{"$ne": false}} - main-get-mem-and: + # where={"match2":{"$eq":"true"},"match3":{"$ne": false}} + main-get-mem-and: + oops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"match2":{"$eq":"true"},"match3":{"$ne":false}}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - # where={"$or":[{"match1":{"$lt":1}},{"match3":{"$exists":true}}]} - main-get-mem-or: + # where={"$or":[{"match1":{"$lt":1}},{"match3":{"$exists":true}}]} + main-get-mem-or: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"$or":[{"match1":{"$lt":1}},{"match3":{"$exists":true}}]}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - # where={"$and":[{"match1":{"$eq":0}},{"$or":[{"match2":{"$eq":"true"}},{"match3":{"$eq":false}}]}]} - main-get-complex1: + # where={"$and":[{"match1":{"$eq":0}},{"$or":[{"match2":{"$eq":"true"}},{"match3":{"$eq":false}}]}]} + main-get-complex1: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"$and":[{"match1":{"$eq":0}},{"$or":[{"match2":{"$eq":"true"}},{"match3":{"$eq":false}}]}]}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - # where={"$and":[{"$or":[{"match1":{"$lte":0}},{"match2":{"$eq":"false"}}]},{"$or":[{"match2":{"$eq":"false"}},{"match3":{"$eq":true}}]}]} - main-get-complex2: + # where={"$and":[{"$or":[{"match1":{"$lte":0}},{"match2":{"$eq":"false"}}]},{"$or":[{"match2":{"$eq":"false"}},{"match3":{"$eq":true}}]}]} + main-get-complex2: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"$and":[{"$or":[{"match1":{"$lte":0}},{"match2":{"$eq":"false"}}]},{"$or":[{"match2":{"$eq":"false"}},{"match3":{"$eq":true}}]}]}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - # where={"$or":[{"$and":[{"match1":{"$lte":0}},{"match2":{"$eq":"true"}}]},{"$and":[{"match2":{"$eq":"false"}},{"match3":{"$eq":true}}]}]} - main-get-complex3: + # where={"$or":[{"$and":[{"match1":{"$lte":0}},{"match2":{"$eq":"true"}}]},{"$and":[{"match2":{"$eq":"false"}},{"match3":{"$eq":true}}]}]} + main-get-complex3: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"$or":[{"$and":[{"match1":{"$lte":0}},{"match2":{"$eq":"true"}}]},{"$and":[{"match2":{"$eq":"false"}},{"match3":{"$eq":true}}]}]}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" diff --git a/adapter-http/src/main/resources/activities/documents-api/http-docsapi-search-basic.yaml b/adapter-http/src/main/resources/activities/documents-api/http-docsapi-search-basic.yaml index 92704dfcc..544813e45 100644 --- a/adapter-http/src/main/resources/activities/documents-api/http-docsapi-search-basic.yaml +++ b/adapter-http/src/main/resources/activities/documents-api/http-docsapi-search-basic.yaml @@ -1,4 +1,4 @@ -min_version: "5.17.1" +min_version: "5.17.3" description: | This workload emulates basic search operations for the Stargate Documents API. @@ -7,28 +7,39 @@ description: | Note that docsapi_port should reflect the port where the Docs API is exposed (defaults to 8180). scenarios: - schema: run driver=http tags==block:"schema.*" threads==<> cycles==UNDEF - rampup: - write: run driver=http tags==name:'rampup-put.*' cycles===TEMPLATE(docscount,10) docpadding=TEMPLATE(docpadding,0) match-ratio=TEMPLATE(match-ratio,0.01) threads=<> errors=timer,warn - read: run driver=http tags==name:'rampup-get.*' cycles===TEMPLATE(rampup-cycles, 10) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn - main: - all: run driver=http tags==block:main cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn - get-eq: run driver=http tags==name:main-get-eq,filter:eq cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn - get-lt: run driver=http tags==name:main-get-lt cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn - get-and: run driver=http tags==name:main-get-and cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn - get-or: run driver=http tags==name:main-get-or cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn - get-or-single-match: run driver=http tags==name:main-get-or-single-match cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + schema: >- + run driver=http tags==block:"schema.*" threads==<> cycles==UNDEF + rampup-write: >- + run driver=http tags==name:"rampup-put.*" cycles===TEMPLATE(docscount,10) + docpadding=TEMPLATE(docpadding,0) match-ratio=TEMPLATE(match-ratio,0.01) threads=<> errors=timer,warn + rampup-read: >- + run driver=http tags==name:"rampup-get.*" cycles===TEMPLATE(rampup-cycles,10) + page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + main-all: >- + run driver=http tags==block:"main-get.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) + page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + main-get-equal: >- + run driver=http tags==name:"main-get-equal.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) + page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + main-get-lt: >- + run driver=http tags==name:"main-get-lt.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) + page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + main-get-and: >- + run driver=http tags==name:"main-get-and.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) + page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + main-get-or: >- + run driver=http tags==name:"main-get-or.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) + page-size=TEMPLATE(page-size,3) fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn + main-get-or-single-match: >- + run driver=http tags==name:"main-get-or-single-match.*" + cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10)) page-size=TEMPLATE(page-size,3) + fields=TEMPLATE(fields,%5b%5d) threads=<> errors=timer,warn bindings: - # To enable an optional weighted set of hosts in place of a load balancer - # Examples - # single host: docsapi_host=host1 - # multiple hosts: docsapi_host=host1,host2,host3 - # multiple weighted hosts: docsapi_host=host1:3,host2:7 weighted_hosts: WeightedStrings('<>') # http request id request_id: ToHashedUUID(); ToString(); - auto_gen_token: Discard(); StargateToken('http://localhost:8081/v1/auth'); ToString(); + token: Discard(); Token('<>','<>', '<>', '<>'); seq_key: Mod(<>); ToString() -> String random_key: Uniform(0,<>); ToString() -> String @@ -55,7 +66,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/schemas/namespaces Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -69,7 +80,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" ok-status: "[2-4][0-9][0-9]" create-docs-collection: @@ -77,21 +88,21 @@ blocks: uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { "name": "<>" } - rampup: + rampup-put: ops: - rampup-put: + action: method: PUT uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{seq_key} Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -121,94 +132,101 @@ blocks: {additional_fields} } - # where={"match3":{"$eq":true}} - rampup-get-eq: + # where={"match3":{"$eq":true}} + rampup-get-eq: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"match3":{"$eq":true}}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" # where={"match1":{"$lt":1}} - rampup-get-lt: + rampup-get-lt: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"match1":{"$lt":1}}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" # where={"match1":{"$lt":1},"match2":{"$eq":"true"}} - rampup-get-and: + rampup-get-and: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"match1":{"$lt":1},"match2":{"$eq":"true"}}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" # where={"$or":[{"match1":{"$lt":1}},{"match3":{"$eq":true}}]} - rampup-get-or: + rampup-get-or: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"$or":[{"match1":{"$lt":1}},{"match3":{"$eq":true}}]}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - # where={"$or":[{"match1":{"$lt":1}},{"match2":{"$eq":"notamatch"}}]} - main-get-or-single-match: + # where={"$or":[{"match1":{"$lt":1}},{"match2":{"$eq":"notamatch"}}]} + main-get-or-single-match: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"$or":[{"match1":{"$lt":1}},{"match2":{"$eq":"notamatch"}}]}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" # where={"match3":{"$eq":true}} - main: + main-get-equal: ops: - main-get-eq: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"match3":{"$eq":true}}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - # where={"match1":{"$lt":1}} - main-get-lt: + # where={"match1":{"$lt":1}} + main-get-lt: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"match1":{"$lt":1}}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - # where={"match1":{"$lt":1},"match2":{"$eq":"true"}} - main-get-and: + # where={"match1":{"$lt":1},"match2":{"$eq":"true"}} + main-get-and: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"match1":{"$lt":1},"match2":{"$eq":"true"}}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - # where={"$or":[{"match1":{"$lt":1}},{"match3":{"$eq":true}}]} - main-get-or: + # where={"$or":[{"match1":{"$lt":1}},{"match3":{"$eq":true}}]} + main-get-or: + ops: + action: method: GET uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"$or":[{"match1":{"$lt":1}},{"match3":{"$eq":true}}]}]]&page-size=<>&fields=<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" - Content-Type: "application/json" - - # where={"$or":[{"match1":{"$lt":1}},{"match2":{"$eq":"notamatch"}}]} - main-get-or-single-match: - method: GET - uri: <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>?where=URLENCODE[[{"$or":[{"match1":{"$lt":1}},{"match2":{"$eq":"notamatch"}}]}]]&page-size=<>&fields=<> - Accept: "application/json" - X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" diff --git a/adapter-http/src/main/resources/activities/graphql-cql-first/http-graphql-cql-keyvalue.yaml b/adapter-http/src/main/resources/activities/graphql-cql-first/http-graphql-cql-keyvalue.yaml index 3511bb61d..a3a14bb04 100644 --- a/adapter-http/src/main/resources/activities/graphql-cql-first/http-graphql-cql-keyvalue.yaml +++ b/adapter-http/src/main/resources/activities/graphql-cql-first/http-graphql-cql-keyvalue.yaml @@ -1,4 +1,4 @@ -min_version: "5.17.1" +min_version: "5.17.3" description: | This workload emulates a key-value data model and access patterns. @@ -10,19 +10,13 @@ description: | scenarios: default: schema: run driver=http tags==block:"schema.*" threads==1 cycles==UNDEF - rampup: run driver=http tags==block:rampup cycles===TEMPLATE(rampup-cycles,10) threads=auto + rampup: run driver=http tags==block:"rampup.*" cycles===TEMPLATE(rampup-cycles,10) threads=auto main: run driver=http tags==block:"main.*" cycles===TEMPLATE(main-cycles,10) threads=auto bindings: - # To enable an optional weighted set of hosts in place of a load balancer - # Examples - # single host: graphql_host=host1 - # multiple hosts: graphql_host=host1,host2,host3 - # multiple weighted hosts: graphql_host=host1:3,host2:7 weighted_hosts: WeightedStrings('<>') - # http request id request_id: ToHashedUUID(); ToString(); - auto_gen_token: Discard(); StargateToken('http://localhost:8081/v1/auth'); ToString(); + token: Discard(); Token('<>','<>', '<>', '<>'); seq_key: Mod(<>); ToString() -> String seq_value: Hash(); Mod(<>); ToString() -> String @@ -37,17 +31,17 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql-schema Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 - {"quersy":"mutation {\n createKeyspace(name:\"<>\", replicas: <>, ifNotExists: true)\n}"} + {"query":"mutation {\n createKeyspace(name:\"<>\", replicas: <>, ifNotExists: true)\n}"} create-table: method: POST uri: <>://{weighted_hosts}:<><>/graphql-schema Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: | {"query":"mutation {\n createTable(\n keyspaceName: \"<>\"\n tableName: \"<>\"\n partitionKeys: [{ name: \"key\", type: { basic: TEXT } }]\n values: [{ name: \"value\", type: { basic: TEXT } }]\n ifNotExists: true\n )\n}"} @@ -59,7 +53,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: | {"query":"mutation {\n insert<>( value: {key: \"{seq_key}\", value: \"{seq_value}\",}) {value {key, value}}}"} @@ -73,7 +67,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: | {"query":"{<>(value: {key: \"{rw_key}\"}) {values {key, value}}}"} @@ -87,7 +81,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: | {"query":"mutation {\n insert<>( value: {key: \"{rw_key}\", value: \"{rw_value}\",}) {value {key, value}}}"} diff --git a/adapter-http/src/main/resources/activities/graphql-cql-first/http-graphql-cql-tabular.yaml b/adapter-http/src/main/resources/activities/graphql-cql-first/http-graphql-cql-tabular.yaml index 516b968df..8e55ca6fe 100644 --- a/adapter-http/src/main/resources/activities/graphql-cql-first/http-graphql-cql-tabular.yaml +++ b/adapter-http/src/main/resources/activities/graphql-cql-first/http-graphql-cql-tabular.yaml @@ -1,4 +1,4 @@ -min_version: "5.17.1" +min_version: "5.17.3" description: | This workload emulates a tabular workload with partitions, clusters, and data fields. @@ -11,45 +11,38 @@ description: | scenarios: default: schema: run driver=http tags==block:"schema.*" threads==1 cycles==UNDEF - rampup: run driver=http tags==block:rampup cycles===TEMPLATE(rampup-cycles,10) threads=auto - main: run driver=http tags==block:"main.*" cycles===TEMPLATE(main-cycles,10) threads=auto + rampup-insert: run driver=http tags==block:"rampup-insert.*" cycles===TEMPLATE(rampup-cycles,12) threads=auto + main-read: run driver=http tags==block:"main-read.*" cycles===TEMPLATE(main-cycles,12) threads=auto + main-write: run driver=http tags==block:"main-write.*" cycles===TEMPLATE(main-cycles,12) threads=auto bindings: - # To enable an optional weighted set of hosts in place of a load balancer - # Examples - # single host: graphql_host=host1 - # multiple hosts: graphql_host=host1,host2,host3 - # multiple weighted hosts: graphql_host=host1:3,host2:7 weighted_hosts: WeightedStrings('<>') - # http request id request_id: ToHashedUUID(); ToString(); - auto_gen_token: Discard(); StargateToken('http://localhost:8081/v1/auth'); ToString(); - # for ramp-up and verify + token: Discard(); Token('<>','<>', '<>', '<>'); + part_layout: Div(<>); ToString() -> String clust_layout: Mod(<>); ToString() -> String data: HashedFileExtractToString('data/lorem_ipsum_full.txt',50,150); URLEncode(); - # for read + limit: Uniform(1,10) -> int part_read: Uniform(0,<>)->int; ToString() -> String clust_read: Add(1); Uniform(0,<>)->int; ToString() -> String - # for write + part_write: Hash(); Uniform(0,<>)->int; ToString() -> String clust_write: Hash(); Add(1); Uniform(0,<>)->int; ToString() -> String data_write: Hash(); HashedFileExtractToString('data/lorem_ipsum_full.txt',50,150); URLEncode(); blocks: schema: - tags: - block: schema ops: create-keyspace: method: POST uri: <>://{weighted_hosts}:<><>/graphql-schema Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - body: | + body: >2 {"query":"mutation {\n createKeyspace(name:\"<>\", replicas: <>, ifNotExists: true)\n}"} create-table: @@ -57,47 +50,48 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql-schema Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - body: | + body: >2 {"query":"mutation {\n createTable(\n keyspaceName: \"<>\"\n tableName: \"<>\"\n partitionKeys: [{ name: \"part\", type: { basic: TEXT } }]\n clusteringKeys: [{ name: \"clust\", type: { basic: TEXT } }]\n values: [{ name: \"data\", type: { basic: TEXT } }]\n ifNotExists: true\n )\n}\n"} - rampup: + rampup-insert: ops: - rampup-insert: + action: method: POST uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - body: | + body: >2 {"query":"mutation {\n insert<>( value: {part: \"{part_layout}\", clust: \"{clust_layout}\", data: \"{data}\"}) {value {part, clust, data}}}"} main-read: params: ratio: 5 ops: - main-select: + action: method: POST uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 {"query":"{<>(value: {part: \"{part_read}\"}, options: { pageSize: <> }) {values {part, clust, data}}}"} + main-write: params: ratio: 5 ops: - main-write: + action: method: POST uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 - {"query":"mutation {\n insert<>( value: {part: \"{part_write}\", clust: \"{clust_write}\", data: \"{data_write}\"}) {value {part, clust, data}}}"} + {"query":"mutation {\n insert<>( value: {part: \"{part_write}\", clust: \"{clust_write}\", data: \"{data_write}\"}) {value {part, clust, data}}}"} \ No newline at end of file diff --git a/adapter-http/src/main/resources/activities/graphql-cql-first/http-graphql-cql-timeseries.yaml b/adapter-http/src/main/resources/activities/graphql-cql-first/http-graphql-cql-timeseries.yaml index 816120e77..1934e5547 100644 --- a/adapter-http/src/main/resources/activities/graphql-cql-first/http-graphql-cql-timeseries.yaml +++ b/adapter-http/src/main/resources/activities/graphql-cql-first/http-graphql-cql-timeseries.yaml @@ -1,4 +1,4 @@ -min_version: "5.17.1" +min_version: "5.17.3" description: | This workload emulates a time-series data model and access patterns. @@ -15,19 +15,14 @@ scenarios: default: schema: run driver=http tags==block:schema threads==1 cycles==UNDEF rampup: run driver=http tags==block:rampup cycles===TEMPLATE(rampup-cycles,10) threads=auto - main: run driver=http tags==block:"main.*" cycles===TEMPLATE(main-cycles,10) threads=auto + main-read: run driver=http tags==block:"main-read.*" cycles===TEMPLATE(main-cycles,10) threads=auto + main-write: run driver=http tags==block:"main-write.*" cycles===TEMPLATE(main-cycles,10) threads=auto + bindings: - # To enable an optional weighted set of hosts in place of a load balancer - # Examples - # single host: graphql_host=host1 - # multiple hosts: graphql_host=host1,host2,host3 - # multiple weighted hosts: graphql_host=host1:3,host2:7 weighted_hosts: WeightedStrings('<>') - - # http request id request_id: ToHashedUUID(); ToString(); - auto_gen_token: Discard(); StargateToken('http://localhost:8081/v1/auth'); ToString(); + token: Discard(); Token('<>','<>', '<>', '<>'); machine_id: Mod(<>); ToHashedUUID() -> java.util.UUID sensor_name: HashedLineToString('data/variable_words.txt') @@ -46,7 +41,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql-schema Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 {"query":"mutation {\n createKeyspace(name:\"<>\", replicas: <>, ifNotExists: true)\n}"} @@ -56,7 +51,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql-schema Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 {"query":"mutation {\n createTable(\n keyspaceName: \"<>\"\n tableName: \"<>\"\n partitionKeys: [{ name: \"machine_id\", type: { basic: UUID } }, { name: \"sensor_name\", type: { basic: TEXT } }]\n clusteringKeys: [{ name: \"time\", type: { basic: TIMESTAMP }, order: \"DESC\" }]\n values: [{ name: \"sensor_value\", type: { basic: FLOAT } }, { name: \"station_id\", type: { basic: UUID } }, { name: \"data\", type: { basic: TEXT } }]\n ifNotExists: true\n )\n}\n"} @@ -68,7 +63,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 {"query":"mutation insertReading {\n reading: insert<>( value: {machine_id: \"{machine_id}\", sensor_name: \"{sensor_name}\", time: \"{time}\", data: \"{data}\", sensor_value: {sensor_value}, station_id: \"{station_id}\"}) {value {machine_id, sensor_name, time, data, sensor_value, station_id}}}"} @@ -82,9 +77,9 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" - body: | + body: >2 {"query":"query readings {<>(value: {machine_id: \"{machine_id}\",sensor_name: \"{sensor_name}\"}, options: { pageSize: <> }) {values {machine_id, sensor_name, time, data, sensor_value, station_id}}}"} main-write: @@ -96,7 +91,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 {"query":"mutation insertReading {\n reading: insert<>( value: {machine_id: \"{machine_id}\", sensor_name: \"{sensor_name}\", time: \"{time}\", data: \"{data}\", sensor_value: {sensor_value}, station_id: \"{station_id}\"}) {value {machine_id, sensor_name, time, data, sensor_value, station_id}}}"} diff --git a/adapter-http/src/main/resources/activities/graphql-schema-first/http-graphql-keyvalue.yaml b/adapter-http/src/main/resources/activities/graphql-schema-first/http-graphql-keyvalue.yaml index 3c531bd3f..f9c8da750 100644 --- a/adapter-http/src/main/resources/activities/graphql-schema-first/http-graphql-keyvalue.yaml +++ b/adapter-http/src/main/resources/activities/graphql-schema-first/http-graphql-keyvalue.yaml @@ -1,4 +1,4 @@ -min_version: "5.17.1" +min_version: "5.17.3" # TODO # - do we need a truncate schema / namespace at the end @@ -18,16 +18,9 @@ scenarios: main: run driver=http tags==block:"main.*" cycles===TEMPLATE(main-cycles,10) threads=auto bindings: - # To enable an optional weighted set of hosts in place of a load balancer - # Examples - # single host: graphql_host=host1 - # multiple hosts: graphql_host=host1,host2,host3 - # multiple weighted hosts: graphql_host=host1:3,host2:7 weighted_hosts: WeightedStrings('<>') - # http request id - request_id: ToHashedUUID(); ToString(); - auto_gen_token: Discard(); StargateToken('http://localhost:8081/v1/auth'); ToString(); + token: Discard(); Token('<>','<>', '<>', '<>'); seq_key: Mod(<>); ToString() -> String seq_value: Hash(); Mod(<>); ToString() -> String @@ -43,7 +36,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql-schema Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -55,7 +48,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql-admin Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -69,7 +62,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -85,7 +78,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -101,7 +94,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { diff --git a/adapter-http/src/main/resources/activities/graphql-schema-first/http-graphql-tabular.yaml b/adapter-http/src/main/resources/activities/graphql-schema-first/http-graphql-tabular.yaml index f31430906..f85bb661c 100644 --- a/adapter-http/src/main/resources/activities/graphql-schema-first/http-graphql-tabular.yaml +++ b/adapter-http/src/main/resources/activities/graphql-schema-first/http-graphql-tabular.yaml @@ -1,4 +1,4 @@ -min_version: "5.17.1" +min_version: "5.17.3" # TODO # - do we need a truncate schema / namespace at the end @@ -20,26 +20,18 @@ scenarios: main: run driver=http tags==block:"main.*" cycles===TEMPLATE(main-cycles,10) threads=auto bindings: - # To enable an optional weighted set of hosts in place of a load balancer - # Examples - # single host: graphql_host=host1 - # multiple hosts: graphql_host=host1,host2,host3 - # multiple weighted hosts: graphql_host=host1:3,host2:7 weighted_hosts: WeightedStrings('<>') - - # http request id request_id: ToHashedUUID(); ToString(); - auto_gen_token: Discard(); StargateToken('http://localhost:8081/v1/auth'); ToString(); + token: Discard(); Token('<>','<>', '<>', '<>'); - # for ramp-up and verify part_layout: Div(<>); ToString() -> String clust_layout: Mod(<>); ToString() -> String data: HashedFileExtractToString('data/lorem_ipsum_full.txt',50,150); URLEncode(); - # for read + limit: Uniform(1,10) -> int part_read: Uniform(0,<>)->int; ToString() -> String clust_read: Add(1); Uniform(0,<>)->int; ToString() -> String - # for write + part_write: Hash(); Uniform(0,<>)->int; ToString() -> String clust_write: Hash(); Add(1); Uniform(0,<>)->int; ToString() -> String data_write: Hash(); HashedFileExtractToString('data/lorem_ipsum_full.txt',50,150); URLEncode(); @@ -52,7 +44,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql-schema Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -64,7 +56,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql-admin Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -78,7 +70,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -94,7 +86,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -110,7 +102,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { diff --git a/adapter-http/src/main/resources/activities/graphql-schema-first/http-graphql-timeseries.yaml b/adapter-http/src/main/resources/activities/graphql-schema-first/http-graphql-timeseries.yaml index b9d6c3f5c..580443e29 100644 --- a/adapter-http/src/main/resources/activities/graphql-schema-first/http-graphql-timeseries.yaml +++ b/adapter-http/src/main/resources/activities/graphql-schema-first/http-graphql-timeseries.yaml @@ -1,4 +1,4 @@ -min_version: "5.17.1" +min_version: "5.17.3" # TODO # - do we need a truncate schema / namespace at the end @@ -24,16 +24,10 @@ scenarios: main: run driver=http tags==block:"main.*" cycles===TEMPLATE(main-cycles,10) threads=auto bindings: - # To enable an optional weighted set of hosts in place of a load balancer - # Examples - # single host: graphql_host=host1 - # multiple hosts: graphql_host=host1,host2,host3 - # multiple weighted hosts: graphql_host=host1:3,host2:7 weighted_hosts: WeightedStrings('<>') - # http request id request_id: ToHashedUUID(); ToString(); - auto_gen_token: Discard(); StargateToken('http://localhost:8081/v1/auth'); ToString(); + token: Discard(); Token('<>','<>', '<>', '<>'); machine_id: Mod(<>); ToHashedUUID() -> java.util.UUID sensor_name: HashedLineToString('data/variable_words.txt') @@ -50,7 +44,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql-schema Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -62,7 +56,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql-admin Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -76,7 +70,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -92,7 +86,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { @@ -108,7 +102,7 @@ blocks: uri: <>://{weighted_hosts}:<><>/graphql/<> Accept: "application/json" X-Cassandra-Request-Id: "{request_id}" - X-Cassandra-Token: "<>" + X-Cassandra-Token: "{token}" Content-Type: "application/json" body: >2 { diff --git a/adapter-mongodb/src/main/resources/activities/baselinesv2/mongodb-keyvalue2.yaml b/adapter-mongodb/src/main/resources/activities/baselinesv2/mongodb-keyvalue2.yaml index 7c65abd87..585325dbf 100644 --- a/adapter-mongodb/src/main/resources/activities/baselinesv2/mongodb-keyvalue2.yaml +++ b/adapter-mongodb/src/main/resources/activities/baselinesv2/mongodb-keyvalue2.yaml @@ -2,7 +2,7 @@ # nb5 run driver=mongodb workload=/path/to/mongodb-keyvalue2.yaml tags=block:"schema.*" connection='mongodb+srv://user:pass@sample-db.host.mongodb.net/?retryWrites=true&w=majority' database=baselines -vv --show-stacktraces # nb5 run driver=mongodb workload=/path/to/mongodb-keyvalue2.yaml tags=block:rampup cycles=25 connection='mongodb+srv://user:pass@sample-db.host.mongodb.net/?retryWrites=true&w=majority' database=baselines -vv --show-stacktraces # nb5 run driver=mongodb workload=/path/to/mongodb-keyvalue2.yaml tags='block:main-.*' cycles=25 connection='mongodb+srv://user:pass@sample-db.host.mongodb.net/?retryWrites=true&w=majority' database=baselines -vv --show-stacktraces -min_version: "5.17.1" +min_version: "5.17.3" description: | This workload is analogous to the cql-keyvalue2 workload, just implemented for MongoDB. diff --git a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/unary_string/StargateToken.java b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/unary_string/Token.java similarity index 60% rename from virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/unary_string/StargateToken.java rename to virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/unary_string/Token.java index 1c82deeb2..3a568c1a4 100644 --- a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/unary_string/StargateToken.java +++ b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/unary_string/Token.java @@ -35,60 +35,75 @@ import java.util.function.Function; @ThreadSafeMapper @Categories({Category.general}) -public class StargateToken implements Function { +public class Token implements Function { - private static final Logger logger = LogManager.getLogger(StargateToken.class); - private final Credentials credentials; - private final String url; - private final HttpClient httpClient; + private static final Logger logger = LogManager.getLogger(Token.class); + private Credentials credentials; + private URI uri; + private String providedToken; - public StargateToken(String url) throws SecurityException { - this(url, Credentials.defaultCredentials()); - } + public Token(String token, String uri, String uid, String password) { - public StargateToken(String url, Credentials credentials) throws SecurityException { - this(url, credentials, HttpClient.newBuilder().build()); - } + if (token != null && !token.trim().isEmpty()) { + this.providedToken = token.trim(); + return; + } + + if (uri == null || uri.trim().isEmpty()) { + throw new IllegalArgumentException("Expected uri to be specified for obtaining Token."); + } + this.uri = URI.create(uri.trim()); + + if (uid == null || uid.trim().isEmpty()) { + throw new IllegalArgumentException("Expected uid to be specified for obtaining Token."); + } + + if (password == null || password.trim().isEmpty()) { + throw new IllegalArgumentException("Expected password to be specified for obtaining Token."); + } + this.credentials = Credentials.create(uid.trim(), password.trim()); - public StargateToken(String url, Credentials credentials, HttpClient client) throws SecurityException { - this.url = url; - this.credentials = credentials; - this.httpClient = client; if (TokenKeeper.isExpired()) { - authTokenStargate(url, credentials); + authTokenStargate(this.uri, this.credentials); } } @Override - public String apply(Object value) throws SecurityException { - if (TokenKeeper.isExpired()) { - authTokenStargate(url, credentials); + public String apply(String p1) { + + if (this.providedToken != null) { + return this.providedToken; } - return TokenKeeper.token; + + if (TokenKeeper.isExpired() || TokenKeeper.token == null || TokenKeeper.token.isEmpty()) { + authTokenStargate(this.uri, this.credentials); + } + return TokenKeeper.getToken(); } public static void setExpired() { TokenKeeper.isExpiredRequested = true; } - private void authTokenStargate(String url, Credentials credentials) throws SecurityException { + private static void authTokenStargate(URI uri, Credentials credentials) throws SecurityException { - if (credentials == null || url == null) { + if (credentials == null || uri == null) { throw new BasicError("Must provide url and credentials to obtain authTokenStargate"); } - logger.debug("Received url for Stargate auth token request: {} ", url); + + logger.debug(() -> "Received uri for auth token request: " + uri); try { final Gson gson = new Gson(); HttpRequest.Builder builder = HttpRequest.newBuilder(); - builder = builder.uri(URI.create(url)); + builder = builder.uri(uri); builder = builder.POST(HttpRequest.BodyPublishers.ofString(gson.toJson(credentials))); builder.setHeader("Content-Type", "application/json"); HttpRequest request = builder.build(); + HttpClient httpClient = HttpClient.newBuilder().build(); HttpResponse resp = httpClient.send(request, HttpResponse.BodyHandlers.ofString()); - logger.debug(() -> "Stargate response status code: " + resp.statusCode()); if (resp.statusCode() != 201) { @@ -98,8 +113,8 @@ public class StargateToken implements Function { throw new BasicError(errorMessage); } - Credentials retrievedToken = gson.fromJson(resp.body(), Credentials.class); - TokenKeeper.setToken(retrievedToken.getAuthToken()); + final Credentials cred = gson.fromJson(resp.body(), Credentials.class); + TokenKeeper.setToken(cred.getAuthToken()); } catch (Exception e) { throw new SecurityException("Auth Token error, stargate-token retrieval failure", e); @@ -121,28 +136,31 @@ public class StargateToken implements Function { lastTokenInstant = Instant.now(); } - public static void setToken(String input) { - token = input; - } - - public static String getToken() { - return token; - } - public static Instant lastTokenInstant() { return lastTokenInstant; } public static boolean isExpired() { - if (isExpiredRequested || Duration.between(Instant.now(), + if (token == null || isExpiredRequested || Duration.between(Instant.now(), lastTokenInstant).toMinutes() > TOKEN_EXPIRE_MIN) { - logger.trace("Token expiry detected."); + logger.debug("Token expiry detected."); lastTokenInstant = Instant.now(); isExpiredRequested = false; + token = null; return true; } + + logger.debug(() -> "Token not expired, reusing as: " + token); return false; } + + public static synchronized void setToken(String value) { + token = value; + } + + public static synchronized String getToken() { + return token; + } } } diff --git a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/util/Credentials.java b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/util/Credentials.java index 4f9600d82..baa7201d6 100644 --- a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/util/Credentials.java +++ b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/util/Credentials.java @@ -18,23 +18,17 @@ package io.nosqlbench.virtdata.library.basics.shared.util; public class Credentials { - private static final String DEFAULT_IDENTITY = "cassandra"; - private String username; - private String password; + private final String username; + private final String password; private String authToken; - public static Credentials defaultCredentials() { - return new Credentials(DEFAULT_IDENTITY, DEFAULT_IDENTITY); - } - public Credentials(String username, String password) { this.username = username; this.password = password; } - // Added for support of auth tokens not obtained via defaultCredentials - public Credentials(String authToken) { - this.authToken = authToken; + public static Credentials create(String username, String password) { + return new Credentials(username, password); } public String getUsername() { @@ -48,4 +42,5 @@ public class Credentials { public String getAuthToken() { return authToken; } + } diff --git a/virtdata-lib-basics/src/test/java/io/nosqlbench/virtdata/library/basics/shared/unary_string/StargateTokenTest.java b/virtdata-lib-basics/src/test/java/io/nosqlbench/virtdata/library/basics/shared/unary_string/StargateTokenTest.java deleted file mode 100644 index 0463e37df..000000000 --- a/virtdata-lib-basics/src/test/java/io/nosqlbench/virtdata/library/basics/shared/unary_string/StargateTokenTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ - -package io.nosqlbench.virtdata.library.basics.shared.unary_string; - -import io.nosqlbench.virtdata.library.basics.shared.util.Credentials; -import org.apache.commons.lang3.reflect.FieldUtils; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.internal.util.reflection.FieldReader; -import org.mockito.junit.jupiter.MockitoExtension; -import org.mockito.junit.jupiter.MockitoSettings; -import org.mockito.quality.Strictness; - -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.time.Instant; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -@ExtendWith(MockitoExtension.class) -@MockitoSettings(strictness = Strictness.LENIENT) -class StargateTokenTest extends TokenTest { - - private static final String TEST_AUTH_TOKEN = "8675309"; - private static final String VALID_TEST_URL = "http://foobar.com:8675"; - private static final String VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON = - "{ 'authToken': " + "\"" + TEST_AUTH_TOKEN + "\"" + "}"; - private static final Credentials VALID_TEST_CREDS = new Credentials("username", "password"); - - private static final Object TOKEN_APPLY_PLACEHOLDER = new Object(); - @Mock - private static HttpResponse httpResponse; - @Mock - private static HttpClient httpClient; - - @BeforeAll - public static void init() { - httpResponse = mock(HttpResponse.class); - httpClient = mock(HttpClient.class); - } - - @BeforeEach - public void setup() { - StargateToken.TokenKeeper.reset(); - } - - @Test - void applyTokenSuccess() throws Exception { - - when(httpResponse.body()).thenReturn(VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON); - when(httpResponse.statusCode()).thenReturn(201); - when(httpClient.send(Mockito.any(HttpRequest.class), - Mockito.any(HttpResponse.BodyHandlers.ofString().getClass()))) - .thenReturn(httpResponse); - - final StargateToken stargateToken = new StargateToken(VALID_TEST_URL, - VALID_TEST_CREDS, httpClient); - final String result = stargateToken.apply(TOKEN_APPLY_PLACEHOLDER); - - assertThat(result).isEqualTo(TEST_AUTH_TOKEN); - - } - - @Test - void receivedResponse500() throws Exception { - - when(httpResponse.body()).thenReturn(VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON); - when(httpResponse.statusCode()).thenReturn(500); - when(httpClient.send(Mockito.any(HttpRequest.class), Mockito.any(HttpResponse.BodyHandlers.ofString() - .getClass()))) - .thenReturn(httpResponse); - - assertThatExceptionOfType(SecurityException.class).isThrownBy(() -> new StargateToken(VALID_TEST_URL, - VALID_TEST_CREDS, httpClient)); - - } - - @Test - void applyTokenSuccessWithRefreshTokenRequested() throws Exception { - - // --- Initial check - StargateToken.TokenKeeper.reset(); - - when(httpResponse.body()).thenReturn(VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON); - when(httpResponse.statusCode()).thenReturn(201); - when(httpClient.send(Mockito.any(HttpRequest.class), - Mockito.any(HttpResponse.BodyHandlers.ofString() - .getClass()))) - .thenReturn(httpResponse); - - final StargateToken stargateToken = new StargateToken(VALID_TEST_URL, VALID_TEST_CREDS, httpClient); - final String resultFirstCheck = stargateToken.apply(TOKEN_APPLY_PLACEHOLDER); - final Instant tokenInstantFirstCheck = StargateToken.TokenKeeper.lastTokenInstant(); - - assertThat(resultFirstCheck).isEqualTo(TEST_AUTH_TOKEN); - assertThat(tokenInstantFirstCheck).isNotNull(); - - // --- Subtest 2 - When NOT having an expired token, expect that the lastTokenInstant does NOT change. - when(httpResponse.body()).thenReturn("{ 'authToken': " + "\"" + "refreshed-token" + "\"" + "}"); - when(httpResponse.statusCode()).thenReturn(201); - when(httpClient.send(Mockito.any(HttpRequest.class), Mockito.any(HttpResponse.BodyHandlers.ofString() - .getClass()))) - .thenReturn(httpResponse); - - final String resultSecondCheck = stargateToken.apply(TOKEN_APPLY_PLACEHOLDER); - final Instant tokenInstantSecondCheck = StargateToken.TokenKeeper.lastTokenInstant(); - - assertThat(resultSecondCheck).isEqualTo(resultFirstCheck); - assertThat(tokenInstantSecondCheck).isEqualTo(tokenInstantFirstCheck); - - // --- Subtest 3 - When having an expired token, expect that the lastTokenInstant changes and - // tokens are different. - // Note: Explicit token expiry, default is 30 minutes - StargateToken.setExpired(); - - final String resultThirdCheck = stargateToken.apply(TOKEN_APPLY_PLACEHOLDER); - final FieldReader fileReaderLastCheck = new FieldReader(stargateToken, - FieldUtils.getDeclaredField(StargateToken.class, - "lastTokenInstant", true)); - final Instant tokenInstantThirdCheck = StargateToken.TokenKeeper.lastTokenInstant(); - - assertThat(tokenInstantThirdCheck.isAfter(tokenInstantFirstCheck)).isTrue(); - assertThat(resultSecondCheck).isNotEqualTo(resultThirdCheck); - } - -} \ No newline at end of file diff --git a/virtdata-lib-basics/src/test/java/io/nosqlbench/virtdata/library/basics/shared/unary_string/TokenTest.java b/virtdata-lib-basics/src/test/java/io/nosqlbench/virtdata/library/basics/shared/unary_string/TokenTest.java index b22295ffd..9bab428d3 100644 --- a/virtdata-lib-basics/src/test/java/io/nosqlbench/virtdata/library/basics/shared/unary_string/TokenTest.java +++ b/virtdata-lib-basics/src/test/java/io/nosqlbench/virtdata/library/basics/shared/unary_string/TokenTest.java @@ -13,8 +13,163 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package io.nosqlbench.virtdata.library.basics.shared.unary_string; -public abstract class TokenTest { - // Intent is to expand for generic (non-Stargate) http-rest test conditions and utils. -} +import io.nosqlbench.virtdata.library.basics.shared.util.Credentials; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.mockito.internal.util.reflection.FieldReader; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; + +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Instant; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) +class TokenTest { + + private static final String TEST_AUTH_TOKEN = "8675309"; + private static final String VALID_TEST_URL = "http://foobar.com:8675"; + private static final String VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON = + "{ 'authToken': " + "\"" + TEST_AUTH_TOKEN + "\"" + "}"; + private static final Credentials VALID_TEST_CREDS = new Credentials("username", "password"); + + @Mock + private static HttpResponse httpResponse; + @Mock + private static HttpClient httpClient; + + private static MockedStatic HttpCli; + + @Mock + private static HttpClient.Builder httpBuilder; + + @BeforeAll + public static void init() { + httpResponse = mock(HttpResponse.class); + httpClient = mock(HttpClient.class); + httpBuilder = mock(HttpClient.Builder.class); + HttpCli = Mockito.mockStatic(HttpClient.class); + } + + @BeforeEach + public void setup() { + Token.TokenKeeper.reset(); + } + + @Test + void applyTokenSuccess() throws Exception { + + when(httpResponse.body()).thenReturn(VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON); + when(httpResponse.statusCode()).thenReturn(201); + + mockResponse(); + + final Token token = new Token(null, VALID_TEST_URL, VALID_TEST_CREDS.getUsername(), + VALID_TEST_CREDS.getPassword()); + // Since constructor handles state management, the inputs aren't utilized in the apply function. + final String result = token.apply("p1"); + + assertThat(result).isEqualTo(TEST_AUTH_TOKEN); + } + + @Test + void receivedResponse500() throws Exception { + + when(httpResponse.body()).thenReturn(VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON); + when(httpResponse.statusCode()).thenReturn(500); + mockResponse(); + + assertThatExceptionOfType(SecurityException.class).isThrownBy(() -> new Token(null, VALID_TEST_URL, + VALID_TEST_CREDS.getUsername(), VALID_TEST_CREDS.getPassword())); + } + + @Test + void applyTokenSuccessWithRefreshTokenRequested() throws Exception { + + Token.TokenKeeper.reset(); + + when(httpResponse.body()).thenReturn(VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON); + when(httpResponse.statusCode()).thenReturn(201); + mockResponse(); + + final Token token = new Token(null, VALID_TEST_URL, VALID_TEST_CREDS.getUsername(), + VALID_TEST_CREDS.getPassword()); + final String resultFirstCheck = token.apply("p1"); + final Instant tokenInstantFirstCheck = Token.TokenKeeper.lastTokenInstant(); + + assertThat(resultFirstCheck).isEqualTo(TEST_AUTH_TOKEN); + assertThat(tokenInstantFirstCheck).isNotNull(); + + // --- Subtest 2 - NOT having an expired token, expect that the lastTokenInstant does NOT change. + when(httpResponse.body()).thenReturn("{ 'authToken': " + "\"" + "refreshed-token" + "\"" + "}"); + when(httpResponse.statusCode()).thenReturn(201); + mockResponse(); + + final String resultSecondCheck = token.apply("p1"); + final Instant tokenInstantSecondCheck = Token.TokenKeeper.lastTokenInstant(); + + assertThat(resultSecondCheck).isEqualTo(resultFirstCheck); + assertThat(tokenInstantSecondCheck).isEqualTo(tokenInstantFirstCheck); + + // --- Subtest 3 - Having expired token, expect that the lastTokenInstant changes and + // tokens are different. + // Note: Explicit token expiry, default is 30m + Token.setExpired(); + + final String resultThirdCheck = token.apply("p1"); + final FieldReader fileReaderLastCheck = new FieldReader(token, + FieldUtils.getDeclaredField(Token.class, + "lastTokenInstant", true)); + final Instant tokenInstantThirdCheck = Token.TokenKeeper.lastTokenInstant(); + + assertThat(tokenInstantThirdCheck.isAfter(tokenInstantFirstCheck)).isTrue(); + assertThat(resultSecondCheck).isNotEqualTo(resultThirdCheck); + } + + @Test + void provideToken() { + + final Token token = new Token(TEST_AUTH_TOKEN, VALID_TEST_URL, VALID_TEST_CREDS.getUsername(), + VALID_TEST_CREDS.getPassword()); + + final String result = token.apply("p1"); + + assertThat(result).isEqualTo(TEST_AUTH_TOKEN); + + + final Token token2 = new Token(TEST_AUTH_TOKEN, null, null, null); + final String result2 = token2.apply("p1"); + + assertThat(result2).isEqualTo(TEST_AUTH_TOKEN); + } + + + private void mockResponse() throws Exception { + + HttpCli.when(HttpClient::newBuilder).thenReturn(httpBuilder); + when(httpBuilder.build()).thenReturn(httpClient); + + when(httpClient.send(Mockito.any(HttpRequest.class), + Mockito.any(HttpResponse.BodyHandlers.ofString().getClass()))) + .thenReturn(httpResponse); + } + + +} \ No newline at end of file