diff options
-rw-r--r-- | src/mongo/dbtests/mmaptests.cpp | 55 | ||||
-rw-r--r-- | src/mongo/dbtests/pdfiletests.cpp | 50 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_collscan.cpp | 4 |
3 files changed, 54 insertions, 55 deletions
diff --git a/src/mongo/dbtests/mmaptests.cpp b/src/mongo/dbtests/mmaptests.cpp index 88c97841e76..7f3b7fac1a1 100644 --- a/src/mongo/dbtests/mmaptests.cpp +++ b/src/mongo/dbtests/mmaptests.cpp @@ -33,9 +33,13 @@ #include <boost/filesystem/operations.hpp> #include "mongo/db/concurrency/lock_state.h" +#include "mongo/db/storage/mmap_v1/data_file.h" #include "mongo/db/storage/mmap_v1/durable_mapped_file.h" -#include "mongo/util/timer.h" +#include "mongo/db/storage/mmap_v1/extent.h" +#include "mongo/db/storage/mmap_v1/extent_manager.h" +#include "mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h" #include "mongo/dbtests/dbtests.h" +#include "mongo/util/timer.h" namespace MMapTests { @@ -120,11 +124,60 @@ namespace MMapTests { } }; + class ExtentSizing { + public: + void run() { + MmapV1ExtentManager em( "x", "x", false ); + + ASSERT_EQUALS( em.maxSize(), em.quantizeExtentSize( em.maxSize() ) ); + + // test that no matter what we start with, we always get to max extent size + for ( int obj=16; obj<BSONObjMaxUserSize; obj += 111 ) { + + int sz = em.initialSize( obj ); + + double totalExtentSize = sz; + + int numFiles = 1; + int sizeLeftInExtent = em.maxSize() - 1; + + for ( int i=0; i<100; i++ ) { + sz = em.followupSize( obj , sz ); + ASSERT( sz >= obj ); + ASSERT( sz >= em.minSize() ); + ASSERT( sz <= em.maxSize() ); + ASSERT( sz <= em.maxSize() ); + + totalExtentSize += sz; + + if ( sz < sizeLeftInExtent ) { + sizeLeftInExtent -= sz; + } + else { + numFiles++; + sizeLeftInExtent = em.maxSize() - sz; + } + } + ASSERT_EQUALS( em.maxSize(), sz ); + + double allocatedOnDisk = (double)numFiles * em.maxSize(); + + ASSERT( ( totalExtentSize / allocatedOnDisk ) > .95 ); + + invariant( em.numFiles() == 0 ); + } + } + }; + class All : public Suite { public: All() : Suite( "mmap" ) {} void setupTests() { + if (storageGlobalParams.engine != "mmapv1") + return; + add< LeakTest >(); + add< ExtentSizing >(); } } myall; diff --git a/src/mongo/dbtests/pdfiletests.cpp b/src/mongo/dbtests/pdfiletests.cpp index 5f154456423..9d0cb433be4 100644 --- a/src/mongo/dbtests/pdfiletests.cpp +++ b/src/mongo/dbtests/pdfiletests.cpp @@ -35,10 +35,6 @@ #include "mongo/db/json.h" #include "mongo/db/ops/insert.h" #include "mongo/db/catalog/collection.h" -#include "mongo/db/storage/mmap_v1/data_file.h" -#include "mongo/db/storage/mmap_v1/extent.h" -#include "mongo/db/storage/mmap_v1/extent_manager.h" -#include "mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h" #include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" @@ -154,51 +150,6 @@ namespace PdfileTests { }; } // namespace Insert - class ExtentSizing { - public: - void run() { - MmapV1ExtentManager em( "x", "x", false ); - - ASSERT_EQUALS( em.maxSize(), em.quantizeExtentSize( em.maxSize() ) ); - - // test that no matter what we start with, we always get to max extent size - for ( int obj=16; obj<BSONObjMaxUserSize; obj += 111 ) { - - int sz = em.initialSize( obj ); - - double totalExtentSize = sz; - - int numFiles = 1; - int sizeLeftInExtent = em.maxSize() - 1; - - for ( int i=0; i<100; i++ ) { - sz = em.followupSize( obj , sz ); - ASSERT( sz >= obj ); - ASSERT( sz >= em.minSize() ); - ASSERT( sz <= em.maxSize() ); - ASSERT( sz <= em.maxSize() ); - - totalExtentSize += sz; - - if ( sz < sizeLeftInExtent ) { - sizeLeftInExtent -= sz; - } - else { - numFiles++; - sizeLeftInExtent = em.maxSize() - sz; - } - } - ASSERT_EQUALS( em.maxSize(), sz ); - - double allocatedOnDisk = (double)numFiles * em.maxSize(); - - ASSERT( ( totalExtentSize / allocatedOnDisk ) > .95 ); - - invariant( em.numFiles() == 0 ); - } - } - }; - class All : public Suite { public: All() : Suite( "pdfile" ) {} @@ -208,7 +159,6 @@ namespace PdfileTests { add< Insert::UpdateDate >(); add< Insert::UpdateDate2 >(); add< Insert::ValidId >(); - add< ExtentSizing >(); } } myall; diff --git a/src/mongo/dbtests/query_stage_collscan.cpp b/src/mongo/dbtests/query_stage_collscan.cpp index e403bf3d35b..519b83f3d1a 100644 --- a/src/mongo/dbtests/query_stage_collscan.cpp +++ b/src/mongo/dbtests/query_stage_collscan.cpp @@ -40,10 +40,6 @@ #include "mongo/db/matcher/expression_parser.h" #include "mongo/db/query/plan_executor.h" #include "mongo/db/operation_context_impl.h" -#include "mongo/db/storage/mmap_v1/extent.h" -#include "mongo/db/storage/mmap_v1/extent_manager.h" -#include "mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h" -// #include "mongo/db/structure/catalog/namespace_details.h" // XXX SERVER-13640 #include "mongo/db/storage/record_store.h" #include "mongo/dbtests/dbtests.h" #include "mongo/util/fail_point_service.h" |