giltene / wrk2

A constant throughput, correct latency recording variant of wrk
Apache License 2.0
4.24k stars 382 forks source link

send advanced http request and capture response using wrk/wrk2 #23

Open mpabbidi opened 8 years ago

mpabbidi commented 8 years ago

Hi I am trying to use wrk to soak my REST API interface in a product. As part of the I am trying to send the wrk request for the below request (given at the bottom). I am not able to set the –d options properly via json file or wrk array. Will you be able to provide me proper wrk array format or Jason format. I am NOT planning to use docker. As my server is not standalone web server. Its part of the product.

also I want to see the response to validate it.

Appreciate any help. Thanks M Curl request taht want to send via wrk. curl -k -i -d '{"jsonrpc":"2.0","id":101,"method":"ProvisionSubscriberInfo", "params":{"info": {"thing1": "@object_1"},"subId": 911}}' -X POST https://TPC-D7-07-001.phaedrus.sandvine.com/policyengine/v1/functions/ -H 'Authorization:

suni1mp commented 7 years ago

Hi @mpabbidi ,

did you figure out the above option with wrk ? , if so request you share the steps

Thanks

GrayedFox commented 7 years ago

Also interested in learning how to send a JSON type body with wrk...

wandenberg commented 7 years ago

@suni1mp and @GrayedFox you can write a lua script and configure the wrk.body and wrk.headers. something like

wrk.headers["Content-Type"] = "application/json"
wrk.body = '{"my":"json"}'

or in a dynamic way

request = function()
wrk.format(method, path, headers, body)
    -- you can create the values dynamically here using lua
    return wrk.format('POST','/resource/path', {["Content-Type"]= "application/json"}, '{"my":"json"}')
end

I got this information from here It also recommends for performance to create your requests first if they have a lot of logic.

GrayedFox commented 7 years ago

Thanks man will give that a go when I'm next doing some stress testing

rex-remind101 commented 3 years ago

@wandenberg should {"Content-Type": "application/json"} actually be {["Content-Type"]= "application/json"}?

wandenberg commented 3 years ago

Correct @rex-remind101 Thanks for noticing. I edited the example to make it easier.