Skip to content
This repository has been archived by the owner on Aug 17, 2020. It is now read-only.

Commit

Permalink
Merge pull request #121 from cwaltken-edrans/104-create-a-pull-reques…
Browse files Browse the repository at this point in the history
…t-for-homebrew

Improve makefile to prepare for submission of hombrew recipe
  • Loading branch information
zeph authored May 2, 2017
2 parents 2099508 + 4fef50d commit 01b64ad
Show file tree
Hide file tree
Showing 76 changed files with 15,820 additions and 249 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
dist: trusty
sudo: false
sudo: required

language: go
go_import_path: github.com/goadapp/goad

go:
- 1.6
- 1.8

install:
- go get github.com/jteeuwen/go-bindata/...

script:
- make test
- make all-zip

deploy:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.8
FROM golang:1.8.1-stretch

RUN apt-get update
RUN apt-get install -y zip
Expand Down
17 changes: 17 additions & 0 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 78 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,94 @@
SHELL := /bin/bash

# name of the binary created
TARGET := goad

# Prepend our vendor directory to the system GOPATH
# so that import path resolution will prioritize
# our third party snapshots.
GOPATH := ${PWD}/vendor:${GOPATH}
export GOPATH

# These will be provided to the target
VERSION := 1.3.0
BUILD := `git rev-parse HEAD`

# Timestamp of last commit to allow for reproducable builds
TIMESTAMP := `git log -1 --date=format:%Y%m%d%H%M --pretty=format:%cd`

# Use linker flags to provide version/build settings to the target
LDFLAGS = -ldflags "-X=github.com/goadapp/goad/version.version=$(VERSION) -X=github.com/goadapp/goad/version.build=$(BUILD)"

# go source files, ignore vendor directory
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")

# go source folders to test
TEST = $(shell go list ./... | grep -v /vendor/)

# $(GO-BUILD) command
GO-BUILD = go build $(LDFLAGS)

# $(ZIP) command ignoring timestamps and using UTC timezone
ZIP = TZ=UTC zip -jrX

.PHONY: lambda bindata clean all-zip all linux osx windows check fmt test install uninstall

all: osx linux windows

test:
go test ./...
test: bindata
@go test $(TEST)

lambda:
GOOS=linux GOARCH=amd64 go build -o data/lambda/goad-lambda ./lambda
zip -jr data/lambda data/lambda
@GOOS=linux GOARCH=amd64 $(GO-BUILD) -o data/lambda/goad-lambda ./lambda
@find data/lambda -exec touch -t $(TIMESTAMP) {} \; # strip timestamp
@$(ZIP) data/lambda data/lambda

bindata: lambda
go get github.com/jteeuwen/go-bindata/...
go-bindata -nocompress -pkg infrastructure -o infrastructure/bindata.go data/lambda.zip
@go get -u github.com/jteeuwen/go-bindata/...
@go-bindata -modtime $(TIMESTAMP) -nocompress -pkg infrastructure -o infrastructure/bindata.go data/lambda.zip

linux: bindata
GOOS=linux GOARCH=amd64 go build -o ./build/linux/x86-64/goad ./cli
GOOS=linux GOARCH=386 go build -o ./build/linux/x86/goad ./cli
@GOOS=linux GOARCH=amd64 $(GO-BUILD) -o build/linux/x86-64/$(TARGET)
@GOOS=linux GOARCH=386 $(GO-BUILD) -o build/linux/x86/$(TARGET)

osx: bindata
GOOS=darwin GOARCH=amd64 go build -o ./build/osx/x86-64/goad ./cli
@GOOS=darwin GOARCH=amd64 $(GO-BUILD) -o build/osx/x86-64/$(TARGET)

windows: bindata
GOOS=windows GOARCH=amd64 go build -o ./build/windows/x86-64/goad ./cli
GOOS=windows GOARCH=386 go build -o ./build/windows/x86/goad ./cli
@GOOS=windows GOARCH=amd64 $(GO-BUILD) -o build/windows/x86-64/$(TARGET)
@GOOS=windows GOARCH=386 $(GO-BUILD) -o build/windows/x86/$(TARGET)

clean:
rm -rf data/lambda/goad-lambda
rm -rf data/lambda.zip
rm -rf build
@rm -rf data/lambda/goad-lambda
@rm -rf data/lambda.zip
@rm -rf build
@rm -rf infrastructure/bindata.go

build: bindata
@$(GO-BUILD) $(LDFLAGS) -o build/$(TARGET)

install: bindata
@go install $(LDFLAGS)

uninstall: clean
@go clean -i

fmt:
@gofmt -l -w $(SRC)

simplify:
@gofmt -s -l -w $(SRC)

check:
@test -z $(shell gofmt -l main.go | tee /dev/stderr) || echo "[WARN] Fix formatting issues with 'make fmt'"
@for d in $$(go list ./... | grep -v /vendor/); do golint $${d}; done
@go tool vet ${SRC}

all-zip: all
mkdir ./build/zip
zip -jr ./build/zip/goad-osx-x86-64 ./build/osx/x86-64/goad
zip -jr ./build/zip/goad-linux-x86-64 ./build/linux/x86-64/goad
zip -jr ./build/zip/goad-linux-x86 ./build/linux/x86/goad
zip -jr ./build/zip/goad-windows-x86-64 ./build/windows/x86-64/goad
zip -jr ./build/zip/goad-windows-x86 ./build/windows/x86/goad

.PHONY: lambda bindata
@mkdir -p ./build/zip
@find build -exec touch -t $(TIMESTAMP) {} \; # strip timestamp
@$(ZIP) ./build/zip/goad-osx-x86-64 ./build/osx/x86-64/goad
@$(ZIP) ./build/zip/goad-linux-x86-64 ./build/linux/x86-64/goad
@$(ZIP) ./build/zip/goad-linux-x86 ./build/linux/x86/goad
@$(ZIP) ./build/zip/goad-windows-x86-64 ./build/windows/x86-64/goad
@$(ZIP) ./build/zip/goad-windows-x86 ./build/windows/x86/goad
77 changes: 60 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,71 @@ Goad will read your credentials from `~/.aws/credentials` or from the `AWS_ACCES

```sh
# Get help:
$ goad -h
Usage of goad:
-c uint
number of concurrent requests (default 10)
-m string
HTTP method (default "GET")
-n uint
number of total requests to make (default 1000)
-r string
AWS regions to run in (comma separated, no spaces) (default "us-east-1")
-t uint
request timeout in seconds (default 15)
-u string
URL to load test (required)
-H string
HTTP Header to add to the request. This option can be set multiple times.
$ goad --help
usage: goad [<flags>] <url>

An AWS Lambda powered load testing tool

Flags:
-h, --help Display usage information (this message)
-n, --requests=1000 Number of requests to perform. Set to 0 in
combination with a specified timelimit allows
for unlimited requests for the specified time.
-c, --concurrency=10 Number of multiple requests to make at a time
-t, --timelimit=3600 Seconds to max. to spend on benchmarking
-s, --timeout=15 Seconds to max. wait for each response
-H, --header=HEADER ... Add Arbitrary header line, eg.
'Accept-Encoding: gzip' (repeatable)
--region=us-east-1... ... AWS regions to run in. Repeat flag to run in
more then one region. (repeatable)
--output-json=OUTPUT-JSON Optional path to file for JSON result storage
-m, --method="GET" HTTP method
--body=BODY HTTP request body
-V, --version Show application version.

Args:
<url> [http[s]://]hostname[:port]/path optional if defined in goad.ini

# For example:
$ goad -n 1000 -c 5 -u https://example.com
```
Note that sites such as https://google.com that employ redirects cannot be tested correctly at this time.
### Settings
Goad supports to load settings stored in an ini file. It looks
for a goad.ini file in the current working directory. Flags set on the command-line will
be overwrite these settings.
```ini
[general]
#url = http://example.com/
timeout = 3600
concurrency = 10
requests = 1000
timelimit = 15
json-output = test-result.json
method = GET
body = Hello world
[regions]
us-east-1 ;N.Virginia
#us-east-2 ;Ohio
#us-west-1 ;N.California
#us-west-2 ;Oregon
eu-west-1 ;Ireland
#eu-central-1 ;Frankfurt
#ap-southeast-1 ;Singapore
#ap-southeast-2 ;Tokio
#ap-northeast-1 ;Sydney
#ap-northeast-2 ;Seoul
[headers]
cache-control: no-cache
auth-token: YOUR-SECRET-AUTH-TOKEN
```
## How it works
Goad takes full advantage of the power of Amazon Lambdas and Go's concurrency for distributed load testing. You can use Goad to launch HTTP loads from up to four AWS regions at once. Each lambda can handle hundreds of concurrent connections, we estimate that Goad should be able to achieve peak loads of up to **100,000 concurrent requests**.
Expand All @@ -94,7 +136,7 @@ Goad takes full advantage of the power of Amazon Lambdas and Go's concurrency fo
Running Goad will create the following AWS resources:
- An IAM Role for the lambda function.
- An IAM Role Policy that allows the lambda function to send messages to SQS and publish logs.
- An IAM Role Policy that allows the lambda function to send messages to SQS, to publish logs and to spawn new lambda in case an individual lambda times out on a long running test.
- A lambda function.
- An SQS queue for the test.
Expand Down Expand Up @@ -136,6 +178,7 @@ See the LICENSE file for more details.
[Termbox]: https://github.com/nsf/termbox-go
[UUID]: https://github.com/satori/go.uuid
[bindata]: https://github.com/jteeuwen/go-bindata
[toml]: https://github.com/toml-lang/toml
[Gopher Gala]: http://gophergala.com/
[Joao Cardoso]: https://twitter.com/jcxplorer
Expand Down
Loading

0 comments on commit 01b64ad

Please sign in to comment.