测试要求:
 
在本次测试中,我需要并发50个User,每一个User占用一个独立的IP,并且只执行一次脚本。脚本中发起两个请求,其中第一次请求返回200后才执行第二个请求。使用win7 OS。
 
前置及Generator设置:
我的Run-time Settings这样设定:
Run Logic: Number of Iterations: 1 (保证只执行一次脚本)
Log: Enable Log. Always send messages.(不是只在出错时发送log。我需要通过log来验证我的测试要求是否达到)
Think Time: Ignore think time (我不要思考时间,我想第二个请求紧跟第一个请求后执行)
其他不变。
 
为了在同一台机器上跑50个IP,我使用IP Spoofing
在开始菜单,找到Loadruner所在文件夹,进去找到Tools,里面有一个IP Wizard(IP欺骗)
在创建新的IP之前,可以CMD查看ipconfig, 查看自己所在IP区间。使用IP欺骗时,需要使用空闲IP,为确保不影响公司网络,建议使用一个路由器搭建独立的IP区间。
我使用的IP区间为:
LAN Subnet : 192.168.32.0 / 23 (空闲IP区段:192.168.32.4 ~ 192.168.33.254)
Gateway : 192.168.32.1
到增加IP地址对话框时,注意配置是否正确。我的配置如下图。
 
 
完成之后可以将刚才的IP地址保存为“IP Address File(*.ips)”文件。(这一操作我没有做,还好Loadrunner已经非常智能,在Load Generators只增加localhost就可以搞定)
好了,在CMD查看ipconfig /all 是不是多了50个IP。
 
注意,IP Wizard不支持DHCP,需要本机配置为固定IP地址。
 
接下来写脚本。
我的脚本如下:
 
 Action()
{ int status;
int HttpRetCode;
char *ip;
ip = lr_get_vuser_ip();
//检查Loadrunner Controller有没有Enable IP Spoofing
if(ip)
lr_output_message("The IP address is %s", ip);
else
lr_output_message("IP spoofing disabled");
//设置集合点,让50个vuser一起发起第一个请求
lr_rendezvous("letusgo");
//开始第一个事务(请求)
lr_start_transaction("1stReq"); web_url("RCS_Initial_HTTP_Req",
//这里有一个参数化,我要每一次传递给该参数一个唯一的msisdn号码,并且只执行一次。
//我在参数属性对话框里设置:Select next row -> Unique
// Update value on -> Once
"URL= http://xxx.yyy.com/self?x-forwarding-msisdn={NewParam}",
"TargetFrame=Main",
"Resource=0",
"RecContentType=text/html",
"Mode=http",
LAST );
//打印第一个请求的返回码
HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
lr_output_message("Response code:%d",HttpRetCode);
//检查返回码是否是200
if(HttpRetCode == ){
lr_end_transaction("1stReq", LR_PASS);
sleep();
//开始第二个事务(请求)
lr_start_transaction("2ndReq");
web_url("RCS_Initial_HTTP_Req",
"URL= https://xxx.yyy.com/self?vers=1&IMSI=1&rcs_version=1&rcs_profile=1&client_vendor=1&client_version=1&terminal_vendor=1&terminal_model=1&terminal_sw_version=1&IMEI=1&mock_scheme=HTTPS",
"TargetFrame=Main",
"Resource=0",
"RecContentType=text/html",
"Mode=http",
LAST );
//打印第二个请求的返回码
HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
lr_output_message("Response code:%d",HttpRetCode);
//检查返回码是否是200
//结束第二个事务(请求)
if(HttpRetCode == ){
lr_end_transaction("2ndReq", LR_PASS);
}else{
lr_end_transaction("2ndReq", LR_FAIL);
} return ; }else{
//结束第一个事务(请求)
lr_end_transaction("1stReq", LR_FAIL);
return ;
}
}
 

场景设置:

 
 
 
添加Load Generator
Name: localhost
Platform: windows
添加这一条就可以了。
然后将状态开启为Ready
 
 
 

一定要注意每一个Vuser的IP是否是唯一的。双击下图Scenario Groups里面的Group Name行可以打开每一个Vuser对应的Generator,查看其IP。

 

 
要监控一些服务器资源的资源如cpu,memory,disk,需要在controller里加入增加监控Unix Resources, 加入服务器地址。可以一次添加多个服务器。
 
前提:
需要关闭防火墙
需要在要监控的服务器上安装rstatd组件
 
[root@ ~]# service rstatd 
Usage: /etc/init.d/rstatd {start|stop|status|restart|reload|force-reload} 
[root@~]# service rstatd status 
rpc.rstatd (pid 2650) is running... 
[root@~]#
 
可能报的错:
lr UNIX Resources. Cannot initialize the monitoring -47190
无法连接该服务器,请找公司OPS部门解决。我在测试中需要连接公司VPN服务器,在没有连接之前就会报这个错。
 
开始Run之前,别忘了log保存位置放到指定位置。在Results下面设置。
 
 
关于Result :
 
Graphs 右键 Add new items -> Add New Graph增加想要的图表结果
Reports -> HTML Report.. 生成html报告
 
小心Scale陷阱 
要乘以前面的Scale值,才是真实结果。
 
结果分析参考:
UNIX counter Windows Counter Description
Average Load* N/A The sum of the number of processes waiting in the run queue plus the number currently executing.
Collision rate N/A The total number of network collisions/sec
Context switch rate System – Context Switches/sec The rate at which processors switch from executing one thread to another. High switch rates can indicate performance problems as servers juggle multiple running applications.
CPU utilisation %Processor Time The percentage of elapsed time that the process spends executing non-idle threads.
Disk traffic %Disk time The percentage of elapsed time that the disk(s) are  busy servicing read or write requests.
Incoming packets error rate Packets received errors The number of packets received containing errors that precvent them from being delivered to a higher OSI layer protocol.
Incoming packets rate Packets received/sec The number of packets received on the network interface
Interrupt rate Interrupts/sec Average rate at which the processor receives and services hardware interrupts. Processes generate an interrupt when they finish a task and need to report that fact to the CPU.
Outgoing packets error rate Packets outbound errors The number of packets that can’t be transmitted due to errors
Outgoing packets rate Packets sent / sec The rate at which packets are sent on the network interface
Page-in rate Pages Input/sec The rate at which pages are read from disk to resolve hard page faults. Hard page faults occur when a process refers to a page in virtual memory which is not in it’s working set or available elsewhere in physical memory and has to be read from disk.
Page-out rate Pages Output/sec The rate at which memory pages are written to disk to free up space in physical memory.
Paging rate Paging rate The rate at which pages are read from disk or written to disk.  This is the sum of Pages Input/sec and Pages Output/sec.
Swap-in rate N/A The number of pages read into memory per second
Swap-out rate N/A The number of pages written out of memory per second
System mode CPU utilization Processor – %Priviledged time The percentage of elapsed time that the processor spends executing user threads (i.e. running applications)
User mode CPU utilization Processor – %User time The percentage or elapsed time that the processor spends executing priviledged or system mode threads.

使用IP欺骗Loadrunner并发测试小结的更多相关文章

  1. jmeter使用IP欺骗进行压力测试

    loadrunner的IP欺骗功能很强大,耐心研究jmeter官方文档,发现在jmeter2.5以上的版本有此功能的实现~ 准备工作: 1.window7一台,安装jdk1.6环境.   2.下载最新 ...

  2. 转 LoadRunner 技巧之 IP欺骗 (推荐)

    IP欺骗也是也loadrunner自带的一个非常有用的功能. 需要使用ip欺骗的原因: 1.当某个IP的访问过于频繁,或者访问量过大是,服务器会拒绝访问请求,这时候通过IP欺骗可以增加访问频率和访问量 ...

  3. LoadRunner 技巧之 IP欺骗 (推荐)

    IP欺骗也是也loadrunner自带的一个非常有用的功能. 需要使用ip欺骗的原因:1.当某个IP的访问过于频繁,或者访问量过大是,服务器会拒绝访问请求,这时候通过IP欺骗可以增加访问频率和访问量, ...

  4. LoadRunner 技巧之 IP欺骗

    IP欺骗也是也loadrunner自带的一个非常有用的功能. 需要使用ip欺骗的原因:1.当某个IP的访问过于频繁,或者访问量过大是,服务器会拒绝访问请求,这时候通过IP欺骗可以增加访问频率和访问量, ...

  5. jmeter使用IP欺骗压力测试

    最近在使用jmeter进行压力测试时需要使用类似于loadrunner的IP欺骗功能,经问津度娘无果后决定再次耐心研究jmeter官方文 档,终于发现在jmeter2.5以上的版本有此功能的实现,由于 ...

  6. 转 jmeter使用IP欺骗压力测试

    jmeterIP 欺骗多IP 最近在使用jmeter进行压力测试时需要使用类似于loadrunner的IP欺骗功能,经问津度娘无果后决定再次耐心研究jmeter官方文 档,终于发现在jmeter2.5 ...

  7. 【Loadrunner】初学Loadrunner——IP欺骗

    因为在默认情况下,同一个用户用同一个IP访问运行是不符合实际情况的,而且很多网站会自动屏蔽同个IP多次重复访问.那么就想到了Loadrunner的虚拟IP技术,也就是常说的IP欺骗.在用Loadrun ...

  8. LoadRunner学习知多少--IP欺骗使用

    使用IP欺骗功能时,需要将系统防火墙,杀毒软件关闭(如果有影响的话) 一.为什么要设置IP欺骗 1. 当某个IP的访问过于频繁,或者访问量过大时,服务器会拒绝访问请求,这时候通过IP欺骗可以增加访问频 ...

  9. Loadrunner如何进行有效的IP欺骗

    柠檬班的清风同学某天紧急求助如何搞IP欺骗,端午节后,抽时间把这个事情搞定啦!跟大家详细的讲讲IP欺骗的运用和理解. 一.什么是IP欺骗 给你客户端的IP地址加个马甲,让服务器端识别不到是同一个IP地 ...

随机推荐

  1. [转]HttpClient的超时用法小记

    HttpClient的超时用法小记 HttpClient在使用中有两个超时时间,是一直接触和使用的,由于上次工作中使用httpClient造成了系统悲剧的情况,特地对它的两个超时时间进行了小小的测试, ...

  2. 李洪强iOS之Foundation框架—字符串

    Foundation框架—字符串 一.Foundation框架中一些常用的类 字符串型: NSString:不可变字符串 NSMutableString:可变字符串 集合型: 1) NSArray:O ...

  3. 大陆 Google play 开发者注册(2016)

    1:准备一个VPN, 如:  https://vpnso.com   收费的,使用一两年了,还不错,很稳定2:准备一张普通的银行卡或者信用卡就可以了,能正常绑定支付宝就行3:在全球付上面申请一个 虚拟 ...

  4. GridView 和ListView中自适应高度

    android中GridView  和ListView放在scrollView中时会默认的只有一行高这时就要我们自己计算出它的高度啦 首先是listview的 //动态设置listview的高度 pu ...

  5. Objective-c CoreData

    #import "AppDelegate.h" #import "Person.h" @implementation AppDelegate @synthesi ...

  6. JodaTime初体验

    前段时间用JDK自带的Calendar类来处理日期,需要获取年.季,月,星期的起始日期,被折腾得要死要活.看了这篇文章 http://www.blogbus.com/dreamhead-logs/22 ...

  7. hive学习笔记——表的基本的操作

    1.hive的数据加载方式 1.1.load data 这中方式一般用于初始化的时候 load data [local] inpath '...' [overwrite] into table t1 ...

  8. Java关键字static、final使用小结

    static  1. static变量     按照是否静态的对类成员变量进行分类可分两种:一种是被static修饰的变量,叫静态变量或类变量:另一种是没有被static修饰的变量,叫实例变量.两者的 ...

  9. bzoj4011

    好题,首先有一个结论,有向无环图的树形图数目=根节点意外入度之积 现在相当于在原图上加一条边问树形图的数目 考虑多出来不合法的方案,一定是成环且包含新加入的边 对于一条路贡献就是∏d[i] [i∉pa ...

  10. bzoj3798: 特殊的质数

    分块打表.块内的暴力块外的打表.开始没有j>0所以WA了. #include<cstdio> #include<cmath> #include<cstring> ...