Skip to content

Commit 11bdcc8

Browse files
committed
mix of makefile and action
1 parent f8f0dd5 commit 11bdcc8

12 files changed

+430
-517
lines changed

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,5 @@ runs:
4747
RCE_DOCKER: "true"
4848
RE_CLUSTER: "false"
4949
run: |
50-
go test ./... -short -race && \
51-
go test -coverprofile=coverage.txt -covermode=atomic ./... && \
50+
make test.ci
5251
shell: bash

Makefile

+13-21
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
2-
export REDIS_VERSION := "7.2"
2+
export REDIS_VERSION := "7.4"
33

4-
redisstackdocker.start:
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
4+
docker.start:
5+
docker compose --profile all up -d
66

7-
redisstackdocker.stop:
8-
docker stop go-redis-redis-stack
7+
docker.stop:
8+
docker compose --profile all down
99

10-
test: testdeps
11-
$(MAKE) redisstackdocker.start
10+
test:
11+
$(MAKE) docker.start
12+
$(MAKE) test.ci
13+
$(MAKE) docker.stop
14+
15+
test.ci:
1216
$(eval GO_VERSION := $(shell go version | cut -d " " -f 3 | cut -d. -f2))
1317
set -e; for dir in $(GO_MOD_DIRS); do \
1418
if echo "$${dir}" | grep -q "./example" && [ "$(GO_VERSION)" = "19" ]; then \
@@ -18,17 +22,12 @@ test: testdeps
1822
echo "go test in $${dir}"; \
1923
(cd "$${dir}" && \
2024
go mod tidy -compat=1.18 && \
21-
go test && \
22-
go test ./... -short -race && \
23-
env GOOS=linux GOARCH=386 go test && \
24-
go test -coverprofile=coverage.txt -covermode=atomic ./... && \
25+
go test ./... -short -race -v && \
26+
go test -v -coverprofile=coverage.txt -covermode=atomic ./... && \
2527
go vet); \
2628
done
2729
cd internal/customvet && go build .
2830
go vet -vettool ./internal/customvet/customvet
29-
$(MAKE) redisstackdocker.stop
30-
31-
testdeps: testdata/redis/src/redis-server
3231

3332
bench:
3433
go test ./... -test.run=NONE -test.bench=. -test.benchmem
@@ -38,13 +37,6 @@ bench:
3837
build:
3938
go build .
4039

41-
testdata/redis:
42-
mkdir -p $@
43-
wget -qO- https://download.redis.io/releases/redis-7.4.2.tar.gz | tar xvz --strip-components=1 -C $@
44-
45-
testdata/redis/src/redis-server: testdata/redis
46-
cd $< && make all
47-
4840
fmt:
4941
gofumpt -w ./
5042
goimports -w -local github.com/redis/go-redis ./

cluster_commands.go

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import "context"
44

55
type ClusterCmdable interface {
66
ClusterMyShardID(ctx context.Context) *StringCmd
7+
ClusterMyID(ctx context.Context) *StringCmd
78
ClusterSlots(ctx context.Context) *ClusterSlotsCmd
89
ClusterShards(ctx context.Context) *ClusterShardsCmd
910
ClusterLinks(ctx context.Context) *ClusterLinksCmd
@@ -35,6 +36,12 @@ func (c cmdable) ClusterMyShardID(ctx context.Context) *StringCmd {
3536
return cmd
3637
}
3738

39+
func (c cmdable) ClusterMyID(ctx context.Context) *StringCmd {
40+
cmd := NewStringCmd(ctx, "cluster", "myid")
41+
_ = c(ctx, cmd)
42+
return cmd
43+
}
44+
3845
func (c cmdable) ClusterSlots(ctx context.Context) *ClusterSlotsCmd {
3946
cmd := NewClusterSlotsCmd(ctx, "cluster", "slots")
4047
_ = c(ctx, cmd)

commands_test.go

+14-19
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ var _ = Describe("Commands", func() {
703703
})
704704

705705
Describe("debugging", func() {
706-
PIt("should DebugObject", func() {
706+
It("should DebugObject", func() {
707707
err := client.DebugObject(ctx, "foo").Err()
708708
Expect(err).To(MatchError("ERR no such key"))
709709

@@ -6628,14 +6628,12 @@ var _ = Describe("Commands", func() {
66286628

66296629
res, err := client.ZRangeWithScores(ctx, "result", 0, -1).Result()
66306630
Expect(err).NotTo(HaveOccurred())
6631-
Expect(res).To(ContainElement(redis.Z{
6632-
Score: 190.44242984775784,
6633-
Member: "Palermo",
6634-
}))
6635-
Expect(res).To(ContainElement(redis.Z{
6636-
Score: 56.4412578701582,
6637-
Member: "Catania",
6638-
}))
6631+
Expect(len(res)).To(Equal(2))
6632+
var palermo, catania redis.Z
6633+
Expect(res).To(ContainElement(HaveField("Member", "Palermo"), &palermo))
6634+
Expect(res).To(ContainElement(HaveField("Member", "Catania"), &catania))
6635+
Expect(palermo.Score).To(BeNumerically("~", 190, 1))
6636+
Expect(catania.Score).To(BeNumerically("~", 56, 1))
66396637
})
66406638

66416639
It("should search geo radius with options", func() {
@@ -6947,16 +6945,13 @@ var _ = Describe("Commands", func() {
69476945

69486946
v, err := client.ZRangeWithScores(ctx, "key2", 0, -1).Result()
69496947
Expect(err).NotTo(HaveOccurred())
6950-
Expect(v).To(Equal([]redis.Z{
6951-
{
6952-
Score: 56.441257870158204,
6953-
Member: "Catania",
6954-
},
6955-
{
6956-
Score: 190.44242984775784,
6957-
Member: "Palermo",
6958-
},
6959-
}))
6948+
6949+
Expect(len(v)).To(Equal(2))
6950+
var palermo, catania redis.Z
6951+
Expect(v).To(ContainElement(HaveField("Member", "Palermo"), &palermo))
6952+
Expect(v).To(ContainElement(HaveField("Member", "Catania"), &catania))
6953+
Expect(palermo.Score).To(BeNumerically("~", 190, 1))
6954+
Expect(catania.Score).To(BeNumerically("~", 56, 1))
69606955
})
69616956
})
69626957

docker-compose.yml

+35-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
services:
44
redis:
5-
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:7.4.1}
5+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
66
container_name: redis-standalone
77
environment:
88
- TLS_ENABLED=yes
@@ -21,32 +21,32 @@ services:
2121
- all-stack
2222
- all
2323

24-
cluster:
25-
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:7.4.1}
26-
container_name: redis-cluster
24+
osscluster:
25+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
26+
container_name: redis-osscluster
2727
environment:
2828
- NODES=6
2929
- PORT=16600
3030
command: "--cluster-enabled yes"
3131
ports:
3232
- "16600-16605:16600-16605"
3333
volumes:
34-
- "./dockers/cluster:/redis/work"
34+
- "./dockers/osscluster:/redis/work"
3535
profiles:
3636
- cluster
3737
- all-stack
3838
- all
3939

40-
sentinel:
40+
sentinel1:
4141
image: ${REDIS_IMAGE:-redis:7.4.1}
42-
container_name: redis-sentinel
42+
container_name: redis-sentinel1
4343
depends_on:
4444
- redis
45-
entrypoint: "redis-sentinel /redis.conf --port 26379"
45+
entrypoint: "redis-sentinel /etc/redis-conf/sentinels/sentinel1.conf --port 26379"
4646
ports:
4747
- 26379:26379
4848
volumes:
49-
- "./dockers/sentinel.conf:/redis.conf"
49+
- "./dockers:/etc/redis-conf"
5050
profiles:
5151
- sentinel
5252
- all-stack
@@ -57,11 +57,11 @@ services:
5757
container_name: redis-sentinel2
5858
depends_on:
5959
- redis
60-
entrypoint: "redis-sentinel /redis.conf --port 26380"
60+
entrypoint: "redis-sentinel /etc/redis-conf/sentinels/sentinel2.conf --port 26380"
6161
ports:
6262
- 26380:26380
6363
volumes:
64-
- "./dockers/sentinel.conf:/redis.conf"
64+
- "./dockers:/etc/redis-conf"
6565
profiles:
6666
- sentinel
6767
- all-stack
@@ -72,18 +72,36 @@ services:
7272
container_name: redis-sentinel3
7373
depends_on:
7474
- redis
75-
entrypoint: "redis-sentinel /redis.conf --port 26381"
75+
entrypoint: "redis-sentinel /etc/redis-conf/sentinels/sentinel3.conf --port 26381"
7676
ports:
7777
- 26381:26381
7878
volumes:
79-
- "./dockers/sentinel.conf:/redis.conf"
79+
- "./dockers:/etc/redis-conf"
80+
profiles:
81+
- sentinel
82+
- all-stack
83+
- all
84+
85+
sentinel-cluster:
86+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
87+
container_name: redis-sentinel-cluster
88+
environment:
89+
- NODES=3
90+
- TLS_ENABLED=yes
91+
- REDIS_CLUSTER=no
92+
- PORT=9121
93+
command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --enable-module-command yes --tls-auth-clients optional --save ""}
94+
ports:
95+
- "9121-9123:9121-9123"
96+
volumes:
97+
- "./dockers/sentinel-cluster:/redis/work"
8098
profiles:
8199
- sentinel
82100
- all-stack
83101
- all
84102

85103
redisRing1:
86-
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:7.4.1}
104+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
87105
container_name: redis-ring-1
88106
environment:
89107
- TLS_ENABLED=yes
@@ -102,7 +120,7 @@ services:
102120
- all
103121

104122
redisRing2:
105-
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:7.4.1}
123+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
106124
container_name: redis-ring-2
107125
environment:
108126
- TLS_ENABLED=yes
@@ -121,7 +139,7 @@ services:
121139
- all
122140

123141
redisRing3:
124-
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:7.4.1}
142+
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
125143
container_name: redis-ring-3
126144
environment:
127145
- TLS_ENABLED=yes
@@ -137,4 +155,4 @@ services:
137155
- cluster
138156
- sentinel
139157
- all-stack
140-
- all
158+
- all

dockers/sentinel.conf

-5
This file was deleted.

internal/pool/pool_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ var _ = Describe("race", func() {
292292
BeforeEach(func() {
293293
C, N = 10, 1000
294294
if testing.Short() {
295-
C = 4
296-
N = 100
295+
C = 2
296+
N = 50
297297
}
298298
})
299299

0 commit comments

Comments
 (0)