一个测试的过程及错误信息?
把环境描述一下:数据库是oracle9i,用c#编程,开发了一个类似msn的消息小程序(是一个主系统的辅助系统)及一个sever(负责验证用户的身份,转发消息)。
启动sever,登陆消息程序,通过sever验证身份,登录之后,给在线的用户发送消息。
登陆用户与登陆主系统的用户是相同的。
现在对sever进行并发用户测试。 通过oracle 2-Tier录制,录制脚本如下:
vuser_init()
{
lrd_init(&InitInfo, DBTypeVersion);
lrd_initialize_db(LRD_DBTYPE_ORACLE, 1, 0);
lrd_env_init(LRD_DBTYPE_ORACLE, &OraEnv1, 0, 0);
lrd_ora8_handle_alloc(OraEnv1, SVCCTX, &OraSvc1, 0);
lrd_ora8_handle_alloc(OraEnv1, SERVER, &OraSrv1, 0);
lrd_ora8_handle_alloc(OraEnv1, SESSION, &OraSes1, 0);
lrd_server_attach(OraSrv1, "?", -1, 0, 0);
lrd_ora8_attr_set(OraSrv1, EXTERNAL_NAME, "", -1, 0);
lrd_ora8_attr_set(OraSrv1, INTERNAL_NAME, "", -1, 0);
lrd_ora8_attr_set_from_handle(OraSvc1, SERVER, OraSrv1, 0, 0);
lrd_ora8_attr_set(OraSes1, USERNAME, "?", -1, 0);
lrd_ora8_attr_set(OraSes1, PASSWORD, lr_decrypt("4338a045ba765169cd01a1"), -1, 0);
lrd_session_begin(OraSvc1, OraSes1, 1, 0, 0);
lrd_ora8_attr_set_from_handle(OraSvc1, SESSION, OraSes1, 0, 0);
lrd_ora8_handle_alloc(OraEnv1, STMT, &OraStm1, 0);
lrd_ora8_stmt(OraStm1, "ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS' "
"NLS_NUMERIC_CHARACTERS = '.,' NLS_CALENDAR = 'GREGORIAN' ", 1, 0, 0);
lrd_ora8_exec(OraSvc1, OraStm1, 1, 0, &uliRowsProcessed, 0, 0, 0, 0,
0);
lrd_handle_free(&OraStm1, 0);
lrd_ora8_handle_alloc(OraEnv1, STMT, &OraStm2, 0);
lrd_ora8_attr_set(OraStm2, PREFETCH_ROWS, "10", -1, 0);
lrd_ora8_stmt(OraStm2, "SELECT PARAMETER, VALUE FROM SYS.NLS_DATABASE_PARAMETERS WHERE "
"PARAMETER IN ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET')", 1, 0, 0);
lrd_ora8_exec(OraSvc1, OraStm2, 0, 0, &uliRowsProcessed, 0, 0, 0, 0,
0);
lrd_ora8_bind_col(OraStm2, &OraDef1, 1, &PARAMETER_D1, 0, 0);
lrd_ora8_attr_set(OraDef1, CHARSET_ID, "1", -1, 0);
lrd_ora8_bind_col(OraStm2, &OraDef2, 2, &VALUE_D2, 0, 0);
lrd_ora8_attr_set(OraDef2, CHARSET_ID, "1", -1, 0);
lrd_ora8_fetch(OraStm2, 2, 1, &uliFetchedRows, PrintRow2, 2, 0, 0);
GRID8(2);
lrd_handle_free(&OraStm2, 0);
lrd_ora8_handle_alloc(OraEnv1, STMT, &OraStm3, 0);
lrd_handle_free(&OraStm3, 0);
lrd_ora8_handle_alloc(OraEnv1, STMT, &OraStm4, 0);
lrd_ora8_stmt(OraStm4, "SELECT code,sender,receiver,sendtime,nvl(content,' ') FROM messages "
"WHERE receiver='?' AND receivetime ISNULLORDER BY "
"sendtime DESC", 1, 0, 0);
lrd_ora8_handle_alloc(OraEnv1, STMT, &OraStm5, 0);
lrd_ora8_stmt(OraStm5, "SELECT code,sender,receiver,sendtime,nvl(content,' ') FROM messages "
"WHERE receiver='?' AND receivetime ISNULLORDER BY "
"sendtime DESC", 1, 0, 0);
lrd_ora8_stmt(OraStm5, "SELECT code , sender , receiver , sendtime , nvl(content,' ')FROM "
"messages WHEREreceiver='?' AND receivetime ISNULL"
"ORDER BY sendtime DESC ", 1, 0, 0);
lrd_ora8_attr_set(OraStm5, PREFETCH_ROWS, "100", -1, 0);
lrd_ora8_exec(OraSvc1, OraStm5, 0, 0, &uliRowsProcessed, 0, 0, 0, 0,
0);
lrd_ora8_bind_col(OraStm5, &OraDef3, 1, &CODE_D3, 0, 0);
lrd_ora8_bind_col(OraStm5, &OraDef4, 2, &SENDER_D4, 0, 0);
lrd_ora8_bind_col(OraStm5, &OraDef5, 3, &RECEIVER_D5, 0, 0);
lrd_ora8_bind_col(OraStm5, &OraDef6, 4, &SENDTIME_D6, 0, 0);
lrd_ora8_bind_col(OraStm5, &OraDef7, 5, &NVL_CONTENT_D7, 0, 0);
lrd_ora8_fetch(OraStm5, -0, 100, &uliFetchedRows, 0, 2, 0, 0);
lrd_ora8_attr_set(OraStm5, PREFETCH_ROWS, "0", -1, 0);
lrd_handle_free(&OraStm5, 0);
lrd_handle_free(&OraStm4, 0);
lrd_session_end(OraSvc1, OraSes1, 0, 0);
lrd_server_detach(OraSrv1, 0, 0);
lrd_handle_free(&OraSvc1, 0);
lrd_handle_free(&OraSrv1, 0);
lrd_handle_free(&OraSes1, 0);
lrd_handle_free(&OraEnv1, 0);
return 0;
100个vuser的运行状态都是pass,觉得这段脚本与sever没有关系,也就是说,没有测试到sever。 通过windows socket 也可以录制,但是在运行的时候出错了,脚本如下:
#include "lrs.h"
vuser_init()
{
lrs_startup(257);
lrs_create_socket("socket0", "TCP", "RemoteHost=ptt-mmm:6000",LrsLastArg);
lrs_send("socket0", "buf0", LrsLastArg);
lrs_receive("socket0", "buf1", LrsLastArg);
lrs_create_socket("socket1", "TCP", "RemoteHost=DATABASE:1521",LrsLastArg);
lrs_send("socket1", "buf2", LrsLastArg);
lrs_receive("socket1", "buf3", LrsLastArg);
lrs_close_socket("socket1");
lrs_create_socket("socket2", "TCP", "RemoteHost=DATABASE:10317",LrsLastArg);
lrs_send("socket2", "buf4", LrsLastArg);
lrs_receive("socket2", "buf5", LrsLastArg);
lrs_send("socket2", "buf6", LrsLastArg);
lrs_receive("socket2", "buf7", LrsLastArg);
lrs_send("socket2", "buf8", LrsLastArg);
lrs_receive("socket2", "buf9", LrsLastArg);
lrs_send("socket2", "buf10", LrsLastArg);
lrs_receive("socket2", "buf11", LrsLastArg);
lrs_send("socket2", "buf12", LrsLastArg);
lrs_receive("socket2", "buf13", LrsLastArg);
lrs_send("socket2", "buf14", LrsLastArg);
lrs_receive("socket2", "buf15", LrsLastArg);
lrs_send("socket2", "buf16", LrsLastArg);
lrs_receive("socket2", "buf17", LrsLastArg);
lrs_send("socket2", "buf18", LrsLastArg);
lrs_receive("socket2", "buf19", LrsLastArg);
lrs_send("socket2", "buf20", LrsLastArg);
lrs_receive("socket2", "buf21", LrsLastArg);
lrs_send("socket2", "buf22", LrsLastArg);
lrs_receive("socket2", "buf23", LrsLastArg);
lrs_send("socket2", "buf24", LrsLastArg);
lrs_receive("socket2", "buf25", LrsLastArg);
lrs_send("socket2", "buf26", LrsLastArg);
lrs_receive("socket2", "buf27", LrsLastArg);
lrs_receive("socket0", "buf28", LrsLastArg);
lrs_send("socket0", "buf29", LrsLastArg);
lrs_close_socket("socket0");
lrs_send("socket2", "buf30", LrsLastArg);
lrs_receive("socket2", "buf31", LrsLastArg);
lrs_send("socket2", "buf32", LrsLastArg);
lrs_close_socket("socket2");
return 0;
}
出错信息如下:
Virtual User Script started
Starting action vuser_init.
vuser_init.c(12): lrs_startup(257)
vuser_init.c(14): lrs_create_socket(socket0, TCP, ...)
vuser_init.c(16): lrs_send(socket0, buf0)
vuser_init.c(18): lrs_receive(socket0, buf1)
vuser_init.c(20): lrs_create_socket(socket1, TCP, ...)
vuser_init.c(22): lrs_send(socket1, buf2)
vuser_init.c(24): lrs_receive(socket1, buf3)
vuser_init.c(26): lrs_close_socket(socket1)
vuser_init.c(28): lrs_create_socket(socket2, TCP, ...)
vuser_init.c(28): Error : callConnect - Connection refused. Error code : 10061.
vuser_init.c(28): Error : Timeout expired while trying to connect. Error code : 9017. 请大家对以上的过程提出意见,该选用哪种协议录制? 使用lrs_set_connect_timeout,增加timeout的时间,但还是出错。是什么导致的失败呢?
问题解决了
把经验跟大家分享一下.lrs_create_socket("socket2", "TCP", "RemoteHost=DATABASE:10317",LrsLastArg);中的端口号是动态的,需要进行关联.
使用lrs_save_param_ex(),将端口号用参数替换.问题就解决了
另外,还有一点经验.
大家在遇到问题的时候先不要急于发帖,可以先在论坛中搜索一下.查看相关的帖子,可以找到解决问题的方法. 哈哈,不错!
请教
楼上的你好,我在工作中可能也会遇到关联的问题,我想请教下你用那个函数是怎么进行关联的,多谢!我的qq号是89250010,或者你也可以把你的号留下来,我加你 多谢 教本回放过不去,大多数是主键和关联的原因。呵呵 顶楼主,呵呵,问题就是这样处理,先搜索。 不懂
页:
[1]