diff --git a/tests/integration/csanning_test.go b/tests/integration/csanning_test.go index 67bc89f73..dfe3ac8f4 100644 --- a/tests/integration/csanning_test.go +++ b/tests/integration/csanning_test.go @@ -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) }) diff --git a/tests/integration/geo_test.go b/tests/integration/geo_test.go index 7b5a4e62b..86b7c54e8 100644 --- a/tests/integration/geo_test.go +++ b/tests/integration/geo_test.go @@ -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) }) diff --git a/tests/integration/hash_test.go b/tests/integration/hash_test.go index b7938d733..e4252c523 100644 --- a/tests/integration/hash_test.go +++ b/tests/integration/hash_test.go @@ -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) }) diff --git a/tests/integration/hyperloglog_test.go b/tests/integration/hyperloglog_test.go index 59d86e69d..97943766a 100644 --- a/tests/integration/hyperloglog_test.go +++ b/tests/integration/hyperloglog_test.go @@ -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) }) diff --git a/tests/integration/main_test.go b/tests/integration/main_test.go index f48bef963..c64d68cb1 100644 --- a/tests/integration/main_test.go +++ b/tests/integration/main_test.go @@ -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") } diff --git a/tests/integration/pubsub_test.go b/tests/integration/pubsub_test.go index 560188ea7..a06317b74 100644 --- a/tests/integration/pubsub_test.go +++ b/tests/integration/pubsub_test.go @@ -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) }) diff --git a/tests/integration/replication_test.go b/tests/integration/replication_test.go index 98dfba89b..6cd82085a 100644 --- a/tests/integration/replication_test.go +++ b/tests/integration/replication_test.go @@ -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() { diff --git a/tests/integration/set_test.go b/tests/integration/set_test.go index dfe39408f..2a96beca7 100644 --- a/tests/integration/set_test.go +++ b/tests/integration/set_test.go @@ -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) }) diff --git a/tests/integration/slowlog_test.go b/tests/integration/slowlog_test.go index cdb00cd2b..8d0fddc52 100644 --- a/tests/integration/slowlog_test.go +++ b/tests/integration/slowlog_test.go @@ -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) }) diff --git a/tests/integration/stream_test.go b/tests/integration/stream_test.go index 00016e14a..85b5baa72 100644 --- a/tests/integration/stream_test.go +++ b/tests/integration/stream_test.go @@ -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()) diff --git a/tests/integration/string_test.go b/tests/integration/string_test.go index fed216d5a..25a324374 100644 --- a/tests/integration/string_test.go +++ b/tests/integration/string_test.go @@ -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) }) diff --git a/tests/integration/txn_test.go b/tests/integration/txn_test.go index 450c235a7..2f7388f5b 100644 --- a/tests/integration/txn_test.go +++ b/tests/integration/txn_test.go @@ -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() { diff --git a/tests/integration/zset_test.go b/tests/integration/zset_test.go index abd9fb35b..7cb9924c2 100644 --- a/tests/integration/zset_test.go +++ b/tests/integration/zset_test.go @@ -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) })