mirror of
https://github.com/wahyd4/telegraf.git
synced 2026-08-09 04:36:05 +10:00
Test http_listener partial write
This commit is contained in:
@@ -30,6 +30,10 @@ cpu_load_short,host=server04 value=12.0 1422568543702900257
|
||||
cpu_load_short,host=server05 value=12.0 1422568543702900257
|
||||
cpu_load_short,host=server06 value=12.0 1422568543702900257
|
||||
`
|
||||
testPartial = `cpu,host=a value1=1
|
||||
cpu,host=b value1=1,value2=+Inf,value3=3
|
||||
cpu,host=c value1=1`
|
||||
|
||||
badMsg = "blahblahblah: 42\n"
|
||||
|
||||
emptyMsg = ""
|
||||
@@ -215,6 +219,30 @@ func TestWriteHTTPNoNewline(t *testing.T) {
|
||||
)
|
||||
}
|
||||
|
||||
func TestPartialWriteHTTP(t *testing.T) {
|
||||
listener := newTestHTTPListener()
|
||||
|
||||
acc := &testutil.Accumulator{}
|
||||
require.NoError(t, listener.Start(acc))
|
||||
defer listener.Stop()
|
||||
|
||||
// post single message to listener
|
||||
resp, err := http.Post(createURL(listener, "http", "/write", "db=mydb"), "", bytes.NewBuffer([]byte(testPartial)))
|
||||
require.NoError(t, err)
|
||||
resp.Body.Close()
|
||||
require.EqualValues(t, 400, resp.StatusCode)
|
||||
|
||||
acc.Wait(1)
|
||||
acc.AssertContainsTaggedFields(t, "cpu",
|
||||
map[string]interface{}{"value1": float64(1)},
|
||||
map[string]string{"host": "a"},
|
||||
)
|
||||
acc.AssertContainsTaggedFields(t, "cpu",
|
||||
map[string]interface{}{"value1": float64(1)},
|
||||
map[string]string{"host": "c"},
|
||||
)
|
||||
}
|
||||
|
||||
func TestWriteHTTPMaxLineSizeIncrease(t *testing.T) {
|
||||
listener := &HTTPListener{
|
||||
ServiceAddress: "localhost:0",
|
||||
|
||||
Reference in New Issue
Block a user