如何让jmeter从每次迭代的响应中选择唯一值

时间:2014-09-30 08:52:50

标签: jmeter

我得到了JMeter的以下回复:

{"tot_cnt":{"tc":"41651","rpp":"100","pdid":"1594"},"mg":[{"id":"683","rsd":"6-May-13 \/ 6-May-13","col":"black","cc":"c_197","pn":"old_NEXUS MARKETING CAMPAIGNS-PERMANENT","loc":"PTD - 07 \/ 18 \/ BX","isf":"1","isl":"0","tq":"180","pi":"0","st":"2","dsid":"527","cid":"1917","iq":"0","wid":"WI\/txq8xa56","inv":null,"rbp":"0","pdid":"106","di":"0","pl":"0","spl":null},{"id":"17670","rsd":"6-Jun-13 \/ 6-Jun-13","col":"black","cc":"c_197","pn":"old_NEXUS MARKETING CAMPAIGNS-PERMANENT","loc":"PTD - 07 \/ 18 \/ BX","isf":"1","isl":"0","tq":"180","pi":"0","st":"2","dsid":"527","cid":"1917","iq":"0","wid":"WI\/ckwu5qe8","inv":null,"rbp":"0","pdid":"106","di":"0","pl":"0","spl":null},{"id":"22","rsd":"22-Jul-13 \/ 22-Jul-13","col":"black","cc":"c_1884","pn":"old_THE ORTHODONTIC CLINC","loc":"15 - 34 \/ 0N \/ RS","isf":"1","isl":"1","tq":"1","pi":"0","st":"2","dsid":"15","cid":"1992","iq":"0","wid":"WI\/tldj53ky","inv":null,"rbp":"0","pdid":"1582","di":"0","pl":"0","spl":null},{"id":"686","rsd":"29-Jul-13 \/ 29-Jul-13","col":"black","cc":"c_197","pn":"old_NEXUS MARKETING CAMPAIGNS-PERMANENT","loc":"PTD - 07 \/ 18 \/ BX","isf":"1","isl":"0","tq":"180","pi":"0","st":"2","dsid":"527","cid":"1917","iq":"0","wid":"WI\/n4olde1g","inv":null,"rbp":"0","pdid":"107","di":"0","pl":"0","spl":null},{"id":"73","rsd":"5-Aug-13 \/ 5-Aug-13","col":"black","cc":"c_2357","pn":"old_KCA DEATAG","loc":"338 - 34 \/ 0N \/ RS","isf":"1","isl":"1","tq":"1","pi":"0","st":"2","dsid":"338","cid":"1914","iq":"0","wid":"WI\/zdqbx1zx","inv":null,"rbp":"0","pdid":"1578","di":"0","pl":"0","spl":null},{"id":"137","rsd":"5-Aug-13 \/ 5-Aug-13","col":"black","cc":"c_1219","pn":"old_TYPHOO - J01-TYPHOO- JULY 2013","loc":"56 - 24 \/ 81 \/ L3","isf":"1","isl":"0","tq":"2","pi":"0","st":"2","dsid":"56","cid":"2090","iq":"0","wid":"WI\/azdtc77c","inv":null,"rbp":"0","pdid":"1086","di":"0","pl":"0","spl":null},{"id":"70","rsd":"12-Aug-13 \/ 12-Aug-13","col":"black","cc":"c_2394","pn":"old_SKF UK LTD","loc":"338 - 34 \/ 0N \/ RS","isf":"1","isl":"1","tq":"1","pi":"0","st":"2","dsid":"338","cid":"1914","iq":"0","wid":"WI\/45uzkvp3","inv":null,"rbp":"0","pdid":"1556","di":"0","pl":"0","spl":null},{"id":"1253","rsd":"12-Aug-13 \/ 12-Aug-13","col":"black","cc":"c_2349","pn":"old_JUST TILES","loc":"PTD - 34 \/ 0M \/ MR","isf":"1","isl":"0","tq":"1","pi":"0","st":"2","dsid":"528","cid":"1955","iq":"0","wid":"WI\/ofunwm5s","inv":null,"rbp":"0","pdid":"1559","di":"0","pl":"0","spl":null},{"id":"1320","rsd":"12-Aug-13 \/ 12-Aug-13","col":"black","cc":"c_2073","pn":"old_NEW COLLEGE SWINDON SUMMER CAMPAIGN","loc":"PTD - 34 \/ 0N \/ RS","isf":"1","isl":"0","tq":"1","pi":"0","st":"2","dsid":"528","cid":"1955","iq":"0","wid":"WI\/gpp1dejn","inv":null,"rbp":"0","pdid":null,"di":"0","pl":"0","spl":null},{"id":"27","rsd":"19-Aug-13 \/ 19-Aug-13","col":"black","cc":"c_2138","pn":"old_WIRED STUDIO PEAK MEGA REAR","loc":"15 - 34 \/ 0N \/ RS","isf":"1","isl":"1","tq":"1","pi":"0","st":"2","dsid":"15","cid":"1992","iq":"0","wid":"WI\/b5m0iyuc","inv":null,"rbp":"0","pdid":"1597","di":"0","pl":"0","spl":null},{"id":"561","rsd":"19-Aug-13 \/ 19-Aug-13","col":"black","cc":"c_3737","pn":"old_LONDON ROAD BRIDGE SCHEME DERBY CITY COUNCIL","loc":"PTD - 83 \/ 4I \/ WB","isf":"1","isl":"0","tq":"1","pi":"0","st":"2","dsid":"527","cid":"1917","iq":"0","wid":"WI\/1s1xaqxw","inv":null,"rbp":"0","pdid":"2574","di":"0","pl":"0","spl":null}

我使用(?=(?:(?!isf).)*?isf":"1)(?=(?:(?!isl).)*?isl":"0)(?=(?:(?!st).)*?st":"2)"id":"(\d+)正则表达式来选择所需的id。

当我使用5个用户运行测试时,在少数测试中,为不同的迭代选择相同的id导致错误。

我需要让jmeter从每次迭代的响应中提取一些唯一值。 我怎样才能做到这一点?提前致谢。

1 个答案:

答案 0 :(得分:1)

临时解决方案:

在您的"正则表达式提取器"中,保持设置"匹配编号" as" 0"

即使很难,ID也不会是唯一的,但它会随机选择不同的值而不是再次选择相同的值。再次。

完整解决方案:

写下所有有效的" ID"使用Bean Shell Sampler在" 1st Thread group" 中的CSV文件 &安培;然后
"第二个线程组" 中使用创建的CSV运行测试,每个请求都包含唯一值。

在分析结果时,您可以忽略第一个线程组。

希望这会有所帮助。