Skip to content

Commit 1139bc3

Browse files
authored
fix(tests): enable testing with Redis CE 8.0-M4 in CI (#3247)
* introduce github workflow for ci similar to the one in redis-py use prerelease for 8.0-M4 * Enable osscluster tests in CI * Add redis major version env Enable filtering test per redis major version Fix test for FT.SEARCH WITHSCORE, the default scorer has changed. fix Makefile syntax remove filter from github action fix makefile use the container name in Makefile * remove 1.20 from doctests * self review, cleanup, add comments * add comments, reorder prints, add default value for REDIS_MAJOR_VERSION
1 parent 9f9fa22 commit 1139bc3

16 files changed

+445
-160
lines changed

.github/actions/run-tests/action.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: 'Run go-redis tests'
2+
description: 'Runs go-redis tests against different Redis versions and configurations'
3+
inputs:
4+
go-version:
5+
description: 'Go version to use for running tests'
6+
default: '1.23'
7+
redis-version:
8+
description: 'Redis version to test against'
9+
required: true
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Set up ${{ inputs.go-version }}
14+
uses: actions/setup-go@v5
15+
with:
16+
go-version: ${{ inputs.go-version }}
17+
18+
- name: Setup Test environment
19+
env:
20+
REDIS_VERSION: ${{ inputs.redis-version }}
21+
CLIENT_LIBS_TEST_IMAGE: "redislabs/client-libs-test:${{ inputs.redis-version }}"
22+
run: |
23+
set -e
24+
redis_major_version=$(echo "$REDIS_VERSION" | grep -oP '^\d+')
25+
if (( redis_major_version < 8 )); then
26+
echo "Using redis-stack for module tests"
27+
else
28+
echo "Using redis CE for module tests"
29+
fi
30+
31+
# Mapping of redis version to redis testing containers
32+
declare -A redis_version_mapping=(
33+
["8.0-M03"]="8.0-M04-pre"
34+
["7.4.2"]="rs-7.4.0-v2"
35+
["7.2.7"]="rs-7.2.0-v14"
36+
)
37+
38+
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
39+
echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV
40+
echo "REDIS_IMAGE=redis:${{ inputs.redis-version }}" >> $GITHUB_ENV
41+
echo "CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:${redis_version_mapping[$REDIS_VERSION]}" >> $GITHUB_ENV
42+
else
43+
echo "Version not found in the mapping."
44+
exit 1
45+
fi
46+
sleep 10 # time to settle
47+
shell: bash
48+
- name: Set up Docker Compose environment with redis ${{ inputs.redis-version }}
49+
run: docker compose --profile all up -d
50+
shell: bash
51+
- name: Run tests
52+
env:
53+
RCE_DOCKER: "true"
54+
RE_CLUSTER: "false"
55+
run: |
56+
go test \
57+
--ginkgo.skip-file="ring_test.go" \
58+
--ginkgo.skip-file="sentinel_test.go" \
59+
--ginkgo.skip-file="pubsub_test.go" \
60+
--ginkgo.skip-file="gears_commands_test.go" \
61+
--ginkgo.label-filter="!NonRedisEnterprise"
62+
shell: bash

.github/workflows/build.yml

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
go-version: [1.19.x, 1.20.x, 1.21.x]
20-
21-
services:
22-
redis:
23-
image: redis/redis-stack-server:latest
24-
options: >-
25-
--health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
26-
ports:
27-
- 6379:6379
19+
go-version: [1.21.x, 1.22.x, 1.23.x]
2820

2921
steps:
3022
- name: Set up ${{ matrix.go-version }}
@@ -50,39 +42,22 @@ jobs:
5042
strategy:
5143
fail-fast: false
5244
matrix:
53-
redis_version:
54-
- "8.0-M01"
55-
- "7.4.1"
56-
- "7.2.6"
57-
- "6.2.16"
45+
redis-version:
46+
- "8.0-M03" # 8.0 milestone 4
47+
- "7.4.2" # should use redis stack 7.4
48+
- "7.2.7" # should redis stack 7.2
5849
go-version:
59-
- "1.19.x"
60-
- "1.20.x"
61-
- "1.21.x"
50+
- "1.22.x"
51+
- "1.23.x"
6252

6353
steps:
64-
- name: Set up ${{ matrix.go-version }}
65-
uses: actions/setup-go@v5
66-
with:
67-
go-version: ${{ matrix.go-version }}
6854

6955
- name: Checkout code
7056
uses: actions/checkout@v4
71-
72-
# Set up Docker Compose environment
73-
- name: Set up Docker Compose environment
74-
run: |
75-
docker compose --profile all up -d
76-
57+
7758
- name: Run tests
78-
env:
79-
USE_CONTAINERIZED_REDIS: "true"
80-
RE_CLUSTER: "true"
81-
run: |
82-
go test \
83-
--ginkgo.skip-file="ring_test.go" \
84-
--ginkgo.skip-file="sentinel_test.go" \
85-
--ginkgo.skip-file="osscluster_test.go" \
86-
--ginkgo.skip-file="pubsub_test.go" \
87-
--ginkgo.skip-file="gears_commands_test.go" \
88-
--ginkgo.label-filter='!NonRedisEnterprise'
59+
uses: ./.github/actions/run-tests
60+
with:
61+
go-version: ${{matrix.go-version}}
62+
redis-version: ${{ matrix.redis-version }}
63+

.github/workflows/doctests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
go-version: [ "1.18", "1.19", "1.20", "1.21" ]
28+
go-version: [ "1.21", "1.22", "1.23" ]
2929

3030
steps:
3131
- name: Set up ${{ matrix.go-version }}

.github/workflows/test-redis-enterprise.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
go-version: [1.21.x]
18+
go-version: [1.23.x]
1919
re-build: ["7.4.2-54"]
2020

2121
steps:
@@ -46,8 +46,8 @@ jobs:
4646

4747
- name: Test
4848
env:
49-
RE_CLUSTER: "1"
50-
USE_CONTAINERIZED_REDIS: "1"
49+
RE_CLUSTER: true
50+
REDIS_MAJOR_VERSION: 7
5151
run: |
5252
go test \
5353
--ginkgo.skip-file="ring_test.go" \

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
dockers/
21
*.rdb
32
testdata/*
43
.idea/

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
2+
export REDIS_MAJOR_VERSION := 7
23

34
test: testdeps
5+
docker start go-redis-redis-stack || docker run -d --name go-redis-redis-stack -p 6379:6379 -e REDIS_ARGS="--enable-debug-command yes --enable-module-command yes" redis/redis-stack-server:latest
46
$(eval GO_VERSION := $(shell go version | cut -d " " -f 3 | cut -d. -f2))
57
set -e; for dir in $(GO_MOD_DIRS); do \
68
if echo "$${dir}" | grep -q "./example" && [ "$(GO_VERSION)" = "19" ]; then \
@@ -19,6 +21,7 @@ test: testdeps
1921
done
2022
cd internal/customvet && go build .
2123
go vet -vettool ./internal/customvet/customvet
24+
docker stop go-redis-redis-stack
2225

2326
testdeps: testdata/redis/src/redis-server
2427

@@ -32,7 +35,7 @@ build:
3235

3336
testdata/redis:
3437
mkdir -p $@
35-
wget -qO- https://download.redis.io/releases/redis-7.4-rc2.tar.gz | tar xvz --strip-components=1 -C $@
38+
wget -qO- https://download.redis.io/releases/redis-7.4.2.tar.gz | tar xvz --strip-components=1 -C $@
3639

3740
testdata/redis/src/redis-server: testdata/redis
3841
cd $< && make all

bench_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func BenchmarkXRead(b *testing.B) {
277277

278278
func newClusterScenario() *clusterScenario {
279279
return &clusterScenario{
280-
ports: []string{"8220", "8221", "8222", "8223", "8224", "8225"},
280+
ports: []string{"16600", "16601", "16602", "16603", "16604", "16605"},
281281
nodeIDs: make([]string, 6),
282282
processes: make(map[string]*redisProcess, 6),
283283
clients: make(map[string]*redis.Client, 6),

commands_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ var _ = Describe("Commands", func() {
441441
It("should Command", Label("NonRedisEnterprise"), func() {
442442
cmds, err := client.Command(ctx).Result()
443443
Expect(err).NotTo(HaveOccurred())
444-
Expect(len(cmds)).To(BeNumerically("~", 240, 25))
445444

446445
cmd := cmds["mget"]
447446
Expect(cmd.Name).To(Equal("mget"))

docker-compose.yml

Lines changed: 125 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,140 @@
11
---
22

33
services:
4-
5-
redis-stanalone:
6-
image: redislabs/client-libs-test:8.0-M02
4+
redis:
5+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:7.4.1}
76
container_name: redis-standalone
87
environment:
8+
- TLS_ENABLED=yes
99
- REDIS_CLUSTER=no
1010
- PORT=6379
1111
- TLS_PORT=6666
12-
12+
command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --enable-module-command yes --tls-auth-clients optional --save ""}
1313
ports:
1414
- 6379:6379
15-
- 6380:6379
1615
- 6666:6666 # TLS port
1716
volumes:
18-
- "./dockers/redis-standalone:/redis/work"
17+
- "./dockers/standalone:/redis/work"
1918
profiles:
2019
- standalone
20+
- sentinel
21+
- all-stack
22+
- all
23+
24+
cluster:
25+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:7.4.1}
26+
container_name: redis-cluster
27+
environment:
28+
- NODES=6
29+
- PORT=16600
30+
command: "--cluster-enabled yes"
31+
ports:
32+
- "16600-16605:16600-16605"
33+
volumes:
34+
- "./dockers/cluster:/redis/work"
35+
profiles:
36+
- cluster
37+
- all-stack
38+
- all
39+
40+
sentinel:
41+
image: ${REDIS_IMAGE:-redis:7.4.1}
42+
container_name: redis-sentinel
43+
depends_on:
44+
- redis
45+
entrypoint: "redis-sentinel /redis.conf --port 26379"
46+
ports:
47+
- 26379:26379
48+
volumes:
49+
- "./dockers/sentinel.conf:/redis.conf"
50+
profiles:
51+
- sentinel
52+
- all-stack
2153
- all
54+
55+
sentinel2:
56+
image: ${REDIS_IMAGE:-redis:7.4.1}
57+
container_name: redis-sentinel2
58+
depends_on:
59+
- redis
60+
entrypoint: "redis-sentinel /redis.conf --port 26380"
61+
ports:
62+
- 26380:26380
63+
volumes:
64+
- "./dockers/sentinel.conf:/redis.conf"
65+
profiles:
66+
- sentinel
67+
- all-stack
68+
- all
69+
70+
sentinel3:
71+
image: ${REDIS_IMAGE:-redis:7.4.1}
72+
container_name: redis-sentinel3
73+
depends_on:
74+
- redis
75+
entrypoint: "redis-sentinel /redis.conf --port 26381"
76+
ports:
77+
- 26381:26381
78+
volumes:
79+
- "./dockers/sentinel.conf:/redis.conf"
80+
profiles:
81+
- sentinel
82+
- all-stack
83+
- all
84+
85+
redisRing1:
86+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:7.4.1}
87+
container_name: redis-ring-1
88+
environment:
89+
- TLS_ENABLED=yes
90+
- REDIS_CLUSTER=no
91+
- PORT=6390
92+
command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --enable-module-command yes --tls-auth-clients optional --save ""}
93+
ports:
94+
- 6390:6390
95+
volumes:
96+
- "./dockers/ring1:/redis/work"
97+
profiles:
98+
- ring
99+
- cluster
100+
- sentinel
101+
- all-stack
102+
- all
103+
104+
redisRing2:
105+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:7.4.1}
106+
container_name: redis-ring-2
107+
environment:
108+
- TLS_ENABLED=yes
109+
- REDIS_CLUSTER=no
110+
- PORT=6391
111+
command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --enable-module-command yes --tls-auth-clients optional --save ""}
112+
ports:
113+
- 6391:6391
114+
volumes:
115+
- "./dockers/ring2:/redis/work"
116+
profiles:
117+
- ring
118+
- cluster
119+
- sentinel
120+
- all-stack
121+
- all
122+
123+
redisRing3:
124+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:7.4.1}
125+
container_name: redis-ring-3
126+
environment:
127+
- TLS_ENABLED=yes
128+
- REDIS_CLUSTER=no
129+
- PORT=6392
130+
command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --enable-module-command yes --tls-auth-clients optional --save ""}
131+
ports:
132+
- 6392:6392
133+
volumes:
134+
- "./dockers/ring3:/redis/work"
135+
profiles:
136+
- ring
137+
- cluster
138+
- sentinel
139+
- all-stack
140+
- all

dockers/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*/

dockers/sentinel.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sentinel resolve-hostnames yes
2+
sentinel monitor go-redis-test redis 6379 2
3+
sentinel down-after-milliseconds go-redis-test 5000
4+
sentinel failover-timeout go-redis-test 60000
5+
sentinel parallel-syncs go-redis-test 1

0 commit comments

Comments
 (0)