From 53eee17fde31f7b1e1d5279bcf26e42bfb704701 Mon Sep 17 00:00:00 2001 From: Dmitry Rybakov Date: Tue, 26 Sep 2023 09:37:30 +0200 Subject: [PATCH 01/10] 2706 --- .../crud_unified/find-test-all-options.yml | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 spec/spec_tests/data/crud_unified/find-test-all-options.yml diff --git a/spec/spec_tests/data/crud_unified/find-test-all-options.yml b/spec/spec_tests/data/crud_unified/find-test-all-options.yml new file mode 100644 index 0000000000..793dd2fb4d --- /dev/null +++ b/spec/spec_tests/data/crud_unified/find-test-all-options.yml @@ -0,0 +1,89 @@ +description: "find options" + +schemaVersion: "1.0" + +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: true # ensure cursors pin to a single server + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name find-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name coll0 + +tests: + - description: "sort" + operations: + - name: find + arguments: + filter: &filter { _name: "John" } + sort: &sort { _id: 1 } + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + sort: *sort + commandName: find + + - description: "projection" + operations: + - name: find + arguments: + filter: *filter + projection: &projection { _id: 1 } + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + projection: *projection + commandName: find + databaseName: *database0Name + + - description: "hint" + operations: + - name: find + arguments: + filter: *filter + hint: &hint { _id: 1 } + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + hint: *hint + commandName: find + databaseName: *database0Name + + - description: "skip" + operations: + - name: find + arguments: + filter: *filter + skip: &skip 10 + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + skip: *skip + commandName: find + databaseName: *database0Name From 5d6289d860133ae37a5bb3b8eaf5712f3dc512d6 Mon Sep 17 00:00:00 2001 From: Dmitry Rybakov Date: Tue, 26 Sep 2023 12:05:28 +0200 Subject: [PATCH 02/10] Add unified test for all find options --- .../crud_unified/find-test-all-options.yml | 324 ++++++++++++++++++ 1 file changed, 324 insertions(+) diff --git a/spec/spec_tests/data/crud_unified/find-test-all-options.yml b/spec/spec_tests/data/crud_unified/find-test-all-options.yml index 793dd2fb4d..8bc6d26a76 100644 --- a/spec/spec_tests/data/crud_unified/find-test-all-options.yml +++ b/spec/spec_tests/data/crud_unified/find-test-all-options.yml @@ -87,3 +87,327 @@ tests: skip: *skip commandName: find databaseName: *database0Name + + - description: "limit" + operations: + - name: find + arguments: + filter: *filter + limit: &limit 10 + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + limit: *limit + commandName: find + databaseName: *database0Name + + - description: "batchSize" + operations: + - name: find + arguments: + filter: *filter + batchSize: &batchSize 10 + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + batchSize: *batchSize + commandName: find + databaseName: *database0Name + + - description: "singleBatch" + operations: + - name: find + arguments: + filter: *filter + singleBatch: &singleBatch true + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + singleBatch: *singleBatch + commandName: find + databaseName: *database0Name + + - description: "comment" + operations: + - name: find + arguments: + filter: *filter + comment: &comment 'comment' + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + comment: *comment + commandName: find + databaseName: *database0Name + + - description: "maxTimeMS" + operations: + - name: find + arguments: + filter: *filter + maxTimeMS: &maxTimeMS 1000 + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + maxTimeMS: *maxTimeMS + commandName: find + databaseName: *database0Name + + - description: "readConcern" + operations: + - name: find + arguments: + filter: *filter + readConcern: &readConcern { level: "local" } + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + readConcern: *readConcern + commandName: find + databaseName: *database0Name + + - description: "max" + operations: + - name: find + arguments: + filter: *filter + max: &max { _id: 10 } + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + max: *max + commandName: find + databaseName: *database0Name + + - description: "min" + operations: + - name: find + arguments: + filter: *filter + min: &min { _id: 10 } + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + min: *min + commandName: find + databaseName: *database0Name + + - description: "returnKey" + operations: + - name: find + arguments: + filter: *filter + returnKey: &returnKey false + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + returnKey: *returnKey + commandName: find + databaseName: *database0Name + + - description: "showRecordId" + operations: + - name: find + arguments: + filter: *filter + showRecordId: &showRecordId false + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + showRecordId: *showRecordId + commandName: find + databaseName: *database0Name + + - description: "tailable" + operations: + - name: find + arguments: + filter: *filter + tailable: &tailable false + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + tailable: *tailable + commandName: find + databaseName: *database0Name + + - description: "awaitData" + operations: + - name: find + arguments: + filter: *filter + awaitData: &awaitData false + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + awaitData: *awaitData + commandName: find + databaseName: *database0Name + + - description: "oplogReply" + operations: + - name: find + arguments: + filter: *filter + oplogReply: &oplogReply false + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + oplogReply: *oplogReply + commandName: find + databaseName: *database0Name + + - description: "noCursorTimeout" + operations: + - name: find + arguments: + filter: *filter + noCursorTimeout: &noCursorTimeout false + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + noCursorTimeout: *noCursorTimeout + commandName: find + databaseName: *database0Name + + - description: "allowPartialResults" + operations: + - name: find + arguments: + filter: *filter + allowPartialResults: &allowPartialResults false + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + allowPartialResults: *allowPartialResults + commandName: find + databaseName: *database0Name + + - description: "collation" + operations: + - name: find + arguments: + filter: *filter + collation: &collation { locale: "en" } + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + collation: *collation + commandName: find + databaseName: *database0Name + + - description: "allowDiskUse" + operations: + - name: find + arguments: + filter: *filter + allowDiskUse: &allowDiskUse true + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + allowDiskUse: *allowDiskUse + commandName: find + databaseName: *database0Name + + - description: "let" + operations: + - name: find + arguments: + filter: *filter + let: &let { name: "Mary" } + object: *collection0 + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + find: *collection0Name + filter: *filter + let: *let + commandName: find + databaseName: *database0Name From d9a5f1c3c31139f4cda8a5c696a20bf48e8a4f27 Mon Sep 17 00:00:00 2001 From: Dmitry Rybakov Date: Fri, 29 Sep 2023 11:45:34 +0200 Subject: [PATCH 03/10] Add missing options --- lib/mongo/collection/view/iterable.rb | 1 + spec/runners/unified/crud_operations.rb | 12 +++ .../crud_unified/find-test-all-options.yml | 88 +++---------------- 3 files changed, 23 insertions(+), 78 deletions(-) diff --git a/lib/mongo/collection/view/iterable.rb b/lib/mongo/collection/view/iterable.rb index f9d7b1603a..159719bcb1 100644 --- a/lib/mongo/collection/view/iterable.rb +++ b/lib/mongo/collection/view/iterable.rb @@ -162,6 +162,7 @@ def initial_query_op(session) let: options[:let], limit: limit, allow_disk_use: options[:allow_disk_use], + allow_partial_results: options[:allow_partial_results], read: read, read_concern: options[:read_concern] || read_concern, batch_size: batch_size, diff --git a/spec/runners/unified/crud_operations.rb b/spec/runners/unified/crud_operations.rb index 9274bf62df..69e35513a8 100644 --- a/spec/runners/unified/crud_operations.rb +++ b/spec/runners/unified/crud_operations.rb @@ -32,6 +32,18 @@ def get_find_view(op) if session = args.use('session') opts[:session] = entities.get(:session, session) end + if collation = args.use('collation') + opts[:collation] = collation + end + if args.key?('noCursorTimeout') + opts[:no_cursor_timeout] = args.use('noCursorTimeout') + end + if args.key?('oplogReplay') + opts[:oplog_replay] = args.use('oplogReplay') + end + if args.key?('allowPartialResults') + opts[:allow_partial_results] = args.use('allowPartialResults') + end req = collection.find(args.use!('filter'), **opts) if batch_size = args.use('batchSize') req = req.batch_size(batch_size) diff --git a/spec/spec_tests/data/crud_unified/find-test-all-options.yml b/spec/spec_tests/data/crud_unified/find-test-all-options.yml index 8bc6d26a76..9f141d514d 100644 --- a/spec/spec_tests/data/crud_unified/find-test-all-options.yml +++ b/spec/spec_tests/data/crud_unified/find-test-all-options.yml @@ -5,7 +5,6 @@ schemaVersion: "1.0" createEntities: - client: id: &client0 client0 - useMultipleMongoses: true # ensure cursors pin to a single server observeEvents: [ commandStartedEvent ] - database: id: &database0 database0 @@ -39,7 +38,7 @@ tests: - name: find arguments: filter: *filter - projection: &projection { _id: 1 } + projection: &projection { _id: 1 } object: *collection0 expectEvents: - client: *client0 @@ -124,24 +123,6 @@ tests: commandName: find databaseName: *database0Name - - description: "singleBatch" - operations: - - name: find - arguments: - filter: *filter - singleBatch: &singleBatch true - object: *collection0 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - find: *collection0Name - filter: *filter - singleBatch: *singleBatch - commandName: find - databaseName: *database0Name - - description: "comment" operations: - name: find @@ -178,30 +159,14 @@ tests: commandName: find databaseName: *database0Name - - description: "readConcern" - operations: - - name: find - arguments: - filter: *filter - readConcern: &readConcern { level: "local" } - object: *collection0 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - find: *collection0Name - filter: *filter - readConcern: *readConcern - commandName: find - databaseName: *database0Name - - description: "max" operations: - name: find arguments: filter: *filter max: &max { _id: 10 } + expectError: + isClientError: false object: *collection0 expectEvents: - client: *client0 @@ -219,7 +184,10 @@ tests: - name: find arguments: filter: *filter - min: &min { _id: 10 } + hint: { name: 1 } + min: &min { name: 'John' } + expectError: + isClientError: false object: *collection0 expectEvents: - client: *client0 @@ -268,48 +236,12 @@ tests: commandName: find databaseName: *database0Name - - description: "tailable" - operations: - - name: find - arguments: - filter: *filter - tailable: &tailable false - object: *collection0 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - find: *collection0Name - filter: *filter - tailable: *tailable - commandName: find - databaseName: *database0Name - - - description: "awaitData" - operations: - - name: find - arguments: - filter: *filter - awaitData: &awaitData false - object: *collection0 - expectEvents: - - client: *client0 - events: - - commandStartedEvent: - command: - find: *collection0Name - filter: *filter - awaitData: *awaitData - commandName: find - databaseName: *database0Name - - - description: "oplogReply" + - description: "oplogReplay" operations: - name: find arguments: filter: *filter - oplogReply: &oplogReply false + oplogReplay: &oplogReplay false object: *collection0 expectEvents: - client: *client0 @@ -318,7 +250,7 @@ tests: command: find: *collection0Name filter: *filter - oplogReply: *oplogReply + oplogReplay: *oplogReplay commandName: find databaseName: *database0Name From 1a3f7105edbdcf72536bbee0d9acec850a7009d0 Mon Sep 17 00:00:00 2001 From: Dmitry Rybakov Date: Mon, 2 Oct 2023 16:05:31 +0200 Subject: [PATCH 04/10] Clarify collation on collection --- lib/mongo/collection.rb | 4 +- spec/integration/find_options_spec.rb | 76 +++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 spec/integration/find_options_spec.rb diff --git a/lib/mongo/collection.rb b/lib/mongo/collection.rb index 90514f203f..58d56e1b94 100644 --- a/lib/mongo/collection.rb +++ b/lib/mongo/collection.rb @@ -339,7 +339,9 @@ def capped? # inserted or updated documents where the clustered index key value # matches an existing value in the index. # - *:name* -- Optional. A name that uniquely identifies the clustered index. - # @option opts [ Hash ] :collation The collation to use. + # @option opts [ Hash ] :collation The collation to use when creating the + # collection. This option will not be sent to the server when calling + # collection methods. # @option opts [ Hash ] :encrypted_fields Hash describing encrypted fields # for queryable encryption. # @option opts [ Integer ] :expire_after Number indicating diff --git a/spec/integration/find_options_spec.rb b/spec/integration/find_options_spec.rb new file mode 100644 index 0000000000..3d7f4d5cf8 --- /dev/null +++ b/spec/integration/find_options_spec.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'Find operation options' do + let(:subscriber) { Mrss::EventSubscriber.new } + + let(:seeds) do + [ SpecConfig.instance.addresses.first ] + end + + let(:client) do + ClientRegistry.instance.new_local_client( + seeds, + SpecConfig.instance.test_options.merge(client_options) + ).tap do |client| + client.subscribe(Mongo::Monitoring::COMMAND, subscriber) + end + end + + let(:collection) do + client['find_options', collection_options] + end + + let(:find_command) do + subscriber.started_events.find { |cmd| cmd.command_name == 'find' } + end + + before do + ClientRegistry.instance.global_client('authorized')['find_options'].drop + collection.insert_many([ { a: 1 }, { a: 2 }, { a: 3 } ]) + end + + describe 'collation' do + let(:client_options) do + {} + end + + let(:collation) do + { 'locale' => 'en_US' } + end + + context 'when defined on the collection' do + let(:collection_options) do + { collation: collation } + end + + it 'uses the collation defined on the collection' do + collection.find.to_a + expect(find_command.command['collation']).to be_nil + end + end + + context 'when defined on the operation' do + let(:collection_options) do + {} + end + + it 'uses the collation defined on the collection' do + collection.find({}, collation: collation).to_a + expect(find_command.command['collation']).to eq(collation) + end + end + + context 'when defined on both collection and operation' do + let(:collection_options) do + { 'locale' => 'de_AT' } + end + + it 'uses the collation defined on the collection' do + collection.find({}, collation: collation).to_a + expect(find_command.command['collation']).to eq(collation) + end + end + end +end From 8a33fa31f7ae68039a33d1a712d4302eeca51ee2 Mon Sep 17 00:00:00 2001 From: Dmitry Rybakov Date: Mon, 2 Oct 2023 17:56:08 +0200 Subject: [PATCH 05/10] Add tests for read_concern option --- spec/integration/find_options_spec.rb | 84 +++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/spec/integration/find_options_spec.rb b/spec/integration/find_options_spec.rb index 3d7f4d5cf8..584af8cfe8 100644 --- a/spec/integration/find_options_spec.rb +++ b/spec/integration/find_options_spec.rb @@ -73,4 +73,88 @@ end end end + + describe 'read concern' do + let(:read_concern) do + { 'level' => 'local' } + end + + context 'when defined on the client' do + let(:client_options) do + { read_concern: read_concern } + end + + let(:collection_options) do + {} + end + + it 'uses the read concern defined on the client' do + collection.find.to_a + expect(find_command.command['readConcern']).to eq(read_concern) + end + + context 'when defined on the collection' do + let(:collection_options) do + { read_concern: { 'level' => 'majority' } } + end + + it 'uses the read concern defined on the collection' do + collection.find.to_a + expect(find_command.command['readConcern']).to eq(collection_options[:read_concern]) + end + + context 'when defined on the operation' do + let(:operation_read_concern) do + { 'level' => 'available' } + end + + it 'uses the read concern defined on the operation' do + collection.find({}, read_concern: operation_read_concern).to_a + expect(find_command.command['readConcern']).to eq(operation_read_concern) + end + end + end + + context 'when defined on the operation' do + let(:collection_options) do + {} + end + + let(:operation_read_concern) do + { 'level' => 'available' } + end + + it 'uses the read concern defined on the operation' do + collection.find({}, read_concern: operation_read_concern).to_a + expect(find_command.command['readConcern']).to eq(operation_read_concern) + end + end + end + + context 'when defined on the collection' do + let(:client_options) do + {} + end + + let(:collection_options) do + { read_concern: { 'level' => 'majority' } } + end + + it 'uses the read concern defined on the collection' do + collection.find.to_a + expect(find_command.command['readConcern']).to eq(collection_options[:read_concern]) + end + + context 'when defined on the operation' do + let(:operation_read_concern) do + { 'level' => 'available' } + end + + it 'uses the read concern defined on the operation' do + collection.find({}, read_concern: operation_read_concern).to_a + expect(find_command.command['readConcern']).to eq(operation_read_concern) + end + end + end + end end From 4a1648bd3989bb945031f7af277ed50ab93e3f94 Mon Sep 17 00:00:00 2001 From: Dmitry Rybakov Date: Wed, 4 Oct 2023 13:38:29 +0200 Subject: [PATCH 06/10] Add tests for read_preference option --- spec/integration/find_options_spec.rb | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/spec/integration/find_options_spec.rb b/spec/integration/find_options_spec.rb index 584af8cfe8..f7522906cf 100644 --- a/spec/integration/find_options_spec.rb +++ b/spec/integration/find_options_spec.rb @@ -157,4 +157,34 @@ end end end + + describe 'read preference' do + require_topology :replica_set + + context 'when defined on the client' do + let(:client_options) do + { read: { mode: :secondary } } + end + + let(:collection_options) do + {} + end + + it 'uses the read preference defined on the client' do + collection.find.to_a + expect(find_command.command['$readPreference']).to eq('mode' => 'secondary') + end + + context 'when defined on the collection' do + let(:collection_options) do + { read: { mode: :secondary_preferred } } + end + + it 'uses the read concern defined on the collection' do + collection.find.to_a + expect(find_command.command['$readPreference']).to eq('mode' => 'secondaryPreferred') + end + end + end + end end From f17ef4f5559464eed171458c4d2805d78f2e718f Mon Sep 17 00:00:00 2001 From: Dmitry Rybakov Date: Thu, 5 Oct 2023 10:10:26 +0200 Subject: [PATCH 07/10] Fix test --- spec/spec_tests/data/crud_unified/find-test-all-options.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/spec_tests/data/crud_unified/find-test-all-options.yml b/spec/spec_tests/data/crud_unified/find-test-all-options.yml index 9f141d514d..ad3266ac91 100644 --- a/spec/spec_tests/data/crud_unified/find-test-all-options.yml +++ b/spec/spec_tests/data/crud_unified/find-test-all-options.yml @@ -165,8 +165,6 @@ tests: arguments: filter: *filter max: &max { _id: 10 } - expectError: - isClientError: false object: *collection0 expectEvents: - client: *client0 @@ -186,8 +184,6 @@ tests: filter: *filter hint: { name: 1 } min: &min { name: 'John' } - expectError: - isClientError: false object: *collection0 expectEvents: - client: *client0 From 211fff9de57e2334b02a1d58c5c1979d2da63418 Mon Sep 17 00:00:00 2001 From: Dmitry Rybakov Date: Thu, 5 Oct 2023 11:02:27 +0200 Subject: [PATCH 08/10] Fix tests --- spec/integration/find_options_spec.rb | 2 ++ spec/spec_tests/data/crud_unified/find-test-all-options.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/spec/integration/find_options_spec.rb b/spec/integration/find_options_spec.rb index f7522906cf..7195f5f5b9 100644 --- a/spec/integration/find_options_spec.rb +++ b/spec/integration/find_options_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' describe 'Find operation options' do + require_no_auth + let(:subscriber) { Mrss::EventSubscriber.new } let(:seeds) do diff --git a/spec/spec_tests/data/crud_unified/find-test-all-options.yml b/spec/spec_tests/data/crud_unified/find-test-all-options.yml index ad3266ac91..b2d459d996 100644 --- a/spec/spec_tests/data/crud_unified/find-test-all-options.yml +++ b/spec/spec_tests/data/crud_unified/find-test-all-options.yml @@ -323,6 +323,8 @@ tests: databaseName: *database0Name - description: "let" + runOnRequirements: + - minServerVersion: "5.0" operations: - name: find arguments: From d05f7b8983e9d8b6f5462bf7aa0c559c712b01dd Mon Sep 17 00:00:00 2001 From: Dmitry Rybakov Date: Thu, 5 Oct 2023 11:45:17 +0200 Subject: [PATCH 09/10] Fix tests --- spec/integration/find_options_spec.rb | 28 ++++++++----------- .../crud_unified/find-test-all-options.yml | 2 ++ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/spec/integration/find_options_spec.rb b/spec/integration/find_options_spec.rb index 7195f5f5b9..a3ab440a97 100644 --- a/spec/integration/find_options_spec.rb +++ b/spec/integration/find_options_spec.rb @@ -77,13 +77,9 @@ end describe 'read concern' do - let(:read_concern) do - { 'level' => 'local' } - end - context 'when defined on the client' do let(:client_options) do - { read_concern: read_concern } + { read_concern: { level: :local } } end let(:collection_options) do @@ -92,27 +88,27 @@ it 'uses the read concern defined on the client' do collection.find.to_a - expect(find_command.command['readConcern']).to eq(read_concern) + expect(find_command.command['readConcern']).to eq('level' => 'local') end context 'when defined on the collection' do let(:collection_options) do - { read_concern: { 'level' => 'majority' } } + { read_concern: { level: :majority } } end it 'uses the read concern defined on the collection' do collection.find.to_a - expect(find_command.command['readConcern']).to eq(collection_options[:read_concern]) + expect(find_command.command['readConcern']).to eq('level' => 'majority') end context 'when defined on the operation' do let(:operation_read_concern) do - { 'level' => 'available' } + { level: :available } end it 'uses the read concern defined on the operation' do collection.find({}, read_concern: operation_read_concern).to_a - expect(find_command.command['readConcern']).to eq(operation_read_concern) + expect(find_command.command['readConcern']).to eq('level' => 'available') end end end @@ -123,12 +119,12 @@ end let(:operation_read_concern) do - { 'level' => 'available' } + { level: :available } end it 'uses the read concern defined on the operation' do collection.find({}, read_concern: operation_read_concern).to_a - expect(find_command.command['readConcern']).to eq(operation_read_concern) + expect(find_command.command['readConcern']).to eq('level' => 'available') end end end @@ -139,22 +135,22 @@ end let(:collection_options) do - { read_concern: { 'level' => 'majority' } } + { read_concern: { level: :majority } } end it 'uses the read concern defined on the collection' do collection.find.to_a - expect(find_command.command['readConcern']).to eq(collection_options[:read_concern]) + expect(find_command.command['readConcern']).to eq('level' => 'majority') end context 'when defined on the operation' do let(:operation_read_concern) do - { 'level' => 'available' } + { level: :available } end it 'uses the read concern defined on the operation' do collection.find({}, read_concern: operation_read_concern).to_a - expect(find_command.command['readConcern']).to eq(operation_read_concern) + expect(find_command.command['readConcern']).to eq('level' => 'available') end end end diff --git a/spec/spec_tests/data/crud_unified/find-test-all-options.yml b/spec/spec_tests/data/crud_unified/find-test-all-options.yml index b2d459d996..24be5ee08d 100644 --- a/spec/spec_tests/data/crud_unified/find-test-all-options.yml +++ b/spec/spec_tests/data/crud_unified/find-test-all-options.yml @@ -305,6 +305,8 @@ tests: databaseName: *database0Name - description: "allowDiskUse" + runOnRequirements: + - minServerVersion: 4.4 operations: - name: find arguments: From 1d339034eb5d75ba5b1345eed566c8e8f2c2f1d3 Mon Sep 17 00:00:00 2001 From: Dmitry Rybakov Date: Thu, 5 Oct 2023 13:01:17 +0200 Subject: [PATCH 10/10] Limit versions --- spec/integration/find_options_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/integration/find_options_spec.rb b/spec/integration/find_options_spec.rb index a3ab440a97..e5a822a3ea 100644 --- a/spec/integration/find_options_spec.rb +++ b/spec/integration/find_options_spec.rb @@ -3,7 +3,9 @@ require 'spec_helper' describe 'Find operation options' do + require_mri require_no_auth + min_server_fcv '4.4' let(:subscriber) { Mrss::EventSubscriber.new }