From 928ecbfe0fa164ff7d327752a7ee512b4b4f04e1 Mon Sep 17 00:00:00 2001 From: Nedyalko Dyakov Date: Mon, 10 Feb 2025 17:04:53 +0200 Subject: [PATCH] wip --- .github/actions/run-tests/action.yml | 11 +--- .github/workflows/build.yml | 40 ++++++++++-- .github/workflows/doctests.yaml | 4 +- .github/workflows/test-redis-enterprise.yml | 2 +- Makefile | 6 +- acl_commands_test.go | 6 +- bench_test.go | 69 +++++++++------------ commands_test.go | 31 ++++++--- iterator_test.go | 2 + main_test.go | 36 ++++++----- osscluster_test.go | 1 + race_test.go | 4 +- redis_test.go | 6 +- search_commands.go | 1 + search_test.go | 31 +++++---- timeseries_commands_test.go | 4 ++ 16 files changed, 147 insertions(+), 107 deletions(-) diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml index 95709b5df..60f295df6 100644 --- a/.github/actions/run-tests/action.yml +++ b/.github/actions/run-tests/action.yml @@ -21,12 +21,7 @@ runs: CLIENT_LIBS_TEST_IMAGE: "redislabs/client-libs-test:${{ inputs.redis-version }}" run: | set -e - redis_major_version=$(echo "$REDIS_VERSION" | grep -oP '^\d+') - if (( redis_major_version < 8 )); then - echo "Using redis-stack for module tests" - else - echo "Using redis CE for module tests" - fi + redis_version_np=$(echo "$REDIS_VERSION" | grep -oP '^\d+.\d+') # Mapping of redis version to redis testing containers declare -A redis_version_mapping=( @@ -36,14 +31,13 @@ runs: ) if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then - echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV + echo "REDIS_VERSION=${redis_version_np}" >> $GITHUB_ENV echo "REDIS_IMAGE=redis:${{ inputs.redis-version }}" >> $GITHUB_ENV echo "CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:${redis_version_mapping[$REDIS_VERSION]}" >> $GITHUB_ENV else echo "Version not found in the mapping." exit 1 fi - sleep 10 # time to settle shell: bash - name: Set up Docker Compose environment with redis ${{ inputs.redis-version }} run: docker compose --profile all up -d @@ -58,5 +52,4 @@ runs: --ginkgo.skip-file="sentinel_test.go" \ --ginkgo.skip-file="pubsub_test.go" \ --ginkgo.skip-file="gears_commands_test.go" \ - --ginkgo.label-filter="!NonRedisEnterprise" shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 40c0b7a6a..0639577cd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - go-version: [1.21.x, 1.22.x, 1.23.x] + go-version: [1.22.x, 1.23.x] steps: - name: Set up ${{ matrix.go-version }} @@ -42,7 +42,12 @@ jobs: strategy: fail-fast: false matrix: - go-version: [1.21.x, 1.23.x] + redis-version: + - "8.0-M03" # 8.0 milestone 4 + - "7.4.2" # should use redis stack 7.4 + go-version: + - "1.22.x" + - "1.23.x" steps: - name: Set up ${{ matrix.go-version }} @@ -53,10 +58,38 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Setup Test environment + env: + REDIS_VERSION: ${{ matrix.redis-version }} + CLIENT_LIBS_TEST_IMAGE: "redislabs/client-libs-test:${{ matrix.redis-version }}" + run: | + set -e + redis_version_np=$(echo "$REDIS_VERSION" | grep -oP '^\d+.\d+') + + # Mapping of redis version to redis testing containers + declare -A redis_version_mapping=( + ["8.0-M03"]="8.0-M04-pre" + ["7.4.2"]="rs-7.4.0-v2" + ) + + if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then + echo "REDIS_VERSION=${redis_version_np}" >> $GITHUB_ENV + echo "REDIS_IMAGE=redis:${{ matrix.redis-version }}" >> $GITHUB_ENV + echo "CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:${redis_version_mapping[$REDIS_VERSION]}" >> $GITHUB_ENV + else + echo "Version not found in the mapping." + exit 1 + fi + shell: bash + - name: Set up Docker Compose environment with redis ${{ matrix.redis-version }} + run: docker compose --profile all up -d + shell: bash - name: Benchmark Tests + env: + RCE_DOCKER: "true" + RE_CLUSTER: "false" run: make bench - test-redis-ce: name: test-redis-ce runs-on: ubuntu-latest @@ -72,7 +105,6 @@ jobs: - "1.23.x" steps: - - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/doctests.yaml b/.github/workflows/doctests.yaml index b04f3140b..bdb69f7b3 100644 --- a/.github/workflows/doctests.yaml +++ b/.github/workflows/doctests.yaml @@ -25,7 +25,7 @@ jobs: strategy: fail-fast: false matrix: - go-version: [ "1.21", "1.22", "1.23" ] + go-version: ["1.22", "1.23"] steps: - name: Set up ${{ matrix.go-version }} @@ -38,4 +38,4 @@ jobs: - name: Test doc examples working-directory: ./doctests - run: go test + run: go test -v diff --git a/.github/workflows/test-redis-enterprise.yml b/.github/workflows/test-redis-enterprise.yml index 10c27198a..4ef4ff0e8 100644 --- a/.github/workflows/test-redis-enterprise.yml +++ b/.github/workflows/test-redis-enterprise.yml @@ -47,7 +47,7 @@ jobs: - name: Test env: RE_CLUSTER: true - REDIS_MAJOR_VERSION: 7 + REDIS_VERSION: "7.4" run: | go test \ --ginkgo.skip-file="ring_test.go" \ diff --git a/Makefile b/Makefile index 48b5a71da..c8f1ff10b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort) -export REDIS_MAJOR_VERSION := 7 +export REDIS_VERSION := "7.2" redisstackdocker.start: 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 @@ -31,11 +31,9 @@ test: testdeps testdeps: testdata/redis/src/redis-server bench: - $(MAKE) redisstackdocker.start go test ./... -test.run=NONE -test.bench=. -test.benchmem - $(MAKE) redisstackdocker.stop -.PHONY: all test testdeps bench fmt +.PHONY: all test bench fmt build: go build . diff --git a/acl_commands_test.go b/acl_commands_test.go index 846455831..a96621dbc 100644 --- a/acl_commands_test.go +++ b/acl_commands_test.go @@ -242,7 +242,7 @@ var _ = Describe("ACL permissions", Label("NonRedisEnterprise"), func() { }) It("set permissions for module commands", func() { - SkipBeforeRedisMajor(8, "permissions for modules are supported for Redis Version >=8") + SkipBeforeRedisVersion(8, "permissions for modules are supported for Redis Version >=8") Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred()) val, err := client.FTCreate(ctx, "txt", &redis.FTCreateOptions{}, &redis.FieldSchema{FieldName: "txt", FieldType: redis.SearchFieldTypeText}).Result() Expect(err).NotTo(HaveOccurred()) @@ -322,7 +322,7 @@ var _ = Describe("ACL permissions", Label("NonRedisEnterprise"), func() { }) It("set permissions for module categories", func() { - SkipBeforeRedisMajor(8, "permissions for modules are supported for Redis Version >=8") + SkipBeforeRedisVersion(8, "permissions for modules are supported for Redis Version >=8") Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred()) val, err := client.FTCreate(ctx, "txt", &redis.FTCreateOptions{}, &redis.FieldSchema{FieldName: "txt", FieldType: redis.SearchFieldTypeText}).Result() Expect(err).NotTo(HaveOccurred()) @@ -419,7 +419,7 @@ var _ = Describe("ACL Categories", func() { }) It("lists acl categories and subcategories with Modules", func() { - SkipBeforeRedisMajor(8, "modules are included in acl for redis version >= 8") + SkipBeforeRedisVersion(8, "modules are included in acl for redis version >= 8") aclTestCase := map[string]string{ "search": "FT.CREATE", "bloom": "bf.add", diff --git a/bench_test.go b/bench_test.go index bb84c4156..bfebb1aea 100644 --- a/bench_test.go +++ b/bench_test.go @@ -291,7 +291,7 @@ func BenchmarkClusterPing(b *testing.B) { ctx := context.Background() cluster := newClusterScenario() - if err := startCluster(ctx, cluster); err != nil { + if err := configureClusterTopology(ctx, cluster); err != nil { b.Fatal(err) } defer cluster.Close() @@ -299,15 +299,17 @@ func BenchmarkClusterPing(b *testing.B) { client := cluster.newClusterClient(ctx, redisClusterOptions()) defer client.Close() - b.ResetTimer() + b.Run("cluster ping", func(b *testing.B) { + b.ResetTimer() - b.RunParallel(func(pb *testing.PB) { - for pb.Next() { - err := client.Ping(ctx).Err() - if err != nil { - b.Fatal(err) + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + err := client.Ping(ctx).Err() + if err != nil { + b.Fatal(err) + } } - } + }) }) } @@ -318,7 +320,7 @@ func BenchmarkClusterDoInt(b *testing.B) { ctx := context.Background() cluster := newClusterScenario() - if err := startCluster(ctx, cluster); err != nil { + if err := configureClusterTopology(ctx, cluster); err != nil { b.Fatal(err) } defer cluster.Close() @@ -326,14 +328,16 @@ func BenchmarkClusterDoInt(b *testing.B) { client := cluster.newClusterClient(ctx, redisClusterOptions()) defer client.Close() - b.ResetTimer() - b.RunParallel(func(pb *testing.PB) { - for pb.Next() { - err := client.Do(ctx, "SET", 10, 10).Err() - if err != nil { - b.Fatal(err) + b.Run("cluster do set int", func(b *testing.B) { + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + err := client.Do(ctx, "SET", 10, 10).Err() + if err != nil { + b.Fatal(err) + } } - } + }) }) } @@ -344,7 +348,7 @@ func BenchmarkClusterSetString(b *testing.B) { ctx := context.Background() cluster := newClusterScenario() - if err := startCluster(ctx, cluster); err != nil { + if err := configureClusterTopology(ctx, cluster); err != nil { b.Fatal(err) } defer cluster.Close() @@ -354,15 +358,17 @@ func BenchmarkClusterSetString(b *testing.B) { value := string(bytes.Repeat([]byte{'1'}, 10000)) - b.ResetTimer() + b.Run("cluster set string", func(b *testing.B) { + b.ResetTimer() - b.RunParallel(func(pb *testing.PB) { - for pb.Next() { - err := client.Set(ctx, "key", value, 0).Err() - if err != nil { - b.Fatal(err) + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + err := client.Set(ctx, "key", value, 0).Err() + if err != nil { + b.Fatal(err) + } } - } + }) }) } @@ -372,21 +378,6 @@ func BenchmarkExecRingSetAddrsCmd(b *testing.B) { ringShard2Name = "ringShardTwo" ) - for _, port := range []string{ringShard1Port, ringShard2Port} { - if _, err := startRedis(port); err != nil { - b.Fatal(err) - } - } - - b.Cleanup(func() { - for _, p := range processes { - if err := p.Close(); err != nil { - b.Errorf("Failed to stop redis process: %v", err) - } - } - processes = nil - }) - ring := redis.NewRing(&redis.RingOptions{ Addrs: map[string]string{ "ringShardOne": ":" + ringShard1Port, diff --git a/commands_test.go b/commands_test.go index ff48cfce5..39cfbd8a1 100644 --- a/commands_test.go +++ b/commands_test.go @@ -194,6 +194,7 @@ var _ = Describe("Commands", func() { }) It("should ClientKillByFilter with MAXAGE", Label("NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") var s []string started := make(chan bool) done := make(chan bool) @@ -345,7 +346,7 @@ var _ = Describe("Commands", func() { }) It("should ConfigGet Modules", func() { - SkipBeforeRedisMajor(8, "Config doesn't include modules before Redis 8") + SkipBeforeRedisVersion(8, "Config doesn't include modules before Redis 8") expected := map[string]string{ "search-*": "search-timeout", "ts-*": "ts-retention-policy", @@ -380,7 +381,7 @@ var _ = Describe("Commands", func() { }) It("should ConfigGet with Modules", Label("NonRedisEnterprise"), func() { - SkipBeforeRedisMajor(8, "config get won't return modules configs before redis 8") + SkipBeforeRedisVersion(8, "config get won't return modules configs before redis 8") configGet := client.ConfigGet(ctx, "*") Expect(configGet.Err()).NotTo(HaveOccurred()) Expect(configGet.Val()).To(HaveKey("maxmemory")) @@ -391,7 +392,7 @@ var _ = Describe("Commands", func() { }) It("should ConfigSet FT DIALECT", func() { - SkipBeforeRedisMajor(8, "config doesn't include modules before Redis 8") + SkipBeforeRedisVersion(8, "config doesn't include modules before Redis 8") defaultState, err := client.ConfigGet(ctx, "search-default-dialect").Result() Expect(err).NotTo(HaveOccurred()) @@ -437,13 +438,13 @@ var _ = Describe("Commands", func() { }) It("should ConfigSet fail for ReadOnly", func() { - SkipBeforeRedisMajor(8, "Config doesn't include modules before Redis 8") + SkipBeforeRedisVersion(8, "Config doesn't include modules before Redis 8") _, err := client.ConfigSet(ctx, "search-max-doctablesize", "100000").Result() Expect(err).To(HaveOccurred()) }) It("should ConfigSet Modules", func() { - SkipBeforeRedisMajor(8, "Config doesn't include modules before Redis 8") + SkipBeforeRedisVersion(8, "Config doesn't include modules before Redis 8") defaults := map[string]string{} expected := map[string]string{ "search-timeout": "100", @@ -484,7 +485,7 @@ var _ = Describe("Commands", func() { }) It("should Fail ConfigSet Modules", func() { - SkipBeforeRedisMajor(8, "Config doesn't include modules before Redis 8") + SkipBeforeRedisVersion(8, "Config doesn't include modules before Redis 8") expected := map[string]string{ "search-timeout": "-100", "ts-retention-policy": "-10", @@ -533,7 +534,7 @@ var _ = Describe("Commands", func() { }) It("should Info Modules", Label("redis.info"), func() { - SkipBeforeRedisMajor(8, "modules are included in info for Redis Version >= 8") + SkipBeforeRedisVersion(8, "modules are included in info for Redis Version >= 8") info := client.Info(ctx) Expect(info.Err()).NotTo(HaveOccurred()) Expect(info.Val()).NotTo(BeNil()) @@ -558,7 +559,7 @@ var _ = Describe("Commands", func() { }) It("should InfoMap Modules", Label("redis.info"), func() { - SkipBeforeRedisMajor(8, "modules are included in info for Redis Version >= 8") + SkipBeforeRedisVersion(8, "modules are included in info for Redis Version >= 8") info := client.InfoMap(ctx) Expect(info.Err()).NotTo(HaveOccurred()) Expect(info.Val()).NotTo(BeNil()) @@ -1332,6 +1333,7 @@ var _ = Describe("Commands", func() { }) It("should HScan without values", Label("NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") for i := 0; i < 1000; i++ { sadd := client.HSet(ctx, "myhash", fmt.Sprintf("key%d", i), "hello") Expect(sadd.Err()).NotTo(HaveOccurred()) @@ -2625,6 +2627,7 @@ var _ = Describe("Commands", func() { }) It("should HExpire", Label("hash-expiration", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") res, err := client.HExpire(ctx, "no_such_key", 10*time.Second, "field1", "field2", "field3").Result() Expect(err).To(BeNil()) Expect(res).To(BeEquivalentTo([]int64{-2, -2, -2})) @@ -2640,6 +2643,7 @@ var _ = Describe("Commands", func() { }) It("should HPExpire", Label("hash-expiration", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") res, err := client.HPExpire(ctx, "no_such_key", 10*time.Second, "field1", "field2", "field3").Result() Expect(err).To(BeNil()) Expect(res).To(BeEquivalentTo([]int64{-2, -2, -2})) @@ -2655,6 +2659,7 @@ var _ = Describe("Commands", func() { }) It("should HExpireAt", Label("hash-expiration", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") resEmpty, err := client.HExpireAt(ctx, "no_such_key", time.Now().Add(10*time.Second), "field1", "field2", "field3").Result() Expect(err).To(BeNil()) Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2})) @@ -2670,6 +2675,7 @@ var _ = Describe("Commands", func() { }) It("should HPExpireAt", Label("hash-expiration", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") resEmpty, err := client.HPExpireAt(ctx, "no_such_key", time.Now().Add(10*time.Second), "field1", "field2", "field3").Result() Expect(err).To(BeNil()) Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2})) @@ -2685,6 +2691,7 @@ var _ = Describe("Commands", func() { }) It("should HPersist", Label("hash-expiration", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") resEmpty, err := client.HPersist(ctx, "no_such_key", "field1", "field2", "field3").Result() Expect(err).To(BeNil()) Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2})) @@ -2708,6 +2715,7 @@ var _ = Describe("Commands", func() { }) It("should HExpireTime", Label("hash-expiration", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") resEmpty, err := client.HExpireTime(ctx, "no_such_key", "field1", "field2", "field3").Result() Expect(err).To(BeNil()) Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2})) @@ -2727,6 +2735,7 @@ var _ = Describe("Commands", func() { }) It("should HPExpireTime", Label("hash-expiration", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") resEmpty, err := client.HPExpireTime(ctx, "no_such_key", "field1", "field2", "field3").Result() Expect(err).To(BeNil()) Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2})) @@ -2747,6 +2756,7 @@ var _ = Describe("Commands", func() { }) It("should HTTL", Label("hash-expiration", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") resEmpty, err := client.HTTL(ctx, "no_such_key", "field1", "field2", "field3").Result() Expect(err).To(BeNil()) Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2})) @@ -2766,6 +2776,7 @@ var _ = Describe("Commands", func() { }) It("should HPTTL", Label("hash-expiration", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") resEmpty, err := client.HPTTL(ctx, "no_such_key", "field1", "field2", "field3").Result() Expect(err).To(BeNil()) Expect(resEmpty).To(BeEquivalentTo([]int64{-2, -2, -2})) @@ -6040,6 +6051,7 @@ var _ = Describe("Commands", func() { }) It("should XRead LastEntry", Label("NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") res, err := client.XRead(ctx, &redis.XReadArgs{ Streams: []string{"stream"}, Count: 2, // we expect 1 message @@ -6057,6 +6069,7 @@ var _ = Describe("Commands", func() { }) It("should XRead LastEntry from two streams", Label("NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") res, err := client.XRead(ctx, &redis.XReadArgs{ Streams: []string{"stream", "stream"}, ID: "+", @@ -6079,6 +6092,7 @@ var _ = Describe("Commands", func() { }) It("should XRead LastEntry blocks", Label("NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") start := time.Now() go func() { defer GinkgoRecover() @@ -7332,6 +7346,7 @@ var _ = Describe("Commands", func() { }) It("Shows function stats", func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") defer client.FunctionKill(ctx) // We can not run blocking commands in Redis functions, so we're using an infinite loop, diff --git a/iterator_test.go b/iterator_test.go index 472ce38a7..c4f046476 100644 --- a/iterator_test.go +++ b/iterator_test.go @@ -85,6 +85,7 @@ var _ = Describe("ScanIterator", func() { }) It("should hscan across multiple pages", func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") Expect(hashSeed(71)).NotTo(HaveOccurred()) var vals []string @@ -100,6 +101,7 @@ var _ = Describe("ScanIterator", func() { }) It("should hscan without values across multiple pages", Label("NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") Expect(hashSeed(71)).NotTo(HaveOccurred()) var vals []string diff --git a/main_test.go b/main_test.go index a326960a0..d9875f097 100644 --- a/main_test.go +++ b/main_test.go @@ -70,20 +70,20 @@ var RECluster = false // Redis Community Edition Docker var RCEDocker = false -// Notes the major version of redis we are executing tests. +// Notes version of redis we are executing tests against. // This can be used before we change the bsm fork of ginkgo for one, -// which have support for label sets, so we can filter tests per redis major version. -var RedisMajorVersion = 7 +// which have support for label sets, so we can filter tests per redis version. +var RedisVersion float64 = 7.2 -func SkipBeforeRedisMajor(version int, msg string) { - if RedisMajorVersion < version { - Skip(fmt.Sprintf("(redis major version < %d) %s", version, msg)) +func SkipBeforeRedisVersion(version float64, msg string) { + if RedisVersion < version { + Skip(fmt.Sprintf("(redis version < %f) %s", version, msg)) } } -func SkipAfterRedisMajor(version int, msg string) { - if RedisMajorVersion > version { - Skip(fmt.Sprintf("(redis major version > %d) %s", version, msg)) +func SkipAfterRedisVersion(version float64, msg string) { + if RedisVersion > version { + Skip(fmt.Sprintf("(redis version > %f) %s", version, msg)) } } @@ -104,18 +104,18 @@ var _ = BeforeSuite(func() { RECluster, _ = strconv.ParseBool(os.Getenv("RE_CLUSTER")) RCEDocker, _ = strconv.ParseBool(os.Getenv("RCE_DOCKER")) - RedisMajorVersion, _ = strconv.Atoi(os.Getenv("REDIS_MAJOR_VERSION")) + RedisVersion, _ = strconv.ParseFloat(os.Getenv("REDIS_VERSION"), 64) - if RedisMajorVersion == 0 { - RedisMajorVersion = 7 + if RedisVersion == 0 { + RedisVersion = 7.2 } fmt.Printf("RECluster: %v\n", RECluster) fmt.Printf("RCEDocker: %v\n", RCEDocker) - fmt.Printf("REDIS_MAJOR_VERSION: %v\n", RedisMajorVersion) + fmt.Printf("REDIS_VERSION: %v\n", RedisVersion) - if RedisMajorVersion < 6 || RedisMajorVersion > 8 { - panic("incorrect or not supported redis major version") + if RedisVersion < 7.0 || RedisVersion > 9 { + panic("incorrect or not supported redis version") } if !RECluster && !RCEDocker { @@ -204,7 +204,7 @@ func redisOptions() *redis.Options { } return &redis.Options{ Addr: redisAddr, - DB: 15, + DB: 0, DialTimeout: 10 * time.Second, ReadTimeout: 30 * time.Second, @@ -256,7 +256,9 @@ func performAsync(n int, cbs ...func(int)) *sync.WaitGroup { var wg sync.WaitGroup for _, cb := range cbs { wg.Add(n) - for i := 0; i < n; i++ { + // start from 1, so we can skip db 0 where such test is executed with + // select db command + for i := 1; i <= n; i++ { go func(cb func(int), i int) { defer GinkgoRecover() defer wg.Done() diff --git a/osscluster_test.go b/osscluster_test.go index 93ee464f3..cda36335f 100644 --- a/osscluster_test.go +++ b/osscluster_test.go @@ -115,6 +115,7 @@ func (s *clusterScenario) Close() error { } func configureClusterTopology(ctx context.Context, scenario *clusterScenario) error { + fmt.Println("configuring cluster") err := collectNodeInformation(ctx, scenario) if err != nil { return err diff --git a/race_test.go b/race_test.go index aeb2d1fa3..661b6014e 100644 --- a/race_test.go +++ b/race_test.go @@ -138,7 +138,7 @@ var _ = Describe("races", func() { }) It("should select db", Label("NonRedisEnterprise"), func() { - err := client.Set(ctx, "db", 1, 0).Err() + err := client.Set(ctx, "db", 0, 0).Err() Expect(err).NotTo(HaveOccurred()) perform(C, func(id int) { @@ -159,7 +159,7 @@ var _ = Describe("races", func() { n, err := client.Get(ctx, "db").Int64() Expect(err).NotTo(HaveOccurred()) - Expect(n).To(Equal(int64(1))) + Expect(n).To(Equal(int64(0))) }) It("should select DB with read timeout", func() { diff --git a/redis_test.go b/redis_test.go index b5cf2570f..f8c91b4a2 100644 --- a/redis_test.go +++ b/redis_test.go @@ -66,11 +66,7 @@ var _ = Describe("Client", func() { }) It("should Stringer", func() { - if RECluster { - Expect(client.String()).To(Equal(fmt.Sprintf("Redis<:%s db:0>", redisPort))) - } else { - Expect(client.String()).To(Equal(fmt.Sprintf("Redis<:%s db:15>", redisPort))) - } + Expect(client.String()).To(Equal(fmt.Sprintf("Redis<:%s db:0>", redisPort))) }) It("supports context", func() { diff --git a/search_commands.go b/search_commands.go index df12bb3f9..b9365c7e6 100644 --- a/search_commands.go +++ b/search_commands.go @@ -2081,6 +2081,7 @@ func (c cmdable) FTTagVals(ctx context.Context, index string, field string) *Str return cmd } +// TODO: remove FTProfile // type FTProfileResult struct { // Results []interface{} // Profile ProfileDetails diff --git a/search_test.go b/search_test.go index e4e552152..ccd2673b7 100644 --- a/search_test.go +++ b/search_test.go @@ -379,7 +379,7 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { // up until redis 8 the default scorer was TFIDF, in redis 8 it is BM25 // this test expect redis major version >= 8 It("should FTSearch WithScores", Label("search", "ftsearch"), func() { - SkipBeforeRedisMajor(8, "default scorer is not BM25") + SkipBeforeRedisVersion(8, "default scorer is not BM25") text1 := &redis.FieldSchema{FieldName: "description", FieldType: redis.SearchFieldTypeText} val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{}, text1).Result() @@ -422,7 +422,7 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { // up until redis 8 the default scorer was TFIDF, in redis 8 it is BM25 // this test expect redis major version <=7 It("should FTSearch WithScores", Label("search", "ftsearch"), func() { - SkipAfterRedisMajor(7, "default scorer is not TFIDF") + SkipAfterRedisVersion(7, "default scorer is not TFIDF") text1 := &redis.FieldSchema{FieldName: "description", FieldType: redis.SearchFieldTypeText} val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{}, text1).Result() Expect(err).NotTo(HaveOccurred()) @@ -462,17 +462,17 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { }) It("should FTConfigSet and FTConfigGet ", Label("search", "ftconfigget", "ftconfigset", "NonRedisEnterprise"), func() { - val, err := client.FTConfigSet(ctx, "TIMEOUT", "100").Result() + val, err := client.FTConfigSet(ctx, "MINPREFIX", "1").Result() Expect(err).NotTo(HaveOccurred()) Expect(val).To(BeEquivalentTo("OK")) res, err := client.FTConfigGet(ctx, "*").Result() Expect(err).NotTo(HaveOccurred()) - Expect(res["TIMEOUT"]).To(BeEquivalentTo("100")) + Expect(res["MINPREFIX"]).To(BeEquivalentTo("1")) - res, err = client.FTConfigGet(ctx, "TIMEOUT").Result() + res, err = client.FTConfigGet(ctx, "MINPREFIX").Result() Expect(err).NotTo(HaveOccurred()) - Expect(res).To(BeEquivalentTo(map[string]interface{}{"TIMEOUT": "100"})) + Expect(res).To(BeEquivalentTo(map[string]interface{}{"MINPREFIX": "1"})) }) @@ -646,7 +646,7 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { }) It("should FTAggregate with scorer and addscores", Label("search", "ftaggregate", "NonRedisEnterprise"), func() { - SkipBeforeRedisMajor(8, "ADDSCORES is available in Redis CE 8") + SkipBeforeRedisVersion(8, "ADDSCORES is available in Redis CE 8") title := &redis.FieldSchema{FieldName: "title", FieldType: redis.SearchFieldTypeText, Sortable: false} description := &redis.FieldSchema{FieldName: "description", FieldType: redis.SearchFieldTypeText, Sortable: false} val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{OnHash: true, Prefix: []interface{}{"product:"}}, title, description).Result() @@ -1186,6 +1186,7 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { }) It("should test dialect 4", Label("search", "ftcreate", "ftsearch", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{ Prefix: []interface{}{"resource:"}, }, &redis.FieldSchema{ @@ -1317,6 +1318,7 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { }) It("should create search index with FLOAT16 and BFLOAT16 vectors", Label("search", "ftcreate", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") val, err := client.FTCreate(ctx, "index", &redis.FTCreateOptions{}, &redis.FieldSchema{FieldName: "float16", FieldType: redis.SearchFieldTypeVector, VectorArgs: &redis.FTVectorArgs{FlatOptions: &redis.FTFlatOptions{Type: "FLOAT16", Dim: 768, DistanceMetric: "COSINE"}}}, &redis.FieldSchema{FieldName: "bfloat16", FieldType: redis.SearchFieldTypeVector, VectorArgs: &redis.FTVectorArgs{FlatOptions: &redis.FTFlatOptions{Type: "BFLOAT16", Dim: 768, DistanceMetric: "COSINE"}}}, @@ -1327,6 +1329,7 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { }) It("should test geoshapes query intersects and disjoint", Label("NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") _, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{}, &redis.FieldSchema{ FieldName: "g", FieldType: redis.SearchFieldTypeGeoShape, @@ -1395,6 +1398,7 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { }) It("should search missing fields", Label("search", "ftcreate", "ftsearch", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{Prefix: []interface{}{"property:"}}, &redis.FieldSchema{FieldName: "title", FieldType: redis.SearchFieldTypeText, Sortable: true}, &redis.FieldSchema{FieldName: "features", FieldType: redis.SearchFieldTypeTag, IndexMissing: true}, @@ -1439,6 +1443,7 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() { }) It("should search empty fields", Label("search", "ftcreate", "ftsearch", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images") val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{Prefix: []interface{}{"property:"}}, &redis.FieldSchema{FieldName: "title", FieldType: redis.SearchFieldTypeText, Sortable: true}, &redis.FieldSchema{FieldName: "features", FieldType: redis.SearchFieldTypeTag, IndexEmpty: true}, @@ -1599,18 +1604,18 @@ var _ = Describe("RediSearch FT.Config with Resp2 and Resp3", Label("search", "N Expect(clientResp3.Close()).NotTo(HaveOccurred()) }) - It("should FTConfigSet and FTConfigGet ", Label("search", "ftconfigget", "ftconfigset", "NonRedisEnterprise"), func() { - val, err := clientResp3.FTConfigSet(ctx, "TIMEOUT", "100").Result() + It("should FTConfigSet and FTConfigGet with resp2 and resp3", Label("search", "ftconfigget", "ftconfigset", "NonRedisEnterprise"), func() { + val, err := clientResp3.FTConfigSet(ctx, "MINPREFIX", "1").Result() Expect(err).NotTo(HaveOccurred()) Expect(val).To(BeEquivalentTo("OK")) - res2, err := clientResp2.FTConfigGet(ctx, "TIMEOUT").Result() + res2, err := clientResp2.FTConfigGet(ctx, "MINPREFIX").Result() Expect(err).NotTo(HaveOccurred()) - Expect(res2).To(BeEquivalentTo(map[string]interface{}{"TIMEOUT": "100"})) + Expect(res2).To(BeEquivalentTo(map[string]interface{}{"MINPREFIX": "1"})) - res3, err := clientResp3.FTConfigGet(ctx, "TIMEOUT").Result() + res3, err := clientResp3.FTConfigGet(ctx, "MINPREFIX").Result() Expect(err).NotTo(HaveOccurred()) - Expect(res3).To(BeEquivalentTo(map[string]interface{}{"TIMEOUT": "100"})) + Expect(res3).To(BeEquivalentTo(map[string]interface{}{"MINPREFIX": "1"})) }) It("should FTConfigGet all resp2 and resp3", Label("search", "NonRedisEnterprise"), func() { diff --git a/timeseries_commands_test.go b/timeseries_commands_test.go index a2d4ba293..d0d865b48 100644 --- a/timeseries_commands_test.go +++ b/timeseries_commands_test.go @@ -43,6 +43,7 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { }) It("should TSCreate and TSCreateWithArgs", Label("timeseries", "tscreate", "tscreateWithArgs", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "older redis stack has different results for timeseries module") result, err := client.TSCreate(ctx, "1").Result() Expect(err).NotTo(HaveOccurred()) Expect(result).To(BeEquivalentTo("OK")) @@ -139,6 +140,7 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { {Timestamp: 1013, Value: 10.0}})) }) It("should TSAdd and TSAddWithArgs", Label("timeseries", "tsadd", "tsaddWithArgs", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "older redis stack has different results for timeseries module") result, err := client.TSAdd(ctx, "1", 1, 1).Result() Expect(err).NotTo(HaveOccurred()) Expect(result).To(BeEquivalentTo(1)) @@ -232,6 +234,7 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { }) It("should TSAlter", Label("timeseries", "tsalter", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "older redis stack has different results for timeseries module") result, err := client.TSCreate(ctx, "1").Result() Expect(err).NotTo(HaveOccurred()) Expect(result).To(BeEquivalentTo("OK")) @@ -349,6 +352,7 @@ var _ = Describe("RedisTimeseries commands", Label("timeseries"), func() { }) It("should TSIncrBy, TSIncrByWithArgs, TSDecrBy and TSDecrByWithArgs", Label("timeseries", "tsincrby", "tsdecrby", "tsincrbyWithArgs", "tsdecrbyWithArgs", "NonRedisEnterprise"), func() { + SkipBeforeRedisVersion(7.4, "older redis stack has different results for timeseries module") for i := 0; i < 100; i++ { _, err := client.TSIncrBy(ctx, "1", 1).Result() Expect(err).NotTo(HaveOccurred())