artilleryio / artillery

The complete load testing platform. Everything you need for production-grade load tests. Serverless & distributed. Load test with Playwright. Load test HTTP APIs, GraphQL, WebSocket, and more. Use any Node.js module.
https://www.artillery.io
Mozilla Public License 2.0
8.04k stars 511 forks source link

HTTP: file uploads #106

Closed hassy closed 6 years ago

hassy commented 8 years ago

It would be nice to have better support for file uploads.

At the moment, the contents of the file to be uploaded needs to be embedded directly into the Artillery script. It should be possible to reference external files to be read at runtime.

pooolz commented 8 years ago

my team would love for this to be implemented so that we can load test our file uploader using artillery by uploading a file from disc

armand1m commented 7 years ago

+1 on this.

mauris commented 7 years ago

It seems like this requires modification to the HttpEngine in artillery-core repository. Perhaps script can take in a files key of :field => :pathnames. e.g.:

  - post:
    url: "/pets"
    files:
      picture: "/tmp/picture.jpg"
    json:
      name: "Mali"
      species: "dog"

The contents of /tmp/picture.jpg can be read and uploaded in HttpEngine. The code will have to detect the presence of files key and ensure that upload is done in multipart/form-data format.

sosloow commented 6 years ago

Seems, like there was a pull request merged with this feature in the original artillery-core repo https://github.com/shoreditch-ops/artillery-core/pull/148 but it was reverted for some reason.

Can we get some reasoning behind this? Maybe we can update this pull request so it will be ok to merge?

hassy commented 6 years ago

@sosloow that change was reverted because the code did not quite work. More details here: https://github.com/shoreditch-ops/artillery/pull/265

It should be fairly straightforward to re-use some of the code in #265 to create a plugin to add file uploading support to HTTP scenarios. It'd be great if someone spent some time on it and shared the result with the community.

An option for teams that need file uploading functionality that just works today is to use Artillery Pro. It has support for file uploads, both for testing from one machine and when running distributed tests from a cloud cluster (on AWS ECS).

sosloow commented 6 years ago

Thanks for clarification. For now, I found that file uploads via custom scripts are pretty straightforward.

Here's an example someone posted earlier: https://github.com/shoreditch-ops/artillery/issues/320#issuecomment-329448748