From 2f83b8240aebb1a026e12e987bc336dc01d7559c Mon Sep 17 00:00:00 2001 From: Arenatlx Date: Wed, 8 Jan 2025 21:53:12 +0800 Subject: [PATCH] add my-tester support for cascades planner. (#137) --- README.md | 9 ++++++++- r/example.result | 6 +++--- src/main.go | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8f78f77..1e32f2f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This is a golang implementation of [MySQL Test Framework](https://github.com/mys ## Requirements - All the tests should be put in [`t`](./t), take [t/example.test](./t/example.test) as an example. -- All the expected test results should be put in [`r`](./r). Result file has the same file name with the corresponding test file, but with a `.result` file suffix, take [r/example.result](./r/example.result) as an examle. +- All the expected test results should be put in [`r`](./r). Result file has the same file name with the corresponding test file, but with a default `.result` file extension, it can be changed by `-extension`, take [r/example.result](./r/example.result) as an examle. ## How to use @@ -39,6 +39,10 @@ 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 + -extension + Specify the extension of result file under special requirement, default as ".result" ``` By default, it connects to the TiDB/MySQL server at `127.0.0.1:4000` with `root` and no passward: @@ -46,6 +50,9 @@ By default, it connects to the TiDB/MySQL server at `127.0.0.1:4000` with `root` ./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 -record=1 -check-error=1 + ``` For more details about how to run and write test cases, see the [Wiki](https://github.com/pingcap/mysql-tester/wiki) page. diff --git a/r/example.result b/r/example.result index 6e5cb8d..91fbf60 100644 --- a/r/example.result +++ b/r/example.result @@ -18,17 +18,17 @@ 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;" +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:, loops:, RU:, cop_task: {num:, max:, proc_keys:, rpc_num:, rpc_time:, copr_cache_hit_ratio:, build_task_duration:, max_distsql_concurrency:} data:TableFullScan Bytes N/A +TableReader 10000.00 5 root NULL time:, open:, close:, loops:, RU:, cop_task: {num:, max:, proc_keys:, copr_cache_hit_ratio:, build_task_duration:, max_distsql_concurrency:, rpc_info:{Cop:{num_rpc:, total_time:}} data:TableFullScan Bytes N/A └─TableFullScan 10000.00 5 cop[tikv] table:t tikv_task:{time:, loops:} 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:, loops:, RU:, cop_task: {num:, max:, proc_keys:, rpc_num:, rpc_time:, copr_cache_hit_ratio:, build_task_duration:, max_distsql_concurrency:} data:TableFullScan_4 Bytes N/A +TableReader_5 10000.00 5 root NULL time:, open:, close:, loops:, RU:, cop_task: {num:, max:, proc_keys:, copr_cache_hit_ratio:, build_task_duration:, max_distsql_concurrency:, rpc_info:{Cop:{num_rpc:, total_time:}} data:TableFullScan_4 Bytes N/A └─TableFullScan_4 10000.00 5 cop[tikv] table:t tikv_task:{time:, loops:} keep order:false, stats:pseudo N/A N/A insert into t values (6, 6); affected rows: 1 diff --git a/src/main.go b/src/main.go index cec17c6..67ea7f4 100644 --- a/src/main.go +++ b/src/main.go @@ -47,6 +47,7 @@ var ( retryConnCount int collationDisable bool checkErr bool + extension string ) func init() { @@ -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.StringVar(&extension, "extension", "result", "the result file extension for result file") } const ( @@ -1081,7 +1083,7 @@ func (t *tester) resultFileName() string { name = name + "_enabled" } } - return fmt.Sprintf("./r/%s.result", name) + return fmt.Sprintf("./r/%s.%s", name, extension) } func loadAllTests() ([]string, error) {