Add prometheus round trip unit tests (#6720)
This commit is contained in:
@@ -144,6 +144,7 @@ func TestDirectoryWithTrailingSlash(t *testing.T) {
|
||||
"size_bytes": 5096,
|
||||
},
|
||||
time.Unix(0, 0),
|
||||
telegraf.Gauge,
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ func TestParkedProcess(t *testing.T) {
|
||||
"zombies": 0,
|
||||
},
|
||||
time.Unix(0, 0),
|
||||
telegraf.Untyped,
|
||||
telegraf.Gauge,
|
||||
),
|
||||
}
|
||||
actual := acc.GetTelegrafMetrics()
|
||||
|
||||
@@ -875,6 +875,7 @@ func TestParse_DataDogTags(t *testing.T) {
|
||||
"value": 1,
|
||||
},
|
||||
time.Now(),
|
||||
telegraf.Counter,
|
||||
),
|
||||
},
|
||||
},
|
||||
@@ -892,6 +893,7 @@ func TestParse_DataDogTags(t *testing.T) {
|
||||
"value": 10.1,
|
||||
},
|
||||
time.Now(),
|
||||
telegraf.Gauge,
|
||||
),
|
||||
},
|
||||
},
|
||||
@@ -948,6 +950,7 @@ func TestParse_DataDogTags(t *testing.T) {
|
||||
"value": 42,
|
||||
},
|
||||
time.Now(),
|
||||
telegraf.Counter,
|
||||
),
|
||||
},
|
||||
},
|
||||
@@ -1668,6 +1671,7 @@ func TestTCP(t *testing.T) {
|
||||
"value": 42,
|
||||
},
|
||||
time.Now(),
|
||||
telegraf.Counter,
|
||||
),
|
||||
},
|
||||
acc.GetTelegrafMetrics(),
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package syslog
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/internal"
|
||||
framing "github.com/influxdata/telegraf/internal/syslog"
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -14,16 +16,16 @@ var (
|
||||
type testCasePacket struct {
|
||||
name string
|
||||
data []byte
|
||||
wantBestEffort *testutil.Metric
|
||||
wantStrict *testutil.Metric
|
||||
wantBestEffort telegraf.Metric
|
||||
wantStrict telegraf.Metric
|
||||
werr bool
|
||||
}
|
||||
|
||||
type testCaseStream struct {
|
||||
name string
|
||||
data []byte
|
||||
wantBestEffort []testutil.Metric
|
||||
wantStrict []testutil.Metric
|
||||
wantBestEffort []telegraf.Metric
|
||||
wantStrict []telegraf.Metric
|
||||
werr int // how many errors we expect in the strict mode?
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/internal"
|
||||
framing "github.com/influxdata/telegraf/internal/syslog"
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
@@ -21,10 +21,16 @@ func getTestCasesForNonTransparent() []testCaseStream {
|
||||
{
|
||||
name: "1st/avg/ok",
|
||||
data: []byte(`<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`),
|
||||
wantStrict: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantStrict: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "notice",
|
||||
"facility": "daemon",
|
||||
"hostname": "web1",
|
||||
"appname": "someservice",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"timestamp": time.Unix(1456029177, 0).UnixNano(),
|
||||
"procid": "2341",
|
||||
@@ -36,19 +42,19 @@ func getTestCasesForNonTransparent() []testCaseStream {
|
||||
"severity_code": 5,
|
||||
"facility_code": 3,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "notice",
|
||||
"facility": "daemon",
|
||||
"hostname": "web1",
|
||||
"appname": "someservice",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
wantBestEffort: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "notice",
|
||||
"facility": "daemon",
|
||||
"hostname": "web1",
|
||||
"appname": "someservice",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"timestamp": time.Unix(1456029177, 0).UnixNano(),
|
||||
"procid": "2341",
|
||||
@@ -60,75 +66,69 @@ func getTestCasesForNonTransparent() []testCaseStream {
|
||||
"severity_code": 5,
|
||||
"facility_code": 3,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "notice",
|
||||
"facility": "daemon",
|
||||
"hostname": "web1",
|
||||
"appname": "someservice",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
werr: 1,
|
||||
},
|
||||
{
|
||||
name: "1st/min/ok//2nd/min/ok",
|
||||
data: []byte("<1>2 - - - - - -\n<4>11 - - - - - -\n"),
|
||||
wantStrict: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantStrict: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(2),
|
||||
"severity_code": 1,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
defaultTime,
|
||||
),
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "warning",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"version": uint16(11),
|
||||
"severity_code": 4,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "warning",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime.Add(time.Nanosecond),
|
||||
},
|
||||
defaultTime.Add(time.Nanosecond),
|
||||
),
|
||||
},
|
||||
wantBestEffort: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(2),
|
||||
"severity_code": 1,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
defaultTime,
|
||||
),
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "warning",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"version": uint16(11),
|
||||
"severity_code": 4,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "warning",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime.Add(time.Nanosecond),
|
||||
},
|
||||
defaultTime.Add(time.Nanosecond),
|
||||
),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -186,13 +186,7 @@ func testStrictNonTransparent(t *testing.T, protocol string, address string, wan
|
||||
if len(acc.Errors) != tc.werr {
|
||||
t.Fatalf("Got unexpected errors. want error = %v, errors = %v\n", tc.werr, acc.Errors)
|
||||
}
|
||||
var got []testutil.Metric
|
||||
for _, metric := range acc.Metrics {
|
||||
got = append(got, *metric)
|
||||
}
|
||||
if !cmp.Equal(tc.wantStrict, got) {
|
||||
t.Fatalf("Got (+) / Want (-)\n %s", cmp.Diff(tc.wantStrict, got))
|
||||
}
|
||||
testutil.RequireMetricsEqual(t, tc.wantStrict, acc.GetTelegrafMetrics())
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -240,14 +234,7 @@ func testBestEffortNonTransparent(t *testing.T, protocol string, address string,
|
||||
acc.Wait(len(tc.wantBestEffort))
|
||||
}
|
||||
|
||||
// Verify
|
||||
var got []testutil.Metric
|
||||
for _, metric := range acc.Metrics {
|
||||
got = append(got, *metric)
|
||||
}
|
||||
if !cmp.Equal(tc.wantBestEffort, got) {
|
||||
t.Fatalf("Got (+) / Want (-)\n %s", cmp.Diff(tc.wantBestEffort, got))
|
||||
}
|
||||
testutil.RequireMetricsEqual(t, tc.wantStrict, acc.GetTelegrafMetrics())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/internal"
|
||||
framing "github.com/influxdata/telegraf/internal/syslog"
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
@@ -22,10 +22,16 @@ func getTestCasesForOctetCounting() []testCaseStream {
|
||||
{
|
||||
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`),
|
||||
wantStrict: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantStrict: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "notice",
|
||||
"facility": "daemon",
|
||||
"hostname": "web1",
|
||||
"appname": "someservice",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"timestamp": time.Unix(1456029177, 0).UnixNano(),
|
||||
"procid": "2341",
|
||||
@@ -37,19 +43,19 @@ func getTestCasesForOctetCounting() []testCaseStream {
|
||||
"severity_code": 5,
|
||||
"facility_code": 3,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "notice",
|
||||
"facility": "daemon",
|
||||
"hostname": "web1",
|
||||
"appname": "someservice",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
wantBestEffort: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "notice",
|
||||
"facility": "daemon",
|
||||
"hostname": "web1",
|
||||
"appname": "someservice",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"timestamp": time.Unix(1456029177, 0).UnixNano(),
|
||||
"procid": "2341",
|
||||
@@ -61,221 +67,215 @@ func getTestCasesForOctetCounting() []testCaseStream {
|
||||
"severity_code": 5,
|
||||
"facility_code": 3,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "notice",
|
||||
"facility": "daemon",
|
||||
"hostname": "web1",
|
||||
"appname": "someservice",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "1st/min/ok//2nd/min/ok",
|
||||
data: []byte("16 <1>2 - - - - - -17 <4>11 - - - - - -"),
|
||||
wantStrict: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantStrict: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(2),
|
||||
"severity_code": 1,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
defaultTime,
|
||||
),
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "warning",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"version": uint16(11),
|
||||
"severity_code": 4,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "warning",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime.Add(time.Nanosecond),
|
||||
},
|
||||
defaultTime.Add(time.Nanosecond),
|
||||
),
|
||||
},
|
||||
wantBestEffort: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(2),
|
||||
"severity_code": 1,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
defaultTime,
|
||||
),
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "warning",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"version": uint16(11),
|
||||
"severity_code": 4,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "warning",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime.Add(time.Nanosecond),
|
||||
},
|
||||
defaultTime.Add(time.Nanosecond),
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "1st/utf8/ok",
|
||||
data: []byte("23 <1>1 - - - - - - hellø"),
|
||||
wantStrict: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantStrict: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"message": "hellø",
|
||||
"severity_code": 1,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
wantBestEffort: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"message": "hellø",
|
||||
"severity_code": 1,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "1st/nl/ok", // newline
|
||||
data: []byte("28 <1>3 - - - - - - hello\nworld"),
|
||||
wantStrict: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantStrict: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(3),
|
||||
"message": "hello\nworld",
|
||||
"severity_code": 1,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
wantBestEffort: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(3),
|
||||
"message": "hello\nworld",
|
||||
"severity_code": 1,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "1st/uf/ko", // underflow (msglen less than provided octets)
|
||||
data: []byte("16 <1>2"),
|
||||
wantStrict: nil,
|
||||
wantBestEffort: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(2),
|
||||
"severity_code": 1,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
werr: 1,
|
||||
},
|
||||
{
|
||||
name: "1st/min/ok",
|
||||
data: []byte("16 <1>1 - - - - - -"),
|
||||
wantStrict: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantStrict: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"severity_code": 1,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
wantBestEffort: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"severity_code": 1,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "1st/uf/mf", // The first "underflow" message breaks also the second one
|
||||
data: []byte("16 <1>217 <11>1 - - - - - -"),
|
||||
wantStrict: nil,
|
||||
wantBestEffort: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(217),
|
||||
"severity_code": 1,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
werr: 1,
|
||||
},
|
||||
@@ -287,10 +287,16 @@ func getTestCasesForOctetCounting() []testCaseStream {
|
||||
{
|
||||
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)),
|
||||
wantStrict: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantStrict: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "debug",
|
||||
"facility": "local7",
|
||||
"hostname": maxH,
|
||||
"appname": maxA,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": maxV,
|
||||
"timestamp": time.Unix(1514764799, 999999000).UnixNano(),
|
||||
"message": message7681,
|
||||
@@ -299,19 +305,19 @@ func getTestCasesForOctetCounting() []testCaseStream {
|
||||
"facility_code": 23,
|
||||
"severity_code": 7,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "debug",
|
||||
"facility": "local7",
|
||||
"hostname": maxH,
|
||||
"appname": maxA,
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
wantBestEffort: []testutil.Metric{
|
||||
{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "debug",
|
||||
"facility": "local7",
|
||||
"hostname": maxH,
|
||||
"appname": maxA,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": maxV,
|
||||
"timestamp": time.Unix(1514764799, 999999000).UnixNano(),
|
||||
"message": message7681,
|
||||
@@ -320,14 +326,8 @@ func getTestCasesForOctetCounting() []testCaseStream {
|
||||
"facility_code": 23,
|
||||
"severity_code": 7,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "debug",
|
||||
"facility": "local7",
|
||||
"hostname": maxH,
|
||||
"appname": maxA,
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -386,13 +386,7 @@ func testStrictOctetCounting(t *testing.T, protocol string, address string, want
|
||||
if len(acc.Errors) != tc.werr {
|
||||
t.Fatalf("Got unexpected errors. want error = %v, errors = %v\n", tc.werr, acc.Errors)
|
||||
}
|
||||
var got []testutil.Metric
|
||||
for _, metric := range acc.Metrics {
|
||||
got = append(got, *metric)
|
||||
}
|
||||
if !cmp.Equal(tc.wantStrict, got) {
|
||||
t.Fatalf("Got (+) / Want (-)\n %s", cmp.Diff(tc.wantStrict, got))
|
||||
}
|
||||
testutil.RequireMetricsEqual(t, tc.wantStrict, acc.GetTelegrafMetrics())
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -440,14 +434,7 @@ func testBestEffortOctetCounting(t *testing.T, protocol string, address string,
|
||||
acc.Wait(len(tc.wantBestEffort))
|
||||
}
|
||||
|
||||
// Verify
|
||||
var got []testutil.Metric
|
||||
for _, metric := range acc.Metrics {
|
||||
got = append(got, *metric)
|
||||
}
|
||||
if !cmp.Equal(tc.wantBestEffort, got) {
|
||||
t.Fatalf("Got (+) / Want (-)\n %s", cmp.Diff(tc.wantBestEffort, got))
|
||||
}
|
||||
testutil.RequireMetricsEqual(t, tc.wantBestEffort, acc.GetTelegrafMetrics())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -25,73 +25,79 @@ func getTestCasesForRFC5426() []testCasePacket {
|
||||
{
|
||||
name: "complete",
|
||||
data: []byte("<1>1 - - - - - - A"),
|
||||
wantBestEffort: &testutil.Metric{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"message": "A",
|
||||
"facility_code": 0,
|
||||
"severity_code": 1,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
defaultTime,
|
||||
),
|
||||
wantStrict: testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
wantStrict: &testutil.Metric{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"message": "A",
|
||||
"facility_code": 0,
|
||||
"severity_code": 1,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "one/per/packet",
|
||||
data: []byte("<1>3 - - - - - - A<1>4 - - - - - - B"),
|
||||
wantBestEffort: &testutil.Metric{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(3),
|
||||
"message": "A<1>4 - - - - - - B",
|
||||
"severity_code": 1,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
defaultTime,
|
||||
),
|
||||
wantStrict: testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
wantStrict: &testutil.Metric{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"version": uint16(3),
|
||||
"message": "A<1>4 - - - - - - B",
|
||||
"severity_code": 1,
|
||||
"facility_code": 0,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "average",
|
||||
data: []byte(`<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`),
|
||||
wantBestEffort: &testutil.Metric{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "notice",
|
||||
"facility": "daemon",
|
||||
"hostname": "web1",
|
||||
"appname": "someservice",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"timestamp": time.Unix(1456029177, 0).UnixNano(),
|
||||
"procid": "2341",
|
||||
@@ -103,17 +109,17 @@ func getTestCasesForRFC5426() []testCasePacket {
|
||||
"severity_code": 5,
|
||||
"facility_code": 3,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
defaultTime,
|
||||
),
|
||||
wantStrict: testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "notice",
|
||||
"facility": "daemon",
|
||||
"hostname": "web1",
|
||||
"appname": "someservice",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
wantStrict: &testutil.Metric{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"timestamp": time.Unix(1456029177, 0).UnixNano(),
|
||||
"procid": "2341",
|
||||
@@ -125,21 +131,21 @@ func getTestCasesForRFC5426() []testCasePacket {
|
||||
"severity_code": 5,
|
||||
"facility_code": 3,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "notice",
|
||||
"facility": "daemon",
|
||||
"hostname": "web1",
|
||||
"appname": "someservice",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "max",
|
||||
data: []byte(fmt.Sprintf("<%d>%d %s %s %s %s %s - %s", maxP, maxV, maxTS, maxH, maxA, maxPID, maxMID, message7681)),
|
||||
wantBestEffort: &testutil.Metric{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "debug",
|
||||
"facility": "local7",
|
||||
"hostname": maxH,
|
||||
"appname": maxA,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": maxV,
|
||||
"timestamp": time.Unix(1514764799, 999999000).UnixNano(),
|
||||
"message": message7681,
|
||||
@@ -148,17 +154,17 @@ func getTestCasesForRFC5426() []testCasePacket {
|
||||
"severity_code": 7,
|
||||
"facility_code": 23,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
defaultTime,
|
||||
),
|
||||
wantStrict: testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "debug",
|
||||
"facility": "local7",
|
||||
"hostname": maxH,
|
||||
"appname": maxA,
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
wantStrict: &testutil.Metric{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"version": maxV,
|
||||
"timestamp": time.Unix(1514764799, 999999000).UnixNano(),
|
||||
"message": message7681,
|
||||
@@ -167,64 +173,58 @@ func getTestCasesForRFC5426() []testCasePacket {
|
||||
"severity_code": 7,
|
||||
"facility_code": 23,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "debug",
|
||||
"facility": "local7",
|
||||
"hostname": maxH,
|
||||
"appname": maxA,
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "minimal/incomplete",
|
||||
data: []byte("<1>2"),
|
||||
wantBestEffort: &testutil.Metric{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(2),
|
||||
"facility_code": 0,
|
||||
"severity_code": 1,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
werr: true,
|
||||
},
|
||||
{
|
||||
name: "trim message",
|
||||
data: []byte("<1>1 - - - - - - \tA\n"),
|
||||
wantBestEffort: &testutil.Metric{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
wantBestEffort: testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"message": "\tA",
|
||||
"facility_code": 0,
|
||||
"severity_code": 1,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
defaultTime,
|
||||
),
|
||||
wantStrict: testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
wantStrict: &testutil.Metric{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"message": "\tA",
|
||||
"facility_code": 0,
|
||||
"severity_code": 1,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: defaultTime,
|
||||
},
|
||||
defaultTime,
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -269,19 +269,17 @@ func testRFC5426(t *testing.T, protocol string, address string, bestEffort bool)
|
||||
}
|
||||
|
||||
// Compare
|
||||
var got *testutil.Metric
|
||||
var want *testutil.Metric
|
||||
var got telegraf.Metric
|
||||
var want telegraf.Metric
|
||||
if len(acc.Metrics) > 0 {
|
||||
got = acc.Metrics[0]
|
||||
got = acc.GetTelegrafMetrics()[0]
|
||||
}
|
||||
if bestEffort {
|
||||
want = tc.wantBestEffort
|
||||
} else {
|
||||
want = tc.wantStrict
|
||||
}
|
||||
if !cmp.Equal(want, got) {
|
||||
t.Fatalf("Got (+) / Want (-)\n %s", cmp.Diff(want, got))
|
||||
}
|
||||
testutil.RequireMetricEqual(t, want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -346,23 +344,22 @@ func TestTimeIncrement_udp(t *testing.T) {
|
||||
// Wait
|
||||
acc.Wait(1)
|
||||
|
||||
want := &testutil.Metric{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"facility_code": 0,
|
||||
"severity_code": 1,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: getNow(),
|
||||
}
|
||||
|
||||
if !cmp.Equal(want, acc.Metrics[0]) {
|
||||
t.Fatalf("Got (+) / Want (-)\n %s", cmp.Diff(want, acc.Metrics[0]))
|
||||
want := []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"facility_code": 0,
|
||||
"severity_code": 1,
|
||||
},
|
||||
getNow(),
|
||||
),
|
||||
}
|
||||
testutil.RequireMetricsEqual(t, want, acc.GetTelegrafMetrics())
|
||||
|
||||
// New one with different time
|
||||
atomic.StoreInt64(&i, atomic.LoadInt64(&i)+1)
|
||||
@@ -377,23 +374,22 @@ func TestTimeIncrement_udp(t *testing.T) {
|
||||
// Wait
|
||||
acc.Wait(1)
|
||||
|
||||
want = &testutil.Metric{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"facility_code": 0,
|
||||
"severity_code": 1,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: getNow(),
|
||||
}
|
||||
|
||||
if !cmp.Equal(want, acc.Metrics[0]) {
|
||||
t.Fatalf("Got (+) / Want (-)\n %s", cmp.Diff(want, acc.Metrics[0]))
|
||||
want = []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"facility_code": 0,
|
||||
"severity_code": 1,
|
||||
},
|
||||
getNow(),
|
||||
),
|
||||
}
|
||||
testutil.RequireMetricsEqual(t, want, acc.GetTelegrafMetrics())
|
||||
|
||||
// New one with same time as previous one
|
||||
|
||||
@@ -407,21 +403,20 @@ func TestTimeIncrement_udp(t *testing.T) {
|
||||
// Wait
|
||||
acc.Wait(1)
|
||||
|
||||
want = &testutil.Metric{
|
||||
Measurement: "syslog",
|
||||
Fields: map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"facility_code": 0,
|
||||
"severity_code": 1,
|
||||
},
|
||||
Tags: map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
Time: getNow().Add(time.Nanosecond),
|
||||
}
|
||||
|
||||
if !cmp.Equal(want, acc.Metrics[0]) {
|
||||
t.Fatalf("Got (+) / Want (-)\n %s", cmp.Diff(want, acc.Metrics[0]))
|
||||
want = []telegraf.Metric{
|
||||
testutil.MustMetric(
|
||||
"syslog",
|
||||
map[string]string{
|
||||
"severity": "alert",
|
||||
"facility": "kern",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"version": uint16(1),
|
||||
"facility_code": 0,
|
||||
"severity_code": 1,
|
||||
},
|
||||
getNow().Add(time.Nanosecond),
|
||||
),
|
||||
}
|
||||
testutil.RequireMetricsEqual(t, want, acc.GetTelegrafMetrics())
|
||||
}
|
||||
|
||||
@@ -121,6 +121,7 @@ func TestLineProtocolConverter_Record(t *testing.T) {
|
||||
"duration_ns": (time.Duration(53106) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360851331000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -138,6 +139,7 @@ func TestLineProtocolConverter_Record(t *testing.T) {
|
||||
"duration_ns": (time.Duration(53106) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360851331000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -152,6 +154,7 @@ func TestLineProtocolConverter_Record(t *testing.T) {
|
||||
"duration_ns": (time.Duration(50410) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360904552000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -169,6 +172,7 @@ func TestLineProtocolConverter_Record(t *testing.T) {
|
||||
"duration_ns": (time.Duration(50410) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360904552000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -183,6 +187,7 @@ func TestLineProtocolConverter_Record(t *testing.T) {
|
||||
"duration_ns": (time.Duration(103680) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360851318000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -199,6 +204,7 @@ func TestLineProtocolConverter_Record(t *testing.T) {
|
||||
"duration_ns": (time.Duration(103680) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360851318000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -215,6 +221,7 @@ func TestLineProtocolConverter_Record(t *testing.T) {
|
||||
"duration_ns": (time.Duration(103680) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360851318000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -231,6 +238,7 @@ func TestLineProtocolConverter_Record(t *testing.T) {
|
||||
"duration_ns": (time.Duration(103680) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360851318000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -248,6 +256,7 @@ func TestLineProtocolConverter_Record(t *testing.T) {
|
||||
"duration_ns": (time.Duration(103680) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360851318000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
@@ -296,6 +305,7 @@ func TestLineProtocolConverter_Record(t *testing.T) {
|
||||
"duration_ns": (time.Duration(1) * time.Nanosecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(1, 0).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -312,6 +322,7 @@ func TestLineProtocolConverter_Record(t *testing.T) {
|
||||
"duration_ns": (time.Duration(1) * time.Nanosecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(1, 0).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
)
|
||||
|
||||
@@ -40,6 +41,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": (time.Duration(53106) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360851331000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -57,6 +59,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": (time.Duration(53106) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360851331000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -71,6 +74,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": (time.Duration(50410) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360904552000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -88,6 +92,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": (time.Duration(50410) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360904552000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -102,6 +107,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": (time.Duration(103680) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360851318000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -118,6 +124,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": (time.Duration(103680) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360851318000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -134,6 +141,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": (time.Duration(103680) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360851318000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -150,6 +158,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": (time.Duration(103680) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360851318000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -167,6 +176,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": (time.Duration(103680) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1498688360851318000).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
@@ -189,6 +199,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": (time.Duration(1) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1433330263415871*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -205,6 +216,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": (time.Duration(1) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1433330263415871*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -221,6 +233,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": (time.Duration(1) * time.Microsecond).Nanoseconds(),
|
||||
},
|
||||
Time: time.Unix(0, 1433330263415871*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -240,7 +253,9 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
},
|
||||
Fields: map[string]interface{}{
|
||||
"duration_ns": int64(3000000),
|
||||
}, Time: time.Unix(0, 1503031538791000*int64(time.Microsecond)).UTC(),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538791000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -257,6 +272,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(3000000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538791000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -273,6 +289,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(3000000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538791000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -290,6 +307,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(3000000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538791000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -307,6 +325,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(3000000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538791000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -324,6 +343,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(3000000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538791000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -338,6 +358,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(10000000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538786000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -354,6 +375,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(10000000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538786000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -370,6 +392,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(10000000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538786000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -387,6 +410,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(10000000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538786000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -404,6 +428,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(10000000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538786000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -421,6 +446,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(10000000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538786000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -438,6 +464,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(10000000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538786000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -455,6 +482,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(10000000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538786000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -469,6 +497,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(23393000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538778000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -485,6 +514,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(23393000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538778000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -501,6 +531,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(23393000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538778000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -518,6 +549,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(23393000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538778000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -535,6 +567,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(23393000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538778000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
{
|
||||
Measurement: "zipkin",
|
||||
@@ -552,6 +585,7 @@ func TestZipkinPlugin(t *testing.T) {
|
||||
"duration_ns": int64(23393000),
|
||||
},
|
||||
Time: time.Unix(0, 1503031538778000*int64(time.Microsecond)).UTC(),
|
||||
Type: telegraf.Untyped,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user