summaryrefslogtreecommitdiff
path: root/jstests/big_object1.js
blob: 14d216e609b53efe12984083cc02c0e4d4eaa3b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

t = db.big_object1
t.drop();

if ( db.adminCommand( "buildinfo" ).bits == 64 ){
    
    var large = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    var s = large;
    while ( s.length < 850 * 1024 ){
        s += large;
    }
    x = 0;
    while ( true ){
        n = { _id : x , a : [] }
        for ( i=0; i<14+x; i++ )
            n.a.push( s )
        try {
            t.insert( n )
            o = n
        }
        catch ( e ){
            break;
        }
        
        if ( db.getLastError() != null )
            break;
        x++;
    }
    
    printjson( t.stats(1024*1024) )

    assert.lt( 15 * 1024 * 1024 , Object.bsonsize( o ) , "A1" )
    assert.gt( 17 * 1024 * 1024 , Object.bsonsize( o ) , "A2" )
    
    assert.eq( x , t.count() , "A3" )
    
    for ( i=0; i<x; i++ ){
        o = t.findOne( { _id : 1 } )
        assert( o , "B" + i );
    }
    
    t.drop()
}
else {
    print( "skipping big_object1 b/c not 64-bit" )
}

print("SUCCESS");