Domanda

The request for our service looks something like this:

GET http://[SERVICE]/Node:[id].Build?format=mime1,mime2,...,mimeN&template-id=[templateid]
Accept: multipart/mixed
Content-Type: application/json
body: json document

I am attempting to use ApacheBench to test benchmark this. Here is the call I am using:

ab -n 10 -c 2 -T 'application/json' -H 'Accept: multipart/mixed' 'http://phx5qa01c-02b0.stratus.phx.qa.ebay.com/.Build?format=text/html,text/plain&template-id=29b1468f-c8c3-db23-2f6f-74e112795540'

This call goes through, and results in an error since the expected json data is not there.Is there a way in ab to supply the necessary json along with this request. I see there are -p and -u commands to specify an input file, but those are for puts and posts.

È stato utile?

Soluzione

I realize that this answer is six years late, but I think it is worth posting since I was banging my head against a wall on a very similar issue to this, in which I was trying to load test a URL which returned only JSON data, and my solution might help other readers encountering this issue. My issue was I kept specifying the -H option when I didn't need to. That kept making the server to send back an HTTP 406 response code (Not Acceptable) to my AB request. During most of my my troubleshooting, I had also kept -T 'application/json' in the AB request as well when I didn't need it. That is only used in conjunction with PUTs or POSTs (when using the -p switch). So I removed -H, and -T, and it worked. All that said, I see those two issues here. We need to be mindful that AB uses the GET method by default.

  1. You are constraining AB by appending extra custom headers to the request, by using the -H option: -H 'Accept: multipart/mixed', which might make your target server think it's an invalid request and stop the sequence right then and there. Just don't use -H unless you have a really good reason why.

  2. You are using the -T option: -T 'application/json' which only works when you specify that in conjunction with -p and you don't have -p anywhere in your command, which you don't want to use anyway since you are sending a GET and not a PUT or a POST.

So to fix this, simply remove both the -T and -H options, and it should work. Reminder to other readers: If on Windows, enclose the URL in double-quotes whenever it contains special characters like a "&", or a "?", as in this case.

ab -n 10 -c 2 'http://phx5qa01c-02b0.stratus.phx.qa.ebay.com/.Build?format=text/html,text/plain&template-id=29b1468f-c8c3-db23-2f6f-74e112795540'
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top