Skip to content

Commit

Permalink
Nosqlbench testing configuration file using dataset (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
maheshrajamani authored Jun 5, 2023
1 parent 84b9478 commit e10155d
Show file tree
Hide file tree
Showing 2 changed files with 199 additions and 26 deletions.
220 changes: 194 additions & 26 deletions nosqlbench/http-jsonapi-crud-dataset.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
min_version: "5.17.3"

# Example command line (when Stargate is running on localhost):
# nb5 -v http-jsonapi-crud-dataset jsonapi_host=localhost docscount=20000 threads=20 dataset=sample-dataset.txt

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.
It requires a data set file (default sample-dataset.txt), 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 8181).
scenarios:
default:
schema: run driver=http tags==block:schema threads==1 cycles==UNDEF
write: run driver=http tags==name:"write.*" cycles===TEMPLATE(write-cycles,TEMPLATE(docscount,10000000)) threads=auto errors=timer,warn
read: run driver=http tags==name:"read.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10000000)) threads=auto errors=timer,warn
update: run driver=http tags==name:"update.*" cycles===TEMPLATE(update-cycles,TEMPLATE(docscount,10000000)) threads=auto errors=timer,warn
delete: run driver=http tags==name:"delete.*" cycles===TEMPLATE(delete-cycles,TEMPLATE(docscount,10000000)) threads=auto errors=timer,warn
schema: run driver=http tags==block:schema threads==1 cycles==UNDEF
write: run driver=http tags==name:"write.*" cycles===TEMPLATE(write-cycles,TEMPLATE(docscount,10000)) threads=auto errors=timer,warn
main: run driver=http tags==block:main cycles===TEMPLATE(read-cycles,100000) threads=auto errors=timer,warn

bindings:
# To enable an optional weighted set of hosts in place of a load balancer
# Examples
# 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_host:localhost>>>>')

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

# field name to be used to check the $exists filter
exists_key: WeightedStrings('<<exists_key:data>>'); ToString();

# field name to be used for sorting
sort_key: WeightedStrings('<<sort_key:data.size>>'); ToString();

# http request id
request_id: ToHashedUUID(); ToString();

# autogenerate auth token to use on API calls using configured uri/uid/password, unless one is provided
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
seq_key: Mod(<<docscount:10000>>); ToString() -> String
update_seq_key: Mod(<<docscount:10000>>); ToString() -> String
random_key: Uniform(0,<<docscount:10000>>); ToString() -> String
document_json_without_id: HashedLineToString('<<dataset:sample-dataset.txt>>');

#Adding some data to verify different types of filters
full_name: FullNames()


blocks:
schema:
Expand All @@ -47,13 +60,13 @@ blocks:
body: >2
{
"createNamespace": {
"name": "<<namespace:jsonapi_crud_basic>>"
"name": "<<namespace:jsonapi_crud_dataset>>"
}
}
delete-collection:
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_basic>>
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_dataset>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Expand All @@ -68,7 +81,7 @@ blocks:
create-collection:
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/namespaces/<<namespace:jsonapi_crud_basic>>
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_dataset>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Expand All @@ -81,47 +94,202 @@ blocks:
}
}
main:
bindings:
document_json: ModuloLineToString('<<dataset_file>>');
write:
ops:
# TODO expect the document have the ID in it?
write-document:
space: "{space}"
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8180>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_basic>>/<<collection:docs_collection>>
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_dataset>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"insertedIds\":\"{seq_key}\".*"
body: "{document_json}"
body: >2
{
"insertOne" : {
"document" : {
"_id" : "{seq_key}",
"full_name" : "{full_name}",
"data" : {document_json_without_id}
}
}
}
main:
ops:
# aka findOne with _id as filter
find-one-id:
space: "{space}"
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_dataset>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"data\".*"
body: >2
{
"findOne" : {
"filter" : {
"_id" : "{random_key}"
}
}
}
# aka findOne with single property as filter
find-one-by-city:
space: "{space}"
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_dataset>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"data\".*"
body: >2
{
"findOne" : {
"filter" : {
"full_name" : "{full_name}"
}
}
}
# aka find with $exist
find-multi-by-exists:
space: "{space}"
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_dataset>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"data\".*"
body: >2
{
"find" : {
"filter" : {
"{exists_key}": { "$exists": true }
}
}
}
read-document:
# aka find with $eq and $exist and $projection
find-multi-by-married-name-exists-with-projection:
space: "{space}"
method: GET
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v2/namespaces/<<namespace:jsonapi_crud_dataset>>/collections/<<table:docs_collection>>/{random_key}
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_dataset>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"data\".*"
body: >2
{
"find" : {
"filter" : {
"full_name": { "$exists": true }
},
"projection": {
"full_name": 1,
"data": 1
}
}
}
# aka find with filter and sort
find-multi-find-by-group-sort-by-name:
space: "{space}"
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_dataset>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"data\".*"
body: >2
{
"find" : {
"filter" : {
"full_name": "{full_name}"
},
"sort": {
"{sort_key}": 1
}
}
}
# aka updateOne
# for parity with other tests this only uses set, not unset, no return value
update-document:
space: "{space}"
method: PUT
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v2/namespaces/<<namespace:jsonapi_crud_dataset>>/collections/<<table:docs_collection>>/{random_key}
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_dataset>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
body: "{document_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\":[0,1].*"
body: >2
{
"updateOne" : {
"filter": {
"_id" : "{random_key}"
},
"update": {
"$set": {
"update_field": "{update_seq_key}"
}
}
}
}
# Delete record by id
delete-document:
space: "{space}"
method: DELETE
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v2/namespaces/<<namespace:jsonapi_crud_dataset>>/collections/<<table:docs_collection>>/{seq_key}
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_dataset>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"deletedCount\":[0,1].*"
body: >2
{
"deleteOne" : {
"filter" : {
"_id" : "{random_key}"
}
}
}
# find one and replace with upsert
find-one-id-and-replace-upsert:
space: "{space}"
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_crud_dataset>>/<<collection:docs_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"data\".*"
body: >2
{
"findOneAndReplace" : {
"filter" : {
"_id": "{random_key}"
},
"replacement": {
"_id" : "{seq_key}",
"full_name" : "{full_name}",
"data" : {document_json_without_id}
},
"options": {
"upsert": true
}
}
}
5 changes: 5 additions & 0 deletions nosqlbench/sample-dataset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{"hash":"3576be49f989ac551af8f7e7b2aad0d4f9dd7b3882e7843839aa173d017cf7fe","ver":2,"vin_sz":1,"vout_sz":1,"size":220,"weight":880,"fee":6468,"relayed_by":"0.0.0.0","lock_time":0,"tx_index":8970844506661621,"double_spend":false,"time":1685054037,"block_index":null,"block_height":null,"inputs":[{"sequence":4294967295,"witness":"","script":"4730440220771152f9eac8397baf82af8711969bdffb4b84db116c3cdf90c15d02699dcbd30220527f2d88855566337933a2180db8ee5455c3da2558f2f79b37dbeb283fd0bbf4014104e62bff7b1af952b1bfd6b68af9e6367d69756807b69f8920a762e1b500d86d821e8d11d3bf9a8bcd88d7a97b6a6aaa945be8e15bd1111478f37c919f807be61f","index":0,"prev_out":{"addr":"1koboutKx17hEXb9mDrF4YjULkdE5faxr","n":0,"script":"76a9140848c944ba84c10a6cb754910a2e8311f49c00b888ac","spending_outpoints":[{"n":0,"tx_index":8970844506661621}],"spent":true,"tx_index":3507365639401646,"type":0,"value":384372}}],"out":[{"type":0,"spent":false,"value":377904,"spending_outpoints":[],"n":0,"tx_index":8970844506661621,"script":"001499c3c085b9b7e31909b4a8ae61a1acc8d63df647","addr":"bc1qn8puppdekl33jzd54zhxrgdvertrmaj8j36jsu"}]}
{"hash":"51321adb9cb7aea7b02a5fd9a2bfd7bc2b15f9b884df3f3169b6feb4e42632f1","ver":1,"vin_sz":1,"vout_sz":2,"size":224,"weight":566,"fee":4900,"relayed_by":"0.0.0.0","lock_time":0,"tx_index":8486326501810134,"double_spend":false,"time":1685054037,"block_index":null,"block_height":null,"inputs":[{"sequence":4294967295,"witness":"02483045022100f9ecfea2e7839ee1fdd6fb9da4d4b9000ba84fec08f316398ea6b5a1b8fd223302200698f28bc3f35c79916f4fbf6a19e39b924f9b8bd42a09a3963618300779d89b012103092fd83bd5195cdf4a5b902ca570adcc35da7fe19ab34ce007dda630b3813041","script":"","index":0,"prev_out":{"addr":"bc1qyv2hrdjxpf4eew9zx6lz0wlt29mhr6nvvc3f4y","n":44,"script":"0014231571b6460a6b9cb8a236be27bbeb517771ea6c","spending_outpoints":[{"n":0,"tx_index":8486326501810134}],"spent":true,"tx_index":8223916460782630,"type":0,"value":174675}}],"out":[{"type":0,"spent":false,"value":25697,"spending_outpoints":[],"n":0,"tx_index":8486326501810134,"script":"a914ad03886e85519a440e43b534fa8940de2625521587","addr":"3HTq4Cjd4iRfm4GXMBZhfKn2T7p7jUw355"},{"type":0,"spent":false,"value":144078,"spending_outpoints":[],"n":1,"tx_index":8486326501810134,"script":"0014c7b96a104e157999e0b8e8c868c6e03c7acd8893","addr":"bc1qc7uk5yzwz4uenc9caryx33hq83avmzynk20ny5"}]}
{"hash":"d78e2b748786c584b115da69d504e064b432e0b2ea93ef6b4c2db7c701516aef","ver":2,"vin_sz":1,"vout_sz":2,"size":226,"weight":577,"fee":10902,"relayed_by":"0.0.0.0","lock_time":791395,"tx_index":8423676948575973,"double_spend":false,"time":1685054037,"block_index":null,"block_height":null,"inputs":[{"sequence":4294967293,"witness":"02473044022025a5910d08a0a2b3ac511e148a7eb9a0392db3f4a194c62b2a8a56be7c26dbff02202090ba4db41e607c025880a8d3ef8bd2c2a0fb888c1724db578ffedd748083970121023f70ba8cde982c805a330a12ac9c6c0afa0394ca5a1d7314a43019ef889934f2","script":"","index":0,"prev_out":{"addr":"bc1q85htd06cl9xa4a2merjlk4zs9csgpmtkn5km78","n":1,"script":"00143d2eb6bf58f94ddaf55bc8e5fb54502e2080ed76","spending_outpoints":[{"n":0,"tx_index":8423676948575973}],"spent":true,"tx_index":7254084117845330,"type":0,"value":37047776}}],"out":[{"type":0,"spent":false,"value":34007559,"spending_outpoints":[],"n":0,"tx_index":8423676948575973,"script":"a914d101d28b372f12a0e701e3b8c37bbaccc49b3b8487","addr":"3Lk9LG7jG4KmqB5hEHRwvs4v9RkK3PfWZh"},{"type":0,"spent":false,"value":3029315,"spending_outpoints":[],"n":1,"tx_index":8423676948575973,"script":"76a914e18022b93795a50a9670c88bb54e68f00aed5b2c88ac","addr":"1MZLYBZb5qWwn2XaUugST6s6PpydZpoQr1"}],"rbf":true}
{"hash":"a9b01a476b62c0c1f1147041f1e2479bc67a22ff7cb0ffc3bf43fbe00605c7e9","ver":1,"vin_sz":1,"vout_sz":1,"size":195,"weight":450,"fee":8588,"relayed_by":"0.0.0.0","lock_time":0,"tx_index":8225311747219304,"double_spend":false,"time":1685054037,"block_index":null,"block_height":null,"inputs":[{"sequence":0,"witness":"02483045022100e00e3f8e62050b94ff65422cac70694e30a173eee2774ff0296b8484f652d3970220358fd7484cd7f9c78db99a6e855eccb6a872b34843fd9d063b7c3b6b1bf919fb0121025e462c50df235b5fcfa32fe8ad59bf690f9587869c33d2c8d65343f17816daa3","script":"","index":0,"prev_out":{"addr":"bc1q9wmx7tk6w2ppc4ektkevkc8m9hfml5asuag5xu","n":3,"script":"00142bb66f2eda72821c57365db2cb60fb2dd3bfd3b0","spending_outpoints":[{"n":0,"tx_index":8225311747219304}],"spent":true,"tx_index":6685634473544555,"type":0,"value":821913}}],"out":[{"type":0,"spent":false,"value":813325,"spending_outpoints":[],"n":0,"tx_index":8225311747219304,"script":"76a91419e9cd6cdeb64b74cc3828e0cb954bc51b9446e388ac","addr":"13N1yg7CKrGh78PzusCgtruYu6n8wi5xYE"}],"rbf":true}
{"hash":"3bc5b22632e6bf4ef3f3be05f31b73e3c933528bde0aefb303ebc978618d3de3","ver":2,"vin_sz":1,"vout_sz":2,"size":235,"weight":610,"fee":7854,"relayed_by":"0.0.0.0","lock_time":0,"tx_index":7995312143538493,"double_spend":false,"time":1685054037,"block_index":null,"block_height":null,"inputs":[{"sequence":4294967295,"witness":"02483045022100f684b60449aac26caf2f6cd1132451757e8724039a6d03cf6b497e93ec14c8bc02205cf1eac26c2a33c3fbe1b518ed24a27d014f2a2bc9d40077ddb0ec0895e92d2c012103e3df69400d738d89f6ae6b27c080576f6639324bcc44b86a48f7be61c5d67a71","script":"","index":0,"prev_out":{"addr":"bc1qxwqw2tqas5leph9x0ef0umm7sxcqmhwx49f0uu","n":1,"script":"00143380e52c1d853f90dca67e52fe6f7e81b00dddc6","spending_outpoints":[{"n":0,"tx_index":7995312143538493}],"spent":true,"tx_index":3708111625349913,"type":0,"value":9649510}}],"out":[{"type":0,"spent":true,"value":76000,"spending_outpoints":[{"tx_index":3917278036337223,"n":0}],"n":0,"tx_index":7995312143538493,"script":"512019a2db97ad0e748a0d5cafc5f8722b7b6a8fdef2093e9ed756fc5661eada045f","addr":"bc1prx3dh9adpe6g5r2u4lzlsu3t0d4glhhjpylfa46kl3txr6k6q30s3qmtn2"},{"type":0,"spent":false,"value":9565656,"spending_outpoints":[],"n":1,"tx_index":7995312143538493,"script":"00143380e52c1d853f90dca67e52fe6f7e81b00dddc6","addr":"bc1qxwqw2tqas5leph9x0ef0umm7sxcqmhwx49f0uu"}]}

0 comments on commit e10155d

Please sign in to comment.