Skip to content

Commit 9afb978

Browse files
Use 3 x nodes per set, pass --shardsvr as a variable so we can share the mongo-rs0-# services with cluster and replset
1 parent b85b912 commit 9afb978

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

scripts/travis-ci/docker-compose.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,43 @@ version: '2'
22
services:
33
mongo-rs0-1:
44
image: "percona/percona-server-mongodb:${MONGO_VERSION}"
5-
command: mongod --port 27017 --replSet=rs0 --dbpath /data/db
5+
command: mongod --port=27017 --replSet=rs0 --dbpath=/data/db ${DATA_MONGOD_FLAGS}
66
mongo-rs0-2:
77
image: "percona/percona-server-mongodb:${MONGO_VERSION}"
8-
command: mongod --port 27017 --replSet=rs0 --dbpath /data/db
8+
command: mongod --port=27017 --replSet=rs0 --dbpath=/data/db ${DATA_MONGOD_FLAGS}
99
mongo-rs0-3:
1010
image: "percona/percona-server-mongodb:${MONGO_VERSION}"
11-
command: mongod --port 27017 --replSet=rs0 --dbpath /data/db
12-
mongo-s-rs0-1:
13-
image: "percona/percona-server-mongodb:${MONGO_VERSION}"
14-
command: mongod --port 27017 --replSet=rs0 --shardsvr --dbpath /data/db
15-
mongo-s-rs0-2:
16-
image: "percona/percona-server-mongodb:${MONGO_VERSION}"
17-
command: mongod --port 27017 --replSet=rs0 --shardsvr --dbpath /data/db
11+
command: mongod --port=27017 --replSet=rs0 --dbpath=/data/db ${DATA_MONGOD_FLAGS}
1812
mongo-cs-1:
1913
image: "percona/percona-server-mongodb:${MONGO_VERSION}"
20-
command: mongod --port 27017 ${CONFIGSVR_FLAGS} --configsvr --dbpath /data/db
14+
command: mongod --port=27017 --configsvr --dbpath=/data/db ${CONFIGSVR_FLAGS}
2115
mongo-cs-2:
2216
image: "percona/percona-server-mongodb:${MONGO_VERSION}"
23-
command: mongod --port 27017 ${CONFIGSVR_FLAGS} --configsvr --dbpath /data/db
17+
command: mongod --port=27017 --configsvr --dbpath=/data/db ${CONFIGSVR_FLAGS}
18+
mongo-cs-3:
19+
image: "percona/percona-server-mongodb:${MONGO_VERSION}"
20+
command: mongod --port=27017 --configsvr --dbpath=/data/db ${CONFIGSVR_FLAGS}
2421
mongo-mongos:
2522
image: "percona/percona-server-mongodb:${MONGO_VERSION}"
26-
command: mongos --port 27017 --configdb ${MONGOS_CONFIGDB}
23+
command: mongos --port=27017 --configdb=${MONGOS_CONFIGDB}
2724
depends_on:
28-
- mongo-s-rs0-1
29-
- mongo-s-rs0-2
25+
- mongo-rs0-1
26+
- mongo-rs0-2
27+
- mongo-rs0-3
3028
- mongo-cs-1
3129
- mongo-cs-2
30+
- mongo-cs-3
3231
backup-cluster:
3332
image: mongodb_consistent_backup:latest
3433
entrypoint: mongodb-consistent-backup
35-
command: --backup.location /tmp --backup.name test-cluster --host ${MONGOS_CONFIGDB} --replication.max_lag_secs 15 ${MCB_EXTRA}
34+
command: --backup.location=/tmp --backup.name=test-cluster --host=${MONGOS_CONFIGDB} --replication.max_lag_secs=15 ${MCB_EXTRA}
3635
depends_on:
3736
- mongo-mongos
3837
backup-replset:
3938
image: mongodb_consistent_backup:latest
4039
entrypoint: mongodb-consistent-backup
41-
command: --backup.location /tmp --backup.name test-replset --host rs0/mongo-rs0-1:27017,mongo-rs0-2:27017,mongo-rs0-3:27017 --replication.max_lag_secs 15 ${MCB_EXTRA}
40+
command: --backup.location=/tmp --backup.name=test-replset --host=rs0/mongo-rs0-1:27017,mongo-rs0-2:27017,mongo-rs0-3:27017 --replication.max_lag_secs=15 ${MCB_EXTRA}
4241
depends_on:
4342
- mongo-rs0-1
4443
- mongo-rs0-2
44+
- mongo-rs0-3

scripts/travis-ci/run-cluster.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@ pushd $(dirname $0)
1111
source $PWD/func.sh
1212

1313
export MONGO_VERSION=${MONGO_VERSION}
14+
export DATA_MONGOD_FLAGS="--shardsvr"
1415
export MCB_EXTRA=${MCB_EXTRA}
1516

1617
CONFIGSVR_REPLSET=csReplSet
1718
if [ "${CONFIGSVR_TYPE}" == "CSRS" ]; then
1819
export CONFIGSVR_FLAGS="--replSet ${CONFIGSVR_REPLSET}"
19-
export MONGOS_CONFIGDB="${CONFIGSVR_REPLSET}/mongo-cs-1:27017,mongo-cs-2:27017"
20+
export MONGOS_CONFIGDB="${CONFIGSVR_REPLSET}/mongo-cs-1:27017,mongo-cs-2:27017,mongo-cs-3:27017"
2021
echo "# Using CSRS-based config servers: '${MONGOS_CONFIGDB}'"
2122
else
2223
export CONFIGSVR_FLAGS=
2324
export MONGOS_CONFIGDB="mongo-cs-1:27017,mongo-cs-2:27017"
2425
echo "# Using SCCC-based config servers: '${MONGOS_CONFIGDB}'"
2526
fi
2627

28+
# start mongo-mongos service (which starts the whole cluster)
2729
echo "# Starting instances with docker-compose"
2830
docker-compose up -d mongo-mongos
2931

@@ -37,25 +39,27 @@ pushd $(dirname $0)
3739
configsvr: true,
3840
members: [
3941
{ _id: 0, host: "mongo-cs-1:27017" },
40-
{ _id: 1, host: "mongo-cs-2:27017" }
42+
{ _id: 1, host: "mongo-cs-2:27017" },
43+
{ _id: 1, host: "mongo-cs-3:27017" }
4144
]
4245
})'
4346
fi
4447

4548
echo "# Initiating rs0"
46-
doMongo mongo-mongos mongo-s-rs0-1:27017 'rs.initiate({
49+
doMongo mongo-mongos mongo-rs0-1:27017 'rs.initiate({
4750
_id: "rs0",
4851
members: [
49-
{ _id: 0, host: "mongo-s-rs0-1:27017" },
50-
{ _id: 1, host: "mongo-s-rs0-2:27017", priority: 0 }
52+
{ _id: 0, host: "mongo-rs0-1:27017" },
53+
{ _id: 1, host: "mongo-rs0-2:27017" },
54+
{ _id: 1, host: "mongo-rs0-3:27017", priority: 0 }
5155
]
5256
})'
5357

5458
echo "# Waiting 10 seconds"
5559
sleep 10
5660

5761
echo "# Adding shard rs0"
58-
doMongo mongo-mongos mongo-mongos:27017 'sh.addShard("rs0/mongo-s-rs0-1:27017,mongo-s-rs0-2:27017")'
62+
doMongo mongo-mongos mongo-mongos:27017 'sh.addShard("rs0/mongo-rs0-1:27017,mongo-rs0-2:27017,mongo-rs0-3:27017")'
5963

6064
echo "# Starting mongodb_consistent_backup, cluster mode (in docker)"
6165
docker-compose up --abort-on-container-exit backup-cluster

scripts/travis-ci/run-replset.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pushd $(dirname $0)
1010
source $PWD/func.sh
1111

1212
export MONGO_VERSION=${MONGO_VERSION}
13+
export DATA_MONGOD_FLAGS=
1314
export MCB_EXTRA=${MCB_EXTRA}
1415

1516
echo "# Starting instances with docker-compose"

0 commit comments

Comments
 (0)