You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by GitBox <gi...@apache.org> on 2022/09/11 08:37:45 UTC

[GitHub] [incubator-kvrocks] tanruixiang opened a new pull request, #858: Move TCL test unit/type/set to Go case

tanruixiang opened a new pull request, #858:
URL: https://github.com/apache/incubator-kvrocks/pull/858

   it closes #819 


-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] tanruixiang commented on pull request #858: Move TCL test unit/type/set to Go case

Posted by GitBox <gi...@apache.org>.
tanruixiang commented on PR #858:
URL: https://github.com/apache/incubator-kvrocks/pull/858#issuecomment-1243410874

   @tisonkun @git-hulk  @PragmaTwice  HI.  I found that the results of CI were a bit random. My same code failed in different places the first two times, and I passed it the last time.


-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] tisonkun merged pull request #858: Move TCL test unit/type/set to Go case

Posted by GitBox <gi...@apache.org>.
tisonkun merged PR #858:
URL: https://github.com/apache/incubator-kvrocks/pull/858


-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] tanruixiang commented on pull request #858: Move TCL test unit/type/set to Go case

Posted by GitBox <gi...@apache.org>.
tanruixiang commented on PR #858:
URL: https://github.com/apache/incubator-kvrocks/pull/858#issuecomment-1243185429

   Hi. I found that the CI failure was accidental, and it seemed that it had nothing to do with my modification. [fail 1](https://github.com/apache/incubator-kvrocks/runs/8297760486?check_suite_focus=true) [fail 2](https://github.com/apache/incubator-kvrocks/runs/8294594464?check_suite_focus=true)


-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] tanruixiang commented on pull request #858: Move TCL test unit/type/set to Go case

Posted by GitBox <gi...@apache.org>.
tanruixiang commented on PR #858:
URL: https://github.com/apache/incubator-kvrocks/pull/858#issuecomment-1244893459

   > @tanruixiang BTW, I'll be away for a few days. You may not expect my reviews in time for other patches. You can always ask for other committers' reviews :)
   
   ok. thank you very much.


-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] git-hulk commented on pull request #858: Move TCL test unit/type/set to Go case

Posted by GitBox <gi...@apache.org>.
git-hulk commented on PR #858:
URL: https://github.com/apache/incubator-kvrocks/pull/858#issuecomment-1244831111

   > ```
   > BenchmarkLTRIM
   > BenchmarkLTRIM/LTRIM_stress_testing_-_zipList
   > BenchmarkLTRIM/LTRIM_stress_testing_-_zipList-3         	       1	10113128988 ns/op
   > BenchmarkLTRIM/LTRIM_stress_testing_-_linkedList
   >     list_test.go:80: 
   >         	Error Trace:	/Users/runner/work/incubator-kvrocks/incubator-kvrocks/tests/gocase/unit/type/list/list_test.go:80
   >         	            				/Users/runner/work/incubator-kvrocks/incubator-kvrocks/tests/gocase/unit/type/list/benchmark.go:193
   >         	            				/Users/runner/work/incubator-kvrocks/incubator-kvrocks/tests/gocase/unit/type/list/benchmark.go:233
   >         	            				/Users/runner/work/incubator-kvrocks/incubator-kvrocks/tests/gocase/unit/type/list/asm_amd64.s:1594
   >         	Error:      	Received unexpected error:
   >         	            	i/o timeout
   >         	Test:       	BenchmarkLTRIM/LTRIM_stress_testing_-_linkedList
   > --- FAIL: BenchmarkLTRIM/LTRIM_stress_testing_-_linkedList
   > --- FAIL: BenchmarkLTRIM
   > FAIL
   > ```
   > 
   > Seems a new unstable test.
   
   Looks like bench test may cause Kvrocks high latency and then client got timeout error.


-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] tisonkun commented on pull request #858: Move TCL test unit/type/set to Go case

Posted by GitBox <gi...@apache.org>.
tisonkun commented on PR #858:
URL: https://github.com/apache/incubator-kvrocks/pull/858#issuecomment-1244823869

   ```
   BenchmarkLTRIM
   BenchmarkLTRIM/LTRIM_stress_testing_-_zipList
   BenchmarkLTRIM/LTRIM_stress_testing_-_zipList-3         	       1	10113128988 ns/op
   BenchmarkLTRIM/LTRIM_stress_testing_-_linkedList
       list_test.go:80: 
           	Error Trace:	/Users/runner/work/incubator-kvrocks/incubator-kvrocks/tests/gocase/unit/type/list/list_test.go:80
           	            				/Users/runner/work/incubator-kvrocks/incubator-kvrocks/tests/gocase/unit/type/list/benchmark.go:193
           	            				/Users/runner/work/incubator-kvrocks/incubator-kvrocks/tests/gocase/unit/type/list/benchmark.go:233
           	            				/Users/runner/work/incubator-kvrocks/incubator-kvrocks/tests/gocase/unit/type/list/asm_amd64.s:1594
           	Error:      	Received unexpected error:
           	            	i/o timeout
           	Test:       	BenchmarkLTRIM/LTRIM_stress_testing_-_linkedList
   --- FAIL: BenchmarkLTRIM/LTRIM_stress_testing_-_linkedList
   --- FAIL: BenchmarkLTRIM
   FAIL
   ```
   
   Seems a new unstable test.


-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] tanruixiang commented on a diff in pull request #858: Move TCL test unit/type/set to Go case

Posted by GitBox <gi...@apache.org>.
tanruixiang commented on code in PR #858:
URL: https://github.com/apache/incubator-kvrocks/pull/858#discussion_r968501731


##########
tests/gocase/unit/type/set/set_test.go:
##########
@@ -0,0 +1,741 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package set
+
+import (
+	"context"
+	"sort"
+	"strconv"
+	"testing"
+
+	"github.com/apache/incubator-kvrocks/tests/gocase/util"
+	"github.com/go-redis/redis/v9"
+	"github.com/stretchr/testify/require"
+)
+
+func CreateSet(t *testing.T, rdb *redis.Client, ctx context.Context, key string, entries []interface{}) {
+	require.NoError(t, rdb.Del(ctx, key).Err())
+	for _, entry := range entries {
+		switch entry := entry.(type) {
+		default:
+			require.NoError(t, rdb.SAdd(ctx, key, entry).Err())
+		}
+	}
+}
+
+func TestSet(t *testing.T) {
+	srv := util.StartServer(t, map[string]string{})
+	defer srv.Close()
+	ctx := context.Background()
+	rdb := srv.NewClient()
+	defer func() { require.NoError(t, rdb.Close()) }()
+
+	t.Run("SADD, SCARD, SISMEMBER, SMISMEMBER, SMEMBERS basics - regular set", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{"foo"})
+		require.EqualValues(t, 1, rdb.SAdd(ctx, "myset", "bar").Val())
+		require.EqualValues(t, 0, rdb.SAdd(ctx, "myset", "bar").Val())
+		require.EqualValues(t, 2, rdb.SCard(ctx, "myset").Val())
+		require.EqualValues(t, true, rdb.SIsMember(ctx, "myset", "foo").Val())
+		require.EqualValues(t, true, rdb.SIsMember(ctx, "myset", "bar").Val())
+		require.EqualValues(t, false, rdb.SIsMember(ctx, "myset", "bla").Val())
+		require.EqualValues(t, []bool{true}, rdb.SMIsMember(ctx, "myset", "foo").Val())
+		require.EqualValues(t, []bool{true, true}, rdb.SMIsMember(ctx, "myset", "foo", "bar").Val())
+		require.EqualValues(t, []bool{true, false}, rdb.SMIsMember(ctx, "myset", "foo", "bla").Val())
+		require.EqualValues(t, []bool{false, true}, rdb.SMIsMember(ctx, "myset", "bla", "foo").Val())
+		require.EqualValues(t, []bool{false}, rdb.SMIsMember(ctx, "myset", "bla").Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"bar", "foo"}, cmd.Val())
+	})
+
+	t.Run("SADD, SCARD, SISMEMBER, SMISMEMBER, SMEMBERS basics - intset", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{17})
+		require.EqualValues(t, 1, rdb.SAdd(ctx, "myset", 16).Val())
+		require.EqualValues(t, 0, rdb.SAdd(ctx, "myset", 16).Val())
+		require.EqualValues(t, 2, rdb.SCard(ctx, "myset").Val())
+		require.EqualValues(t, true, rdb.SIsMember(ctx, "myset", 16).Val())
+		require.EqualValues(t, true, rdb.SIsMember(ctx, "myset", 17).Val())
+		require.EqualValues(t, false, rdb.SIsMember(ctx, "myset", 18).Val())
+		require.EqualValues(t, []bool{true}, rdb.SMIsMember(ctx, "myset", 16).Val())
+		require.EqualValues(t, []bool{true, true}, rdb.SMIsMember(ctx, "myset", 16, 17).Val())
+		require.EqualValues(t, []bool{true, false}, rdb.SMIsMember(ctx, "myset", 16, 18).Val())
+		require.EqualValues(t, []bool{false, true}, rdb.SMIsMember(ctx, "myset", 18, 16).Val())
+		require.EqualValues(t, []bool{false}, rdb.SMIsMember(ctx, "myset", 18).Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"16", "17"}, cmd.Val())
+	})
+
+	t.Run("SMISMEMBER against non set", func(t *testing.T) {
+		require.ErrorContains(t, rdb.LPush(ctx, "myset", "foo").Err(), "WRONGTYPE")
+	})
+
+	t.Run("SMISMEMBER non existing key", func(t *testing.T) {
+		require.EqualValues(t, []bool{false}, rdb.SMIsMember(ctx, "myset1", "foo").Val())
+		require.EqualValues(t, []bool{false, false}, rdb.SMIsMember(ctx, "myset1", "foo", "bar").Val())
+	})
+
+	t.Run("SMISMEMBER requires one or more members", func(t *testing.T) {
+		require.NoError(t, rdb.Del(ctx, "zmscoretest").Err())
+		require.NoError(t, rdb.ZAdd(ctx, "zmscoretest", redis.Z{Score: 10, Member: "x"}).Err())
+		require.NoError(t, rdb.ZAdd(ctx, "zmscoretest", redis.Z{Score: 20, Member: "y"}).Err())
+		util.ErrorRegexp(t, rdb.Do(ctx, "smismember", "zmscoretest").Err(), ".*ERR.*wrong.*number.*arg.*")
+	})
+
+	t.Run("SADD against non set", func(t *testing.T) {
+		require.NoError(t, rdb.LPush(ctx, "mylist", "foo").Err())
+		util.ErrorRegexp(t, rdb.SAdd(ctx, "mylist", "bar").Err(), ".*WRONGTYPE.*")
+	})
+
+	t.Run("SADD a non-integer against an intset", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{1, 2, 3})
+		require.EqualValues(t, 1, rdb.SAdd(ctx, "myset", "a").Val())
+	})
+
+	t.Run("SADD an integer larger than 64 bits", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{"213244124402402314402033402"})
+		require.EqualValues(t, true, rdb.SIsMember(ctx, "myset", "213244124402402314402033402").Val())
+		require.EqualValues(t, []bool{true}, rdb.SMIsMember(ctx, "myset", "213244124402402314402033402").Val())
+	})
+
+	t.Run("SADD overflows the maximum allowed integers in an intset", func(t *testing.T) {
+		require.NoError(t, rdb.Del(ctx, "myset").Err())
+		for i := 0; i < 512; i++ {
+			require.NoError(t, rdb.SAdd(ctx, "myset", i).Err())
+		}
+		require.EqualValues(t, 1, rdb.SAdd(ctx, "myset", 512).Val())
+	})
+
+	t.Run("Variadic SADD", func(t *testing.T) {
+		require.NoError(t, rdb.Del(ctx, "myset").Err())
+		require.EqualValues(t, 3, rdb.SAdd(ctx, "myset", "a", "b", "c").Val())
+		require.EqualValues(t, 2, rdb.SAdd(ctx, "myset", "A", "a", "b", "c", "B").Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"A", "B", "a", "b", "c"}, cmd.Val())
+	})
+
+	t.Run("SREM basics - regular set", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{"foo", "bar", "ciao"})
+		require.EqualValues(t, 0, rdb.SRem(ctx, "myset", "qux").Val())
+		require.EqualValues(t, 1, rdb.SRem(ctx, "myset", "foo").Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"bar", "ciao"}, cmd.Val())
+	})
+
+	t.Run("SREM basics - intset", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{3, 4, 5})
+		require.EqualValues(t, 0, rdb.SRem(ctx, "myset", 6).Val())
+		require.EqualValues(t, 1, rdb.SRem(ctx, "myset", 4).Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"3", "5"}, cmd.Val())
+	})
+
+	t.Run("SREM with multiple arguments", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{"a", "b", "c", "d"})
+		require.EqualValues(t, 0, rdb.SRem(ctx, "myset", "k", "k", "k").Val())
+		require.EqualValues(t, 2, rdb.SRem(ctx, "myset", "b", "d", "x", "y").Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"a", "c"}, cmd.Val())
+	})
+
+	t.Run("SREM variadic version with more args needed to destroy the key", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{1, 2, 3})
+		require.EqualValues(t, 3, rdb.SRem(ctx, "myset", 1, 2, 3, 4, 5, 6, 7, 8).Val())
+	})
+
+	t.Run("SREM variadic version with more args needed to destroy the key", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{1, 2, 3})
+		require.EqualValues(t, 3, rdb.SRem(ctx, "myset", 1, 2, 3, 4, 5, 6, 7, 8).Val())
+	})
+
+	for _, dstype := range [2]string{"hashtable", "intset"} {
+		for i := 1; i <= 5; i++ {
+			require.NoError(t, rdb.Del(ctx, "set"+strconv.Itoa(i)).Err())
+		}
+		for i := 0; i < 200; i++ {
+			require.NoError(t, rdb.SAdd(ctx, "set1", i).Err())
+			require.NoError(t, rdb.SAdd(ctx, "set2", i+195).Err())
+		}
+		for _, i := range []int{199, 195, 100, 2000} {
+			require.NoError(t, rdb.SAdd(ctx, "set3", i).Err())
+		}
+		for i := 5; i < 200; i++ {
+			require.NoError(t, rdb.SAdd(ctx, "set4", i).Err())
+		}
+		var larger interface{}
+		larger = 200
+		require.NoError(t, rdb.SAdd(ctx, "set5", 0).Err())
+		if dstype == "hashtable" {
+			larger = "foo"
+		}
+		for i := 1; i <= 5; i++ {
+			switch larger := larger.(type) {
+			default:
+				require.NoError(t, rdb.SAdd(ctx, "set"+strconv.Itoa(i), larger).Err())
+			}
+		}
+		t.Run("SINTER with two sets - "+dstype, func(t *testing.T) {
+			cmd := rdb.SInter(ctx, "set1", "set2")
+			require.NoError(t, cmd.Err())
+			sort.Strings(cmd.Val())
+			switch larger := larger.(type) {
+			case int:
+				require.EqualValues(t, []string{"195", "196", "197", "198", "199", strconv.Itoa(larger)}, cmd.Val())
+			case string:
+				require.EqualValues(t, []string{"195", "196", "197", "198", "199", larger}, cmd.Val())
+			}
+		})
+
+		t.Run("SINTERSTORE with two sets - "+dstype, func(t *testing.T) {
+			require.NoError(t, rdb.SInterStore(ctx, "setres", "set1", "set2").Err())
+			cmd := rdb.SMembers(ctx, "setres")
+			require.NoError(t, cmd.Err())
+			sort.Strings(cmd.Val())
+
+			switch larger := larger.(type) {
+			case int:
+				require.EqualValues(t, []string{"195", "196", "197", "198", "199", strconv.Itoa(larger)}, cmd.Val())
+			case string:
+				require.EqualValues(t, []string{"195", "196", "197", "198", "199", larger}, cmd.Val())
+			}
+		})
+
+		t.Run("SUNION with two sets - "+dstype, func(t *testing.T) {
+			set1 := rdb.SMembers(ctx, "set1")
+			require.NoError(t, set1.Err())
+			set2 := rdb.SMembers(ctx, "set2")
+			require.NoError(t, set2.Err())
+			var expect []string
+			var vis = make(map[string]bool)
+			for _, i := range set1.Val() {

Review Comment:
   ok. I have added it.



-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] git-hulk commented on a diff in pull request #858: Move TCL test unit/type/set to Go case

Posted by GitBox <gi...@apache.org>.
git-hulk commented on code in PR #858:
URL: https://github.com/apache/incubator-kvrocks/pull/858#discussion_r969071143


##########
tests/gocase/unit/type/set/set_test.go:
##########
@@ -0,0 +1,741 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package set
+
+import (
+	"context"
+	"sort"
+	"strconv"
+	"testing"
+
+	"github.com/apache/incubator-kvrocks/tests/gocase/util"
+	"github.com/go-redis/redis/v9"
+	"github.com/stretchr/testify/require"
+)
+
+func CreateSet(t *testing.T, rdb *redis.Client, ctx context.Context, key string, entries []interface{}) {
+	require.NoError(t, rdb.Del(ctx, key).Err())
+	for _, entry := range entries {
+		switch entry := entry.(type) {
+		default:
+			require.NoError(t, rdb.SAdd(ctx, key, entry).Err())
+		}
+	}
+}
+
+func TestSet(t *testing.T) {
+	srv := util.StartServer(t, map[string]string{})
+	defer srv.Close()
+	ctx := context.Background()
+	rdb := srv.NewClient()
+	defer func() { require.NoError(t, rdb.Close()) }()
+
+	t.Run("SADD, SCARD, SISMEMBER, SMISMEMBER, SMEMBERS basics - regular set", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{"foo"})
+		require.EqualValues(t, 1, rdb.SAdd(ctx, "myset", "bar").Val())
+		require.EqualValues(t, 0, rdb.SAdd(ctx, "myset", "bar").Val())
+		require.EqualValues(t, 2, rdb.SCard(ctx, "myset").Val())
+		require.EqualValues(t, true, rdb.SIsMember(ctx, "myset", "foo").Val())
+		require.EqualValues(t, true, rdb.SIsMember(ctx, "myset", "bar").Val())
+		require.EqualValues(t, false, rdb.SIsMember(ctx, "myset", "bla").Val())
+		require.EqualValues(t, []bool{true}, rdb.SMIsMember(ctx, "myset", "foo").Val())
+		require.EqualValues(t, []bool{true, true}, rdb.SMIsMember(ctx, "myset", "foo", "bar").Val())
+		require.EqualValues(t, []bool{true, false}, rdb.SMIsMember(ctx, "myset", "foo", "bla").Val())
+		require.EqualValues(t, []bool{false, true}, rdb.SMIsMember(ctx, "myset", "bla", "foo").Val())
+		require.EqualValues(t, []bool{false}, rdb.SMIsMember(ctx, "myset", "bla").Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"bar", "foo"}, cmd.Val())
+	})
+
+	t.Run("SADD, SCARD, SISMEMBER, SMISMEMBER, SMEMBERS basics - intset", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{17})
+		require.EqualValues(t, 1, rdb.SAdd(ctx, "myset", 16).Val())
+		require.EqualValues(t, 0, rdb.SAdd(ctx, "myset", 16).Val())
+		require.EqualValues(t, 2, rdb.SCard(ctx, "myset").Val())
+		require.EqualValues(t, true, rdb.SIsMember(ctx, "myset", 16).Val())
+		require.EqualValues(t, true, rdb.SIsMember(ctx, "myset", 17).Val())
+		require.EqualValues(t, false, rdb.SIsMember(ctx, "myset", 18).Val())
+		require.EqualValues(t, []bool{true}, rdb.SMIsMember(ctx, "myset", 16).Val())
+		require.EqualValues(t, []bool{true, true}, rdb.SMIsMember(ctx, "myset", 16, 17).Val())
+		require.EqualValues(t, []bool{true, false}, rdb.SMIsMember(ctx, "myset", 16, 18).Val())
+		require.EqualValues(t, []bool{false, true}, rdb.SMIsMember(ctx, "myset", 18, 16).Val())
+		require.EqualValues(t, []bool{false}, rdb.SMIsMember(ctx, "myset", 18).Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"16", "17"}, cmd.Val())
+	})
+
+	t.Run("SMISMEMBER against non set", func(t *testing.T) {
+		require.ErrorContains(t, rdb.LPush(ctx, "myset", "foo").Err(), "WRONGTYPE")
+	})
+
+	t.Run("SMISMEMBER non existing key", func(t *testing.T) {
+		require.EqualValues(t, []bool{false}, rdb.SMIsMember(ctx, "myset1", "foo").Val())
+		require.EqualValues(t, []bool{false, false}, rdb.SMIsMember(ctx, "myset1", "foo", "bar").Val())
+	})
+
+	t.Run("SMISMEMBER requires one or more members", func(t *testing.T) {
+		require.NoError(t, rdb.Del(ctx, "zmscoretest").Err())
+		require.NoError(t, rdb.ZAdd(ctx, "zmscoretest", redis.Z{Score: 10, Member: "x"}).Err())
+		require.NoError(t, rdb.ZAdd(ctx, "zmscoretest", redis.Z{Score: 20, Member: "y"}).Err())
+		util.ErrorRegexp(t, rdb.Do(ctx, "smismember", "zmscoretest").Err(), ".*ERR.*wrong.*number.*arg.*")
+	})
+
+	t.Run("SADD against non set", func(t *testing.T) {
+		require.NoError(t, rdb.LPush(ctx, "mylist", "foo").Err())
+		util.ErrorRegexp(t, rdb.SAdd(ctx, "mylist", "bar").Err(), ".*WRONGTYPE.*")
+	})
+
+	t.Run("SADD a non-integer against an intset", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{1, 2, 3})
+		require.EqualValues(t, 1, rdb.SAdd(ctx, "myset", "a").Val())
+	})
+
+	t.Run("SADD an integer larger than 64 bits", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{"213244124402402314402033402"})
+		require.EqualValues(t, true, rdb.SIsMember(ctx, "myset", "213244124402402314402033402").Val())
+		require.EqualValues(t, []bool{true}, rdb.SMIsMember(ctx, "myset", "213244124402402314402033402").Val())
+	})
+
+	t.Run("SADD overflows the maximum allowed integers in an intset", func(t *testing.T) {
+		require.NoError(t, rdb.Del(ctx, "myset").Err())
+		for i := 0; i < 512; i++ {
+			require.NoError(t, rdb.SAdd(ctx, "myset", i).Err())
+		}
+		require.EqualValues(t, 1, rdb.SAdd(ctx, "myset", 512).Val())
+	})
+
+	t.Run("Variadic SADD", func(t *testing.T) {
+		require.NoError(t, rdb.Del(ctx, "myset").Err())
+		require.EqualValues(t, 3, rdb.SAdd(ctx, "myset", "a", "b", "c").Val())
+		require.EqualValues(t, 2, rdb.SAdd(ctx, "myset", "A", "a", "b", "c", "B").Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"A", "B", "a", "b", "c"}, cmd.Val())
+	})
+
+	t.Run("SREM basics - regular set", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{"foo", "bar", "ciao"})
+		require.EqualValues(t, 0, rdb.SRem(ctx, "myset", "qux").Val())
+		require.EqualValues(t, 1, rdb.SRem(ctx, "myset", "foo").Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"bar", "ciao"}, cmd.Val())
+	})
+
+	t.Run("SREM basics - intset", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{3, 4, 5})
+		require.EqualValues(t, 0, rdb.SRem(ctx, "myset", 6).Val())
+		require.EqualValues(t, 1, rdb.SRem(ctx, "myset", 4).Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"3", "5"}, cmd.Val())
+	})
+
+	t.Run("SREM with multiple arguments", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{"a", "b", "c", "d"})
+		require.EqualValues(t, 0, rdb.SRem(ctx, "myset", "k", "k", "k").Val())
+		require.EqualValues(t, 2, rdb.SRem(ctx, "myset", "b", "d", "x", "y").Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"a", "c"}, cmd.Val())
+	})
+
+	t.Run("SREM variadic version with more args needed to destroy the key", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{1, 2, 3})
+		require.EqualValues(t, 3, rdb.SRem(ctx, "myset", 1, 2, 3, 4, 5, 6, 7, 8).Val())
+	})
+
+	t.Run("SREM variadic version with more args needed to destroy the key", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{1, 2, 3})
+		require.EqualValues(t, 3, rdb.SRem(ctx, "myset", 1, 2, 3, 4, 5, 6, 7, 8).Val())
+	})
+
+	for _, dstype := range [2]string{"hashtable", "intset"} {
+		for i := 1; i <= 5; i++ {
+			require.NoError(t, rdb.Del(ctx, "set"+strconv.Itoa(i)).Err())
+		}
+		for i := 0; i < 200; i++ {
+			require.NoError(t, rdb.SAdd(ctx, "set1", i).Err())
+			require.NoError(t, rdb.SAdd(ctx, "set2", i+195).Err())
+		}
+		for _, i := range []int{199, 195, 100, 2000} {
+			require.NoError(t, rdb.SAdd(ctx, "set3", i).Err())
+		}
+		for i := 5; i < 200; i++ {
+			require.NoError(t, rdb.SAdd(ctx, "set4", i).Err())
+		}
+		var larger interface{}
+		larger = 200
+		require.NoError(t, rdb.SAdd(ctx, "set5", 0).Err())
+		if dstype == "hashtable" {
+			larger = "foo"
+		}
+		for i := 1; i <= 5; i++ {
+			switch larger := larger.(type) {
+			default:
+				require.NoError(t, rdb.SAdd(ctx, "set"+strconv.Itoa(i), larger).Err())
+			}
+		}
+		t.Run("SINTER with two sets - "+dstype, func(t *testing.T) {
+			cmd := rdb.SInter(ctx, "set1", "set2")
+			require.NoError(t, cmd.Err())
+			sort.Strings(cmd.Val())
+			switch larger := larger.(type) {
+			case int:
+				require.EqualValues(t, []string{"195", "196", "197", "198", "199", strconv.Itoa(larger)}, cmd.Val())
+			case string:
+				require.EqualValues(t, []string{"195", "196", "197", "198", "199", larger}, cmd.Val())
+			}
+		})
+
+		t.Run("SINTERSTORE with two sets - "+dstype, func(t *testing.T) {
+			require.NoError(t, rdb.SInterStore(ctx, "setres", "set1", "set2").Err())
+			cmd := rdb.SMembers(ctx, "setres")
+			require.NoError(t, cmd.Err())
+			sort.Strings(cmd.Val())
+
+			switch larger := larger.(type) {
+			case int:
+				require.EqualValues(t, []string{"195", "196", "197", "198", "199", strconv.Itoa(larger)}, cmd.Val())
+			case string:
+				require.EqualValues(t, []string{"195", "196", "197", "198", "199", larger}, cmd.Val())
+			}
+		})
+
+		t.Run("SUNION with two sets - "+dstype, func(t *testing.T) {
+			set1 := rdb.SMembers(ctx, "set1")
+			require.NoError(t, set1.Err())
+			set2 := rdb.SMembers(ctx, "set2")
+			require.NoError(t, set2.Err())
+			var expect []string
+			var vis = make(map[string]bool)
+			for _, i := range set1.Val() {

Review Comment:
   Thanks



-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] tisonkun commented on pull request #858: Move TCL test unit/type/set to Go case

Posted by GitBox <gi...@apache.org>.
tisonkun commented on PR #858:
URL: https://github.com/apache/incubator-kvrocks/pull/858#issuecomment-1243631743

   > some tcl random failures
   
   I notice they're all for `scripting.tcl`. If you found any failure for others, you can point it out. I hope when migrating tests to Go cases, we can dig a big to prevent new unstable tests.


-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] tisonkun commented on pull request #858: Move TCL test unit/type/set to Go case

Posted by GitBox <gi...@apache.org>.
tisonkun commented on PR #858:
URL: https://github.com/apache/incubator-kvrocks/pull/858#issuecomment-1244835194

   @git-hulk see #870 .


-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] git-hulk commented on a diff in pull request #858: Move TCL test unit/type/set to Go case

Posted by GitBox <gi...@apache.org>.
git-hulk commented on code in PR #858:
URL: https://github.com/apache/incubator-kvrocks/pull/858#discussion_r968291514


##########
tests/gocase/unit/type/set/set_test.go:
##########
@@ -0,0 +1,741 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package set
+
+import (
+	"context"
+	"sort"
+	"strconv"
+	"testing"
+
+	"github.com/apache/incubator-kvrocks/tests/gocase/util"
+	"github.com/go-redis/redis/v9"
+	"github.com/stretchr/testify/require"
+)
+
+func CreateSet(t *testing.T, rdb *redis.Client, ctx context.Context, key string, entries []interface{}) {
+	require.NoError(t, rdb.Del(ctx, key).Err())
+	for _, entry := range entries {
+		switch entry := entry.(type) {
+		default:
+			require.NoError(t, rdb.SAdd(ctx, key, entry).Err())
+		}
+	}
+}
+
+func TestSet(t *testing.T) {
+	srv := util.StartServer(t, map[string]string{})
+	defer srv.Close()
+	ctx := context.Background()
+	rdb := srv.NewClient()
+	defer func() { require.NoError(t, rdb.Close()) }()
+
+	t.Run("SADD, SCARD, SISMEMBER, SMISMEMBER, SMEMBERS basics - regular set", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{"foo"})
+		require.EqualValues(t, 1, rdb.SAdd(ctx, "myset", "bar").Val())
+		require.EqualValues(t, 0, rdb.SAdd(ctx, "myset", "bar").Val())
+		require.EqualValues(t, 2, rdb.SCard(ctx, "myset").Val())
+		require.EqualValues(t, true, rdb.SIsMember(ctx, "myset", "foo").Val())
+		require.EqualValues(t, true, rdb.SIsMember(ctx, "myset", "bar").Val())
+		require.EqualValues(t, false, rdb.SIsMember(ctx, "myset", "bla").Val())
+		require.EqualValues(t, []bool{true}, rdb.SMIsMember(ctx, "myset", "foo").Val())
+		require.EqualValues(t, []bool{true, true}, rdb.SMIsMember(ctx, "myset", "foo", "bar").Val())
+		require.EqualValues(t, []bool{true, false}, rdb.SMIsMember(ctx, "myset", "foo", "bla").Val())
+		require.EqualValues(t, []bool{false, true}, rdb.SMIsMember(ctx, "myset", "bla", "foo").Val())
+		require.EqualValues(t, []bool{false}, rdb.SMIsMember(ctx, "myset", "bla").Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"bar", "foo"}, cmd.Val())
+	})
+
+	t.Run("SADD, SCARD, SISMEMBER, SMISMEMBER, SMEMBERS basics - intset", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{17})
+		require.EqualValues(t, 1, rdb.SAdd(ctx, "myset", 16).Val())
+		require.EqualValues(t, 0, rdb.SAdd(ctx, "myset", 16).Val())
+		require.EqualValues(t, 2, rdb.SCard(ctx, "myset").Val())
+		require.EqualValues(t, true, rdb.SIsMember(ctx, "myset", 16).Val())
+		require.EqualValues(t, true, rdb.SIsMember(ctx, "myset", 17).Val())
+		require.EqualValues(t, false, rdb.SIsMember(ctx, "myset", 18).Val())
+		require.EqualValues(t, []bool{true}, rdb.SMIsMember(ctx, "myset", 16).Val())
+		require.EqualValues(t, []bool{true, true}, rdb.SMIsMember(ctx, "myset", 16, 17).Val())
+		require.EqualValues(t, []bool{true, false}, rdb.SMIsMember(ctx, "myset", 16, 18).Val())
+		require.EqualValues(t, []bool{false, true}, rdb.SMIsMember(ctx, "myset", 18, 16).Val())
+		require.EqualValues(t, []bool{false}, rdb.SMIsMember(ctx, "myset", 18).Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"16", "17"}, cmd.Val())
+	})
+
+	t.Run("SMISMEMBER against non set", func(t *testing.T) {
+		require.ErrorContains(t, rdb.LPush(ctx, "myset", "foo").Err(), "WRONGTYPE")
+	})
+
+	t.Run("SMISMEMBER non existing key", func(t *testing.T) {
+		require.EqualValues(t, []bool{false}, rdb.SMIsMember(ctx, "myset1", "foo").Val())
+		require.EqualValues(t, []bool{false, false}, rdb.SMIsMember(ctx, "myset1", "foo", "bar").Val())
+	})
+
+	t.Run("SMISMEMBER requires one or more members", func(t *testing.T) {
+		require.NoError(t, rdb.Del(ctx, "zmscoretest").Err())
+		require.NoError(t, rdb.ZAdd(ctx, "zmscoretest", redis.Z{Score: 10, Member: "x"}).Err())
+		require.NoError(t, rdb.ZAdd(ctx, "zmscoretest", redis.Z{Score: 20, Member: "y"}).Err())
+		util.ErrorRegexp(t, rdb.Do(ctx, "smismember", "zmscoretest").Err(), ".*ERR.*wrong.*number.*arg.*")
+	})
+
+	t.Run("SADD against non set", func(t *testing.T) {
+		require.NoError(t, rdb.LPush(ctx, "mylist", "foo").Err())
+		util.ErrorRegexp(t, rdb.SAdd(ctx, "mylist", "bar").Err(), ".*WRONGTYPE.*")
+	})
+
+	t.Run("SADD a non-integer against an intset", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{1, 2, 3})
+		require.EqualValues(t, 1, rdb.SAdd(ctx, "myset", "a").Val())
+	})
+
+	t.Run("SADD an integer larger than 64 bits", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{"213244124402402314402033402"})
+		require.EqualValues(t, true, rdb.SIsMember(ctx, "myset", "213244124402402314402033402").Val())
+		require.EqualValues(t, []bool{true}, rdb.SMIsMember(ctx, "myset", "213244124402402314402033402").Val())
+	})
+
+	t.Run("SADD overflows the maximum allowed integers in an intset", func(t *testing.T) {
+		require.NoError(t, rdb.Del(ctx, "myset").Err())
+		for i := 0; i < 512; i++ {
+			require.NoError(t, rdb.SAdd(ctx, "myset", i).Err())
+		}
+		require.EqualValues(t, 1, rdb.SAdd(ctx, "myset", 512).Val())
+	})
+
+	t.Run("Variadic SADD", func(t *testing.T) {
+		require.NoError(t, rdb.Del(ctx, "myset").Err())
+		require.EqualValues(t, 3, rdb.SAdd(ctx, "myset", "a", "b", "c").Val())
+		require.EqualValues(t, 2, rdb.SAdd(ctx, "myset", "A", "a", "b", "c", "B").Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"A", "B", "a", "b", "c"}, cmd.Val())
+	})
+
+	t.Run("SREM basics - regular set", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{"foo", "bar", "ciao"})
+		require.EqualValues(t, 0, rdb.SRem(ctx, "myset", "qux").Val())
+		require.EqualValues(t, 1, rdb.SRem(ctx, "myset", "foo").Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"bar", "ciao"}, cmd.Val())
+	})
+
+	t.Run("SREM basics - intset", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{3, 4, 5})
+		require.EqualValues(t, 0, rdb.SRem(ctx, "myset", 6).Val())
+		require.EqualValues(t, 1, rdb.SRem(ctx, "myset", 4).Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"3", "5"}, cmd.Val())
+	})
+
+	t.Run("SREM with multiple arguments", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{"a", "b", "c", "d"})
+		require.EqualValues(t, 0, rdb.SRem(ctx, "myset", "k", "k", "k").Val())
+		require.EqualValues(t, 2, rdb.SRem(ctx, "myset", "b", "d", "x", "y").Val())
+		cmd := rdb.SMembers(ctx, "myset")
+		require.NoError(t, cmd.Err())
+		sort.Strings(cmd.Val())
+		require.EqualValues(t, []string{"a", "c"}, cmd.Val())
+	})
+
+	t.Run("SREM variadic version with more args needed to destroy the key", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{1, 2, 3})
+		require.EqualValues(t, 3, rdb.SRem(ctx, "myset", 1, 2, 3, 4, 5, 6, 7, 8).Val())
+	})
+
+	t.Run("SREM variadic version with more args needed to destroy the key", func(t *testing.T) {
+		CreateSet(t, rdb, ctx, "myset", []interface{}{1, 2, 3})
+		require.EqualValues(t, 3, rdb.SRem(ctx, "myset", 1, 2, 3, 4, 5, 6, 7, 8).Val())
+	})
+
+	for _, dstype := range [2]string{"hashtable", "intset"} {
+		for i := 1; i <= 5; i++ {
+			require.NoError(t, rdb.Del(ctx, "set"+strconv.Itoa(i)).Err())
+		}
+		for i := 0; i < 200; i++ {
+			require.NoError(t, rdb.SAdd(ctx, "set1", i).Err())
+			require.NoError(t, rdb.SAdd(ctx, "set2", i+195).Err())
+		}
+		for _, i := range []int{199, 195, 100, 2000} {
+			require.NoError(t, rdb.SAdd(ctx, "set3", i).Err())
+		}
+		for i := 5; i < 200; i++ {
+			require.NoError(t, rdb.SAdd(ctx, "set4", i).Err())
+		}
+		var larger interface{}
+		larger = 200
+		require.NoError(t, rdb.SAdd(ctx, "set5", 0).Err())
+		if dstype == "hashtable" {
+			larger = "foo"
+		}
+		for i := 1; i <= 5; i++ {
+			switch larger := larger.(type) {
+			default:
+				require.NoError(t, rdb.SAdd(ctx, "set"+strconv.Itoa(i), larger).Err())
+			}
+		}
+		t.Run("SINTER with two sets - "+dstype, func(t *testing.T) {
+			cmd := rdb.SInter(ctx, "set1", "set2")
+			require.NoError(t, cmd.Err())
+			sort.Strings(cmd.Val())
+			switch larger := larger.(type) {
+			case int:
+				require.EqualValues(t, []string{"195", "196", "197", "198", "199", strconv.Itoa(larger)}, cmd.Val())
+			case string:
+				require.EqualValues(t, []string{"195", "196", "197", "198", "199", larger}, cmd.Val())
+			}
+		})
+
+		t.Run("SINTERSTORE with two sets - "+dstype, func(t *testing.T) {
+			require.NoError(t, rdb.SInterStore(ctx, "setres", "set1", "set2").Err())
+			cmd := rdb.SMembers(ctx, "setres")
+			require.NoError(t, cmd.Err())
+			sort.Strings(cmd.Val())
+
+			switch larger := larger.(type) {
+			case int:
+				require.EqualValues(t, []string{"195", "196", "197", "198", "199", strconv.Itoa(larger)}, cmd.Val())
+			case string:
+				require.EqualValues(t, []string{"195", "196", "197", "198", "199", larger}, cmd.Val())
+			}
+		})
+
+		t.Run("SUNION with two sets - "+dstype, func(t *testing.T) {
+			set1 := rdb.SMembers(ctx, "set1")
+			require.NoError(t, set1.Err())
+			set2 := rdb.SMembers(ctx, "set2")
+			require.NoError(t, set2.Err())
+			var expect []string
+			var vis = make(map[string]bool)
+			for _, i := range set1.Val() {

Review Comment:
   I saw this unique merge code block appears many times, do you mind adding a util function for merging N sets?



-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] git-hulk commented on pull request #858: Move TCL test unit/type/set to Go case

Posted by GitBox <gi...@apache.org>.
git-hulk commented on PR #858:
URL: https://github.com/apache/incubator-kvrocks/pull/858#issuecomment-1243601630

   > a bit random. My same code failed in different places the first two times, and I passed it the last time.
   
   Yes, there's some tcl random failures but we can't produce them locally, so can just ignore them. 


-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org