Skip to content
Closed
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
3 changes: 2 additions & 1 deletion tests/gocase/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ linters-settings:
staticcheck:
checks:
- all
- '-QF1012' # disable the rule QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...))
- '-QF1012' # disable the rule QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...))
- '-SA1019' # disable the rule SA1019: redis command is deprecated
21 changes: 11 additions & 10 deletions tests/gocase/go.mod
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
module github.com/apache/kvrocks/tests/gocase

go 1.25
go 1.25.0

require (
github.com/redis/go-redis/v9 v9.17.2
github.com/shirou/gopsutil/v4 v4.25.12
github.com/redis/go-redis/v9 v9.18.0
github.com/shirou/gopsutil/v4 v4.26.5
github.com/stretchr/testify v1.11.1
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93
golang.org/x/sync v0.19.0
golang.org/x/exp v0.0.0-20260611194520-c48552f49976
golang.org/x/sync v0.21.0
)

require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/ebitengine/purego v0.9.1 // indirect
github.com/ebitengine/purego v0.10.1 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 // indirect
github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/tklauser/go-sysconf v0.3.16 // indirect
github.com/tklauser/numcpus v0.11.0 // indirect
github.com/tklauser/go-sysconf v0.4.0 // indirect
github.com/tklauser/numcpus v0.12.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/sys v0.39.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/sys v0.46.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
42 changes: 24 additions & 18 deletions tests/gocase/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,46 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/ebitengine/purego v0.9.1 h1:a/k2f2HQU3Pi399RPW1MOaZyhKJL9w/xFpKAg4q1s0A=
github.com/ebitengine/purego v0.9.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/ebitengine/purego v0.10.1 h1:dewVBCBT2GaMu1SrNTYxQhgQBethzfhiwvZiLGP/qyY=
github.com/ebitengine/purego v0.10.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 h1:PwQumkgq4/acIiZhtifTV5OUqqiP82UAl0h87xj/l9k=
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg=
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e h1:Q6MvJtQK/iRcRtzAscm/zF23XxJlbECiGPyRicsX+Ak=
github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/redis/go-redis/v9 v9.17.2 h1:P2EGsA4qVIM3Pp+aPocCJ7DguDHhqrXNhVcEp4ViluI=
github.com/redis/go-redis/v9 v9.17.2/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370=
github.com/shirou/gopsutil/v4 v4.25.12 h1:e7PvW/0RmJ8p8vPGJH4jvNkOyLmbkXgXW4m6ZPic6CY=
github.com/shirou/gopsutil/v4 v4.25.12/go.mod h1:EivAfP5x2EhLp2ovdpKSozecVXn1TmuG7SMzs/Wh4PU=
github.com/redis/go-redis/v9 v9.18.0 h1:pMkxYPkEbMPwRdenAzUNyFNrDgHx9U+DrBabWNfSRQs=
github.com/redis/go-redis/v9 v9.18.0/go.mod h1:k3ufPphLU5YXwNTUcCRXGxUoF1fqxnhFQmscfkCoDA0=
github.com/shirou/gopsutil/v4 v4.26.5 h1:RPcBXkpz7kOj9PqGFQOlBPZHsyaPvPVQc098y9RmCNM=
github.com/shirou/gopsutil/v4 v4.26.5/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA=
github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI=
github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw=
github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ=
github.com/tklauser/go-sysconf v0.4.0 h1:7H0uAN+7RkwWRaxhYXDLqa5V3LPrJeV8wmD9dRUgPQU=
github.com/tklauser/go-sysconf v0.4.0/go.mod h1:8mTNWyog7H+MpKijp4VmKJAd2bbYQ2zuUwkYRbUArPI=
github.com/tklauser/numcpus v0.12.0 h1:NR85qdvHA9pFse3x3weVZ0r0ST8R6l5RHbZrlRaqob4=
github.com/tklauser/numcpus v0.12.0/go.mod h1:ABHeXzJnr/qqwguhClkZKT1/8VABcYrsyUiUGobwWJg=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 h1:fQsdNF2N+/YewlRZiricy4P1iimyPKZ/xwniHj8Q2a0=
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93/go.mod h1:EPRbTFwzwjXj9NpYyyrvenVh9Y+GFeEvMNh7Xuz7xgU=
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
golang.org/x/exp v0.0.0-20260611194520-c48552f49976 h1:X8Hz2ImujgbmetVuW+w2YkyZChE3cBpZi2P158rTG9M=
golang.org/x/exp v0.0.0-20260611194520-c48552f49976/go.mod h1:vnf4pv9iKZXY58sQE1L86zmNWJ4159e1RkcWiLCkeEY=
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
18 changes: 9 additions & 9 deletions tests/gocase/integration/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestClusterNodes(t *testing.T) {
require.Equal(t, "0-100\n", fields[8])

// cluster slot command
slots := rdb.ClusterSlots(ctx).Val()
slots := rdb.ClusterShards(ctx).Val()
require.Len(t, slots, 1)
require.EqualValues(t, 0, slots[0].Start)
require.EqualValues(t, 100, slots[0].End)
Expand Down Expand Up @@ -263,7 +263,7 @@ func TestClusterDumpAndLoadClusterNodesInfo(t *testing.T) {
require.NoError(t, rdb2.Do(ctx, "clusterx", "SETNODES", clusterNodes, "1").Err())

srv1.Restart()
slots := rdb1.ClusterSlots(ctx).Val()
slots := rdb1.ClusterShards(ctx).Val()
require.Len(t, slots, 5)
require.EqualValues(t, 10000, slots[2].Start)
require.EqualValues(t, 10000, slots[2].End)
Expand All @@ -274,7 +274,7 @@ func TestClusterDumpAndLoadClusterNodesInfo(t *testing.T) {
newNodeID := "0123456789012345678901234567890123456789"
require.NoError(t, rdb2.Do(ctx, "clusterx", "SETNODEID", newNodeID).Err())
srv1.Restart()
slots = rdb1.ClusterSlots(ctx).Val()
slots = rdb1.ClusterShards(ctx).Val()
require.EqualValues(t, 10000, slots[2].Start)
require.EqualValues(t, 10000, slots[2].End)
nodes = rdb1.ClusterNodes(ctx).Val()
Expand Down Expand Up @@ -306,7 +306,7 @@ func TestClusterComplexTopology(t *testing.T) {
require.NoError(t, rdb.Do(ctx, "clusterx", "SETNODES", clusterNodes, "1").Err())
require.NoError(t, rdb.Do(ctx, "clusterx", "SETNODEID", nodeID).Err())

slots := rdb.ClusterSlots(ctx).Val()
slots := rdb.ClusterShards(ctx).Val()
require.Len(t, slots, 5)
require.EqualValues(t, 10000, slots[2].Start)
require.EqualValues(t, 10000, slots[2].End)
Expand All @@ -316,7 +316,7 @@ func TestClusterComplexTopology(t *testing.T) {
require.Contains(t, nodes, "0-2 4-8193 10000 10002-11002 16381-16383")
}

func TestClusterSlotSet(t *testing.T) {
func TestClusterShardSet(t *testing.T) {
t.Parallel()
ctx := context.Background()

Expand Down Expand Up @@ -347,8 +347,8 @@ func TestClusterSlotSet(t *testing.T) {
require.NoError(t, rdb1.Do(ctx, "clusterx", "setslot", "0", "node", nodeID2, "3").Err())
require.EqualValues(t, "3", rdb2.Do(ctx, "clusterx", "version").Val())
require.EqualValues(t, "3", rdb1.Do(ctx, "clusterx", "version").Val())
slots := rdb2.ClusterSlots(ctx).Val()
require.EqualValues(t, slots, rdb1.ClusterSlots(ctx).Val())
slots := rdb2.ClusterShards(ctx).Val()
require.EqualValues(t, slots, rdb1.ClusterShards(ctx).Val())
require.Len(t, slots, 2)
require.EqualValues(t, 0, slots[0].Start)
require.EqualValues(t, 0, slots[0].End)
Expand All @@ -361,8 +361,8 @@ func TestClusterSlotSet(t *testing.T) {
util.ErrorRegexp(t, rdb1.Set(ctx, slotKey, 0, 0).Err(), fmt.Sprintf("MOVED 0.*%d.*", srv2.Port()))
require.NoError(t, rdb2.Do(ctx, "clusterx", "setslot", "1-3 4", "node", nodeID2, "4").Err())
require.NoError(t, rdb1.Do(ctx, "clusterx", "setslot", "1-3 4", "node", nodeID2, "4").Err())
slots = rdb2.ClusterSlots(ctx).Val()
require.EqualValues(t, slots, rdb1.ClusterSlots(ctx).Val())
slots = rdb2.ClusterShards(ctx).Val()
require.EqualValues(t, slots, rdb1.ClusterShards(ctx).Val())
require.Len(t, slots, 2)
require.EqualValues(t, 0, slots[0].Start)
require.EqualValues(t, 4, slots[0].End)
Expand Down
6 changes: 3 additions & 3 deletions tests/gocase/integration/replication/replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestReplicationWithHostname(t *testing.T) {
defer func() { require.NoError(t, rdbB.Close()) }()

t.Run("Set instance A as slave of B with localhost, for issue #1182", func(t *testing.T) {
require.NoError(t, rdbA.SlaveOf(context.Background(), "localhost", fmt.Sprintf("%d", srvB.Port())).Err())
require.NoError(t, rdbA.ReplicaOf(context.Background(), "localhost", fmt.Sprintf("%d", srvB.Port())).Err())
util.SlaveOf(t, rdbA, srvB)
util.WaitForSync(t, rdbA)
ctx := context.Background()
Expand Down Expand Up @@ -537,7 +537,7 @@ func TestShouldNotReplicate(t *testing.T) {
defer func() { require.NoError(t, slaveClient.Close()) }()

t.Run("Setting server as replica of itself should throw error", func(t *testing.T) {
err := slaveClient.SlaveOf(ctx, slave.Host(), fmt.Sprintf("%d", slave.Port())).Err()
err := slaveClient.ReplicaOf(ctx, slave.Host(), fmt.Sprintf("%d", slave.Port())).Err()
require.Equal(t, "ERR can't replicate itself", err.Error())
require.Equal(t, "master", util.FindInfoEntry(slaveClient, "role"))
})
Expand All @@ -546,7 +546,7 @@ func TestShouldNotReplicate(t *testing.T) {
util.SlaveOf(t, slaveClient, master)
util.WaitForSync(t, slaveClient)
require.Equal(t, "slave", util.FindInfoEntry(slaveClient, "role"))
err := masterClient.SlaveOf(ctx, slave.Host(), fmt.Sprintf("%d", slave.Port())).Err()
err := masterClient.ReplicaOf(ctx, slave.Host(), fmt.Sprintf("%d", slave.Port())).Err()
require.EqualErrorf(t, err, "ERR can't replicate your own replicas", err.Error())
require.Equal(t, "master", util.FindInfoEntry(masterClient, "role"))
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestSlowConsumerBug(t *testing.T) {
defer func() { require.NoError(t, slaveClient.Close()) }()

// Connect slave through proxy
require.NoError(t, slaveClient.SlaveOf(ctx, "127.0.0.1", fmt.Sprintf("%d", proxyPort)).Err())
require.NoError(t, slaveClient.ReplicaOf(ctx, "127.0.0.1", fmt.Sprintf("%d", proxyPort)).Err())

// Wait for initial sync
require.Eventually(t, func() bool {
Expand Down Expand Up @@ -194,7 +194,7 @@ func TestSlowConsumerBlocksIndefinitely(t *testing.T) {
defer func() { require.NoError(t, slaveClient.Close()) }()

// Connect and sync
require.NoError(t, slaveClient.SlaveOf(ctx, "127.0.0.1", fmt.Sprintf("%d", proxyPort)).Err())
require.NoError(t, slaveClient.ReplicaOf(ctx, "127.0.0.1", fmt.Sprintf("%d", proxyPort)).Err())
require.Eventually(t, func() bool {
return util.FindInfoEntry(slaveClient, "master_link_status") == "up"
}, 10*time.Second, 100*time.Millisecond)
Expand Down
2 changes: 1 addition & 1 deletion tests/gocase/integration/rsid/rsid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestRSIDMasterAndReplicaYes(t *testing.T) {
})

t.Run("replica can partially re-sync after changing master but having the same history", func(t *testing.T) {
require.NoError(t, rdbA.SlaveOf(ctx, "127.0.0.1", "1025").Err())
require.NoError(t, rdbA.ReplicaOf(ctx, "127.0.0.1", "1025").Err())
time.Sleep(time.Second)

// now topology is:
Expand Down
2 changes: 1 addition & 1 deletion tests/gocase/unit/multi/multi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func TestMulti(t *testing.T) {
rdb := newSrv.NewClient()
defer func() { require.NoError(t, rdb.Close()) }()
require.NoError(t, rdb.Do(ctx, "MULTI").Err())
require.NoError(t, rdb.SlaveOf(ctx, "NO", "ONE").Err())
require.NoError(t, rdb.ReplicaOf(ctx, "NO", "ONE").Err())
require.NoError(t, rdb.ConfigRewrite(ctx).Err())
require.NoError(t, rdb.Do(ctx, "CLIENT", "KILL", "TYPE", "normal").Err())
require.NoError(t, rdb.Do(ctx, "CLIENT", "KILL", "TYPE", "PUBSUB").Err())
Expand Down
2 changes: 1 addition & 1 deletion tests/gocase/util/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func WaitForOffsetSync(t testing.TB, master, slave *redis.Client, waitFor time.D
}

func SlaveOf(t testing.TB, slave *redis.Client, master *KvrocksServer) {
require.NoError(t, slave.SlaveOf(context.Background(), master.Host(), fmt.Sprintf("%d", master.Port())).Err())
require.NoError(t, slave.ReplicaOf(context.Background(), master.Host(), fmt.Sprintf("%d", master.Port())).Err())
}

func Populate(t testing.TB, rdb *redis.Client, prefix string, n, size int) {
Expand Down
Loading