~evarlast/ubuntu/trusty/mongodb/upstart-workaround-debian-bug-718702

« back to all changes in this revision

Viewing changes to jstests/slowWeekly/indexbg_dur.js

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Robie Basak
  • Date: 2013-05-29 17:44:42 UTC
  • mfrom: (44.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130529174442-z0a4qmoww4y0t458
Tags: 1:2.4.3-1ubuntu1
[ James Page ]
* Merge from Debian unstable, remaining changes:
  - Enable SSL support:
    + d/control: Add libssl-dev to BD's.
    + d/rules: Enabled --ssl option.
    + d/mongodb.conf: Add example SSL configuration options.
  - d/mongodb-server.mongodb.upstart: Add upstart configuration.
  - d/rules: Don't strip binaries during scons build for Ubuntu.
  - d/control: Add armhf to target archs.
  - d/p/SConscript.client.patch: fixup install of client libraries.
  - d/p/0010-install-libs-to-usr-lib-not-usr-lib64-Closes-588557.patch:
    Install libraries to lib not lib64.
* Dropped changes:
  - d/p/arm-support.patch: Included in Debian.
  - d/p/double-alignment.patch: Included in Debian.
  - d/rules,control: Debian also builds with avaliable system libraries
    now.
* Fix FTBFS due to gcc and boost upgrades in saucy:
  - d/p/0008-ignore-unused-local-typedefs.patch: Add -Wno-unused-typedefs
    to unbreak building with g++-4.8.
  - d/p/0009-boost-1.53.patch: Fixup signed/unsigned casting issue.

[ Robie Basak ]
* d/p/0011-Use-a-signed-char-to-store-BSONType-enumerations.patch: Fixup
  build failure on ARM due to missing signed'ness of char cast.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * Kill mongod during a background index build and ensure that the bad index
3
 
 * can be dropped on restart.
4
 
 */
5
 
 
6
 
load( "jstests/libs/slow_weekly_util.js" )
7
 
 
8
 
testServer = new SlowWeeklyMongod( "indexbg_dur" )
9
 
db = testServer.getDB( "test" );
10
 
 
11
 
function countFields( x ) {
12
 
    var count = 0;
13
 
    for( var i in x ) {
14
 
        ++count;
15
 
    }
16
 
    return count;
17
 
}
18
 
 
19
 
size = 100000;
20
 
while( 1 ) {
21
 
    print( "size: " + size );
22
 
 
23
 
    var testname = "index_build";
24
 
    var path = "/data/db/" + testname+"_dur";
25
 
    conn = startMongodEmpty("--port", 30001, "--dbpath", path, "--dur", "--smallfiles", "--durOptions", 8);
26
 
    t = conn.getDB( testname ).getCollection( testname );
27
 
 
28
 
    for( var i = 0; i < size; ++i ) {
29
 
        t.save( {i:i} );
30
 
    }
31
 
    t.getDB().getLastError();
32
 
    x = startMongoProgramNoConnect( "mongo", "--eval", "db.getSisterDB( '" + testname + "' )." + testname + ".ensureIndex( {i:1}, {background:true} );", conn.host );
33
 
    sleep( 1000 );
34
 
    stopMongod( 30001, /* signal */ 9 );
35
 
    waitProgram( x );
36
 
    
37
 
    conn = startMongodNoReset("--port", 30001, "--dbpath", path, "--dur", "--smallfiles", "--durOptions", 8);
38
 
    t = conn.getDB( testname ).getCollection( testname );
39
 
    
40
 
    var statsSize = countFields( t.stats().indexSizes );
41
 
    var nsSize = conn.getDB( testname ).system.indexes.count( {ns:testname+'.'+testname} );
42
 
    
43
 
    // If index build completed before the kill, try again with more data.
44
 
    if ( !( statsSize == 1 && nsSize == 2 ) ) {
45
 
        print( "statsSize: " + statsSize + ", nsSize: " + nsSize + ", retrying with more data" );
46
 
        stopMongod( 30001 );
47
 
        size *= 2;
48
 
        continue;
49
 
    }
50
 
    
51
 
    assert.eq( "index not found", t.dropIndex( "i_1" ).errmsg );
52
 
    
53
 
    var statsSize = countFields( t.stats().indexSizes );
54
 
    var nsSize = conn.getDB( testname ).system.indexes.count( {ns:testname+'.'+testname} );
55
 
 
56
 
    assert.eq( statsSize, nsSize );
57
 
    assert( t.validate().valid );
58
 
    // TODO check that index namespace is cleaned up as well once that is implemented
59
 
    
60
 
    t.ensureIndex( {i:1} );
61
 
    var statsSize = countFields( t.stats().indexSizes );
62
 
    var nsSize = conn.getDB( testname ).system.indexes.count( {ns:testname+'.'+testname} );
63
 
 
64
 
    assert.eq( 2, statsSize );
65
 
    assert.eq( 2, nsSize );
66
 
    
67
 
    exp = t.find( {i:20} ).explain();
68
 
    assert.eq( 1, exp.n );
69
 
    assert.eq( 'BtreeCursor i_1', exp.cursor );
70
 
    
71
 
    break;
72
 
}   
73
 
 
74
 
testServer.stop();