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

Function TestGc

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

Source from the content-addressed store, hash-verified

61}
62
63func TestGc(t *testing.T) {
64 // config format:
65 // MySQL [(none)]> show config where name = 'gc.ratio-threshold';
66 // +------+-------------------+--------------------+-------+
67 // | Type | Instance | Name | Value |
68 // +------+-------------------+--------------------+-------+
69 // | tikv | 172.16.6.46:3460 | gc.ratio-threshold | 1.1 |
70 // | tikv | 172.16.6.47:3460 | gc.ratio-threshold | 1.1 |
71 // +------+-------------------+--------------------+-------+
72 fields := make([]*resolve.ResultField, 4)
73 tps := []*types.FieldType{
74 types.NewFieldType(mysql.TypeString),
75 types.NewFieldType(mysql.TypeString),
76 types.NewFieldType(mysql.TypeString),
77 types.NewFieldType(mysql.TypeString),
78 }
79 for i := 0; i < len(tps); i++ {
80 rf := new(resolve.ResultField)
81 rf.Column = new(model.ColumnInfo)
82 rf.Column.FieldType = *tps[i]
83 fields[i] = rf
84 }
85 rows := make([]chunk.Row, 0, 2)
86 row := chunk.MutRowFromValues("tikv", " 127.0.0.1:20161", "log-backup.enable", "1.1").ToRow()
87 rows = append(rows, row)
88 row = chunk.MutRowFromValues("tikv", " 127.0.0.1:20162", "log-backup.enable", "1.1").ToRow()
89 rows = append(rows, row)
90
91 s := &mockRestrictedSQLExecutor{rows: rows, fields: fields}
92 ratio, err := utils.GetGcRatio(s)
93 require.Nil(t, err)
94 require.Equal(t, ratio, "1.1")
95
96 err = utils.SetGcRatio(s, "-1.0")
97 require.Nil(t, err)
98 ratio, err = utils.GetGcRatio(s)
99 require.Nil(t, err)
100 require.Equal(t, ratio, "-1.0")
101}
102
103func TestRegionSplitInfo(t *testing.T) {
104 // config format:

Callers

nothing calls this directly

Calls 6

NewFieldTypeFunction · 0.92
MutRowFromValuesFunction · 0.92
GetGcRatioFunction · 0.92
SetGcRatioFunction · 0.92
EqualMethod · 0.65
ToRowMethod · 0.45

Tested by

no test coverage detected