285 lines
6.8 KiB
JSON
285 lines
6.8 KiB
JSON
{
|
|
"description": "mapReduce",
|
|
"schemaVersion": "1.9",
|
|
"runOnRequirements": [
|
|
{
|
|
"minServerVersion": "4.0",
|
|
"topologies": [
|
|
"single",
|
|
"replicaset"
|
|
]
|
|
},
|
|
{
|
|
"minServerVersion": "4.1.7",
|
|
"serverless": "forbid",
|
|
"topologies": [
|
|
"sharded",
|
|
"load-balanced"
|
|
]
|
|
}
|
|
],
|
|
"createEntities": [
|
|
{
|
|
"client": {
|
|
"id": "client0",
|
|
"useMultipleMongoses": false,
|
|
"observeEvents": [
|
|
"commandStartedEvent"
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"database": {
|
|
"id": "database0",
|
|
"client": "client0",
|
|
"databaseName": "retryable-reads-tests"
|
|
}
|
|
},
|
|
{
|
|
"collection": {
|
|
"id": "collection0",
|
|
"database": "database0",
|
|
"collectionName": "coll"
|
|
}
|
|
}
|
|
],
|
|
"initialData": [
|
|
{
|
|
"collectionName": "coll",
|
|
"databaseName": "retryable-reads-tests",
|
|
"documents": [
|
|
{
|
|
"_id": 1,
|
|
"x": 0
|
|
},
|
|
{
|
|
"_id": 2,
|
|
"x": 1
|
|
},
|
|
{
|
|
"_id": 3,
|
|
"x": 2
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"tests": [
|
|
{
|
|
"description": "MapReduce succeeds with retry on",
|
|
"operations": [
|
|
{
|
|
"object": "collection0",
|
|
"name": "mapReduce",
|
|
"arguments": {
|
|
"map": {
|
|
"$code": "function inc() { return emit(0, this.x + 1) }"
|
|
},
|
|
"reduce": {
|
|
"$code": "function sum(key, values) { return values.reduce((acc, x) => acc + x); }"
|
|
},
|
|
"out": {
|
|
"inline": 1
|
|
}
|
|
},
|
|
"expectResult": [
|
|
{
|
|
"_id": 0,
|
|
"value": 6
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"expectEvents": [
|
|
{
|
|
"client": "client0",
|
|
"events": [
|
|
{
|
|
"commandStartedEvent": {
|
|
"command": {
|
|
"mapReduce": "coll",
|
|
"map": {
|
|
"$code": "function inc() { return emit(0, this.x + 1) }"
|
|
},
|
|
"reduce": {
|
|
"$code": "function sum(key, values) { return values.reduce((acc, x) => acc + x); }"
|
|
},
|
|
"out": {
|
|
"inline": 1
|
|
}
|
|
},
|
|
"databaseName": "retryable-reads-tests"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "MapReduce fails with retry on",
|
|
"operations": [
|
|
{
|
|
"object": "testRunner",
|
|
"name": "failPoint",
|
|
"arguments": {
|
|
"client": "client0",
|
|
"failPoint": {
|
|
"configureFailPoint": "failCommand",
|
|
"mode": {
|
|
"times": 1
|
|
},
|
|
"data": {
|
|
"failCommands": [
|
|
"mapReduce"
|
|
],
|
|
"closeConnection": true
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"object": "collection0",
|
|
"name": "mapReduce",
|
|
"arguments": {
|
|
"map": {
|
|
"$code": "function inc() { return emit(0, this.x + 1) }"
|
|
},
|
|
"reduce": {
|
|
"$code": "function sum(key, values) { return values.reduce((acc, x) => acc + x); }"
|
|
},
|
|
"out": {
|
|
"inline": 1
|
|
}
|
|
},
|
|
"expectError": {
|
|
"isError": true
|
|
}
|
|
}
|
|
],
|
|
"expectEvents": [
|
|
{
|
|
"client": "client0",
|
|
"events": [
|
|
{
|
|
"commandStartedEvent": {
|
|
"command": {
|
|
"mapReduce": "coll",
|
|
"map": {
|
|
"$code": "function inc() { return emit(0, this.x + 1) }"
|
|
},
|
|
"reduce": {
|
|
"$code": "function sum(key, values) { return values.reduce((acc, x) => acc + x); }"
|
|
},
|
|
"out": {
|
|
"inline": 1
|
|
}
|
|
},
|
|
"databaseName": "retryable-reads-tests"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "MapReduce fails with retry off",
|
|
"operations": [
|
|
{
|
|
"object": "testRunner",
|
|
"name": "createEntities",
|
|
"arguments": {
|
|
"entities": [
|
|
{
|
|
"client": {
|
|
"id": "client1",
|
|
"useMultipleMongoses": false,
|
|
"uriOptions": {
|
|
"retryReads": false
|
|
},
|
|
"observeEvents": [
|
|
"commandStartedEvent"
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"database": {
|
|
"id": "database1",
|
|
"client": "client1",
|
|
"databaseName": "retryable-reads-tests"
|
|
}
|
|
},
|
|
{
|
|
"collection": {
|
|
"id": "collection1",
|
|
"database": "database1",
|
|
"collectionName": "coll"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"object": "testRunner",
|
|
"name": "failPoint",
|
|
"arguments": {
|
|
"client": "client1",
|
|
"failPoint": {
|
|
"configureFailPoint": "failCommand",
|
|
"mode": {
|
|
"times": 1
|
|
},
|
|
"data": {
|
|
"failCommands": [
|
|
"mapReduce"
|
|
],
|
|
"closeConnection": true
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"object": "collection1",
|
|
"name": "mapReduce",
|
|
"arguments": {
|
|
"map": {
|
|
"$code": "function inc() { return emit(0, this.x + 1) }"
|
|
},
|
|
"reduce": {
|
|
"$code": "function sum(key, values) { return values.reduce((acc, x) => acc + x); }"
|
|
},
|
|
"out": {
|
|
"inline": 1
|
|
}
|
|
},
|
|
"expectError": {
|
|
"isError": true
|
|
}
|
|
}
|
|
],
|
|
"expectEvents": [
|
|
{
|
|
"client": "client1",
|
|
"events": [
|
|
{
|
|
"commandStartedEvent": {
|
|
"command": {
|
|
"mapReduce": "coll",
|
|
"map": {
|
|
"$code": "function inc() { return emit(0, this.x + 1) }"
|
|
},
|
|
"reduce": {
|
|
"$code": "function sum(key, values) { return values.reduce((acc, x) => acc + x); }"
|
|
},
|
|
"out": {
|
|
"inline": 1
|
|
}
|
|
},
|
|
"databaseName": "retryable-reads-tests"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|