Trunks is a lightweight, template-based load testing tool built upon vegeta. Trunks combined the power of Vegeta and Golang Template to generate randomized data, mimics the pattern of real-life traffic.
If you like my work, consider buy me a coffee :D
Please checkout Release page
You need go
installed and GOBIN
in your PATH
. Once that is done, run the command:
$ go get -u github.com/vanhtuan0409/trunks
$ trunks -rate 10 -duration 20 -target targets.sample.yml | vegeta report
Usage of trunks:
-debug string
Write debug log to file (default discard)
-duration int
Duration to run the request (in seconds)
-output string
Output file (default "stdout")
-rate int
Request per second to send (default 5)
-target string
Targets config file path (default "targets.yml")
Specifies the path of debug log file. It defauls to be discarded (/dev/null
)
Specifies the amount of time to issue request to the targets. The internal concurrency structure's setup has this value as a variable. The actual run time of the test can be longer than specified due to the responses delay. Use 0 for an infinite attack.
Specifies the output file to which the binary results will be written to. Made to be piped to the report command input. Defaults to stdout.
For more details about load test analytics, please refer to vegeta attack
Specifies the request rate per time unit to issue against the targets. The actual request rate can vary slightly due to things like garbage collection, but overall it should stay very close to the specified. If no time unit is provided, 1s is used.
Specifies the file config for targets. Refer to Targets format
meta:
headers:
Accept: application/json
targets:
- url: "http://localhost:8080/api1?lat={{ randNumeric 3 }}&long={{ randNumeric 3 }}"
method: GET
repeat: 2
headers:
Authorization: "Bearer xxx"
- url: "http://localhost:8080/api2?token={{ randAlphaNum 12 }}"
method: POST
repeat: 3
body: |
{
"timestamp": {{ now | unixEpoch }},
}
Go template functions are powered by Sprig
Specifies common Header for all targets. Not allow templating
Specifies target URL for load test request. Allow templating
Specifies HTTP Method for load test request.
Specifies HTTP Body for load test request. Allow templating and only taken into affect when Method is not GET
Request-specific headers, will override meta.headers
if duplicated.
Number of repeated time for a request (default to 1). Used for balancing request distribution among apis