File: rename6.js

package info (click to toggle)
mongodb 1%3A2.4.10-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 82,464 kB
  • sloc: cpp: 740,225; ansic: 152,098; sh: 13,820; python: 11,864; makefile: 1,012; perl: 922; pascal: 617; java: 452; lisp: 222; asm: 174
file content (24 lines) | stat: -rw-r--r-- 1,378 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Test for SERVER-7017
// We shouldn't rename a collection when one of its indexes will generate a namespace
// that is greater than 120 chars. To do this we create a long index name and try
// and rename the collection to one with a much longer name. We use the test database
// by default and we add this here to ensure we are using it
testDB = db.getSiblingDB("test")
c = "rename2c";
dbc = testDB.getCollection(c);
d = "dest4567890123456789012345678901234567890123456789012345678901234567890"
dbd = testDB.getCollection(d);
dbc.ensureIndex({ "name" : 1,
                  "date" : 1,
                  "time" : 1,
                  "renameCollection" : 1,
                  "mongodb" : 1,
                  "testing" : 1,
                  "data" : 1});
//Checking for the newly created index and the _id index in original collection
assert.eq(2, testDB.system.indexes.find( { "ns" : "test." + c } ).count(), "Long Rename Init");
//Should fail to rename collection as the index namespace is too long
assert.commandFailed( dbc.renameCollection( dbd ) , "Long Rename Exec" );
//Since we failed we should have the 2 indexes unmoved and no indexes under the new collection name
assert.eq(2, testDB.system.indexes.find( { "ns" : "test." + c } ).count(), "Long Rename Result 1");
assert.eq(0, testDB.system.indexes.find( { "ns" : "test." + d } ).count(), "Long Rename Result 2");