Skip to content

Commit 928ecbf

Browse files
committed
wip
1 parent bdb19f5 commit 928ecbf

16 files changed

+147
-107
lines changed

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

+2-9
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ runs:
2121
CLIENT_LIBS_TEST_IMAGE: "redislabs/client-libs-test:${{ inputs.redis-version }}"
2222
run: |
2323
set -e
24-
redis_major_version=$(echo "$REDIS_VERSION" | grep -oP '^\d+')
25-
if (( redis_major_version < 8 )); then
26-
echo "Using redis-stack for module tests"
27-
else
28-
echo "Using redis CE for module tests"
29-
fi
24+
redis_version_np=$(echo "$REDIS_VERSION" | grep -oP '^\d+.\d+')
3025
3126
# Mapping of redis version to redis testing containers
3227
declare -A redis_version_mapping=(
@@ -36,14 +31,13 @@ runs:
3631
)
3732
3833
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
39-
echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV
34+
echo "REDIS_VERSION=${redis_version_np}" >> $GITHUB_ENV
4035
echo "REDIS_IMAGE=redis:${{ inputs.redis-version }}" >> $GITHUB_ENV
4136
echo "CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:${redis_version_mapping[$REDIS_VERSION]}" >> $GITHUB_ENV
4237
else
4338
echo "Version not found in the mapping."
4439
exit 1
4540
fi
46-
sleep 10 # time to settle
4741
shell: bash
4842
- name: Set up Docker Compose environment with redis ${{ inputs.redis-version }}
4943
run: docker compose --profile all up -d
@@ -58,5 +52,4 @@ runs:
5852
--ginkgo.skip-file="sentinel_test.go" \
5953
--ginkgo.skip-file="pubsub_test.go" \
6054
--ginkgo.skip-file="gears_commands_test.go" \
61-
--ginkgo.label-filter="!NonRedisEnterprise"
6255
shell: bash

.github/workflows/build.yml

+36-4
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,12 @@ jobs:
4242
strategy:
4343
fail-fast: false
4444
matrix:
45-
go-version: [1.21.x, 1.23.x]
45+
redis-version:
46+
- "8.0-M03" # 8.0 milestone 4
47+
- "7.4.2" # should use redis stack 7.4
48+
go-version:
49+
- "1.22.x"
50+
- "1.23.x"
4651

4752
steps:
4853
- name: Set up ${{ matrix.go-version }}
@@ -53,10 +58,38 @@ jobs:
5358
- name: Checkout code
5459
uses: actions/checkout@v4
5560

61+
- name: Setup Test environment
62+
env:
63+
REDIS_VERSION: ${{ matrix.redis-version }}
64+
CLIENT_LIBS_TEST_IMAGE: "redislabs/client-libs-test:${{ matrix.redis-version }}"
65+
run: |
66+
set -e
67+
redis_version_np=$(echo "$REDIS_VERSION" | grep -oP '^\d+.\d+')
68+
69+
# Mapping of redis version to redis testing containers
70+
declare -A redis_version_mapping=(
71+
["8.0-M03"]="8.0-M04-pre"
72+
["7.4.2"]="rs-7.4.0-v2"
73+
)
74+
75+
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
76+
echo "REDIS_VERSION=${redis_version_np}" >> $GITHUB_ENV
77+
echo "REDIS_IMAGE=redis:${{ matrix.redis-version }}" >> $GITHUB_ENV
78+
echo "CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:${redis_version_mapping[$REDIS_VERSION]}" >> $GITHUB_ENV
79+
else
80+
echo "Version not found in the mapping."
81+
exit 1
82+
fi
83+
shell: bash
84+
- name: Set up Docker Compose environment with redis ${{ matrix.redis-version }}
85+
run: docker compose --profile all up -d
86+
shell: bash
5687
- name: Benchmark Tests
88+
env:
89+
RCE_DOCKER: "true"
90+
RE_CLUSTER: "false"
5791
run: make bench
5892

59-
6093
test-redis-ce:
6194
name: test-redis-ce
6295
runs-on: ubuntu-latest
@@ -72,7 +105,6 @@ jobs:
72105
- "1.23.x"
73106

74107
steps:
75-
76108
- name: Checkout code
77109
uses: actions/checkout@v4
78110

.github/workflows/doctests.yaml

+2-2
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

+1-1
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

+2-4
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
@@ -31,11 +31,9 @@ test: testdeps
3131
testdeps: testdata/redis/src/redis-server
3232

3333
bench:
34-
$(MAKE) redisstackdocker.start
3534
go test ./... -test.run=NONE -test.bench=. -test.benchmem
36-
$(MAKE) redisstackdocker.stop
3735

38-
.PHONY: all test testdeps bench fmt
36+
.PHONY: all test bench fmt
3937

4038
build:
4139
go build .

acl_commands_test.go

+3-3
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",

bench_test.go

+30-39
Original file line numberDiff line numberDiff line change
@@ -291,23 +291,25 @@ func BenchmarkClusterPing(b *testing.B) {
291291

292292
ctx := context.Background()
293293
cluster := newClusterScenario()
294-
if err := startCluster(ctx, cluster); err != nil {
294+
if err := configureClusterTopology(ctx, cluster); err != nil {
295295
b.Fatal(err)
296296
}
297297
defer cluster.Close()
298298

299299
client := cluster.newClusterClient(ctx, redisClusterOptions())
300300
defer client.Close()
301301

302-
b.ResetTimer()
302+
b.Run("cluster ping", func(b *testing.B) {
303+
b.ResetTimer()
303304

304-
b.RunParallel(func(pb *testing.PB) {
305-
for pb.Next() {
306-
err := client.Ping(ctx).Err()
307-
if err != nil {
308-
b.Fatal(err)
305+
b.RunParallel(func(pb *testing.PB) {
306+
for pb.Next() {
307+
err := client.Ping(ctx).Err()
308+
if err != nil {
309+
b.Fatal(err)
310+
}
309311
}
310-
}
312+
})
311313
})
312314
}
313315

@@ -318,22 +320,24 @@ func BenchmarkClusterDoInt(b *testing.B) {
318320

319321
ctx := context.Background()
320322
cluster := newClusterScenario()
321-
if err := startCluster(ctx, cluster); err != nil {
323+
if err := configureClusterTopology(ctx, cluster); err != nil {
322324
b.Fatal(err)
323325
}
324326
defer cluster.Close()
325327

326328
client := cluster.newClusterClient(ctx, redisClusterOptions())
327329
defer client.Close()
328330

329-
b.ResetTimer()
330-
b.RunParallel(func(pb *testing.PB) {
331-
for pb.Next() {
332-
err := client.Do(ctx, "SET", 10, 10).Err()
333-
if err != nil {
334-
b.Fatal(err)
331+
b.Run("cluster do set int", func(b *testing.B) {
332+
b.ResetTimer()
333+
b.RunParallel(func(pb *testing.PB) {
334+
for pb.Next() {
335+
err := client.Do(ctx, "SET", 10, 10).Err()
336+
if err != nil {
337+
b.Fatal(err)
338+
}
335339
}
336-
}
340+
})
337341
})
338342
}
339343

@@ -344,7 +348,7 @@ func BenchmarkClusterSetString(b *testing.B) {
344348

345349
ctx := context.Background()
346350
cluster := newClusterScenario()
347-
if err := startCluster(ctx, cluster); err != nil {
351+
if err := configureClusterTopology(ctx, cluster); err != nil {
348352
b.Fatal(err)
349353
}
350354
defer cluster.Close()
@@ -354,15 +358,17 @@ func BenchmarkClusterSetString(b *testing.B) {
354358

355359
value := string(bytes.Repeat([]byte{'1'}, 10000))
356360

357-
b.ResetTimer()
361+
b.Run("cluster set string", func(b *testing.B) {
362+
b.ResetTimer()
358363

359-
b.RunParallel(func(pb *testing.PB) {
360-
for pb.Next() {
361-
err := client.Set(ctx, "key", value, 0).Err()
362-
if err != nil {
363-
b.Fatal(err)
364+
b.RunParallel(func(pb *testing.PB) {
365+
for pb.Next() {
366+
err := client.Set(ctx, "key", value, 0).Err()
367+
if err != nil {
368+
b.Fatal(err)
369+
}
364370
}
365-
}
371+
})
366372
})
367373
}
368374

@@ -372,21 +378,6 @@ func BenchmarkExecRingSetAddrsCmd(b *testing.B) {
372378
ringShard2Name = "ringShardTwo"
373379
)
374380

375-
for _, port := range []string{ringShard1Port, ringShard2Port} {
376-
if _, err := startRedis(port); err != nil {
377-
b.Fatal(err)
378-
}
379-
}
380-
381-
b.Cleanup(func() {
382-
for _, p := range processes {
383-
if err := p.Close(); err != nil {
384-
b.Errorf("Failed to stop redis process: %v", err)
385-
}
386-
}
387-
processes = nil
388-
})
389-
390381
ring := redis.NewRing(&redis.RingOptions{
391382
Addrs: map[string]string{
392383
"ringShardOne": ":" + ringShard1Port,

0 commit comments

Comments
 (0)