Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSQLBench workloads - auto token generation #358

Merged
merged 3 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions nosqlbench/http-jsonapi-crud-basic.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
min_version: "4.17.15"
min_version: "5.17.1"

# nb5 -v run driver=http yaml=http-jsonapi-crud-basic jsonapi_host=my_jsonapi_host auth_token=$AUTH_TOKEN

description: |
description: >2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change wanted? what s >2 doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a convention that Jeff Banks added to the equivalent Docs API tests in the main nosqlbench repo. I think it means that what follows is structured data with 2 space indentation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a YAML feature, where there's a myriad of ways to specify how text blocks are included (String values, not YAML markup -- often embedded JSON, XML, CSV, shell scripts)
Which can be convenient but also confusing until you learn all of them when someone uses them (at least I find them confusing).

This workload emulates CRUD operations for the Stargate JSON API.
It generates a simple JSON document to be used for writes and updates.
Note that jsonapi_port should reflect the port where the JSON API is exposed (defaults to 8080).
Expand All @@ -21,13 +21,14 @@ bindings:
# single host: jsonapi_host=host1
# multiple hosts: jsonapi_host=host1,host2,host3
# multiple weighted hosts: jsonapi_host=host1:3,host2:7
weighted_hosts: WeightedStrings('<<jsonapi_host:jsonapi>>')
weighted_hosts: WeightedStrings('<<jsonapi_host:stargate>>')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still like why don't we have localhost as default? In addition, this change is also only available in this file, not the others.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to revert this change for consistency


# spread into different spaces to use multiple connections
space: HashRange(1,<<connections:20>>); ToString();

# http request id
request_id: ToHashedUUID(); ToString();
token: Discard(); Token('<<auth_token:>>','<<uri:http://localhost:8081/v1/auth>>', '<<uid:cassandra>>', '<<pswd:cassandra>>');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this do an auth request on each cycle?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, NB caches the token

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. but can you add a small comment here, explaining what the parameters are.. I guess first parameter is token given from the command line and if given, don't call the auth api? In addition it's good to know that the result of the token is saved in the {{token}} var.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comment


seq_key: Mod(<<docscount:10000000>>); ToString() -> String
random_key: Uniform(0,<<docscount:10000000>>); ToString() -> String
Expand All @@ -51,10 +52,10 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"ok\":1.*"
body: |
body: >2
{
"createNamespace": {
"name": "<<namespace:jsonapi_crud_basic>>"
Expand All @@ -66,10 +67,10 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_basic>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"ok\":1.*"
body: |
body: >2
{
"deleteCollection": {
"name": "<<collection:docs_collection>>"
Expand All @@ -81,10 +82,10 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_basic>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"ok\":1.*"
body: |
body: >2
{
"createCollection": {
"name": "<<collection:docs_collection>>"
Expand All @@ -100,10 +101,10 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_basic>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"insertedIds\":\"{seq_key}\".*"
body: |
body: >2
{
"insertOne" : {
"document" : {
Expand Down Expand Up @@ -141,10 +142,10 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_basic>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"data\".*"
body: |
body: >2
{
"findOne" : {
"filter" : {
Expand All @@ -163,13 +164,13 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_basic>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
# because this is not an upsert, modified count could technically be 0 or 1,
# but since we are fixing the _ids to be sequential over the docscount range during the write phase,
# every update during this phase should update exactly 1 document.
ok-body: ".*\"modifiedCount\":1.*"
body: |
body: >2
{
"updateOne" : {
"filter": {
Expand Down Expand Up @@ -211,10 +212,10 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_basic>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"deletedCount\":[0,1].*"
body: |
body: >2
{
"deleteOne" : {
"filter" : {
Expand Down
25 changes: 13 additions & 12 deletions nosqlbench/http-jsonapi-crud-dataset.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
min_version: "4.17.15"
min_version: "5.17.1"

description: |
description: >2
This workload emulates CRUD operations for the Stargate Documents API.
It requires a data set file, where each line is a single JSON document to be used for writes and updates.
Note that jsonapi_port should reflect the port where the Docs API is exposed (defaults to 8080).
Expand All @@ -26,6 +26,7 @@ bindings:

# http request id
request_id: ToHashedUUID(); ToString();
token: Discard(); Token('<<auth_token:>>','<<uri:http://localhost:8081/v1/auth>>', '<<uid:cassandra>>', '<<pswd:cassandra>>');

seq_key: Mod(<<docscount:10000000>>); ToString() -> String
random_key: Uniform(0,<<docscount:10000000>>); ToString() -> String
Expand All @@ -38,10 +39,10 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"ok\":1.*"
body: |
body: >2
{
"createNamespace": {
"name": "<<namespace:jsonapi_crud_basic>>"
Expand All @@ -53,10 +54,10 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_basic>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"ok\":1.*"
body: |
body: >2
{
"deleteCollection": {
"name": "<<collection:docs_collection>>"
Expand All @@ -68,10 +69,10 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1/namespaces/<<namespace:jsonapi_crud_basic>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"ok\":1.*"
body: |
body: >2
{
"createCollection": {
"name": "<<collection:docs_collection>>"
Expand All @@ -89,7 +90,7 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8180>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_basic>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"insertedIds\":\"{seq_key}\".*"
body: "{document_json}"
Expand All @@ -100,7 +101,7 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v2/namespaces/<<namespace:jsonapi_crud_dataset>>/collections/<<table:docs_collection>>/{random_key}
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"data\".*"

Expand All @@ -110,7 +111,7 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v2/namespaces/<<namespace:jsonapi_crud_dataset>>/collections/<<table:docs_collection>>/{random_key}
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
body: "{document_json}"

Expand All @@ -120,5 +121,5 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v2/namespaces/<<namespace:jsonapi_crud_dataset>>/collections/<<table:docs_collection>>/{seq_key}
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
29 changes: 15 additions & 14 deletions nosqlbench/http-jsonapi-keyvalue.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
min_version: "4.17.15"
min_version: "5.17.1"

description: |
description: >2
This workload emulates a key-value data model and access patterns.
This should be identical to the cql variant except for:
- Schema creation with the Docs API, we don't use cql because the Docs API is opinionated about schema.
Expand All @@ -27,6 +27,7 @@ bindings:

# http request id
request_id: ToHashedUUID(); ToString();
token: Discard(); Token('<<auth_token:>>','<<uri:http://localhost:8081/v1/auth>>', '<<uid:cassandra>>', '<<pswd:cassandra>>');

seq_key: Mod(<<keycount:10000000>>); ToString() -> String
seq_value: Hash(); Mod(<<valuecount:10000000>>); ToString() -> String
Expand All @@ -41,10 +42,10 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"ok\":1.*"
body: |
body: >2
{
"createNamespace": {
"name": "<<namespace:jsonapi_keyvalue>>"
Expand All @@ -56,10 +57,10 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1/<<namespace:jsonapi_keyvalue>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"ok\":1.*"
body: |
body: >2
{
"deleteCollection": {
"name": "<<collection:docs_collection>>"
Expand All @@ -71,10 +72,10 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1/<<namespace:jsonapi_keyvalue>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"ok\":1.*"
body: |
body: >2
{
"createCollection": {
"name": "<<collection:docs_collection>>"
Expand All @@ -89,10 +90,10 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1/<<namespace:jsonapi_keyvalue>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"insertedIds\":\"{seq_key}\".*"
body: |
body: >2
{
"insertOne" : {
"document" : {
Expand All @@ -112,10 +113,10 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1/<<namespace:jsonapi_keyvalue>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"data\".*"
body: |
body: >2
{
"findOne" : {
"filter" : {
Expand All @@ -130,11 +131,11 @@ blocks:
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8080>><<path_prefix:>>/v1/<<namespace:jsonapi_keyvalue>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "<<auth_token:my_auth_token>>"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
# because this is not an upsert, modified count could be 0 or 1
ok-body: ".*\"modifiedCount\":[0,1].*"
body: |
body: >2
{
"updateOne" : {
"filter": {
Expand Down
Loading