Skip to content

Commit 6c78cea

Browse files
committed
wip: increase timeout, focus only sentinel tests
1 parent 6d277a4 commit 6c78cea

File tree

4 files changed

+24
-71
lines changed

4 files changed

+24
-71
lines changed

bench_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,9 @@ func BenchmarkXRead(b *testing.B) {
277277

278278
func newClusterScenario() *clusterScenario {
279279
return &clusterScenario{
280-
ports: []string{"16600", "16601", "16602", "16603", "16604", "16605"},
281-
nodeIDs: make([]string, 6),
282-
processes: make(map[string]*redisProcess, 6),
283-
clients: make(map[string]*redis.Client, 6),
280+
ports: []string{"16600", "16601", "16602", "16603", "16604", "16605"},
281+
nodeIDs: make([]string, 6),
282+
clients: make(map[string]*redis.Client, 6),
284283
}
285284
}
286285

main_test.go

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"net"
66
"os"
7-
"path/filepath"
87
"strconv"
98
"strings"
109
"sync"
@@ -308,50 +307,6 @@ func connectTo(port string) (*redis.Client, error) {
308307
return client, nil
309308
}
310309

311-
type redisProcess struct {
312-
*os.Process
313-
*redis.Client
314-
}
315-
316-
func (p *redisProcess) Close() error {
317-
if err := p.Kill(); err != nil {
318-
return err
319-
}
320-
321-
err := eventually(func() error {
322-
if err := p.Client.Ping(ctx).Err(); err != nil {
323-
return nil
324-
}
325-
return fmt.Errorf("client %s is not shutdown", p.Options().Addr)
326-
}, 10*time.Second)
327-
if err != nil {
328-
return err
329-
}
330-
331-
p.Client.Close()
332-
return nil
333-
}
334-
335-
var (
336-
redisServerBin, _ = filepath.Abs(filepath.Join("testdata", "redis", "src", "redis-server"))
337-
redisServerConf, _ = filepath.Abs(filepath.Join("testdata", "redis", "redis.conf"))
338-
redisSentinelConf, _ = filepath.Abs(filepath.Join("testdata", "redis", "sentinel.conf"))
339-
)
340-
341-
func redisDir(port string) (string, error) {
342-
dir, err := filepath.Abs(filepath.Join("testdata", "instances", port))
343-
if err != nil {
344-
return "", err
345-
}
346-
if err := os.RemoveAll(dir); err != nil {
347-
return "", err
348-
}
349-
if err := os.MkdirAll(dir, 0o775); err != nil {
350-
return "", err
351-
}
352-
return dir, nil
353-
}
354-
355310
func startSentinel(port, masterName, masterPort string) (*redis.Client, error) {
356311
client, err := connectTo(port)
357312
if err != nil {

osscluster_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ import (
2020
)
2121

2222
type clusterScenario struct {
23-
ports []string
24-
nodeIDs []string
25-
processes map[string]*redisProcess
26-
clients map[string]*redis.Client
23+
ports []string
24+
nodeIDs []string
25+
clients map[string]*redis.Client
2726
}
2827

2928
func (s *clusterScenario) slots() []int {
@@ -197,7 +196,7 @@ func configureClusterTopology(ctx context.Context, scenario *clusterScenario) er
197196
return err
198197
}
199198
return assertSlotsEqual(res, wanted)
200-
}, 60*time.Second)
199+
}, 2*time.Minute)
201200
if err != nil {
202201
return err
203202
}

sentinel_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/redis/go-redis/v9"
1010
)
1111

12-
var _ = Describe("Sentinel", func() {
12+
var _ = FDescribe("Sentinel", func() {
1313
var _ = Describe("Sentinel PROTO 2", func() {
1414
var client *redis.Client
1515
BeforeEach(func() {
@@ -63,13 +63,13 @@ var _ = Describe("Sentinel", func() {
6363
// Wait until slaves are picked up by sentinel.
6464
Eventually(func() string {
6565
return sentinel1.Info(ctx).Val()
66-
}, "15s", "100ms").Should(ContainSubstring("slaves=2"))
66+
}, "30s", "100ms").Should(ContainSubstring("slaves=2"))
6767
Eventually(func() string {
6868
return sentinel2.Info(ctx).Val()
69-
}, "15s", "100ms").Should(ContainSubstring("slaves=2"))
69+
}, "30s", "100ms").Should(ContainSubstring("slaves=2"))
7070
Eventually(func() string {
7171
return sentinel3.Info(ctx).Val()
72-
}, "15s", "100ms").Should(ContainSubstring("slaves=2"))
72+
}, "30s", "100ms").Should(ContainSubstring("slaves=2"))
7373
})
7474

7575
AfterEach(func() {
@@ -93,7 +93,7 @@ var _ = Describe("Sentinel", func() {
9393
Eventually(func() []string {
9494
slavesAddr = redis.GetSlavesAddrByName(ctx, sentinel, sentinelName)
9595
return slavesAddr
96-
}, "15s", "100ms").Should(HaveLen(2))
96+
}, "30s", "100ms").Should(HaveLen(2))
9797
Eventually(func() bool {
9898
sync := true
9999
for _, addr := range slavesAddr {
@@ -105,7 +105,7 @@ var _ = Describe("Sentinel", func() {
105105
_ = slave.Close()
106106
}
107107
return sync
108-
}, "15s", "100ms").Should(BeTrue())
108+
}, "30s", "100ms").Should(BeTrue())
109109

110110
// Create subscription.
111111
pub := client.Subscribe(ctx, "foo")
@@ -116,19 +116,19 @@ var _ = Describe("Sentinel", func() {
116116
Expect(err).NotTo(HaveOccurred())
117117
Eventually(func() error {
118118
return master.Ping(ctx).Err()
119-
}, "15s", "100ms").Should(HaveOccurred())
119+
}, "30s", "100ms").Should(HaveOccurred())
120120

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

126126
// Check if subscription is renewed.
127127
var msg *redis.Message
128128
Eventually(func() <-chan *redis.Message {
129129
_ = client.Publish(ctx, "foo", "hello").Err()
130130
return ch
131-
}, "15s", "100ms").Should(Receive(&msg))
131+
}, "30s", "100ms").Should(Receive(&msg))
132132
Expect(msg.Channel).To(Equal("foo"))
133133
Expect(msg.Payload).To(Equal("hello"))
134134
Expect(pub.Close()).NotTo(HaveOccurred())
@@ -218,13 +218,13 @@ var _ = Describe("Sentinel", func() {
218218
// Wait until slaves are picked up by sentinel.
219219
Eventually(func() string {
220220
return sentinel1.Info(ctx).Val()
221-
}, "15s", "100ms").Should(ContainSubstring("slaves=2"))
221+
}, "30s", "100ms").Should(ContainSubstring("slaves=2"))
222222
Eventually(func() string {
223223
return sentinel2.Info(ctx).Val()
224-
}, "15s", "100ms").Should(ContainSubstring("slaves=2"))
224+
}, "30s", "100ms").Should(ContainSubstring("slaves=2"))
225225
Eventually(func() string {
226226
return sentinel3.Info(ctx).Val()
227-
}, "15s", "100ms").Should(ContainSubstring("slaves=2"))
227+
}, "30s", "100ms").Should(ContainSubstring("slaves=2"))
228228
})
229229

230230
AfterEach(func() {
@@ -241,7 +241,7 @@ var _ = Describe("Sentinel", func() {
241241
// Verify.
242242
Eventually(func() string {
243243
return client.Get(ctx, "foo").Val()
244-
}, "15s", "1ms").Should(Equal("master"))
244+
}, "30s", "1ms").Should(Equal("master"))
245245
}
246246

247247
// Create subscription.
@@ -253,19 +253,19 @@ var _ = Describe("Sentinel", func() {
253253
Expect(err).NotTo(HaveOccurred())
254254
Eventually(func() error {
255255
return master.Ping(ctx).Err()
256-
}, "15s", "100ms").Should(HaveOccurred())
256+
}, "30s", "100ms").Should(HaveOccurred())
257257

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

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

0 commit comments

Comments
 (0)