Yangsx-1 commented on code in PR #1490:
URL:
https://github.com/apache/incubator-kvrocks/pull/1490#discussion_r1233089993
##########
tests/gocase/unit/type/zset/zset_test.go:
##########
@@ -318,6 +318,62 @@ func basicTests(t *testing.T, rdb *redis.Client, ctx
context.Context, encoding s
require.Equal(t, []redis.Z{{Score: 10, Member: "a"}},
rdb.ZPopMax(ctx, "ztmp", 3).Val())
})
+ t.Run(fmt.Sprintf("BZPOPMIN basics - %s", encoding), func(t *testing.T)
{
+ rdb.Del(ctx, "zseta")
+ rdb.Del(ctx, "zsetb")
+ rdb.ZAdd(ctx, "zseta", redis.Z{Score: 1, Member: "a"},
redis.Z{Score: 2, Member: "b"}, redis.Z{Score: 3, Member: "c"})
+ rdb.ZAdd(ctx, "zsetb", redis.Z{Score: 1, Member: "d"},
redis.Z{Score: 2, Member: "e"})
+ require.EqualValues(t, 3, rdb.ZCard(ctx, "zseta").Val())
+ require.EqualValues(t, 2, rdb.ZCard(ctx, "zsetb").Val())
+ resultz := rdb.BZPopMin(ctx, 0, "zseta", "zsetb").Val().Z
+ require.Equal(t, redis.Z{Score: 1, Member: "a"}, resultz)
+ resultz = rdb.BZPopMin(ctx, 0, "zseta", "zsetb").Val().Z
+ require.Equal(t, redis.Z{Score: 2, Member: "b"}, resultz)
+ resultz = rdb.BZPopMin(ctx, 0, "zsetb", "zseta").Val().Z
+ require.Equal(t, redis.Z{Score: 1, Member: "d"}, resultz)
+ resultz = rdb.BZPopMin(ctx, 0, "zsetb", "zseta").Val().Z
+ require.Equal(t, redis.Z{Score: 2, Member: "e"}, resultz)
+ resultz = rdb.BZPopMin(ctx, 0, "zseta", "zsetb").Val().Z
+ require.Equal(t, redis.Z{Score: 3, Member: "c"}, resultz)
+ var err = rdb.BZPopMin(ctx, time.Millisecond*1000, "zseta",
"zsetb").Err()
+ require.Equal(t, redis.Nil, err)
+
+ rd := srv.NewTCPClient()
+ defer func() { require.NoError(t, rd.Close()) }()
+ require.NoError(t, rd.WriteArgs("bzpopmin", "zseta", "0"))
+ time.Sleep(time.Millisecond * 1000)
Review Comment:
I think we need to wait for the client `rd` actually blocked.
The code has two client, if `rdb` add the key-value before `rd` actually
blocked, it will not test out whether the key-value is poped after another
client add.
Other go tests for command with block also have the same `sleep` operation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]