关于jmeter+ant+jenkins性能自动化将测试结果文件jtl转换成html文件遇到的问题。
1、ant自身缺陷,返回结果中有特殊字符,乱码字符,无法识别,jtl文件转换时报错。
2、jtl文件过大转换成html文件时出现内存溢出。
针对以上情况:可考虑使用BeenShell Sampler:对返回结果的乱码、特殊字符进行处理,返回结果内容过大,通过代码进行截取,但是会对性能测试结果又小许影响。
引入的外部java文件代码如下:
import java.net.URI;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
public class GetRequest {
public static String doGet(String url, String keyValueParam,String proxy,String port){
// 构建htpp客户端对象
CloseableHttpClient client = HttpClientBuilder.create().build();
HttpGet get = new HttpGet();
RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(20000)
.setConnectTimeout(20000)
.setConnectionRequestTimeout(20000)
.build();
if(!proxy.equals("")){
requestConfig = RequestConfig.custom()
.setSocketTimeout(20000)
.setConnectTimeout(20000)
.setConnectionRequestTimeout(20000).setProxy(new HttpHost(proxy, Integer.valueOf(port)))
.build();
}
get.setConfig(requestConfig);
// 将url和键值对参数拼接成新的url地址
get.setURI(URI.create(url + keyValueParam));
HttpResponse response;
String strResponse ="No HttpResponse";
try {
response = client.execute(get);
// 获取返回主体
strResponse = EntityUtils.toString(response.getEntity());
} catch (Exception e) {
// TODO Auto-generated catch block
//e.printStackTrace();
strResponse ="Send Request,But HttpResponse is error";
}finally {
try {
client.close();
} catch (IOException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
}
return strResponse;
}
public static String doGet(String url, String keyValueParam, String header,String proxy,String port){
// 构建htpp客户端对象
CloseableHttpClient client = HttpClientBuilder.create().build();
HttpGet get = new HttpGet();
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(20000).setConnectTimeout(20000)
.setConnectionRequestTimeout(20000).build();
if (!proxy.equals("")) {
requestConfig = RequestConfig.custom().setSocketTimeout(20000).setConnectTimeout(20000)
.setConnectionRequestTimeout(20000).setProxy(new HttpHost(proxy, Integer.valueOf(port))).build();
}
get.setConfig(requestConfig);
// 将url和键值对参数拼接成新的url地址
get.setURI(URI.create(url + keyValueParam));
get.addHeader("Cookie", header);
HttpResponse response;
String strResponse="No HttpResponse";
try {
response = client.execute(get);
strResponse = EntityUtils.toString(response.getEntity());
} catch (Exception e) {
// TODO Auto-generated catch block
//e.printStackTrace();
strResponse="Send Request,But HttpResponse is error";
}finally {
try {
client.close();
} catch (IOException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
}
// 获取返回主体
return strResponse;
}
}
BeenShell Sampler的代码如下:
source("D:/Jmeter/运营平台核心性能场景/java/GetRequest.java");
String actualResponse = GetRequest.doGet("${Agreement}://${Host}:${Port}","${qualityCertificationUrl}","${Cookie}","${ProxyHost}","${ProxyPort}");
String sonStr= "<h3>初级认证2.0</h3>";
String response="";
//判断是否包含期望的字符串
if(actualResponse.indexOf(sonStr)!=-1){
response = "<h3>初级认证2.0</h3>";
}else{
response = actualResponse;
}
//为jmeter响应结果赋值
ResponseMessage=response;
关于jmeter+ant+jenkins性能自动化将测试结果文件jtl转换成html文件遇到的问题。的更多相关文章
- Jmeter+ant+Jenkins接口自动化框架搭建
摘自:https://testerhome.com/topics/13389 一.背景 上一篇讲了Jmeter 接口自动化-脚本数据分离实例,我们知道怎么利用Jmeter去编写接口自动化脚本,但是接 ...
- jmeter+ant+jenkins实现自动化接口测试
一.安装前准备 1.JDK:jdk-8u121-windows-x64 2.jmeter工具:apache-jmeter-2.13 3.ANT工具:apache-ant-1.9.7-bin 4.jen ...
- Jmeter+Ant+Jenkins接口自动化框架
最近应公司要求,搭建一套接口自动化环境.看到通知邮件,没有多想就确定了Jmeter路线.可能有些人会 说,为啥不用python,相对而言高大上一些.因为公司内部现在项目有用到Jmeter,正好可以结合 ...
- Jmeter+Ant+Jenkins接口自动化持续集成环境搭建(Linux)
一.安装说明 系统环境:CentOS release 6.4 JDK版本:jdk1.8.0_181 Jmeter版本:apache-jmeter-3.0 Ant版本:apache-ant-1.9.13 ...
- jmeter+ant+jenkins接口自动化环境搭建
一.准备 1.安装jdk --->点击查看安装教程 2.安装jmeter ,官网下载jmeter解压,配置jmeter环境: JMETER_HOME (解压jdk路径) Path (;% ...
- Jmeter+Ant+Jenkins 接口自动化之简单demo
之前的文章我们已经分享过了 Jmeter+Ant 的批量执行 ,并且搭建好了Jenkins部署平台,如何再将三者完美结合呢? 1.首先打开Jenkins主页面,进入“系统管理-插件管理”,安装相关的插 ...
- jmeter+ant+jenkins的自动化接口测试
一.Jenkins安装配置 1.安装配置JDK1.7+环境变量: 2.下载jenkins.war,放入D:\jenkins目录下,目录位置随意: Jenkins启动方法: cmd进入Jenkins目录 ...
- 关于Jmeter+Ant+Jenkins作为接口、性能自动化框架的误区
说明:Apach-Jmeter有完善的桌面客户端,关联数据的处方方式,各种参数化的方式,各种Jar包的扩展,也可以用作抓包工具使用,当然最重要的是它是[开源!开源!开源!],重要的事说三遍,目前也有基 ...
- 【此处有干货~】jmeter+ant+jenkins持续集成配置及过程中问题解决思路
本人是一枚工作近三年的小测试,大学正好专业为软件测试,在工作中用到最多的是功能测试.接口测试.压力测试.偶尔会涉及到性能测试......(小白,很多观念技术跟大佬差距太大,勿喷) 在接口测试过程当中, ...
随机推荐
- 中文日历Calendar
一.层次结构 Object<-----Calendar<-----EastAsianLunisolarCalendar<-----ChineseLunisolarCalendar(农 ...
- H3C常见视图及命令
H3C常见视图及命令 H3C Comware的视图模式 1.用户视图:查看系统的硬件和系统的信息 2.系统视图(类似于Cisco的配置模式) 3.路由协议视图 4.接口视图 5.用户界面视图 各种视图 ...
- String字符串常量池简介
直接贴代码---> public class Test { public static void main(String[] args) { /** * 为了提升字符串的访问效率,在程序中使用了 ...
- postgresql学习笔记--基础篇 - copy
1. psql 导入/导出数据 psql支持文件数据导入到数据库,也支持数据库表数据导出到文件中. COPY命令和\copy 命令都支持这两类操作,但两者有如下区别: COPY 命令是SQL命令,\c ...
- GIL 信号量 event事件 线程queue
GIL全局解释器锁 官方解释: In CPython, the global interpreter lock, or GIL, is a mutex that prevents multiple n ...
- public abstract啥时候可以省略?
父类是抽象类,其中有抽象方法,那么子类继承父类,并把父类中的所有方法都实现覆盖了,子类才有创建对象实例的能力,否则子类也必须是抽象类.抽象类中可以有构造方法,是子类在构造子类对象时需要调用父类(抽象类 ...
- leetcode解题报告(14):Max Consecutive Ones
描述 Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: ...
- Codeforces Round #528 (Div. 2)题解
Codeforces Round #528 (Div. 2)题解 A. Right-Left Cipher 很明显这道题按题意逆序解码即可 Code: # include <bits/stdc+ ...
- requests记录
http://docs.python-requests.org/zh_CN/latest/user/quickstart.html r = requests.get('http://httpbin.o ...
- rabbitmq 删除所有队列及服务重启脚本
#!/bin/bash # 删除元数据 rm -rf /var/lib/rabbitmq/mnesia # 重启rabbitmq rabbitmqctl stop systemctl restart ...