Skip to content

armgit / hey

Public Imported from GitHub
0

HTTP load generator, ApacheBench (ab) replacement

Go

Renaming commands package.

Burcu Dogan629053fa2bb0
diff --git a/boom.go b/boom.go
index 4e1d5a6..e8a999a 100644
--- a/boom.go
+++ b/boom.go
@@ -24,7 +24,7 @@ import (
"regexp"
"strings"
- "github.com/rakyll/boom/commands"
+ "github.com/rakyll/boom/boomer"
)
var (
@@ -141,8 +141,8 @@ func main() {
usageAndExit("Invalid output type.")
}
- (&commands.Boom{
- Req: &commands.ReqOpts{
+ (&boomer.Boomer{
+ Req: &boomer.ReqOpts{
Method: method,
Url: url,
Body: *flagD,
diff --git a/commands/boom.go b/boomer/boomer.go
similarity index 94%
rename from commands/boom.go
rename to boomer/boomer.go
index 037f6c6..51d5d94 100644
--- a/commands/boom.go
+++ b/boomer/boomer.go
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-// Package provides commands to run load tests and display results.
-package commands
+// Package boomer provides commands to run load tests and display results.
+package boomer
import (
"net/http"
@@ -56,7 +56,7 @@ func (r *ReqOpts) Request() *http.Request {
return req
}
-type Boom struct {
+type Boomer struct {
// Request to make.
Req *ReqOpts
// Total number of requests to make.
diff --git a/commands/print.go b/boomer/print.go
similarity index 99%
rename from commands/print.go
rename to boomer/print.go
index 5a9775e..69942d3 100644
--- a/commands/print.go
+++ b/boomer/print.go
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package commands
+package boomer
import (
"fmt"
diff --git a/commands/run.go b/boomer/run.go
similarity index 95%
rename from commands/run.go
rename to boomer/run.go
index cf9e1fb..ee6c037 100644
--- a/commands/run.go
+++ b/boomer/run.go
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package commands
+package boomer
import (
"crypto/tls"
@@ -24,7 +24,7 @@ import (
"time"
)
-func (b *Boom) Run() {
+func (b *Boomer) Run() {
b.results = make(chan *result, b.N)
if b.Output == "" {
b.bar = newPb(b.N)
@@ -33,7 +33,7 @@ func (b *Boom) Run() {
b.run()
}
-func (b *Boom) worker(ch chan *http.Request) {
+func (b *Boomer) worker(ch chan *http.Request) {
host, _, _ := net.SplitHostPort(b.Req.OriginalHost)
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: b.AllowInsecure, ServerName: host},
@@ -71,7 +71,7 @@ func (b *Boom) worker(ch chan *http.Request) {
}
}
-func (b *Boom) run() {
+func (b *Boomer) run() {
var wg sync.WaitGroup
wg.Add(b.C)
diff --git a/commands/run_test.go b/boomer/run_test.go
similarity index 92%
rename from commands/run_test.go
rename to boomer/run_test.go
index 83bd60d..b1763a2 100644
--- a/commands/run_test.go
+++ b/boomer/run_test.go
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package commands
+package boomer
import (
"io/ioutil"
@@ -32,7 +32,7 @@ func TestN(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(handler))
defer server.Close()
- boom := &Boom{
+ boomer := &Boomer{
Req: &ReqOpts{
Method: "GET",
Url: server.URL,
@@ -40,7 +40,7 @@ func TestN(t *testing.T) {
N: 20,
C: 2,
}
- boom.Run()
+ boomer.Run()
if count != 20 {
t.Errorf("Expected to boom 20 times, found %v", count)
}
@@ -55,7 +55,7 @@ func TestQps(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(handler))
defer server.Close()
- boom := &Boom{
+ boomer := &Boomer{
Req: &ReqOpts{
Method: "GET",
Url: server.URL,
@@ -71,7 +71,7 @@ func TestQps(t *testing.T) {
}
wg.Done()
})
- go boom.Run()
+ go boomer.Run()
wg.Wait()
}
@@ -90,7 +90,7 @@ func TestRequest(t *testing.T) {
header := make(http.Header)
header.Add("Content-type", "text/html")
header.Add("X-some", "value")
- boom := &Boom{
+ boomer := &Boomer{
Req: &ReqOpts{
Method: "PUT",
Url: server.URL,
@@ -101,7 +101,7 @@ func TestRequest(t *testing.T) {
N: 1,
C: 1,
}
- boom.Run()
+ boomer.Run()
if uri != "/" {
t.Errorf("Uri is expected to be /, %v is found", uri)
}
@@ -127,7 +127,7 @@ func TestBody(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(handler))
defer server.Close()
- boom := &Boom{
+ boomer := &Boomer{
Req: &ReqOpts{
Method: "POST",
Url: server.URL,
@@ -136,7 +136,7 @@ func TestBody(t *testing.T) {
N: 10,
C: 1,
}
- boom.Run()
+ boomer.Run()
if count != 10 {
t.Errorf("Expected to boom 10 times, found %v", count)
}
@@ -149,7 +149,7 @@ func TestContentLengthIfExists(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(handler))
defer server.Close()
- boom := &Boom{
+ boomer := &Boomer{
Req: &ReqOpts{
Method: "GET",
Url: server.URL,
@@ -157,10 +157,10 @@ func TestContentLengthIfExists(t *testing.T) {
N: 10,
C: 1,
}
- boom.Run()
+ boomer.Run()
- if boom.rpt.sizeTotal != 200 {
- t.Errorf("Expected Total Data Recieved 200 bytes, found %v", boom.rpt.sizeTotal)
+ if boomer.rpt.sizeTotal != 200 {
+ t.Errorf("Expected Total Data Recieved 200 bytes, found %v", boomer.rpt.sizeTotal)
}
}
@@ -170,7 +170,7 @@ func TestContentLengthIfDontExists(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(handler))
defer server.Close()
- boom := &Boom{
+ boomer := &Boomer{
Req: &ReqOpts{
Method: "GET",
Url: server.URL,
@@ -178,9 +178,9 @@ func TestContentLengthIfDontExists(t *testing.T) {
N: 10,
C: 1,
}
- boom.Run()
+ boomer.Run()
- if boom.rpt.sizeTotal != 0 {
- t.Errorf("Expected Total Data Recieved 200 bytes, found %v", boom.rpt.sizeTotal)
+ if boomer.rpt.sizeTotal != 0 {
+ t.Errorf("Expected Total Data Recieved 200 bytes, found %v", boomer.rpt.sizeTotal)
}
}