Skip to content

Commit 870f378

Browse files
authored
[Dev-infra]Fix a minor bug in dev-infra setup (#437)
Fix a minor bug on the dev-infra setup. In MongoDB, config servers are initiated with --configsvr flag. The mongo-cnf-setup container has to use this flag as well.
1 parent 536fa8c commit 870f378

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ define TEST_ENV
5050
TEST_MONGODB_S1_PRIMARY_PORT=$(TEST_MONGODB_S1_PRIMARY_PORT) \
5151
TEST_MONGODB_S1_SECONDARY1_PORT=$(TEST_MONGODB_S1_SECONDARY1_PORT) \
5252
TEST_MONGODB_S1_SECONDARY2_PORT=$(TEST_MONGODB_S1_SECONDARY2_PORT) \
53-
TEST_MONGODB_S1_ARTBITER_PORT=$(TEST_MONGODB_S1_ARTBITER_PORT) \
53+
TEST_MONGODB_S1_ARTBITER_PORT=$(TEST_MONGODB_S1_ARBITER_PORT) \
5454
TEST_MONGODB_S2_RS=$(TEST_MONGODB_S2_RS) \
5555
TEST_MONGODB_S2_PRIMARY_PORT=$(TEST_MONGODB_S2_PRIMARY_PORT) \
5656
TEST_MONGODB_S2_SECONDARY1_PORT=$(TEST_MONGODB_S2_SECONDARY1_PORT) \
5757
TEST_MONGODB_S2_SECONDARY2_PORT=$(TEST_MONGODB_S2_SECONDARY2_PORT) \
58-
TEST_MONGODB_S2_ARTBITER_PORT=$(TEST_MONGODB_S2_ARTBITER_PORT) \
58+
TEST_MONGODB_S2_ARTBITER_PORT=$(TEST_MONGODB_S2_ARBITER_PORT) \
5959
TEST_MONGODB_CONFIGSVR_RS=$(TEST_MONGODB_CONFIGSVR_RS) \
6060
TEST_MONGODB_CONFIGSVR1_PORT=$(TEST_MONGODB_CONFIGSVR1_PORT) \
6161
TEST_MONGODB_CONFIGSVR2_PORT=$(TEST_MONGODB_CONFIGSVR2_PORT) \

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ services:
151151
- MONGO3=mongo-cnf-3
152152
- RS=cnf-serv
153153
- PORT=27017
154-
entrypoint: [ "/scripts/setup.sh" ]
154+
entrypoint: [ "/scripts/setup.sh","cnf_servers" ]
155155

156156
mongos:
157157
container_name: "mongos"

docker/scripts/setup.sh

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,39 @@ done
1616
echo "Started.."
1717

1818
echo setup.sh time now: `date +"%T" `
19-
mongo --host ${mongodb1}:${port} <<EOF
20-
var cfg = {
19+
20+
21+
function cnf_servers() {
22+
echo "setup cnf servers"
23+
mongo --host ${mongodb1}:${port} <<EOF
24+
var cfg = {
25+
"_id": "${RS}",
26+
"protocolVersion": 1,
27+
"configsvr": true,
28+
"members": [
29+
{
30+
"_id": 0,
31+
"host": "${mongodb1}:${port}"
32+
},
33+
{
34+
"_id": 1,
35+
"host": "${mongodb2}:${port}"
36+
},
37+
{
38+
"_id": 2,
39+
"host": "${mongodb3}:${port}"
40+
}
41+
]
42+
};
43+
rs.initiate(cfg, { force: true });
44+
rs.reconfig(cfg, { force: true });
45+
EOF
46+
}
47+
48+
function general_servers() {
49+
echo "setup servers"
50+
mongo --host ${mongodb1}:${port} <<EOF
51+
var cfg = {
2152
"_id": "${RS}",
2253
"protocolVersion": 1,
2354
"members": [
@@ -40,4 +71,15 @@ mongo --host ${mongodb1}:${port} <<EOF
4071
4172
rs.addArb("${arbiter}:${port}")
4273
EOF
74+
}
4375

76+
case $1 in
77+
cnf_servers)
78+
cnf_servers
79+
shift
80+
;;
81+
*)
82+
general_servers
83+
shift
84+
;;
85+
esac

0 commit comments

Comments
 (0)