我不知道如何让JMeter生成特定请求并等待特定响应。谁能帮助我? 我正在测试Web应用程序。有特定的数据计算工作。 在我的情况下,当我运行一个作业时,在UI上显示进度条,每一秒我都得到中间服务器响应。 工作计算时间可能需要1-2个小时。
SUBMIT
• REQUEST:
o POST POST "https:/myserver/web/api/datasets/684/cluster?viz-id=9242"
with payload in json: {"dbType":"unit","columnName":"Type", "version":0,"useWeight":false, "weightColumnName":"", "useWeightAsAttribute":false, "extraAttributes":9, "ignoreColumns":[]}
• RESPONSE:
o {"message":"Ok","result":{"location":"http:/localhost:8000/async/result/340"}}
CHECK
然后我需要得到" location"从响应中,通过发布位置字符串每隔一秒左右检查一次 在请求中
• REQUEST:
o "https:/myserver/web/api/datasets/job-status"
with payload as string "http:/localhost:8000/async/result/340"
• RESPONSE:
o {"message":"Ok","result":{"jobId":"340","status":"IN_PROGRESS","taskList":[]}}
并继续检查,直到我得到cacheId作为回应
• REQUEST:
o POST "https:/myserver/web/api/datasets/job-status
with payload as string "http:/localhost:8000/async/result/340"
• RESPONSE:
o {"message":"Ok","result":{"colimp_data":"web-340.colimp.data","cacheId":1184}}
获得结果
现在解析最后一个响应以获取缓存ID并生成另一个http请求
• REQUEST:
o GET http:/myserver/web/api/cache/1184/colimp_data
• RESPONSE:
o {"columnName":"Type","columns":[
{"column":"sepalWidth","importance":93.13}]}
答案 0 :(得分:1)
我会选择以下测试计划结构:
控制器配置:
${__javaScript(vars.get('cacheId')==null,)}
放入"条件"输入正则表达式提取器配置:
cacheId
"cacheId":(\d+)
$1$
获得结果配置:
/myserver/web/api/cache/${cacheId}/colimp_data
当Controller将循环并执行" CHECK"请求" cacheID"将提取值。完成后 - 您将能够在" GET RESULTS:request中使用它。