diff --git a/marbl/handler_test.go b/marbl/handler_test.go index 588ed0661..c647d158a 100644 --- a/marbl/handler_test.go +++ b/marbl/handler_test.go @@ -16,16 +16,19 @@ package marbl import ( "fmt" - "golang.org/x/net/websocket" "math/rand" "net" "net/http" "strconv" "testing" "time" + + "golang.org/x/net/websocket" ) func TestStreamsInSentOrder(t *testing.T) { + //t.Skip("skipping test to deflake.") + l, err := net.Listen("tcp", "localhost:0") if err != nil { t.Fatalf("net.Listen(): got %v, want no error", err) diff --git a/proxy_trafficshaping_test.go b/proxy_trafficshaping_test.go index a391f4ac2..4a467c851 100644 --- a/proxy_trafficshaping_test.go +++ b/proxy_trafficshaping_test.go @@ -7,7 +7,6 @@ import ( "net" "net/http" "net/http/httptest" - "net/http/httputil" "strings" "testing" "time" @@ -63,9 +62,6 @@ func TestConstantThrottleAndClose(t *testing.T) { tsh.ServeHTTP(rw, tsReq) res := rw.Result() - body, _ := ioutil.ReadAll(res.Body) - t.Logf("%s", string(body)) - if got, want := res.StatusCode, 200; got != want { t.Fatalf("res.StatusCode: got %d, want %d", got, want) } @@ -105,7 +101,6 @@ func TestConstantThrottleAndClose(t *testing.T) { } go func() { - t.Logf("starting %v", time.Now()) req, err := http.NewRequest("GET", "http://example/example", nil) if err != nil { t.Fatalf("http.NewRequest(): got %v, want no error", err) @@ -121,7 +116,6 @@ func TestConstantThrottleAndClose(t *testing.T) { } body, _ := ioutil.ReadAll(res.Body) bodystr := string(body) - t.Logf("after reading all %v", time.Now()) c1 <- bodystr }() @@ -194,9 +188,6 @@ func TestSleepAndClose(t *testing.T) { tsh.ServeHTTP(rw, tsReq) res := rw.Result() - body, _ := ioutil.ReadAll(res.Body) - t.Logf("%s", string(body)) - if got, want := res.StatusCode, 200; got != want { t.Fatalf("res.StatusCode: got %d, want %d", got, want) } @@ -236,7 +227,6 @@ func TestSleepAndClose(t *testing.T) { } go func() { - t.Logf("starting %v", time.Now()) req, err := http.NewRequest("GET", "http://example/example", nil) if err != nil { t.Fatalf("http.NewRequest(): got %v, want no error", err) @@ -252,7 +242,6 @@ func TestSleepAndClose(t *testing.T) { } body, _ := ioutil.ReadAll(res.Body) bodystr := string(body) - t.Logf("after reading all %v", time.Now()) c1 <- bodystr }() @@ -317,9 +306,6 @@ func TestConstantThrottleAndCloseByteRange(t *testing.T) { tsh.ServeHTTP(rw, tsReq) res := rw.Result() - body, _ := ioutil.ReadAll(res.Body) - t.Logf("%s", string(body)) - if got, want := res.StatusCode, 200; got != want { t.Fatalf("res.StatusCode: got %d, want %d", got, want) } @@ -360,7 +346,6 @@ func TestConstantThrottleAndCloseByteRange(t *testing.T) { } go func() { - t.Logf("starting %v", time.Now()) req, err := http.NewRequest("GET", "http://example/example", nil) if err != nil { t.Fatalf("http.NewRequest(): got %v, want no error", err) @@ -377,9 +362,6 @@ func TestConstantThrottleAndCloseByteRange(t *testing.T) { body, _ := ioutil.ReadAll(res.Body) bodystr := string(body) - dump, err := httputil.DumpResponse(res, true) - t.Logf("%s %d", dump, int64(len(dump))) - t.Logf("after reading all %v", time.Now()) c1 <- bodystr }() @@ -442,9 +424,6 @@ func TestMaxBandwidth(t *testing.T) { tsh.ServeHTTP(rw, tsReq) res := rw.Result() - body, _ := ioutil.ReadAll(res.Body) - t.Logf("%s", string(body)) - if got, want := res.StatusCode, 200; got != want { t.Fatalf("res.StatusCode: got %d, want %d", got, want) } @@ -486,7 +465,6 @@ func TestMaxBandwidth(t *testing.T) { for i := 0; i < numChannels; i++ { go func(i int) { - t.Logf("%d starting %v", i, time.Now()) conn, err := net.Dial("tcp", l.Addr().String()) defer conn.Close() if err != nil { @@ -508,7 +486,6 @@ func TestMaxBandwidth(t *testing.T) { body, _ := ioutil.ReadAll(res.Body) bodystr := string(body) - t.Logf("%d after reading all %v", i, time.Now()) if i != 0 { <-channels[i-1] @@ -585,9 +562,6 @@ func TestConcurrentResponseActions(t *testing.T) { tsh.ServeHTTP(rw, tsReq) res := rw.Result() - body, _ := ioutil.ReadAll(res.Body) - t.Logf("%s", string(body)) - if got, want := res.StatusCode, 200; got != want { t.Fatalf("res.StatusCode: got %d, want %d", got, want) } @@ -628,7 +602,6 @@ func TestConcurrentResponseActions(t *testing.T) { c2 := make(chan string) go func() { - t.Logf("starting 1 %v", time.Now()) conn, err := net.Dial("tcp", l.Addr().String()) defer conn.Close() if err != nil { @@ -651,14 +624,10 @@ func TestConcurrentResponseActions(t *testing.T) { body, _ := ioutil.ReadAll(res.Body) bodystr := string(body) - dump, err := httputil.DumpResponse(res, true) - t.Logf("%s %d", dump, int64(len(dump))) - t.Logf("1 after reading all %v", time.Now()) c1 <- bodystr }() go func() { - t.Logf("2 starting %v", time.Now()) conn, err := net.Dial("tcp", l.Addr().String()) defer conn.Close() if err != nil { @@ -680,9 +649,6 @@ func TestConcurrentResponseActions(t *testing.T) { body, _ := ioutil.ReadAll(res.Body) bodystr := string(body) - dump, err := httputil.DumpResponse(res, true) - t.Logf("%s %d", dump, int64(len(dump))) - t.Logf("2 after reading all %v", time.Now()) c2 <- bodystr }() @@ -696,4 +662,3 @@ func TestConcurrentResponseActions(t *testing.T) { t.Errorf("res.Body: got %s, want %s", bodystr2, want2) } } - diff --git a/trafficshape/handler.go b/trafficshape/handler.go index e54fb36c2..3318ea3c1 100644 --- a/trafficshape/handler.go +++ b/trafficshape/handler.go @@ -227,5 +227,4 @@ func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) { rw.WriteHeader(http.StatusOK) io.WriteString(rw, bodystr) - log.Infof("trafficshape: Configured from json %s", bodystr) -} \ No newline at end of file +} diff --git a/trafficshape/handler_test.go b/trafficshape/handler_test.go index 24df2bc4f..e5396533c 100644 --- a/trafficshape/handler_test.go +++ b/trafficshape/handler_test.go @@ -17,7 +17,6 @@ package trafficshape import ( "bytes" "fmt" - "io/ioutil" "net" "net/http" "net/http/httptest" @@ -136,9 +135,6 @@ func TestHandlerIncorrectInputs(t *testing.T) { h.ServeHTTP(rw, req) - body, _ := ioutil.ReadAll(rw.Result().Body) - t.Logf("%d\n %s", i+1, string(body)) - if got := rw.Code; got != 400 { t.Errorf("%d. rw.Code: got %d, want %d", i+1, got, 400) } @@ -167,9 +163,6 @@ func TestHandlerClear(t *testing.T) { h.ServeHTTP(rw, req) - body, _ := ioutil.ReadAll(rw.Result().Body) - t.Logf("%s", string(body)) - if got, want := rw.Code, 200; got != want { t.Errorf(" rw.Code: got %d, want %d", got, want) } @@ -244,9 +237,6 @@ func TestHandlerActions(t *testing.T) { h.ServeHTTP(rw, req) - body, _ := ioutil.ReadAll(rw.Result().Body) - t.Logf("%d\n %s", i+1, string(body)) - if got, want := rw.Code, 200; got != want { t.Errorf("%d. rw.Code: got %d, want %d", i+1, got, want) } @@ -266,4 +256,3 @@ func TestHandlerActions(t *testing.T) { } } } - diff --git a/trafficshape/listener.go b/trafficshape/listener.go index 5e3fb743b..8979d212a 100644 --- a/trafficshape/listener.go +++ b/trafficshape/listener.go @@ -579,7 +579,6 @@ func (c *Conn) Write(b []byte) (int, error) { return c.Context.GlobalBucket.FillThrottleLocked(func(rem int64) (int64, error) { max = min(rem, max) - log.Debugf("Writing %d into connection", max) n, err := c.Conn.Write(b[:max]) return int64(n), err @@ -604,8 +603,6 @@ func (c *Conn) Write(b []byte) (int, error) { c.Context.ByteOffset >= c.Context.NextActionInfo.ByteOffset { // Note here, we check again that the url shape map is still valid and that the action still has // a non zero count, since that could have been modified since the last time we checked. - log.Debugf("Performing action if there for regex %s byte offset %d", - c.Context.URLRegex, c.Context.ByteOffset) ind := c.Context.NextActionInfo.Index c.Shapes.RLock() if !c.CheckExistenceAndValidity(c.Context.URLRegex) { @@ -625,7 +622,7 @@ func (c *Conn) Write(b []byte) (int, error) { switch action := actions[ind].(type) { case *Halt: d := action.Duration - log.Infof("trafficshape: Sleeping for time %d ms for urlregex %s at byte offset %d", + log.Debugf("trafficshape: Sleeping for time %d ms for urlregex %s at byte offset %d", d, c.Context.URLRegex, c.Context.ByteOffset) c.Shapes.M[c.Context.URLRegex].Unlock() c.Shapes.RUnlock() @@ -661,4 +658,4 @@ func (c *Conn) Write(b []byte) (int, error) { func (c *Conn) sleepLatency() { log.Debugf("trafficshape: simulating latency: %s", c.latency) time.Sleep(c.latency) -} \ No newline at end of file +} diff --git a/trafficshape/listener_test.go b/trafficshape/listener_test.go index 771c89fa2..2d0e0e805 100644 --- a/trafficshape/listener_test.go +++ b/trafficshape/listener_test.go @@ -473,14 +473,10 @@ func TestActionsAndThrottles(t *testing.T) { h.ServeHTTP(rw, req) - body, _ := ioutil.ReadAll(rw.Result().Body) - t.Logf("%d\n %s", i+1, string(body)) - if got, want := rw.Code, 200; got != want { t.Errorf("%d. rw.Code: got %d, want %d", i+1, got, want) } - t.Logf("%d starting %v", i, time.Now()) conn, err := net.Dial("tcp", l.Addr().String()) defer conn.Close() if err != nil { @@ -526,9 +522,6 @@ func TestActionsAfterUpdatingCounts(t *testing.T) { h.ServeHTTP(rw, req) - body, _ := ioutil.ReadAll(rw.Result().Body) - t.Logf("%s", string(body)) - if got, want := rw.Code, 200; got != want { t.Errorf("rw.Code: got %d, want %d", got, want) } @@ -573,4 +566,3 @@ func TestActionsAfterUpdatingCounts(t *testing.T) { t.Errorf("NextActionInfo at %d got %+v, want %+v", 1015, got, want) } } -