Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add my-tester support for cascades planner. #137

Merged
merged 7 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -39,13 +39,20 @@ Usage of ./mysql-tester:
The user for connecting to the database. (default "root")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to change this function to a custom suffix? This will make it look more universal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense, done

Copy link
Contributor Author

@AilinKid AilinKid Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one day, when we remove the cascades planner switch (remove the old planner), we could just run cmd as below:

./mysql-tester -cascades=1 -check-error=1 -record=1 -cascades-suffix="result"

which will overrides test result of .result file, then we can remove all .casult files if any with find . -type -f -name "*.casult" | xargs rm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cascades enable is out of tester now, when cascades is enabled, we will pass suffix as ".casult" in.

-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:
```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 -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.
Expand Down
6 changes: 3 additions & 3 deletions r/example.result
Original file line number Diff line number Diff line change
Expand Up @@ -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:<num>, loops:<num>, RU:<num>, cop_task: {num:<num>, max:<num>, proc_keys:<num>, rpc_num:<num>, rpc_time:<num>, copr_cache_hit_ratio:<num>, build_task_duration:<num>, max_distsql_concurrency:<num>} data:TableFullScan <num> Bytes N/A
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>, loops:<num>, RU:<num>, cop_task: {num:<num>, max:<num>, proc_keys:<num>, rpc_num:<num>, rpc_time:<num>, copr_cache_hit_ratio:<num>, build_task_duration:<num>, max_distsql_concurrency:<num>} data:TableFullScan_4 <num> Bytes N/A
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
Expand Down
4 changes: 3 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
extension string
)

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.StringVar(&extension, "extension", "result", "the result file extension for result file")
}

const (
Expand Down Expand Up @@ -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) {
Expand Down
Loading