51Testing软件测试论坛
标题:
LR 测试 sqlserver2005
[打印本页]
作者:
wofeman
时间:
2006-12-29 11:24
标题:
LR 测试 sqlserver2005
选用的是ODBC协议
做一个连表的查询
脚本如下
/* -------------------------------------------------------------------------------
Script Title :
Script Description :
Recorder Version : 1008
------------------------------------------------------------------------------- */
vuser_init()
{
lr_think_time(3);
lr_start_transaction("login");
lrd_init(&InitInfo, DBTypeVersion);
lrd_open_context(&Ctx1, LRD_DBTYPE_ODBC, 0, 0, 0);
lrd_db_option(Ctx1, OT_ODBC_OV_ODBC3, 0, 0);
lrd_alloc_connection(&Con1, LRD_DBTYPE_ODBC, Ctx1, 0 /*Unused*/, 0);
lrd_db_option(Con1, OT_ODBC_LOGIN_TIMEOUT, (void FAR const *)15, 0);
lrd_db_option(Con1, OT_ODBC_SS_QUOTED_IDENT, "OFF", 0);
lrd_db_option(Con1, OT_ODBC_SQL_PACKET_SIZE, (void FAR const *)0, 0);
lrd_open_connection(&Con1, LRD_DBTYPE_ODBC, "", lr_decrypt("4590ade4e"), "", lr_decrypt("4590ade47aebc1e520628ebbe8b9d70b426b24ca6cf40bd9"
"7b33608fa8ff50fa0048d1d4c23920ef37e1d6fcff9e0e2cba8f28312650"
"413665769cfa8db78a5e02c1b7513d025632c47ece3ec3488dc4"), Ctx1, 1, 0);
lrd_open_cursor(&Csr1, Con1, 0);
lrd_db_option(Csr1, OT_ODBC_MAX_LENGTH, (void FAR const *)64512, 0);
lrd_result_set(Csr1, 0, 0, 0);
lrd_db_option(Csr1, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_db_option(Csr1, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_stmt(Csr1, "select @@microsoftversion", -1, 1, 0 /*None*/, 0);
lrd_bind_cols(Csr1, BCInfo_D2, 0);
lrd_fetch(Csr1, -1, 1, 0, PrintRow2, 0);
GRID(2);
lrd_result_set(Csr1, 0, 0, 0);
lrd_result_set(Csr1, 0, 0, 0);
lrd_db_option(Csr1, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_db_option(Csr1, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_result_set(Csr1, 0, 0, 0);
lrd_db_option(Csr1, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_db_option(Csr1, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_stmt(Csr2, "set lock_timeout -1", -1, 1, 0 /*None*/, 0);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_stmt(Csr2, "select IS_SRVROLEMEMBER ('sysadmin')", -1, 1, 0 /*None*/, 0);
lrd_fetch(Csr2, 1, 1, 0, PrintRow14, 0);
GRID(14);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_stmt(Csr2, "set nocount off\r\nset arithabort on\r\nset concat_null_yields_null "
"on\r\nset ansi_nulls on\r\nset cursor_close_on_commit off\r"
"\nset ansi_null_dflt_on on\r\nset implicit_transactions "
"off\r\nset ansi_padding on\r\nset ansi_warnings on\r\nset "
"quoted_identifier on\r\n", -1, 1, 0 /*None*/, 0);
lrd_open_context(&Ctx3, LRD_DBTYPE_ODBC, 0, 0, 0);
lrd_db_option(Ctx3, OT_ODBC_OV_ODBC3, 0, 0);
lrd_alloc_connection(&Con3, LRD_DBTYPE_ODBC, Ctx3, 0 /*Unused*/, 0);
lrd_db_option(Con3, OT_ODBC_LOGIN_TIMEOUT, (void FAR const *)15, 0);
lrd_open_connection(&Con3, LRD_DBTYPE_ODBC, "", lr_decrypt("4590ade4e"), "", lr_decrypt("4590ade47aebc1e520628ebbe8b9d70b426b24ca6cf40bd9"
"7b33608fa8ff50fa0048d1d4c23920ef37e1d6fcff9e0e2cba8f28312650"
"413665769cfa8db78a5e02c1b7513d025632c47ed5c83a217f2de37b540c"
"aaac02bf5002d7808f7a928eacd3fbac31e3c5435f64032510"), Ctx3, 1, 0);
lrd_open_cursor(&Csr3, Con3, 0);
lrd_db_option(Csr3, OT_ODBC_QUERY_TIMEOUT, (void FAR const *)30, 0);
lrd_stmt(Csr3, "set lock_timeout 30", -1, 1, 0 /*None*/, 0);
lrd_close_cursor(&Csr3, 0);
lrd_open_cursor(&Csr4, Con3, 0);
lrd_db_option(Csr4, OT_ODBC_QUERY_TIMEOUT, (void FAR const *)30, 0);
lrd_stmt(Csr4, "dbo.sp_MShasdbaccess", -1, 1, 0 /*None*/, 0);
lrd_bind_cols(Csr4, BCInfo_D27, 0);
lrd_fetchx(Csr4, -15, 1, 0, PrintRow16, 1, 0);
GRID(16);
lrd_db_option(Csr4, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_db_option(Csr4, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_close_cursor(&Csr4, 0);
lr_end_transaction("login",LR_AUTO);
lr_think_time(6);
lr_start_transaction("choice");
//lr_think_time(15);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_stmt(Csr2, "set showplan_text off\r\n", -1, 1, 0 /*None*/, 0);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_stmt(Csr2, "DBCC USEROPTIONS", -1, 1, 0 /*None*/, 0);
lrd_bind_cols(Csr2, BCInfo_D30, 0);
lrd_fetch(Csr2, -14, 1, 0, PrintRow18, 0);
GRID(18);
lrd_stmt(Csr2, "set showplan_text off\r\n", -1, 1, 0 /*None*/, 0);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_stmt(Csr2, "SET NOEXEC OFF SET PARSEONLY OFF", -1, 1, 0 /*None*/, 0);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_stmt(Csr2, "set showplan_all off\r\n", -1, 1, 0 /*None*/, 0);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lrd_stmt(Csr2, "use [UMsgBig]", -1, 1, 0 /*None*/, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lr_end_transaction("choice",LR_AUTO);
return 0;
}
Action()
{
lr_think_time(3);
lr_start_transaction("exe");
//lr_think_time(15);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
//lr_think_time(4);
lrd_stmt(Csr2, "declare @telno bigint\r\ndeclare @area2Spell varchar(16)\r\ndeclare "
"@area3Spell varchar(16)\r\ndeclare @UserID "
"uniqueidentifier\r\ndeclare @time datetime\r\ndeclare @Tag1 "
"varchar(64)\r\ndeclare @Tag2 varchar(64)\r\ndeclare "
"'AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA','??????????????',"
"'00001','0000100002'\r\n,0,'','',0,0,'1900-1-1','1900-1-1',"
"'','0',0,@time,1)\r\n\r\nset @i=@i+1\r\nend\r\n\r\n\r\n\r\n"
"\r\n\r\n", -1, 1, 0 /*None*/, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_bind_cols(Csr2, BCInfo_D33, 0);
lrd_fetch(Csr2, -1, 1, 0, PrintRow22, 0);
GRID(22);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_bind_cols(Csr2, BCInfo_D35, 0);
lrd_fetch(Csr2, -1, 1, 0, PrintRow24, 0);
GRID(24);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_bind_cols(Csr2, BCInfo_D69, 0);
lrd_fetch(Csr2, -5, 1, 0, PrintRow26, 0);
GRID(26);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lr_end_transaction("exe",LR_AUTO);
return 0;
}
vuser_end()
{
lr_think_time(4);
lr_start_transaction("logout");
//lr_think_time(13);
lrd_cancel(0, Csr2, 0 /*Unused*/, 0);
lrd_result_set(Csr2, 0, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_stmt(Csr2, "select @@trancount", -1, 1, 0 /*None*/, 0);
lrd_fetch(Csr2, 1, 1, 0, PrintRow28, 0);
GRID(28);
//lr_think_time(7);
lr_end_transaction("logout", LR_AUTO);
lrd_result_set(Csr2, 0, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_CLOSE, 0, 0);
lrd_db_option(Csr2, OT_ODBC_CURSOR_UNBOUNDCOLS, 0, 0);
lrd_close_cursor(&Csr2, 0);
lrd_close_connection(&Con2, 0, 0);
lrd_free_connection(&Con2, 0 /*Unused*/, 0);
lrd_close_context(&Ctx2, 0, 0);
lrd_close_connection(&Con3, 0, 0);
lrd_free_connection(&Con3, 0 /*Unused*/, 0);
lrd_close_context(&Ctx3, 0, 0);
return 0;
}
作者:
picture
时间:
2006-12-29 14:04
刚好我也在研究LR测试数据库,你这个脚本是连表的查询啊.那算是性能的还是功能上的!查询的结果LR怎么捕捉的啊 ,我也是新手,都不知道这么去测试数据库,一般来说是不是测试数据库功能上面的合理性啊,性能数据库是看配置的吧应该
作者:
foxmishy
时间:
2006-12-29 16:51
我也在研究LR,不知道是否可以直接测试WEB 方法就可以了呢?
作者:
you力
时间:
2007-5-6 15:35
标题:
楼主,请指点
PrintRow24 ?是什么意思?
GRID(26);这个表格出现的值,你能不能取出其中特定的一个值呢?就比如说,你把查询语句,变成count(*)类型的数值. 在GRID中会显示出这个count,那么这个count的值你用什么方法可以取出来,用于别的地方的对比呢?批点~~~~
作者:
筷子
时间:
2007-9-19 10:16
sdlkfj8
作者:
房雷
时间:
2010-10-26 10:14
定上来。。。
作者:
房雷
时间:
2010-10-26 10:14
还有谁知道啊。。
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2