@@ -124,17 +124,24 @@ var db;
124
124
configOptions : {
125
125
setParameter : { logComponentVerbosity : tojson ( { command : 1 } ) } ,
126
126
} ,
127
- shards : 0
127
+ shards : 1
128
128
} ) ;
129
129
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
+
130
134
const output = runDataConsistencyChecks ( { conn : st . s , teardown : ( ) => st . stop ( ) } ) ;
131
135
132
136
let pattern = makePatternForDBHash ( "config" ) ;
133
137
assert . eq ( 0 ,
134
138
countMatches ( pattern , output ) ,
135
139
"expected not to find " + tojson ( pattern ) + " in the log output for 1-node CSRS" ) ;
136
140
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" ) ;
138
145
assert . eq ( 1 ,
139
146
countMatches ( pattern , output ) ,
140
147
"expected to find " + tojson ( pattern ) + " in the log output for 1-node CSRS" ) ;
@@ -154,9 +161,13 @@ var db;
154
161
}
155
162
} ) ;
156
163
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
+
157
168
// Insert a document so the "dbhash" and "validate" commands have some actual work to do on
158
169
// the replica set shard.
159
- assert . commandWorked ( st . s . getDB ( "test" ) . mycoll . insert ( { } ) ) ;
170
+ assert . commandWorked ( st . s . getDB ( "test" ) . mycoll . insert ( { _id : 0 } ) ) ;
160
171
const output = runDataConsistencyChecks ( { conn : st . s , teardown : ( ) => st . stop ( ) } ) ;
161
172
162
173
// The "config" database exists on both the CSRS and the replica set shards due to the
@@ -167,7 +178,10 @@ var db;
167
178
"expected to find " + tojson ( pattern ) +
168
179
" from each CSRS node and each replica set shard node in the log output" ) ;
169
180
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" ) ;
171
185
assert . eq ( 3 ,
172
186
countMatches ( pattern , output ) ,
173
187
"expected to find " + tojson ( pattern ) + " from each CSRS node in the log output" ) ;
0 commit comments