diff options
author | Rishab Joshi <rishab.joshi@mongodb.com> | 2022-06-10 19:03:45 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-06-10 19:48:46 +0000 |
commit | 09bb1491952e6e756746640fbfdfaddead59c61b (patch) | |
tree | cec59ed6242e97b56e5938cb9492262cec3e2d4d /jstests | |
parent | ea3e7127282a3d2974c39d7f0045ffa29d1dc426 (diff) | |
download | mongo-09bb1491952e6e756746640fbfdfaddead59c61b.tar.gz |
SERVER-66633 Record change collection entries in the secondaries.
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/replsets/write_change_stream_change_collection.js | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/jstests/replsets/write_change_stream_change_collection.js b/jstests/replsets/write_change_stream_change_collection.js index 32fce968ecc..d4e1a75d04b 100644 --- a/jstests/replsets/write_change_stream_change_collection.js +++ b/jstests/replsets/write_change_stream_change_collection.js @@ -8,18 +8,20 @@ (function() { "use strict"; -const replSetTest = new ReplSetTest({nodes: 1}); +const replSetTest = new ReplSetTest({nodes: 2}); replSetTest.startSet({setParameter: "multitenancySupport=true"}); replSetTest.initiate(); const primary = replSetTest.getPrimary(); -const oplogColl = primary.getDB("local").oplog.rs; -const changeColl = primary.getDB("config").system.change_collection; +const secondary = replSetTest.getSecondary(); const testDb = primary.getDB("test"); // Verifies that the oplog and change collection entries are the same for the specified start and // end duration of the oplog timestamp. -function verifyChangeCollectionEntries(startOplogTimestamp, endOplogTimestamp) { +function verifyChangeCollectionEntries(connection, startOplogTimestamp, endOplogTimestamp) { + const oplogColl = connection.getDB("local").oplog.rs; + const changeColl = connection.getDB("config").system.change_collection; + // Fetch all oplog and change collection entries for the duration: [startOplogTimestamp, // endOplogTimestamp]. const oplogEntries = @@ -69,6 +71,7 @@ function performWrites(coll) { // Test the change collection entries with the oplog by performing some basic writes. (function testBasicWritesInChangeCollection() { + const oplogColl = primary.getDB("local").oplog.rs; const startOplogTimestamp = oplogColl.find().toArray().at(-1).ts; assert(startOplogTimestamp != undefined); @@ -79,11 +82,18 @@ function performWrites(coll) { assert(endOplogTimestamp !== undefined); assert(timestampCmp(endOplogTimestamp, startOplogTimestamp) > 0); - verifyChangeCollectionEntries(startOplogTimestamp, endOplogTimestamp); + // Wait for the replication to finish. + replSetTest.awaitReplication(); + + // Verify that the change collection entries are the same as the oplog in the primary and the + // secondary node. + verifyChangeCollectionEntries(primary, startOplogTimestamp, endOplogTimestamp); + verifyChangeCollectionEntries(secondary, startOplogTimestamp, endOplogTimestamp); })(); // Test the change collection entries with the oplog by performing writes in a transaction. (function testWritesinChangeCollectionWithTrasactions() { + const oplogColl = primary.getDB("local").oplog.rs; const startOplogTimestamp = oplogColl.find().toArray().at(-1).ts; assert(startOplogTimestamp != undefined); @@ -97,7 +107,13 @@ function performWrites(coll) { assert(endOplogTimestamp != undefined); assert(timestampCmp(endOplogTimestamp, startOplogTimestamp) > 0); - verifyChangeCollectionEntries(startOplogTimestamp, endOplogTimestamp); + // Wait for the replication to finish. + replSetTest.awaitReplication(); + + // Verify that the change collection entries are the same as the oplog in the primary and the + // secondary node for the applyOps. + verifyChangeCollectionEntries(primary, startOplogTimestamp, endOplogTimestamp); + verifyChangeCollectionEntries(secondary, startOplogTimestamp, endOplogTimestamp); })(); replSetTest.stopSet(); |