MCPcopy
hub / github.com/pingcap/tidb / TestRegionSplitInfo

Function TestRegionSplitInfo

br/pkg/utils/db_test.go:103–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

101}
102
103func TestRegionSplitInfo(t *testing.T) {
104 // config format:
105 // MySQL [(none)]> show config where name = 'coprocessor.region-split-size';
106 // +------+-------------------+-------------------------------+-------+
107 // | Type | Instance | Name | Value |
108 // +------+-------------------+-------------------------------+-------+
109 // | tikv | 127.0.0.1:20161 | coprocessor.region-split-size | 10MB |
110 // +------+-------------------+-------------------------------+-------+
111 // MySQL [(none)]> show config where name = 'coprocessor.region-split-keys';
112 // +------+-------------------+-------------------------------+--------+
113 // | Type | Instance | Name | Value |
114 // +------+-------------------+-------------------------------+--------+
115 // | tikv | 127.0.0.1:20161 | coprocessor.region-split-keys | 100000 |
116 // +------+-------------------+-------------------------------+--------+
117
118 fields := make([]*resolve.ResultField, 4)
119 tps := []*types.FieldType{
120 types.NewFieldType(mysql.TypeString),
121 types.NewFieldType(mysql.TypeString),
122 types.NewFieldType(mysql.TypeString),
123 types.NewFieldType(mysql.TypeString),
124 }
125 for i := 0; i < len(tps); i++ {
126 rf := new(resolve.ResultField)
127 rf.Column = new(model.ColumnInfo)
128 rf.Column.FieldType = *tps[i]
129 fields[i] = rf
130 }
131 rows := make([]chunk.Row, 0, 1)
132 row := chunk.MutRowFromValues("tikv", "127.0.0.1:20161", "coprocessor.region-split-size", "10MB").ToRow()
133 rows = append(rows, row)
134 s := &mockRestrictedSQLExecutor{rows: rows, fields: fields}
135 require.Equal(t, utils.GetSplitSize(s), uint64(10000000))
136
137 rows = make([]chunk.Row, 0, 1)
138 row = chunk.MutRowFromValues("tikv", "127.0.0.1:20161", "coprocessor.region-split-keys", "100000").ToRow()
139 rows = append(rows, row)
140 s = &mockRestrictedSQLExecutor{rows: rows, fields: fields}
141 require.Equal(t, utils.GetSplitKeys(s), int64(100000))
142}

Callers

nothing calls this directly

Calls 6

NewFieldTypeFunction · 0.92
MutRowFromValuesFunction · 0.92
GetSplitSizeFunction · 0.92
GetSplitKeysFunction · 0.92
EqualMethod · 0.65
ToRowMethod · 0.45

Tested by

no test coverage detected