Skip to content

Commit

Permalink
Integration tests differentiate between cached and non-cached (OpenAt…
Browse files Browse the repository at this point in the history
…omFoundation#2467)

Co-authored-by: liuyuecai <[email protected]>
  • Loading branch information
luky116 and liuyuecai committed Mar 14, 2024
1 parent 5be35a5 commit 2864f81
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 5 deletions.
1 change: 1 addition & 0 deletions tests/integration/csanning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var _ = Describe("Csanning Commands", func() {
BeforeEach(func() {
client = redis.NewClient(PikaOption(SINGLEADDR))
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
GlobalBefore(ctx, client)
time.Sleep(1 * time.Second)
})

Expand Down
1 change: 1 addition & 0 deletions tests/integration/geo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var _ = Describe("Geo Commands", func() {
BeforeEach(func() {
client = redis.NewClient(PikaOption(SINGLEADDR))
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
GlobalBefore(ctx, client)
time.Sleep(1 * time.Second)
})

Expand Down
1 change: 1 addition & 0 deletions tests/integration/hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var _ = Describe("Hash Commands", func() {
BeforeEach(func() {
client = redis.NewClient(PikaOption(SINGLEADDR))
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
GlobalBefore(ctx, client)
time.Sleep(1 * time.Second)
})

Expand Down
1 change: 1 addition & 0 deletions tests/integration/hyperloglog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var _ = Describe("Hyperloglog Commands", func() {
BeforeEach(func() {
client = redis.NewClient(PikaOption(SINGLEADDR))
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
GlobalBefore(ctx, client)
time.Sleep(1 * time.Second)
})

Expand Down
29 changes: 24 additions & 5 deletions tests/integration/main_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
package pika_integration

import (
"testing"

"context"
. "github.com/bsm/ginkgo/v2"

. "github.com/bsm/gomega"
"github.com/redis/go-redis/v9"
"testing"
)

func TestPika(t *testing.T) {
var (
GlobalBefore func(ctx context.Context, client *redis.Client)
)

func TestPikaWithCache(t *testing.T) {
GlobalBefore = func(ctx context.Context, client *redis.Client) {
Expect(client.SlaveOf(ctx, "NO", "ONE").Err()).NotTo(HaveOccurred())
Expect(client.FlushAll(ctx).Err()).NotTo(HaveOccurred())
Expect(client.ConfigSet(ctx, "cache-model", "1").Err()).NotTo(HaveOccurred())
}
RegisterFailHandler(Fail)
RunSpecs(t, "Pika integration test with cache done")
}

func TestPikaWithoutCache(t *testing.T) {
GlobalBefore = func(ctx context.Context, client *redis.Client) {
Expect(client.SlaveOf(ctx, "NO", "ONE").Err()).NotTo(HaveOccurred())
Expect(client.FlushAll(ctx).Err()).NotTo(HaveOccurred())
Expect(client.ConfigSet(ctx, "cache-model", "0").Err()).NotTo(HaveOccurred())
}
RegisterFailHandler(Fail)
RunSpecs(t, "Pika integration test")
RunSpecs(t, "Pika integration test without cache done")
}
2 changes: 2 additions & 0 deletions tests/integration/pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ var _ = Describe("PubSub", func() {
client2 = redis.NewClient(PikaOption(SINGLEADDR))
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
Expect(client2.FlushDB(ctx).Err()).NotTo(HaveOccurred())
GlobalBefore(ctx, client)
GlobalBefore(ctx, client2)
time.Sleep(2 * time.Second)
})

Expand Down
2 changes: 2 additions & 0 deletions tests/integration/replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ var _ = Describe("should replication ", func() {
cleanEnv(ctx, clientMaster, clientSlave)
Expect(clientSlave.FlushDB(ctx).Err()).NotTo(HaveOccurred())
Expect(clientMaster.FlushDB(ctx).Err()).NotTo(HaveOccurred())
GlobalBefore(ctx, clientMaster)
GlobalBefore(ctx, clientSlave)
time.Sleep(3 * time.Second)
})
AfterEach(func() {
Expand Down
1 change: 1 addition & 0 deletions tests/integration/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var _ = Describe("Set Commands", func() {
BeforeEach(func() {
client = redis.NewClient(PikaOption(SINGLEADDR))
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
GlobalBefore(ctx, client)
time.Sleep(1 * time.Second)
})

Expand Down
1 change: 1 addition & 0 deletions tests/integration/slowlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var _ = Describe("Slowlog Commands", func() {
BeforeEach(func() {
client = redis.NewClient(PikaOption(SINGLEADDR))
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
GlobalBefore(ctx, client)
time.Sleep(1 * time.Second)
})

Expand Down
1 change: 1 addition & 0 deletions tests/integration/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ var _ = Describe("Stream Commands", func() {
var client *redis.Client
client = redis.NewClient(PikaOption(SINGLEADDR))
client.FlushDB(ctx)
GlobalBefore(ctx, client)

BeforeEach(func() {
// client = redis.NewClient(pikaOptions1())
Expand Down
1 change: 1 addition & 0 deletions tests/integration/string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var _ = Describe("String Commands", func() {
BeforeEach(func() {
client = redis.NewClient(PikaOption(SINGLEADDR))
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
GlobalBefore(ctx, client)
time.Sleep(1 * time.Second)
})

Expand Down
3 changes: 3 additions & 0 deletions tests/integration/txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ var _ = Describe("Text Txn", func() {
BeforeEach(func() {
txnClient = redis.NewClient(PikaOption(SINGLEADDR))
cmdClient = redis.NewClient(PikaOption(SINGLEADDR))

GlobalBefore(ctx, txnClient)
GlobalBefore(ctx, cmdClient)
})
Describe("test watch", func() {
It("basic watch", func() {
Expand Down
1 change: 1 addition & 0 deletions tests/integration/zset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var _ = Describe("Zset Commands", func() {
BeforeEach(func() {
client = redis.NewClient(PikaOption(SINGLEADDR))
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
GlobalBefore(ctx, client)
time.Sleep(1 * time.Second)
})

Expand Down

0 comments on commit 2864f81

Please sign in to comment.