Skip to content

Commit a0aa2d5

Browse files
committedJan 25, 2022
feat: if redisCluster is used ensure we wait for it to be ready
1 parent c2c9dd9 commit a0aa2d5

File tree

4 files changed

+235
-184
lines changed

4 files changed

+235
-184
lines changed
 

‎bin/cmds/test_cmds/auto-compose.js

+8
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ function tester(compose, argv) {
107107
}
108108
}
109109

110+
if (argv.services.includes('redisCluster')) {
111+
const cmdWait = process.env.DEPLOY_CLUSTER_SCRIPT || '/deploy-scripts/wait-for-cluster.sh';
112+
volumes.push(
113+
`${resolve(__dirname, '../../../scripts/wait-for-cluster.sh')}:${cmdWait}`
114+
);
115+
testerConfig.command = `${cmdWait} ${testerConfig.command}`;
116+
}
117+
110118
testerConfig.volumes = volumes;
111119

112120
compose.services.tester = testerConfig;

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@babel/core": "^7.16.12",
2828
"@babel/plugin-proposal-class-properties": "^7.13.0",
2929
"@babel/plugin-transform-strict-mode": "^7.12.13",
30-
"@types/node": "^17.0.10",
30+
"@types/node": "^17.0.12",
3131
"codecov": "^3.8.1",
3232
"eslint": "^8.4.1",
3333
"eslint-config-makeomatic": "^5.0.4",
@@ -39,7 +39,7 @@
3939
},
4040
"dependencies": {
4141
"@commitlint/cli": "^16.1.0",
42-
"@sinclair/typebox": "^0.23.2",
42+
"@sinclair/typebox": "^0.23.3",
4343
"bluebird": "^3.7.2",
4444
"chrome-launcher": "^0.15.0",
4545
"chrome-remote-interface": "^0.31.1",

‎scripts/wait-for-cluster.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env sh
2+
3+
set -ex
4+
5+
max_retry=30
6+
counter=0
7+
8+
function pingRedis() {
9+
echo "Verifying pingRedis ${counter}/${max_retry}"
10+
echo "CLUSTER INFO" | nc $1 $2 2>/dev/null | grep cluster_state:ok > /dev/null
11+
if [ $? -eq 0 ]
12+
then
13+
return 0
14+
else
15+
return 1
16+
fi
17+
}
18+
19+
until pingRedis 'redis-cluster' '7000' && pingRedis 'redis-cluster' '7001' && pingRedis 'redis-cluster' '7002'
20+
do
21+
sleep 1
22+
[[ $counter -eq $max_retry ]] && echo "Failed!" && exit 1
23+
counter=`expr $counter + 1`
24+
done
25+
26+
# first arg is `-f` or `--some-option`
27+
if [ "${1#-}" != "$1" ]; then
28+
set -- node "$@"
29+
fi
30+
31+
exec "$@"

‎yarn.lock

+194-182
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.