Skip to content

Commit 01b64ad

Browse files
authored
Merge pull request goadapp#121 from cwaltken-edrans/104-create-a-pull-request-for-homebrew
Improve makefile to prepare for submission of hombrew recipe
2 parents 2099508 + 4fef50d commit 01b64ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+15820
-249
lines changed

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
dist: trusty
2-
sudo: false
2+
sudo: required
33

44
language: go
5+
go_import_path: github.com/goadapp/goad
56

67
go:
7-
- 1.6
8+
- 1.8
9+
10+
install:
11+
- go get github.com/jteeuwen/go-bindata/...
812

913
script:
14+
- make test
1015
- make all-zip
1116

1217
deploy:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.8
1+
FROM golang:1.8.1-stretch
22

33
RUN apt-get update
44
RUN apt-get install -y zip

Godeps/Godeps.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 78 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,94 @@
1+
SHELL := /bin/bash
2+
3+
# name of the binary created
4+
TARGET := goad
5+
6+
# Prepend our vendor directory to the system GOPATH
7+
# so that import path resolution will prioritize
8+
# our third party snapshots.
9+
GOPATH := ${PWD}/vendor:${GOPATH}
10+
export GOPATH
11+
12+
# These will be provided to the target
13+
VERSION := 1.3.0
14+
BUILD := `git rev-parse HEAD`
15+
16+
# Timestamp of last commit to allow for reproducable builds
17+
TIMESTAMP := `git log -1 --date=format:%Y%m%d%H%M --pretty=format:%cd`
18+
19+
# Use linker flags to provide version/build settings to the target
20+
LDFLAGS = -ldflags "-X=github.com/goadapp/goad/version.version=$(VERSION) -X=github.com/goadapp/goad/version.build=$(BUILD)"
21+
22+
# go source files, ignore vendor directory
23+
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
24+
25+
# go source folders to test
26+
TEST = $(shell go list ./... | grep -v /vendor/)
27+
28+
# $(GO-BUILD) command
29+
GO-BUILD = go build $(LDFLAGS)
30+
31+
# $(ZIP) command ignoring timestamps and using UTC timezone
32+
ZIP = TZ=UTC zip -jrX
33+
34+
.PHONY: lambda bindata clean all-zip all linux osx windows check fmt test install uninstall
35+
136
all: osx linux windows
237

3-
test:
4-
go test ./...
38+
test: bindata
39+
@go test $(TEST)
540

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

1046
bindata: lambda
11-
go get github.com/jteeuwen/go-bindata/...
12-
go-bindata -nocompress -pkg infrastructure -o infrastructure/bindata.go data/lambda.zip
47+
@go get -u github.com/jteeuwen/go-bindata/...
48+
@go-bindata -modtime $(TIMESTAMP) -nocompress -pkg infrastructure -o infrastructure/bindata.go data/lambda.zip
1349

1450
linux: bindata
15-
GOOS=linux GOARCH=amd64 go build -o ./build/linux/x86-64/goad ./cli
16-
GOOS=linux GOARCH=386 go build -o ./build/linux/x86/goad ./cli
51+
@GOOS=linux GOARCH=amd64 $(GO-BUILD) -o build/linux/x86-64/$(TARGET)
52+
@GOOS=linux GOARCH=386 $(GO-BUILD) -o build/linux/x86/$(TARGET)
1753

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

2157
windows: bindata
22-
GOOS=windows GOARCH=amd64 go build -o ./build/windows/x86-64/goad ./cli
23-
GOOS=windows GOARCH=386 go build -o ./build/windows/x86/goad ./cli
58+
@GOOS=windows GOARCH=amd64 $(GO-BUILD) -o build/windows/x86-64/$(TARGET)
59+
@GOOS=windows GOARCH=386 $(GO-BUILD) -o build/windows/x86/$(TARGET)
2460

2561
clean:
26-
rm -rf data/lambda/goad-lambda
27-
rm -rf data/lambda.zip
28-
rm -rf build
62+
@rm -rf data/lambda/goad-lambda
63+
@rm -rf data/lambda.zip
64+
@rm -rf build
65+
@rm -rf infrastructure/bindata.go
66+
67+
build: bindata
68+
@$(GO-BUILD) $(LDFLAGS) -o build/$(TARGET)
69+
70+
install: bindata
71+
@go install $(LDFLAGS)
72+
73+
uninstall: clean
74+
@go clean -i
75+
76+
fmt:
77+
@gofmt -l -w $(SRC)
78+
79+
simplify:
80+
@gofmt -s -l -w $(SRC)
81+
82+
check:
83+
@test -z $(shell gofmt -l main.go | tee /dev/stderr) || echo "[WARN] Fix formatting issues with 'make fmt'"
84+
@for d in $$(go list ./... | grep -v /vendor/); do golint $${d}; done
85+
@go tool vet ${SRC}
2986

3087
all-zip: all
31-
mkdir ./build/zip
32-
zip -jr ./build/zip/goad-osx-x86-64 ./build/osx/x86-64/goad
33-
zip -jr ./build/zip/goad-linux-x86-64 ./build/linux/x86-64/goad
34-
zip -jr ./build/zip/goad-linux-x86 ./build/linux/x86/goad
35-
zip -jr ./build/zip/goad-windows-x86-64 ./build/windows/x86-64/goad
36-
zip -jr ./build/zip/goad-windows-x86 ./build/windows/x86/goad
37-
38-
.PHONY: lambda bindata
88+
@mkdir -p ./build/zip
89+
@find build -exec touch -t $(TIMESTAMP) {} \; # strip timestamp
90+
@$(ZIP) ./build/zip/goad-osx-x86-64 ./build/osx/x86-64/goad
91+
@$(ZIP) ./build/zip/goad-linux-x86-64 ./build/linux/x86-64/goad
92+
@$(ZIP) ./build/zip/goad-linux-x86 ./build/linux/x86/goad
93+
@$(ZIP) ./build/zip/goad-windows-x86-64 ./build/windows/x86-64/goad
94+
@$(ZIP) ./build/zip/goad-windows-x86 ./build/windows/x86/goad

README.md

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,29 +62,71 @@ Goad will read your credentials from `~/.aws/credentials` or from the `AWS_ACCES
6262

6363
```sh
6464
# Get help:
65-
$ goad -h
66-
Usage of goad:
67-
-c uint
68-
number of concurrent requests (default 10)
69-
-m string
70-
HTTP method (default "GET")
71-
-n uint
72-
number of total requests to make (default 1000)
73-
-r string
74-
AWS regions to run in (comma separated, no spaces) (default "us-east-1")
75-
-t uint
76-
request timeout in seconds (default 15)
77-
-u string
78-
URL to load test (required)
79-
-H string
80-
HTTP Header to add to the request. This option can be set multiple times.
65+
$ goad --help
66+
usage: goad [<flags>] <url>
67+
68+
An AWS Lambda powered load testing tool
69+
70+
Flags:
71+
-h, --help Display usage information (this message)
72+
-n, --requests=1000 Number of requests to perform. Set to 0 in
73+
combination with a specified timelimit allows
74+
for unlimited requests for the specified time.
75+
-c, --concurrency=10 Number of multiple requests to make at a time
76+
-t, --timelimit=3600 Seconds to max. to spend on benchmarking
77+
-s, --timeout=15 Seconds to max. wait for each response
78+
-H, --header=HEADER ... Add Arbitrary header line, eg.
79+
'Accept-Encoding: gzip' (repeatable)
80+
--region=us-east-1... ... AWS regions to run in. Repeat flag to run in
81+
more then one region. (repeatable)
82+
--output-json=OUTPUT-JSON Optional path to file for JSON result storage
83+
-m, --method="GET" HTTP method
84+
--body=BODY HTTP request body
85+
-V, --version Show application version.
86+
87+
Args:
88+
<url> [http[s]://]hostname[:port]/path optional if defined in goad.ini
8189

8290
# For example:
8391
$ goad -n 1000 -c 5 -u https://example.com
8492
```
8593
8694
Note that sites such as https://google.com that employ redirects cannot be tested correctly at this time.
8795
96+
### Settings
97+
98+
Goad supports to load settings stored in an ini file. It looks
99+
for a goad.ini file in the current working directory. Flags set on the command-line will
100+
be overwrite these settings.
101+
102+
```ini
103+
[general]
104+
#url = http://example.com/
105+
timeout = 3600
106+
concurrency = 10
107+
requests = 1000
108+
timelimit = 15
109+
json-output = test-result.json
110+
method = GET
111+
body = Hello world
112+
113+
[regions]
114+
us-east-1 ;N.Virginia
115+
#us-east-2 ;Ohio
116+
#us-west-1 ;N.California
117+
#us-west-2 ;Oregon
118+
eu-west-1 ;Ireland
119+
#eu-central-1 ;Frankfurt
120+
#ap-southeast-1 ;Singapore
121+
#ap-southeast-2 ;Tokio
122+
#ap-northeast-1 ;Sydney
123+
#ap-northeast-2 ;Seoul
124+
125+
[headers]
126+
cache-control: no-cache
127+
auth-token: YOUR-SECRET-AUTH-TOKEN
128+
```
129+
88130
## How it works
89131
90132
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**.
@@ -94,7 +136,7 @@ Goad takes full advantage of the power of Amazon Lambdas and Go's concurrency fo
94136
Running Goad will create the following AWS resources:
95137
96138
- An IAM Role for the lambda function.
97-
- An IAM Role Policy that allows the lambda function to send messages to SQS and publish logs.
139+
- 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.
98140
- A lambda function.
99141
- An SQS queue for the test.
100142
@@ -136,6 +178,7 @@ See the LICENSE file for more details.
136178
[Termbox]: https://github.com/nsf/termbox-go
137179
[UUID]: https://github.com/satori/go.uuid
138180
[bindata]: https://github.com/jteeuwen/go-bindata
181+
[toml]: https://github.com/toml-lang/toml
139182
140183
[Gopher Gala]: http://gophergala.com/
141184
[Joao Cardoso]: https://twitter.com/jcxplorer

0 commit comments

Comments
 (0)