mtr mysqltest — Program to Run Test Cases

The mysqltest program runs a test case against a MySQL server and optionally compares the output with a result file.
mysqltest程序針對MySQL服務(wù)器運行一個測試用例,并可選地將輸出與結(jié)果文件進行比較。

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調(diào)用mysqltest,而不是直接調(diào)用它瓤逼。

Features of mysqltest:
mysqltest的特點:

  • Can send SQL statements to MySQL servers for execution
    可以發(fā)送SQL語句到MySQL服務(wù)器執(zhí)行

  • Can execute external shell commands
    可以執(zhí)行外部shell命令

  • Can test whether the result from an SQL statement or shell command is as expected
    能測試SQL語句或shell命令的結(jié)果是否符合預(yù)期

  • Can connect to one or more standalone mysqld servers and switch between connections
    可以連接到一個或多個獨立的mysqld服務(wù)器笼吟,并在連接之間切換

By default, mysqltest reads the test case on the standard input. To run mysqltest this way, you normally invoke it like this:
默認情況下,mysqltest在標準輸入上讀取測試用例霸旗。要這樣運行mysqltest贷帮,你通常像這樣調(diào)用它:

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協(xié)議中啟用異步通信支持沟绪。

  • --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版本中可用搜贤。
  • --compress, -C

    Compress all information sent between the client and the server if both support compression.
    壓縮客戶端和服務(wù)器之間發(fā)送的所有信息,如果兩者都支持壓縮钝凶。

  • --cursor-protocol

    Use cursors for prepared statements.
    對準備好的語句使用游標仪芒。

  • --database=db_name, -D db_name

    The default database to use.
    要使用的默認數(shù)據(jù)庫。

  • --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是帶調(diào)試支持的耕陷,寫一個調(diào)試日志掂名。默認的debug_options值是'd:t:S:i:O,/tmp/mysqltest.trace'哟沫。

  • --debug-check

    Print some debugging information when the program exits.
    在程序退出時打印一些調(diào)試信息饺蔑。

  • --debug-info

    Print debugging information and memory and CPU usage statistics when the program exits.
    當程序退出時,打印調(diào)試信息和內(nèi)存和CPU使用統(tǒng)計信息嗜诀。

  • --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作為客戶端和連接的默認字符集猾警。有關(guān)更多信息,請參見連接字符集和排序規(guī)則隆敢。

  • --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服務(wù)器。

  • --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.
    在處理測試文件的內(nèi)容之前匣屡,包含給定文件的內(nèi)容封救。包含的文件應(yīng)該具有與其他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.
    連接到服務(wù)器時的最大連接次數(shù)以舒。

  • --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.
    每個客戶機(即每個測試)同時進行的最大服務(wù)器連接數(shù)趾痘。如果未設(shè)置,則最大為128蔓钟。最小允許的數(shù)量是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參數(shù)來指定身份驗證插件世分,但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.
    連接到服務(wù)器時使用的密碼臭埋。如果使用短選項形式(-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.
    選擇與服務(wù)器通信的協(xié)議。套接字是默認魁莉。

  • --ps-protocol

    Use the prepared-statement protocol for communication.
    使用準備語句協(xié)議進行通信睬涧。

  • --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.
    將運行測試文件的結(jié)果記錄到由——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:
    此選項為測試用例預(yù)期結(jié)果指定文件∈合保——result-file和——record一起決定mysqltest如何處理測試用例的實際和預(yù)期結(jié)果:

    • 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.
      如果測試沒有產(chǎn)生結(jié)果夺溢,mysqltest將退出并輸出一條錯誤消息,除非給出了——result-file并且指定的文件是一個空文件烛谊。

    • Otherwise, if --result-file is not given, mysqltest sends test results to the standard output.
      否則风响,如果沒有給出——result-file, mysqltest將把測試結(jié)果發(fā)送到標準輸出。

    • 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從給定的文件中讀取預(yù)期的結(jié)果丹禀,并將它們與實際結(jié)果進行比較状勤。如果結(jié)果不匹配鞋怀,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通過向它寫入實際的測試結(jié)果來更新給定的文件。

  • --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.
    包含服務(wù)器RSA公鑰的文件路徑名葫盼。文件格式必須為PEM残腌。該公鑰用于RSA對使用sha256_password插件進行身份驗證的帳戶與服務(wù)器連接時的客戶端密碼進行加密。對于沒有使用該插件進行身份驗證的客戶端帳戶剪返,將忽略此選項废累。如果不需要密碼加密,它也會被忽略脱盲,比如當客戶機使用SSL連接連接到服務(wù)器時邑滨。

    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.
    服務(wù)器根據(jù)需要將公鑰發(fā)送給客戶端,因此RSA密碼加密不需要使用此選項钱反。這樣做效率更高掖看,因為服務(wù)器不需要發(fā)送密鑰。

    For additional discussion regarding use of the sha256_password plugin, including how to get the RSA public key, see The SHA-256 Authentication Plugin.
    關(guān)于sha256_password插件使用的更多討論面哥,包括如何獲取RSA公鑰哎壳,請參見SHA-256認證插件。

  • --silent, -s

    Suppress all normal output.
    禁止所有正常輸出尚卫。

  • --skip-safemalloc

    Do not use memory allocation checking.
    不要使用內(nèi)存分配檢查归榕。

  • --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.
    在存儲過程中執(zhí)行DML語句吱涉。對于每一條DML語句刹泄,mysqltest都會創(chuàng)建并調(diào)用一個執(zhí)行該語句的存儲過程,而不是直接執(zhí)行該語句怎爵。

  • --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語句失敗而導(dǎo)致測試失敗特石,輸出中要包含多少行結(jié)果。默認值為0鳖链,表示不打印結(jié)果行姆蘸。

  • --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.
    如果給出逞敷,則將運行測試所花費的毫秒數(shù)寫入該文件。它被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.
    客戶端允許的加密連接協(xié)議兰粉。逗號分隔的列表,包含一個或多個協(xié)議:TLSv1顶瞳、TLSv1.1玖姑、TLSv1.2愕秫。

  • --tmpdir=dir_name, -t dir_name

    The temporary directory where socket files are created.
    創(chuàng)建套接字文件的臨時目錄。

  • --trace-exec

    If enabled, this option causes mysqltest to immediately display the output from executed programs to stdout.
    如果啟用該選項焰络,mysqltest會立即將已執(zhí)行程序的輸出顯示到stdout戴甩。

  • --user=user_name, -u user_name

    The MySQL user name to use when connecting to the server.
    連接到服務(wù)器時使用的MySQL用戶名。

  • --verbose, -v

    Verbose mode. Print out more information about what the program does.
    詳細的模式闪彼。打印更多關(guān)于程序功能的信息甜孤。

  • --version, -V

    Display version information and exit.
    顯示版本信息并退出。

  • --view-protocol

    Every SELECT statement is wrapped inside a view.
    每個SELECT語句都包裝在一個視圖中畏腕。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末缴川,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子描馅,更是在濱河造成了極大的恐慌把夸,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,122評論 6 505
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件铭污,死亡現(xiàn)場離奇詭異恋日,居然都是意外死亡,警方通過查閱死者的電腦和手機嘹狞,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,070評論 3 395
  • 文/潘曉璐 我一進店門岂膳,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人磅网,你說我怎么就攤上這事谈截。” “怎么了涧偷?”我有些...
    開封第一講書人閱讀 164,491評論 0 354
  • 文/不壞的土叔 我叫張陵傻盟,是天一觀的道長。 經(jīng)常有香客問我嫂丙,道長,這世上最難降的妖魔是什么规哲? 我笑而不...
    開封第一講書人閱讀 58,636評論 1 293
  • 正文 為了忘掉前任跟啤,我火速辦了婚禮,結(jié)果婚禮上唉锌,老公的妹妹穿的比我還像新娘隅肥。我一直安慰自己,他們只是感情好袄简,可當我...
    茶點故事閱讀 67,676評論 6 392
  • 文/花漫 我一把揭開白布腥放。 她就那樣靜靜地躺著,像睡著了一般绿语。 火紅的嫁衣襯著肌膚如雪秃症。 梳的紋絲不亂的頭發(fā)上候址,一...
    開封第一講書人閱讀 51,541評論 1 305
  • 那天诞吱,我揣著相機與錄音粗井,去河邊找鬼酵熙。 笑死扩氢,一個胖子當著我的面吹牛驶赏,可吹牛的內(nèi)容都是我干的炸卑。 我是一名探鬼主播,決...
    沈念sama閱讀 40,292評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼煤傍,長吁一口氣:“原來是場噩夢啊……” “哼盖文!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起患久,我...
    開封第一講書人閱讀 39,211評論 0 276
  • 序言:老撾萬榮一對情侶失蹤椅寺,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后蒋失,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體返帕,經(jīng)...
    沈念sama閱讀 45,655評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡篙挽,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,846評論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了铣卡。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片链韭。...
    茶點故事閱讀 39,965評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖煮落,靈堂內(nèi)的尸體忽然破棺而出旋讹,到底是詐尸還是另有隱情,我是刑警寧澤轿衔,帶...
    沈念sama閱讀 35,684評論 5 347
  • 正文 年R本政府宣布沉迹,位于F島的核電站,受9級特大地震影響害驹,放射性物質(zhì)發(fā)生泄漏鞭呕。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,295評論 3 329
  • 文/蒙蒙 一宛官、第九天 我趴在偏房一處隱蔽的房頂上張望葫松。 院中可真熱鬧瓦糕,春花似錦、人聲如沸进宝。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,894評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽党晋。三九已至谭胚,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間未玻,已是汗流浹背灾而。 一陣腳步聲響...
    開封第一講書人閱讀 33,012評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留扳剿,地道東北人旁趟。 一個月前我還...
    沈念sama閱讀 48,126評論 3 370
  • 正文 我出身青樓,卻偏偏與公主長得像庇绽,于是被迫代替她去往敵國和親锡搜。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 44,914評論 2 355

推薦閱讀更多精彩內(nèi)容