测试要求:
 
在本次测试中,我需要并发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. 【原创】30分钟入门 github

    很久没更新了,这篇文章重点在github的入门使用,读者可以下载github for windows shell,边看边操作,加深印象. 好了,30分钟的愉快之旅开始吧: 一.github使用的注意事 ...

  2. 9本java程序员必读的书

    来源:http://mp.weixin.qq.com/s?__biz=MjM5NzA1MTcyMA==&mid=202904638&idx=2&sn=21dd20438e32a ...

  3. TCP protocol

    he characteristics of TCP protocol TCP (which means Transmission Control Protocol) is one of the mai ...

  4. PHP无限极分类生成树方法

    你还在用浪费时间又浪费内存的递归遍历无限极分类吗,看了该篇文章,我觉得你应该换换了.这是我在OSChina上看到的一段非常精简的PHP无限极分类生成树方法,整理分享了. function genera ...

  5. 在CentOS 6.X 上面安装 Python 2.7.X

    在CentOS 6.X 上面安装 Python 2.7.X CentOS 6.X 自带的python版本是 2.6 , 由于工作需要,很多时候需要2.7版本.所以需要进行版本升级.由于一些系统工具和服 ...

  6. C#实现GDI+基本图的缩放、拖拽、移动

    C#实现GDI+基本图的缩放.拖拽.移动示例代码如下: using System;using System.Collections.Generic;using System.ComponentMode ...

  7. Android开发之权限列表

    权限定义 功能 android.permission.ACCESS_CHECKIN_PROPERTIES 允许读写访问"properties"表在checkin数据库中,改值可以修 ...

  8. C++STL之整理算法

    这里主要介绍颠倒.旋转.随机排列和分类4中常见的整理算法 1.颠倒(反转) void reverse(_BidIt _First, _BidIt _Last) _OutIt reverse_copy( ...

  9. poj 1905 Expanding Rods (数学 计算方法 二分)

    题目链接 题意:将长度为L的棒子卡在墙壁之间.现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离. 分析: 下面的分析是网上别人的分析: ...

  10. Android 怎样使用API

    本文针对Android开发如何使用API文档进行一些经验分享. 1.为什么需要掌握API的使用. 也许你需要完成一个功能时很多时候你在网上google一番,因为很可能找到有用的代码片段,甚至不用关心具 ...