From 3706cc581f7e40f193a70beae561eb536291ae86 Mon Sep 17 00:00:00 2001 From: JmPotato Date: Tue, 25 Jun 2024 20:35:30 +0800 Subject: [PATCH] Resolve the conflicts Signed-off-by: JmPotato --- pkg/schedule/config/store_config_test.go | 75 ------------------------ pkg/typeutil/size_test.go | 21 +------ server/config/store_config_test.go | 4 ++ 3 files changed, 7 insertions(+), 93 deletions(-) delete mode 100644 pkg/schedule/config/store_config_test.go diff --git a/pkg/schedule/config/store_config_test.go b/pkg/schedule/config/store_config_test.go deleted file mode 100644 index 3f4789a74c9..00000000000 --- a/pkg/schedule/config/store_config_test.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2022 TiKV Project Authors. -// -// Licensed 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 config - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestMergeCheck(t *testing.T) { - re := require.New(t) - testdata := []struct { - size uint64 - mergeSize uint64 - keys uint64 - mergeKeys uint64 - pass bool - }{{ - // case 1: the merged region size is smaller than the max region size - size: 96 + 20, - mergeSize: 20, - keys: 1440000 + 200000, - mergeKeys: 200000, - pass: true, - }, { - // case 2: the smallest region is 68MiB, it can't be merged again. - size: 144 + 20, - mergeSize: 20, - keys: 1440000 + 200000, - mergeKeys: 200000, - pass: true, - }, { - // case 3: the smallest region is 50MiB, it can be merged again. - size: 144 + 2, - mergeSize: 50, - keys: 1440000 + 20000, - mergeKeys: 500000, - pass: false, - }, { - // case4: the smallest region is 51MiB, it can't be merged again. - size: 144 + 3, - mergeSize: 50, - keys: 1440000 + 30000, - mergeKeys: 500000, - pass: true, - }} - config := &StoreConfig{} - for _, v := range testdata { - if v.pass { - re.NoError(config.CheckRegionSize(v.size, v.mergeSize)) - re.NoError(config.CheckRegionKeys(v.keys, v.mergeKeys)) - } else { - re.Error(config.CheckRegionSize(v.size, v.mergeSize)) - re.Error(config.CheckRegionKeys(v.keys, v.mergeKeys)) - } - } - // Test CheckRegionSize when the region split size is 0. - config.RegionSplitSize = "100KiB" - config.Adjust() - re.Empty(config.GetRegionSplitSize()) - re.NoError(config.CheckRegionSize(defaultRegionMaxSize, 50)) -} diff --git a/pkg/typeutil/size_test.go b/pkg/typeutil/size_test.go index 77bdadd7827..5d66f43d5a4 100644 --- a/pkg/typeutil/size_test.go +++ b/pkg/typeutil/size_test.go @@ -17,6 +17,7 @@ package typeutil import ( "encoding/json" + "github.com/docker/go-units" . "github.com/pingcap/check" ) @@ -40,16 +41,10 @@ func (s *testSizeSuite) TestJSON(c *C) { c.Assert(string(o), Equals, `"1.598TiB"`) } -<<<<<<< HEAD:pkg/typeutil/size_test.go func (s *testSizeSuite) TestParseMbFromText(c *C) { - testdata := []struct { -======= -func TestParseMbFromText(t *testing.T) { const defaultValue = 2 - re := require.New(t) - testCases := []struct { ->>>>>>> 6fbe73796 (config: fix the panic caused by zero RegionSplitSizeMB (#8324)):pkg/utils/typeutil/size_test.go + testdata := []struct { body []string size uint64 }{{ @@ -57,9 +52,6 @@ func TestParseMbFromText(t *testing.T) { size: 10, }, { body: []string{"10GiB", "10Gib", "10G", "10GB"}, -<<<<<<< HEAD:pkg/typeutil/size_test.go - size: uint64(10 * 1024), -======= size: 10 * units.GiB / units.MiB, }, { body: []string{"1024KiB", "1048576"}, @@ -67,21 +59,14 @@ func TestParseMbFromText(t *testing.T) { }, { body: []string{"100KiB", "1023KiB", "1048575", "0"}, size: 0, ->>>>>>> 6fbe73796 (config: fix the panic caused by zero RegionSplitSizeMB (#8324)):pkg/utils/typeutil/size_test.go }, { body: []string{"10yiB", "10aib"}, size: defaultValue, }} -<<<<<<< HEAD:pkg/typeutil/size_test.go for _, t := range testdata { for _, b := range t.body { - c.Assert(int(ParseMBFromText(b, 1)), Equals, int(t.size)) -======= - for _, testCase := range testCases { - for _, b := range testCase.body { - re.Equal(testCase.size, ParseMBFromText(b, defaultValue)) ->>>>>>> 6fbe73796 (config: fix the panic caused by zero RegionSplitSizeMB (#8324)):pkg/utils/typeutil/size_test.go + c.Assert(ParseMBFromText(b, defaultValue), Equals, t.size) } } } diff --git a/server/config/store_config_test.go b/server/config/store_config_test.go index 478e1ebb3d7..821d5825610 100644 --- a/server/config/store_config_test.go +++ b/server/config/store_config_test.go @@ -147,4 +147,8 @@ func (t *testTiKVConfigSuite) TestMergeCheck(c *C) { c.Assert(config.CheckRegionKeys(v.keys, v.mergeKeys), NotNil) } } + // Test CheckRegionSize when the region split size is 0. + config.RegionSplitSize = "100KiB" + c.Assert(config.GetRegionSplitSize(), Equals, uint64(0)) + c.Assert(config.CheckRegionSize(defaultRegionMaxSize, 50), IsNil) }