在controller中设置scheduling setting的duration与vugen中设置iterations关系

上一篇 / 下一篇  2009-01-08 10:05:24

转载:http://bbs.51testing.com/viewthread.php?tid=553&page=1#pid357158

关于设置场景


脚本设置情况如下:
单纯的打开一个页面就停止了录制(此处没有录制关闭该页面的过程)。Run_Time设置为3。

场景设置情况如下:
设置100个虚拟用户,要求每隔1分钟加载20个用户,设置当加载完所有用户后场景继续运行的时间为10分钟。

问题:
1。第1分钟成功加载20个用户,在第2分钟,这20个用户是继续不断执行上述打开页面的脚本还是仅仅只是保持在线状态?

2。第5分钟结束,成功加载了100个用户,然后场景继续运行10分钟,在这10分钟中这100个用户是保持在线状态还是不断的执行上述录制的打开页面的脚本?

3。安装版主在“在loadrunner中录制脚本时碰到的问题"这个帖子中的解释“如果在controller中设置scheduling setting的duration设置1小时,即使你vugen中设置iterations为3,她也会运行到指定时间。次数也许不只3次,会更多。”那 是否表示当用户成功加载后仍然在继续不断的执行上述录制的打开页面的脚本?如果这样的话,对我打算测试web服务器而言肯定已经不止是100个用户了, 那我们还设置虚拟用户为100又有什么意义呢?

没有回答问题之前,我把上次的脚本进行如下修改!做几个试验:
VuGen建立的第一个脚本 TestFirst的action脚本如下
char *filename = "c:\\test.txt";
Action() {

     long file;
     int id;
     char *groupname;

     /* Create a new file */
     if ((file = fopen(filename, "a" )) == NULL) {
          lr_output_message("Unable to create %s", filename);
          return -1;
     }
     
     /* Write the Vuser id and group to the log file */
     id = 1;
         groupname = "one";

     fprintf(file, "logfile of virtual user id: %d group: %s\n", id, groupname);
     fclose(file);

     return 0;
}
vu_End脚本如下
char *filepath = "c:\\test.txt";
vuser_end()
{
         long file;
     int id;
     /* Create a new file */
     if ((file = fopen(filepath, "a" )) == NULL) {
          lr_output_message("Unable to create %s", filename);
          return -1;
     }
     
     id = 1;

     fprintf(file, "%d End  ", id);
     fclose(file);
         return 0;
}

VuGen建立的第二个脚本TestSecond的Action脚本如下

char *filename = "c:\\test.txt";
Action() {

     long file;
     int id;
     char *groupname;

     /* Create a new file */
     if ((file = fopen(filename, "a" )) == NULL) {
          lr_output_message("Unable to create %s", filename);
          return -1;
     }
     
     /* Write the Vuser id and group to the log file */
     id = 2;
         groupname = "two";

     fprintf(file, "logfile of virtual user id: %d group: %s\n", id, groupname);
     fclose(file);

     return 0;
}
vu_End脚本如下:
#include "as_web.h"
char *filepath = "c:\\test.txt";
vuser_end()
{
         long file;
     int id;
     /* Create a new file */
     if ((file = fopen(filepath, "a" )) == NULL) {
          lr_output_message("Unable to create %s", filename);
          return -1;
     }
     
     id = 2;
     fprintf(file, "%d End  ", id);
     fclose(file);
         return 0;
}

上边的脚本其实很相类似只不过每个脚本中用one,two来标示每个用户(为了看到测试效果),我们这样做只是为了检测Controller如何调用脚本。
还有一点我在vu_end()加入代码,这是因为我们知道vuGen设置iteration的数值,实质是设置action的运行次数,也就是说只有运行action的iteration后才会运行vu_end。

一.设置iteration为1,在Controller中添加运行testfirst,testSecond脚本用户各一,运行结果如下:
logfile of virtual user id: 1 group: one
1 End  
logfile of virtual user id: 2 group: two
2 End
二.设置iteration为2,在Controller中添加运行testfirst,testSecond脚本用户各一,运行结果如下:
logfile of virtual user id: 2 group: two
logfile of virtual user id: 2 group: two
2 End  
logfile of virtual user id: 1 group: one
logfile of virtual user id: 1 group: one
1 End  

三.设置iteration为2,在Controller中添加运行testfirst,testSecond脚本用户各一,每隔1分钟加载1个用户,运行结果如下:
logfile of virtual user id: 1 group: one
logfile of virtual user id: 1 group: one
1 End  
logfile of virtual user id: 2 group: two
logfile of virtual user id: 2 group: two
2 End  

四.设置iteration为2,在Controller中添加运行testfirst,testSecond脚本用户各2,每隔1分
钟加载1个用户,运行结果如下:
logfile of virtual user id: 1 group: one
logfile of virtual user id: 1 group: one
1 End  
logfile of virtual user id: 2 group: two
logfile of virtual user id: 2 group: two
2 End
logfile of virtual user id: 1 group: one
logfile of virtual user id: 1 group: one
1 End
logfile of virtual user id: 2 group: two
logfile of virtual user id: 2 group: two
2 End  
五.设置iteration为2,在Controller中添加运行testfirst,testSecond脚本用户各2,设置每隔10秒加载1个用户并设置duration为40秒,运行结果如下:
logfile of virtual user id: 1 group: one
logfile of virtual user id: 1 group: one
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’省略
logfile of virtual user id: 1 group: one
2 End  
logfile of virtual user id: 2 group: two
logfile of virtual user id: 1 group: one
1 End  
logfile of virtual user id: 2 group: two
2 End  
logfile of virtual user id: 1 group: one
1 End  


以上对loadrunner的研究说明用户对应脚本,而不管他当前运行到什么状态。在第四中设置中很容易清晰的看出运行次序,可以说是从头运行到尾。(这么做只是为了研究,实际操作中情况千变万化,我只是为了测试结果清晰化)
你的三个问题从上边的试验可以得出结论,脚本影响实际程序的状态通过action脚本中运行的状态(如果你没有录制关闭页面脚本那么当前状态仍然是打开状态)。其实你设置的情况比较复杂了,我把几种不同的设置,所得出的运行结果都列举出来了。你可以自行研究。

你第一个问题 状态仍然是打开状态
你第二个问题 你的设置情况与我第五种试验设置一致,结论是仍然打开页面
你第三个问题 虚拟用户是针对loadrunner来说的,虚拟用户试和运行的机器有关系,你设置虚拟用户是为了把虚拟用户分布到不同的机器上,模拟现实世界,实际登陆 用户是对你的测试软件来说的, 这是有区别的,要弄清楚概念。工具只是实现你测试目的的辅助手段,你所开发的脚本都是根据你的测试用例,在这个案例中你这么做有没有意义取决你选择的压力 测试策略。如果现实中有这么做的,你就可以模拟!

我想这些测试试验可以帮助你了解iteration和虚拟用户设置对脚本调用的作用!


TAG:

 

评分:0

我来说两句

Open Toolbar