HTTP load generator, ApacheBench (ab) replacement
Go
all: rename the tool to hey, add minor fixes
Jaana Burcu Dogan90614616f30e
diff --git a/LICENSE b/LICENSEindex a4c5efd..20a5aea 100644--- a/LICENSE+++ b/LICENSE@@ -1,4 +1,3 @@-Apache LicenseVersion 2.0, January 2004http://www.apache.org/licenses/@@ -179,7 +178,7 @@APPENDIX: How to apply the Apache License to your work.To apply the Apache License to your work, attach the following- boilerplate notice, with the fields enclosed by brackets "[]"+ boilerplate notice, with the fields enclosed by brackets "{}"replaced with your own identifying information. (Don't includethe brackets!) The text should be enclosed in the appropriatecomment syntax for the file format. We also recommend that a@@ -187,7 +186,7 @@same "printed page" as the copyright notice for easieridentification within third-party archives.- Copyright 2014 Google Inc.+ Copyright {yyyy} {name of copyright owner}Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.@@ -200,3 +199,4 @@WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.+\ No newline at end of filediff --git a/README.md b/README.mdindex c96b183..331d7fe 100644--- a/README.md+++ b/README.md@@ -1,22 +1,31 @@-# boom+# hey[](https://travis-ci.org/rakyll/boom)-Boom is a tiny program that sends some load to a web application. It's similar to Apache Bench ([ab](http://httpd.apache.org/docs/2.2/programs/ab.html)), but with better availability across different platforms and a less troubling installation experience.+hey is a tiny program that sends some load to a web application.+It's similar to Apache Bench ([ab](http://httpd.apache.org/docs/2.2/programs/ab.html)),+but with better availability across different platforms and a less troubling+installation experience if you have [Go](http://golang.org/) installed.-Boom is originally written by Tarek Ziade in Python and is available on [tarekziade/boom](https://github.com/tarekziade/boom). But, due to its dependency requirements and my personal annoyance of maintaining concurrent programs in Python, I decided to rewrite it in Go.+hey was originally called boom and was influnced from Tarek Ziade's+tool at [tarekziade/boom](https://github.com/tarekziade/boom).-## Installation+Using the same name was a mistake as it resulted in cases+where binary name conflicts created confusion.+To preserve the name for its original owner, we renamed this project to hey.-Simple as it takes to type the following command:+## Installation- go get github.com/rakyll/boom+ go get github.com/rakyll/hey## Usage-Boom supports custom headers, request body and basic authentication. It runs provided number of requests in the provided concurrency level, and prints stats.-~~~-Usage: boom [options...] <url>+hey runs provided number of requests in the provided concurrency level and prints stats.++It also supports HTTP2 endpoints.++```+Usage: hey [options...] <url>Options:-n Number of requests to run.@@ -37,64 +46,12 @@ Options:-a Basic authentication, username:password.-x HTTP Proxy address as host:port.+ -h2 Make HTTP/2 requests.+-disable-compression Disable compression.-disable-keepalive Disable keep-alive, prevents re-use of TCPconnections between different HTTP requests.-cpus Number of used cpu cores.- (default for current machine is 1 cores)-~~~--This is what happens when you run Boom:-- % boom -n 1000 -c 100 https://google.com- 1000 / 1000 ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ 100.00 %-- Summary:- Total: 21.1307 secs.- Slowest: 2.9959 secs.- Fastest: 0.9868 secs.- Average: 2.0827 secs.- Requests/sec: 47.3246- Speed index: Hahahaha-- Response time histogram:- 0.987 [1] |- 1.188 [2] |- 1.389 [3] |- 1.590 [18] |∎∎- 1.790 [85] |∎∎∎∎∎∎∎∎∎∎∎- 1.991 [244] |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎- 2.192 [284] |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎- 2.393 [304] |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎- 2.594 [50] |∎∎∎∎∎∎- 2.795 [5] |- 2.996 [4] |-- Latency distribution:- 10% in 1.7607 secs.- 25% in 1.9770 secs.- 50% in 2.0961 secs.- 75% in 2.2385 secs.- 90% in 2.3681 secs.- 95% in 2.4451 secs.- 99% in 2.5393 secs.-- Status code distribution:- [200] 1000 responses--## License--Copyright 2014 Google Inc. All Rights Reserved.--Licensed under the Apache License, Version 2.0 (the "License");-you may not use this file except in compliance with the License.-You may obtain a copy of the License at-- http://www.apache.org/licenses/LICENSE-2.0--Unless required by applicable law or agreed to in writing, software-distributed under the License is distributed on an "AS IS" BASIS,-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.-See the License for the specific language governing permissions and-limitations under the License. -+ (default for current machine is 8 cores)+ -host HTTP Host header.+ ```diff --git a/boom.go b/hey.gosimilarity index 97%rename from boom.gorename to hey.goindex e43b769..ebb40fd 100644--- a/boom.go+++ b/hey.go@@ -12,6 +12,7 @@// See the License for the specific language governing permissions and// limitations under the License.+// Command hey is an HTTP load generator.package mainimport (@@ -24,7 +25,7 @@ import ("runtime""strings"- "github.com/rakyll/boom/boomer"+ "github.com/rakyll/hey/requester")const (@@ -69,7 +70,7 @@ var (proxyAddr = flag.String("x", "", ""))-var usage = `Usage: boom [options...] <url>+var usage = `Usage: hey [options...] <url>Options:-n Number of requests to run.@@ -90,7 +91,7 @@ Options:-a Basic authentication, username:password.-x HTTP Proxy address as host:port.- -h2 Make HTTP/2 requests.+ -h2 Enable HTTP/2.-disable-compression Disable compression.-disable-keepalive Disable keep-alive, prevents re-use of TCP@@ -185,7 +186,7 @@ func main() {req.Host = *hostHeader}- (&boomer.Boomer{+ (&requester.Work{Request: req,RequestBody: *body,N: num,diff --git a/boom_test.go b/hey_test.gosimilarity index 100%rename from boom_test.gorename to hey_test.godiff --git a/boomer/print.go b/requester/print.gosimilarity index 99%rename from boomer/print.gorename to requester/print.goindex 5c68302..6165ac0 100644--- a/boomer/print.go+++ b/requester/print.go@@ -12,7 +12,7 @@// See the License for the specific language governing permissions and// limitations under the License.-package boomer+package requesterimport ("fmt"diff --git a/boomer/boomer.go b/requester/requester.gosimilarity index 94%rename from boomer/boomer.gorename to requester/requester.goindex c165ae1..195732f 100644--- a/boomer/boomer.go+++ b/requester/requester.go@@ -12,8 +12,8 @@// See the License for the specific language governing permissions and// limitations under the License.-// Package boomer provides commands to run load tests and display results.-package boomer+// Package requester provides commands to run load tests and display results.+package requesterimport ("crypto/tls"@@ -37,7 +37,7 @@ type result struct {contentLength int64}-type Boomer struct {+type Work struct {// Request is the request to be made.Request *http.Request@@ -77,7 +77,7 @@ type Boomer struct {// Run makes all the requests, prints the summary. It blocks until// all work is done.-func (b *Boomer) Run() {+func (b *Work) Run() {b.results = make(chan *result, b.N)start := time.Now()@@ -96,7 +96,7 @@ func (b *Boomer) Run() {close(b.results)}-func (b *Boomer) makeRequest(c *http.Client) {+func (b *Work) makeRequest(c *http.Client) {s := time.Now()var size int64var code int@@ -116,7 +116,7 @@ func (b *Boomer) makeRequest(c *http.Client) {}}-func (b *Boomer) runWorker(n int) {+func (b *Work) runWorker(n int) {var throttle <-chan time.Timeif b.Qps > 0 {throttle = time.Tick(time.Duration(1e6/(b.Qps)) * time.Microsecond)@@ -146,7 +146,7 @@ func (b *Boomer) runWorker(n int) {}}-func (b *Boomer) runWorkers() {+func (b *Work) runWorkers() {var wg sync.WaitGroupwg.Add(b.C)diff --git a/boomer/boomer_test.go b/requester/requester_test.gosimilarity index 92%rename from boomer/boomer_test.gorename to requester/requester_test.goindex c3e6f75..69b05a5 100644--- a/boomer/boomer_test.go+++ b/requester/requester_test.go@@ -12,7 +12,7 @@// See the License for the specific language governing permissions and// limitations under the License.-package boomer+package requesterimport ("bytes"@@ -34,12 +34,12 @@ func TestN(t *testing.T) {defer server.Close()req, _ := http.NewRequest("GET", server.URL, nil)- boomer := &Boomer{+ w := &Work{Request: req,N: 20,C: 2,}- boomer.Run()+ w.Run()if count != 20 {t.Errorf("Expected to boom 20 times, found %v", count)}@@ -55,7 +55,7 @@ func TestQps(t *testing.T) {defer server.Close()req, _ := http.NewRequest("GET", server.URL, nil)- boomer := &Boomer{+ w := &Work{Request: req,N: 20,C: 2,@@ -64,11 +64,11 @@ func TestQps(t *testing.T) {wg.Add(1)time.AfterFunc(time.Second, func() {if count > 1 {- t.Errorf("Expected to boom 1 times, found %v", count)+ t.Errorf("Expected to work 1 times, found %v", count)}wg.Done()})- go boomer.Run()+ go w.Run()wg.Wait()}@@ -90,12 +90,12 @@ func TestRequest(t *testing.T) {req, _ := http.NewRequest("GET", server.URL, nil)req.Header = headerreq.SetBasicAuth("username", "password")- boomer := &Boomer{+ w := &Work{Request: req,N: 1,C: 1,}- boomer.Run()+ w.Run()if uri != "/" {t.Errorf("Uri is expected to be /, %v is found", uri)}@@ -122,14 +122,14 @@ func TestBody(t *testing.T) {defer server.Close()req, _ := http.NewRequest("POST", server.URL, bytes.NewBuffer([]byte("Body")))- boomer := &Boomer{+ w := &Work{Request: req,RequestBody: "Body",N: 10,C: 1,}- boomer.Run()+ w.Run()if count != 10 {- t.Errorf("Expected to boom 10 times, found %v", count)+ t.Errorf("Expected to work 10 times, found %v", count)}}