使用loadrunner进行压力测试之----post请求
1. 发送post请求时使用web_submit_data
 web_submit_data("create",//事务名
           "Action=http://bizhi.sogou.com/diy/", //请求域名
           "Method=POST", //请求类型为post
           "RecContentType=application/json", //返回格式为json
           "Referer=http://bizhi.sogou.com/diy?wp_id=8743",
           "Snapshot=t4.inf",
           "Mode=HTML",
           ITEMDATA, //下面编辑post请求的数据
           "Name=img", "Value=http://dl.bizhi.sogou.com/images/2012/05/3/8743.jpg", ENDITEM, //数据的name、value及结束符
           "Name=left", "Value=60", ENDITEM, //第二条数据的name、value及结束符
           "Name=top", "Value=30", ENDITEM,
           "Name=width", "Value=720", ENDITEM,
           "Name=height", "Value=450", ENDITEM,
           "Name=model", "Value=5/5s", ENDITEM,
           "Name=x", "Value=1", ENDITEM,
           "Name=y", "Value=1", ENDITEM,
           "Name=ofc", "Value=1", ENDITEM,
           "Name=wp_id", "Value=8743", ENDITEM,
           "Name=mat", "Value=ms", ENDITEM,
           "Name=curMode", "Value=normal", ENDITEM,
           LAST);
 web_submit_data("create",
           "Action=http://bizhi.sogou.com/diy/",
           "Method=POST",
           "RecContentType=application/json",
           "Referer=http://bizhi.sogou.com/diy?wp_id=8743",
           "Snapshot=t4.inf",
           "Mode=HTML",
           ITEMDATA,
           "Name=img", "Value=http://dl.bizhi.sogou.com/images/2012/05/3/8743.jpg", ENDITEM,
           "Name=left", "Value=60", ENDITEM,
           "Name=top", "Value=30", ENDITEM,
           "Name=width", "Value=720", ENDITEM,
           "Name=height", "Value=450", ENDITEM,
           "Name=model", "Value=5/5s", ENDITEM,
           "Name=x", "Value=1", ENDITEM,
           "Name=y", "Value=1", ENDITEM,
           "Name=ofc", "Value=1", ENDITEM,
           "Name=wp_id", "Value=8743", ENDITEM,
           "Name=mat", "Value=ms", ENDITEM,
           "Name=curMode", "Value=normal", ENDITEM,
           LAST);//请求1
      lr_set_debug_message(  | , );
      lr_save_string((char*)strtok(lr_eval_string("{Output}"),","),"temp");//获得请求1的返回数据
      //lr_output_message("bian:%s",lr_eval_string("{temp}"));
      lr_save_string((char*)strtok(NULL,","),"diyid_temp");//解析返回数据
      //lr_output_message("bian2:%s",lr_eval_string("{diyid_temp}"));
      lr_save_string((char*)strtok(lr_eval_string("{diyid_temp}"),":"),"temp");//解析返回数据
      //lr_output_message("bian:%s",lr_eval_string("{temp}"));
      lr_save_string((char*)strtok(NULL,":"),"diyid_temp");//解析返回数据
      //lr_output_message("bian2:%s",lr_eval_string("{diyid_temp}"));
      diyid_str=(char*)strtok(lr_eval_string("{diyid_temp}"),"}");
      lr_save_string((char*)strtok(lr_eval_string("{diyid_temp}"),"}"),"diyid");//解析返回数据
      //lr_output_message("bian:%s",lr_eval_string("{diyid}"));
      strcat(test, diyid_str);
      //lr_output_message("%s",test);
      lr_save_string(CMd5(test),"md5");//计算md5
      //lr_output_message("bianmd5:%s",lr_eval_string("{md5}"));
      web_submit_data("postname",
                 "Action=http://bizhi.sogou.com/orderpay/",
                 "Method=POST",
                 "RecContentType=textml",
                 "Mode=HTML",
                 ITEMDATA,
                 "Name=goods_action","Value=goods_detail",ENDITEM,
                     "Name=goods_addr","Value=656",ENDITEM,
                     "Name=md5str","Value={md5}",ENDITEM,//根据参数构造请求
                     "Name=diy_id","Value={diyid}",ENDITEM,//根据参数构造请求
                     "Name=goods_info","Value=448_1",ENDITEM,
                     "Name=from","Value=diy",ENDITEM,
                     "Name=Accept","Value=text/plain",ENDITEM,
                 LAST); 
3. 另附,计算md5,需要添加md5的头文件,并别忘了在gloab.h中include md5.h
#ifndef MD5_H
#define MD5_H
#ifdef __alpha
typedef unsigned int uint32;
#else
typedef unsigned long uint32;
#endif
struct MD5Context {
uint32 buf[];
uint32 bits[];
unsigned char in[];
};
extern void MD5Init();
extern void MD5Update();
extern void MD5Final();
extern void MD5Transform();
typedef struct MD5Context MD5_CTX;
#endif
#ifdef sgi
#define HIGHFIRST
#endif
#ifdef sun
#define HIGHFIRST
#endif
#ifndef HIGHFIRST
#define byteReverse(buf, len) /* Nothing */
#else
void byteReverse(buf, longs)unsigned char *buf; unsigned longs;
{
uint32 t;
do {
t = (uint32) ((unsigned) buf[] << | buf[]) << |((unsigned) buf[] << | buf[]);
*(uint32 *) buf = t;
buf += ;
} while (--longs);
}
#endif
void MD5Init(ctx)struct MD5Context *ctx;
{
ctx->buf[] = 0x67452301;
ctx->buf[] = 0xefcdab89;
ctx->buf[] = 0x98badcfe;
ctx->buf[] = 0x10325476;
ctx->bits[] = ;
ctx->bits[] = ;
}
void MD5Update(ctx, buf, len) struct MD5Context *ctx; unsigned char *buf; unsigned len;
{
uint32 t;
t = ctx->bits[];
if ((ctx->bits[] = t + ((uint32) len << )) < t)
ctx->bits[]++;
ctx->bits[] += len >> ;
t = (t >> ) & 0x3f;
if (t) {
unsigned char *p = (unsigned char *) ctx->in + t;
t = - t;
if (len < t) {
memcpy(p, buf, len);
return;
}
memcpy(p, buf, t);
byteReverse(ctx->in, );
MD5Transform(ctx->buf, (uint32 *) ctx->in);
buf += t;
len -= t;
}
while (len >= ) {
memcpy(ctx->in, buf, );
byteReverse(ctx->in, );
MD5Transform(ctx->buf, (uint32 *) ctx->in);
buf += ;
len -= ;
}
memcpy(ctx->in, buf, len);
}
void MD5Final(digest, ctx)
unsigned char digest[]; struct MD5Context *ctx;
{
unsigned count;
unsigned char *p;
count = (ctx->bits[] >> ) & 0x3F;
p = ctx->in + count;
*p++ = 0x80;
count = - - count;
if (count < ) {
memset(p, , count);
byteReverse(ctx->in, );
MD5Transform(ctx->buf, (uint32 *) ctx->in);
memset(ctx->in, , );
} else {
memset(p, , count - );
}
byteReverse(ctx->in, );
((uint32 *) ctx->in)[] = ctx->bits[];
((uint32 *) ctx->in)[] = ctx->bits[];
MD5Transform(ctx->buf, (uint32 *) ctx->in);
byteReverse((unsigned char *) ctx->buf, );
memcpy(digest, ctx->buf, );
memset(ctx, , sizeof(ctx));
}
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
#define MD5STEP(f, w, x, y, z, data, s) ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
void MD5Transform(buf, in)
uint32 buf[]; uint32 in[];
{
register uint32 a, b, c, d;
a = buf[];
b = buf[];
c = buf[];
d = buf[];
MD5STEP(F1, a, b, c, d, in[] + 0xd76aa478, );
MD5STEP(F1, d, a, b, c, in[] + 0xe8c7b756, );
MD5STEP(F1, c, d, a, b, in[] + 0x242070db, );
MD5STEP(F1, b, c, d, a, in[] + 0xc1bdceee, );
MD5STEP(F1, a, b, c, d, in[] + 0xf57c0faf, );
MD5STEP(F1, d, a, b, c, in[] + 0x4787c62a, );
MD5STEP(F1, c, d, a, b, in[] + 0xa8304613, );
MD5STEP(F1, b, c, d, a, in[] + 0xfd469501, );
MD5STEP(F1, a, b, c, d, in[] + 0x698098d8, );
MD5STEP(F1, d, a, b, c, in[] + 0x8b44f7af, );
MD5STEP(F1, c, d, a, b, in[] + 0xffff5bb1, );
MD5STEP(F1, b, c, d, a, in[] + 0x895cd7be, );
MD5STEP(F1, a, b, c, d, in[] + 0x6b901122, );
MD5STEP(F1, d, a, b, c, in[] + 0xfd987193, );
MD5STEP(F1, c, d, a, b, in[] + 0xa679438e, );
MD5STEP(F1, b, c, d, a, in[] + 0x49b40821, );
MD5STEP(F2, a, b, c, d, in[] + 0xf61e2562, );
MD5STEP(F2, d, a, b, c, in[] + 0xc040b340, );
MD5STEP(F2, c, d, a, b, in[] + 0x265e5a51, );
MD5STEP(F2, b, c, d, a, in[] + 0xe9b6c7aa, );
MD5STEP(F2, a, b, c, d, in[] + 0xd62f105d, );
MD5STEP(F2, d, a, b, c, in[] + 0x02441453, );
MD5STEP(F2, c, d, a, b, in[] + 0xd8a1e681, );
MD5STEP(F2, b, c, d, a, in[] + 0xe7d3fbc8, );
MD5STEP(F2, a, b, c, d, in[] + 0x21e1cde6, );
MD5STEP(F2, d, a, b, c, in[] + 0xc33707d6, );
MD5STEP(F2, c, d, a, b, in[] + 0xf4d50d87, );
MD5STEP(F2, b, c, d, a, in[] + 0x455a14ed, );
MD5STEP(F2, a, b, c, d, in[] + 0xa9e3e905, );
MD5STEP(F2, d, a, b, c, in[] + 0xfcefa3f8, );
MD5STEP(F2, c, d, a, b, in[] + 0x676f02d9, );
MD5STEP(F2, b, c, d, a, in[] + 0x8d2a4c8a, );
MD5STEP(F3, a, b, c, d, in[] + 0xfffa3942, );
MD5STEP(F3, d, a, b, c, in[] + 0x8771f681, );
MD5STEP(F3, c, d, a, b, in[] + 0x6d9d6122, );
MD5STEP(F3, b, c, d, a, in[] + 0xfde5380c, );
MD5STEP(F3, a, b, c, d, in[] + 0xa4beea44, );
MD5STEP(F3, d, a, b, c, in[] + 0x4bdecfa9, );
MD5STEP(F3, c, d, a, b, in[] + 0xf6bb4b60, );
MD5STEP(F3, b, c, d, a, in[] + 0xbebfbc70, );
MD5STEP(F3, a, b, c, d, in[] + 0x289b7ec6, );
MD5STEP(F3, d, a, b, c, in[] + 0xeaa127fa, );
MD5STEP(F3, c, d, a, b, in[] + 0xd4ef3085, );
MD5STEP(F3, b, c, d, a, in[] + 0x04881d05, );
MD5STEP(F3, a, b, c, d, in[] + 0xd9d4d039, );
MD5STEP(F3, d, a, b, c, in[] + 0xe6db99e5, );
MD5STEP(F3, c, d, a, b, in[] + 0x1fa27cf8, );
MD5STEP(F3, b, c, d, a, in[] + 0xc4ac5665, );
MD5STEP(F4, a, b, c, d, in[] + 0xf4292244, );
MD5STEP(F4, d, a, b, c, in[] + 0x432aff97, );
MD5STEP(F4, c, d, a, b, in[] + 0xab9423a7, );
MD5STEP(F4, b, c, d, a, in[] + 0xfc93a039, );
MD5STEP(F4, a, b, c, d, in[] + 0x655b59c3, );
MD5STEP(F4, d, a, b, c, in[] + 0x8f0ccc92, );
MD5STEP(F4, c, d, a, b, in[] + 0xffeff47d, );
MD5STEP(F4, b, c, d, a, in[] + 0x85845dd1, );
MD5STEP(F4, a, b, c, d, in[] + 0x6fa87e4f, );
MD5STEP(F4, d, a, b, c, in[] + 0xfe2ce6e0, );
MD5STEP(F4, c, d, a, b, in[] + 0xa3014314, );
MD5STEP(F4, b, c, d, a, in[] + 0x4e0811a1, );
MD5STEP(F4, a, b, c, d, in[] + 0xf7537e82, );
MD5STEP(F4, d, a, b, c, in[] + 0xbd3af235, );
MD5STEP(F4, c, d, a, b, in[] + 0x2ad7d2bb, );
MD5STEP(F4, b, c, d, a, in[] + 0xeb86d391, );
buf[] += a;
buf[] += b;
buf[] += c;
buf[] += d;
}
char* CMd5(const char* s)
{
struct MD5Context md5c;
unsigned char ss[];
char subStr[],resStr[];
int i;
MD5Init( &md5c );
MD5Update( &md5c, s, strlen(s) );
MD5Final( ss, &md5c );
strcpy(resStr,"");
for( i=; i<; i++ )
{
sprintf(subStr, "%02x", ss[i] );
itoa(ss[i],subStr,);
if (strlen(subStr)==) {
strcat(resStr,"");
}
strcat(resStr,subStr);
}
strcat(resStr,"\0");
return resStr;
}
4. 如果一个action中有两个请求,那么压测是看到的响应时间曲线是两个请求综合的响应时间,如果要区分每个请求的响应时间,可加入请求开始/结束标记
lr_start_transaction(“create”);//插入结束标记,从此结束计时
lr_end_transaction(“create”, LR_AUTO);//插入结束标记,从此结束计时
转自:51testing论坛
使用loadrunner进行压力测试之----post请求的更多相关文章
- LoadRunner压力测试之Unique Number参数类型、Random Number参数类型浅析
		前几天工作需要用LoadRunner进行压力测试,期间对手机号进行参数化设置. 当时选用了<Value>137{Random_quhao}{Unique_weiyi}</Value& ... 
- 实验二. 使用LoadRunner进行压力测试
		实验二. 使用LoadRunner进行压力测试 一. LoadRunner 概要介绍 1.1简介 LoadRunner 是一种预测系统行为和性能的工业标准级负载测试工具.通过以模拟上千万用户实 ... 
- Loadrunner 进行压力测试 并发测试
		问题背景: 今年公司项目进行Saas化转型,在中间遇到很多问题,其中之一就是 Saas化后多租户的性能 和 并发问题.公司让我来调研和重现问题,通过调研总结了一些经验教训,分享给大家. 环境: Loa ... 
- loadrunner通过web的post请求方法测接口 1
		loadrunner通过web的post请求方法测接口 loginapi() { web_url("rest", "URL=http://192 ... 
- loadrunner通过web的post请求方法测接口
		loadrunner通过web的post请求方法测接口 loginapi() 模拟APP发送请求给Cloud, Action() "Name=input","Value= ... 
- ab压力测试之post与get请求
		安装ab工具 yum install httpd-tools 参数说明 -n:执行的请求个数,默认时执行一个请求 -c:一次产生的请求个数,即并发个数 -p:模拟post请求,文件格式为gid=2&a ... 
- 压力测试之badboy和Jmeter的简单使用方法
		文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 所谓压力测试是指,通过确定一个系统的瓶颈或者不能接收的性能点, ... 
- 使用loadrunner进行压力测试遇到的问题总结
		本人整理了一个LR使用过程中遇到的各种问题的总结文档,有需要可以加QQ群169974486下载. 一.无法生成虚拟用户,运行报错:CCI compilation error -vuser_init.c ... 
- CentOS服务器Http压力测试之ab
		ab的全称是Apache Bench,是Apache自带的网络压力测试工具,相比于LR.JMeter,是我所知道的 Http 压力测试工具中最简单.最通用的. ab命令对发出负载的计算机要求很低,不会 ... 
随机推荐
- JS  BOM
			一.window对象 //系统对话框 var flag=confirm("提示语句");//弹出一个对话框 当你点击确定flag=true,点击取消flag=false: var ... 
- css 文本溢出显示省略号
			<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ... 
- ubuntu下在apache部署python站点
			ubuntu下在apache部署python站点 我的是ubuntu14 32为的虚拟机,默认安装的python为3.4 环境:apache + mysql + django + python3 软件 ... 
- 快速了解SPA单页面应用
			简要 SPA单页网页应用程序这个概念并不算新,早在2003年就已经有在讨论这个概念了,不过,单页应用这个词是到了2005年才有人提出使用,SPA的概念就和它的名字一样显而易懂,就是整个网站不再像传统的 ... 
- 【原创】C#搭建足球赛事资料库与预测平台(6) 赔率数据表设计2
			本博客所有文章分类的总目录:[总目录]本博客博文总目录-实时更新 开源C#彩票数据资料库系列文章总目录:[目录]C#搭建足球赛事资料库与预测平台与彩票数据分析目录 本篇文章开始将逐步介 ... 
- backbone库学习-Collection
			backbone库的结构: http://www.cnblogs.com/nuysoft/archive/2012/03/19/2404274.html 本文所有例子来自于http://blog.cs ... 
- MySQL5.6忘记root密码(win平台)
			1.首先net stop mysql服务,并且切换到任务管理器,有与mysql有关的,最好关闭进程. 2.运行CMD命令切换到MySql安装bin目录,下面是我的mysql安装目录 cd C:\Pr ... 
- 使用bokeh-scala进行数据可视化
			目录 前言 bokeh简介及胡扯 bokeh-scala基本代码 我的封装 总结 一.前言 最近在使用spark集群以及geotrellis框架(相关文章见http://www.cnbl ... 
- Android系统目录介绍
			src目录:完成对java代码的编写 assets目录: 资源目录 res目录: 图片,布局文件和字符串,菜单等文件 bin目录:输出文件夹 如生成的apk安装文件 project.propertie ... 
- Azure Redis Cache (1) 入门
			<Windows Azure Platform 系列文章目录> Microsoft Azure Redis Cache基于流行的开源Redis Cache. 1.功能 Redis 是一种高 ... 
