Skip to content

Commit

Permalink
Increase timeout deltas for http.send timeout test
Browse files Browse the repository at this point in the history
The original was using very short (1us) timeouts but it seemed to
be inconsistent, especially on travis. There are now larger deltas
between the timeouts and longer base ones. The overall impact to the
unit test times are still pretty minimal.

Signed-off-by: Patrick East <east.patrick@gmail.com>
  • Loading branch information
patrick-east committed Feb 19, 2020
1 parent 6589fcb commit d27d687
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions topdown/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ func TestHTTPSendTimeout(t *testing.T) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte(`hello`))
}))
defer ts.Close()
// Note: We don't Close() the test server as it will block waiting for the
// timed out clients connections to shut down gracefully (they wont).
// We don't need to clean it up nicely for the unit test.

tests := []struct {
note string
Expand All @@ -415,39 +417,39 @@ func TestHTTPSendTimeout(t *testing.T) {
note: "default timeout",
rule: `p = x { http.send({"method": "get", "url": "%URL%" }, x) }`,
evalTimeout: 1 * time.Minute,
serverDelay: 500 * time.Millisecond,
defaultTimeout: 1 * time.Microsecond,
serverDelay: 5 * time.Second,
defaultTimeout: 500 * time.Millisecond,
expected: &Error{Code: BuiltinErr, Message: "http.send: Get %URL%: request timed out"},
},
{
note: "eval timeout",
rule: `p = x { http.send({"method": "get", "url": "%URL%" }, x) }`,
evalTimeout: 1 * time.Microsecond,
serverDelay: 500 * time.Millisecond,
evalTimeout: 500 * time.Millisecond,
serverDelay: 5 * time.Second,
defaultTimeout: 1 * time.Minute,
expected: &Error{Code: BuiltinErr, Message: "http.send: Get %URL%: context deadline exceeded"},
},
{
note: "param timeout less than default",
rule: `p = x { http.send({"method": "get", "url": "%URL%", "timeout": "1ms"}, x) }`,
rule: `p = x { http.send({"method": "get", "url": "%URL%", "timeout": "500ms"}, x) }`,
evalTimeout: 1 * time.Minute,
serverDelay: 500 * time.Millisecond,
serverDelay: 5 * time.Second,
defaultTimeout: 1 * time.Minute,
expected: &Error{Code: BuiltinErr, Message: "http.send: Get %URL%: request timed out"},
},
{
note: "param timeout greater than default",
rule: `p = x { http.send({"method": "get", "url": "%URL%", "timeout": "1ms"}, x) }`,
rule: `p = x { http.send({"method": "get", "url": "%URL%", "timeout": "500ms"}, x) }`,
evalTimeout: 1 * time.Minute,
serverDelay: 500 * time.Millisecond,
defaultTimeout: 1 * time.Microsecond,
serverDelay: 5 * time.Second,
defaultTimeout: 1 * time.Millisecond,
expected: &Error{Code: BuiltinErr, Message: "http.send: Get %URL%: request timed out"},
},
{
note: "eval timeout less than param",
rule: `p = x { http.send({"method": "get", "url": "%URL%", "timeout": "1m" }, x) }`,
evalTimeout: 1 * time.Millisecond,
serverDelay: 100 * time.Millisecond,
evalTimeout: 500 * time.Millisecond,
serverDelay: 5 * time.Second,
defaultTimeout: 1 * time.Minute,
expected: &Error{Code: BuiltinErr, Message: "http.send: Get %URL%: context deadline exceeded"},
},
Expand Down

0 comments on commit d27d687

Please sign in to comment.