diff options
-rw-r--r-- | jstests/sharding/bigMapReduce.js | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/jstests/sharding/bigMapReduce.js b/jstests/sharding/bigMapReduce.js index bf4f4c5fb66..3cc1d66405a 100644 --- a/jstests/sharding/bigMapReduce.js +++ b/jstests/sharding/bigMapReduce.js @@ -15,26 +15,61 @@ s.printChangeLog(); function map() { emit('count', 1); } function reduce(key, values) { return Array.sum(values) } -out = db.foo.mapReduce(map, reduce,"big_out") -printjson(out) // SERVER-1400 +gotAGoodOne = false; +for ( iter=0; iter<5; iter++ ){ + try { + out = db.foo.mapReduce(map, reduce,"big_out") + gotAGoodOne = true + } + catch ( e ){ + if ( __mrerror__ && __mrerror__.cause && __mrerror__.cause.assertionCode == 13388 ){ + // TODO: SERVER-2396 + sleep( 1000 ); + continue; + } + printjson( __mrerror__ ); + throw e; + } +} +assert( gotAGoodOne , "no good for basic" ) + +gotAGoodOne = false; // test output to a different DB // do it multiple times so that primary shard changes for (iter = 0; iter < 5; iter++) { outCollStr = "mr_replace_col_" + iter; outDbStr = "mr_db_" + iter; + print("Testing mr replace into DB " + iter) - res = db.foo.mapReduce( map , reduce , { out : { replace: outCollStr, db: outDbStr } } ) + + try { + res = db.foo.mapReduce( map , reduce , { out : { replace: outCollStr, db: outDbStr } } ) + gotAGoodOne = true; + } + catch ( e ){ + if ( __mrerror__ && __mrerror__.cause && __mrerror__.cause.assertionCode == 13388 ){ + // TODO: SERVER-2396 + sleep( 1000 ); + continue; + } + printjson( __mrerror__ ); + throw e; + } printjson(res); + outDb = s.getDB(outDbStr); outColl = outDb[outCollStr]; + obj = outColl.convertToSingleObject("value"); - assert.eq( obj.count , 25600 , "Received wrong result " + obj.count ); + assert.eq( 25600 , obj.count , "Received wrong result " + obj.count ); + print("checking result field"); assert.eq(res.result.collection, outCollStr, "Wrong collection " + res.result.collection); assert.eq(res.result.db, outDbStr, "Wrong db " + res.result.db); } -for (i = 0; i < 5; i++) { print(i); } +assert( gotAGoodOne , "no good for out db" ) + s.stop() |