taurus body-file support for non-ascii

225 views
Skip to first unread message

Srinivas Narayanan

unread,
Apr 23, 2018, 4:51:28 AM4/23/18
to codename-taurus
I am trying to run a performance test scenario where the body of a POST request is binary (office document file) in nature. 

requests:
- url: files/213123/contents
method: POST
headers:
Accept: "*/*"
content-type: "application/octet-stream"
body-file: mockServers/simpleWebServer/some.docx

I had first tried with gatling executor but I don't think the executor is able to handle the `body-file` construct. So I switched to jmeter. Still I got the following error:

14:16:34 WARNING: Failed to set body: Traceback (most recent call last):
  File "/Users/snarayanan/play/taurus/gatling/taurus_2/lib/python2.7/site-packages/bzt/jmx/base.py", line 328, in __add_body_from_string
    header.append(JMX._string_prop("Argument.value", body))
  File "/Users/snarayanan/play/taurus/gatling/taurus_2/lib/python2.7/site-packages/bzt/jmx/base.py", line 423, in _string_prop
    res.text = text_type(value)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf8 in position 14: ordinal not in range(128)

Can we not send a binary file as body? I don't think I can use the `upload-files` technique since that works with multipart and this API is not expecting a multipart request. I just expects the request body to be binary in nature. Is it possible to make this work with Jmeter? If so please let us know. Also please let us know if we can do something for this with the gatling executor.

Thanks,
~ Srini





Srinivas Narayanan

unread,
Apr 23, 2018, 5:25:37 AM4/23/18
to codename-taurus
Looks like I am able to use the `upload-files` technique. I tried it based on this post - https://stackoverflow.com/questions/41862223/making-post-request-to-a-restful-api-with-binary-body-using-jmeter . The catch is that I have to give a param name otherwise taurus does not allow me to proceed. So I filled it up like this:

requests:
- url: files/213123/contents
method: POST
headers:
Accept: "*/*"
content-type: "application/octet-stream"
upload-files:
- param: body
path: mockServers/simpleWebServer/some.docx

The param name could be anything (I tried just sending "a" and it still seemed to work. The only problem seems to be that the uploaded file does not seem to be complete in nature. It shows as corrupted when I try to open it. MS Word is able to recover it when asked but I am not sure why this happens at the first place. Is it something to do with how taurus streams the file to service? Or do you think the problem is with my service? Please share your thoughts.

Thanks,
~ Srini

Dmitri Pribysh

unread,
Apr 23, 2018, 5:33:04 AM4/23/18
to codenam...@googlegroups.com

Hello,

Thanks for reporting this Python2 file encoding-related crash. We consider it as a bug that needs to be fixed.

Can you attach two versions of this file (first one is the file before uploading, the second one is the uploaded file)? This way we can compare them and figure out if there were any modifications to file on Taurus/JMeter side.


  Dimitri
--
You received this message because you are subscribed to the Google Groups "codename-taurus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codename-taur...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codename-taurus/7f7cc57d-a344-4624-8c84-67e90e53e3a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Srinivas Narayanan

unread,
Apr 24, 2018, 7:43:57 AM4/24/18
to codename-taurus
Hi Dimitri,
The files are really word document files. I am attaching the before upload one (some.docx) and after upload one. You can probably take a look and see.

Thanks,
~ Srini
1524570079773.docx
some.docx

Srinivas Narayanan

unread,
Apr 24, 2018, 7:46:11 AM4/24/18
to codename-taurus
The after upload one shows as corrupt but if we allow the MS word to recover it, it gets the content right. Just some additional information to you.

Another question which I asked above is if Taurus gatling executor has support for file upload? I could not see if there is support so wanted to check.

Thanks,
~ Srini

Dmitri Pribysh

unread,
Apr 25, 2018, 9:59:29 AM4/25/18
to Srinivas Narayanan, codename-taurus

The file after upload has a mutlipart form wrappings, which were added by using `upload-files`. Usually the backend server gets rid of them when it's handling a POST request, but in your case it didn't.

So it looks like you can't use `upload-files`, as your server won't understand `multipart/form-data` requests. That means you can grab a JMX generated by Taurus in the early runs (look for `modified_requests.jmx` file in the artifacts dir) and set up a POST request manually. And then run resulting JMX with Taurus.


  Dimitri


So it looks like you can't use upload-files, as it
Reply all
Reply to author
Forward
0 new messages