From 4b3270405b568058a911c8789963a15397918217 Mon Sep 17 00:00:00 2001 From: Madhavan Sridharan Date: Tue, 27 Sep 2022 09:27:43 -0400 Subject: [PATCH] Initial Draft. Added a fully working tabular example for MongoDB --- .../baselinesv2/mongodb-keyvalue2.yaml | 94 +++++++++++-- .../baselinesv2/mongodb-tabular2.yaml | 6 +- .../baselinesv2/mongodb-timeseries2.yaml | 0 mongodb-keyvalue2.yaml | 125 ------------------ 4 files changed, 83 insertions(+), 142 deletions(-) rename mongodb-tabular2.yaml => adapter-mongodb/src/main/resources/activities/baselinesv2/mongodb-tabular2.yaml (99%) rename mongodb-timeseries2.yaml => adapter-mongodb/src/main/resources/activities/baselinesv2/mongodb-timeseries2.yaml (100%) delete mode 100644 mongodb-keyvalue2.yaml 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 e0872c3ab..f32a23c78 100644 --- a/adapter-mongodb/src/main/resources/activities/baselinesv2/mongodb-keyvalue2.yaml +++ b/adapter-mongodb/src/main/resources/activities/baselinesv2/mongodb-keyvalue2.yaml @@ -1,3 +1,7 @@ +# Connection Guide: https://www.mongodb.com/docs/drivers/java/sync/current/fundamentals/connection/ +# 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: "4.17.24" description: | @@ -7,12 +11,11 @@ scenarios: default: schema: run driver=mongodb tags==block:schema threads==1 cycles==UNDEF rampup: run driver=mongodb tags==block:rampup cycles===TEMPLATE(rampup-cycles,10000000) threads=auto - main: run driver=mongodb tags==block:"main.*" cycles===TEMPLATE(main-cycles,10000000) threads=auto - astra: - schema: run driver=mongodb tags==block:schema-astra threads==1 cycles==UNDEF - rampup: run driver=mongodb tags==block:rampup cycles===TEMPLATE(rampup-cycles,10000000) threads=auto - main: run driver=mongodb tags==block:"main.*" cycles===TEMPLATE(main-cycles,10000000) threads=auto + main: run driver=mongodb tags==block:"main-.*" cycles===TEMPLATE(main-cycles,10000000) threads=auto + drop: run driver=mongodb tags==block:drop-collection threads==1 cycles==UNDEF +params: + instrument: true bindings: seq_key: Mod(TEMPLATE(keycount,1000000000)); ToString(); seq_value: >- @@ -28,32 +31,95 @@ blocks: params: prepared: false ops: + # https://www.mongodb.com/docs/manual/reference/method/db.createCollection/ + # https://www.mongodb.com/docs/manual/core/schema-validation/specify-json-schema/ + # `clusteredIndex` only support creation of an index on `_id` field (as shown below) so its optional create-collection: | { - ... + create: "TEMPLATE(collection,keyvalue)", + clusteredIndex: { + key: { "_id": 1 }, + unique: true, + name: "_id_idx" + }, + writeConcern: { w: "majority" }, + validator: { + $jsonSchema: { + bsonType: "object", + title: "Key/Value collection schema validation", + required: [ "key" ], + properties: { + key: { + bsonType: "string", + description: "'key' must be a string and is required" + } + } + } + }, + validationLevel: "strict", + validationAction: "error", + comment: "keyvalue collection creation with strict types and required 'key' field." + } + create-key-index: | + { + createIndexes: "TEMPLATE(collection,keyvalue)", + indexes: [ + { + key: { + key: 1, + }, + name: "kv_key_idx", + unique: true + } + ], + writeConcern: { w: "majority" }, + comment: "'key' index creation for keyvalue collection. Values should be unique.", + commitQuorum: "majority" } -# create keyspace if not exists TEMPLATE(keyspace,baselines) -# WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 'TEMPLATE(rf,1)'} -# AND durable_writes = true; rampup: ops: rampup-insert: | { - ... + insert: "TEMPLATE(collection,keyvalue)", + documents: [ + { + key: "{rw_key}", + value: "{rw_value}" + } + ], + comment: "Insert documents into keyvalue collection." } main-read: params: ratio: 5 - statements: + ops: main-select: | { - ... + find: "TEMPLATE(collection,keyvalue)", + filter: { key: { $eq: "{rw_key}" } }, + readConcern: { level: "majority" }, + comment: "Find the value for the given 'key'." } main-write: params: ratio: 5 - statements: + ops: main-insert: | { - ... + insert: "TEMPLATE(collection,keyvalue)", + documents: [ + { + key: "{rw_key}", + value: "{rw_value}" + } + ], + writeConcern: { w: "majority" }, + comment: "Insert documents into keyvalue collection." } + drop-collection: + ops: + drop-collection: | + { + drop: "TEMPLATE(collection,keyvalue)", + comment: "Drop keyvalue collection to start afresh." + } \ No newline at end of file diff --git a/mongodb-tabular2.yaml b/adapter-mongodb/src/main/resources/activities/baselinesv2/mongodb-tabular2.yaml similarity index 99% rename from mongodb-tabular2.yaml rename to adapter-mongodb/src/main/resources/activities/baselinesv2/mongodb-tabular2.yaml index 945b5951d..5f8775898 100644 --- a/mongodb-tabular2.yaml +++ b/adapter-mongodb/src/main/resources/activities/baselinesv2/mongodb-tabular2.yaml @@ -114,10 +114,10 @@ blocks: indexes: [ { key: { - key: 1, + part: 1, }, name: "tab_part_idx", - unique: true + unique: false }, { key: { @@ -277,4 +277,4 @@ blocks: { drop: "TEMPLATE(collection,tabular)", comment: "Drop tabular collection to start afresh." - } \ No newline at end of file + } diff --git a/mongodb-timeseries2.yaml b/adapter-mongodb/src/main/resources/activities/baselinesv2/mongodb-timeseries2.yaml similarity index 100% rename from mongodb-timeseries2.yaml rename to adapter-mongodb/src/main/resources/activities/baselinesv2/mongodb-timeseries2.yaml diff --git a/mongodb-keyvalue2.yaml b/mongodb-keyvalue2.yaml deleted file mode 100644 index f32a23c78..000000000 --- a/mongodb-keyvalue2.yaml +++ /dev/null @@ -1,125 +0,0 @@ -# Connection Guide: https://www.mongodb.com/docs/drivers/java/sync/current/fundamentals/connection/ -# 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: "4.17.24" - -description: | - This workload is analogous to the cql-keyvalue2 workload, just implemented for MongoDB. - -scenarios: - default: - schema: run driver=mongodb tags==block:schema threads==1 cycles==UNDEF - rampup: run driver=mongodb tags==block:rampup cycles===TEMPLATE(rampup-cycles,10000000) threads=auto - main: run driver=mongodb tags==block:"main-.*" cycles===TEMPLATE(main-cycles,10000000) threads=auto - drop: run driver=mongodb tags==block:drop-collection threads==1 cycles==UNDEF - -params: - instrument: true -bindings: - seq_key: Mod(TEMPLATE(keycount,1000000000)); ToString(); - seq_value: >- - Hash(); - Mod(TEMPLATE(valuecount,1000000000)); - CharBufImage('A-Za-z0-9 _|/',16000000,HashRange(TEMPLATE(mintext,50000)TEMPLATE(addzeroes,),TEMPLATE(maxtext,150000)TEMPLATE(addzeroes,))); - ToString(); - rw_key: TEMPLATE(keydist,Uniform(0,1000000000)); ToString() -> String - rw_value: Hash(); TEMPLATE(valdist,Uniform(0,1000000000)); CharBufImage('A-Za-z0-9 _|/',16000000,HashRange(TEMPLATE(mintext,50000)TEMPLATE(addzeros,),TEMPLATE(maxtext,150000)TEMPLATE(addzeros,))); ToString(); - -blocks: - schema: - params: - prepared: false - ops: - # https://www.mongodb.com/docs/manual/reference/method/db.createCollection/ - # https://www.mongodb.com/docs/manual/core/schema-validation/specify-json-schema/ - # `clusteredIndex` only support creation of an index on `_id` field (as shown below) so its optional - create-collection: | - { - create: "TEMPLATE(collection,keyvalue)", - clusteredIndex: { - key: { "_id": 1 }, - unique: true, - name: "_id_idx" - }, - writeConcern: { w: "majority" }, - validator: { - $jsonSchema: { - bsonType: "object", - title: "Key/Value collection schema validation", - required: [ "key" ], - properties: { - key: { - bsonType: "string", - description: "'key' must be a string and is required" - } - } - } - }, - validationLevel: "strict", - validationAction: "error", - comment: "keyvalue collection creation with strict types and required 'key' field." - } - create-key-index: | - { - createIndexes: "TEMPLATE(collection,keyvalue)", - indexes: [ - { - key: { - key: 1, - }, - name: "kv_key_idx", - unique: true - } - ], - writeConcern: { w: "majority" }, - comment: "'key' index creation for keyvalue collection. Values should be unique.", - commitQuorum: "majority" - } - rampup: - ops: - rampup-insert: | - { - insert: "TEMPLATE(collection,keyvalue)", - documents: [ - { - key: "{rw_key}", - value: "{rw_value}" - } - ], - comment: "Insert documents into keyvalue collection." - } - main-read: - params: - ratio: 5 - ops: - main-select: | - { - find: "TEMPLATE(collection,keyvalue)", - filter: { key: { $eq: "{rw_key}" } }, - readConcern: { level: "majority" }, - comment: "Find the value for the given 'key'." - } - main-write: - params: - ratio: 5 - ops: - main-insert: | - { - insert: "TEMPLATE(collection,keyvalue)", - documents: [ - { - key: "{rw_key}", - value: "{rw_value}" - } - ], - writeConcern: { w: "majority" }, - comment: "Insert documents into keyvalue collection." - } - drop-collection: - ops: - drop-collection: | - { - drop: "TEMPLATE(collection,keyvalue)", - comment: "Drop keyvalue collection to start afresh." - } \ No newline at end of file