File: server14969.js

package info (click to toggle)
mongodb 1%3A3.2.11-2%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 196,404 kB
  • sloc: cpp: 1,412,793; ansic: 504,961; python: 78,522; perl: 5,837; sh: 5,661; java: 4,202; makefile: 1,784; pascal: 617; xml: 176; asm: 128
file content (32 lines) | stat: -rw-r--r-- 1,033 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
// Test dropping an index that is being used by an agg pipeline.
var coll = db.server14969;
var docsPerBatch = 3;
coll.drop();

// Initialize collection with eight 1M documents, and index on field "a".
var longString = new Array(1024 * 1024).join('x');
for (var i = 0; i < 100; ++i) {
    assert.writeOK(coll.insert({a: 1, bigField: longString}));
}
assert.commandWorked(coll.ensureIndex({a: 1}));

// Create pipeline that uses index "a", with a small initial batch size.
var cursor = coll.aggregate([{$match: {a: 1}}], {cursor: {batchSize: docsPerBatch}});
for (var i = 0; i < docsPerBatch; ++i) {
    assert(cursor.hasNext());
    assert.eq(1, cursor.next().a);
}

// Drop index "a".
assert.commandWorked(coll.dropIndex({a: 1}));

// Issue a getmore against agg cursor.  Note that it is not defined whether the server continues to
// generate further results for the cursor.
try {
    cursor.hasNext();
    cursor.next();
} catch (e) {
}

// Verify that the server hasn't crashed.
assert.commandWorked(db.adminCommand({ping: 1}));