tisonkun commented on code in PR #835:
URL: https://github.com/apache/incubator-kvrocks/pull/835#discussion_r967849531


##########
tests/gocase/unit/type/list/list_test.go:
##########
@@ -84,3 +84,154 @@ func BenchmarkLTRIM(b *testing.B) {
                })
        }
 }
+
+func TestZipList(t *testing.T) {
+       srv := util.StartServer(t, map[string]string{
+               "list-max-ziplist-size": "16",
+       })
+       defer srv.Close()
+       ctx := context.Background()
+       rdb := srv.NewClient()
+       defer func() { require.NoError(t, rdb.Close()) }()
+
+       rand.Seed(0)
+
+       t.Run("Explicit regression for a list bug", func(t *testing.T) {
+               key := "l"
+               myList := []string{
+                       "49376042582", 
"BkG2o\\pIC]4YYJa9cJ4GWZalG[4tin;1D2whSkCOW`mX;SFXGyS8sedcff3fQI^tgPCC@^Nu1J6o]meM@Lko]t_jRyo<xSJ1oObDYd`ppZuW6P@fS278YaOx=s6lvdFlMbP0[SbkI^Kr\\HBXtuFaA^mDx:yzS4a[skiiPWhT<nNfAf=aQVfclcuwDrfe;iVuKdNvB9kbfq>tK?tH[\\EvWqS]b`o2OCtjg:?nUTwdjpcUm]y:pg5q24q7LlCOwQE^",
+               }
+               require.NoError(t, rdb.Del(ctx, key).Err())
+               require.NoError(t, rdb.RPush(ctx, key, myList[0]).Err())
+               require.NoError(t, rdb.RPush(ctx, key, myList[1]).Err())
+               require.Equal(t, myList[0], rdb.LIndex(ctx, key, 0).Val())
+               require.Equal(t, myList[1], rdb.LIndex(ctx, key, 1).Val())
+       })
+
+       t.Run("Regression for quicklist #3343 bug", func(t *testing.T) {
+               key := "myList"
+               require.NoError(t, rdb.Del(ctx, key).Err())
+               require.NoError(t, rdb.LPush(ctx, key, "401").Err())
+               require.NoError(t, rdb.LPush(ctx, key, "392").Err())
+
+               require.NoError(t, rdb.RPush(ctx, key, fmt.Sprintf("%s\"%s\"", 
strings.Repeat("x", 5105), "799")).Err())
+               require.NoError(t, rdb.LSet(ctx, key, -1, 
fmt.Sprintf("%s\"%s\"", strings.Repeat("x", 1014), "702")).Err())
+
+               require.NoError(t, rdb.LPop(ctx, key).Err())
+
+               require.NoError(t, rdb.LSet(ctx, key, -1, 
fmt.Sprintf("%s\"%s\"", strings.Repeat("x", 4149), "852")).Err())
+
+               require.NoError(t, rdb.LInsert(ctx, key, "before", "401", 
fmt.Sprintf("%s\"%s\"", strings.Repeat("x", 9927), "12")).Err())
+               require.NoError(t, rdb.LRange(ctx, key, 0, -1).Err())
+               require.Equal(t, rdb.Ping(ctx).Val(), "PONG")
+       })
+
+       t.Run("Stress tester for #3343-alike bugs", func(t *testing.T) {
+               key := "key"
+               require.NoError(t, rdb.Del(ctx, key).Err())
+               for i := 0; i < 10000; i++ {
+                       op := rand.Int63n(6)
+                       randCnt := 5 - rand.Int63n(10)
+                       var ele string
+                       if rand.Int31n(2) == 0 {
+                               ele = fmt.Sprintf("%d", rand.Int63n(1000))
+                       } else {
+                               ele = fmt.Sprintf("%s%d", strings.Repeat("x", 
int(rand.Int63n(10000))), 1)
+                       }
+                       switch op {
+                       case 0:
+                               require.NoError(t, rdb.LPush(ctx, key, 
ele).Err())
+                       case 1:
+                               require.NoError(t, rdb.RPush(ctx, key, 
ele).Err())
+                       case 2:
+                               rdb.LPop(ctx, key)
+                       case 3:
+                               rdb.RPop(ctx, key)
+                       case 4:
+                               rdb.LSet(ctx, key, randCnt, ele)
+                       case 5:
+                               otherEle := fmt.Sprintf("%d", rand.Int63n(1000))
+                               var where string
+                               if rand.Int31n(2) == 0 {
+                                       where = "before"
+                               } else {
+                                       where = "after"
+                               }
+                               require.NoError(t, rdb.LInsert(ctx, key, where, 
otherEle, ele).Err())
+                       }
+               }
+       })
+
+       t.Run("ziplist implementation: value encoding and backlink", func(t 
*testing.T) {
+               // TODO: check --accurate options for go test

Review Comment:
   Then from my perspective, either set the iteration to 10 or 100 is OK - we 
don't run with `--accurate` now. Please choose one and remove this TODO comment.



-- 
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]

Reply via email to