(t *testing.T)
| 1333 | } |
| 1334 | |
| 1335 | func TestBuildVersion3RegionQueries(t *testing.T) { |
| 1336 | db, mock, err := sqlmock.New() |
| 1337 | require.NoError(t, err) |
| 1338 | defer func() { |
| 1339 | require.NoError(t, db.Close()) |
| 1340 | }() |
| 1341 | |
| 1342 | conn, err := db.Conn(context.Background()) |
| 1343 | require.NoError(t, err) |
| 1344 | baseConn := newBaseConn(conn, true, nil) |
| 1345 | tctx, cancel := tcontext.Background().WithLogger(appLogger).WithCancel() |
| 1346 | oldOpenFunc := openDBFunc |
| 1347 | defer func() { |
| 1348 | openDBFunc = oldOpenFunc |
| 1349 | }() |
| 1350 | openDBFunc = func(*mysql.Config) (*sql.DB, error) { |
| 1351 | return db, nil |
| 1352 | } |
| 1353 | |
| 1354 | conf := DefaultConfig() |
| 1355 | conf.ServerInfo = version.ServerInfo{ |
| 1356 | HasTiKV: true, |
| 1357 | ServerType: version.ServerTypeTiDB, |
| 1358 | ServerVersion: decodeRegionVersion, |
| 1359 | } |
| 1360 | database := "test" |
| 1361 | conf.Tables = DatabaseTables{ |
| 1362 | database: []*TableInfo{ |
| 1363 | {"t1", 0, TableTypeBase}, |
| 1364 | {"t2", 0, TableTypeBase}, |
| 1365 | {"t3", 0, TableTypeBase}, |
| 1366 | {"t4", 0, TableTypeBase}, |
| 1367 | }, |
| 1368 | } |
| 1369 | metrics := newMetrics(promutil.NewDefaultFactory(), nil) |
| 1370 | |
| 1371 | d := &Dumper{ |
| 1372 | tctx: tctx, |
| 1373 | conf: conf, |
| 1374 | cancelCtx: cancel, |
| 1375 | metrics: metrics, |
| 1376 | selectTiDBTableRegionFunc: selectTiDBTableRegion, |
| 1377 | } |
| 1378 | showStatsHistograms := buildMockNewRows(mock, []string{"Db_name", "Table_name", "Partition_name", "Column_name", "Is_index", "Update_time", "Distinct_count", "Null_count", "Avg_col_size", "Correlation"}, |
| 1379 | [][]driver.Value{ |
| 1380 | {"test", "t2", "p0", "a", 0, "2021-06-27 17:43:51", 1999999, 0, 8, 0}, |
| 1381 | {"test", "t2", "p1", "a", 0, "2021-06-22 20:30:16", 1260000, 0, 8, 0}, |
| 1382 | {"test", "t2", "p2", "a", 0, "2021-06-22 20:32:16", 1230000, 0, 8, 0}, |
| 1383 | {"test", "t2", "p3", "a", 0, "2021-06-22 20:36:19", 2000000, 0, 8, 0}, |
| 1384 | {"test", "t1", "", "a", 0, "2021-04-22 15:23:58", 7100000, 0, 8, 0}, |
| 1385 | {"test", "t3", "", "PRIMARY", 1, "2021-06-27 22:08:43", 4980000, 0, 0, 0}, |
| 1386 | {"test", "t4", "p0", "PRIMARY", 1, "2021-06-28 10:54:06", 2000000, 0, 0, 0}, |
| 1387 | {"test", "t4", "p1", "PRIMARY", 1, "2021-06-28 10:55:04", 1300000, 0, 0, 0}, |
| 1388 | {"test", "t4", "p2", "PRIMARY", 1, "2021-06-28 10:57:05", 1830000, 0, 0, 0}, |
| 1389 | {"test", "t4", "p3", "PRIMARY", 1, "2021-06-28 10:59:04", 2000000, 0, 0, 0}, |
| 1390 | {"mysql", "global_priv", "", "PRIMARY", 1, "2021-06-04 20:39:44", 0, 0, 0, 0}, |
| 1391 | }) |
| 1392 | selectMySQLStatsHistograms := buildMockNewRows(mock, []string{"TABLE_ID", "VERSION", "DISTINCT_COUNT"}, |
nothing calls this directly
no test coverage detected