如何等到在 jmeter 中找到响应中的特定单词?

How to wait until specific word is found in response in jmeter?

json 响应是:

{
  "status": 11111,
  "data": {
    "mylist": 
    {
      "1": [
        {
          "id": 1,
          "tId": 11
        }],
    
      "2": [
        {
          "id": 2,
          "tId": 12
        },
        {
          "id": 3,
          "tId": 12
  
        },
        {
          "id": 4,
          "tId": 13,
        }
      ]
}

由于服务器需要时间来显示此响应,我们希望等到看到“1”和“2”下的值。我怎样才能做到这一点?

JMeter HTTP Request Sampler 下载所有数据以标记请求完成。下载后,您可以添加不同类型的断言,例如 JSON 断言、JSR223 断言或响应断言,以验证响应的不同属性。 据我所知,您无法在流式传输/下载数据时达到峰值。

  1. 加 2 JSON Extractors to store the values of id attributes below 1 and 2 into the relevant JMeter Variables

  2. 将整个构造置于While Controller and use the following __groovy() function条件下:

    ${__groovy((vars.get('1_matchNr') ?: 0  as int) == 0 && (vars.get('2_matchNr') ?: 0  as int) == 0,)}
    

  3. 就是这样,JMeter会重复请求,直到mylist下有结果至少包含一个id属性