Skip to content
Snippets Groups Projects
Unverified Commit aff199fe authored by prinz's avatar prinz Committed by GitHub
Browse files

add mo-tester examples (#4479)

Approved by: @dengn
parent 9382f26b
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@ MO-Tester 测试用例如下表所示:
* 请先确认已安装 jdk8。
* 启动 MatrixOne 或其他数据库用例。参见更多信息 >>[安装单机版 MatrixOne](https://docs.matrixorigin.io/0.5.0/MatrixOne/Get-Started/install-standalone-matrixone/).
* 启动 MatrixOne 或其他数据库用例。参见更多信息 >>[安装单机版 MatrixOne](../Get-Started/install-standalone-matrixone.md).
* 克隆 MO-Tester 仓库.
......@@ -49,7 +49,7 @@ MO-Tester 测试用例如下表所示:
## 2. 配置 MO-Tester
MO-tester 基于 Java 语言进行开发,因此 JDBC 驱动程序需要配置参数信息:打开 `mo.yml` 文件,配置服务器地址、默认的数据库名称、用户名和密码等。
MO-tester 基于 Java 语言进行开发,因此 Mo-tester 所依赖的 Java 数据库连接(JDBC,Java Database Connectivity) 驱动程序需要配置 *mo.yml* 文件里的参数信息:进入到 *mo-tester* 本地仓库,打开 *mo.yml* 文件,配置服务器地址、默认的数据库名称、用户名和密码等。
以下是本地独立版本 MatrixOne 的默认示例。
......@@ -79,42 +79,41 @@ MO-tester 基于 Java 语言进行开发,因此 JDBC 驱动程序需要配置
## 3. 运行 MO-Tester
运行以下所示命令行,SQL 所有测试用例将自动运行,并将报告和错误消息生成至 `report/report.txt``report/error.txt` 文件中。
运行以下所示命令行,SQL 所有测试用例将自动运行,并将报告和错误消息生成至 *report/report.txt**report/error.txt* 文件中。
```
> ./run.sh
```
如果你想调整测试范围,你可以修改 `run.yml` 文件中的 `path` 参数。或者,在执行 `run.sh` 命令时,你也可以指定一些参数,参数如下:
如果你想调整测试范围,你可以修改 `run.yml` 文件中的 `path` 参数。或者,在执行 `run.sh` 命令时,你也可以指定一些参数,参数解释如下:
|参数|参数释义|
|---|---|
|-p|设置由 MO-tester 执行的测试用例的路径。默认值可以参见 *run.yml* 文件中 `path` 的配置参数|
|-m|设置 MO-tester 测试的方法,即直接运行或者生成新的测试结果。默认值可以参见 *run.yaml* 文件中 `method` 的配置参数|
|-t| 设置 MO-tester 执行 SQL 命令的格式类型。默认值可以参见 *run.yml* 文件中 `type` 的配置参数。|
|-r| 设置测试用例应该达到的成功率。默认值可以参见 *run.yml* 文件中 `rate` 的配置参数。|
|-i|设置包含列表,只有路径中名称包含其中一个列表的脚本文件将被执行,如果有多个,如果没有指定,用','分隔,指的是包含的所有情况set the including list, and only script files in the path whose name contains one of the lists will be executed, if more than one, separated by `,`, if not specified, refers to all cases included|
|-e|设置排除列表,如果路径下的脚本文件的名称包含一个排除列表,则不会被执行,如果有多个,用','分隔,如果没有指定,表示不排除任何情况set the excluding list, and script files in the path whose name contains one of the lists will not be executed, if more than one, separated by `,`, if not specified, refers to none of the cases excluded|
|-g|表示带有[-- @bvt:issue#{issueNO.}]标志的 SQL 命令将不会被执行,该标志以 [-- @bvt:issue#{issueNO.}]开始,以 [-- @bvt:issue]结束。例如,<br>-- @bvt:issue#3236<br/><br>select date_add("1997-12-31 23:59:59",INTERVAL "-10000:1" HOUR_MINUTE);<br/><br>select date_add("1997-12-31 23:59:59",INTERVAL "-100 1" YEAR_MONTH);<br/><br>-- @bvt:issue<br/><br>这两个 SQL 命令与问题 #3236 相关联,它们将不会在 MO-tester 测试中执行,直到问题 #3236 修复后标签移除才可以在测试中执行。<br/>|
|-n|表示在比较结果时将忽略结果集的元数据|
**示例**
```
-p set the path of test cases needed to be executed by mo-tester, the default value is configured by the `path` in `run.yaml`
-m set the method that mo-tester will run with, the default value is configured by the `method` in `run.yaml`
-t set the type of the format that mo-tester executes the SQL command in, the default value is configured by the `type` in `run.yaml`
-r set The success rate that test cases should reach, the default value is configured by the `rate` in `run.yaml`
-i set the including list, and only script files in the path whose name contains one of the lists will be executed, if more than one, separated by `,`, if not specified, refers to all cases included
-e set the excluding list, and script files in the path whose name contains one of the lists will not be executed, if more than one, separated by `,`, if not specified, refers to none of the cases excluded
-g means SQL commands which is marked with [bvt:issue] flag will not be executed,this flag starts with [-- @bvt:issue#{issueNO.}],and ends with [-- @bvt:issue],eg:
-- @bvt:issue#3236
select date_add("1997-12-31 23:59:59",INTERVAL "-10000:1" HOUR_MINUTE);
select date_add("1997-12-31 23:59:59",INTERVAL "-100 1" YEAR_MONTH);
-- @bvt:issue
Those two sql commands are associated with issue#3236, and they will not be executed in bvt test, until the flag is removed when issue#3236 is fixed.
-n means the metadata of the resultset will be ignored when comparing the result
Examples:
bash run.sh -p case -m run -t script -r 100 -i select,subquery -e substring -g
./run.sh -p case -m run -t script -r 100 -i select,subquery -e substring -g
```
如果你想测试新的 SQL 用例并自动生成 SQL 结果,你只需要将 `run``method` 参数 `yml` 修改为 `genrs`。运行 `run.sh` 后,在`result/` 路径下将直接记录测试结果及其原始文件名。
如果你想测试新的 SQL 用例并自动生成 SQL 结果,运行命令中可以将 `-m run` 更改为 `-m genrs`,或者将 *run.yml* 文件里`method` 参数修改为 `genrs`,相关示例参见<p><a href="#new_test_scenario">示例 4</a></p>
注意:每次运行 `run.sh` 都会覆盖 `error.txt``report.txt``success.txt` 报告文件。
!!! note
每次运行 `./run.sh` 都会覆盖 *report/* 路径下 *error.txt**report.txt**success.txt* 报告文件。
## 4. 查看测试报告
测试完成后,MO-Tester 生成 `error.txt``report.txt` `success.txt` 报告文件。
测试完成后,MO-Tester 生成 *error.txt**report.txt**success.txt* 报告文件。
* `report.txt` 示例如下:
* *report.txt* 示例如下:
```
[SUMMARY] TOTAL : 486, SUCCESS : 486, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
......@@ -124,7 +123,7 @@ bash run.sh -p case -m run -t script -r 100 -i select,subquery -e substring -g
[cases/transaction/isolation_1.sql] TOTAL : 217, SUCCESS : 217, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
```
* `error.txt` 示例如下:
* *error.txt* 示例如下:
```
[ERROR]
......@@ -139,3 +138,126 @@ c d
c d
1 1
```
## 5. 测试示例
### 示例 1
**示例描述**:运行 *mo-tester* 仓库内的 */cases* 路径下的所有测试用例。
**步骤**
1. 拉取最新的 *mo-tester* 远端仓库。
```
cd mo-tester
git pull https://github.com/matrixorigin/mo-tester.git
```
2. 运行如下命令,即运行 *mo-tester* 仓库内所有的测试用例:
```
./run.sh
```
3.*report/* 路径下的 *error.txt**report.txt**success.txt* 报告文件中查看运行结果。
### 示例 2
**示例描述**:运行 *mo-tester* 仓库内 */cases/transaction/* 路径下的测试用例。
**步骤**
1. 拉取最新的 *mo-tester* 远端仓库。
```
cd mo-tester
git pull https://github.com/matrixorigin/mo-tester.git
```
2. 运行如下命令,即运行 *mo-tester* 仓库内 *cases/transaction/* 路径的所有测试用例:
```
./run.sh -p cases/transaction/
```
3.*report/* 路径下的 *error.txt**report.txt**success.txt* 报告文件中查看运行结果。例如,预期 *report.txt* 报告如下所示:
```
[SUMMARY] TOTAL : 486, SUCCESS : 486, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
[cases/transaction/atomicity.sql] TOTAL : 67, SUCCESS : 67, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
[cases/transaction/isolation.sql] TOTAL : 202, SUCCESS : 202, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
[cases/transaction/isolation_1.sql] TOTAL : 217, SUCCESS : 217, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
```
### 示例 3
**示例描述**:运行 *mo-tester* 仓库内 *cases/transaction/atomicity.sql* 单个测试用例。
**步骤**
1. 拉取最新的 *mo-tester* 远端仓库。
```
cd mo-tester
git pull https://github.com/matrixorigin/mo-tester.git
```
2. 运行如下命令,即运行 *mo-tester* 仓库内 *cases/transaction/atomicity.sql* 测试用例:
```
./run.sh -p cases/transaction/atomicity.sql
```
3.*report/* 路径下的 *error.txt**report.txt**success.txt* 报告文件中查看运行结果。例如,预期 *report.txt* 报告如下所示:
```
[SUMMARY] TOTAL : 67, SUCCESS : 67, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
[cases/transaction/atomicity.sql] TOTAL : 67, SUCCESS : 67, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
```
### <h3><a name="new_test_scenario">示例 4</a></h3>
**示例描述**
- 新建一个命名为 *local_test* 的文件夹,放在 */cases* 目录下
- 本地新增一个命名为测试文件 *new_test.sql*,放在 *cases/local_test/* 路径下
- 仅想要运行 *new_test.sql** 测试用例
**步骤**
1. 拉取最新的 *mo-tester* 远端仓库。
```
cd mo-tester
git pull https://github.com/matrixorigin/mo-tester.git
```
2. 生成测试结果:
- 方式 1:运行如下命令,生成测试结果。
```
./run.sh -p cases/local_test/new_test.sql -m genrs -g
```
- 方式 2:打开 *run.yml* 文件,先将 *method* 参数由默认的 `run` 修改为 `genrs`,再运行如下命令,生成测试结果。
```
./run.sh -p cases/local_test/new_test.sql
```
3.*result/* 路径下查看 *local_test/new_test.result* 结果。
4. 运行如下命令,即运行 *mo-tester* 仓库内 *cases/local_test/new_test.sql* 测试用例:
```
./run.sh -p cases/local_test/new_test.sql -m run -g
```
4.*report/* 路径下的 *error.txt**report.txt**success.txt* 报告文件中查看运行结果。例如,*report.txt* 中结果如下所示:
```
[SUMMARY] TOTAL : 67, SUCCESS : 67, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
[cases/local_test/new_test.sql] TOTAL : 67, SUCCESS : 67, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
```
......@@ -39,7 +39,7 @@ MO-Tester includes testing cases in the following table.
* Make sure you have installed jdk8.
* Launch MatrixOne or other database instance. Please refer to more information about [how to install and launch MatrixOne](https://docs.matrixorigin.io/0.5.0/MatrixOne/Get-Started/install-standalone-matrixone/).
* Launch MatrixOne or other database instance. Please refer to more information about [how to install and launch MatrixOne](../Get-Started/install-standalone-matrixone/).
* Clone `mo-tester` repository.
......@@ -49,7 +49,7 @@ MO-Tester includes testing cases in the following table.
## 2. Configure `mo-tester`
* In `mo.yml` file, configure the server address, default database name, username&password, etc. MO-tester is based on java, so these parameters are required for the JDBC driver. Below is a default example for a local standalone version MatrixOne.
* In `mo.yml` file, configure the server address, default database name, username, and password, etc. MO-tester is based on java, so these parameters are required for the JDBC(JDBC,Java Database Connectivity) driver. Below is a default example for a local standalone version MatrixOne.
```
#jdbc
......@@ -77,42 +77,41 @@ MO-Tester includes testing cases in the following table.
## 3. Run mo-tester
* With the simple below command, all the SQL test cases will automatically run and generate reports and error messages to `report/report.txt` and `report/error.txt`.
* With the simple below command, all the SQL test cases will automatically run and generate reports and error messages to *report/report.txt* and *report/error.txt*.
```
> ./run.sh
```
If you'd like to adjust the test range, you can just change the `path` parameter of `run.yml`. And you can also specify some parameters when executing the command `run.sh`, parameters are as followings:
If you'd like to adjust the test range, you can just change the `path` parameter of `run.yml`. And you can also specify some parameters when executing the command `run.sh`, parameters are as followings:
|Parameters|Description|
|---|---|
|-p|set the path of test cases needed to be executed by mo-tester, the default value is configured by the `path` in `run.yaml`|
|-m|set the method that mo-tester will run with, the default value is configured by the `method` in `run.yaml`|
|-t| set the type of the format that mo-tester executes the SQL command in, the default value is configured by the `type` in `run.yaml`|
|-r|set The success rate that test cases should reach, the default value is configured by the `rate` in `run.yaml`|
|-i|set the including list, and only script files in the path whose name contains one of the lists will be executed, if more than one, separated by `,`, if not specified, refers to all cases included|
|-e|set the excluding list, and script files in the path whose name contains one of the lists will not be executed, if more than one, separated by `,`, if not specified, refers to none of the cases excluded|
|-g|means SQL commands which is marked with [bvt:issue] flag will not be executed,this flag starts with [-- @bvt:issue#{issueNO.}],and ends with [-- @bvt:issue],eg:<br>-- @bvt:issue#3236<br/><br>select date_add("1997-12-31 23:59:59",INTERVAL "-10000:1" HOUR_MINUTE);<br/><br>select date_add("1997-12-31 23:59:59",INTERVAL "-100 1" YEAR_MONTH);<br/><br>-- @bvt:issue<br/><br>Those two sql commands are associated with issue#3236, and they will not be executed in bvt test, until the flag is removed when issue#3236 is fixed.<br/>|
|-n|means the metadata of the resultset will be ignored when comparing the result|
**Examples**:
```
-p set the path of test cases needed to be executed by mo-tester, the default value is configured by the `path` in `run.yaml`
-m set the method that mo-tester will run with, the default value is configured by the `method` in `run.yaml`
-t set the type of the format that mo-tester executes the SQL command in, the default value is configured by the `type` in `run.yaml`
-r set The success rate that test cases should reach, the default value is configured by the `rate` in `run.yaml`
-i set the including list, and only script files in the path whose name contains one of the lists will be executed, if more than one, separated by `,`, if not specified, refers to all cases included
-e set the excluding list, and script files in the path whose name contains one of the lists will not be executed, if more than one, separated by `,`, if not specified, refers to none of the cases excluded
-g means SQL commands which is marked with [bvt:issue] flag will not be executed,this flag starts with [-- @bvt:issue#{issueNO.}],and ends with [-- @bvt:issue],eg:
-- @bvt:issue#3236
select date_add("1997-12-31 23:59:59",INTERVAL "-10000:1" HOUR_MINUTE);
select date_add("1997-12-31 23:59:59",INTERVAL "-100 1" YEAR_MONTH);
-- @bvt:issue
Those two sql commands are associated with issue#3236, and they will not be executed in bvt test, until the flag is removed when issue#3236 is fixed.
-n means the metadata of the resultset will be ignored when comparing the result
Examples:
bash run.sh -p case -m run -t script -r 100 -i select,subquery -e substring -g
./run.sh -p case -m run -t script -r 100 -i select,subquery -e substring -g
```
If you want to automatically generate SQL results for the new SQL cases, you can just change the `method` parameter of `run.yml` to `genrs`. Running the `run.sh` scripts will directly record test results in the `result/` path with their original filenames.
If you want to automatically generate SQL results for the new SQL cases, you can just change the `method` parameter of `run.yml` file to `genrs`, or you can just change the command `-m run` to `-m genrs`. Running the `run.sh` scripts will directly record test results in the `result/` path with their original filenames. For more information on example, see <a href="#new_test_scenario">Example 4</a>.
Note: every time running `run.sh` will overwrite the `error`, `report`, and `success` reports.
!!! note
Every time running `run.sh` will overwrite the report of the *error.txt* file, *report.txt* file, and *success.txt* file.
## 4. Check the report
* Once the test is finished, `mo-tester` generates `error`, `report` and `success` reports in `txt` format.
* Once the test is finished, *mo-tester* generates *error.txt* file, *report.txt* file and *success.txt* file reports .
* An example of `report.txt` looks like this:
* An example of *report.txt* file looks like this:
```
[SUMMARY] TOTAL : 486, SUCCESS : 486, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
......@@ -122,7 +121,7 @@ Note: every time running `run.sh` will overwrite the `error`, `report`, and `suc
[cases/transaction/isolation_1.sql] TOTAL : 217, SUCCESS : 217, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
```
* An example of `error.txt` looks like this:
* An example of *error.txt* file looks like this:
```
[ERROR]
......@@ -137,3 +136,126 @@ c d
c d
1 1
```
## 5. Test Examples
### Example 1
**Example Description**: Run all test cases in the */cases* path of the *mo-tester* repository.
**Steps**:
1. Get the latest *mo-tester* code.
```
cd mo-tester
git pull https://github.com/matrixorigin/mo-tester.git
```
2. To run all the test cases of the *mo-tester* repository, see the following commands:
```
./run.sh
```
3. Check the result reports in the *error.txt* file, *report.txt* file, and *success.txt* file in the *report/* path.
### Example 2
**Example Description**: Run the test cases in the */cases/transaction/* path of the *mo-tester* repository.
**Steps**:
1. Get the latest *mo-tester* code.
```
cd mo-tester
git pull https://github.com/matrixorigin/mo-tester.git
```
2. To run the test cases in the *cases/transaction/* path of the *mo-tester* repository, see the following commands:
```
./run.sh -p cases/transaction/
```
3. Check the result reports in the *error.txt* file, *report.txt* file, and *success.txt* file in the *report/* path. The example of the expected *report.txt* looks like this:
```
[SUMMARY] TOTAL : 486, SUCCESS : 486, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
[cases/transaction/atomicity.sql] TOTAL : 67, SUCCESS : 67, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
[cases/transaction/isolation.sql] TOTAL : 202, SUCCESS : 202, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
[cases/transaction/isolation_1.sql] TOTAL : 217, SUCCESS : 217, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
```
### Example 3
**Example Description**: Run the single test case *cases/transaction/atomicity.sql*.
**Steps**:
1. Get the latest *mo-tester* code.
```
cd mo-tester
git pull https://github.com/matrixorigin/mo-tester.git
```
2. To run the test cases *cases/transaction/atomicity.sql*, see the following commands:
```
./run.sh -p cases/transaction/atomicity.sql
```
3. Check the result reports in the *error.txt* file, *report.txt* file, and *success.txt* file in the *report/* path. The example of the expected *report.txt* looks like this:
```
[SUMMARY] TOTAL : 67, SUCCESS : 67, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
[cases/transaction/atomicity.sql] TOTAL : 67, SUCCESS : 67, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
```
### <h3><a name="new_test_scenario">Example 4</a></h3>
**Example Description**:
- Create a new folder named *local_test* and place it in */cases*
- Add a test file named *new_test.sql* to *cases/local_test/*
- Only run the single test case *new_test.sql**
**Steps**
1. Get the latest *mo-tester* code.
```
cd mo-tester
git pull https://github.com/matrixorigin/mo-tester.git
```
2. Generate test results:
- Method 1: To generate the test result, run the following command.
```
./run.sh -p cases/local_test/new_test.sql -m genrs -g
```
- Method 2: Open the *run.yml* file, change the *method* parameter from the default `run` to `genrs`, and run the following command to generate the test result.
```
./run.sh -p cases/local_test/new_test.sql
```
3. Check the result file in the *result/* path.
4. To run the test cases *cases/local_test/new_test.sql*, see the following commands:
```
./run.sh -p cases/local_test/new_test.sql -m run -g
```
4. Check the result reports in the *error.txt* file, *report.txt* file, and *success.txt* file in the *report/* path. The example of the expected *report.txt* looks like this:
```
[SUMMARY] TOTAL : 67, SUCCESS : 67, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
[cases/local_test/new_test.sql] TOTAL : 67, SUCCESS : 67, ERROR :0, NOEXE :0, SUCCESS RATE : 100%
```
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment