2018-05-25 18:40:12 +00:00
|
|
|
package syslog
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/tls"
|
|
|
|
"fmt"
|
2018-06-04 02:43:06 +00:00
|
|
|
"io/ioutil"
|
2018-05-25 18:40:12 +00:00
|
|
|
"net"
|
2018-06-04 02:43:06 +00:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2018-05-25 18:40:12 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2019-11-27 01:31:36 +00:00
|
|
|
"github.com/influxdata/telegraf"
|
2018-05-25 18:40:12 +00:00
|
|
|
"github.com/influxdata/telegraf/internal"
|
2019-05-08 18:21:51 +00:00
|
|
|
framing "github.com/influxdata/telegraf/internal/syslog"
|
2018-05-25 18:40:12 +00:00
|
|
|
"github.com/influxdata/telegraf/testutil"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2018-12-18 18:54:38 +00:00
|
|
|
func getTestCasesForOctetCounting() []testCaseStream {
|
|
|
|
testCases := []testCaseStream{
|
2018-05-25 18:40:12 +00:00
|
|
|
{
|
|
|
|
name: "1st/avg/ok",
|
|
|
|
data: []byte(`188 <29>1 2016-02-21T04:32:57+00:00 web1 someservice 2341 2 [origin][meta sequence="14125553" service="someservice"] "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575`),
|
2019-11-27 01:31:36 +00:00
|
|
|
wantStrict: []telegraf.Metric{
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
|
|
|
"severity": "notice",
|
|
|
|
"facility": "daemon",
|
|
|
|
"hostname": "web1",
|
|
|
|
"appname": "someservice",
|
|
|
|
},
|
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": uint16(1),
|
|
|
|
"timestamp": time.Unix(1456029177, 0).UnixNano(),
|
|
|
|
"procid": "2341",
|
|
|
|
"msgid": "2",
|
|
|
|
"message": `"GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575`,
|
|
|
|
"origin": true,
|
|
|
|
"meta_sequence": "14125553",
|
|
|
|
"meta_service": "someservice",
|
|
|
|
"severity_code": 5,
|
|
|
|
"facility_code": 3,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime,
|
|
|
|
),
|
|
|
|
},
|
|
|
|
wantBestEffort: []telegraf.Metric{
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
2018-05-25 18:40:12 +00:00
|
|
|
"severity": "notice",
|
|
|
|
"facility": "daemon",
|
|
|
|
"hostname": "web1",
|
|
|
|
"appname": "someservice",
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": uint16(1),
|
|
|
|
"timestamp": time.Unix(1456029177, 0).UnixNano(),
|
|
|
|
"procid": "2341",
|
|
|
|
"msgid": "2",
|
|
|
|
"message": `"GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575`,
|
|
|
|
"origin": true,
|
|
|
|
"meta_sequence": "14125553",
|
|
|
|
"meta_service": "someservice",
|
|
|
|
"severity_code": 5,
|
|
|
|
"facility_code": 3,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime,
|
|
|
|
),
|
2018-05-25 18:40:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "1st/min/ok//2nd/min/ok",
|
|
|
|
data: []byte("16 <1>2 - - - - - -17 <4>11 - - - - - -"),
|
2019-11-27 01:31:36 +00:00
|
|
|
wantStrict: []telegraf.Metric{
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
|
|
|
"severity": "alert",
|
|
|
|
"facility": "kern",
|
|
|
|
},
|
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": uint16(2),
|
|
|
|
"severity_code": 1,
|
|
|
|
"facility_code": 0,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime,
|
|
|
|
),
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
|
|
|
"severity": "warning",
|
2018-05-25 18:40:12 +00:00
|
|
|
"facility": "kern",
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": uint16(11),
|
|
|
|
"severity_code": 4,
|
|
|
|
"facility_code": 0,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime.Add(time.Nanosecond),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
wantBestEffort: []telegraf.Metric{
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
|
|
|
"severity": "alert",
|
2018-05-25 18:40:12 +00:00
|
|
|
"facility": "kern",
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": uint16(2),
|
|
|
|
"severity_code": 1,
|
|
|
|
"facility_code": 0,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime,
|
|
|
|
),
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
|
|
|
"severity": "warning",
|
2018-05-25 18:40:12 +00:00
|
|
|
"facility": "kern",
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": uint16(11),
|
|
|
|
"severity_code": 4,
|
|
|
|
"facility_code": 0,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime.Add(time.Nanosecond),
|
|
|
|
),
|
2018-05-25 18:40:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "1st/utf8/ok",
|
|
|
|
data: []byte("23 <1>1 - - - - - - hellø"),
|
2019-11-27 01:31:36 +00:00
|
|
|
wantStrict: []telegraf.Metric{
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
|
|
|
"severity": "alert",
|
|
|
|
"facility": "kern",
|
|
|
|
},
|
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": uint16(1),
|
|
|
|
"message": "hellø",
|
|
|
|
"severity_code": 1,
|
|
|
|
"facility_code": 0,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime,
|
|
|
|
),
|
|
|
|
},
|
|
|
|
wantBestEffort: []telegraf.Metric{
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
2018-05-25 18:40:12 +00:00
|
|
|
"severity": "alert",
|
|
|
|
"facility": "kern",
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": uint16(1),
|
|
|
|
"message": "hellø",
|
|
|
|
"severity_code": 1,
|
|
|
|
"facility_code": 0,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime,
|
|
|
|
),
|
2018-05-25 18:40:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "1st/nl/ok", // newline
|
|
|
|
data: []byte("28 <1>3 - - - - - - hello\nworld"),
|
2019-11-27 01:31:36 +00:00
|
|
|
wantStrict: []telegraf.Metric{
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
|
|
|
"severity": "alert",
|
|
|
|
"facility": "kern",
|
|
|
|
},
|
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": uint16(3),
|
|
|
|
"message": "hello\nworld",
|
|
|
|
"severity_code": 1,
|
|
|
|
"facility_code": 0,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime,
|
|
|
|
),
|
|
|
|
},
|
|
|
|
wantBestEffort: []telegraf.Metric{
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
2018-05-25 18:40:12 +00:00
|
|
|
"severity": "alert",
|
|
|
|
"facility": "kern",
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": uint16(3),
|
|
|
|
"message": "hello\nworld",
|
|
|
|
"severity_code": 1,
|
|
|
|
"facility_code": 0,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime,
|
|
|
|
),
|
2018-05-25 18:40:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "1st/uf/ko", // underflow (msglen less than provided octets)
|
|
|
|
data: []byte("16 <1>2"),
|
|
|
|
wantStrict: nil,
|
2019-11-27 01:31:36 +00:00
|
|
|
wantBestEffort: []telegraf.Metric{
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
|
|
|
"severity": "alert",
|
|
|
|
"facility": "kern",
|
|
|
|
},
|
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": uint16(2),
|
|
|
|
"severity_code": 1,
|
|
|
|
"facility_code": 0,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime,
|
|
|
|
),
|
2018-05-25 18:40:12 +00:00
|
|
|
},
|
|
|
|
werr: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "1st/min/ok",
|
|
|
|
data: []byte("16 <1>1 - - - - - -"),
|
2019-11-27 01:31:36 +00:00
|
|
|
wantStrict: []telegraf.Metric{
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
|
|
|
"severity": "alert",
|
|
|
|
"facility": "kern",
|
|
|
|
},
|
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": uint16(1),
|
|
|
|
"severity_code": 1,
|
|
|
|
"facility_code": 0,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime,
|
|
|
|
),
|
|
|
|
},
|
|
|
|
wantBestEffort: []telegraf.Metric{
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
2018-05-25 18:40:12 +00:00
|
|
|
"severity": "alert",
|
|
|
|
"facility": "kern",
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": uint16(1),
|
|
|
|
"severity_code": 1,
|
|
|
|
"facility_code": 0,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime,
|
|
|
|
),
|
2018-05-25 18:40:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "1st/uf/mf", // The first "underflow" message breaks also the second one
|
|
|
|
data: []byte("16 <1>217 <11>1 - - - - - -"),
|
|
|
|
wantStrict: nil,
|
2019-11-27 01:31:36 +00:00
|
|
|
wantBestEffort: []telegraf.Metric{
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
|
|
|
"severity": "alert",
|
|
|
|
"facility": "kern",
|
|
|
|
},
|
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": uint16(217),
|
|
|
|
"severity_code": 1,
|
|
|
|
"facility_code": 0,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime,
|
|
|
|
),
|
2018-05-25 18:40:12 +00:00
|
|
|
},
|
|
|
|
werr: 1,
|
|
|
|
},
|
|
|
|
// {
|
|
|
|
// name: "1st/of/ko", // overflow (msglen greather then max allowed octets)
|
|
|
|
// data: []byte(fmt.Sprintf("8193 <%d>%d %s %s %s %s %s 12 %s", maxP, maxV, maxTS, maxH, maxA, maxPID, maxMID, message7681)),
|
|
|
|
// want: []testutil.Metric{},
|
|
|
|
// },
|
|
|
|
{
|
|
|
|
name: "1st/max/ok",
|
|
|
|
data: []byte(fmt.Sprintf("8192 <%d>%d %s %s %s %s %s - %s", maxP, maxV, maxTS, maxH, maxA, maxPID, maxMID, message7681)),
|
2019-11-27 01:31:36 +00:00
|
|
|
wantStrict: []telegraf.Metric{
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
|
|
|
"severity": "debug",
|
|
|
|
"facility": "local7",
|
|
|
|
"hostname": maxH,
|
|
|
|
"appname": maxA,
|
|
|
|
},
|
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": maxV,
|
|
|
|
"timestamp": time.Unix(1514764799, 999999000).UnixNano(),
|
|
|
|
"message": message7681,
|
|
|
|
"procid": maxPID,
|
|
|
|
"msgid": maxMID,
|
|
|
|
"facility_code": 23,
|
|
|
|
"severity_code": 7,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime,
|
|
|
|
),
|
|
|
|
},
|
|
|
|
wantBestEffort: []telegraf.Metric{
|
|
|
|
testutil.MustMetric(
|
|
|
|
"syslog",
|
|
|
|
map[string]string{
|
2018-05-25 18:40:12 +00:00
|
|
|
"severity": "debug",
|
|
|
|
"facility": "local7",
|
|
|
|
"hostname": maxH,
|
|
|
|
"appname": maxA,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
map[string]interface{}{
|
2018-05-25 18:40:12 +00:00
|
|
|
"version": maxV,
|
|
|
|
"timestamp": time.Unix(1514764799, 999999000).UnixNano(),
|
|
|
|
"message": message7681,
|
|
|
|
"procid": maxPID,
|
|
|
|
"msgid": maxMID,
|
|
|
|
"facility_code": 23,
|
|
|
|
"severity_code": 7,
|
|
|
|
},
|
2019-11-27 01:31:36 +00:00
|
|
|
defaultTime,
|
|
|
|
),
|
2018-05-25 18:40:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return testCases
|
|
|
|
}
|
|
|
|
|
2018-12-18 18:54:38 +00:00
|
|
|
func testStrictOctetCounting(t *testing.T, protocol string, address string, wantTLS bool, keepAlive *internal.Duration) {
|
|
|
|
for _, tc := range getTestCasesForOctetCounting() {
|
2018-05-25 18:40:12 +00:00
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
// Creation of a strict mode receiver
|
2019-05-08 18:21:51 +00:00
|
|
|
receiver := newTCPSyslogReceiver(protocol+"://"+address, keepAlive, 0, false, framing.OctetCounting)
|
2018-05-25 18:40:12 +00:00
|
|
|
require.NotNil(t, receiver)
|
|
|
|
if wantTLS {
|
|
|
|
receiver.ServerConfig = *pki.TLSServerConfig()
|
|
|
|
}
|
|
|
|
require.Equal(t, receiver.KeepAlivePeriod, keepAlive)
|
|
|
|
acc := &testutil.Accumulator{}
|
|
|
|
require.NoError(t, receiver.Start(acc))
|
|
|
|
defer receiver.Stop()
|
|
|
|
|
|
|
|
// Connect
|
|
|
|
var conn net.Conn
|
|
|
|
var err error
|
|
|
|
if wantTLS {
|
|
|
|
config, e := pki.TLSClientConfig().TLSConfig()
|
|
|
|
require.NoError(t, e)
|
|
|
|
config.ServerName = "localhost"
|
|
|
|
conn, err = tls.Dial(protocol, address, config)
|
|
|
|
} else {
|
|
|
|
conn, err = net.Dial(protocol, address)
|
|
|
|
defer conn.Close()
|
|
|
|
}
|
|
|
|
require.NotNil(t, conn)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// Clear
|
|
|
|
acc.ClearMetrics()
|
|
|
|
acc.Errors = make([]error, 0)
|
|
|
|
|
|
|
|
// Write
|
2018-07-28 01:29:54 +00:00
|
|
|
_, err = conn.Write(tc.data)
|
|
|
|
conn.Close()
|
|
|
|
require.NoError(t, err)
|
2018-05-25 18:40:12 +00:00
|
|
|
|
|
|
|
// Wait that the the number of data points is accumulated
|
|
|
|
// Since the receiver is running concurrently
|
|
|
|
if tc.wantStrict != nil {
|
|
|
|
acc.Wait(len(tc.wantStrict))
|
|
|
|
}
|
2018-07-28 01:29:54 +00:00
|
|
|
|
2018-05-25 18:40:12 +00:00
|
|
|
// Wait the parsing error
|
|
|
|
acc.WaitError(tc.werr)
|
|
|
|
|
|
|
|
// Verify
|
|
|
|
if len(acc.Errors) != tc.werr {
|
|
|
|
t.Fatalf("Got unexpected errors. want error = %v, errors = %v\n", tc.werr, acc.Errors)
|
|
|
|
}
|
2019-11-27 01:31:36 +00:00
|
|
|
testutil.RequireMetricsEqual(t, tc.wantStrict, acc.GetTelegrafMetrics())
|
2018-05-25 18:40:12 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-18 18:54:38 +00:00
|
|
|
func testBestEffortOctetCounting(t *testing.T, protocol string, address string, wantTLS bool, keepAlive *internal.Duration) {
|
|
|
|
for _, tc := range getTestCasesForOctetCounting() {
|
2018-05-25 18:40:12 +00:00
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
// Creation of a best effort mode receiver
|
2019-05-08 18:21:51 +00:00
|
|
|
receiver := newTCPSyslogReceiver(protocol+"://"+address, keepAlive, 0, true, framing.OctetCounting)
|
2018-05-25 18:40:12 +00:00
|
|
|
require.NotNil(t, receiver)
|
|
|
|
if wantTLS {
|
|
|
|
receiver.ServerConfig = *pki.TLSServerConfig()
|
|
|
|
}
|
|
|
|
require.Equal(t, receiver.KeepAlivePeriod, keepAlive)
|
|
|
|
acc := &testutil.Accumulator{}
|
|
|
|
require.NoError(t, receiver.Start(acc))
|
|
|
|
defer receiver.Stop()
|
|
|
|
|
|
|
|
// Connect
|
|
|
|
var conn net.Conn
|
|
|
|
var err error
|
|
|
|
if wantTLS {
|
|
|
|
config, e := pki.TLSClientConfig().TLSConfig()
|
|
|
|
require.NoError(t, e)
|
|
|
|
config.ServerName = "localhost"
|
|
|
|
conn, err = tls.Dial(protocol, address, config)
|
|
|
|
} else {
|
|
|
|
conn, err = net.Dial(protocol, address)
|
|
|
|
}
|
|
|
|
require.NotNil(t, conn)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// Clear
|
|
|
|
acc.ClearMetrics()
|
|
|
|
acc.Errors = make([]error, 0)
|
|
|
|
|
|
|
|
// Write
|
2018-07-28 01:29:54 +00:00
|
|
|
_, err = conn.Write(tc.data)
|
|
|
|
require.NoError(t, err)
|
|
|
|
conn.Close()
|
2018-05-25 18:40:12 +00:00
|
|
|
|
|
|
|
// Wait that the the number of data points is accumulated
|
|
|
|
// Since the receiver is running concurrently
|
|
|
|
if tc.wantBestEffort != nil {
|
|
|
|
acc.Wait(len(tc.wantBestEffort))
|
|
|
|
}
|
|
|
|
|
2019-11-27 01:31:36 +00:00
|
|
|
testutil.RequireMetricsEqual(t, tc.wantBestEffort, acc.GetTelegrafMetrics())
|
2018-05-25 18:40:12 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-18 18:54:38 +00:00
|
|
|
func TestOctetCountingStrict_tcp(t *testing.T) {
|
|
|
|
testStrictOctetCounting(t, "tcp", address, false, nil)
|
2018-05-25 18:40:12 +00:00
|
|
|
}
|
|
|
|
|
2018-12-18 18:54:38 +00:00
|
|
|
func TestOctetCountingBestEffort_tcp(t *testing.T) {
|
|
|
|
testBestEffortOctetCounting(t, "tcp", address, false, nil)
|
2018-05-25 18:40:12 +00:00
|
|
|
}
|
|
|
|
|
2018-12-18 18:54:38 +00:00
|
|
|
func TestOctetCountingStrict_tcp_tls(t *testing.T) {
|
|
|
|
testStrictOctetCounting(t, "tcp", address, true, nil)
|
2018-05-25 18:40:12 +00:00
|
|
|
}
|
|
|
|
|
2018-12-18 18:54:38 +00:00
|
|
|
func TestOctetCountingBestEffort_tcp_tls(t *testing.T) {
|
|
|
|
testBestEffortOctetCounting(t, "tcp", address, true, nil)
|
2018-05-25 18:40:12 +00:00
|
|
|
}
|
|
|
|
|
2018-12-18 18:54:38 +00:00
|
|
|
func TestOctetCountingStrictWithKeepAlive_tcp_tls(t *testing.T) {
|
|
|
|
testStrictOctetCounting(t, "tcp", address, true, &internal.Duration{Duration: time.Minute})
|
2018-05-25 18:40:12 +00:00
|
|
|
}
|
|
|
|
|
2018-12-18 18:54:38 +00:00
|
|
|
func TestOctetCountingStrictWithZeroKeepAlive_tcp_tls(t *testing.T) {
|
|
|
|
testStrictOctetCounting(t, "tcp", address, true, &internal.Duration{Duration: 0})
|
2018-05-25 18:40:12 +00:00
|
|
|
}
|
|
|
|
|
2018-12-18 18:54:38 +00:00
|
|
|
func TestOctetCountingStrict_unix(t *testing.T) {
|
2018-06-04 02:43:06 +00:00
|
|
|
tmpdir, err := ioutil.TempDir("", "telegraf")
|
|
|
|
require.NoError(t, err)
|
|
|
|
defer os.RemoveAll(tmpdir)
|
|
|
|
sock := filepath.Join(tmpdir, "syslog.TestStrict_unix.sock")
|
2018-12-18 18:54:38 +00:00
|
|
|
testStrictOctetCounting(t, "unix", sock, false, nil)
|
2018-05-25 18:40:12 +00:00
|
|
|
}
|
|
|
|
|
2018-12-18 18:54:38 +00:00
|
|
|
func TestOctetCountingBestEffort_unix(t *testing.T) {
|
2018-06-04 02:43:06 +00:00
|
|
|
tmpdir, err := ioutil.TempDir("", "telegraf")
|
|
|
|
require.NoError(t, err)
|
|
|
|
defer os.RemoveAll(tmpdir)
|
|
|
|
sock := filepath.Join(tmpdir, "syslog.TestBestEffort_unix.sock")
|
2018-12-18 18:54:38 +00:00
|
|
|
testBestEffortOctetCounting(t, "unix", sock, false, nil)
|
2018-05-25 18:40:12 +00:00
|
|
|
}
|
|
|
|
|
2018-12-18 18:54:38 +00:00
|
|
|
func TestOctetCountingStrict_unix_tls(t *testing.T) {
|
2018-06-04 02:43:06 +00:00
|
|
|
tmpdir, err := ioutil.TempDir("", "telegraf")
|
|
|
|
require.NoError(t, err)
|
|
|
|
defer os.RemoveAll(tmpdir)
|
|
|
|
sock := filepath.Join(tmpdir, "syslog.TestStrict_unix_tls.sock")
|
2018-12-18 18:54:38 +00:00
|
|
|
testStrictOctetCounting(t, "unix", sock, true, nil)
|
2018-05-25 18:40:12 +00:00
|
|
|
}
|
|
|
|
|
2018-12-18 18:54:38 +00:00
|
|
|
func TestOctetCountingBestEffort_unix_tls(t *testing.T) {
|
2018-06-04 02:43:06 +00:00
|
|
|
tmpdir, err := ioutil.TempDir("", "telegraf")
|
|
|
|
require.NoError(t, err)
|
|
|
|
defer os.RemoveAll(tmpdir)
|
|
|
|
sock := filepath.Join(tmpdir, "syslog.TestBestEffort_unix_tls.sock")
|
2018-12-18 18:54:38 +00:00
|
|
|
testBestEffortOctetCounting(t, "unix", sock, true, nil)
|
2018-05-25 18:40:12 +00:00
|
|
|
}
|