已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
通过web_set_user解决Windows登录验证问题。 The web_set_user function is a Service function that specifies a login string and password for a Web server or proxy server. It can be called more than once if several proxy servers require authentication. web_set_user overrides the run-time proxy authentication settings for user name and password. When you log onto a server that requires user and password validation, VuGen records a web_set_user statement containing the login details. However, there are some more stringent, authentication methods for which VuGen is unable to insert web_set_user statements. See User Authentication for more detail. In such cases, you can add web_set_user into your script manually. When you run the script, LoadRunner automatically submits the user authorization along with every subsequent request to that server. At the end of the script, LoadRunner resets the authorization. 例子:web_set_user(mercury, mercury, mansfield:80); 如果要进行域验证的话,需要在用户名前面加上域名,如web_set_user(domainmercury, mercury, mansfield:80);关于时间、日期格式的设置 Datetime Format Codes %a day of week, using locales abbreviated weekday names %A day of week, using locales full weekday names %b month, using locales abbreviated month names %B month, using locales full month names %c date and time as %x %X %d day of month (01-31) %H hour (00-23) %I hour (00-12) %j number of day in year (001-366) %m month number (01-12) %M minute (00-59) %p locales equivalent of AM or PM, whichever is appropriate %S seconds (00-59) %U week number of year (01-52), Sunday is the first day of the week. Week number 01 is the first week with four or more January days in it. %w day of week; Sunday is day 0 %W week number of year (01-52), Monday is the first day of the week. Week number 01 is the first week with four or more January days in it. %x date, using locales date format %X time, using locales time format %y year within century (00-99) %Y year, including century (for example, 1988) %Z time zone abbreviation % to include the % character in your output string 例子: lr_save_datetime(today is %Y-%B-%d, DATE_NOW , today); lr_output_message(lr_eval_string(today); 英文操作系统中的执行结果:today is 2007-April-06 中文操作系统中的执行结果:today is 2007-四月-06调用库函数,生成随机数 str=rand(); /生成任意随机数 str=rand()%200 /生成最大值为200的随机数 str=rand()%100+200 /生成200300之间的随机数ThinkTime设置 在录制完脚本进行运行时默认是忽略ThinkTime的,此时需要在RumTimeSettings中进行设置,才能使lr_think_time正常工作。参数化事务名称 当脚本需要在多种场景下运行时,可以通过参数化事务名称来区分事务时间。下面的脚本将vusergroup作为事务名称: int id, scid; char* vuser_group; char str=; lr_whoami(&id, &vuser_group, &scid); lr_message( Group: %s, vuser id: %d, scenario id %d, vuser_group, id, scid); strcat(str,vuser_group); lr_start_transaction(str); . lr_end_transaction(str,LR_AUTO);lr_continue_on_error 在脚本中的RTS中的“continue on error”用于脚本级别的设置,而通过本函数可以灵活的在脚本中控制错误处理,当出现错误时是否终止脚本运行,默认是出错时停止的。 其中的错误级别: 0:Terminate script execution upon database access errors.(default) 1:Continue script execution upon database access errors, but issue a warning. 脚本示例: lr_continue_on_error(0); lrd_stmt(Csr1, select.); lrd_exec(.); lr_continue_on_error(1);lr_get_attrib_string:获取命令行中的参数 vuser_init() /* LPCSTR is a char * . */ LPCSTR server; LPCSTR user = Tom; LPCSTR password = pwd; LPCSTR connect10; server=lr_get_attrib_string(host); if (server=NULL) lr_error_message(Failed to login. Unknown host.n); return(0); /*Prepare a string with login information */ sprintf(connect,%s, %s, %s, user, password, server); lr_message(%s, connect); return 0; 在脚本目录的outoutput.txt中打印内容如下: tomh, pwd, sun2 MsgId: MMSG-17999 运行的命令: mdrv.exe -usr D:Program FilesMIMercury LoadRunnerscriptstestTestScriptTestScript.usr -out D:Program FilesMIMercury LoadRunnerscriptstestTestScriptout -host sun2 -loop 4 -time 1.5lr_eval_string 将所有出现的参数替换为其当前值。 lr_save_string 将以 NULL 结尾的字符串保存到参数中。 lr_save_var 将可变长度字符串保存到参数中。 使用lr_save_string要将以 NULL 结尾的字符串保存到参数中,请使用 lr_save_string。要保存可变长度的字符串,请使用 lr_save_var 并指定要保存的字符串的长度。关于Rumtime Settings的默认设置 对于 LoadRunner,默认的运行时设置支持 VuGen 的调试环境和Controller 的负载测试环境。默认设置为: 思考时间:在 VuGen 中为“关闭”,而在 Controller 中为“按录制参数回放”。 日志:在 VuGen 中为“标准”,而在 Controller 中为“关闭”。 下载非 HTML 资源:在 VuGen 和 Controller 中均为“已启用”。持续时间与迭代次数 对于 LoadRunner Controller 和优化模块:如果在计划设置中指定了场景或会话步骤持续时间,则持续时间设置将覆盖 Vuser迭代设置。这意味着,如果持续时间被设置为 5 分钟(默认设置), Vuser 将在 5 分钟内根据需要连续运行任意多次迭代,即使运行时设置仅指定一次迭代。Runtime Settings中的日志设置 Enable Logging启用日志记录 该选项将在回放期间启用自动日志记录 - VuGen 将写入日志消息,您可以在执行日志中查看这些消息。该选项仅影响自动日志记录和通过 lr_log_message 出的日志消息。仍会发出使用 lr_message、lr_output_message 和lr_error_message 手动发送的消息。 如果在“常规运行时设置”文件夹中将“错误处理”设置为“出现错误时仍继续”,则错误消息仍将被发送到“输出”窗口。如果修改了脚本的“日志详细级别”, lr_message、lr_output_message 和lr_log_message 函数的行为将不会更改 这些函数将继续发送消息。 脚本示例: Action() lr_log_message(lr_log_message); lr_message(lr_message); lr_output_message(lr_output_message); /lr_error_message(Unable to login to secure computing); return 0; 不激活Enable Logging时的运行结果: lr_message Action.c(8): lr_output_message Vuser Terminated. 如果激活Enable Logging并且设置send message only when error occur,则正常日志没有打印。 Just In Time Log mode. Log messages will be sent only when an error occurs. To change this behavior, look at the Log tab in Run Time Settings. 如果把lr_error_message语句前的注释去掉,则会将所有日志打印出来 Start auto log messages stack - Iteration 1. Starting action Action. lr_log_message lr_message Action.c(8): lr_output_message Action.c(9): Error: Unable to login to secure computing End auto log messages stack.脚本中灵活设置日志打印级别 在脚本的Runtime Settings中的日志设置是针对整个脚本而言,可以通过lr_set_debug_message在脚本中进行灵活设置。 VuGen 日志事件(标准、参数替换等)的等级也称为消息类。有五个消息类:“简要”、“扩展”、“参数”、“结果数据”和“完全跟踪”。 可以使用 lr_set_debug_message 函数手动设置脚本内的消息类。如果您希望仅接收关于脚本的一小部分的调试信息,该设置非常有用。 例如,假设将日志运行时设置设为“标准日志”,并且需要获得脚本的特定部分的扩展日志。您可以使用 lr_set_debug_message函数在脚本中的所需位置设置扩展消息类。必须再次调用该函数以指定扩展模式的类型(“参数”、“结果数据”或“完全跟踪”)。通过调用 lr_set_debug_message 并指定“简要”模式,可返回到“标准日志”模式。 In this example, the lr_set_debug_message function enables the full trace option just before a call to lrd_fetch, which the user needs to debug because it has been giving unexpected results. The second invocation of lr_set_debug_message resets the debug level to what it was formerly, by turning off (LR_SWITCH_OFF) the Extended message level. Note that the two values for message level, LR_MSG_CLASS_EXTENDED_LOG and LR_MSG_CLASS_FULL_TRACE, have been logically ORed together. lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG | LR_MSG_CLASS_FULL_TRACE, LR_SWITCH_ON ); rc = lrd_fetch(Csr1, 1, 1, 0, PrintRow3); if (rc2000) lr_debug_message(LR_MSG_CLASS_FULL_TRACE, Fetch failed returned %d, rc); /* Now reset message class to former level */ lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG | LR_MSG_CLASS_FULL_TRACE, LR_SWITCH_OFF ); 关于多线程的运行方式 Vuser 支持多线程环境。多线程环境的主要优势是每个负载生成器都能运行多个Vuser。只有线程安全协议才能按线程运行。(不适用于应用程序管理工具) Controller 和优化控制台使用驱动程序(例如 mdrv.exe 或 r3vuser.exe)来运行Vuser。如果按进程运行每个 Vuser,则对于每个 Vuser 实例,都将反复启动(和加载)同一驱动程序并将其加载到内存中。将同一驱动程序加载到内存中会占用大量 RAM (随机访问内存)及其他系统资源。这就限制了可以在任一负载生成器上运行的 Vuser 数。或者,如果按线程运行每个 Vuser,Controller 为每 50 个 Vuser(默认
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 河南信阳市潢川县招才引智招聘2025届高校毕业生100名易考易错模拟试题(共500题)试卷后附参考答案
- 杂志服装合作协议书
- 供电所供电合同范本
- 服装租赁赔偿协议书
- 松原市市直和宁江区共5个主管部门所属16家事业单位共招考工作人易考易错模拟试题(共500题)试卷后附参考答案
- 村史管装修合同范本
- 惠州市惠阳区国土资源分局属下事业单位2025年下半年招考易考易错模拟试题(共500题)试卷后附参考答案
- lg电池供应协议书
- 广州市海珠区规划服务中心招考工作人员易考易错模拟试题(共500题)试卷后附参考答案
- 冷柜技术协议书范本
- 2025城发环保能源(汝南)有限公司招聘4人笔试历年备考题库附带答案详解试卷3套
- 河北省沧衡名校联盟2025-2026学年高三上学期11月期中考试语文试题(含答案)
- 2025山东德德州天衢建设发展集团有限公司招聘工作人员20人笔试考试参考试题及答案解析
- 2025年酉阳土家族苗族自治县辅警招聘考试真题附答案详解(满分必刷)
- 世界艾滋病日健康讲座
- 2025-2026学年河南省天一大联考高一上学期9月月考历史试题
- 省级总代理合同协议范本2024
- 物业公司服务标准手册
- 标准离婚协议书文档模板
- 国开2025年《行政领导学》形考作业1-4答案
- (完整)污水清运合同
评论
0/150
提交评论