[go: up one dir, main page]

Skip to content

A RESTful API server for vegeta, a load testing tool written in Go.

License

Notifications You must be signed in to change notification settings

nitishm/vegeta-server

Repository files navigation

GoDoc Go Report Card Build Status License Coverage Status

Vegeta Server - A RESTful load-testing service

A RESTful API server for vegeta, a load testing tool written in Go.

Vegeta is a versatile HTTP load testing tool built out of a need to drill HTTP services with a constant request rate. The vegeta library is written in Go, which makes it ideal to implement server in Go.

The REST API model enables users to, asynchronously, submit multiple attacks targeting the same (or varied) endpoints, lookup pending or historical reports and update/cancel/re-submit attacks, using a simple RESTful API.

Getting Started

Installing

make all

NOTE: make all resolves all the dependencies, formats the code using gofmt, validates and lints using golangci-lint and golint, builds the vegeta-server binary and drops it in the /bin directory and finally runs tests using go test.

Quick Start

Start the server using the vegeta-server binary generated after the previous step.

Usage: main [<flags>]

Flags:
      --help            Show context-sensitive help (also try --help-long and --help-man).
      --ip="0.0.0.0"  Server IP Address.
      --port="80"     Server Port.
  -v, --version         Version Info
      --debug           Enabled Debug

Example

Serve HTTP traffic at 0.0.0.0:80/api/v1

./bin/vegeta-server --ip=0.0.0.0 --port=80 --debug

Try it out using make run

make run

INFO[0000] creating new dispatcher                       component=dispatcher
INFO[0000] starting dispatcher                           component=dispatcher
INFO[0000] listening                                     component=server ip=0.0.0.0 port=80

Using Docker

Build the docker image using local Dockerfile

docker build .

Run the docker container

docker run -d -p 8000:80 --name vegeta {container id}

You can also build and run a docker container using make

make container_run

NOTE: make container and make container_clean can be used to build the Dockerfile and delete the container and image.

Running tests

make test

Documentation

Contributing

Link to CONTRIBUTING.md

Project Structure

  • /: Extraneous setup and configuration files. No go code exists at this level.
  • /cmd/server: Comprises of package main serving as an entry point to the code.
  • /models: Includes the model definitions used by the DB and the API endpoints.
    • /db.go: Provides the storage interface, which is implemented by the configured database.
  • /internal: Internal only packages used by the server to run attacks and serve reports.
    • /dispatcher: Defines and implements the dispatcher interface, with the primary responsibility to carry out concurrent attacks.
    • /reporter: Defines and implements the reporter interface, with the primary responsibility to generate reports from previously completed attacks, in supported formats (JSON/Text/Binary).
    • /endpoints: Responsible for defining and registering the REST API endpoint handlers.
  • /pkg/vegeta: Vegeta library specific, wrapper methods and definitions. (Keep these isolated from the internals of the server, to support more load-testing tools/libraries in the future.)
  • /scripts: Helper installation scripts.

Roadmap

Link to roadmap

License

Link to LICENSE

Support

Contact Author at nitish.malhotra@gmail.com