Skip to content

Commit

Permalink
test: txn-context-enabled test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
PokIsemaine committed Sep 8, 2024
1 parent df58c47 commit 559f6a8
Show file tree
Hide file tree
Showing 15 changed files with 427 additions and 72 deletions.
45 changes: 45 additions & 0 deletions tests/gocase/unit/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,48 @@ func TestChangeProtoMaxBulkLen(t *testing.T) {
// Must be >= 1MB
require.Error(t, rdb.ConfigSet(ctx, "proto-max-bulk-len", "1024").Err())
}

func TestGetConfigTxnContext(t *testing.T) {
srv := util.StartServer(t, map[string]string{
"txn-context-enabled": "yes",
})
defer srv.Close()

ctx := context.Background()
rdb := srv.NewClient()
defer func() { require.NoError(t, rdb.Close()) }()
val := rdb.ConfigGet(ctx, "txn-context-enabled").Val()
require.EqualValues(t, "yes", val["txn-context-enabled"])

// default value "no"
srv1 := util.StartServer(t, map[string]string{})
defer srv1.Close()

rdb = srv1.NewClient()
val = rdb.ConfigGet(ctx, "txn-context-enabled").Val()
require.EqualValues(t, "no", val["txn-context-enabled"])
}

func TestGenerateConfigsMatrix(t *testing.T) {
configOptions := []util.ConfigOptions{
{
Name: "txn-context-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
{
Name: "resp3-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
}

configsMatrix, err := util.GenerateConfigsMatrix(configOptions)

require.NoError(t, err)
require.Equal(t, 4, len(configsMatrix))
require.Contains(t, configsMatrix, util.KvrocksServerConfigs{"txn-context-enabled": "yes", "resp3-enabled": "yes"})
require.Contains(t, configsMatrix, util.KvrocksServerConfigs{"txn-context-enabled": "yes", "resp3-enabled": "no"})
require.Contains(t, configsMatrix, util.KvrocksServerConfigs{"txn-context-enabled": "no", "resp3-enabled": "yes"})
require.Contains(t, configsMatrix, util.KvrocksServerConfigs{"txn-context-enabled": "no", "resp3-enabled": "no"})
}
30 changes: 21 additions & 9 deletions tests/gocase/unit/geo/geo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,30 @@ func compareLists(list1, list2 []string) []string {
return result
}

func TestGeoWithRESP2(t *testing.T) {
testGeo(t, "no")
}
func TestGeo(t *testing.T) {
configOptions := []util.ConfigOptions{
{
Name: "txn-context-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
{
Name: "resp3-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
}

configsMatrix, err := util.GenerateConfigsMatrix(configOptions)
require.NoError(t, err)

func TestGeoWithRESP3(t *testing.T) {
testGeo(t, "yes")
for _, configs := range configsMatrix {
testGeo(t, configs)
}
}

var testGeo = func(t *testing.T, enabledRESP3 string) {
srv := util.StartServer(t, map[string]string{
"resp3-enabled": enabledRESP3,
})
var testGeo = func(t *testing.T, configs util.KvrocksServerConfigs) {
srv := util.StartServer(t, configs)
defer srv.Close()
ctx := context.Background()
rdb := srv.NewClient()
Expand Down
30 changes: 21 additions & 9 deletions tests/gocase/unit/pubsub/pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,30 @@ func receiveType[T any](t *testing.T, pubsub *redis.PubSub, typ T) T {
return msg.(T)
}

func TestPubSubWithRESP2(t *testing.T) {
testPubSub(t, "no")
}
func TestPubSub(t *testing.T) {
configOptions := []util.ConfigOptions{
{
Name: "txn-context-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
{
Name: "resp3-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
}

configsMatrix, err := util.GenerateConfigsMatrix(configOptions)
require.NoError(t, err)

func TestPubSubWithRESP3(t *testing.T) {
testPubSub(t, "yes")
for _, configs := range configsMatrix {
testPubSub(t, configs)
}
}

func testPubSub(t *testing.T, enabledRESP3 string) {
srv := util.StartServer(t, map[string]string{
"resp3-enabled": enabledRESP3,
})
func testPubSub(t *testing.T, configs util.KvrocksServerConfigs) {
srv := util.StartServer(t, configs)
defer srv.Close()

ctx := context.Background()
Expand Down
30 changes: 21 additions & 9 deletions tests/gocase/unit/scripting/function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,30 @@ func decodeListLibResult(t *testing.T, v interface{}) ListLibResult {
return ListLibResult{}
}

func TestFunctionsWithRESP3(t *testing.T) {
testFunctions(t, "yes")
}
func TestFunctions(t *testing.T) {
configOptions := []util.ConfigOptions{
{
Name: "txn-context-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
{
Name: "resp3-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
}

configsMatrix, err := util.GenerateConfigsMatrix(configOptions)
require.NoError(t, err)

func TestFunctionsWithoutRESP2(t *testing.T) {
testFunctions(t, "no")
for _, configs := range configsMatrix {
testFunctions(t, configs)
}
}

var testFunctions = func(t *testing.T, enabledRESP3 string) {
srv := util.StartServer(t, map[string]string{
"resp3-enabled": enabledRESP3,
})
var testFunctions = func(t *testing.T, config util.KvrocksServerConfigs) {
srv := util.StartServer(t, config)
defer srv.Close()

ctx := context.Background()
Expand Down
20 changes: 18 additions & 2 deletions tests/gocase/unit/type/bloom/bloom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,24 @@ import (
"github.com/stretchr/testify/require"
)

func TestBloom(t *testing.T) {
srv := util.StartServer(t, map[string]string{})
func TestBloomInfo(t *testing.T) {
configOptions := []util.ConfigOptions{
{
Name: "txn-context-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
}

configsMatrix, err := util.GenerateConfigsMatrix(configOptions)
require.NoError(t, err)

for _, configs := range configsMatrix {
testBloom(t, configs)
}
}
func testBloom(t *testing.T, configs util.KvrocksServerConfigs) {
srv := util.StartServer(t, configs)
defer srv.Close()
ctx := context.Background()
rdb := srv.NewClient()
Expand Down
30 changes: 21 additions & 9 deletions tests/gocase/unit/type/hash/hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,30 @@ func getVals(hash map[string]string) []string {
return r
}

func TestHashWithRESP2(t *testing.T) {
testHash(t, "no")
}
func TestHash(t *testing.T) {
configOptions := []util.ConfigOptions{
{
Name: "txn-context-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
{
Name: "resp3-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
}

configsMatrix, err := util.GenerateConfigsMatrix(configOptions)
require.NoError(t, err)

func TestHashWithRESP3(t *testing.T) {
testHash(t, "yes")
for _, configs := range configsMatrix {
testHash(t, configs)
}
}

var testHash = func(t *testing.T, enabledRESP3 string) {
srv := util.StartServer(t, map[string]string{
"resp3-enabled": enabledRESP3,
})
var testHash = func(t *testing.T, configs util.KvrocksServerConfigs) {
srv := util.StartServer(t, configs)
defer srv.Close()
ctx := context.Background()
rdb := srv.NewClient()
Expand Down
19 changes: 18 additions & 1 deletion tests/gocase/unit/type/incr/incr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,24 @@ import (
)

func TestIncr(t *testing.T) {
srv := util.StartServer(t, map[string]string{})
configOptions := []util.ConfigOptions{
{
Name: "txn-context-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
}

configsMatrix, err := util.GenerateConfigsMatrix(configOptions)
require.NoError(t, err)

for _, configs := range configsMatrix {
testIncr(t, configs)
}
}

func testIncr(t *testing.T, configs util.KvrocksServerConfigs) {
srv := util.StartServer(t, configs)
defer srv.Close()
ctx := context.Background()
rdb := srv.NewClient()
Expand Down
18 changes: 17 additions & 1 deletion tests/gocase/unit/type/json/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,23 @@ import (
)

func TestJson(t *testing.T) {
srv := util.StartServer(t, map[string]string{})
configOptions := []util.ConfigOptions{
{
Name: "txn-context-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
}

configsMatrix, err := util.GenerateConfigsMatrix(configOptions)
require.NoError(t, err)

for _, configs := range configsMatrix {
testJSON(t, configs)
}
}
func testJSON(t *testing.T, configs util.KvrocksServerConfigs) {
srv := util.StartServer(t, configs)
defer srv.Close()
ctx := context.Background()
rdb := srv.NewClient()
Expand Down
62 changes: 59 additions & 3 deletions tests/gocase/unit/type/list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,24 @@ var largeValue = map[string]string{
}

func TestLTRIM(t *testing.T) {
srv := util.StartServer(t, map[string]string{})
configOptions := []util.ConfigOptions{
{
Name: "txn-context-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
}

configsMatrix, err := util.GenerateConfigsMatrix(configOptions)
require.NoError(t, err)

for _, configs := range configsMatrix {
testLTRIM(t, configs)
}
}

func testLTRIM(t *testing.T, configs util.KvrocksServerConfigs) {
srv := util.StartServer(t, configs)
defer srv.Close()
ctx := context.Background()
rdb := srv.NewClient()
Expand Down Expand Up @@ -85,7 +102,24 @@ func TestLTRIM(t *testing.T) {
}

func TestZipList(t *testing.T) {
srv := util.StartServer(t, map[string]string{})
configOptions := []util.ConfigOptions{
{
Name: "txn-context-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
}

configsMatrix, err := util.GenerateConfigsMatrix(configOptions)
require.NoError(t, err)

for _, configs := range configsMatrix {
testZipList(t, configs)
}
}

func testZipList(t *testing.T, configs util.KvrocksServerConfigs) {
srv := util.StartServer(t, configs)
defer srv.Close()
ctx := context.Background()
rdb := srv.NewClientWithOption(&redis.Options{
Expand Down Expand Up @@ -233,7 +267,29 @@ func TestZipList(t *testing.T) {
}

func TestList(t *testing.T) {
srv := util.StartServer(t, map[string]string{})
configOptions := []util.ConfigOptions{
{
Name: "txn-context-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
{
Name: "resp3-enabled",
Options: []string{"yes", "no"},
ConfigType: util.YesNo,
},
}

configsMatrix, err := util.GenerateConfigsMatrix(configOptions)
require.NoError(t, err)

for _, configs := range configsMatrix {
testList(t, configs)
}
}

func testList(t *testing.T, configs util.KvrocksServerConfigs) {
srv := util.StartServer(t, configs)
defer srv.Close()
ctx := context.Background()
rdb := srv.NewClient()
Expand Down
Loading

0 comments on commit 559f6a8

Please sign in to comment.