MySQL Test Suite使用

MySQL自动测试套件(The MySQL Test Suite)用于对MySQL程序进行测试,包括各种功能与存储引擎。包含于MySQL与MariaDB版本代码中,位于mysql-test目录下。总体测试脚本为mysql-test-run.pl。该perl脚本通过调用各种已有的测试脚本,将测试结果与预置的result文件做对比来判断测试是否通过。(任何一点差异都会导致测试失败,包括预期之外的warning)
 
 

一、主要目录介绍

    • include
包含.inc文件,用于测试开始时判断是否满足测试条件,在测试用通过source命令引入
如hava_innodb.inc:
 
1
2
3
4
if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED')`)
{
             --skip Test requires InnoDB.
}

如不满足,则会跳过需要该验证的测试。

    • suite
包含所有测试suite,每一个suite为一个测试用例集,具体用例集在2节介绍
 
 
    • t
1、测试文件
例:1st.test
 
1
2
3
4
5
#
# Check that we haven't any strange new tables or databases
#
show databases;
show tables in mysql;

上面内容即为1st这个测试用例的测试脚本

 2、配置文件
例:innodb_bug53674-master.opt
–loose-innodb-locks-unsafe-for-binlog –binlog-format=mixed
为该测试需要的特殊配置项
 
3、脚本文件,在测试开始之前执行的脚本
例:rpl_misc_functions-slave.sh
rm -f $MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile
 
 
    • r
结果文件,判断是否通过的依据
使用上面的例子:1st.result
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
show databases;
Database
information_schema
mtr
mysql
performance_schema
test
show tables in mysql;
Tables_in_mysql
column_stats
columns_priv
db
event
func
general_log
gtid_slave_pos
help_category
help_keyword
help_relation
help_topic
host
index_stats
innodb_index_stats
innodb_table_stats
plugin
proc
procs_priv
proxies_priv
roles_mapping
servers
slow_log
table_stats
tables_priv
time_zone
time_zone_leap_second
time_zone_name
time_zone_transition
time_zone_transition_type
user

执行完1st用例会严格比对该文件。完全一致则测试通过。

    • std_date
有些测试需要用到一些标准数据。
 
    • var
测试默认使用该文件夹下的my.cnf文件
 
 

二、测试用例集

./mysql-test-run.pl不带任何参数表示执行所有测试用例集。使用—suite=suitename来指定单独执行suitename目录下的所有测试用例。
测试用例集包括:
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
main:主要测试用例
archive
binlog
csv
encryption:加密功能
engines
federated
funcs_1:额外功能(包括视图、存储过程、INFORMATION_SCHEMA等)
funcs_2:额外功能(字符集等)
galera
galera_3nodes
handler
heap
innodb
innodb_fts:innodb全文索引
innodb_zip:innodb压缩
jp:日本字符相关测试
large_tests:
maria
mtr
mtr2
multi_source
ndb
optimizer_unfixed_bugs
parts
percona
perfschema
perfschema_stress
plugins
roles
rpl
storage_engine
stress
sys_vars
unit
vcol
wsrep

三、主要参数

force:默认情况下,只要遇到一个用例出错,测试程序就会退出,在指定force的情况下,测试程序会继续执行下面的测试(但是最多发现10个错误还是会退出)
suite:指定使用的测试suite
do-test:会以输入的字符串进行匹配用例执行
skip-test:会以输入的字符串进行匹配跳过用例执行
big-test:执行标记为big的测试用例。因为用例较大、耗时较长,标记为big的用例默认不会执行。输入两遍big-test则只执行标记为big的测试用例
recored:重新生成结果文件
mysqld:传递启动参数给mysqld,每个参数需要分别指定一个mysqld
其他还有很多选项,可以使用./mtr –help查看
 
如果需要在服务启动前执行一些脚本,可以写在 t/testname.sh文件中,由mtr自动执行。
 
 

四、测试举例

例1:
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
[lzk@redhat64-26 mysql-test]$ ./mtr  --force --big-test --suite=archive
Logging: ./mtr  --force --big-test --suite=archive
vardir: /home/lzk/mysql-test/var
Checking leftover processes...
Removing old var directory...
Creating var directory '/home/lzk/mysql-test/var'...
Checking supported features...
MariaDB Version 10.1.12-MariaDB
 - SSL connections supported
Using suites: archive
Collecting tests...
Installing system database...
 
==============================================================================
 
TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------
 
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
archive.archive_debug                    [ skipped ]  Requires debug build
archive.partition_archive                [ pass ]     74
archive.archive_no_symlink               [ pass ]      5
archive.archive-big                      [ pass ]  298619
archive.archive                          [ pass ]    417
archive.archive_bitfield                 [ pass ]     37
archive.archive_gis                      [ pass ]     66
archive.archive_symlink                  [ pass ]     11
archive.discover                         [ pass ]     47
archive.discover_5438                    [ pass ]      7
archive.mysqlhotcopy_archive             [ pass ]   1035
archive.repair                           [ pass ]      3
archive.archive_plugin                   [ pass ]      6
--------------------------------------------------------------------------
The servers were restarted 3 times
Spent 300.327 of 309 seconds executing testcases
 
Completed: All 12 tests were successful.
 
1 tests were skipped, 0 by the test itself.
 
可以看出共完成12个测试用例,全部通过。1个用例必须在debug模式下测试,所以跳过。测试过程中服务重启3次。测试默认使用16000-16019端口。
 
例2:
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[lzk@redhat64-26 mysql-test]$  ./mtr binlog_innodb_row
Logging: ./mtr  binlog_innodb_row
vardir: /home/lzk/mysql-test/var
Checking leftover processes...
 - found old pid 28610 in 'mysqld.1.pid', killing it...
   process did not exist!
Removing old var directory...
Creating var directory '/home/lzk/mysql-test/var'...
Checking supported features...
MariaDB Version 10.1.12-MariaDB
 - SSL connections supported
klist: No credentials cache found (ticket cache FILE:/tmp/krb5cc_550)
Collecting tests...
Installing system database...
 
==============================================================================
 
TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------
 
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
binlog.binlog_innodb_row 'innodb_plugin,row' [ pass ]   3361
binlog.binlog_innodb_row 'row,xtradb'    [ pass ]   3349
--------------------------------------------------------------------------
The servers were restarted 1 times
Spent 6.710 of 17 seconds executing testcases
 
Completed: All 2 tests were successful.

每个测试结束前,mtr会检索error日志,如果发现warning或error,则测试失败。

再来看两个失败用例:
(截取部分日志)
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
innodb.innodb_bug53674 'innodb_plugin'   [ fail ]  Found warnings/errors in server log file!
        Test ended at 2016-03-24 20:57:36
line
2016-03-24 20:57:35 7fd0fc6fc7e0 InnoDB: Warning: Using innodb_locks_unsafe_for_binlog is DEPRECATED. This option may be removed in future releases. Please use READ COMMITTED transaction isolation level instead, see http://dev.mysql.com/doc/refman/5.6/en/set-transaction.html.
^ Found warnings in /home/lzk/mysql-test/var/log/mysqld.1.err
ok
 
 - saving '/home/lzk/mysql-test/var/log/innodb.innodb_bug53674-innodb_plugin/' to '/home/lzk/mysql-test/var/log/innodb.innodb_bug53674-innodb_plugin/'
innodb.innodb_bug53674 'xtradb'          [ fail ]  Found warnings/errors in server log file!
        Test ended at 2016-03-24 20:57:37
line
2016-03-24 20:57:36 7f274c58b7e0 InnoDB: Warning: Using innodb_locks_unsafe_for_binlog is DEPRECATED. This option may be removed in future releases. Please use READ COMMITTED transaction isolation level instead, see http://dev.mysql.com/doc/refman/5.6/en/set-transaction.html.
^ Found warnings in /home/lzk/mysql-test/var/log/mysqld.1.err
ok
 
 - saving '/home/lzk/mysql-test/var/log/innodb.innodb_bug53674-xtradb/' to '/home/lzk/mysql-test/var/log/innodb.innodb_bug53674-xtradb/'

分析日志可以看出是在测试过程中在错误日志中发现了warnings/errors。原因是使用了废弃的参数innodb_locks_unsafe_for_binlog导致warning。

找到并修改配置文件:innodb_bug53674-master.opt
将–loose-innodb-locks-unsafe-for-binlog –binlog-format=mixed
修改为:–transaction-isolation=READ-COMMITTED –binlog-format=mixed
 
重新测试:
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[lzk@redhat64-26 mysql-test]$ ./mtr innodb_bug53674
Logging: ./mtr  innodb_bug53674
vardir: /home/lzk/mysql-test/var
Checking leftover processes...
Removing old var directory...
Creating var directory '/home/lzk/mysql-test/var'...
Checking supported features...
MariaDB Version 10.1.12-MariaDB
 - SSL connections supported
klist: No credentials cache found (ticket cache FILE:/tmp/krb5cc_550)
Collecting tests...
Installing system database...
 
==============================================================================
 
TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------
 
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
innodb.innodb_bug53674 'innodb_plugin'   [ pass ]    211
innodb.innodb_bug53674 'xtradb'          [ pass ]    205
--------------------------------------------------------------------------
The servers were restarted 1 times
Spent 0.416 of 10 seconds executing testcases
 
Completed: All 2 tests were successful.

不再有warning,测试通过。

MySQL Test Suite使用的更多相关文章

  1. mysql几种性能测试的工具使用

    mysql几种性能测试的工具使用 近期由于要比较mysql及其分支mariadb, percona的性能,了解了几个这方面的工具,包括:mysqlslap sysbench tpcc-mysql,做一 ...

  2. Installing MySQL Server

    Installing MySQL Server Here we will learn how to Compile and Install the MySQL Server from source c ...

  3. MySQL基准测试(三)--开源工具与实例演示

    MySQL基准测试(三)--开源工具与实例演示 针对web应用 ab ab是一个Apache HTTP服务的基准测试工具. http_load http_load是一个针对Web服务器测试工具. JM ...

  4. mysql压力测试工具Mysqlslap

    mysql 性能测试工具:The MySQL Benchmark Suite(不支持多CPU而且不是压力工具) 压力测试工具: MySQL super-smack:需要找能连接外网的机器,能连接外网的 ...

  5. 测试mysql性能工具

    mysqlslap mysqlslap可以模拟服务器的负载,并输出计时信息.它包含在MySQL 5.1 的发行包中,应该在MySQL 4.1或者更新的版本中都可以使用.测试时可以执行并发连接数,并指定 ...

  6. MySQL常用配置和性能压力测试:MySQL系列之十五

    一.MySQL常用配置 以下所有配置参数以32G内存的服务器为基 1.打开独立的表空间 innodb_file_per_table = 1 2.MySQL服务所允许的同时会话数的上限,默认为151,经 ...

  7. 高性能MySQL(二)

    MySQL基准测试 为什么需要benchmark 验证基于系统的假设,确认是否符合实际情况 重现系统中的某些异常行为,以解决它们 测试系统当前的运行情况,如果不清楚当前性能,就无法确认优化效果 模拟比 ...

  8. Mysql 5.7 官方文档翻译

    始于 2017年4月1日-愚人节 1.1 MySQL 5.7 新功能 本章节介绍了MySQL 5.7 新版本中新增.废弃.删除的功能. 在1.5章节 Section 1.5, "Server ...

  9. MySQL集群高可用

    目录 MySQL高可用 Galera Cluster Galera Cluster Galera Cluster特点 Galera Cluster 缺点 Galera Cluster工作过程 Gale ...

随机推荐

  1. shell学习(四)

    一.字符截取 expr 基本用法 expr  substr   $var1   起始位置    截取长度,如: [root@localhost mnt]# a=Centos6.9[root@local ...

  2. 【AtCoder】AGC029(A-E)

    A - Irreversible operation 题解 把每个B后面的W个数累加起来即可 代码 #include <bits/stdc++.h> #define fi first #d ...

  3. 【noip模拟赛3】贾老二的工件 (模拟)

    描述 贾老二有很多工件,最常见的工件都是长条形的,但其顶端是凹凸不平的,即不同位置的高度不同.现在贾老二有两个最常见的工件,他想将它们完全放入另一种罕见的可容纳高度不超过k的工件中,问该罕见的工件的最 ...

  4. oj提交时常见错误归纳

    Presentation Error: 常见的PE错误应该有以下的几种情况: 每行输出之后有空行 每两行输出之间有空行 一行中,每个输出数字(或字符串,等)之间有空格 一行中,每个输出数字(或字符串, ...

  5. [过程记录]Centos7 下 Hadoop分布式集群搭建

    过程如下: 配置hosts vim /etc/hosts 格式: ip hostname ip hostname 设置免密登陆 首先:每台主机使用ssh命令连接其余主机 ssh 用户名@主机名 提示是 ...

  6. 关于函数getline()(简单注意事项,不懂你怼我!!!)

    关于getline()函数好使但是有毒: 有两种操作需要进行特殊处理: First: #include <iostream>#include <cstring>#include ...

  7. Spring Cache缓存技术的介绍

    缓存用于提升系统的性能,特别适用于一些对资源需求比较高的操作.本文介绍如何基于spring boot cache技术,使用caffeine作为具体的缓存实现,对操作的结果进行缓存. demo场景 本d ...

  8. 第二届i春秋挖洞大赛的一些感想

    挖洞比赛嘛,根据规则就是一个问题,如何在短时间内挖到更多.等级更高的漏洞? 先分析这个问题,需求是什么? 更多? 等级更高? 短时间内? 首先要解决的是时间的问题 时间有限,所以你必须要快.如何快?把 ...

  9. Android-Kotlin在Fragment获取View

    Android-Kotlin在Fragment获取View Overview 在使用Fragment的时候,使用了ButterKnife 来获取View但是一直出错,后来就直接使用Kotlin的导入布 ...

  10. java 中的同步机制

    对于有些场景,需要a.b线程按照顺序去执行,因为b线程要依赖a线程对某共享资源或 状态处理后,对于这种情况可以使用 private CountDownLatch connectedSignal = n ...