【问题标题】:How make JMeter generate specific request and wait for the specific response如何让 JMeter 生成特定请求并等待特定响应
【发布时间】:2015-04-22 17:21:17
【问题描述】:

我不知道如何让 JMeter 生成特定的请求并等待特定的响应。谁能帮助我? 我正在测试网络应用程序。数据计算有特定的工作。 就我而言,当我运行作业时,在 UI 上会显示进度条,并且每秒我都会收到中间服务器响应。 作业计算时间可能需要 1-2 小时。

提交

•   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"}}

检查

然后我需要从响应中获取“位置”,并通过发布位置字符串每隔一秒左右检查一次 在请求中

•   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}]}

【问题讨论】:

    标签: jmeter


    【解决方案1】:

    我会选择以下测试计划结构:

    控制器配置时:

    • ${__javaScript(vars.get('cacheId')==null,)} 放入“条件”输入中

    正则表达式提取器配置:

    • 参考名称:cacheId
    • 正则表达式:"cacheId":(\d+)
    • 模板:$1$

    获取结果配置:

    • HTTP 请求路径:/myserver/web/api/cache/${cacheId}/colimp_data

    而控制器将循环并执行“CHECK”请求,直到“cacheID”值被提取。完成后 - 您将能够在“获取结果:请求”中使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-04
      • 1970-01-01
      • 2020-07-23
      • 2019-10-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多