Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/bustedware/telegraf
Browse files Browse the repository at this point in the history
  • Loading branch information
bustedware committed Oct 26, 2023
2 parents 2c1e0cf + becebf2 commit 312c76d
Show file tree
Hide file tree
Showing 87 changed files with 1,143 additions and 541 deletions.
16 changes: 8 additions & 8 deletions agent/accumulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/models"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestAddFields(t *testing.T) {
Expand Down Expand Up @@ -61,12 +61,12 @@ func TestAccAddError(t *testing.T) {

errs := bytes.Split(errBuf.Bytes(), []byte{'\n'})
require.Len(t, errs, 4) // 4 because of trailing newline
assert.Contains(t, string(errs[0]), "TestPlugin")
assert.Contains(t, string(errs[0]), "foo")
assert.Contains(t, string(errs[1]), "TestPlugin")
assert.Contains(t, string(errs[1]), "bar")
assert.Contains(t, string(errs[2]), "TestPlugin")
assert.Contains(t, string(errs[2]), "baz")
require.Contains(t, string(errs[0]), "TestPlugin")
require.Contains(t, string(errs[0]), "foo")
require.Contains(t, string(errs[1]), "TestPlugin")
require.Contains(t, string(errs[1]), "bar")
require.Contains(t, string(errs[2]), "TestPlugin")
require.Contains(t, string(errs[2]), "baz")
}

func TestSetPrecision(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestAgent_LoadPlugin(t *testing.T) {
err = c.LoadConfig("../config/testdata/telegraf-agent.toml")
require.NoError(t, err)
a = NewAgent(c)
require.Equal(t, 0, len(a.Config.Inputs))
require.Empty(t, a.Config.Inputs)

c = config.NewConfig()
c.InputFilters = []string{"mysql", "foo"}
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestAgent_LoadOutput(t *testing.T) {
err = c.LoadConfig("../config/testdata/telegraf-agent.toml")
require.NoError(t, err)
a = NewAgent(c)
require.Equal(t, 0, len(a.Config.Outputs))
require.Empty(t, a.Config.Outputs)

c = config.NewConfig()
c.OutputFilters = []string{"influxdb", "foo"}
Expand Down
1 change: 1 addition & 0 deletions docs/LICENSE_OF_DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ following works:
- github.com/mdlayher/genetlink [MIT License](https://github.com/mdlayher/genetlink/blob/master/LICENSE.md)
- github.com/mdlayher/netlink [MIT License](https://github.com/mdlayher/netlink/blob/master/LICENSE.md)
- github.com/mdlayher/socket [MIT License](https://github.com/mdlayher/socket/blob/master/LICENSE.md)
- github.com/mdlayher/vsock [MIT License](https://github.com/mdlayher/vsock/blob/master/LICENSE.md)
- github.com/microsoft/ApplicationInsights-Go [MIT License](https://github.com/microsoft/ApplicationInsights-Go/blob/master/LICENSE)
- github.com/microsoft/go-mssqldb [BSD 3-Clause "New" or "Revised" License](https://github.com/microsoft/go-mssqldb/blob/master/LICENSE.txt)
- github.com/miekg/dns [BSD 3-Clause Clear License](https://github.com/miekg/dns/blob/master/LICENSE)
Expand Down
42 changes: 21 additions & 21 deletions filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@ package filter
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestCompile(t *testing.T) {
f, err := Compile([]string{})
assert.NoError(t, err)
assert.Nil(t, f)
require.NoError(t, err)
require.Nil(t, f)

f, err = Compile([]string{"cpu"})
assert.NoError(t, err)
assert.True(t, f.Match("cpu"))
assert.False(t, f.Match("cpu0"))
assert.False(t, f.Match("mem"))
require.NoError(t, err)
require.True(t, f.Match("cpu"))
require.False(t, f.Match("cpu0"))
require.False(t, f.Match("mem"))

f, err = Compile([]string{"cpu*"})
assert.NoError(t, err)
assert.True(t, f.Match("cpu"))
assert.True(t, f.Match("cpu0"))
assert.False(t, f.Match("mem"))
require.NoError(t, err)
require.True(t, f.Match("cpu"))
require.True(t, f.Match("cpu0"))
require.False(t, f.Match("mem"))

f, err = Compile([]string{"cpu", "mem"})
assert.NoError(t, err)
assert.True(t, f.Match("cpu"))
assert.False(t, f.Match("cpu0"))
assert.True(t, f.Match("mem"))
require.NoError(t, err)
require.True(t, f.Match("cpu"))
require.False(t, f.Match("cpu0"))
require.True(t, f.Match("mem"))

f, err = Compile([]string{"cpu", "mem", "net*"})
assert.NoError(t, err)
assert.True(t, f.Match("cpu"))
assert.False(t, f.Match("cpu0"))
assert.True(t, f.Match("mem"))
assert.True(t, f.Match("network"))
require.NoError(t, err)
require.True(t, f.Match("cpu"))
require.False(t, f.Match("cpu0"))
require.True(t, f.Match("mem"))
require.True(t, f.Match("network"))
}

func TestIncludeExclude(t *testing.T) {
Expand All @@ -52,7 +52,7 @@ func TestIncludeExclude(t *testing.T) {
}
}

assert.Equal(t, []string{"best", "timeseries", "ever"}, tags)
require.Equal(t, []string{"best", "timeseries", "ever"}, tags)
}

var benchbool bool
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ require (
github.com/lxc/lxd v0.0.0-20220920163450-e9b4b514106a
github.com/matttproud/golang_protobuf_extensions v1.0.4
github.com/mdlayher/apcupsd v0.0.0-20220319200143-473c7b5f3c6a
github.com/mdlayher/vsock v1.1.1
github.com/microsoft/ApplicationInsights-Go v0.4.4
github.com/microsoft/go-mssqldb v1.5.0
github.com/miekg/dns v1.1.56
Expand Down Expand Up @@ -203,7 +204,7 @@ require (
gonum.org/v1/gonum v0.14.0
google.golang.org/api v0.147.0
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97
google.golang.org/grpc v1.58.2
google.golang.org/grpc v1.58.3
google.golang.org/protobuf v1.31.0
gopkg.in/gorethink/gorethink.v3 v3.0.5
gopkg.in/olivere/elastic.v5 v5.0.86
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,8 @@ github.com/mdlayher/socket v0.0.0-20211102153432-57e3fa563ecb/go.mod h1:nFZ1EtZY
github.com/mdlayher/socket v0.1.1/go.mod h1:mYV5YIZAfHh4dzDVzI8x8tWLWCliuX8Mon5Awbj+qDs=
github.com/mdlayher/socket v0.2.3 h1:XZA2X2TjdOwNoNPVPclRCURoX/hokBY8nkTmRZFEheM=
github.com/mdlayher/socket v0.2.3/go.mod h1:bz12/FozYNH/VbvC3q7TRIK/Y6dH1kCKsXaUeXi/FmY=
github.com/mdlayher/vsock v1.1.1 h1:8lFuiXQnmICBrCIIA9PMgVSke6Fg6V4+r0v7r55k88I=
github.com/mdlayher/vsock v1.1.1/go.mod h1:Y43jzcy7KM3QB+/FK15pfqGxDMCMzUXWegEfIbSM18U=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/mholt/archiver/v3 v3.5.0/go.mod h1:qqTTPUK/HZPFgFQ/TJ3BzvTpF/dPtFVJXdQbCmeMxwc=
github.com/microsoft/ApplicationInsights-Go v0.4.4 h1:G4+H9WNs6ygSCe6sUyxRc2U81TI5Es90b2t/MwX5KqY=
Expand Down Expand Up @@ -2016,8 +2018,8 @@ google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG
google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I=
google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ=
google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
Expand Down
7 changes: 3 additions & 4 deletions internal/templating/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package templating
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -69,9 +68,9 @@ func TestEngineWithWildcardTemplate(t *testing.T) {
measurement, tags, field, err := engine.Apply(testCase.line)
require.NoError(t, err)

assert.Equal(t, testCase.measurement, measurement)
assert.Equal(t, testCase.field, field)
assert.Equal(t, testCase.tags, tags)
require.Equal(t, testCase.measurement, measurement)
require.Equal(t, testCase.field, field)
require.Equal(t, testCase.tags, tags)
})
}
}
7 changes: 4 additions & 3 deletions models/buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/metric"
"github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/require"
)

type MockMetric struct {
Expand Down Expand Up @@ -95,14 +96,14 @@ func TestBuffer_BatchLenZero(t *testing.T) {
b := setup(NewBuffer("test", "", 5))
batch := b.Batch(0)

require.Len(t, batch, 0)
require.Empty(t, batch)
}

func TestBuffer_BatchLenBufferEmpty(t *testing.T) {
b := setup(NewBuffer("test", "", 5))
batch := b.Batch(2)

require.Len(t, batch, 0)
require.Empty(t, batch)
}

func TestBuffer_BatchLenUnderfill(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion models/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestFilter_ApplyDeleteAllFields(t *testing.T) {
require.NoError(t, err)
require.True(t, selected)
f.Modify(m)
require.Len(t, m.FieldList(), 0)
require.Empty(t, m.FieldList())
}

func TestFilter_Empty(t *testing.T) {
Expand Down
7 changes: 3 additions & 4 deletions models/running_input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import (
"testing"
"time"

"github.com/influxdata/telegraf/selfstat"
"github.com/stretchr/testify/require"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/metric"
"github.com/influxdata/telegraf/selfstat"
"github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestMakeMetricFilterAfterApplyingGlobalTags(t *testing.T) {
Expand Down Expand Up @@ -127,7 +126,7 @@ func TestMakeMetricFilteredOut(t *testing.T) {
Filter: Filter{NamePass: []string{"foobar"}},
})

assert.NoError(t, ri.Config.Filter.Compile())
require.NoError(t, ri.Config.Filter.Compile())

m := metric.New("RITest",
map[string]string{},
Expand Down
Loading

0 comments on commit 312c76d

Please sign in to comment.