目标:用50个并发用户创建3000个账号到HP Web Server

分析:

1. Vugen录制脚本时,打开首页http://127.0.0.1:1080/WebTours/,进入注册账号界面不用重复打开,放入vsuer_init.

2. 创建账号页面需要重复操作,放入Action.

3. 登出账号放入vuser_end.

4. 50个并发用户我们需要在Controller里边设置Vuser为50,总共创建3000个账号那每个Vuser用户数据分配60个。

    每个Vuser迭代次数为60.

 

接下来实际操作步骤:

1. 创建一个Web(HTTP/HTML)脚本.

2. 脚本代码如下:

vuser_init()
{

    web_url("WebTours", 
        "URL=http://127.0.0.1:1080/WebTours/", 
        "Resource=0", 
        "RecContentType=text/html", 
        "Referer=", 
        "Snapshot=t3.inf", 
        "Mode=HTML", 
        LAST);

    web_link("sign up now", 
        "Text=sign up now", 
        "Snapshot=t4.inf", 
        LAST);

    return 0;
}

 

Action()
{

    lr_think_time(14);

    web_submit_data("login.pl", 
        "Action=http://127.0.0.1:1080/WebTours/login.pl", 
        "Method=POST", 
        "RecContentType=text/html", 
        "Referer=http://127.0.0.1:1080/WebTours/login.pl?username=&password=&getInfo=true", 
        "Snapshot=t5.inf", 
        "Mode=HTML", 
        ITEMDATA, 
        "Name=username", "Value=lll{username}", ENDITEM, 
        "Name=password", "Value=1234", ENDITEM, 
        "Name=passwordConfirm", "Value=1234", ENDITEM, 
        "Name=firstName", "Value=", ENDITEM, 
        "Name=lastName", "Value=", ENDITEM, 
        "Name=address1", "Value=", ENDITEM, 
        "Name=address2", "Value=", ENDITEM, 
        "Name=register.x", "Value=73", ENDITEM, 
        "Name=register.y", "Value=10", ENDITEM, 
        LAST);

    web_image("button_next.gif", 
        "Src=/WebTours/images/button_next.gif", 
        "Snapshot=t6.inf", 
        LAST);

    return 0;
}
vuser_end()
{

    lr_think_time(7);

    web_url("welcome.pl", 
        "URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1", 
        "Resource=0", 
        "RecContentType=text/html", 
        "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home", 
        "Snapshot=t7.inf", 
        "Mode=HTML", 
        LAST);

    return 0;
}

 

 3. 参数username设置成unique number类型,每个Vuser分配60个,编号格式为%04d,

创建账号名称为lll0001~lll3000,如下图:

4. Run-time setting中,Iteration Count设置成60,50个Vuser,每个Vuser迭代60次,总共创建3000个账号。

think time设置为限制在5s:

 

 在Miscellaneous中把Define each action as a transaction勾选上

 

5. 打开Controller,把刚才创建的脚本加入到场景中。

6. 场景计划设置如下图,50个Vuser同时初始化同时启动,迭代次数跑完前一直运行。

 

7. 运行场景,在Scenaario Status里边查看事务运行状态。

 

打开Web Server创建账号目录底下查看账号是否创建成功。

C:Program Files (x86)HPLoadRunnerWebToursMercuryWebToursusers

 

内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!