File: big_object1.js

package info (click to toggle)
mongodb 1%3A2.0.6-1.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 17,204 kB
  • sloc: cpp: 109,783; ansic: 101,073; python: 2,287; perl: 395; makefile: 370; sh: 242; asm: 46
file content (48 lines) | stat: -rw-r--r-- 910 bytes parent folder | download
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 ){
    
    s = ""
    while ( s.length < 850 * 1024 ){
        s += "x";
    }
    
    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");