zoukankan      html  css  js  c++  java
  • LR录制Flex+Web,登录功能之登录密码出错的处理

      在LR中录制好更改密码脚本,Controller中使用少量用户进行:单用户多迭代、多用户单迭代、多用户多迭代,运行正常,于是使用490Vuser+2iteration修改980个用户的密码,部分

    Vuser因为Connection timed out、download timeout原因出错,这个时候因为用户量大,不知道究竟哪一个用户更改了密码,而哪一个用户没有更改成功。

      至此,查找未更改密码的用户名,之前username参数化采用的Unique+Iteration,根据LR的参数分配规则及我的迭代次数是2,想着Controller中出错id为n,在VuGen的参数列表中对应

    的 id =( 2*n -1) 与 (2*n),其中一条出错id为5,对应VuGen参数列表找到用户名为qt009和qt010登录,发现密码更改成功,看来自己对Unique+Iteration的分配规则的理解不够深刻。

      找寻别的出路,思路如下:录制登录脚本,使用新密码登录,若出错,则是说明密码修改失败,经过一番百度和对LR帮助手册的学习,根据登录事务成功与否完成判断,参见L11帮助手册lr_get_transaction_duration()函数的例子。

    Action()   //此处仅显示重要代码部分
    {
    
            double trans_time = 0; 
    
    	int status = 0;
    
    	lr_start_transaction("login");
    
    	trans_time = lr_get_transaction_duration("login"); 
    	
           /*
              记录操作为“Login”的flex_amf_call的返回值,该函数0成功,1失败
           */
    	status = flex_amf_call(
                     "<operation>login</operation>"
    		"<parameters><string>{user}</string>
                    <string>800Best</string>);
    
    	if (0 == status) 
    	{
    		lr_output_message ("UserName:%s",lr_eval_string ("{user}"));
    		lr_end_transaction("login", LR_PASS); 
    	}	
    	else 
    	{
    		lr_output_message ("UserName:%s",lr_eval_string ("{user}"));
    		lr_end_transaction("login", LR_FAIL);
    	}
    		 	
    	if (trans_time) 
    	{
    		lr_output_message("The duration up to the submit is %f seconds", trans_time); 
    	}
    	else 
    	{
    		lr_output_message("The duration cannot be determined."); 
    	}
    
    	//lr_end_transaction("login", LR_AUTO);
    
    return 0;
    }
    

      使用上述代码,同时在Vuser——>Run-Time Setting ——>Miscellaneous——>Error Handling中勾选“ Continue on error”,即可。

      在Controller中500Vuser+2iteration,打开状态为Failed的Vuser,Show Vuser log,即可知道是哪一个用户密码未修改成功,这里的场景可能还会遇到各种问题,但是分析一下可以知道和脚本无关,大概和服务器负载有关,可能一次不能找到所有的用户,多跑几次场景试试。

      遇到的问题。

    1: Action.c (16): illegal statement termination

      Action.c (16): skipping `double'

      解决:将 trans_time 与status放在脚本的最开始,因为LR的C解释器有点奇葩,变量的定义必须在系统函数调用之前,否则出错。

    2: Error: Failed to end Transaction "login" (by name). Please check that you made a call to start transaction operation.

      解决:产生该错误的原因是,事务没有成对匹配,检查发现当事务判断成功时有一条lr_end_transaction("login", LR_PASS);在action.c的末尾仍有一条lr_end_transaction("login", LR_AUTO); 总结:在有 分支 的代码中,一定要注意同一事务的start与end是否仅成对出现,要么干脆在分支语句中不使用事务的结束语句,要么每一个分支都加上结束语句,不要出现分支中有结束语句,分支外部还有结束语句的情况。

      PS:道阻且长,希望自己在性能这条路上越走越远。

  • 相关阅读:
    返回一个整数数组中最大子数组的和
    对autocad的建议
    作业:30道四则运算——C++编程
    四则运算2
    [leetcode] Letter Combinations of a Phone Number
    [leetcode] Pow(x, n)
    [leetcode] Longest Common Prefix
    [leetcode] Binary Tree Zigzag Level Order Traversal
    [leetcode] Construct Binary Tree from Preorder and Inorder Traversal
    [leetcode] Construct Binary Tree from Inorder and Postorder Traversal
  • 原文地址:https://www.cnblogs.com/xpp142857/p/5775796.html
Copyright © 2011-2022 走看看