我尝试使用标准的jmeter报告模板XSL(jmeter-results-detail-report_21.xsl)生成jmeter报告,但是以某种方式,报告无法将httpSample / httpSample的子子项显示为httpSample的细分。
无论如何,是否将子子项httpSample / httpSample的结果显示为其父项httpSample的细分?
我有一个想法用其父磅值替换子子磅值,以使其唯一。但是,由于我是java / regex / XSL的新手,我该怎么做。
below is original jtl
<sample t="1605" it="15032" lt="0" ct="0" ts="1567595832665" s="true" lb="A02 Landing" rc="200" rm="Number of samples in transaction : 3, number of failing samples : 0" tn="Thread Group 1-1" dt="" by="70695" sby="3136" ng="2" na="2">
<httpSample t="649" it="0" lt="629" ct="440" ts="1567595837679" s="true" lb="A02.01 /abcd/login.action?do=Login" rc="200" rm="OK" tn="Thread Group 1-1" dt="text" by="2094" sby="1671" ng="2" na="2">
<httpSample t="629" it="0" lt="629" ct="440" ts="1567595837679" s="true" lb="https://10.111.11.111:7351/abcd/login.action?do=Login" rc="302" rm="Moved Temporarily" tn="Thread Group 1-1" dt="text" by="856" sby="1001" ng="2" na="2"/>
<httpSample t="18" it="0" lt="18" ct="0" ts="1567595838310" s="true" lb="https://10.111.11.111:7351/abcd/HandlerInit.action?do=Redirect" rc="200" rm="OK" tn="Thread Group 1-1" dt="text" by="1238" sby="670" ng="2" na="2"/>
</httpSample>
<httpSample t="549" it="0" lt="533" ct="137" ts="1567595843333" s="true" lb="A02.02 /abcd/HandlerLogin.action?do=InitLoad" rc="200" rm="OK" tn="Thread Group 1-1" dt="text" by="34332" sby="794" ng="2" na="2"/>
<httpSample t="407" it="0" lt="402" ct="332" ts="1567595848894" s="true" lb="A02.03 /abcd/message_board.action" rc="200" rm="OK" tn="Thread Group 1-1" dt="text" by="34269" sby="671" ng="2" na="2"/>
</sample>
<sample t="5863" it="15038" lt="0" ct="0" ts="1567595835027" s="true" lb="A03 Landing 2" rc="200" rm="Number of samples in transaction : 3, number of failing samples : 0" tn="Thread Group 1-2" dt="" by="70695" sby="3136" ng="2" na="2">
<httpSample t="609" it="0" lt="290" ct="142" ts="1567595840037" s="true" lb="A03.01 /abcd/login.action?do=Login2" rc="200" rm="OK" tn="Thread Group 1-2" dt="text" by="2094" sby="1671" ng="2" na="2">
<httpSample t="290" it="0" lt="290" ct="142" ts="1567595840037" s="true" lb="https://10.111.11.111:7351/abcd/login.action?do=Login2" rc="302" rm="Moved Temporarily" tn="Thread Group 1-2" dt="text" by="856" sby="1001" ng="2" na="2"/>
<httpSample t="318" it="0" lt="318" ct="0" ts="1567595840328" s="true" lb="https://10.111.11.111:7351/abcd/HandlerInit.action?do=Redirect2" rc="200" rm="OK" tn="Thread Group 1-2" dt="text" by="1238" sby="670" ng="2" na="2"/>
</httpSample>
<httpSample t="2064" it="0" lt="1323" ct="342" ts="1567595845660" s="true" lb="A03.02 /abcd/HandlerLogin.action?do=InitLoad" rc="200" rm="OK" tn="Thread Group 1-2" dt="text" by="34332" sby="794" ng="2" na="2"/>
<httpSample t="3190" it="0" lt="1302" ct="333" ts="1567595852737" s="true" lb="A03.03 /abcd/message_board.action" rc="200" rm="OK" tn="Thread Group 1-2" dt="text" by="34269" sby="671" ng="2" na="2"/>
</sample>
expected result as below. It's will be few hundred thousand row need to be replace. Is there any way to replace it?
<sample t="1605" it="15032" lt="0" ct="0" ts="1567595832665" s="true" lb="A02 Landing" rc="200" rm="Number of samples in transaction : 3, number of failing samples : 0" tn="Thread Group 1-1" dt="" by="70695" sby="3136" ng="2" na="2">
<httpSample t="649" it="0" lt="629" ct="440" ts="1567595837679" s="true" lb="A02.01 /abcd/login.action?do=Login" rc="200" rm="OK" tn="Thread Group 1-1" dt="text" by="2094" sby="1671" ng="2" na="2">
<httpSample t="629" it="0" lt="629" ct="440" ts="1567595837679" s="true" lb="A02.01 https://10.111.11.111:7351/abcd/login.action?do=Login" rc="302" rm="Moved Temporarily" tn="Thread Group 1-1" dt="text" by="856" sby="1001" ng="2" na="2"/>
<httpSample t="18" it="0" lt="18" ct="0" ts="1567595838310" s="true" lb="A02.01 https://10.111.11.111:7351/abcd/HandlerInit.action?do=Redirect" rc="200" rm="OK" tn="Thread Group 1-1" dt="text" by="1238" sby="670" ng="2" na="2"/>
</httpSample>
<httpSample t="549" it="0" lt="533" ct="137" ts="1567595843333" s="true" lb="A02.02 /abcd/HandlerLogin.action?do=InitLoad" rc="200" rm="OK" tn="Thread Group 1-1" dt="text" by="34332" sby="794" ng="2" na="2"/>
<httpSample t="407" it="0" lt="402" ct="332" ts="1567595848894" s="true" lb="A02.03 /abcd/message_board.action" rc="200" rm="OK" tn="Thread Group 1-1" dt="text" by="34269" sby="671" ng="2" na="2"/>
</sample>
<sample t="5863" it="15038" lt="0" ct="0" ts="1567595835027" s="true" lb="A03 Landing 2" rc="200" rm="Number of samples in transaction : 3, number of failing samples : 0" tn="Thread Group 1-2" dt="" by="70695" sby="3136" ng="2" na="2">
<httpSample t="609" it="0" lt="290" ct="142" ts="1567595840037" s="true" lb="A03.01 /abcd/login.action?do=Login2" rc="200" rm="OK" tn="Thread Group 1-2" dt="text" by="2094" sby="1671" ng="2" na="2">
<httpSample t="290" it="0" lt="290" ct="142" ts="1567595840037" s="true" lb="A03.01 https://10.111.11.111:7351/abcd/login.action?do=Login2" rc="302" rm="Moved Temporarily" tn="Thread Group 1-2" dt="text" by="856" sby="1001" ng="2" na="2"/>
<httpSample t="318" it="0" lt="318" ct="0" ts="1567595840328" s="true" lb="A03.01 https://10.111.11.111:7351/abcd/HandlerInit.action?do=Redirect2" rc="200" rm="OK" tn="Thread Group 1-2" dt="text" by="1238" sby="670" ng="2" na="2"/>
</httpSample>
<httpSample t="2064" it="0" lt="1323" ct="342" ts="1567595845660" s="true" lb="A03.02 /abcd/HandlerLogin.action?do=InitLoad" rc="200" rm="OK" tn="Thread Group 1-2" dt="text" by="34332" sby="794" ng="2" na="2"/>
<httpSample t="3190" it="0" lt="1302" ct="333" ts="1567595852737" s="true" lb="A03.03 /abcd/message_board.action" rc="200" rm="OK" tn="Thread Group 1-2" dt="text" by="34269" sby="671" ng="2" na="2"/>
</sample>
最佳答案
也许正则表达式不是解决此问题的最佳方法,因为它看起来很复杂。
话虽如此,父母在行的开头有两个空格,“子子”似乎有四个空格,如果需要,可以将其用作左边界,并设计必须的任何表达式,例如:
^\s{2}<httpSample\s+.*?lb="(\S*).*[\r\n]^\s{4}<httpSample\s+.*?lb="([^"]*)"
只是一个例子。
测试
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class re{
public static void main(String[] args){
final String regex = "^\\s{2}<httpSample\\s+.*?lb=\"(\\S*).*[\\r\\n]^\\s{4}<httpSample\\s+.*?lb=\"([^\"]*)\"";
final String string = "<sample t=\"1605\" it=\"15032\" lt=\"0\" ct=\"0\" ts=\"1567595832665\" s=\"true\" lb=\"A02 Landing\" rc=\"200\" rm=\"Number of samples in transaction : 3, number of failing samples : 0\" tn=\"Thread Group 1-1\" dt=\"\" by=\"70695\" sby=\"3136\" ng=\"2\" na=\"2\">\n"
+ " <httpSample t=\"649\" it=\"0\" lt=\"629\" ct=\"440\" ts=\"1567595837679\" s=\"true\" lb=\"A02.01 /abcd/login.action?do=Login\" rc=\"200\" rm=\"OK\" tn=\"Thread Group 1-1\" dt=\"text\" by=\"2094\" sby=\"1671\" ng=\"2\" na=\"2\">\n"
+ " <httpSample t=\"629\" it=\"0\" lt=\"629\" ct=\"440\" ts=\"1567595837679\" s=\"true\" lb=\"https://10.111.11.111:7351/abcd/login.action?do=Login\" rc=\"302\" rm=\"Moved Temporarily\" tn=\"Thread Group 1-1\" dt=\"text\" by=\"856\" sby=\"1001\" ng=\"2\" na=\"2\"/>\n"
+ " <httpSample t=\"18\" it=\"0\" lt=\"18\" ct=\"0\" ts=\"1567595838310\" s=\"true\" lb=\"https://10.111.11.111:7351/abcd/HandlerInit.action?do=Redirect\" rc=\"200\" rm=\"OK\" tn=\"Thread Group 1-1\" dt=\"text\" by=\"1238\" sby=\"670\" ng=\"2\" na=\"2\"/>\n"
+ " </httpSample>\n"
+ " <httpSample t=\"549\" it=\"0\" lt=\"533\" ct=\"137\" ts=\"1567595843333\" s=\"true\" lb=\"A02.02 /abcd/HandlerLogin.action?do=InitLoad\" rc=\"200\" rm=\"OK\" tn=\"Thread Group 1-1\" dt=\"text\" by=\"34332\" sby=\"794\" ng=\"2\" na=\"2\"/>\n"
+ " <httpSample t=\"407\" it=\"0\" lt=\"402\" ct=\"332\" ts=\"1567595848894\" s=\"true\" lb=\"A02.03 /abcd/message_board.action\" rc=\"200\" rm=\"OK\" tn=\"Thread Group 1-1\" dt=\"text\" by=\"34269\" sby=\"671\" ng=\"2\" na=\"2\"/>\n"
+ "</sample>\n"
+ "<sample t=\"5863\" it=\"15038\" lt=\"0\" ct=\"0\" ts=\"1567595835027\" s=\"true\" lb=\"A03 Landing 2\" rc=\"200\" rm=\"Number of samples in transaction : 3, number of failing samples : 0\" tn=\"Thread Group 1-2\" dt=\"\" by=\"70695\" sby=\"3136\" ng=\"2\" na=\"2\">\n"
+ " <httpSample t=\"609\" it=\"0\" lt=\"290\" ct=\"142\" ts=\"1567595840037\" s=\"true\" lb=\"A03.01 /abcd/login.action?do=Login2\" rc=\"200\" rm=\"OK\" tn=\"Thread Group 1-2\" dt=\"text\" by=\"2094\" sby=\"1671\" ng=\"2\" na=\"2\">\n"
+ " <httpSample t=\"290\" it=\"0\" lt=\"290\" ct=\"142\" ts=\"1567595840037\" s=\"true\" lb=\"https://10.111.11.111:7351/abcd/login.action?do=Login2\" rc=\"302\" rm=\"Moved Temporarily\" tn=\"Thread Group 1-2\" dt=\"text\" by=\"856\" sby=\"1001\" ng=\"2\" na=\"2\"/>\n"
+ " <httpSample t=\"318\" it=\"0\" lt=\"318\" ct=\"0\" ts=\"1567595840328\" s=\"true\" lb=\"https://10.111.11.111:7351/abcd/HandlerInit.action?do=Redirect2\" rc=\"200\" rm=\"OK\" tn=\"Thread Group 1-2\" dt=\"text\" by=\"1238\" sby=\"670\" ng=\"2\" na=\"2\"/>\n"
+ " </httpSample>\n"
+ " <httpSample t=\"2064\" it=\"0\" lt=\"1323\" ct=\"342\" ts=\"1567595845660\" s=\"true\" lb=\"A03.02 /abcd/HandlerLogin.action?do=InitLoad\" rc=\"200\" rm=\"OK\" tn=\"Thread Group 1-2\" dt=\"text\" by=\"34332\" sby=\"794\" ng=\"2\" na=\"2\"/>\n"
+ " <httpSample t=\"3190\" it=\"0\" lt=\"1302\" ct=\"333\" ts=\"1567595852737\" s=\"true\" lb=\"A03.03 /abcd/message_board.action\" rc=\"200\" rm=\"OK\" tn=\"Thread Group 1-2\" dt=\"text\" by=\"34269\" sby=\"671\" ng=\"2\" na=\"2\"/>\n"
+ "</sample>";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
输出量
Full match: <httpSample t="649" it="0" lt="629" ct="440" ts="1567595837679" s="true" lb="A02.01 /abcd/login.action?do=Login" rc="200" rm="OK" tn="Thread Group 1-1" dt="text" by="2094" sby="1671" ng="2" na="2">
<httpSample t="629" it="0" lt="629" ct="440" ts="1567595837679" s="true" lb="https://10.111.11.111:7351/abcd/login.action?do=Login"
Group 1: A02.01
Group 2: https://10.111.11.111:7351/abcd/login.action?do=Login
Full match: <httpSample t="609" it="0" lt="290" ct="142" ts="1567595840037" s="true" lb="A03.01 /abcd/login.action?do=Login2" rc="200" rm="OK" tn="Thread Group 1-2" dt="text" by="2094" sby="1671" ng="2" na="2">
<httpSample t="290" it="0" lt="290" ct="142" ts="1567595840037" s="true" lb="https://10.111.11.111:7351/abcd/login.action?do=Login2"
Group 1: A03.01
Group 2: https://10.111.11.111:7351/abcd/login.action?do=Login2
如果您想探索/简化/修改表达式,它已经
在右上角的面板上进行了说明
regex101.com。如果您愿意,
也可以在this link中观看它的匹配方式
针对一些样本输入。