Utilize timeout in net_response plugin.
Also changing the net_response and http_response plugins to only accept duration strings for their timeout parameters. This is a breaking config file change. closes #1214
This commit is contained in:
@@ -5,7 +5,9 @@ import (
|
||||
"regexp"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/telegraf/internal"
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -35,7 +37,7 @@ func TestTCPError(t *testing.T) {
|
||||
// Error
|
||||
err1 := c.Gather(&acc)
|
||||
require.Error(t, err1)
|
||||
assert.Equal(t, "dial tcp 127.0.0.1:9999: getsockopt: connection refused", err1.Error())
|
||||
assert.Contains(t, err1.Error(), "getsockopt: connection refused")
|
||||
}
|
||||
|
||||
func TestTCPOK1(t *testing.T) {
|
||||
@@ -46,8 +48,8 @@ func TestTCPOK1(t *testing.T) {
|
||||
Address: "127.0.0.1:2004",
|
||||
Send: "test",
|
||||
Expect: "test",
|
||||
ReadTimeout: 3.0,
|
||||
Timeout: 1.0,
|
||||
ReadTimeout: internal.Duration{Duration: time.Second * 3},
|
||||
Timeout: internal.Duration{Duration: time.Second},
|
||||
Protocol: "tcp",
|
||||
}
|
||||
// Start TCP server
|
||||
@@ -86,8 +88,8 @@ func TestTCPOK2(t *testing.T) {
|
||||
Address: "127.0.0.1:2004",
|
||||
Send: "test",
|
||||
Expect: "test2",
|
||||
ReadTimeout: 3.0,
|
||||
Timeout: 1.0,
|
||||
ReadTimeout: internal.Duration{Duration: time.Second * 3},
|
||||
Timeout: internal.Duration{Duration: time.Second},
|
||||
Protocol: "tcp",
|
||||
}
|
||||
// Start TCP server
|
||||
@@ -141,8 +143,8 @@ func TestUDPOK1(t *testing.T) {
|
||||
Address: "127.0.0.1:2004",
|
||||
Send: "test",
|
||||
Expect: "test",
|
||||
ReadTimeout: 3.0,
|
||||
Timeout: 1.0,
|
||||
ReadTimeout: internal.Duration{Duration: time.Second * 3},
|
||||
Timeout: internal.Duration{Duration: time.Second},
|
||||
Protocol: "udp",
|
||||
}
|
||||
// Start UDP server
|
||||
|
||||
Reference in New Issue
Block a user