Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
Signed-off-by: arenatlx <[email protected]>
  • Loading branch information
AilinKid committed Jan 7, 2025
1 parent 0d83955 commit 0091eb3
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,22 @@ Usage of ./mysql-tester:
The user for connecting to the database. (default "root")
-xunitfile string
The xml file path to record testing results.
-check-error
If --error ERR does not match, return error instead of just warn
-cascades
Record the result based on cascades planner into result file with .casult suffix.
```

By default, it connects to the TiDB/MySQL server at `127.0.0.1:4000` with `root` and no passward:
```sh
./mysql-tester # run all the tests
./mysql-tester example # run a specified test
./mysql-tester example1 example2 example3 # seperate different tests with one or more spaces
# modify current example cases for .result output.
./mysql-tester ./mysql-tester -record=1 -check-error=1
# modify current example cases for .casult output.
./mysql-tester ./mysql-tester -record=1 -check-error=1 -cascades=1

```

For more details about how to run and write test cases, see the [Wiki](https://github.com/pingcap/mysql-tester/wiki) page.
Expand Down
49 changes: 49 additions & 0 deletions r/example.casult
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
create table t(a bigint, b bigint);
insert into t values(1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
select * from t where a = 1;
a b
1 1
SELECT 1 FROM NON_EXISTING_TABLE;
Error 1146 (42S02): Table 'example.NON_EXISTING_TABLE' doesn't exist
SELECT 2 FROM NON_EXISTING_TABLE;
SELECT 3 FROM NON_EXISTING_TABLE;
Got one of the listed errors
SELECT 4;
4
4
SELECT 5;
5
5
SELECT 6;
6
6
1 SELECT;
Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 1 near "1 SELECT"
2 SELECT;
3 SELECT;
Got one of the listed errors
explain analyze format='brief' select * from t;
id estRows actRows task access object execution info operator info memory disk
TableReader 10000.00 5 root NULL time:<num>, open:<num>, close:<num>, loops:<num>, RU:<num>, cop_task: {num:<num>, max:<num>, proc_keys:<num>, copr_cache_hit_ratio:<num>, build_task_duration:<num>, max_distsql_concurrency:<num>, rpc_info:{Cop:{num_rpc:<num>, total_time:<num>}} data:TableFullScan <num> Bytes N/A
└─TableFullScan 10000.00 5 cop[tikv] table:t tikv_task:{time:<num>, loops:<num>} keep order:false, stats:pseudo N/A N/A
explain analyze select * from t;
id estRows actRows task access object execution info operator info memory disk
TableReader_5 10000.00 5 root NULL time:<num>, open:<num>, close:<num>, loops:<num>, RU:<num>, cop_task: {num:<num>, max:<num>, proc_keys:<num>, copr_cache_hit_ratio:<num>, build_task_duration:<num>, max_distsql_concurrency:<num>, rpc_info:{Cop:{num_rpc:<num>, total_time:<num>}} data:TableFullScan_4 <num> Bytes N/A
└─TableFullScan_4 10000.00 5 cop[tikv] table:t tikv_task:{time:<num>, loops:<num>} keep order:false, stats:pseudo N/A N/A
insert into t values (6, 6);
affected rows: 1
info:
DROP TABLE IF EXISTS t1;
affected rows: 0
info:
CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 INT NOT NULL UNIQUE);
affected rows: 0
info:
INSERT t1 VALUES (1, 1);
affected rows: 1
info:
INSERT t1 VALUES (1, 1), (1, 1) ON DUPLICATE KEY UPDATE f1 = 2, f2 = 2;
affected rows: 3
info: Records: 2 Duplicates: 1 Warnings: 0
1
use `test`;;
2 changes: 2 additions & 0 deletions r/extensions.casult
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT 1 FROM NON_EXISTING_TABLE;
Got one of the listed errors
13 changes: 12 additions & 1 deletion src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (
retryConnCount int
collationDisable bool
checkErr bool
cascades bool
)

func init() {
Expand All @@ -63,6 +64,7 @@ func init() {
flag.IntVar(&retryConnCount, "retry-connection-count", 120, "The max number to retry to connect to the database.")
flag.BoolVar(&checkErr, "check-error", false, "if --error ERR does not match, return error instead of just warn")
flag.BoolVar(&collationDisable, "collation-disable", false, "run collation related-test with new-collation disabled")
flag.BoolVar(&cascades, "cascades", false, "run exec and query based on cascades planner")
}

const (
Expand Down Expand Up @@ -196,6 +198,11 @@ func setSessionVariable(db *Conn) {
if _, err := db.conn.ExecContext(ctx, "SET @@tidb_enable_clustered_index='int_only'"); err != nil {
log.Fatalf("Executing \"SET @@tidb_enable_clustered_index='int_only'\" err[%v]", err)
}
if cascades {
if _, err := db.conn.ExecContext(ctx, "SET @@tidb_enable_cascades_planner=1"); err != nil {
log.Fatalf("Executing \"SET @@tidb_enable_cascades_planner=1\" err[%v]", err)
}
}
}

// isTiDB returns true if the DB is confirmed to be TiDB
Expand Down Expand Up @@ -1081,7 +1088,11 @@ func (t *tester) resultFileName() string {
name = name + "_enabled"
}
}
return fmt.Sprintf("./r/%s.result", name)
suffix := "result"
if cascades {
suffix = "casult"
}
return fmt.Sprintf("./r/%s.%s", name, suffix)
}

func loadAllTests() ([]string, error) {
Expand Down

0 comments on commit 0091eb3

Please sign in to comment.