summaryrefslogtreecommitdiff
path: root/jstests/count10.js
blob: 478c30a4393a41f759b9c5ba21867550290f0782 (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
// interrupting a count returns an error code

t = db.count10;
t.drop();

for ( i=0; i<100; i++ ){
    t.save( { x : i } );
}
// make sure data is written
db.getLastError();

s = startParallelShell(
    'sleep(1000); ' +
    'current = db.currentOp({"ns": db.count10.getFullName(), "query.count": db.count10.getName()}); ' +
    'assert(current); ' +
    'countOp = current.inprog[0]; ' +
    'assert(countOp); ' +
    'db.killOp(countOp.opid); '
);

function getKilledCount() {
    try {
        db.count10.find("sleep(1000)").count();
    } catch (e) {
        return e;
    }
}

var res = getKilledCount();
assert(res);
assert(res.match(/count failed/) !== null);
assert(res.match(/\"code\"/) !== null);

s();