The mysqltest program runs a test case against a MySQL server and optionally compares the output with a result file.
mysqltest程序针对MySQL服务器运行一个测试用例,并可选地将输出与结果文件进行比较。
This program reads input written in a special test language. Typically, you invoke mysqltest using mysql-test-run.pl rather than invoking it directly.
这个程序读取用特殊测试语言编写的输入。通常,使用mysql-test-run.pl调用mysqltest,而不是直接调用它。
Features of mysqltest:
mysqltest的特点:
Can send SQL statements to MySQL servers for execution
可以发送SQL语句到MySQL服务器执行Can execute external shell commands
可以执行外部shell命令Can test whether the result from an SQL statement or shell command is as expected
能测试SQL语句或shell命令的结果是否符合预期Can connect to one or more standalone mysqld servers and switch between connections
可以连接到一个或多个独立的mysqld服务器,并在连接之间切换
By default, mysqltest reads the test case on the standard input. To run mysqltest this way, you normally invoke it like this:
默认情况下,mysqltest在标准输入上读取测试用例。要这样运行mysqltest,你通常像这样调用它:
shell> mysqltest [options] [db_name] < test_file
You can also name the test case file with a --test- file=file_name option.
您也可以使用——test- file=file_name选项为测试用例文件命名。
The exit value from mysqltest is 0 for success, 1 for failure, and 62 if it skips the test case (for example, if after checking some preconditions it decides not to run the test).
mysqltest的退出值为0表示成功,1表示失败,如果它跳过测试用例,则为62(例如,如果在检查了一些先决条件后,它决定不运行测试)。
mysqltest supports the following options:
-
--help, -?
Display a help message and exit.
显示帮助信息并退出。 -
--async-client
Enable asynchronous communication support in mysql protocol.
在mysql协议中启用异步通信支持。 -
--basedir=dir_name, -b dir_name
The base directory for tests.
测试的基本目录。 -
--character-sets-dir=path
The directory where character sets are installed.
字符集安装的目录。 -
--colored-diff
Colorize the diff part of the output.
对输出的差值部分着色。If enabled, mysqltest uses diff command with --color='always' option to print the colored diff. If the command fails or is not supported, mysqltest will report an error and abort the test run.
如果enabled, mysqltest使用diff命令和——color='always'选项来打印彩色的diff,如果命令失败或不支持,mysqltest将报告一个错误并中止测试运行。Note
- --color option for diff command is available from GNU diffutils version 3.4.
diff命令的——color选项在GNU diffutils 3.4版本中可用。
- --color option for diff command is available from GNU diffutils version 3.4.
-
--compress, -C
Compress all information sent between the client and the server if both support compression.
压缩客户端和服务器之间发送的所有信息,如果两者都支持压缩。 -
--cursor-protocol
Use cursors for prepared statements.
对准备好的语句使用游标。 -
--database=db_name, -D db_name
The default database to use.
要使用的默认数据库。 -
--debug[=debug_options], -#[debug_options]
Write a debugging log if MySQL is built with debugging support. The default debug_options value is 'd:t:S:i:O,/tmp/mysqltest.trace'.
如果MySQL是带调试支持的,写一个调试日志。默认的debug_options值是'd:t:S:i:O,/tmp/mysqltest.trace'。 -
--debug-check
Print some debugging information when the program exits.
在程序退出时打印一些调试信息。 -
--debug-info
Print debugging information and memory and CPU usage statistics when the program exits.
当程序退出时,打印调试信息和内存和CPU使用统计信息。 -
--default-character-set=charset_name
Use charset_name as the default character set for the client and connection. For more information, see Connection Character Sets and Collations.
使用charset_name作为客户端和连接的默认字符集。有关更多信息,请参见连接字符集和排序规则。 -
--explain-protocol
Run EXPLAIN EXTENDED on all SELECT, INSERT, REPLACE, UPDATE and DELETE queries.
在所有的SELECT、INSERT、REPLACE、UPDATE和DELETE查询上运行EXPLAIN extension。 -
--host=host_name, -h host_name
Connect to the MySQL server on the given host.
连接到给定主机上的MySQL服务器。 -
--include=file_name, -i file_name
Include the contents of the given file before processing the contents of the test file. The included file should have the same format as other mysqltest test files. This option has the same effect as putting a --source file_name command as the first line of the test file.
在处理测试文件的内容之前,包含给定文件的内容。包含的文件应该具有与其他mysqltest测试文件相同的格式。这个选项与将——source file_name命令作为测试文件的第一行具有相同的效果。 -
--json-explain-protocol
Run EXPLAIN EXTENDED on all SELECT, INSERT, REPLACE, UPDATE and DELETE queries. The json-explain-protocol
在所有的SELECT、INSERT、REPLACE、UPDATE和DELETE查询上运行EXPLAIN extension。的json-explain-protocol -
--logdir=dir_name
The directory to use for log files.
用于日志文件的目录。 -
--mark-progress
Write the line number and elapsed time to test_file.progress.
将行号和运行时间写入test_file.progress。 -
--max-connect-retries=num
The maximum number of connection attempts when connecting to server.
连接到服务器时的最大连接次数。 -
--max-connections=num
The maximum number of simultaneous server connections per client (that is, per test). If not set, the maximum is 128. Minimum allowed limit is 8, maximum is 5120.
每个客户机(即每个测试)同时进行的最大服务器连接数。如果未设置,则最大为128。最小允许的数量是8,最大是5120。 -
--no-defaults
Do not read default options from any option files. If used, this must be the first option.
不要从任何选项文件中读取默认选项。如果使用,这必须是第一个选项。 -
--plugin-dir=path
The directory in which to look for plugins. It may be necessary to specify this option if the default_auth argument is used for the connect() command to specify an authentication plugin but mysqltest does not find it.
查找插件的目录。如果connect()命令使用default_auth参数来指定身份验证插件,但mysqltest没有找到它,那么可能需要指定这个选项。 -
--password[=password], -p[password]
The password to use when connecting to the server. If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password value following the --password or -p option on the command line, you are prompted for one.
连接到服务器时使用的密码。如果使用短选项形式(-p),则选项和密码之间不能有空格。如果忽略命令行上——password或-p选项后面的密码值,则会提示输入一个。 -
--port=port_num, -P port_num
The TCP/IP port number to use for the connection.
用于连接的TCP/IP端口号。 -
--protocol={TCP|SOCKET|PIPE|MEMORY}
Choose the protocol for communication with the server. SOCKET is default.
选择与服务器通信的协议。套接字是默认。 -
--ps-protocol
Use the prepared-statement protocol for communication.
使用准备语句协议进行通信。 -
--quiet
Suppress all normal output. This is a synonym for --silent.
禁止所有正常输出。这是silent的同义词。 -
--record, -r
Record the output that results from running the test file into the file named by the --result-file option, if that option is given. It is an error to use this option without also using --result-file.
将运行测试文件的结果记录到由——result-file选项命名的文件中,如果给出了该选项的话。如果不使用——result-file,则使用此选项是错误的。 -
--result-file=file_name, -R file_name
This option specifies the file for test case expected results. --result-file, together with --record, determines how mysqltest treats the test actual and expected results for a test case:
此选项为测试用例预期结果指定文件。——result-file和——record一起决定mysqltest如何处理测试用例的实际和预期结果:If the test produces no results, mysqltest exits with an error message to that effect, unless --result-file is given and the named file is an empty file.
如果测试没有产生结果,mysqltest将退出并输出一条错误消息,除非给出了——result-file并且指定的文件是一个空文件。Otherwise, if --result-file is not given, mysqltest sends test results to the standard output.
否则,如果没有给出——result-file, mysqltest将把测试结果发送到标准输出。With --result-file but not --record, mysqltest reads the expected results from the given file and compares them with the actual results. If the results do not match, mysqltest writes a .reject file in the log directory, outputs a diff of the two files, and exits with an error.
使用——result-file而不是——record, mysqltest从给定的文件中读取预期的结果,并将它们与实际结果进行比较。如果结果不匹配,mysqltest在日志目录中写入一个.reject文件,输出两个文件的差异,并带错误退出。With both --result-file and --record, mysqltest updates the given file by writing the actual test results to it.
使用——result-file和——record, mysqltest通过向它写入实际的测试结果来更新给定的文件。
-
--server-public-key-path=file_name
The path name to a file containing the server RSA public key. The file must be in PEM format. The public key is used for RSA encryption of the client password for connections to the server made using accounts that authenticate with the sha256_password plugin. This option is ignored for client accounts that do not authenticate with that plugin. It is also ignored if password encryption is not needed, as is the case when the client connects to the server using an SSL connection.
包含服务器RSA公钥的文件路径名。文件格式必须为PEM。该公钥用于RSA对使用sha256_password插件进行身份验证的帐户与服务器连接时的客户端密码进行加密。对于没有使用该插件进行身份验证的客户端帐户,将忽略此选项。如果不需要密码加密,它也会被忽略,比如当客户机使用SSL连接连接到服务器时。The server sends the public key to the client as needed, so it is not necessary to use this option for RSA password encryption to occur. It is more efficient to do so because then the server need not send the key.
服务器根据需要将公钥发送给客户端,因此RSA密码加密不需要使用此选项。这样做效率更高,因为服务器不需要发送密钥。For additional discussion regarding use of the sha256_password plugin, including how to get the RSA public key, see The SHA-256 Authentication Plugin.
关于sha256_password插件使用的更多讨论,包括如何获取RSA公钥,请参见SHA-256认证插件。 -
--silent, -s
Suppress all normal output.
禁止所有正常输出。 -
--skip-safemalloc
Do not use memory allocation checking.
不要使用内存分配检查。 -
--socket=path, -S path
The socket file to use when connecting to localhost (which is the default host).
连接到localhost(默认主机)时使用的套接字文件。 -
--sp-protocol
Execute DML statements within a stored procedure. For every DML statement, mysqltest creates and invokes a stored procedure that executes the statement rather than executing the statement directly.
在存储过程中执行DML语句。对于每一条DML语句,mysqltest都会创建并调用一个执行该语句的存储过程,而不是直接执行该语句。 -
--tail-lines=n
Specify how many lines of the result to include in the output if the test fails because an SQL statement fails. The default is 0, meaning no lines of result printed.
指定如果由于SQL语句失败而导致测试失败,输出中要包含多少行结果。默认值为0,表示不打印结果行。 -
--test-file=file_name, -x file_name
Read test input from this file. The default is to read from the standard input.
从这个文件中读取测试输入。默认是从标准输入中读取。 -
--timer-file=file_name, -m file_name
If given, the number of millisecond spent running the test will be written to this file. This is used by mysql-test-run.pl for its reporting.
如果给出,则将运行测试所花费的毫秒数写入该文件。它被mysql-test-run.pl用于报告。 -
--tls-version=protocol_list
The protocols permitted by the client for encrypted connections. The value is a comma-separated list containing one or more of these protocols: TLSv1, TLSv1.1, TLSv1.2.
客户端允许的加密连接协议。逗号分隔的列表,包含一个或多个协议:TLSv1、TLSv1.1、TLSv1.2。 -
--tmpdir=dir_name, -t dir_name
The temporary directory where socket files are created.
创建套接字文件的临时目录。 -
--trace-exec
If enabled, this option causes mysqltest to immediately display the output from executed programs to stdout.
如果启用该选项,mysqltest会立即将已执行程序的输出显示到stdout。 -
--user=user_name, -u user_name
The MySQL user name to use when connecting to the server.
连接到服务器时使用的MySQL用户名。 -
--verbose, -v
Verbose mode. Print out more information about what the program does.
详细的模式。打印更多关于程序功能的信息。 -
--version, -V
Display version information and exit.
显示版本信息并退出。 -
--view-protocol
Every SELECT statement is wrapped inside a view.
每个SELECT语句都包装在一个视图中。