summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-07-01 12:52:02 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-07-11 15:42:11 -0400
commitc9c340ad6e9e1f33cb001a8375c62d6b16138c74 (patch)
tree5b4958fba84fc6a153ae0faadd88688d737eeb1b /src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp
parentbccb252836954ac1963f8daf0d7bbdcf7af1d01c (diff)
downloadmongo-c9c340ad6e9e1f33cb001a8375c62d6b16138c74.tar.gz
SERVER-36054 Remove ScopedCollectionMetadata's operator bool
Diffstat (limited to 'src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp')
-rw-r--r--src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp
index e92f24d0468..911792e33bc 100644
--- a/src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp
+++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp
@@ -117,16 +117,24 @@ protected:
}
/**
+ * Inserts the specified docs in 'kNss' and ensures the insert succeeded.
+ */
+ void insertDocsInShardedCollection(const std::vector<BSONObj>& docs) {
+ if (docs.empty())
+ return;
+
+ client()->insert(kNss.ns(), docs);
+ ASSERT_EQ("", client()->getLastError());
+ }
+
+ /**
* Creates a collection, which contains an index corresponding to kShardKeyPattern and insers
* the specified initial documents.
*/
- void createShardedCollection(std::vector<BSONObj> initialDocs) {
+ void createShardedCollection(const std::vector<BSONObj>& initialDocs) {
ASSERT(_client->createCollection(kNss.ns()));
_client->createIndex(kNss.ns(), kShardKeyPattern);
-
- if (!initialDocs.empty()) {
- _client->insert(kNss.ns(), initialDocs);
- }
+ insertDocsInShardedCollection(initialDocs);
}
/**
@@ -232,13 +240,13 @@ TEST_F(MigrationChunkClonerSourceLegacyTest, CorrectDocumentsFetched) {
}
// Insert some documents in the chunk range to be included for migration
- client()->insert(kNss.ns(), createCollectionDocument(150));
- client()->insert(kNss.ns(), createCollectionDocument(151));
+ insertDocsInShardedCollection({createCollectionDocument(150)});
+ insertDocsInShardedCollection({createCollectionDocument(151)});
// Insert some documents which are outside of the chunk range and should not be included for
// migration
- client()->insert(kNss.ns(), createCollectionDocument(90));
- client()->insert(kNss.ns(), createCollectionDocument(210));
+ insertDocsInShardedCollection({createCollectionDocument(90)});
+ insertDocsInShardedCollection({createCollectionDocument(210)});
// Normally the insert above and the onInsert/onDelete callbacks below will happen under the
// same lock and write unit of work