问题描述
我收到了来自 JMeter 的以下回复:
I have the following response from 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.
I used (?=(?:(?!isf).)*?isf":"1)(?=(?:(?!isl).)*?isl":"0)(?=(?:(?!st).)*?st":"2)"id":"(d+)
regular expression to select the required id.
当我使用 5 个用户运行测试时,在几个测试中,为不同的迭代选择了相同的 ID,导致错误.
When I run the test using 5 users, during few tests same id is selected for different iterations causing error.
我需要让 jmeter 从每次迭代的响应中提取一些独特的值.我怎样才能做到这一点?提前致谢.
I need to make jmeter extract some unique values from response for each iteration.How can I do that? Thanks in advance.
推荐答案
临时解决方案:
在您的Regular Expression Extractor"中,保持Match No."设置.为0"
In your "Regular Expression Extractor", keep the setting "Match No." as "0"
即使很难,ID 也不会是唯一的,但它会随机选择不同的值,而不是再次选择相同的值 &再次.
Even tough the ID's will not be unique but it will randomly select different values rather than selecting same value again & again.
完整的解决方案:
使用 Bean Shell Sampler 将所有有效的ID"写入 第一个线程组" 中的 CSV 文件&然后
在第二个线程组"中,使用为每个请求创建的具有唯一值的 CSV 运行测试.
write all the valid "ID" to CSV file in "1st Thread group" using Bean Shell Sampler& then
In the "2nd Thread Group" run the test using created CSV with unique values for each request.
在分析结果时,您可以忽略第一个线程组.
While analyzing the results you can ignore 1st thread group.
希望这会有所帮助.
这篇关于如何让 jmeter 从每次迭代的响应中选择唯一值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!