From 7b459d9383c9e595371c4a08e81dae96e34606c1 Mon Sep 17 00:00:00 2001 From: emadum Date: Wed, 30 Jun 2021 15:15:31 -0400 Subject: [PATCH] chore(ci): update cluster setup script from 4.0, add versioned api support --- lib/mongo_client.js | 3 --- test/tools/cluster_setup.sh | 24 +++++++++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/mongo_client.js b/lib/mongo_client.js index 98f2d0a9512..31c37a7d771 100644 --- a/lib/mongo_client.js +++ b/lib/mongo_client.js @@ -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. * @@ -185,8 +184,6 @@ const validOptions = require('./operations/connect').validOptions; * @property {function} [callback] The command result callback */ - - /** * Creates a new MongoClient instance * @constructor diff --git a/test/tools/cluster_setup.sh b/test/tools/cluster_setup.sh index 2f12d17f941..36beca5dc9f 100755 --- a/test/tools/cluster_setup.sh +++ b/test/tools/cluster_setup.sh @@ -2,17 +2,31 @@ if [ "$#" -ne 1 ]; then echo "usage: cluster_setup " + echo "override 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"