blob: 1b3d302be957fa1cf398258ecf52b5ee7c90c088 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
// This test just make sure that aggregation is possible on a secondary node.
// @tags: [
// requires_replication,
// requires_spawning_own_processes,
// ]
var replTest = new ReplSetTest({name: 'aggTestSlave', nodes: 2});
var nodes = replTest.startSet();
replTest.initiate();
replTest.awaitReplication();
var primary = replTest.getPrimary().getDB('test');
var secondary = replTest.getSecondary().getDB('test');
var options = {writeConcern: {w: 2}};
primary.agg.insert({}, options);
primary.agg.insert({}, options);
primary.agg.insert({}, options);
var res = secondary.agg.aggregate({$group: {_id: null, count: {$sum: 1}}});
assert.eq(res.toArray(), [{_id: null, count: 3}]);
replTest.stopSet();
|