Send multipart/form-data requests with Vegeta
Vegeta is an HTTP load testing tool written in Go.
When sending multipart/form-data requests in the API server benchmark, wrk requires writing lua to send the request. Vegeta could send the request easily without writing any code, so will share how to do it.
vegeta
has the subcommands attack
, report
, and dump
, with attack
sending an HTTP Request.
The -targets
option of vegeta attack
can send HTTP requests flexibly by specifying the text of the request header and request body.
The following is an example of a file to specify for -targets
.
POST http://localhost:8080/api/path
Content-Type: multipart/form-data; boundary=vegetaboundary
@body.txt
@body.txt
is the path to the file where the request body. You can write it as follows:
--vegetaboundary
Content-Disposition: form-data; name="file"; filename="dummy"
Content-Type: application/octet-stream
12345
--vegetaboundary--
Once the file is created, run vegeta attack
.
$ vegeta attack -rate 10 -duration 60s -targets targets.txt
You can send multipart/form-data by writing the request body and request headers in text like this.
Vegeta writes the results of the attack
to a file, and when you pass the data to vegeta report
, it will output a report.
$ vegeta attack ... > load_test.bin
$ cat load_test.bin | vegeta report
You can run it as above.