diff options
Diffstat (limited to 'src/mongo/db/storage/record_store_test_validate.cpp')
-rw-r--r-- | src/mongo/db/storage/record_store_test_validate.cpp | 352 |
1 files changed, 176 insertions, 176 deletions
diff --git a/src/mongo/db/storage/record_store_test_validate.cpp b/src/mongo/db/storage/record_store_test_validate.cpp index 89453520073..71790a376a3 100644 --- a/src/mongo/db/storage/record_store_test_validate.cpp +++ b/src/mongo/db/storage/record_store_test_validate.cpp @@ -41,211 +41,211 @@ using std::string; namespace mongo { namespace { - // Verify that calling validate() on an empty collection returns an OK status. - // When either of `full` or `scanData` are false, the ValidateAdaptor - // should not be used. - TEST( RecordStoreTestHarness, ValidateEmpty ) { - unique_ptr<HarnessHelper> harnessHelper( newHarnessHelper() ); - unique_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() ); - - { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) ); - } - - { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - ValidateAdaptorSpy adaptor; - ValidateResults results; - BSONObjBuilder stats; - ASSERT_OK( rs->validate( opCtx.get(), - false, // full validate - false, // scan data - &adaptor, - &results, - &stats ) ); - ASSERT( results.valid ); - ASSERT( results.errors.empty() ); - } - } +// Verify that calling validate() on an empty collection returns an OK status. +// When either of `full` or `scanData` are false, the ValidateAdaptor +// should not be used. +TEST(RecordStoreTestHarness, ValidateEmpty) { + unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); + + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); } - // Verify that calling validate() on an empty collection returns an OK status. - // When either of `full` or `scanData` are false, the ValidateAdaptor - // should not be used. - TEST( RecordStoreTestHarness, ValidateEmptyAndScanData ) { - unique_ptr<HarnessHelper> harnessHelper( newHarnessHelper() ); - unique_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() ); - - { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) ); - } - + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - ValidateAdaptorSpy adaptor; - ValidateResults results; - BSONObjBuilder stats; - ASSERT_OK( rs->validate( opCtx.get(), - false, // full validate - true, // scan data - &adaptor, - &results, - &stats ) ); - ASSERT( results.valid ); - ASSERT( results.errors.empty() ); - } + ValidateAdaptorSpy adaptor; + ValidateResults results; + BSONObjBuilder stats; + ASSERT_OK(rs->validate(opCtx.get(), + false, // full validate + false, // scan data + &adaptor, + &results, + &stats)); + ASSERT(results.valid); + ASSERT(results.errors.empty()); } } +} + +// Verify that calling validate() on an empty collection returns an OK status. +// When either of `full` or `scanData` are false, the ValidateAdaptor +// should not be used. +TEST(RecordStoreTestHarness, ValidateEmptyAndScanData) { + unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); + + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); + } - // Verify that calling validate() on an empty collection returns an OK status. - // When either of `full` or `scanData` are false, the ValidateAdaptor - // should not be used. - TEST( RecordStoreTestHarness, FullValidateEmpty ) { - unique_ptr<HarnessHelper> harnessHelper( newHarnessHelper() ); - unique_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() ); - + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) ); + ValidateAdaptorSpy adaptor; + ValidateResults results; + BSONObjBuilder stats; + ASSERT_OK(rs->validate(opCtx.get(), + false, // full validate + true, // scan data + &adaptor, + &results, + &stats)); + ASSERT(results.valid); + ASSERT(results.errors.empty()); } + } +} + +// Verify that calling validate() on an empty collection returns an OK status. +// When either of `full` or `scanData` are false, the ValidateAdaptor +// should not be used. +TEST(RecordStoreTestHarness, FullValidateEmpty) { + unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); + + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); + } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - ValidateAdaptorSpy adaptor; - ValidateResults results; - BSONObjBuilder stats; - ASSERT_OK( rs->validate( opCtx.get(), - true, // full validate - false, // scan data - &adaptor, - &results, - &stats ) ); - ASSERT( results.valid ); - ASSERT( results.errors.empty() ); - } + ValidateAdaptorSpy adaptor; + ValidateResults results; + BSONObjBuilder stats; + ASSERT_OK(rs->validate(opCtx.get(), + true, // full validate + false, // scan data + &adaptor, + &results, + &stats)); + ASSERT(results.valid); + ASSERT(results.errors.empty()); } } +} - // Verify that calling validate() on an empty collection returns an OK status. - TEST( RecordStoreTestHarness, FullValidateEmptyAndScanData ) { - unique_ptr<HarnessHelper> harnessHelper( newHarnessHelper() ); - unique_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() ); +// Verify that calling validate() on an empty collection returns an OK status. +TEST(RecordStoreTestHarness, FullValidateEmptyAndScanData) { + unique_ptr<HarnessHelper> harnessHelper(newHarnessHelper()); + unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore()); - { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) ); - } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); + ASSERT_EQUALS(0, rs->numRecords(opCtx.get())); + } + { + unique_ptr<OperationContext> opCtx(harnessHelper->newOperationContext()); { - unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); - { - ValidateAdaptorSpy adaptor; - ValidateResults results; - BSONObjBuilder stats; - ASSERT_OK( rs->validate( opCtx.get(), - true, // full validate - true, // scan data - &adaptor, - &results, - &stats ) ); - ASSERT( results.valid ); - ASSERT( results.errors.empty() ); - } + ValidateAdaptorSpy adaptor; + ValidateResults results; + BSONObjBuilder stats; + ASSERT_OK(rs->validate(opCtx.get(), + true, // full validate + true, // scan data + &adaptor, + &results, + &stats)); + ASSERT(results.valid); + ASSERT(results.errors.empty()); } } - - // Insert multiple records, and verify that calling validate() on a nonempty collection - // returns an OK status. When either of `full` or `scanData` are false, the ValidateAdaptor - // should not be used. - TEST_F( ValidateTest, ValidateNonEmpty ) { +} + +// Insert multiple records, and verify that calling validate() on a nonempty collection +// returns an OK status. When either of `full` or `scanData` are false, the ValidateAdaptor +// should not be used. +TEST_F(ValidateTest, ValidateNonEmpty) { + { + unique_ptr<OperationContext> opCtx(newOperationContext()); { - unique_ptr<OperationContext> opCtx( newOperationContext() ); - { - ValidateAdaptorSpy adaptor; - ValidateResults results; - BSONObjBuilder stats; - ASSERT_OK( getRecordStore().validate( opCtx.get(), - false, // full validate - false, // scan data - &adaptor, - &results, - &stats ) ); - ASSERT( results.valid ); - ASSERT( results.errors.empty() ); - } + ValidateAdaptorSpy adaptor; + ValidateResults results; + BSONObjBuilder stats; + ASSERT_OK(getRecordStore().validate(opCtx.get(), + false, // full validate + false, // scan data + &adaptor, + &results, + &stats)); + ASSERT(results.valid); + ASSERT(results.errors.empty()); } } - - // Insert multiple records, and verify that calling validate() on a nonempty collection - // returns an OK status. When either of `full` or `scanData` are false, the ValidateAdaptor - // should not be used. - TEST_F( ValidateTest, ValidateAndScanDataNonEmpty ) { +} + +// Insert multiple records, and verify that calling validate() on a nonempty collection +// returns an OK status. When either of `full` or `scanData` are false, the ValidateAdaptor +// should not be used. +TEST_F(ValidateTest, ValidateAndScanDataNonEmpty) { + { + unique_ptr<OperationContext> opCtx(newOperationContext()); { - unique_ptr<OperationContext> opCtx( newOperationContext() ); - { - ValidateAdaptorSpy adaptor; - ValidateResults results; - BSONObjBuilder stats; - ASSERT_OK( getRecordStore().validate( opCtx.get(), - false, // full validate - true, // scan data - &adaptor, - &results, - &stats ) ); - ASSERT( results.valid ); - ASSERT( results.errors.empty() ); - } + ValidateAdaptorSpy adaptor; + ValidateResults results; + BSONObjBuilder stats; + ASSERT_OK(getRecordStore().validate(opCtx.get(), + false, // full validate + true, // scan data + &adaptor, + &results, + &stats)); + ASSERT(results.valid); + ASSERT(results.errors.empty()); } } - - // Insert multiple records, and verify that calling validate() on a nonempty collection - // returns an OK status. When either of `full` or `scanData` are false, the ValidateAdaptor - // should not be used. - TEST_F( ValidateTest, FullValidateNonEmpty ) { +} + +// Insert multiple records, and verify that calling validate() on a nonempty collection +// returns an OK status. When either of `full` or `scanData` are false, the ValidateAdaptor +// should not be used. +TEST_F(ValidateTest, FullValidateNonEmpty) { + { + unique_ptr<OperationContext> opCtx(newOperationContext()); { - unique_ptr<OperationContext> opCtx( newOperationContext() ); - { - ValidateAdaptorSpy adaptor; - ValidateResults results; - BSONObjBuilder stats; - ASSERT_OK( getRecordStore().validate( opCtx.get(), - true, // full validate - false, // scan data - &adaptor, - &results, - &stats ) ); - ASSERT( results.valid ); - ASSERT( results.errors.empty() ); - } + ValidateAdaptorSpy adaptor; + ValidateResults results; + BSONObjBuilder stats; + ASSERT_OK(getRecordStore().validate(opCtx.get(), + true, // full validate + false, // scan data + &adaptor, + &results, + &stats)); + ASSERT(results.valid); + ASSERT(results.errors.empty()); } } +} - // Insert multiple records, and verify that calling validate() on a nonempty collection - // returns an OK status. - TEST_F( ValidateTest, FullValidateNonEmptyAndScanData ) { +// Insert multiple records, and verify that calling validate() on a nonempty collection +// returns an OK status. +TEST_F(ValidateTest, FullValidateNonEmptyAndScanData) { + { + unique_ptr<OperationContext> opCtx(newOperationContext()); { - unique_ptr<OperationContext> opCtx( newOperationContext() ); - { - ValidateAdaptorSpy adaptor( getInsertedRecords() ); - ValidateResults results; - BSONObjBuilder stats; - ASSERT_OK( getRecordStore().validate( opCtx.get(), - true, // full validate - true, // scan data - &adaptor, - &results, - &stats ) ); - ASSERT( adaptor.allValidated() ); - ASSERT( results.valid ); - ASSERT( results.errors.empty() ); - } + ValidateAdaptorSpy adaptor(getInsertedRecords()); + ValidateResults results; + BSONObjBuilder stats; + ASSERT_OK(getRecordStore().validate(opCtx.get(), + true, // full validate + true, // scan data + &adaptor, + &results, + &stats)); + ASSERT(adaptor.allValidated()); + ASSERT(results.valid); + ASSERT(results.errors.empty()); } } +} -} // namespace -} // namespace mongo +} // namespace +} // namespace mongo |