8000 Add a CI step that waits for server instances before running tests · phpredis/phpredis@5996597 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5996597

Browse files
Add a CI step that waits for server instances before running tests
Every so often our tests will fail because we attempt to interact with one of the daemonized server instances before it has enough time to actually start. Usually this happens when we try to use the cli tool to execute `--cluster-create`, but it can occur elsewhere as well. This commit adds a step that waits for every instance that we started to actually be up before trying to create the cluster and run subsequent unit tests. Additionally it switches from `$(seq a b)` to the `{a..b}` brace expansion.
1 parent a819a44 commit 5996597

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ jobs:
143143

144144
- name: Start ${{ matrix.server }}-server
145145
run: |
146-
for PORT in $(seq 6379 6382) $(seq 32767 32769); do
146+
for PORT in {6379..6382} {32767..32769}; do
147147
${{ matrix.server }}-server \
148148
--port "$PORT" \
149149
--daemonize yes \
@@ -161,7 +161,7 @@ jobs:
161161
run: |
162162
mkdir -p tests/nodes
163163
echo -n > tests/nodes/nodemap
164-
for PORT in $(seq 7000 7005); do
164+
for PORT in {7000..7005}; do
165165
${{ matrix.server }}-server \
166166
--port "$PORT" \
167167
--cluster-enabled yes \
@@ -171,14 +171,12 @@ jobs:
171171
--acl-pubsub-default allchannels
172172
echo 127.0.0.1:"$PORT" >> tests/nodes/nodemap
173173
done
174-
echo yes | ${{ matrix.server }}-cli --cluster create $(seq -f 127.0.0.1:%g 7000 7005) \
175-
--cluster-replicas 1 --user phpredis -a phpredis
176174
177175
- name: Start ${{ matrix.server }} sentinel
178176
continue-on-error: ${{ matrix.server == 'valkey' }}
179177
run: |
180178
wget raw.githubusercontent.com/redis/redis/7.0/sentinel.conf
181-
for PORT in $(seq 26379 26380); do
179+
for PORT in {26379..26380}; do
182180
cp sentinel.conf "$PORT.conf"
183181
sed -i '/^sentinel/Id' "$PORT.conf"
184182
${{ matrix.server }}-server "$PORT.conf" \
@@ -188,6 +186,24 @@ jobs:
188186
--sentinel auth-pass mymaster phpredis
189187
done
190188
189+
- name: Wait for ${{ matrix.server }} instances
190+
run: |
191+
for PORT in {6379..6382} {7000..7005} {32767..32768} {26379..26380}; do
192+
until echo PING | ${{ matrix.server }}-cli -p "$PORT" 2>&1 | grep -qE 'PONG|NOAUTH'; do
193+
echo "Still waiting for ${{ matrix.server }} on port $PORT"
194+
sleep .05
195+
done
196+
done
197+
until echo PING | ${{ matrix.server }}-cli -s /tmp/redis.sock 2>&1 | grep -qE 'PONG|NOAUTH'; do
198+
echo "Still waiting for ${{ matrix.server }} at /tmp/redis.sock"
199+
sleep .05
200+
done
201+
202+
- name: Initialize ${{ matrix.server }} cluster
203+
run: |
204+
echo yes | ${{ matrix.server }}-cli --cluster create 127.0.0.1:{7000..7005} \
205+
--cluster-replicas 1 --user phpredis -a phpredis
206+
191207
- name: Run tests
192208
continue-on-error: ${{ matrix.server == 'valkey' }}
193209
run: |

0 commit comments

Comments
 (0)
0