jstests/sharding/move_chunk_update_shard_key_in_retryable_write.js
// Run the given command and assert the response is as expected.
Run the given command and assert the response is as expected.
Run the given command and assert the response is as expected .
function runCommandOnInitialTry(cmdObj) {
        if (!cmdObj.upsert) {
            mongos0TestColl.insert({x: shardKeyValueOnShard0});
        }
        const result = assert.commandWorked(mongos0TestDB.runCommand(cmdObj));
        if (cmdObj.findAndModify) {
            if (!cmdObj.upsert) {
                assert.eq(result.lastErrorObject.n, 1, tojson(result));
                assert.eq(result.lastErrorObject.updatedExisting, true, tojson(result));
            } else {
                assert.eq(result.lastErrorObject.n, 1, tojson(result));
                assert.eq(result.lastErrorObject.updatedExisting, false, tojson(result));
                assert(result.lastErrorObject.upserted, tojson(result));
            }
        } else {  
            assert.eq(result.n, 1, tojson(result));
            assert.eq(result.nModified, 1, tojson(result));
        }
        assert.eq(mongos0TestColl.find({x: shardKeyValueOnShard1}).itcount(), 1);
        assert.commandWorked(mongos0TestColl.deleteMany({}));  
    }
function runCommandOnInitialTry ( cmdObj ) { if ( ! cmdObj . upsert ) { mongos0TestColl . insert ( { x : shardKeyValueOnShard0 } ) ; } const result = assert . commandWorked ( mongos0TestDB . runCommand ( cmdObj ) ) ; if ( cmdObj . findAndModify ) { if ( ! cmdObj . upsert ) { assert . eq ( result . lastErrorObject . n , 1 , tojson ( result ) ) ; assert . eq ( result . lastErrorObject . updatedExisting , true , tojson ( result ) ) ; } else { assert . eq ( result . lastErrorObject . n , 1 , tojson ( result ) ) ; assert . eq ( result . lastErrorObject . updatedExisting , false , tojson ( result ) ) ; assert ( result . lastErrorObject . upserted , tojson ( result ) ) ; } } else { assert . eq ( result . n , 1 , tojson ( result ) ) ; assert . eq ( result . nModified , 1 , tojson ( result ) ) ; } assert . eq ( mongos0TestColl . find ( { x : shardKeyValueOnShard1 } ) . itcount ( ) , 1 ) ; assert . commandWorked ( mongos0TestColl . deleteMany ( { } ) ) ; }
Run the given command and assert the response is as expected.
Run the given command and assert the response is as expected .
// Insert a single document on shard0. Skip in the upsert case to get coverage where there // is no pre-image. // Update the document shard key. The document should now be on shard1. // update // Clean up for the next test case.