Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion lib/mongo/operation/map_reduce/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ def time
# @since 2.0.0
# @api private
def validate!
documents.nil? ? raise_operation_failure : self
if documents.nil? || !parser.message.empty?
Comment thread
jamis marked this conversation as resolved.
Resolved
raise_operation_failure
else
self
end
end

# Get the cursor id.
Expand Down
10 changes: 10 additions & 0 deletions spec/runners/unified/crud_operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,16 @@ def aggregate(op)
obj.aggregate(pipeline, **opts).to_a
end

def map_reduce(op)
obj = entities.get_any(op.use!('object'))
args = op.use!('arguments')
map = args.use!('map')
reduce = args.use!('reduce')
out = args.use!('out')

Mongo::Collection::View.new(obj).map_reduce(map, reduce, out: out).to_a
end

def create_find_cursor(op)
obj = entities.get_any(op.use!('object'))
args = op.use!('arguments')
Expand Down
10 changes: 10 additions & 0 deletions spec/runners/unified/grid_fs_operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ def delete(op)
end
end

def delete_by_name(op)
bucket = entities.get(:bucket, op.use!('object'))
use_arguments(op) do |args|
filename = args.use!('filename')
bucket.find(filename: filename).to_a.each do |file|
bucket.delete(file['_id'])
end
end
end

def download(op)
bucket = entities.get(:bucket, op.use!('object'))
use_arguments(op) do |args|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
description: write-concern-errors-aggregate

schemaVersion: "1.0"

createEntities:
- client:
id: &client0 client0
useMultipleMongoses: false
- database:
id: &database0 database0
client: *client0
databaseName: &database_name write-concern-errors-tests
- collection:
id: &collection0 collection0
database: *database0
collectionName: &collection_name coll

# Create the database used for aggregate to avoid a NamespaceNotFound error.
initialData:
- collectionName: *collection_name
databaseName: *database_name
documents: []

tests:
- description: aggregate with $out reports a writeConcernError
operations:
- name: failPoint
object: testRunner
arguments:
client: *client0
failPoint:
configureFailPoint: failCommand
mode: { times: 1 }
data:
failCommands: [ aggregate ]
writeConcernError: &write_concern_error
code: 79
codeName: UnknownReplWriteConcern
- name: aggregate
object: *collection0
arguments:
pipeline:
- $match: { _id: { $gt: 1 } }
- $out: "aggregate_out"
expectError: &expect_write_concern_error
errorCode: 79

- description: aggregate with $merge reports a writeConcernError
operations:
- name: failPoint
object: testRunner
arguments:
client: *client0
failPoint:
configureFailPoint: failCommand
mode: { times: 1 }
data:
failCommands: [ aggregate ]
writeConcernError: *write_concern_error
- name: aggregate
object: *collection0
arguments:
pipeline:
- $match: { _id: { $gt: 1 } }
- $merge: { into: "aggregate_merge" }
expectError: *expect_write_concern_error
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
description: write-concern-errors-bulkWrite

schemaVersion: "1.0"

createEntities:
- client:
id: &client0 client0
useMultipleMongoses: false
- database:
id: &database0 database0
client: *client0
databaseName: write-concern-errors-tests
- collection:
id: &collection0 collection0
database: *database0
collectionName: coll

tests:
- description: bulkWrite reports a writeConcernError
operations:
- name: failPoint
object: testRunner
arguments:
client: *client0
failPoint:
configureFailPoint: failCommand
mode: { times: 1 }
data:
failCommands: [ insert ]
writeConcernError:
code: 79
codeName: UnknownReplWriteConcern
- name: bulkWrite
object: *collection0
arguments:
requests:
- insertOne:
document: { x: 33 }
expectError:
isError: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
description: write-concern-errors-client-bulkWrite

schemaVersion: "1.21"

runOnRequirements:
- minServerVersion: "8.0"

createEntities:
- client:
id: &client0 client0
useMultipleMongoses: false

tests:
- description: clientBulkWrite reports a writeConcernError
operations:
- name: failPoint
object: testRunner
arguments:
client: *client0
failPoint:
configureFailPoint: failCommand
mode: { times: 1 }
data:
failCommands: [ bulkWrite ]
writeConcernError:
code: 79
codeName: UnknownReplWriteConcern
- name: clientBulkWrite
object: *client0
arguments:
models:
- insertOne:
namespace: write-concern-errors-tests.coll
document: { x: 33 }
expectError:
writeConcernErrors:
- code: 79
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
description: write-concern-errors-client-side-encryption

schemaVersion: "1.8"

runOnRequirements:
- csfle: true

createEntities:
- client:
id: &client0 client0
useMultipleMongoses: false
- clientEncryption:
id: &clientEncryption0 clientEncryption0
clientEncryptionOpts:
keyVaultClient: *client0
keyVaultNamespace: keyvault.datakeys
kmsProviders:
local: { key: { $$placeholder: 1 } }

initialData:
- databaseName: keyvault
collectionName: datakeys
documents:
- _id: { $binary: { base64: bG9jYWxrZXlsb2NhbGtleQ==, subType: "04" } }
keyAltNames: ["local_key"]
keyMaterial:
{
$binary:
{
base64: ABKBldDEoDW323yejOnIRk6YQmlD9d3eQthd16scKL75nz2LjNL9fgPDZWrFFOlqlhMCFaSrNJfGrFUjYk5JFDO7soG5Syb50k1niJoKg4ilsj0L4mpimFUtTpOr2nzZOeQtvAksEXc7gsFgq8gV7t/U3lsaXPY7I0t42DfSE8EGlPdxRjFdHnxh+OR8h7U9b8Qs5K5UuhgyeyxaBZ1Hgw==,
subType: "00",
},
}
creationDate: { $date: { $numberLong: "1641024000000" } }
updateDate: { $date: { $numberLong: "1641024000000" } }
status: 1
masterKey:
provider: local

tests:
- description: rewrapManyDataKey reports a writeConcernError
operations:
- name: failPoint
object: testRunner
arguments:
client: *client0
failPoint:
configureFailPoint: failCommand
mode: { times: 1 }
data:
failCommands: [ update ]
writeConcernError: &write_concern_error
code: 79
codeName: UnknownReplWriteConcern
- name: rewrapManyDataKey
object: *clientEncryption0
arguments:
filter: {}
opts:
provider: local
expectError:
isError: true

- description: createDataKey reports a writeConcernError
operations:
- name: failPoint
object: testRunner
arguments:
client: *client0
failPoint:
configureFailPoint: failCommand
mode: { times: 1 }
data:
failCommands: [ insert ]
writeConcernError: *write_concern_error
- name: createDataKey
object: *clientEncryption0
arguments:
kmsProvider: local
expectError: &expect_write_concern_error
errorCode: 79

- description: deleteKey reports a writeConcernError
operations:
- name: failPoint
object: testRunner
arguments:
client: *client0
failPoint:
configureFailPoint: failCommand
mode: { times: 1 }
data:
failCommands: [ delete ]
writeConcernError: *write_concern_error
- name: deleteKey
object: *clientEncryption0
arguments:
id: &local_key_id { $binary: { base64: bG9jYWxrZXlsb2NhbGtleQ==, subType: "04" } }
expectError: *expect_write_concern_error

- description: addKeyAltName reports a writeConcernError
operations:
- &failPoint_findAndModify
name: failPoint
object: testRunner
arguments:
client: *client0
failPoint:
configureFailPoint: failCommand
mode: { times: 1 }
data:
failCommands: [ findAndModify ]
writeConcernError: *write_concern_error
- name: addKeyAltName
object: *clientEncryption0
arguments:
id: *local_key_id
keyAltName: new_key_alt_name
expectError: *expect_write_concern_error

- description: removeKeyAltName reports a writeConcernError
operations:
- *failPoint_findAndModify
- name: removeKeyAltName
object: *clientEncryption0
arguments:
id: *local_key_id
keyAltName: local_key
expectError: *expect_write_concern_error
Loading
Loading