From QA/QA-370
|
/**
|
* bad_index_tests.js
|
* Make sure that we cannot build invalid indexes with the new external sort refactor.
|
*
|
* Note that all of these are large enough to trigger a spill to disk.
|
*
|
* NOTE: for text search to be indexed you need to it to be enabled on
|
* mongod startup
|
*/
|
coll = db.manyIndexType;
|
coll.drop();
|
|
//multi-key index (index on array)
|
//could be smaller really...
|
print("trying to create hashed multikey index...");
|
for(i=0; i<50000; i++) {
|
arr = [];
|
for(j=0; j<(i/100); j++) {
|
arr.push(j);
|
}
|
coll.insert({a: arr})
|
}
|
var err = coll.ensureIndex({a : "hashed"});
|
assert.neq(err, undefined);
|
assert.eq(coll.getIndexes().length, 1);
|
assert.eq(err.code, 16766, "should not be able to create hashed multikey index");
|
coll.drop();
|
print("PASSED");
|