Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add non-cached and cached integration test #2467

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading