|
- 本测试文档,采用GPL 协议,如转载请注明出处 : http://blog.bowenye.com/
- 如商业,请联系本人 QQ : 84437129
复制代码
第四节, 破坏性测试,要把表搞弄,不易,这两天测试如果能让大家都看得把表搞坏的机率.
决定用一些BT的方法,所以下在面的测试基本都是VM里面进行,如果你出现硬件在测试过程中破坏的问题.
请不要找我,因为我也只是测试的,在没有足够明白下面测试的朋友,请注意了.
为了增加出现表坏的机率,请把前面所用过的表都多增加一两个KEY,像下面:
- uchome_docomment_innodb | CREATE TABLE `uchome_docomment_innodb` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `upid` int(10) unsigned NOT NULL DEFAULT '0',
- `doid` mediumint(8) unsigned NOT NULL DEFAULT '0',
- `uid` mediumint(8) unsigned NOT NULL DEFAULT '0',
- `username` char(15) NOT NULL DEFAULT '',
- `dateline` int(10) unsigned NOT NULL DEFAULT '0',
- `message` text NOT NULL,
- `ip` char(20) NOT NULL DEFAULT '',
- `grade` smallint(6) unsigned NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`),
- KEY `doid` (`doid`),
- KEY `upid` (`upid`),
- KEY `username` (`username`)
- ) ENGINE=InnoDB
复制代码
测试方式在之前的代码加个POST参数,作用是同时打开四个页面而根据不同参数来执行不同的操作
操作方式就是select insert update delete 四个.需要FOR循环10W次,当然一万都可以,只不过
是为了有足够的时间来进行"破坏活动",
过程:
1.同时打开四个页面,用参数来确定操作方式
2.在运行一段时间之后,突然把VM关了
结果很简单,经过多次测试.MyISAM 50% 上面机率会出现下面的错误,而PostgreSQL 和InnoDB
没发现错误
- mysql> INSERT INTO uchome_docomment (upid ,doid ,uid ,username ,dateline ,message ,ip ,grade)VALUES (
- -> '1', '2', '1', 'myname', '1234567890', 'messagemes
- sagemessagemessagemessagemessagemessagemessagemessage
- messagemessagemessagemessagemessage', '127.0.0.1', '2'
- -> );
- ERROR 1062 (23000): Duplicate entry '1107639' for key 'PRIMARY'
- mysql> repair table uchome_docomment;
- +------------------------+--------+----------+----------------------------------------------+
- | Table | Op | Msg_type | Msg_text |
- +------------------------+--------+----------+----------------------------------------------+
- | bowen.uchome_docomment | repair | warning | Number of rows changed from 741633 to 741567 |
- | bowen.uchome_docomment | repair | status | OK |
- +------------------------+--------+----------+----------------------------------------------+
- 2 rows in set (38.02 sec)
- ...
- mysql> INSERT INTO uchome_docomment (upid ,doid ,uid ,username ,dateline ,
- message ,ip ,grade)VALUES ( '1', '2', '1', 'myname', '1234567890', 'messag
- emessagemessagemessag
- emessagemessagemessagemessagem
- essagemessagemessagemessagemessagemessage', '127.0.0.1', '2' );
- ERROR 1062 (23000): Duplicate entry '1135730' for key 'PRIMARY'
- mysql> select id from uchome_docomment limit 1;
- +--------+
- | id |
- +--------+
- | 100080 |
- +--------+
- 1 row in set (0.00 sec)
- mysql> delete from uchome_docomment where id=100080;
- ERROR 126 (HY000): Incorrect key file for table './bowen/uchome_docomment.MYI'; try to repair it
复制代码
这节是破坏性测试,操作简单,结果也简单,不过为了成功,倒花费了不少时间,当然不一定是关VM就出现问题
可以试试,在没关VM情况下,突然关闭页面,也会出现表破坏的现像,不过成功性就太低了,不利于发现问题,当然如果你拥有过一个网站
,你应该会试过,网站运行过程中,突然表坏的现像,差不多都出现上面的提示,一般来说,只要用myisamchk,就可以修复的了.
OK,还有下一节,而一下节会是啥测试呢,等等,哈哈 |
|