mtr Running Test Cases

Running Test Cases

Typically, you run the test suite either from within a source tree (after MySQL has been built), or on a host where the MySQL server distribution has been installed.
通常,您可以在源树中(在MySQL构建之后)运行测试套件,或者在安装了MySQL服务器分发版的主机上运行测试套件。

(If you find that the test suite is not included in your distribution, look for a similar distribution with -test in the name and install that as well.)
(如果您发现该测试套件不包含在您的发行版中,请查找名称中带有-test的类似发行版并安装它。)

To run tests, your current working directory should be the mysql-test directory of your source tree or installed distribution. In a source distribution, mysql-test is under the root of the source tree. In a binary distribution, the location of mysql-test depends on the distribution layout. The program that runs the test suite, mysql-test-run.pl, will figure out whether you are in a source tree or an installed directory tree.
要运行测试,当前的工作目录应该是源代码树或安装的发行版的mysql-test目录。在源码发布中,mysql-test位于源码树的根下。在二进制发行版中,mysql-test的位置取决于发行版的布局。运行测试套件的程序mysql-test-run.pl将确定您是在源代码树中还是在已安装的目录树中。

To run the test suite, change location into your mysql-test directory and invoke the mysql-test-run.pl script:
要运行测试套件,将位置更改到你的mysql-test目录,并调用mysql-test-run.pl脚本:

shell> cd mysql-test
shell> ./mysql-test-run.pl

mysql-test-run.pl accepts options on the command line. For example:
mysql-test-run.pl 接收命令行参数,例如:

shell> ./mysql-test-run.pl --force --suite=binlog

By default, mysql-test-run.pl exits if a test case fails. --force causes execution to continue regardless of test case failure.
默认情况下,如果测试用例失败,mysql-test-run.pl将退出。——force导致执行继续,不管测试用例失败。

For a full list of the supported options, see mysql-test-run.pl — Run MySQL Test Suite.
有关支持的选项的完整列表,请参阅 mysql-test-run.pl - Run MySQL测试套件。

To run one or more specific test cases, name them on the mysql-test-run.pl command line. Test case files have names like t/test_name.test, where test_name is the name of the test case, but each name given on the command line should be the test case name, not the full test case file name. The following command runs the test case named rpl_abcd, which has a test file of t/rpl_abcd.test:
要运行一个或多个特定的测试用例,请在mysql-test-run.pl命令行中为它们命名。测试用例文件的名称类似于t/test_name。test_name是测试用例的名称,但是命令行上给出的每个名称都应该是测试用例名称,而不是完整的测试用例文件名。运行名为rpl_abcd的测试用例,测试文件为t/rpl_abcd.test:

shell> ./mysql-test-run.pl rpl_abcd

To run a family of test cases for which the names share a common prefix, use the --do-test option:
要运行名称共享一个公共前缀的一系列测试用例,使用——do-test选项:

shell> ./mysql-test-run.pl --do-test=prefix

For example, the following command runs the events tests (test cases that have names beginning with events):
例如,以下命令运行事件测试(名称以事件开头的测试用例):

shell> ./mysql-test-run.pl --do-test=events

To run a specific named testsuite with all the test cases in it, use the --suite option:
要运行包含所有测试用例的特定命名测试套件,使用——suite选项:

shell> ./mysql-test-run.pl --suite=suite_name

For example, the following command runs the replication tests located in the rpl suite:
例如,以下命令运行位于rpl套件中的复制测试:

shell> ./mysql-test-run.pl --suite=rpl

mysql-test-run.pl starts the MySQL server, sets up the environment for calling the mysqltest program, and invokes mysqltest to run the test case. For each test case to be run, mysqltest handles operations such as reading input from the test case file, creating server connections, and sending SQL statements to servers.
mysql-test-run.pl启动MySQL服务器,设置调用mysqltest程序的环境,并调用mysqltest来运行测试用例。对于要运行的每个测试用例,mysqltest处理诸如从测试用例文件中读取输入、创建服务器连接以及向服务器发送SQL语句等操作。

The language used in test case files is a mix of commands that the mysqltest program understands and SQL statements. Input that mysqltest doesn't understand is assumed to consist of SQL statements to be sent to the database server. This makes the test case language familiar to those that know how to write SQL and powerful enough to add the control needed to write test cases.
测试用例文件中使用的语言是mysqltest程序理解的命令和SQL语句的混合。假设mysqltest不能理解的输入包含要发送到数据库服务器的SQL语句。这使得测试用例语言对那些知道如何编写SQL的人来说很熟悉,而且它的功能足够强大,可以添加编写测试用例所需的控件。

You need not start a MySQL server first before running tests. Instead, the mysql-test-run.pl program will start the server or servers as needed. Any servers started for the test run use ports in the range from 13000 by default.
在运行测试之前,不需要先启动MySQL服务器。相反,mysql-test-run.pl程序将根据需要启动服务器。默认情况下,为测试运行启动的任何服务器都使用13000范围内的端口。

Running Tests in Parallel

It is possible to run more than one instance of mysql-test-run.pl simultaneously on the same machine. Both will by default use server ports from 13000 but will coordinate used port numbers as well as check for availibility, to avoid conflicts.
可以在同一台机器上同时运行多个mysql-test-run.pl实例。两者都将默认使用13000起的服务器端口,但将协调使用的端口号,并检查可用性,以避免冲突。

Running several instances from the same mysql-test directory is possible but problematic. You must the use the --vardir to set different log directories for each instance. Even so, you can get into trouble becuse they will write .reject files to the same directories.
从同一个mysql-test目录运行几个实例是可能的,但有问题。您必须使用——vardir为每个实例设置不同的日志目录。即使这样,您也会遇到麻烦,因为它们会将.reject文件写入相同的目录。

It is also possible to have a single mysql-test-run.pl run tests in several threads in parallel. Execution of the tests will be distributed among the threads. This is achieved using the --parallel option, with the number of threads as argument. The special value auto will ask mysql-test-run.pl to pick a value automatically, based on system information. The parallel option may also be given using the environment variable MTR_PARALLEL.
也可以让一个mysql-test-run.pl并行地在几个线程中运行测试。测试的执行将分布在各个线程之间。这可以使用——parallel选项,并使用线程数作为参数。这个特殊值auto会要求mysql-test-run.pl根据系统信息自动选择一个值。parallel选项也可以使用环境变量MTR_PARALLEL给出。

Note

  • Test cases which use not_parallel.inc are run at the end with a parallel value of 1 overriding the --parallel option value. Such test cases will be executed at the end of the test run one at a time.
    使用not_parallel的测试用例。在末尾使用并行值1覆盖——parallel选项值运行Inc。这样的测试用例将在测试运行结束时一次执行一个。
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,390评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,821评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,632评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,170评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,033评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,098评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,511评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,204评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,479评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,572评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,341评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,213评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,576评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,893评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,171评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,486评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,676评论 2 335

推荐阅读更多精彩内容