Skip to content

Commit

Permalink
Merge pull request #76 from anuraaga/direct-rtt
Browse files Browse the repository at this point in the history
  • Loading branch information
fzipi authored Sep 27, 2022
2 parents fd953f4 + e33dc16 commit fcf6dfd
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 88 deletions.
16 changes: 0 additions & 16 deletions ftwhttp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func (c *Client) NewConnection(d Destination) error {
connection: netConn,
protocol: d.Protocol,
readTimeout: c.config.ReadTimeout,
duration: NewRoundTripTime(),
}
}

Expand All @@ -86,18 +85,3 @@ func (c *Client) Do(req Request) (*Response, error) {

return response, err
}

// GetRoundTripTime returns the time taken from the initial send till receiving the full response
func (c *Client) GetRoundTripTime() *RoundTripTime {
return c.Transport.GetTrackedTime()
}

// StartTrackingTime sets the timer to start transactions. This will be the starting time in logs.
func (c *Client) StartTrackingTime() {
c.Transport.StartTrackingTime()
}

// StopTrackingTime stops the timer. When looking at logs, we will read up to this one.
func (c *Client) StopTrackingTime() {
c.Transport.StopTrackingTime()
}
14 changes: 0 additions & 14 deletions ftwhttp/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,15 @@ func TestGetTrackedTime(t *testing.T) {
t.Logf("This should not error")
}

c.StartTrackingTime()

resp, err := c.Do(*req)

c.StopTrackingTime()

if err != nil {
t.Logf("This should not error")
}

if resp.Parsed.StatusCode != 200 {
t.Logf("Error in calling website")
}

rtt := c.GetRoundTripTime()

if rtt.RoundTripDuration() < 0 {
t.Logf("Error getting RTT")
}
}

func TestClientMultipartFormDataRequest(t *testing.T) {
Expand Down Expand Up @@ -135,12 +125,8 @@ Some-file-test-here
t.Logf("This should not error")
}

c.StartTrackingTime()

resp, err := c.Do(*req)

c.StopTrackingTime()

if err != nil {
t.Logf("This should not error")
}
Expand Down
15 changes: 0 additions & 15 deletions ftwhttp/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,6 @@ func DestinationFromString(urlString string) (*Destination, error) {
return d, nil
}

// StartTrackingTime initializes timer
func (c *Connection) StartTrackingTime() {
c.duration.StartTracking()
}

// StopTrackingTime stops timer
func (c *Connection) StopTrackingTime() {
c.duration.StopTracking()
}

// GetTrackedTime will return the time since the request started and the response was parsed
func (c *Connection) GetTrackedTime() *RoundTripTime {
return c.duration
}

func (c *Connection) send(data []byte) (int, error) {
var err error
var sent int
Expand Down
39 changes: 0 additions & 39 deletions ftwhttp/rtt.go

This file was deleted.

1 change: 0 additions & 1 deletion ftwhttp/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type Connection struct {
connection net.Conn
protocol string
readTimeout time.Duration
duration *RoundTripTime
}

// RoundTripTime abstracts the time a transaction takes
Expand Down
5 changes: 2 additions & 3 deletions runner/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ func RunStage(runContext *TestRunContext, ftwCheck *check.FTWCheck, testCase tes
if err != nil && !expectedOutput.ExpectError {
log.Fatal().Caller().Err(err).Msgf("can't connect to destination %+v", dest)
}
runContext.Client.StartTrackingTime()

reqStartTime := time.Now()
response, responseErr := runContext.Client.Do(*req)
roundTripTime := time.Since(reqStartTime)

runContext.Client.StopTrackingTime()
if responseErr != nil && !expectedOutput.ExpectError {
log.Fatal().Caller().Err(responseErr).Msgf("failed sending request to destination %+v", dest)
}
Expand All @@ -159,7 +159,6 @@ func RunStage(runContext *TestRunContext, ftwCheck *check.FTWCheck, testCase tes
// now get the test result based on output
testResult := checkResult(ftwCheck, response, responseErr)

roundTripTime := runContext.Client.GetRoundTripTime().RoundTripDuration()
stageTime := time.Since(stageStartTime)

addResultToStats(testResult, testCase.TestTitle, &runContext.Stats)
Expand Down

0 comments on commit fcf6dfd

Please sign in to comment.