summaryrefslogtreecommitdiff
path: root/jstests/disk
diff options
context:
space:
mode:
authorGregory Noma <gregory.noma@gmail.com>2023-01-13 16:24:46 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-01-13 18:40:12 +0000
commitd70f7f0de2a21cce242dc53e2848157d50eb8ff4 (patch)
tree6f194681a3ac776bdf918d462dd7b0be47ddd9b6 /jstests/disk
parent37ee8149d1ceae0c1dc462d5861825e6823e641d (diff)
downloadmongo-d70f7f0de2a21cce242dc53e2848157d50eb8ff4.tar.gz
SERVER-68981 Validate WT table logging settings
Diffstat (limited to 'jstests/disk')
-rw-r--r--jstests/disk/wt_table_checks.js2
-rw-r--r--jstests/disk/wt_validate_table_logging.js88
2 files changed, 89 insertions, 1 deletions
diff --git a/jstests/disk/wt_table_checks.js b/jstests/disk/wt_table_checks.js
index 8a74d53b1c9..17eea4b8ebb 100644
--- a/jstests/disk/wt_table_checks.js
+++ b/jstests/disk/wt_table_checks.js
@@ -91,7 +91,7 @@ checkLog.containsJson(conn, 5548302);
// Changing table logging settings.
assert(checkLog.checkContainsWithCountJson(conn, 22432, undefined, 0));
checkTableLogSettings(conn, /*enabled=*/false);
-MongoRunner.stopMongod(conn);
+MongoRunner.stopMongod(conn, null, {skipValidation: true});
/**
* Test 3. Change into a single node replica set again. Table log settings are checked but none are
diff --git a/jstests/disk/wt_validate_table_logging.js b/jstests/disk/wt_validate_table_logging.js
new file mode 100644
index 00000000000..1dcebc31144
--- /dev/null
+++ b/jstests/disk/wt_validate_table_logging.js
@@ -0,0 +1,88 @@
+/**
+ * Tests that the validate command detects incorrect WT table logging settings.
+ *
+ * @tags: [
+ * requires_wiredtiger,
+ * ]
+ */
+(function() {
+'use strict';
+
+let conn = MongoRunner.runMongod();
+
+const dbpath = conn.dbpath;
+const dbName = jsTestName();
+const collName = 'coll';
+
+const create = function(conn) {
+ assert.commandWorked(conn.getDB(dbName).createCollection(collName));
+ assert.commandWorked(conn.getDB(dbName)[collName].createIndex({'$**': "columnstore"}));
+};
+
+const collUri = function(conn) {
+ return conn.getDB(dbName)[collName]
+ .aggregate([{$collStats: {storageStats: {}}}])
+ .toArray()[0]
+ .storageStats.wiredTiger.uri.split('statistics:')[1];
+};
+
+const indexUri = function(conn, indexName) {
+ return conn.getDB(dbName)[collName]
+ .aggregate([{$collStats: {storageStats: {}}}])
+ .toArray()[0]
+ .storageStats.indexDetails[indexName]
+ .uri.split('statistics:')[1];
+};
+
+// Create the collection and indexes as a standlone, which will cause the tables to be logged.
+create(conn);
+MongoRunner.stopMongod(conn);
+
+const nodeOptions = {
+ dbpath: dbpath,
+ noCleanData: true,
+ // Skip the normal step of switching the logging setting on the tables.
+ setParameter: {wiredTigerSkipTableLoggingChecksOnStartup: true},
+};
+const replTest = new ReplSetTest({
+ nodes: 1,
+ nodeOptions: nodeOptions,
+});
+replTest.startSet();
+replTest.initiate();
+const primary = replTest.getPrimary();
+
+// Run validate as a replica set, which will expect the tables to not be logged.
+let res = assert.commandWorked(primary.getDB(dbName).runCommand({validate: collName}));
+assert(!res.valid);
+// TODO (SERVER-72677): The validate results should report three errors.
+assert.eq(res.errors.length, 1);
+checkLog.containsJson(primary, 6898101, {uri: collUri(primary), expected: false});
+checkLog.containsJson(
+ primary, 6898101, {index: '_id_', uri: indexUri(primary, '_id_'), expected: false});
+checkLog.containsJson(
+ primary,
+ 6898101,
+ {index: '$**_columnstore', uri: indexUri(primary, '$**_columnstore'), expected: false});
+
+// Create the collection and indexes as a replica set, which will cause the tables to not be logged.
+assert.commandWorked(primary.getDB(dbName).runCommand({drop: collName}));
+create(primary);
+
+replTest.stopSet(null, false, {noCleanData: true, skipValidation: true});
+conn = MongoRunner.runMongod(nodeOptions);
+
+// Run validate as a standalone, which will expect the tables to be logged.
+res = assert.commandWorked(conn.getDB(dbName).runCommand({validate: collName}));
+assert(!res.valid);
+// TODO (SERVER-72677): The validate results should report three errors.
+assert.eq(res.errors.length, 1);
+checkLog.containsJson(conn, 6898101, {uri: collUri(conn), expected: true});
+checkLog.containsJson(conn, 6898101, {index: '_id_', uri: indexUri(conn, '_id_'), expected: true});
+checkLog.containsJson(
+ conn,
+ 6898101,
+ {index: '$**_columnstore', uri: indexUri(conn, '$**_columnstore'), expected: true});
+
+MongoRunner.stopMongod(conn, null, {skipValidation: true});
+}());