GoReplay is an open-source tool for capturing and replaying live HTTP traffic into a test environment in order to continuously test your system with real data. It can be used to increase confidence in code deployments, configuration changes and infrastructure changes.
I don't think the output_http test, and possibly others that use test_input, are behaving correctly. It seems that most of the time only a single POST request is received. But the number of GET requests pads out to match the WaitGroup.
This can be easily observed with the following diff:
diff --git a/output_http_test.go b/output_http_test.go
index 7c9d977..d7581d3 100644
--- a/output_http_test.go
+++ b/output_http_test.go
@@ -24,11 +24,13 @@ func TestHTTPOutput(t *testing.T) {
headers := HTTPHeaders{HTTPHeader{"User-Agent", "Gor"}}
output := NewHTTPOutput("127.0.0.1:50003", headers, "")
+ Settings.verbose = true
startHTTP("127.0.0.1:50003", func(req *http.Request) {
if req.Header.Get("User-Agent") != "Gor" {
t.Error("Wrong header")
}
+ t.Log(req)
wg.Done()
})
@@ -37,7 +39,7 @@ func TestHTTPOutput(t *testing.T) {
go Start(quit)
- for i := 0; i < 100; i++ {
+ for i := 0; i < 3; i++ {
wg.Add(2)
input.EmitGET()
input.EmitPOST()
Which shows 3x POST requests going in, but only one coming out:
Occasionally it also appears to truncate the POST request. Which can be easily observed by switching the order:
diff --git a/output_http_test.go b/output_http_test.go
index 7c9d977..0169321 100644
--- a/output_http_test.go
+++ b/output_http_test.go
@@ -37,10 +37,10 @@ func TestHTTPOutput(t *testing.T) {
go Start(quit)
- for i := 0; i < 100; i++ {
+ for i := 0; i < 3; i++ {
wg.Add(2)
- input.EmitGET()
input.EmitPOST()
+ input.EmitGET()
}
wg.Wait()
Causing a parse error and the WaitGroup hangs:
➜ gor git:(master) ✗ go test -run TestHTTPOutput -v
warning: building out-of-date packages:
github.com/mattbaird/elastigo/api
github.com/araddon/gou
github.com/mattbaird/elastigo/core
github.com/buger/gor/elasticsearch
github.com/buger/gor/raw_socket_listener
installing these packages with 'go test -i' will speed future tests.
=== RUN TestHTTPOutput
2013/11/26 13:27:45 Can not parse request POST /pub/WWW/ HTT malformed HTTP version "HTT"
2013/11/26 13:27:45 Can not parse request POST /pub/WWW/ HTT malformed HTTP version "HTT"
I don't think the
output_http
test, and possibly others that usetest_input
, are behaving correctly. It seems that most of the time only a singlePOST
request is received. But the number ofGET
requests pads out to match the WaitGroup.This can be easily observed with the following diff:
Which shows 3x
POST
requests going in, but only one coming out:Occasionally it also appears to truncate the
POST
request. Which can be easily observed by switching the order:Causing a parse error and the WaitGroup hangs: