Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Commit 0380262

Browse files
authored
added tests with Valkey (#90)
* added tests with Valkey * fix CI
1 parent c394aa9 commit 0380262

File tree

6 files changed

+188
-43
lines changed

6 files changed

+188
-43
lines changed
Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test
1+
name: Test Redis
22

33
on:
44
push:
@@ -9,14 +9,14 @@ on:
99
- master
1010

1111
jobs:
12-
test:
12+
redis-standalone:
1313
env:
1414
CI: true
1515
timeout-minutes: 10
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
node-version: [14.x, 16.x, 18.x, 20.x]
19+
node-version: [18.x, 20.x]
2020

2121
steps:
2222
- name: Checkout
@@ -27,29 +27,50 @@ jobs:
2727
with:
2828
node-version: ${{ matrix.node-version }}
2929

30-
- name: install redis-cli
31-
run: sudo apt-get install redis-tools
32-
3330
- name: Install dependencies
3431
run: npm install
3532

3633
- name: Setup Standalone Tests
37-
run: make test-standalone-setup
34+
run: make test-standalone-redis-setup
3835

3936
- name: Run Standalone tests
40-
run: make test-standalone
37+
run: make test-standalone-run
4138

4239
- name: Teardown Standalone Tests
43-
run: make test-standalone-teardown
40+
run: make test-standalone-redis-teardown
41+
42+
redis-cluster:
43+
env:
44+
CI: true
45+
timeout-minutes: 10
46+
runs-on: ubuntu-latest
47+
strategy:
48+
matrix:
49+
node-version: [18.x, 20.x]
50+
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
55+
- name: Install node
56+
uses: actions/setup-node@v4
57+
with:
58+
node-version: ${{ matrix.node-version }}
59+
60+
- name: install redis-cli
61+
run: sudo apt-get install redis-tools
62+
63+
- name: Install dependencies
64+
run: npm install
4465

4566
- name: Setup Clustered Tests
46-
run: make test-cluster-setup
67+
run: make test-cluster-redis-setup
4768

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

5172
- name: Run Clustered tests
52-
run: make test-cluster
73+
run: make test-cluster-run
5374

5475
- name: Teardown Clustered Tests
55-
run: make test-cluster-teardown
76+
run: make test-cluster-redis-teardown

.github/workflows/valkey-tests.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Test Valkey
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
valkey-standalone:
13+
env:
14+
CI: true
15+
timeout-minutes: 10
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
node-version: [18.x, 20.x]
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Install node
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
30+
- name: Install dependencies
31+
run: npm install
32+
33+
- name: Setup Standalone Tests
34+
run: make test-standalone-valkey-setup
35+
36+
- name: Run Standalone tests
37+
run: make test-standalone-run
38+
39+
- name: Teardown Standalone Tests
40+
run: make test-standalone-valkey-teardown
41+
42+
valkey-cluster:
43+
env:
44+
CI: true
45+
timeout-minutes: 10
46+
runs-on: ubuntu-latest
47+
strategy:
48+
matrix:
49+
node-version: [18.x, 20.x]
50+
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
55+
- name: Install node
56+
uses: actions/setup-node@v4
57+
with:
58+
node-version: ${{ matrix.node-version }}
59+
60+
- name: install redis-cli
61+
run: sudo apt-get install redis-tools
62+
63+
- name: Install dependencies
64+
run: npm install
65+
66+
- name: Setup Clustered Tests
67+
run: make test-cluster-valkey-setup
68+
69+
- name: Check valkey Cluster
70+
run: timeout 60 bash <<< "until redis-cli -c -p 16371 cluster info | grep 'cluster_state:ok'; do sleep 1; done"
71+
72+
- name: Run Clustered tests
73+
run: make test-cluster-run
74+
75+
- name: Teardown Clustered Tests
76+
run: make test-cluster-valkey-teardown

Makefile

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,51 @@
11
export CLUSTER_NO_TLS_VALIDATION=true
2+
.ONESHELL:
23

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

6-
test-standalone-teardown:
7-
docker compose down
7+
test: test-redis test-valkey
8+
@echo "All tests executed"
89

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

12-
test-cluster-teardown:
13-
docker compose -f docker-compose-cluster.yml down
13+
test-setup-%: test-standalone-%-setup test-cluster-%-setup
14+
@echo "Test setup executed"
1415

15-
test-cluster:
16+
test-teardown-%: test-standalone-%-teardown test-cluster-%-teardown
17+
@echo "Test teardown executed"
18+
19+
test-standalone-redis-setup:
20+
REDIS_IMAGE=${REDIS_DOCKER_IMAGE} docker compose up -d
21+
22+
test-standalone-valkey-setup:
23+
REDIS_IMAGE=${VALKEY_DOCKER_IMAGE} docker compose up -d
24+
25+
test-standalone-redis-teardown:
26+
REDIS_IMAGE=${REDIS_DOCKER_IMAGE} docker compose down
27+
28+
test-standalone-valkey-teardown:
29+
REDIS_IMAGE=${VALKEY_DOCKER_IMAGE} docker compose down
30+
31+
test-cluster-redis-setup:
32+
REDIS_IMAGE=${REDIS_DOCKER_IMAGE} docker compose -f docker-compose-cluster.yml up -d
33+
34+
test-cluster-valkey-setup:
35+
REDIS_IMAGE=${VALKEY_DOCKER_IMAGE} docker compose -f docker-compose-cluster.yml up -d
36+
37+
test-cluster-redis-teardown:
38+
REDIS_IMAGE=${REDIS_DOCKER_IMAGE} docker compose -f docker-compose-cluster.yml down
39+
40+
test-cluster-valkey-teardown:
41+
REDIS_IMAGE=${VALKEY_DOCKER_IMAGE} docker compose -f docker-compose-cluster.yml down
42+
43+
test-cluster-run:
1644
npm run test-cluster
17-
test-standalone:
45+
46+
test-standalone-run:
1847
npm run test-standalone
1948

20-
test: test-standalone test-cluster
21-
test-setup: test-standalone-setup test-cluster-setup
22-
test-teardown: test-standalone-teardown test-cluster-teardown
49+
test-teardown-all: test-standalone-redis-teardown test-cluster-redis-teardown test-standalone-valkey-teardown test-cluster-valkey-teardown
50+
51+

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,12 @@ const configOverride = {
456456

457457
## Testing
458458

459-
- Setup tests: `make test-setup`
460-
- Run tests: `make test`
461-
- Teardown tests: `make test-teardown`
462-
459+
- Run All tests: `make test`
460+
- Run Redis tests: `make test-redis`
461+
- Run Valkey tests: `make test-valkey`
462+
- Setup environment for testing with Redis: `make test-setup-redis`
463+
- Setup environment for testing with Valkey: `make test-setup-valkey`
464+
- Teardown environment: `make test-teardown-all`
463465

464466
## Author
465467

docker-compose-cluster.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,59 @@
11
services:
22
redis-1:
3-
image: 'redis:6'
3+
image: ${REDIS_IMAGE}
44
healthcheck:
55
interval: "1s"
6-
test: [ "CMD", "redis-cli", "-p", "16371", "ping", "|", "grep", "PONG" ]
6+
test: ["CMD", "redis-cli", "-p", "16371", "ping", "|", "grep", "PONG"]
77
command: ["redis-server", "/etc/redis/redis.conf"]
8+
user: root
9+
environment:
10+
- ALLOW_EMPTY_PASSWORD=yes
811
volumes:
912
- ${PWD}/test-resources/redis-cluster/node-1/conf/redis.conf:/etc/redis/redis.conf
1013
network_mode: host
1114
redis-2:
12-
image: 'redis:6'
15+
image: ${REDIS_IMAGE}
1316
healthcheck:
1417
interval: "1s"
15-
test: [ "CMD", "redis-cli", "-p", "16372", "ping", "|", "grep", "PONG" ]
16-
command: [ "redis-server", "/etc/redis/redis.conf" ]
18+
test: ["CMD", "redis-cli", "-p", "16372", "ping", "|", "grep", "PONG"]
19+
command: ["redis-server", "/etc/redis/redis.conf"]
20+
user: root
21+
environment:
22+
- ALLOW_EMPTY_PASSWORD=yes
1723
volumes:
1824
- ${PWD}/test-resources/redis-cluster/node-2/conf/redis.conf:/etc/redis/redis.conf
1925
network_mode: host
2026
redis-3:
21-
image: 'redis:6'
27+
image: ${REDIS_IMAGE}
2228
healthcheck:
2329
interval: "1s"
24-
test: [ "CMD", "redis-cli", "-p", "16373", "ping", "|", "grep", "PONG" ]
25-
command: [ "redis-server", "/etc/redis/redis.conf" ]
30+
test: ["CMD", "redis-cli", "-p", "16373", "ping", "|", "grep", "PONG"]
31+
command: ["redis-server", "/etc/redis/redis.conf"]
32+
user: root
33+
environment:
34+
- ALLOW_EMPTY_PASSWORD=yes
2635
volumes:
2736
- ${PWD}/test-resources/redis-cluster/node-3/conf/redis.conf:/etc/redis/redis.conf
2837
network_mode: host
2938
redis-cluster-create:
30-
image: 'redis:6'
31-
command: '/usr/local/etc/redis/redis-cluster-create.sh'
39+
image: ${REDIS_IMAGE}
40+
command: "/usr/local/etc/redis/redis-cluster-create.sh"
3241
depends_on:
3342
redis-1:
3443
condition: service_healthy
3544
redis-2:
3645
condition: service_healthy
3746
redis-3:
3847
condition: service_healthy
48+
user: root
49+
environment:
50+
- ALLOW_EMPTY_PASSWORD=yes
3951
volumes:
4052
- ${PWD}/test-resources/redis-cluster/redis-cluster-create.sh:/usr/local/etc/redis/redis-cluster-create.sh
4153
network_mode: host
4254
healthcheck:
43-
test: ["CMD-SHELL", "redis-cli -p 16371 -c cluster info | grep cluster_state:ok"]
55+
test:
56+
[
57+
"CMD-SHELL",
58+
"redis-cli -p 16371 -c cluster info | grep cluster_state:ok",
59+
]

docker-compose.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
services:
22
redis:
3-
image: 'redis:6'
4-
command: --save "" --appendonly no
3+
image: ${REDIS_IMAGE}
4+
environment:
5+
- ALLOW_EMPTY_PASSWORD=yes
56
ports:
67
- "6379:6379"
78
toxiproxy:
8-
image: 'shopify/toxiproxy'
9+
image: "shopify/toxiproxy"
910
ports:
1011
- "8474:8474"
1112
- "22222:22222"

0 commit comments

Comments
 (0)