Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ndyakov committed Feb 10, 2025
1 parent bdb19f5 commit 928ecbf
Show file tree
Hide file tree
Showing 16 changed files with 147 additions and 107 deletions.
11 changes: 2 additions & 9 deletions .github/actions/run-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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=(
Expand All @@ -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
Expand All @@ -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
40 changes: 36 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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
Expand All @@ -72,7 +105,6 @@ jobs:
- "1.23.x"

steps:

- name: Checkout code
uses: actions/checkout@v4

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/doctests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -38,4 +38,4 @@ jobs:

- name: Test doc examples
working-directory: ./doctests
run: go test
run: go test -v
2 changes: 1 addition & 1 deletion .github/workflows/test-redis-enterprise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 .
Expand Down
6 changes: 3 additions & 3 deletions acl_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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",
Expand Down
69 changes: 30 additions & 39 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,23 +291,25 @@ 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()

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)
}
}
}
})
})
}

Expand All @@ -318,22 +320,24 @@ 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()

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)
}
}
}
})
})
}

Expand All @@ -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()
Expand All @@ -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)
}
}
}
})
})
}

Expand All @@ -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,
Expand Down
Loading

0 comments on commit 928ecbf

Please sign in to comment.