Skip to content

Commit 75e45cb

Browse files
committed
SERVER-34667 Run validate command against config.collections.
Changes the data_consistency_checks.js test to shard a collection to ensure the config.collections collection exists.
1 parent d62890f commit 75e45cb

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

jstests/noPassthrough/data_consistency_checks.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,24 @@ var db;
124124
configOptions: {
125125
setParameter: {logComponentVerbosity: tojson({command: 1})},
126126
},
127-
shards: 0
127+
shards: 1
128128
});
129129

130+
// We shard a collection in order to guarantee that at least one collection on the "config"
131+
// database exists for when we go to run the data consistency checks against the CSRS.
132+
st.shardColl(st.s.getDB("test").mycoll, {_id: 1}, false);
133+
130134
const output = runDataConsistencyChecks({conn: st.s, teardown: () => st.stop()});
131135

132136
let pattern = makePatternForDBHash("config");
133137
assert.eq(0,
134138
countMatches(pattern, output),
135139
"expected not to find " + tojson(pattern) + " in the log output for 1-node CSRS");
136140

137-
pattern = makePatternForValidate("config", "mongos");
141+
// The choice of using the "config.collections" collection here is mostly arbitrary as the
142+
// "config.databases" and "config.chunks" collections are also implicitly created as part of
143+
// sharding a collection.
144+
pattern = makePatternForValidate("config", "collections");
138145
assert.eq(1,
139146
countMatches(pattern, output),
140147
"expected to find " + tojson(pattern) + " in the log output for 1-node CSRS");
@@ -154,9 +161,13 @@ var db;
154161
}
155162
});
156163

164+
// We shard a collection in order to guarantee that at least one collection on the "config"
165+
// database exists for when we go to run the data consistency checks against the CSRS.
166+
st.shardColl(st.s.getDB("test").mycoll, {_id: 1}, false);
167+
157168
// Insert a document so the "dbhash" and "validate" commands have some actual work to do on
158169
// the replica set shard.
159-
assert.commandWorked(st.s.getDB("test").mycoll.insert({}));
170+
assert.commandWorked(st.s.getDB("test").mycoll.insert({_id: 0}));
160171
const output = runDataConsistencyChecks({conn: st.s, teardown: () => st.stop()});
161172

162173
// The "config" database exists on both the CSRS and the replica set shards due to the
@@ -167,7 +178,10 @@ var db;
167178
"expected to find " + tojson(pattern) +
168179
" from each CSRS node and each replica set shard node in the log output");
169180

170-
pattern = makePatternForValidate("config", "mongos");
181+
// The choice of using the "config.collections" collection here is mostly arbitrary as the
182+
// "config.databases" and "config.chunks" collections are also implicitly created as part of
183+
// sharding a collection.
184+
pattern = makePatternForValidate("config", "collections");
171185
assert.eq(3,
172186
countMatches(pattern, output),
173187
"expected to find " + tojson(pattern) + " from each CSRS node in the log output");

0 commit comments

Comments
 (0)