diff options
author | Aaron <aaron@10gen.com> | 2011-01-14 17:00:28 -0800 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2011-01-14 17:00:28 -0800 |
commit | 37a315ef47a95b46710dbdf9b9f1806ed03f3923 (patch) | |
tree | a4828e5bddc03b53ac3dd414a7ebb3437743949b /jstests/slowWeekly | |
parent | a61e609d2bc52025d9f7b479411a5241baaa0130 (diff) | |
download | mongo-37a315ef47a95b46710dbdf9b9f1806ed03f3923.tar.gz |
commit dur index build test
Diffstat (limited to 'jstests/slowWeekly')
-rw-r--r-- | jstests/slowWeekly/indexbg_dur.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/jstests/slowWeekly/indexbg_dur.js b/jstests/slowWeekly/indexbg_dur.js new file mode 100644 index 00000000000..b8077878e0c --- /dev/null +++ b/jstests/slowWeekly/indexbg_dur.js @@ -0,0 +1,55 @@ +/** + * Kill mongod during a background index build and ensure that the bad index + * can be dropped on restart. + */ + +function countFields( x ) { + var count = 0; + for( var i in x ) { + ++count; + } + return count; +} + +size = 100000; +while( 1 ) { + print( "size: " + size ); + + var testname = "index_build"; + var path = "/data/db/" + testname+"_dur"; + conn = startMongodEmpty("--port", 30001, "--dbpath", path, "--dur", "--smallfiles", "--durOptions", 8); + t = conn.getDB( testname ).getCollection( testname ); + + for( var i = 0; i < size; ++i ) { + t.save( {i:i} ); + } + t.getDB().getLastError(); + x = startMongoProgramNoConnect( "mongo", "--eval", "db.getSisterDB( '" + testname + "' )." + testname + ".ensureIndex( {i:1}, {background:true} );", conn.host ); + sleep( 1000 ); + stopMongod( 30001, /* signal */ 9 ); + waitProgram( x ); + + conn = startMongodNoReset("--port", 30001, "--dbpath", path, "--dur", "--smallfiles", "--durOptions", 8); + t = conn.getDB( testname ).getCollection( testname ); + + var statsSize = countFields( t.stats().indexSizes ); + var nsSize = conn.getDB( testname ).system.indexes.count( {ns:testname+'.'+testname} ); + + // If index build completed before the kill, try again with more data. + if ( !( statsSize == 1 && nsSize == 2 ) ) { + print( "statsSize: " + statsSize + ", nsSize: " + nsSize + ", retrying with more data" ); + stopMongod( 30001 ); + size *= 2; + continue; + } + + assert.eq( "index not found", t.dropIndex( "i_1" ).errmsg ); + + var statsSize = countFields( t.stats().indexSizes ); + var nsSize = conn.getDB( testname ).system.indexes.count( {ns:testname+'.'+testname} ); + + assert.eq( statsSize, nsSize ); + assert( t.validate().valid ); + // TODO check that index namespace is cleaned up as well once that is implemented + break; +} |