Skip to content

Commit 7c498dc

Browse files
committed
tidy docker compose
1 parent 5961017 commit 7c498dc

File tree

9 files changed

+30
-74
lines changed

9 files changed

+30
-74
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ runs:
4040
fi
4141
shell: bash
4242
- name: Set up Docker Compose environment with redis ${{ inputs.redis-version }}
43-
run: docker compose --profile all up -d
43+
run: |
44+
make docker.start
4445
shell: bash
4546
- name: Run tests
4647
env:

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ jobs:
5656
fi
5757
shell: bash
5858
- name: Set up Docker Compose environment with redis ${{ matrix.redis-version }}
59-
run: docker compose --profile all up -d
59+
run: make docker.start
6060
shell: bash
6161
- name: Benchmark Tests
6262
env:
6363
RCE_DOCKER: "true"
6464
RE_CLUSTER: "false"
6565
run: make bench
66+
shell: bash
6667

6768
test-redis-ce:
6869
name: test-redis-ce

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
22

33
docker.start:
4-
docker compose --profile all up -d
4+
docker compose --profile all up -d --quiet-pull
55

66
docker.stop:
77
docker compose --profile all down

docker-compose.yml

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ services:
6262
depends_on:
6363
- sentinel-cluster
6464
environment:
65-
- REDIS_CLUSTER=no
6665
- NODES=3
66+
- REDIS_CLUSTER=no
6767
- PORT=26379
6868
command: ${REDIS_EXTRA_ARGS:---sentinel}
6969
network_mode: "host"
@@ -79,61 +79,23 @@ services:
7979
- all-stack
8080
- all
8181

82-
83-
84-
redisRing1:
82+
ring-cluster:
8583
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
86-
container_name: redis-ring-1
84+
container_name: redis-ring-cluster
8785
environment:
86+
- NODES=3
8887
- TLS_ENABLED=yes
8988
- REDIS_CLUSTER=no
9089
- PORT=6390
9190
command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --enable-module-command yes --tls-auth-clients optional --save ""}
9291
ports:
9392
- 6390:6390
94-
volumes:
95-
- "./dockers/ring1:/redis/work"
96-
profiles:
97-
- ring
98-
- cluster
99-
- sentinel
100-
- all-stack
101-
- all
102-
103-
redisRing2:
104-
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
105-
container_name: redis-ring-2
106-
environment:
107-
- TLS_ENABLED=yes
108-
- REDIS_CLUSTER=no
109-
- PORT=6391
110-
command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --enable-module-command yes --tls-auth-clients optional --save ""}
111-
ports:
11293
- 6391:6391
113-
volumes:
114-
- "./dockers/ring2:/redis/work"
115-
profiles:
116-
- ring
117-
- cluster
118-
- sentinel
119-
- all-stack
120-
- all
121-
122-
redisRing3:
123-
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
124-
container_name: redis-ring-3
125-
environment:
126-
- TLS_ENABLED=yes
127-
- REDIS_CLUSTER=no
128-
- PORT=6392
129-
command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --enable-module-command yes --tls-auth-clients optional --save ""}
130-
ports:
13194
- 6392:6392
13295
volumes:
133-
- "./dockers/ring3:/redis/work"
96+
- "./dockers/ring:/redis/work"
13497
profiles:
13598
- ring
13699
- cluster
137-
- sentinel
138100
- all-stack
139101
- all

dockers/.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
osscluster/
2-
ring1/
3-
ring2/
4-
ring3/
2+
ring/
53
standalone/
64
sentinel-cluster/
75
sentinel/

dockers/sentinel.conf

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

main_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var (
4646
)
4747

4848
var (
49-
sentinelAddrs = []string{"127.0.0.1:" + sentinelPort1, "127.0.0.1:" + sentinelPort2, "127.0.0.1:" + sentinelPort3}
49+
sentinelAddrs = []string{":" + sentinelPort1, ":" + sentinelPort2, ":" + sentinelPort3}
5050

5151
ringShard1, ringShard2, ringShard3 *redis.Client
5252
sentinelMaster, sentinelSlave1, sentinelSlave2 *redis.Client
@@ -313,13 +313,8 @@ func startSentinel(port, masterName, masterPort string) (*redis.Client, error) {
313313
return nil, err
314314
}
315315

316-
// set down-after-milliseconds=2000
317-
// link: https://github.com/redis/redis/issues/8607
318316
for _, cmd := range []*redis.StatusCmd{
319317
redis.NewStatusCmd(ctx, "SENTINEL", "MONITOR", masterName, "127.0.0.1", masterPort, "2"),
320-
redis.NewStatusCmd(ctx, "SENTINEL", "SET", masterName, "down-after-milliseconds", "2000"),
321-
redis.NewStatusCmd(ctx, "SENTINEL", "SET", masterName, "failover-timeout", "1000"),
322-
redis.NewStatusCmd(ctx, "SENTINEL", "SET", masterName, "parallel-syncs", "1"),
323318
} {
324319
client.Process(ctx, cmd)
325320
if err := cmd.Err(); err != nil && !strings.Contains(err.Error(), "ERR Duplicate master name.") {

sentinel_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ var _ = Describe("Sentinel", func() {
6262
// Wait until slaves are picked up by sentinel.
6363
Eventually(func() string {
6464
return sentinel1.Info(ctx).Val()
65-
}, "15s", "100ms").Should(ContainSubstring("slaves=2"))
65+
}, "20s", "100ms").Should(ContainSubstring("slaves=2"))
6666
Eventually(func() string {
6767
return sentinel2.Info(ctx).Val()
68-
}, "15s", "100ms").Should(ContainSubstring("slaves=2"))
68+
}, "20s", "100ms").Should(ContainSubstring("slaves=2"))
6969
Eventually(func() string {
7070
return sentinel3.Info(ctx).Val()
71-
}, "15s", "100ms").Should(ContainSubstring("slaves=2"))
71+
}, "20s", "100ms").Should(ContainSubstring("slaves=2"))
7272
})
7373

7474
AfterEach(func() {
@@ -92,7 +92,7 @@ var _ = Describe("Sentinel", func() {
9292
Eventually(func() []string {
9393
slavesAddr = redis.GetSlavesAddrByName(ctx, sentinel, sentinelName)
9494
return slavesAddr
95-
}, "15s", "100ms").Should(HaveLen(2))
95+
}, "20s", "50ms").Should(HaveLen(2))
9696
Eventually(func() bool {
9797
sync := true
9898
for _, addr := range slavesAddr {
@@ -104,7 +104,7 @@ var _ = Describe("Sentinel", func() {
104104
_ = slave.Close()
105105
}
106106
return sync
107-
}, "15s", "100ms").Should(BeTrue())
107+
}, "20s", "50ms").Should(BeTrue())
108108

109109
// Create subscription.
110110
pub := client.Subscribe(ctx, "foo")
@@ -115,19 +115,19 @@ var _ = Describe("Sentinel", func() {
115115
Expect(err).NotTo(HaveOccurred())
116116
Eventually(func() error {
117117
return master.Ping(ctx).Err()
118-
}, "15s", "100ms").Should(HaveOccurred())
118+
}, "20s", "50ms").Should(HaveOccurred())
119119

120120
// Check that client picked up new master.
121121
Eventually(func() string {
122122
return client.Get(ctx, "foo").Val()
123-
}, "15s", "100ms").Should(Equal("master"))
123+
}, "20s", "100ms").Should(Equal("master"))
124124

125125
// Check if subscription is renewed.
126126
var msg *redis.Message
127127
Eventually(func() <-chan *redis.Message {
128128
_ = client.Publish(ctx, "foo", "hello").Err()
129129
return ch
130-
}, "15s", "100ms").Should(Receive(&msg))
130+
}, "20s", "100ms").Should(Receive(&msg))
131131
Expect(msg.Channel).To(Equal("foo"))
132132
Expect(msg.Payload).To(Equal("hello"))
133133
Expect(pub.Close()).NotTo(HaveOccurred())
@@ -217,13 +217,13 @@ var _ = Describe("NewFailoverClusterClient", func() {
217217
// Wait until slaves are picked up by sentinel.
218218
Eventually(func() string {
219219
return sentinel1.Info(ctx).Val()
220-
}, "15s", "100ms").Should(ContainSubstring("slaves=2"))
220+
}, "20s", "100ms").Should(ContainSubstring("slaves=2"))
221221
Eventually(func() string {
222222
return sentinel2.Info(ctx).Val()
223-
}, "15s", "100ms").Should(ContainSubstring("slaves=2"))
223+
}, "20s", "100ms").Should(ContainSubstring("slaves=2"))
224224
Eventually(func() string {
225225
return sentinel3.Info(ctx).Val()
226-
}, "15s", "100ms").Should(ContainSubstring("slaves=2"))
226+
}, "20s", "100ms").Should(ContainSubstring("slaves=2"))
227227
})
228228

229229
AfterEach(func() {
@@ -240,7 +240,7 @@ var _ = Describe("NewFailoverClusterClient", func() {
240240
// Verify.
241241
Eventually(func() string {
242242
return client.Get(ctx, "foo").Val()
243-
}, "15s", "1ms").Should(Equal("master"))
243+
}, "20s", "1ms").Should(Equal("master"))
244244
}
245245

246246
// Create subscription.
@@ -252,19 +252,19 @@ var _ = Describe("NewFailoverClusterClient", func() {
252252
Expect(err).NotTo(HaveOccurred())
253253
Eventually(func() error {
254254
return master.Ping(ctx).Err()
255-
}, "15s", "100ms").Should(HaveOccurred())
255+
}, "20s", "100ms").Should(HaveOccurred())
256256

257257
// Check that client picked up new master.
258258
Eventually(func() string {
259259
return client.Get(ctx, "foo").Val()
260-
}, "15s", "100ms").Should(Equal("master"))
260+
}, "20s", "100ms").Should(Equal("master"))
261261

262262
// Check if subscription is renewed.
263263
var msg *redis.Message
264264
Eventually(func() <-chan *redis.Message {
265265
_ = client.Publish(ctx, "foo", "hello").Err()
266266
return ch
267-
}, "15s", "100ms").Should(Receive(&msg))
267+
}, "20s", "100ms").Should(Receive(&msg))
268268
Expect(msg.Channel).To(Equal("foo"))
269269
Expect(msg.Payload).To(Equal("hello"))
270270
Expect(sub.Close()).NotTo(HaveOccurred())
@@ -342,7 +342,7 @@ var _ = Describe("SentinelAclAuth", func() {
342342
for _, process := range sentinels() {
343343
Eventually(func() string {
344344
return process.Info(ctx).Val()
345-
}, "15s", "100ms").Should(ContainSubstring("sentinels=3"))
345+
}, "20s", "100ms").Should(ContainSubstring("sentinels=3"))
346346
}
347347
})
348348

universal_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ var _ = Describe("UniversalClient", func() {
1717
})
1818

1919
It("should connect to failover servers", func() {
20-
Skip("Flaky Test")
2120
client = redis.NewUniversalClient(&redis.UniversalOptions{
2221
MasterName: sentinelName,
2322
Addrs: sentinelAddrs,

0 commit comments

Comments
 (0)