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 04:17:05 UTC

[GitHub] [incubator-kvrocks] suica commented on a diff in pull request #835: Move TCL test unit/type/list-3 to Go case

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


##########
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:
   TCL testing has `--accurate` flag. When it is enabled, we would run slower test by running more iterations.
   Should we port this to Go test cases?



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