summaryrefslogtreecommitdiff
path: root/jstests/sharding/copydb_from_mongos.js
blob: 4ec392f57893e03e1d564643fb7508e9742e3334 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var st = new ShardingTest({ shards: 1 });

var testDB = st.s.getDB('test');
assert.writeOK(testDB.foo.insert({ a: 1 }));

var res = testDB.adminCommand({ copydb: 1,
                                fromhost: st.s.host,
                                fromdb: 'test',
                                todb: 'test_copy' });
assert.commandWorked(res);

var copy = st.s.getDB('test_copy');
assert.eq(1, copy.foo.count());
assert.eq(1, copy.foo.findOne().a);

// Test invalid todb database name.
assert.commandFailed(testDB.adminCommand({ copydb: 1,
                                           fromhost: st.s.host,
                                           fromdb: 'test_copy',
                                           todb: 'test/copy' }));

st.stop();