Skip to content

Commit a2c85f9

Browse files
committed
Enable osscluster tests in CI
1 parent d5d0f27 commit a2c85f9

File tree

14 files changed

+278
-138
lines changed

14 files changed

+278
-138
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ runs:
3838
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
3939
echo "REDIS_IMAGE=redis:${{ inputs.redis-version }}" >> $GITHUB_ENV
4040
echo "CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:${redis_version_mapping[$REDIS_VERSION]}" >> $GITHUB_ENV
41-
echo "REDIS_MOD_URL=redis://127.0.0.1:6479/0" >> $GITHUB_ENV
4241
else
4342
echo "Version not found in the mapping."
4443
exit 1
@@ -50,14 +49,15 @@ runs:
5049
shell: bash
5150
- name: Run tests
5251
env:
53-
USE_CONTAINERIZED_REDIS: "true"
54-
RE_CLUSTER: "true"
52+
RCE_DOCKER: "true"
53+
RE_CLUSTER: "false"
5554
run: |
55+
set -e
56+
redis_major_version=$(echo "$REDIS_VERSION" | grep -oP '^\d+')
5657
go test \
5758
--ginkgo.skip-file="ring_test.go" \
5859
--ginkgo.skip-file="sentinel_test.go" \
59-
--ginkgo.skip-file="osscluster_test.go" \
6060
--ginkgo.skip-file="pubsub_test.go" \
6161
--ginkgo.skip-file="gears_commands_test.go" \
62-
--ginkgo.label-filter='!NonRedisEnterprise'
62+
--ginkgo.label-filter="!NonRedisEnterprise && RedisVersion: isSubsetOf {$redis_major_version}"
6363
shell: bash

.github/workflows/build.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ jobs:
1818
matrix:
1919
go-version: [1.21.x, 1.22.x, 1.23.x]
2020

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
28-
2921
steps:
3022
- name: Set up ${{ matrix.go-version }}
3123
uses: actions/setup-go@v5

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ jobs:
4747
- name: Test
4848
env:
4949
RE_CLUSTER: true
50-
USE_CONTAINERIZED_REDIS: true
5150
run: |
5251
go test \
5352
--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: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
2+
REDIS_VERSION="7.4.2"
23

34
test: testdeps
5+
$(eval R_MAJOR := $(shell echo "$(REDIS_VERSION)" | grep -o '\d' | head -1))
6+
echo "Executing test agains redis-stack-server:latest and redis $(REDIS_VERSION), $(R_MAJOR) "
7+
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
48
$(eval GO_VERSION := $(shell go version | cut -d " " -f 3 | cut -d. -f2))
59
set -e; for dir in $(GO_MOD_DIRS); do \
610
if echo "$${dir}" | grep -q "./example" && [ "$(GO_VERSION)" = "19" ]; then \
@@ -10,7 +14,7 @@ test: testdeps
1014
echo "go test in $${dir}"; \
1115
(cd "$${dir}" && \
1216
go mod tidy -compat=1.18 && \
13-
go test && \
17+
go test --ginkgo.label-filter="RedisVersion: isSubsetOf \"$(R_MAJOR)\""&& \
1418
go test ./... -short -race && \
1519
go test ./... -run=NONE -bench=. -benchmem && \
1620
env GOOS=linux GOARCH=386 go test && \
@@ -19,9 +23,12 @@ test: testdeps
1923
done
2024
cd internal/customvet && go build .
2125
go vet -vettool ./internal/customvet/customvet
26+
docker stop (docker container ls -a -q --filter name=go-redis-redis-stack)
2227

2328
testdeps: testdata/redis/src/redis-server
2429

30+
31+
2532
bench: testdeps
2633
go test ./... -test.run=NONE -test.bench=. -test.benchmem
2734

@@ -32,7 +39,7 @@ build:
3239

3340
testdata/redis:
3441
mkdir -p $@
35-
wget -qO- https://download.redis.io/releases/redis-7.4-rc2.tar.gz | tar xvz --strip-components=1 -C $@
42+
wget -qO- https://download.redis.io/releases/redis-7.4.2.tar.gz | tar xvz --strip-components=1 -C $@
3643

3744
testdata/redis/src/redis-server: testdata/redis
3845
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: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22

33
services:
4-
54
redis:
65
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:7.4.1}
76
container_name: redis-standalone
@@ -26,16 +25,11 @@ services:
2625
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:7.4.1}
2726
container_name: redis-cluster
2827
environment:
29-
- REDIS_CLUSTER=yes
3028
- NODES=6
31-
- REPLICAS=1
32-
- TLS_ENABLED=yes
33-
- PORT=16379
34-
- TLS_PORT=27379
35-
command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --enable-module-command yes --tls-auth-clients optional --save ""}
29+
- PORT=16600
30+
command: "--cluster-enabled yes"
3631
ports:
37-
- "16379-16384:16379-16384"
38-
- "27379-27384:27379-27384"
32+
- "16600-16605:16600-16605"
3933
volumes:
4034
- "./dockers/cluster:/redis/work"
4135
profiles:
@@ -84,6 +78,63 @@ services:
8478
volumes:
8579
- "./dockers/sentinel.conf:/redis.conf"
8680
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
87138
- sentinel
88139
- all-stack
89140
- all

dockers/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
redis-standalone
1+
*/

main_test.go

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
. "github.com/bsm/ginkgo/v2"
1515
. "github.com/bsm/gomega"
16-
1716
"github.com/redis/go-redis/v9"
1817
)
1918

@@ -28,7 +27,7 @@ const (
2827
)
2928

3029
const (
31-
sentinelName = "mymaster"
30+
sentinelName = "go-redis-test"
3231
sentinelMasterPort = "9123"
3332
sentinelSlave1Port = "9124"
3433
sentinelSlave2Port = "9125"
@@ -43,8 +42,8 @@ var (
4342
)
4443

4544
var (
46-
rediStackPort = "6379"
47-
rediStackAddr = ":" + rediStackPort
45+
redisStackPort = "6379"
46+
redisStackAddr = ":" + redisStackPort
4847
)
4948

5049
var (
@@ -59,14 +58,17 @@ var (
5958
)
6059

6160
var cluster = &clusterScenario{
62-
ports: []string{"8220", "8221", "8222", "8223", "8224", "8225"},
61+
ports: []string{"16600", "16601", "16602", "16603", "16604", "16605"},
6362
nodeIDs: make([]string, 6),
6463
processes: make(map[string]*redisProcess, 6),
6564
clients: make(map[string]*redis.Client, 6),
6665
}
6766

67+
// Redis Software Cluster
6868
var RECluster = false
69-
var USE_CONTAINERIZED_REDIS = false
69+
70+
// Redis Community Edition Docker
71+
var RCEDocker = false
7072

7173
func registerProcess(port string, p *redisProcess) {
7274
if processes == nil {
@@ -83,8 +85,10 @@ var _ = BeforeSuite(func() {
8385
}
8486
var err error
8587
RECluster, _ = strconv.ParseBool(os.Getenv("RE_CLUSTER"))
86-
USE_CONTAINERIZED_REDIS, _ = strconv.ParseBool(os.Getenv("USE_CONTAINERIZED_REDIS"))
87-
if !RECluster || !USE_CONTAINERIZED_REDIS {
88+
RCEDocker, _ = strconv.ParseBool(os.Getenv("RCE_DOCKER"))
89+
fmt.Printf("RECluster: %v\n", RECluster)
90+
fmt.Printf("RCEDocker: %v\n", RCEDocker)
91+
if !RECluster && !RCEDocker {
8892

8993
redisMain, err = startRedis(redisPort)
9094
Expect(err).NotTo(HaveOccurred())
@@ -121,18 +125,24 @@ var _ = BeforeSuite(func() {
121125
err = startCluster(ctx, cluster)
122126
Expect(err).NotTo(HaveOccurred())
123127
} else {
124-
redisPort = rediStackPort
125-
redisAddr = rediStackAddr
128+
redisPort = redisStackPort
129+
redisAddr = redisStackAddr
130+
131+
if !RECluster {
132+
// populate cluster node information
133+
Expect(configureClusterTopology(ctx, cluster)).NotTo(HaveOccurred())
134+
}
126135
}
127136
})
128137

129138
var _ = AfterSuite(func() {
130139
if !RECluster {
131140
Expect(cluster.Close()).NotTo(HaveOccurred())
141+
}
132142

133-
for _, p := range processes {
134-
Expect(p.Close()).NotTo(HaveOccurred())
135-
}
143+
// NOOP if there are no processes registered
144+
for _, p := range processes {
145+
Expect(p.Close()).NotTo(HaveOccurred())
136146
}
137147
processes = nil
138148
})
@@ -156,8 +166,8 @@ func redisOptions() *redis.Options {
156166
ContextTimeoutEnabled: true,
157167

158168
MaxRetries: -1,
159-
PoolSize: 10,
160169

170+
PoolSize: 10,
161171
PoolTimeout: 30 * time.Second,
162172
ConnMaxIdleTime: time.Minute,
163173
}

0 commit comments

Comments
 (0)