summaryrefslogtreecommitdiff
path: root/jstests/drop2.js
blob: fa239fd66f2615ab7dea0498853a44c6c4f5b205 (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
t = db.jstests_drop2;
t.drop();

function debug( x ) {
//    printjson( x );
}

t.save( {} );
db.getLastError();

function op( drop ) {
    p = db.currentOp().inprog;
    debug( p );
    for ( var i in p ) {
        var o = p[ i ];
        if ( drop ) {
            if ( o.active && o.query && o.query.drop && o.query.drop == "jstests_drop2" ) {
                return o.opid;
            }
        } else {
            if ( o.active && o.query && o.query.query && o.query.query.$where && o.ns == "test.jstests_drop2" ) {
                return o.opid;
            }
        }
    }
    return null;
}

s1 = startParallelShell( "db.jstests_drop2.count( { $where: function() { while( 1 ) { ; } } } )" );
countOp = null;
assert.soon( function() { countOp = op( false ); return countOp; } );

s2 = startParallelShell( "db.jstests_drop2.drop()" );
dropOp = null;
assert.soon( function() { dropOp = op( true ); return dropOp; } );

db.killOp( dropOp );
db.killOp( countOp );

s1();
s2();

t.drop(); // in SERVER-1818, this fails