summaryrefslogtreecommitdiff
path: root/jstests/sharding/shard_with_special_db_names.js
blob: 75f0ea19bb5d0de2a4bb21ed770dd144b7c1bf00 (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
(function() {
    'use strict';

    var s = new ShardingTest({shards: 2, mongos: 2});
    var specialDB = "[a-z]+";
    var specialNS = specialDB + ".special";

    assert.commandWorked(s.s0.adminCommand({enablesharding: "test"}));
    s.ensurePrimaryShard('test', s.shard1.shardName);
    assert.commandWorked(s.s0.adminCommand({shardcollection: "test.data", key: {num: 1}}));

    // Test that the database will not complain "cannot have 2 database names that differs on case"
    assert.commandWorked(s.s0.adminCommand({enablesharding: specialDB}));
    s.ensurePrimaryShard(specialDB, s.shard0.shardName);
    assert.commandWorked(s.s0.adminCommand({shardcollection: specialNS, key: {num: 1}}));

    var exists = s.getDB("config").collections.find({_id: specialNS}).itcount();
    assert.eq(exists, 1);

    // Test that drop database properly cleans up config
    s.getDB(specialDB).dropDatabase();

    var cursor = s.getDB("config").collections.find({_id: specialNS});
    assert(cursor.next()["dropped"]);
    assert(!cursor.hasNext());

    s.stop();
})();