Timur Isangulov
Timur Isangulov

Reputation: 21

How make JMeter generate specific request and wait for the specific response

I don't know how to make JMeter generate specific request and wait for the specific response. Could anyone help me? I'm testing web application. There are specific jobs for data calculations. In my case when I run a job, on UI the progress bar is shown and every second I'm getting intermediate server response. The job calculations time could take up to 1-2 hours.

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

Then I need to get "location" from the response, and keep checking every second or so by posting the location string in the request

•   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":[]}}

and keep checking until I get cacheId in response

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

GET RESULTS

Now parse the last response to get cache id and generate another http request

•   REQUEST:
o   GET http:/myserver/web/api/cache/1184/colimp_data
•   RESPONSE:
o   {"columnName":"Type","columns":[
 {"column":"sepalWidth","importance":93.13}]}

Upvotes: 1

Views: 2904

Answers (1)

Dmitri T
Dmitri T

Reputation: 168002

I would go for the following test plan structure:

While Controller Configuration:

  • Put ${__javaScript(vars.get('cacheId')==null,)} in "Condition" input

Regular Expression Extractor Configuration:

  • Reference Name: cacheId
  • Regular Expression: "cacheId":(\d+)
  • Template: $1$

GET RESULTS Configuration:

  • HTTP Request Path: /myserver/web/api/cache/${cacheId}/colimp_data

While Controller will loop and execute "CHECK" request until "cacheID" value will be extracted. Once done - you will be able to use it in "GET RESULTS: request.

Upvotes: 1

Related Questions