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

Function TestShowViaSQL

br/pkg/task/show/cmd_test.go:171–211  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

169}
170
171func TestShowViaSQL(t *testing.T) {
172 req := require.New(t)
173 store := testkit.CreateMockStore(t)
174 tk := testkit.NewTestKit(t, store)
175
176 tempBackup := tempBackupDir(t)
177 metaPath := path.Join(tempBackup, "backupmeta")
178 err := os.WriteFile(metaPath, FullMeta, 0o444)
179 req.NoError(err)
180
181 tk.MustExec("set @@time_zone='+08:00'")
182 res := tk.MustQuery(fmt.Sprintf("SHOW BACKUP METADATA FROM 'local://%s'", tempBackup))
183 fmt.Printf("%#v", res.Sort().Rows())
184 res.Sort().Check([][]any{
185 {"tpcc", "customer", "0", "0", "<nil>", "2023-04-10 11:18:21"},
186 {"tpcc", "district", "0", "0", "<nil>", "2023-04-10 11:18:21"},
187 {"tpcc", "history", "0", "0", "<nil>", "2023-04-10 11:18:21"},
188 {"tpcc", "item", "0", "0", "<nil>", "2023-04-10 11:18:21"},
189 {"tpcc", "new_order", "0", "0", "<nil>", "2023-04-10 11:18:21"},
190 {"tpcc", "order_line", "0", "0", "<nil>", "2023-04-10 11:18:21"},
191 {"tpcc", "orders", "0", "0", "<nil>", "2023-04-10 11:18:21"},
192 {"tpcc", "stock", "0", "0", "<nil>", "2023-04-10 11:18:21"},
193 {"tpcc", "warehouse", "0", "0", "<nil>", "2023-04-10 11:18:21"},
194 })
195
196 // Test result in different time_zone
197 tk.MustExec("set @@time_zone='-08:00'")
198 res = tk.MustQuery(fmt.Sprintf("SHOW BACKUP METADATA FROM 'local://%s'", tempBackup))
199 fmt.Printf("%#v", res.Sort().Rows())
200 res.Sort().Check([][]any{
201 {"tpcc", "customer", "0", "0", "<nil>", "2023-04-09 19:18:21"},
202 {"tpcc", "district", "0", "0", "<nil>", "2023-04-09 19:18:21"},
203 {"tpcc", "history", "0", "0", "<nil>", "2023-04-09 19:18:21"},
204 {"tpcc", "item", "0", "0", "<nil>", "2023-04-09 19:18:21"},
205 {"tpcc", "new_order", "0", "0", "<nil>", "2023-04-09 19:18:21"},
206 {"tpcc", "order_line", "0", "0", "<nil>", "2023-04-09 19:18:21"},
207 {"tpcc", "orders", "0", "0", "<nil>", "2023-04-09 19:18:21"},
208 {"tpcc", "stock", "0", "0", "<nil>", "2023-04-09 19:18:21"},
209 {"tpcc", "warehouse", "0", "0", "<nil>", "2023-04-09 19:18:21"},
210 })
211}

Callers

nothing calls this directly

Calls 12

MustExecMethod · 0.95
MustQueryMethod · 0.95
CreateMockStoreFunction · 0.92
NewTestKitFunction · 0.92
tempBackupDirFunction · 0.85
PrintfMethod · 0.80
NewMethod · 0.65
JoinMethod · 0.65
WriteFileMethod · 0.65
RowsMethod · 0.65
SortMethod · 0.65
CheckMethod · 0.65

Tested by

no test coverage detected