Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 33 additions & 12 deletions .github/workflows/ci.yml → .github/workflows/redis-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Test Redis

on:
push:
Expand All @@ -9,14 +9,14 @@ on:
- master

jobs:
test:
redis-standalone:
env:
CI: true
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [18.x, 20.x]

steps:
- name: Checkout
Expand All @@ -27,29 +27,50 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: install redis-cli
run: sudo apt-get install redis-tools

- name: Install dependencies
run: npm install

- name: Setup Standalone Tests
run: make test-standalone-setup
run: make test-standalone-redis-setup

- name: Run Standalone tests
run: make test-standalone
run: make test-standalone-run

- name: Teardown Standalone Tests
run: make test-standalone-teardown
run: make test-standalone-redis-teardown

redis-cluster:
env:
CI: true
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: install redis-cli
run: sudo apt-get install redis-tools

- name: Install dependencies
run: npm install

- name: Setup Clustered Tests
run: make test-cluster-setup
run: make test-cluster-redis-setup

- name: Check Redis Cluster
run: timeout 60 bash <<< "until redis-cli -c -p 16371 cluster info | grep 'cluster_state:ok'; do sleep 1; done"

- name: Run Clustered tests
run: make test-cluster
run: make test-cluster-run

- name: Teardown Clustered Tests
run: make test-cluster-teardown
run: make test-cluster-redis-teardown
76 changes: 76 additions & 0 deletions .github/workflows/valkey-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Test Valkey

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
valkey-standalone:
env:
CI: true
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm install

- name: Setup Standalone Tests
run: make test-standalone-valkey-setup

- name: Run Standalone tests
run: make test-standalone-run

- name: Teardown Standalone Tests
run: make test-standalone-valkey-teardown

valkey-cluster:
env:
CI: true
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: install redis-cli
run: sudo apt-get install redis-tools

- name: Install dependencies
run: npm install

- name: Setup Clustered Tests
run: make test-cluster-valkey-setup

- name: Check valkey Cluster
run: timeout 60 bash <<< "until redis-cli -c -p 16371 cluster info | grep 'cluster_state:ok'; do sleep 1; done"

- name: Run Clustered tests
run: make test-cluster-run

- name: Teardown Clustered Tests
run: make test-cluster-valkey-teardown
55 changes: 42 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,51 @@
export CLUSTER_NO_TLS_VALIDATION=true
.ONESHELL:

test-standalone-setup:
docker compose up -d
VALKEY_DOCKER_IMAGE=bitnami/valkey:8.0.2-debian-12-r5
REDIS_DOCKER_IMAGE=redis:6

test-standalone-teardown:
docker compose down
test: test-redis test-valkey
@echo "All tests executed"

test-cluster-setup:
docker compose -f docker-compose-cluster.yml up -d
test-%: test-setup-% test-standalone-run test-cluster-run test-teardown-%
@echo "Test executed"

test-cluster-teardown:
docker compose -f docker-compose-cluster.yml down
test-setup-%: test-standalone-%-setup test-cluster-%-setup
@echo "Test setup executed"

test-cluster:
test-teardown-%: test-standalone-%-teardown test-cluster-%-teardown
@echo "Test teardown executed"

test-standalone-redis-setup:
REDIS_IMAGE=${REDIS_DOCKER_IMAGE} docker compose up -d

test-standalone-valkey-setup:
REDIS_IMAGE=${VALKEY_DOCKER_IMAGE} docker compose up -d

test-standalone-redis-teardown:
REDIS_IMAGE=${REDIS_DOCKER_IMAGE} docker compose down

test-standalone-valkey-teardown:
REDIS_IMAGE=${VALKEY_DOCKER_IMAGE} docker compose down

test-cluster-redis-setup:
REDIS_IMAGE=${REDIS_DOCKER_IMAGE} docker compose -f docker-compose-cluster.yml up -d

test-cluster-valkey-setup:
REDIS_IMAGE=${VALKEY_DOCKER_IMAGE} docker compose -f docker-compose-cluster.yml up -d

test-cluster-redis-teardown:
REDIS_IMAGE=${REDIS_DOCKER_IMAGE} docker compose -f docker-compose-cluster.yml down

test-cluster-valkey-teardown:
REDIS_IMAGE=${VALKEY_DOCKER_IMAGE} docker compose -f docker-compose-cluster.yml down

test-cluster-run:
npm run test-cluster
test-standalone:

test-standalone-run:
npm run test-standalone

test: test-standalone test-cluster
test-setup: test-standalone-setup test-cluster-setup
test-teardown: test-standalone-teardown test-cluster-teardown
test-teardown-all: test-standalone-redis-teardown test-cluster-redis-teardown test-standalone-valkey-teardown test-cluster-valkey-teardown


10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,12 @@ const configOverride = {

## Testing

- Setup tests: `make test-setup`
- Run tests: `make test`
- Teardown tests: `make test-teardown`

- Run All tests: `make test`
- Run Redis tests: `make test-redis`
- Run Valkey tests: `make test-valkey`
- Setup environment for testing with Redis: `make test-setup-redis`
- Setup environment for testing with Valkey: `make test-setup-valkey`
- Teardown environment: `make test-teardown-all`

## Author

Expand Down
38 changes: 27 additions & 11 deletions docker-compose-cluster.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,59 @@
services:
redis-1:
image: 'redis:6'
image: ${REDIS_IMAGE}
healthcheck:
interval: "1s"
test: [ "CMD", "redis-cli", "-p", "16371", "ping", "|", "grep", "PONG" ]
test: ["CMD", "redis-cli", "-p", "16371", "ping", "|", "grep", "PONG"]
command: ["redis-server", "/etc/redis/redis.conf"]
user: root
environment:
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- ${PWD}/test-resources/redis-cluster/node-1/conf/redis.conf:/etc/redis/redis.conf
network_mode: host
redis-2:
image: 'redis:6'
image: ${REDIS_IMAGE}
healthcheck:
interval: "1s"
test: [ "CMD", "redis-cli", "-p", "16372", "ping", "|", "grep", "PONG" ]
command: [ "redis-server", "/etc/redis/redis.conf" ]
test: ["CMD", "redis-cli", "-p", "16372", "ping", "|", "grep", "PONG"]
command: ["redis-server", "/etc/redis/redis.conf"]
user: root
environment:
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- ${PWD}/test-resources/redis-cluster/node-2/conf/redis.conf:/etc/redis/redis.conf
network_mode: host
redis-3:
image: 'redis:6'
image: ${REDIS_IMAGE}
healthcheck:
interval: "1s"
test: [ "CMD", "redis-cli", "-p", "16373", "ping", "|", "grep", "PONG" ]
command: [ "redis-server", "/etc/redis/redis.conf" ]
test: ["CMD", "redis-cli", "-p", "16373", "ping", "|", "grep", "PONG"]
command: ["redis-server", "/etc/redis/redis.conf"]
user: root
environment:
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- ${PWD}/test-resources/redis-cluster/node-3/conf/redis.conf:/etc/redis/redis.conf
network_mode: host
redis-cluster-create:
image: 'redis:6'
command: '/usr/local/etc/redis/redis-cluster-create.sh'
image: ${REDIS_IMAGE}
command: "/usr/local/etc/redis/redis-cluster-create.sh"
depends_on:
redis-1:
condition: service_healthy
redis-2:
condition: service_healthy
redis-3:
condition: service_healthy
user: root
environment:
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- ${PWD}/test-resources/redis-cluster/redis-cluster-create.sh:/usr/local/etc/redis/redis-cluster-create.sh
network_mode: host
healthcheck:
test: ["CMD-SHELL", "redis-cli -p 16371 -c cluster info | grep cluster_state:ok"]
test:
[
"CMD-SHELL",
"redis-cli -p 16371 -c cluster info | grep cluster_state:ok",
]
7 changes: 4 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
services:
redis:
image: 'redis:6'
command: --save "" --appendonly no
image: ${REDIS_IMAGE}
environment:
- ALLOW_EMPTY_PASSWORD=yes
ports:
- "6379:6379"
toxiproxy:
image: 'shopify/toxiproxy'
image: "shopify/toxiproxy"
ports:
- "8474:8474"
- "22222:22222"