summaryrefslogtreecommitdiff
path: root/jstests/big_object1.js
blob: 55c22934e00f7b538cc8203d577fa555058e6a02 (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

t = db.big_object1
t.drop();

s = ""
while ( s.length < 512 * 1024 ){
    s += "x";
}

x = 0;
while ( true ){
    o = { _id : x , a : [] }
    for ( i=0; i<x; i++ )
        o.a.push( s )
    print( Object.bsonsize( o ) )
    try {
        t.insert( o )
    }
    catch ( e ){
        break;
    }
    
    if ( db.getLastError() != null )
        break;
    x++;
}

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()