diff options
author | Maria van Keulen <maria.vankeulen@mongodb.com> | 2019-10-02 15:45:50 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-10-02 15:45:50 +0000 |
commit | 294a8f68615710b47936d5ee42439d01538ac746 (patch) | |
tree | f0fe9a80ccce3a760ad2938a658896dfe8b44590 /jstests/replsets/oplog_sampling.js | |
parent | a1db5c954668c888f0c47313dc142b3259012647 (diff) | |
download | mongo-294a8f68615710b47936d5ee42439d01538ac746.tar.gz |
SERVER-43322 Add tunable oplog stone sizes and track truncation speeds
Diffstat (limited to 'jstests/replsets/oplog_sampling.js')
-rw-r--r-- | jstests/replsets/oplog_sampling.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/jstests/replsets/oplog_sampling.js b/jstests/replsets/oplog_sampling.js new file mode 100644 index 00000000000..a87f17e72a3 --- /dev/null +++ b/jstests/replsets/oplog_sampling.js @@ -0,0 +1,41 @@ +/** + * Ensure serverStatus reports the total time spent sampling the oplog for all storage engines that + * support OplogStones. + * @tags: [ requires_wiredtiger ] + */ +(function() { +"use strict"; + +// Force oplog sampling to occur on start up for small numbers of oplog inserts. +const replSet = new ReplSetTest( + {nodes: 1, nodeOptions: {setParameter: {"maxOplogTruncationPointsDuringStartup": 10}}}); +replSet.startSet(); +replSet.initiate(); + +let coll = replSet.getPrimary().getDB("test").getCollection("testcoll"); + +let res = replSet.getPrimary().getDB("test").serverStatus(); +assert.commandWorked(res); + +// Small (or empty) oplogs should be processed by scanning. +assert.gt(res.oplogTruncation.totalTimeProcessingMicros, 0); +assert.eq(res.oplogTruncation.processingMethod, "scanning"); + +// Insert enough documents to force oplog sampling to occur on the following start up. +const maxOplogDocsForScanning = 2000; +for (let i = 0; i < maxOplogDocsForScanning + 1; i++) { + assert.commandWorked(coll.insert({m: 1 + i})); +} + +// Restart replica set to load entries from the oplog for sampling. +replSet.stopSet(null /* signal */, true /* forRestart */); +replSet.startSet({restart: true}); + +res = replSet.getPrimary().getDB("test").serverStatus(); +assert.commandWorked(res); + +assert.gt(res.oplogTruncation.totalTimeProcessingMicros, 0); +assert.eq(res.oplogTruncation.processingMethod, "sampling"); + +replSet.stopSet(); +})(); |