Skip to content

Commit

Permalink
chore(ci): update cluster setup script from 4.0, add versioned api su…
Browse files Browse the repository at this point in the history
…pport
  • Loading branch information
emadum committed Jun 30, 2021
1 parent 4867d92 commit 7b459d9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
3 changes: 0 additions & 3 deletions lib/mongo_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const NativeTopology = require('./topologies/native_topology');
const connect = require('./operations/connect').connect;
const validOptions = require('./operations/connect').validOptions;


/**
* @fileOverview The **MongoClient** class is a class that allows for making Connections to MongoDB.
*
Expand Down Expand Up @@ -185,8 +184,6 @@ const validOptions = require('./operations/connect').validOptions;
* @property {function} [callback] The command result callback
*/



/**
* Creates a new MongoClient instance
* @constructor
Expand Down
24 changes: 19 additions & 5 deletions test/tools/cluster_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,31 @@

if [ "$#" -ne 1 ]; then
echo "usage: cluster_setup <server|replica_set|sharded_cluster>"
echo "override <DATA_DIR | SINGLE_DIR | REPLICASET_DIR | SHARDED_DIR> env variables to change dbPath"
exit
fi

DATA_DIR=${DATA_DIR:-data}
SINGLE_DIR=${SINGLE_DIR:-$DATA_DIR/server}
REPLICASET_DIR=${REPLICASET_DIR:-$DATA_DIR/replica_set}
SHARDED_DIR=${SHARDED_DIR:-$DATA_DIR/sharded_cluster}

if [[ ! -z "$MONGODB_API_VERSION" ]]; then
echo "Requiring versioned API $MONGODB_API_VERSION"
REQUIRE_API="--setParameter requireApiVersion=$MONGODB_API_VERSION"
fi

if [[ $1 == "replica_set" ]]; then
mlaunch init --replicaset --nodes 3 --arbiter --name rs --port 31000 --enableMajorityReadConcern --setParameter enableTestCommands=1
echo "mongodb://localhost:31000/?replicaSet=rs"
mkdir -p $REPLICASET_DIR
mlaunch init --dir $REPLICASET_DIR --replicaset --nodes 3 --arbiter --name rs --port 31000 --enableMajorityReadConcern --setParameter enableTestCommands=1
echo "mongodb://localhost:31000,localhost:31001,localhost:31002/?replicaSet=rs"
elif [[ $1 == "sharded_cluster" ]]; then
mlaunch init --replicaset --nodes 3 --arbiter --name rs --port 51000 --enableMajorityReadConcern --setParameter enableTestCommands=1 --sharded 1 --mongos 2
echo "mongodb://localhost:51000,localhost:51001/"
mkdir -p $SHARDED_DIR
mlaunch init --dir $SHARDED_DIR --replicaset --nodes 3 --arbiter --name rs --port 51000 --enableMajorityReadConcern --setParameter enableTestCommands=1 --sharded 1 --mongos 2
echo "mongodb://localhost:51000,localhost:51001"
elif [[ $1 == "server" ]]; then
mlaunch init --single --setParameter enableTestCommands=1
mkdir -p $SINGLE_DIR
mlaunch init --dir $SINGLE_DIR --single --setParameter enableTestCommands=1 $REQUIRE_API
echo "mongodb://localhost:27017"
else
echo "unsupported topology: $1"
Expand Down

0 comments on commit 7b459d9

Please sign in to comment.