예제 #1
0
            void run() {
                DurTransaction txn;
                create();
                ASSERT_EQUALS( 2, nExtents() );

                DiskLoc l[ 8 ];
                for ( int i = 0; i < 8; ++i ) {
                    StatusWith<DiskLoc> status = collection()->insertDocument( &txn, bigObj(), true );
                    ASSERT( status.isOK() );
                    l[ i ] = status.getValue();
                    ASSERT( !l[ i ].isNull() );
                    //ASSERT_EQUALS( i < 2 ? i + 1 : 3 + i % 2, nRecords() );
                    //if ( i > 3 )
                    //    ASSERT( l[ i ] == l[ i - 4 ] );
                }
                ASSERT( nRecords() == 8 );

                // Too big
                BSONObjBuilder bob;
                bob.appendOID( "_id", NULL, true );
                bob.append( "a", string( MinExtentSize + 500, 'a' ) ); // min extent size is now 4096
                BSONObj bigger = bob.done();
                StatusWith<DiskLoc> status = collection()->insertDocument( &txn, bigger, false );
                ASSERT( !status.isOK() );
                ASSERT_EQUALS( 0, nRecords() );
            }
예제 #2
0
 void run() {
     DurTransaction txn;
     create();
     BSONObj b = bigObj();
     ASSERT( collection()->insertDocument( &txn, b, true ).isOK() );
     ASSERT_EQUALS( 1, nRecords() );
 }
예제 #3
0
 void run() {
     OperationContextImpl txn;
     create();
     BSONObj b = bigObj();
     ASSERT( collection()->insertDocument( &txn, b, true ).isOK() );
     ASSERT_EQUALS( 1, nRecords() );
 }
예제 #4
0
 void run() {
     create();
     ASSERT( nsd() );
     ASSERT_EQUALS( 0, nRecords() );
     ASSERT( nsd()->firstExtent == nsd()->capExtent );
     DiskLoc initial = DiskLoc();
     initial.setInvalid();
     ASSERT( initial == nsd()->capFirstNewRecord );
 }
예제 #5
0
 void run() {
     create();
     ASSERT( nsd() );
     ASSERT_EQUALS( 0, nRecords() );
     ASSERT( nsd()->firstExtent() == nsd()->capExtent() );
     RecordId initial = RecordId();
     initial.setInvalid();
     ASSERT( initial == nsd()->capFirstNewRecord() );
 }
예제 #6
0
            void run() {
                create();
                ASSERT_EQUALS( 2, nExtents() );
                BSONObj b = bigObj();

                DiskLoc l[ 8 ];
                for ( int i = 0; i < 8; ++i ) {
                    l[ i ] = theDataFileMgr.insert( ns(), b.objdata(), b.objsize() );
                    ASSERT( !l[ i ].isNull() );
                    ASSERT_EQUALS( i < 2 ? i + 1 : 3 + i % 2, nRecords() );
                    if ( i > 3 )
                        ASSERT( l[ i ] == l[ i - 4 ] );
                }

                // Too big
                BSONObjBuilder bob;
                bob.append( "a", string( 787, 'a' ) );
                BSONObj bigger = bob.done();
                ASSERT( theDataFileMgr.insert( ns(), bigger.objdata(), bigger.objsize() ).isNull() );
                ASSERT_EQUALS( 0, nRecords() );
            }
예제 #7
0
            void run() {
                create();
                BSONObj b = bigObj();

                DiskLoc l[ 6 ];
                for ( int i = 0; i < 6; ++i ) {
                    l[ i ] = theDataFileMgr.insert( ns(), b.objdata(), b.objsize() );
                    ASSERT( !l[ i ].isNull() );
                    ASSERT_EQUALS( 1 + i % 2, nRecords() );
                    if ( i > 1 )
                        ASSERT( l[ i ] == l[ i - 2 ] );
                }
            }
예제 #8
0
            void run() {
                DurTransaction txn;
                create();

                const int N = 20;
                const int Q = 16; // these constants depend on the size of the bson object, the extent size allocated by the system too
                DiskLoc l[ N ];
                for ( int i = 0; i < N; ++i ) {
                    BSONObj b = bigObj();
                    StatusWith<DiskLoc> status = collection()->insertDocument( &txn, b, true );
                    ASSERT( status.isOK() );
                    l[ i ] = status.getValue();
                    ASSERT( !l[ i ].isNull() );
                    ASSERT( nRecords() <= Q );
                    //ASSERT_EQUALS( 1 + i % 2, nRecords() );
                    if ( i >= 16 )
                        ASSERT( l[ i ] == l[ i - Q] );
                }
            }
예제 #9
0
 void run() {
     create();
     BSONObj b = bigObj();
     ASSERT( !theDataFileMgr.insert( ns(), b.objdata(), b.objsize() ).isNull() );
     ASSERT_EQUALS( 1, nRecords() );
 }
예제 #10
0
            void pass(int p) {
                DurTransaction txn;
                create();
                ASSERT_EQUALS( 2, nExtents() );

                BSONObj b = bigObj();

                int N = MinExtentSize / b.objsize() * nExtents() + 5;
                int T = N - 4;

                DiskLoc truncAt;
                //DiskLoc l[ 8 ];
                for ( int i = 0; i < N; ++i ) {
                    BSONObj bb = bigObj();
                    StatusWith<DiskLoc> status = collection()->insertDocument( &txn, bb, true );
                    ASSERT( status.isOK() );
                    DiskLoc a = status.getValue();
                    if( T == i )
                        truncAt = a;
                    ASSERT( !a.isNull() );
                    /*ASSERT_EQUALS( i < 2 ? i + 1 : 3 + i % 2, nRecords() );
                    if ( i > 3 )
                        ASSERT( l[ i ] == l[ i - 4 ] );*/
                }
                ASSERT( nRecords() < N );

                DiskLoc last, first;
                {
                    auto_ptr<Runner> runner(InternalPlanner::collectionScan(ns(),
                                                                            collection(),
                                                                            InternalPlanner::BACKWARD));
                    runner->getNext(NULL, &last);
                    ASSERT( !last.isNull() );
                }
                {
                    auto_ptr<Runner> runner(InternalPlanner::collectionScan(ns(),
                                                                            collection(),
                                                                            InternalPlanner::FORWARD));
                    runner->getNext(NULL, &first);
                    ASSERT( !first.isNull() );
                    ASSERT( first != last ) ;
                }

                collection()->temp_cappedTruncateAfter(&txn, truncAt, false);
                ASSERT_EQUALS( collection()->numRecords() , 28u );

                {
                    DiskLoc loc;
                    auto_ptr<Runner> runner(InternalPlanner::collectionScan(ns(),
                                                                            collection(),
                                                                            InternalPlanner::FORWARD));
                    runner->getNext(NULL, &loc);
                    ASSERT( first == loc);
                }
                {
                    auto_ptr<Runner> runner(InternalPlanner::collectionScan(ns(),
                                                                            collection(),
                                                                            InternalPlanner::BACKWARD));
                    DiskLoc loc;
                    runner->getNext(NULL, &loc);
                    ASSERT( last != loc );
                    ASSERT( !last.isNull() );
                }

                // Too big
                BSONObjBuilder bob;
                bob.appendOID("_id", 0, true);
                bob.append( "a", string( MinExtentSize + 300, 'a' ) );
                BSONObj bigger = bob.done();
                StatusWith<DiskLoc> status = collection()->insertDocument( &txn, bigger, true );
                ASSERT( !status.isOK() );
                ASSERT_EQUALS( 0, nRecords() );
            }