jmeter+ant+jenkins+mac报告优化(二):添加90% Line和QPS
一、优化内容
1、Summary中只标红Failures数
2、Pages页面按Average Time倒序排序
3、Average Time超过2s标黄显示
4、Pagelist 模块中针对错误和超长时间接口标色显示
5、添加90% Line和QPS
6、Failure Detail模块显示Response Data
效果:
二、具体实现
1、 Summary中的只标红Failures数:
屏蔽Summary中class属性
<!--
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$allFailureCount > 0">Failure</xsl:when>
</xsl:choose>
</xsl:attribute>
-->修改allFailureCount
<td align="center">
<xsl:value-of select="$allSuccessCount" />
</td>
<xsl:choose>
<xsl:when test="$allFailureCount > 0">
<td align="center" style="font-weight:bold">
<font color="red">
<xsl:value-of select="$allFailureCount" />
</font>
</td>
</xsl:when>
<xsl:otherwise>
<td align="center">
<xsl:value-of select="$allFailureCount" />
</td>
</xsl:otherwise>
</xsl:choose>
2、Pages页面按Average Time倒序排序:
在Pagelist模板中for-each下添加
<xsl:for-each select="/testResults/*[not(@lb = preceding::*/@lb)]" >
<!-- 按平均时间排序 -->
<xsl:sort select="sum(../*[@lb = current()/@lb]/@t) div count(../*[@lb = current()/@lb])" data-type="number" order="descending"/>
3、接口Average Time超过2s标黄显示:
- 添加LongTime css
.Failure {
font-weight:bold; color:red;
}
.LongTime {
font-weight:bold; color:#ff9900;
}
4、Pagelist 模块中针对错误和超长时间接口标色显示
<tr valign="top">
<xsl:choose>
<!-- 失败用例标红显示 -->
<xsl:when test="$failureCount > 0">
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$failureCount > 0">Failure</xsl:when>
</xsl:choose>
</xsl:attribute>
</xsl:when>
<!-- 平均时间超过2s,标色显示 -->
<xsl:when test="$averageTime > 2000">
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$averageTime > 2000">LongTime</xsl:when>
</xsl:choose>
</xsl:attribute>
</xsl:when>
</xsl:choose>
5、添加90% Line和QPS
- 添加90 %lineTime模板
<xsl:template name="max">
<xsl:param name="nodes" select="/.." />
<xsl:choose>
<xsl:when test="not($nodes)">NaN</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$nodes">
<xsl:sort data-type="number" order="descending" />
<xsl:if test="position() = 1">
<xsl:value-of select="number(.)" />
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template> <!-- 90% line time -->
<xsl:template name="lineTime">
<xsl:param name="nodes" select="/.." />
<xsl:choose>
<xsl:when test="not($nodes)">NaN</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$nodes">
<xsl:sort data-type="number" />
<!-- last() 返回当前上下文中的最后一个节点位置数 -->
<!-- ceiling(number) 返回大于number的最小整数 -->
<!-- floor(number) 返回不大于number的最大整数 -->
<!-- position() 返回当前节点位置的数字 -->
<!-- number(object) 使对象转换成数字 -->
<xsl:choose>
<!-- 当只有一个节点时,向上取整 -->
<xsl:when test="last() = 1">
<xsl:if test="position() = ceiling(last()*0.9)">
<xsl:value-of select="number(.)" />
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:if test="position() = floor(last()*0.9)">
<xsl:value-of select="number(.)" />
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
- Sunmary中添加标题
<tr valign="top">
<th># Samples</th>
<th>Success</th>
<th>Failures</th>
<th>Success Rate</th>
<th>Average Time</th>
<th>Min Time</th>
<th>Max Time</th>
<th>90% Line</th>
<th>QPS</th>
</tr>
- Summary中添加allLineTime和qps变量
<xsl:variable name="allMaxTime">
<xsl:call-template name="max">
<xsl:with-param name="nodes" select="/testResults/*/@t" />
</xsl:call-template>
</xsl:variable>
<!-- New add 90% line -->
<xsl:variable name="allLineTime">
<xsl:call-template name="lineTime">
<xsl:with-param name="nodes" select="/testResults/*/@t" />
</xsl:call-template>
</xsl:variable>
<!-- 将毫秒转换成秒 -->
<xsl:variable name="qps" select="$allCount * 1000 div $allTotalTime"/>
- Summary中调用allLineTime和qps变量
<td align="center">
<xsl:call-template name="display-time">
<xsl:with-param name="value" select="$allMaxTime" />
</xsl:call-template>
</td>
<td align="center">
<xsl:call-template name="display-time">
<xsl:with-param name="value" select="$allLineTime" />
</xsl:call-template>
</td>
<td align="center">
<xsl:call-template name="display-qps">
<xsl:with-param name="value" select="$qps" />
</xsl:call-template>
- pagelist中添加标题
<xsl:template name="pagelist">
<h2>Pages</h2>
<table align="center" class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
<tr valign="top">
<th>URL</th>
<th># Samples</th>
<th>Success</th>
<th>Failures</th>
<th>Success Rate</th>
<th>Average Time</th>
<th>Min Time</th>
<th>Max Time</th>
<th>90% Line</th>
<th>QPS</th>
<th></th>
</tr>
- pagelist中添加allLineTime和qps变量
<xsl:variable name="maxTime">
<xsl:call-template name="max">
<xsl:with-param name="nodes" select="../*[@lb = current()/@lb]/@t" />
</xsl:call-template>
</xsl:variable>
<!-- new add 90% line time -->
<xsl:variable name="nintyTime">
<xsl:call-template name="lineTime">
<xsl:with-param name="nodes" select="../*[@lb = current()/@lb]/@t" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="qpsTime" select="$count * 1000 div $totalTime"/>
- pagelist中调用allLineTime和qps变量
<td align="center">
<xsl:call-template name="display-time">
<xsl:with-param name="value" select="$maxTime" />
</xsl:call-template>
</td>
<!-- Page页面添加90% LineTime -->
<td align="center">
<xsl:call-template name="display-time">
<xsl:with-param name="value" select="$nintyTime" />
</xsl:call-template>
</td>
<td align="center">
<xsl:call-template name="display-qps">
<xsl:with-param name="value" select="$qpsTime" />
</xsl:call-template>
</td>
6、Failure Detail模块显示Response Data
- 设置showData为‘y’
<!-- Defined parameters (overrideable) -->
<xsl:param name="showData" select="'y'"/>
<xsl:param name="titleReport" select="'Interface Test Results'"/>
<xsl:param name="dateReport" select="'date not defined'"/>
- 替换内容
<table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
<tr valign="top">
<th align="center">Response</th>
<th align="center">Failure Message</th>
<xsl:if test="$showData = 'y'">
<th align="left">Response Data</th>
</xsl:if>
</tr> <xsl:for-each select="/testResults/*[@lb = current()/@lb][attribute::s='false']">
<tr>
<td><xsl:value-of select="@rc | @rs" /> - <xsl:value-of select="@rm" /></td>
<td><xsl:value-of select="assertionResult/failureMessage" /></td>
<xsl:if test="$showData = 'y'">
<td><xsl:value-of select="responseData" /></td>
</xsl:if>
</tr>
</xsl:for-each>
7.添加Host
<xsl:template name="pageHeader">
<h1><xsl:value-of select="$titleReport" /></h1>
<table width="100%">
<tr>
<!-- 获取requestHeader数据 -->
<xsl:variable name="URL" select="/testResults/httpSample/requestHeader" />
<!-- 从获取的URL中截取数据,第二代表起始位置,第三位代表长度 -->
<xsl:variable name="newURL" select="substring($URL, 94, 40)" />
<!-- 已换行符来截取,before代表换行符之前的数据 -->
<xsl:variable name="remaining" select="substring-before($newURL, ' ')" />
<td align="left">Date report: <xsl:value-of select="$dateReport" /></td>
<td align="center">Host: <xsl:value-of select="$remaining" /></td>
<td align="right"><a href="./TestLog.html">测试日志</a></td>
</tr>
</table>
jmeter+ant+jenkins+mac报告优化(二):添加90% Line和QPS的更多相关文章
- jmeter+ant+jenkins+mac报告优化
一.在上篇博客中生成的报告有两个问题: 1.date not defined 2.Min Time和Max Time显示成了NaN 二.Jmeter+Ant报告生成原理: 在解决问题之前,让我们先弄清 ...
- jmeter+ant+jenkins+mac报告优化(一):解决Min Time和Max Time显示NaN
一.在上篇博客中生成的报告有两个问题: 1.date not defined 2.Min Time和Max Time显示成了NaN 二.Jmeter+Ant报告生成原理: 1.在Jmeter的extr ...
- jmeter+ant+jenkins+mac 报告优化(三) 使用命令行执行jmeter方式生成多维度的图形化HTML报告
1.在构建中填写如下命令: 2.start.sh文件的内容 cd /Applications/apache-jmeter-3.0/bin/ CURTIME=`date +%Y%m%d%H%M` ./j ...
- jmeter+ant+jenkins+mac使用HTML Publisher插件后查看html报告显示不正常
Jenkins安全默认将以下功能关闭: 1.javascript2.html上的内置插件3.内置css或从其它站的css4.从其它站的图处5.AJAX 报告中有javascript,所以显示异常.解决 ...
- jmeter+ant+jenkins+mac环境搭建
一.环境准备 1.JDK环境:http://www.oracle.com/technetwork/java/javase/downloads/index.html 2.ANT环境:http://ant ...
- Jmeter+Ant+Jenkins接口自动化测试(二)_测试方案设计及jmeter脚本开发
前言 根据之前部署好的测试环境,进行接口自动化测试的方案设计及Jmeter脚本开发.测试方案设计过程中采用了数据分离和对象分离等思路,因此直接通过特定的测试用例文档来驱动整个自动化接口测试的执行,相关 ...
- jmeter+ant+jenkins+mac 构建后自动发送邮件
1.安装Email Extension Plugin插件 2.进入系统管理-系统设置,按如下进行设置: ------------------------------------------------ ...
- jmeter+ant+jenkins生产的报告乱码
jmeter+ant+jenkins生产的报告乱码 问题:生产报告会乱码的问题,一般是有编码格式引起的.我遇到的问题是,jmeter需要读取csv的数据作为参数.但是我们并不知道csv保存是什么编码格 ...
- jmeter--接口自动化jmeter+ant+jenkins
的 一.介绍 接口自动化工具:jmeter+ant+jenkins 流程: -1.jmeter已录制或手动设置好脚本后 -2.配置ant,使用Ant工具,进行批量执行jmeter的脚本 -3.使用Je ...
随机推荐
- socket & pipe note
[socket & pipe note] 1.socket类型 2.大小端 3.socketpair 如何创建全双工管道? 直接的办法当然是pipe两次,创建两组管道,但是有没有更简单的呢? ...
- 九项重要的职业规划提示(转自W3School )
1. 学习的步伐不停止 古人说,活到老,学到老.终身学习应该是您的座右铭. 世界在不断变化,每个人都在寻找各自的事业途径. 您只有保证了足够的技能储备,才能确保能够得到一份足够满意的工作. 为了保证您 ...
- Python_07-常用函数
1 python常用常用函数 1.1 常用内置函数 1.2 类型转换函数 1.3 和操作系统相关的调用 1.3.1 操作举例 1.4 用os ...
- Kafka管理工具介绍
Kafka内部提供了许多管理脚本,这些脚本都放在$KAFKA_HOME/bin目录下,而这些类的实现都是放在源码的kafka/core/src/main/scala/kafka/tools/路径下. ...
- docker 容器创建参数错误记录
sudo docker ps -a -q sudo docker ps -a|cutawk '{print $1}' #删除前八条 sudo docker ps -a -q|head -n |xarg ...
- springcloud工程构建过程
1.概述 2.zookeeper与eureka在CAP理论中的区别 (电商时,应当保证高可用,即最好选用AP) eureka遵守AP zookeeper遵守CP eureka集群,不区分主从节点 zo ...
- mybatis使用原始Dao开发中存在的问题
1.Dao方法存在重复代码:通过SqlSessionFactory创建SqlSession,调用SqlSession的送数据库操作方法. 2.调用SqlSession的数据库需要制定statement ...
- golang之切片
1.切片:切片是数组的一个引用,因此切片是引用类型 2.切片的长度可以改变,因此,切片是个可变的数组. 3.切片遍历方式和数组一样,可以用len()求长度 4.cap可以求出slice最大的容量,0& ...
- openssl详解
openssl详解 摘自:https://blog.csdn.net/liguangxianbin/article/details/79665100 目录 目录 第一章 前言 第二章 证书 第三章 加 ...
- Spring MyBatis Oracle 多数据源
数据源1 <bean id="dataSource1" class="org.apache.commons.dbcp.BasicDataSource"&g ...