diff options
Diffstat (limited to 'jstests/multiVersion/sharded_timeseries_collmod_mixed_version.js')
-rw-r--r-- | jstests/multiVersion/sharded_timeseries_collmod_mixed_version.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/jstests/multiVersion/sharded_timeseries_collmod_mixed_version.js b/jstests/multiVersion/sharded_timeseries_collmod_mixed_version.js new file mode 100644 index 00000000000..12c0f4bf6ef --- /dev/null +++ b/jstests/multiVersion/sharded_timeseries_collmod_mixed_version.js @@ -0,0 +1,50 @@ +/** + * Tests latest shards can process collMod on time-series collection sent from old 5.0 mongos. + */ + +(function() { +"use strict"; + +const dbName = 'testDB'; +const collName = 'testColl'; +const timeField = 'tm'; +const metaField = 'mt'; +const indexName = 'index'; +const viewNss = `${dbName}.${collName}`; + +const st = new ShardingTest( + {shards: 2, rs: {nodes: 3}, mongos: [{binVersion: 'latest'}, {binVersion: '5.0'}]}); +const mongos = st.s0; +const db = mongos.getDB(dbName); + +assert.commandWorked( + mongos.adminCommand({setFeatureCompatibilityVersion: binVersionToFCV('latest')})); + +assert.commandWorked( + db.createCollection(collName, {timeseries: {timeField: timeField, metaField: metaField}})); +assert.commandWorked(mongos.adminCommand({enableSharding: dbName})); +assert.commandWorked(db[collName].createIndex({[metaField]: 1}, {name: indexName})); +assert.commandWorked(mongos.adminCommand({ + shardCollection: viewNss, + key: {[metaField]: 1}, +})); + +assert.commandWorked(mongos.adminCommand({setFeatureCompatibilityVersion: '5.0'})); + +const oldDb = st.s1.getDB(dbName); +// Assert that collMod works with matching versions of mongos and mongod. +assert.commandWorked(db.runCommand({collMod: collName, index: {name: indexName, hidden: true}})); +// Assert that collMod still works with old version of mongos. +assert.commandWorked( + oldDb.runCommand({collMod: collName, index: {name: indexName, hidden: false}})); + +// Assert that collMod with granularity update fails with matching versions of mongos and mongod. +assert.commandFailedWithCode(db.runCommand({collMod: collName, timeseries: {granularity: 'hours'}}), + ErrorCodes.NotImplemented); +// Assert that collMod with granularity update still fails with old version of mongos. +assert.commandFailedWithCode( + oldDb.runCommand({collMod: collName, timeseries: {granularity: 'hours'}}), + ErrorCodes.NotImplemented); + +st.stop(); +})(); |