Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
fix(sharded-tests): add shardsvr cmdline opt, wait for async fns
Browse files Browse the repository at this point in the history
NODE-1075
  • Loading branch information
mbroadst committed Dec 19, 2017
1 parent 8d77484 commit 867b080
Showing 1 changed file with 61 additions and 38 deletions.
99 changes: 61 additions & 38 deletions test/environments.js
Expand Up @@ -50,6 +50,33 @@ class ReplicaSetEnvironment extends EnvironmentBase {
}
}

const genMongosConfig = (port, options) => {
return Object.assign(
{
options: {
bind_ip: 'localhost',
port: port,
dbpath: `${__dirname}/../db/${port}`,
shardsvr: null
}
},
options
);
};

const genConfigServerConfig = (port, options) => {
return Object.assign(
{
options: {
bind_ip: 'localhost',
port: port,
dbpath: `${__dirname}/../db/${port}`
}
},
options
);
};

class ShardedEnvironment extends EnvironmentBase {
constructor() {
super();
Expand All @@ -67,22 +94,8 @@ class ShardedEnvironment extends EnvironmentBase {
}

setup(callback) {
const genMongosConfig = (port, options) => {
return Object.assign(
{
options: {
bind_ip: 'localhost',
port: port,
dbpath: `${__dirname}/../db/${port}`,
shardsvr: null
}
},
options
);
};

const shardingManager = this.manager;
const setupPromise = Promise.all([
const shardPromise = Promise.all([
shardingManager.addShard(
[genMongosConfig(31000), genMongosConfig(31001), genMongosConfig(31002, { arbiter: true })],
{
Expand All @@ -94,33 +107,43 @@ class ShardedEnvironment extends EnvironmentBase {
{
replSet: 'rs2'
}
),
shardingManager.addConfigurationServers(
[genMongosConfig(35000), genMongosConfig(35001), genMongosConfig(35002)],
{
replSet: 'rs3'
}
),
shardingManager.addProxies(
[
)
]);

shardPromise
.then(() =>
shardingManager.addConfigurationServers(
[
genConfigServerConfig(35000),
genConfigServerConfig(35001),
genConfigServerConfig(35002)
],
{
bind_ip: 'localhost',
port: 51000,
configdb: 'localhost:35000,localhost:35001,localhost:35002'
},
replSet: 'rs3'
}
)
)
.then(() =>
shardingManager.addProxies(
[
{
bind_ip: 'localhost',
port: 51000,
configdb: 'localhost:35000,localhost:35001,localhost:35002'
},
{
bind_ip: 'localhost',
port: 51001,
configdb: 'localhost:35000,localhost:35001,localhost:35002'
}
],
{
bind_ip: 'localhost',
port: 51001,
configdb: 'localhost:35000,localhost:35001,localhost:35002'
binary: 'mongos'
}
],
{
binary: 'mongos'
}
)
)
]);

setupPromise.then(() => callback()).catch(err => callback(err));
.then(() => callback())
.catch(err => callback(err));
}
}

Expand Down

0 comments on commit 867b080

Please sign in to comment.