From 2917d4560b4a12818969185ec98cff4145d3db17 Mon Sep 17 00:00:00 2001 From: Neil Shen Date: Fri, 22 Nov 2024 12:28:05 +0800 Subject: [PATCH] *: update kvproto (#8816) ref tikv/pd#4399, ref pingcap/tidb#57338 Signed-off-by: Neil Shen --- .../server/resource_group_test.go | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/pkg/mcs/resourcemanager/server/resource_group_test.go b/pkg/mcs/resourcemanager/server/resource_group_test.go index 96325ea3653..96b15d14293 100644 --- a/pkg/mcs/resourcemanager/server/resource_group_test.go +++ b/pkg/mcs/resourcemanager/server/resource_group_test.go @@ -2,7 +2,6 @@ package server import ( "encoding/json" - "reflect" "testing" "github.com/brianvoe/gofakeit/v6" @@ -37,37 +36,10 @@ func TestPatchResourceGroup(t *testing.T) { } } -func resetSizeCache(obj any) { - resetSizeCacheRecursive(reflect.ValueOf(obj)) -} - -func resetSizeCacheRecursive(value reflect.Value) { - if value.Kind() == reflect.Ptr { - value = value.Elem() - } - - if value.Kind() != reflect.Struct { - return - } - - for i := range value.NumField() { - fieldValue := value.Field(i) - fieldType := value.Type().Field(i) - - if fieldType.Name == "XXX_sizecache" && fieldType.Type.Kind() == reflect.Int32 { - fieldValue.SetInt(0) - } else { - resetSizeCacheRecursive(fieldValue) - } - } -} - func TestClone(t *testing.T) { for i := 0; i <= 10; i++ { var rg ResourceGroup gofakeit.Struct(&rg) - // hack to reset XXX_sizecache, gofakeit will random set this field but proto clone will not copy this field. - resetSizeCache(&rg) rgClone := rg.Clone(true) require.EqualValues(t, &rg, rgClone) }