Skip to content

Commit 6aa7581

Browse files
committed
wip
1 parent bdb19f5 commit 6aa7581

File tree

14 files changed

+79
-56
lines changed

14 files changed

+79
-56
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ runs:
2222
run: |
2323
set -e
2424
redis_major_version=$(echo "$REDIS_VERSION" | grep -oP '^\d+')
25+
redis_version_np=$(echo "$REDIS_VERSION" | grep -oP '^\d+.\d+')
2526
if (( redis_major_version < 8 )); then
2627
echo "Using redis-stack for module tests"
2728
else
@@ -36,7 +37,7 @@ runs:
3637
)
3738
3839
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
39-
echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV
40+
echo "REDIS_VERSION=${redis_version_np}" >> $GITHUB_ENV
4041
echo "REDIS_IMAGE=redis:${{ inputs.redis-version }}" >> $GITHUB_ENV
4142
echo "CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:${redis_version_mapping[$REDIS_VERSION]}" >> $GITHUB_ENV
4243
else
@@ -58,5 +59,4 @@ runs:
5859
--ginkgo.skip-file="sentinel_test.go" \
5960
--ginkgo.skip-file="pubsub_test.go" \
6061
--ginkgo.skip-file="gears_commands_test.go" \
61-
--ginkgo.label-filter="!NonRedisEnterprise"
6262
shell: bash

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
go-version: [1.21.x, 1.22.x, 1.23.x]
19+
go-version: [1.22.x, 1.23.x]
2020

2121
steps:
2222
- name: Set up ${{ matrix.go-version }}
@@ -42,7 +42,7 @@ jobs:
4242
strategy:
4343
fail-fast: false
4444
matrix:
45-
go-version: [1.21.x, 1.23.x]
45+
go-version: [1.22.x, 1.23.x]
4646

4747
steps:
4848
- name: Set up ${{ matrix.go-version }}

.github/workflows/doctests.yaml

Lines changed: 2 additions & 2 deletions
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.21", "1.22", "1.23" ]
28+
go-version: ["1.22", "1.23"]
2929

3030
steps:
3131
- name: Set up ${{ matrix.go-version }}
@@ -38,4 +38,4 @@ jobs:
3838

3939
- name: Test doc examples
4040
working-directory: ./doctests
41-
run: go test
41+
run: go test -v

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Test
4848
env:
4949
RE_CLUSTER: true
50-
REDIS_MAJOR_VERSION: 7
50+
REDIS_VERSION: "7.4"
5151
run: |
5252
go test \
5353
--ginkgo.skip-file="ring_test.go" \

Makefile

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

44
redisstackdocker.start:
55
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

acl_commands_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ var _ = Describe("ACL permissions", Label("NonRedisEnterprise"), func() {
242242
})
243243

244244
It("set permissions for module commands", func() {
245-
SkipBeforeRedisMajor(8, "permissions for modules are supported for Redis Version >=8")
245+
SkipBeforeRedisVersion(8, "permissions for modules are supported for Redis Version >=8")
246246
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
247247
val, err := client.FTCreate(ctx, "txt", &redis.FTCreateOptions{}, &redis.FieldSchema{FieldName: "txt", FieldType: redis.SearchFieldTypeText}).Result()
248248
Expect(err).NotTo(HaveOccurred())
@@ -322,7 +322,7 @@ var _ = Describe("ACL permissions", Label("NonRedisEnterprise"), func() {
322322
})
323323

324324
It("set permissions for module categories", func() {
325-
SkipBeforeRedisMajor(8, "permissions for modules are supported for Redis Version >=8")
325+
SkipBeforeRedisVersion(8, "permissions for modules are supported for Redis Version >=8")
326326
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
327327
val, err := client.FTCreate(ctx, "txt", &redis.FTCreateOptions{}, &redis.FieldSchema{FieldName: "txt", FieldType: redis.SearchFieldTypeText}).Result()
328328
Expect(err).NotTo(HaveOccurred())
@@ -419,7 +419,7 @@ var _ = Describe("ACL Categories", func() {
419419
})
420420

421421
It("lists acl categories and subcategories with Modules", func() {
422-
SkipBeforeRedisMajor(8, "modules are included in acl for redis version >= 8")
422+
SkipBeforeRedisVersion(8, "modules are included in acl for redis version >= 8")
423423
aclTestCase := map[string]string{
424424
"search": "FT.CREATE",
425425
"bloom": "bf.add",

commands_test.go

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ var _ = Describe("Commands", func() {
194194
})
195195

196196
It("should ClientKillByFilter with MAXAGE", Label("NonRedisEnterprise"), func() {
197+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
197198
var s []string
198199
started := make(chan bool)
199200
done := make(chan bool)
@@ -345,7 +346,7 @@ var _ = Describe("Commands", func() {
345346
})
346347

347348
It("should ConfigGet Modules", func() {
348-
SkipBeforeRedisMajor(8, "Config doesn't include modules before Redis 8")
349+
SkipBeforeRedisVersion(8, "Config doesn't include modules before Redis 8")
349350
expected := map[string]string{
350351
"search-*": "search-timeout",
351352
"ts-*": "ts-retention-policy",
@@ -380,7 +381,7 @@ var _ = Describe("Commands", func() {
380381
})
381382

382383
It("should ConfigGet with Modules", Label("NonRedisEnterprise"), func() {
383-
SkipBeforeRedisMajor(8, "config get won't return modules configs before redis 8")
384+
SkipBeforeRedisVersion(8, "config get won't return modules configs before redis 8")
384385
configGet := client.ConfigGet(ctx, "*")
385386
Expect(configGet.Err()).NotTo(HaveOccurred())
386387
Expect(configGet.Val()).To(HaveKey("maxmemory"))
@@ -391,7 +392,7 @@ var _ = Describe("Commands", func() {
391392
})
392393

393394
It("should ConfigSet FT DIALECT", func() {
394-
SkipBeforeRedisMajor(8, "config doesn't include modules before Redis 8")
395+
SkipBeforeRedisVersion(8, "config doesn't include modules before Redis 8")
395396
defaultState, err := client.ConfigGet(ctx, "search-default-dialect").Result()
396397
Expect(err).NotTo(HaveOccurred())
397398

@@ -437,13 +438,13 @@ var _ = Describe("Commands", func() {
437438
})
438439

439440
It("should ConfigSet fail for ReadOnly", func() {
440-
SkipBeforeRedisMajor(8, "Config doesn't include modules before Redis 8")
441+
SkipBeforeRedisVersion(8, "Config doesn't include modules before Redis 8")
441442
_, err := client.ConfigSet(ctx, "search-max-doctablesize", "100000").Result()
442443
Expect(err).To(HaveOccurred())
443444
})
444445

445446
It("should ConfigSet Modules", func() {
446-
SkipBeforeRedisMajor(8, "Config doesn't include modules before Redis 8")
447+
SkipBeforeRedisVersion(8, "Config doesn't include modules before Redis 8")
447448
defaults := map[string]string{}
448449
expected := map[string]string{
449450
"search-timeout": "100",
@@ -484,7 +485,7 @@ var _ = Describe("Commands", func() {
484485
})
485486

486487
It("should Fail ConfigSet Modules", func() {
487-
SkipBeforeRedisMajor(8, "Config doesn't include modules before Redis 8")
488+
SkipBeforeRedisVersion(8, "Config doesn't include modules before Redis 8")
488489
expected := map[string]string{
489490
"search-timeout": "-100",
490491
"ts-retention-policy": "-10",
@@ -533,7 +534,7 @@ var _ = Describe("Commands", func() {
533534
})
534535

535536
It("should Info Modules", Label("redis.info"), func() {
536-
SkipBeforeRedisMajor(8, "modules are included in info for Redis Version >= 8")
537+
SkipBeforeRedisVersion(8, "modules are included in info for Redis Version >= 8")
537538
info := client.Info(ctx)
538539
Expect(info.Err()).NotTo(HaveOccurred())
539540
Expect(info.Val()).NotTo(BeNil())
@@ -558,7 +559,7 @@ var _ = Describe("Commands", func() {
558559
})
559560

560561
It("should InfoMap Modules", Label("redis.info"), func() {
561-
SkipBeforeRedisMajor(8, "modules are included in info for Redis Version >= 8")
562+
SkipBeforeRedisVersion(8, "modules are included in info for Redis Version >= 8")
562563
info := client.InfoMap(ctx)
563564
Expect(info.Err()).NotTo(HaveOccurred())
564565
Expect(info.Val()).NotTo(BeNil())
@@ -2625,6 +2626,7 @@ var _ = Describe("Commands", func() {
26252626
})
26262627

26272628
It("should HExpire", Label("hash-expiration", "NonRedisEnterprise"), func() {
2629+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
26282630
res, err := client.HExpire(ctx, "no_such_key", 10*time.Second, "field1", "field2", "field3").Result()
26292631
Expect(err).To(BeNil())
26302632
Expect(res).To(BeEquivalentTo([]int64{-2, -2, -2}))
@@ -2640,6 +2642,7 @@ var _ = Describe("Commands", func() {
26402642
})
26412643

26422644
It("should HPExpire", Label("hash-expiration", "NonRedisEnterprise"), func() {
2645+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
26432646
res, err := client.HPExpire(ctx, "no_such_key", 10*time.Second, "field1", "field2", "field3").Result()
26442647
Expect(err).To(BeNil())
26452648
Expect(res).To(BeEquivalentTo([]int64{-2, -2, -2}))
@@ -2655,6 +2658,7 @@ var _ = Describe("Commands", func() {
26552658
})
26562659

26572660
It("should HExpireAt", Label("hash-expiration", "NonRedisEnterprise"), func() {
2661+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
26582662
resEmpty, err := client.HExpireAt(ctx, "no_such_key", time.Now().Add(10*time.Second), "field1", "field2", "field3").Result()
26592663
Expect(err).To(BeNil())
26602664
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
@@ -2670,6 +2674,7 @@ var _ = Describe("Commands", func() {
26702674
})
26712675

26722676
It("should HPExpireAt", Label("hash-expiration", "NonRedisEnterprise"), func() {
2677+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
26732678
resEmpty, err := client.HPExpireAt(ctx, "no_such_key", time.Now().Add(10*time.Second), "field1", "field2", "field3").Result()
26742679
Expect(err).To(BeNil())
26752680
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
@@ -2685,6 +2690,7 @@ var _ = Describe("Commands", func() {
26852690
})
26862691

26872692
It("should HPersist", Label("hash-expiration", "NonRedisEnterprise"), func() {
2693+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
26882694
resEmpty, err := client.HPersist(ctx, "no_such_key", "field1", "field2", "field3").Result()
26892695
Expect(err).To(BeNil())
26902696
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
@@ -2708,6 +2714,7 @@ var _ = Describe("Commands", func() {
27082714
})
27092715

27102716
It("should HExpireTime", Label("hash-expiration", "NonRedisEnterprise"), func() {
2717+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
27112718
resEmpty, err := client.HExpireTime(ctx, "no_such_key", "field1", "field2", "field3").Result()
27122719
Expect(err).To(BeNil())
27132720
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
@@ -2727,6 +2734,7 @@ var _ = Describe("Commands", func() {
27272734
})
27282735

27292736
It("should HPExpireTime", Label("hash-expiration", "NonRedisEnterprise"), func() {
2737+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
27302738
resEmpty, err := client.HPExpireTime(ctx, "no_such_key", "field1", "field2", "field3").Result()
27312739
Expect(err).To(BeNil())
27322740
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
@@ -2747,6 +2755,7 @@ var _ = Describe("Commands", func() {
27472755
})
27482756

27492757
It("should HTTL", Label("hash-expiration", "NonRedisEnterprise"), func() {
2758+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
27502759
resEmpty, err := client.HTTL(ctx, "no_such_key", "field1", "field2", "field3").Result()
27512760
Expect(err).To(BeNil())
27522761
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
@@ -2766,6 +2775,7 @@ var _ = Describe("Commands", func() {
27662775
})
27672776

27682777
It("should HPTTL", Label("hash-expiration", "NonRedisEnterprise"), func() {
2778+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
27692779
resEmpty, err := client.HPTTL(ctx, "no_such_key", "field1", "field2", "field3").Result()
27702780
Expect(err).To(BeNil())
27712781
Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2}))
@@ -6040,6 +6050,7 @@ var _ = Describe("Commands", func() {
60406050
})
60416051

60426052
It("should XRead LastEntry", Label("NonRedisEnterprise"), func() {
6053+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
60436054
res, err := client.XRead(ctx, &redis.XReadArgs{
60446055
Streams: []string{"stream"},
60456056
Count: 2, // we expect 1 message
@@ -6057,6 +6068,7 @@ var _ = Describe("Commands", func() {
60576068
})
60586069

60596070
It("should XRead LastEntry from two streams", Label("NonRedisEnterprise"), func() {
6071+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
60606072
res, err := client.XRead(ctx, &redis.XReadArgs{
60616073
Streams: []string{"stream", "stream"},
60626074
ID: "+",
@@ -6079,6 +6091,7 @@ var _ = Describe("Commands", func() {
60796091
})
60806092

60816093
It("should XRead LastEntry blocks", Label("NonRedisEnterprise"), func() {
6094+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
60826095
start := time.Now()
60836096
go func() {
60846097
defer GinkgoRecover()
@@ -7332,6 +7345,7 @@ var _ = Describe("Commands", func() {
73327345
})
73337346

73347347
It("Shows function stats", func() {
7348+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
73357349
defer client.FunctionKill(ctx)
73367350

73377351
// We can not run blocking commands in Redis functions, so we're using an infinite loop,

iterator_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ var _ = Describe("ScanIterator", func() {
8585
})
8686

8787
It("should hscan across multiple pages", func() {
88+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
8889
Expect(hashSeed(71)).NotTo(HaveOccurred())
8990

9091
var vals []string
@@ -100,6 +101,7 @@ var _ = Describe("ScanIterator", func() {
100101
})
101102

102103
It("should hscan without values across multiple pages", Label("NonRedisEnterprise"), func() {
104+
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
103105
Expect(hashSeed(71)).NotTo(HaveOccurred())
104106

105107
var vals []string

main_test.go

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,20 @@ var RECluster = false
7070
// Redis Community Edition Docker
7171
var RCEDocker = false
7272

73-
// Notes the major version of redis we are executing tests.
73+
// Notes version of redis we are executing tests against.
7474
// This can be used before we change the bsm fork of ginkgo for one,
75-
// which have support for label sets, so we can filter tests per redis major version.
76-
var RedisMajorVersion = 7
75+
// which have support for label sets, so we can filter tests per redis version.
76+
var RedisVersion float64 = 7.2
7777

78-
func SkipBeforeRedisMajor(version int, msg string) {
79-
if RedisMajorVersion < version {
80-
Skip(fmt.Sprintf("(redis major version < %d) %s", version, msg))
78+
func SkipBeforeRedisVersion(version float64, msg string) {
79+
if RedisVersion < version {
80+
Skip(fmt.Sprintf("(redis version < %f) %s", version, msg))
8181
}
8282
}
8383

84-
func SkipAfterRedisMajor(version int, msg string) {
85-
if RedisMajorVersion > version {
86-
Skip(fmt.Sprintf("(redis major version > %d) %s", version, msg))
84+
func SkipAfterRedisVersion(version float64, msg string) {
85+
if RedisVersion > version {
86+
Skip(fmt.Sprintf("(redis version > %f) %s", version, msg))
8787
}
8888
}
8989

@@ -104,18 +104,18 @@ var _ = BeforeSuite(func() {
104104
RECluster, _ = strconv.ParseBool(os.Getenv("RE_CLUSTER"))
105105
RCEDocker, _ = strconv.ParseBool(os.Getenv("RCE_DOCKER"))
106106

107-
RedisMajorVersion, _ = strconv.Atoi(os.Getenv("REDIS_MAJOR_VERSION"))
107+
RedisVersion, _ = strconv.ParseFloat(os.Getenv("REDIS_VERSION"), 64)
108108

109-
if RedisMajorVersion == 0 {
110-
RedisMajorVersion = 7
109+
if RedisVersion == 0 {
110+
RedisVersion = 7.2
111111
}
112112

113113
fmt.Printf("RECluster: %v\n", RECluster)
114114
fmt.Printf("RCEDocker: %v\n", RCEDocker)
115-
fmt.Printf("REDIS_MAJOR_VERSION: %v\n", RedisMajorVersion)
115+
fmt.Printf("REDIS_VERSION: %v\n", RedisVersion)
116116

117-
if RedisMajorVersion < 6 || RedisMajorVersion > 8 {
118-
panic("incorrect or not supported redis major version")
117+
if RedisVersion < 7.0 || RedisVersion > 9 {
118+
panic("incorrect or not supported redis version")
119119
}
120120

121121
if !RECluster && !RCEDocker {
@@ -204,7 +204,7 @@ func redisOptions() *redis.Options {
204204
}
205205
return &redis.Options{
206206
Addr: redisAddr,
207-
DB: 15,
207+
DB: 0,
208208

209209
DialTimeout: 10 * time.Second,
210210
ReadTimeout: 30 * time.Second,
@@ -256,7 +256,9 @@ func performAsync(n int, cbs ...func(int)) *sync.WaitGroup {
256256
var wg sync.WaitGroup
257257
for _, cb := range cbs {
258258
wg.Add(n)
259-
for i := 0; i < n; i++ {
259+
// start from 1, so we can skip db 0 where such test is executed with
260+
// select db command
261+
for i := 1; i <= n; i++ {
260262
go func(cb func(int), i int) {
261263
defer GinkgoRecover()
262264
defer wg.Done()

race_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ var _ = Describe("races", func() {
138138
})
139139

140140
It("should select db", Label("NonRedisEnterprise"), func() {
141-
err := client.Set(ctx, "db", 1, 0).Err()
141+
err := client.Set(ctx, "db", 0, 0).Err()
142142
Expect(err).NotTo(HaveOccurred())
143143

144144
perform(C, func(id int) {
@@ -159,7 +159,7 @@ var _ = Describe("races", func() {
159159

160160
n, err := client.Get(ctx, "db").Int64()
161161
Expect(err).NotTo(HaveOccurred())
162-
Expect(n).To(Equal(int64(1)))
162+
Expect(n).To(Equal(int64(0)))
163163
})
164164

165165
It("should select DB with read timeout", func() {

0 commit comments

Comments
 (0)