Make Relay work with Redis cluster (#1397)

This commit is contained in:
Jiří Bok
2023-09-13 18:59:50 +02:00
committed by Till Krüss
parent 8e66c20dc0
commit c83ffa43d8
17 changed files with 397 additions and 22 deletions
+7
View File
@@ -0,0 +1,7 @@
FROM redis/redis-stack-server:edge as rss
COPY create_cluster.sh /create_cluster.sh
RUN ls -R /opt/redis-stack
RUN chmod a+x /create_cluster.sh
ENTRYPOINT [ "/create_cluster.sh"]
@@ -0,0 +1,47 @@
#! /bin/bash
mkdir -p /nodes
touch /nodes/nodemap
if [ -z ${START_PORT} ]; then
START_PORT=6372
fi
if [ -z ${END_PORT} ]; then
END_PORT=6377
fi
if [ ! -z "$3" ]; then
START_PORT=$2
START_PORT=$3
fi
echo "STARTING: ${START_PORT}"
echo "ENDING: ${END_PORT}"
for PORT in `seq ${START_PORT} ${END_PORT}`; do
mkdir -p /nodes/$PORT
if [[ -e /redis.conf ]]; then
cp /redis.conf /nodes/$PORT/redis.conf
else
touch /nodes/$PORT/redis.conf
fi
cat << EOF >> /nodes/$PORT/redis.conf
port ${PORT}
cluster-enabled yes
daemonize yes
logfile /redis.log
dir /nodes/$PORT
EOF
set -x
/opt/redis-stack/bin/redis-server /nodes/$PORT/redis.conf
sleep 1
if [ $? -ne 0 ]; then
echo "Redis failed to start, exiting."
continue
fi
echo 127.0.0.1:$PORT >> /nodes/nodemap
done
if [ -z "${REDIS_PASSWORD}" ]; then
echo yes | /opt/redis-stack/bin/redis-cli --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
else
echo yes | opt/redis-stack/bin/redis-cli -a ${REDIS_PASSWORD} --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
fi
tail -f /redis.log
@@ -0,0 +1,17 @@
version: "3.9"
services:
cluster:
container_name: redis-cluster
build:
context: .
dockerfile: Dockerfile
ports:
- "6372:6372"
- "6373:6373"
- "6374:6374"
- "6375:6375"
- "6376:6376"
- "6377:6377"
volumes:
- "./redis.conf:/redis.conf:ro"
+10
View File
@@ -0,0 +1,10 @@
# Redis Cluster config file will be shared across all nodes.
# Do not change the following configurations that are already set:
# port, cluster-enabled, daemonize, logfile, dir
protected-mode no
loadmodule /opt/redis-stack/lib/redisearch.so
loadmodule /opt/redis-stack/lib/redisgraph.so
loadmodule /opt/redis-stack/lib/redisgears.so v8-plugin-path /opt/redis-stack/lib/libredisgears_v8_plugin.so
loadmodule /opt/redis-stack/lib/redistimeseries.so
loadmodule /opt/redis-stack/lib/rejson.so
loadmodule /opt/redis-stack/lib/redisbloom.so
+1 -1
View File
@@ -137,7 +137,7 @@ jobs:
EXPECTED="LICENSE,README.md,autoload.php,composer.json"
CURRENT="$(
git archive HEAD \
| tar --list --exclude="src" --exclude="src/*" --exclude="bin" --exclude="bin/*" --exclude="docker" --exclude="docker/*" \
| tar --list --exclude="src" --exclude="src/*" --exclude="bin" --exclude="bin/*" \
| paste --serial --delimiters=","
)"
echo "CURRENT =${CURRENT}"
+12 -11
View File
@@ -66,7 +66,7 @@ jobs:
- name: Run tests with coverage
if: ${{ matrix.php == '8.1' && matrix.redis == '7' }}
run: vendor/bin/phpunit --coverage-php build/cov/coverage-predis.cov --coverage-filter ./src
run: vendor/bin/phpunit --coverage-clover build/logs/clover-default.xml --coverage-filter ./src
- name: Run tests using Relay
if: ${{ matrix.redis >= '6' && (matrix.php != '8.1' || matrix.redis != '7')}}
@@ -74,11 +74,7 @@ jobs:
- name: Run tests using Relay with coverage
if: ${{ matrix.php == '8.1' && matrix.redis == '7' }}
run: vendor/bin/phpunit -c phpunit.relay.xml --coverage-php build/cov/coverage-relay.cov --coverage-filter ./src
- name: Merge coverage reports
if: ${{ matrix.php == '8.1' && matrix.redis == '7' }}
run: php vendor/bin/phpcov merge --clover build/logs/clover.xml build/cov
run: vendor/bin/phpunit -c phpunit.relay.xml --coverage-clover build/logs/clover-relay.xml --coverage-filter ./src
- name: Send coverage to Coveralls
uses: coverallsapp/github-action@v2
@@ -107,12 +103,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- name: Run redis cluster
- name: Run Redis cluster
uses: isbang/compose-action@v1.4.1
with:
compose-file: "./docker/unstable_cluster/docker-compose.yml"
compose-file: .github/workflows/cluster/docker-compose.yml
- name: Setup PHP with Composer and extensions
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
@@ -127,8 +123,13 @@ jobs:
- name: Run tests against cluster
run: |
sleep 5 # Timeout to make sure that docker image is setup
vendor/bin/phpunit --group cluster,gears-cluster
sleep 5 # make sure that docker image is setup
vendor/bin/phpunit --group cluster
- name: Run tests against cluster using Relay
run: |
sleep 5 # make sure nodes are stable and fully joined
vendor/bin/phpunit -c phpunit.relay.xml --group cluster
predis-stack: