Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feat/processors/s…
Browse files Browse the repository at this point in the history
…nmp_lookup

* upstream/master:
  chore(linters): Fix findings found by testifylint: expected-actual (influxdata#14229)
  chore(deps): Bump github.com/nats-io/nkeys from 0.4.5 to 0.4.6 (influxdata#14225)
  feat(inputs.procstat)!: Remove useless zero cpu_times (influxdata#14224)
  feat(inputs.gnmi): Rework plugin (influxdata#14091)
  fix(outputs.timestream): Clip uint64 values (influxdata#14213)
  fix(inputs.cgroup): Escape backslashes (influxdata#14187)
  test(outputs.kafka): Use private network for testing (influxdata#14220)
  test(inputs.vault): Fix integration test by only testing for subset (influxdata#14222)
  fix(outputs.elasticsearch): Print error status value (influxdata#14115)
  • Loading branch information
Hipska committed Nov 2, 2023
2 parents a0d0ac7 + 8fbea28 commit f4fd7ce
Show file tree
Hide file tree
Showing 92 changed files with 1,701 additions and 581 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<!-- markdownlint-disable MD024 -->
# Changelog

## Unreleased

### Important Changes

- Remove useless, all-zero fields in `inputs.procstat`. Up to now, Telegraf
reports the fields `cpu_time_guest`, `cpu_time_guest_nice`, `cpu_time_idle`,
`cpu_time_irq`, `cpu_time_nice`, `cpu_time_soft_irq` and `cpu_time_steal`
which are never set by the underlying library. As a consequence those fields
were always zero. [#14224](https://github.com/influxdata/telegraf/pull/14224)
removes those useless fields. In case you reference them, please adapt your
queries!

## v1.28.3 [2023-10-23]

### Bugfixes
Expand Down
2 changes: 1 addition & 1 deletion config/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestConfigDuration(t *testing.T) {
p := c.Processors[0].Processor.(*reverse_dns.ReverseDNS)
require.EqualValues(t, p.CacheTTL, 3*time.Hour)
require.EqualValues(t, p.LookupTimeout, 17*time.Second)
require.Equal(t, p.MaxParallelLookups, 13)
require.Equal(t, 13, p.MaxParallelLookups)
require.True(t, p.Ordered)
}

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 @@ -96,6 +96,7 @@ following works:
- github.com/cloudevents/sdk-go [Apache License 2.0](https://github.com/cloudevents/sdk-go/blob/main/LICENSE)
- github.com/compose-spec/compose-go [Apache License 2.0](https://github.com/compose-spec/compose-go/blob/master/LICENSE)
- github.com/containerd/containerd [Apache License 2.0](https://github.com/containerd/containerd/blob/master/LICENSE)
- github.com/containerd/log [Apache License 2.0](https://github.com/containerd/log/blob/main/LICENSE)
- github.com/coocood/freecache [MIT License](https://github.com/coocood/freecache/blob/master/LICENSE)
- github.com/coreos/go-semver [Apache License 2.0](https://github.com/coreos/go-semver/blob/main/LICENSE)
- github.com/coreos/go-systemd [Apache License 2.0](https://github.com/coreos/go-systemd/blob/main/LICENSE)
Expand Down
15 changes: 8 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ require (
github.com/safchain/ethtool v0.3.0
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
github.com/sensu/sensu-go/api/core/v2 v2.16.0
github.com/shirou/gopsutil/v3 v3.23.8
github.com/shirou/gopsutil/v3 v3.23.9
github.com/showwin/speedtest-go v1.6.6
github.com/signalfx/golib/v3 v3.3.53
github.com/sirupsen/logrus v1.9.3
Expand All @@ -175,7 +175,7 @@ require (
github.com/srebhan/protobufquery v0.0.0-20230803132024-ae4c0d878e55
github.com/stretchr/testify v1.8.4
github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62
github.com/testcontainers/testcontainers-go v0.25.0
github.com/testcontainers/testcontainers-go v0.26.0
github.com/thomasklein94/packer-plugin-libvirt v0.5.0
github.com/tidwall/gjson v1.14.4
github.com/tinylib/msgp v1.1.8
Expand Down Expand Up @@ -249,7 +249,7 @@ require (
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/semver/v3 v3.2.0
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/hcsshim v0.11.0 // indirect
github.com/Microsoft/hcsshim v0.11.1 // indirect
github.com/alecthomas/participle v0.4.1 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df // indirect
Expand Down Expand Up @@ -284,7 +284,8 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cloudevents/sdk-go/v2 v2.14.0
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect
github.com/containerd/containerd v1.7.6 // indirect
github.com/containerd/containerd v1.7.7 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/couchbase/gomemcached v0.1.3 // indirect
github.com/couchbase/goutils v0.1.0 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
Expand Down Expand Up @@ -385,7 +386,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/patternmatcher v0.5.0 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand All @@ -396,11 +397,11 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/naoina/go-stringutil v0.1.0 // indirect
github.com/nats-io/jwt/v2 v2.5.0 // indirect
github.com/nats-io/nkeys v0.4.5 // indirect
github.com/nats-io/nkeys v0.4.6 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.84.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc4 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/opencontainers/runc v1.1.5 // indirect
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492 // indirect
github.com/pborman/uuid v1.2.1 // indirect
Expand Down
31 changes: 17 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,8 @@ github.com/Mellanox/rdmamap v1.1.0/go.mod h1:fN+/V9lf10ABnDCwTaXRjeeWijLt2iVLETn
github.com/Microsoft/go-winio v0.4.15/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/Microsoft/hcsshim v0.11.0 h1:7EFNIY4igHEXUdj1zXgAyU3fLc7QfOKHbkldRVTBdiM=
github.com/Microsoft/hcsshim v0.11.0/go.mod h1:OEthFdQv/AD2RAdzR6Mm1N1KPCztGKDurW1Z8b8VGMM=
github.com/Microsoft/hcsshim v0.11.1 h1:hJ3s7GbWlGK4YVV92sO88BQSyF4ZLVy7/awqOlPxFbA=
github.com/Microsoft/hcsshim v0.11.1/go.mod h1:nFJmaO4Zr5Y7eADdFOpYswDDlNVbvcIJJNJLECr5JQg=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/PaesslerAG/gval v1.2.2 h1:Y7iBzhgE09IGTt5QgGQ2IdaYYYOU134YGHBThD+wm9E=
github.com/PaesslerAG/gval v1.2.2/go.mod h1:XRFLwvmkTEdYziLdaCeCa5ImcGVrfQbeNUbVR+C6xac=
Expand Down Expand Up @@ -1003,8 +1003,10 @@ github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMe
github.com/compose-spec/compose-go v1.20.0 h1:h4ZKOst1EF/DwZp7dWkb+wbTVE4nEyT9Lc89to84Ol4=
github.com/compose-spec/compose-go v1.20.0/go.mod h1:+MdqXV4RA7wdFsahh/Kb8U0pAJqkg7mr4PM9tFKU8RM=
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
github.com/containerd/containerd v1.7.6 h1:oNAVsnhPoy4BTPQivLgTzI9Oleml9l/+eYIDYXRCYo8=
github.com/containerd/containerd v1.7.6/go.mod h1:SY6lrkkuJT40BVNO37tlYTSnKJnP5AXBc0fhx0q+TJ4=
github.com/containerd/containerd v1.7.7 h1:QOC2K4A42RQpcrZyptP6z9EJZnlHfHJUfZrAAHe15q4=
github.com/containerd/containerd v1.7.7/go.mod h1:3c4XZv6VeT9qgf9GMTxNTMFxGJrGpI2vz1yk4ye+YY8=
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
github.com/coocood/freecache v1.2.3 h1:lcBwpZrwBZRZyLk/8EMyQVXRiFl663cCuMOrjCALeto=
github.com/coocood/freecache v1.2.3/go.mod h1:RBUWa/Cy+OHdfTGFEhEuE1pMCMX51Ncizj7rthiQ3vk=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
Expand Down Expand Up @@ -1816,8 +1818,8 @@ github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx
github.com/moby/ipvs v1.1.0 h1:ONN4pGaZQgAx+1Scz5RvWV4Q7Gb+mvfRh3NsPS+1XQQ=
github.com/moby/ipvs v1.1.0/go.mod h1:4VJMWuf098bsUMmZEiD4Tjk/O7mOn3l1PTD3s4OoYAs=
github.com/moby/moby v24.0.6+incompatible/go.mod h1:fDXVQ6+S340veQPv35CzDahGBmHsiclFwfEygB/TWMc=
github.com/moby/patternmatcher v0.5.0 h1:YCZgJOeULcxLw1Q+sVR636pmS7sPEn1Qo2iAN6M7DBo=
github.com/moby/patternmatcher v0.5.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU=
github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc=
github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo=
Expand Down Expand Up @@ -1852,8 +1854,8 @@ github.com/nats-io/nats-server/v2 v2.9.23 h1:6Wj6H6QpP9FMlpCyWUaNu2yeZ/qGj+mdRkZ
github.com/nats-io/nats-server/v2 v2.9.23/go.mod h1:wEjrEy9vnqIGE4Pqz4/c75v9Pmaq7My2IgFmnykc4C0=
github.com/nats-io/nats.go v1.31.0 h1:/WFBHEc/dOKBF6qf1TZhrdEfTmOZ5JzdJ+Y3m6Y/p7E=
github.com/nats-io/nats.go v1.31.0/go.mod h1:di3Bm5MLsoB4Bx61CBTsxuarI36WbhAwOm8QrW39+i8=
github.com/nats-io/nkeys v0.4.5 h1:Zdz2BUlFm4fJlierwvGK+yl20IAKUm7eV6AAZXEhkPk=
github.com/nats-io/nkeys v0.4.5/go.mod h1:XUkxdLPTufzlihbamfzQ7mw/VGx6ObUs+0bN5sNvt64=
github.com/nats-io/nkeys v0.4.6 h1:IzVe95ru2CT6ta874rt9saQRkWfe2nFj1NtvYSLqMzY=
github.com/nats-io/nkeys v0.4.6/go.mod h1:4DxZNzenSVd1cYQoAa8948QY3QDjrHfcfVADymtkpts=
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/netsampler/goflow2 v1.3.6 h1:fZbHDcWPcG+nkg2wGHCv4VJ9MrG8iA16YmuYhrSAEdQ=
Expand Down Expand Up @@ -1911,8 +1913,8 @@ github.com/openconfig/ygot v0.20.0/go.mod h1:7ZiBFNc4n/1Hkv2v2dAEpxisqDznp0JVpLR
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/image-spec v1.1.0-rc4 h1:oOxKUJWnFC4YGHCCMNql1x4YaDfYBTS5Y4x/Cgeo1E0=
github.com/opencontainers/image-spec v1.1.0-rc4/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8=
github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI=
github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8=
github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/GDEs=
github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg=
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
Expand Down Expand Up @@ -2067,8 +2069,8 @@ github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod
github.com/sensu/sensu-go/api/core/v2 v2.16.0 h1:HOq4rFkQ1S5ZjxmMTLc5J5mAbECrnKWvtXXbMqr3j9s=
github.com/sensu/sensu-go/api/core/v2 v2.16.0/go.mod h1:MjM7+MCGEyTAgaZ589SiGHwYiaYF7N/58dU0J070u/0=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shirou/gopsutil/v3 v3.23.8 h1:xnATPiybo6GgdRoC4YoGnxXZFRc3dqQTGi73oLvvBrE=
github.com/shirou/gopsutil/v3 v3.23.8/go.mod h1:7hmCaBn+2ZwaZOr6jmPBZDfawwMGuo1id3C6aM8EDqQ=
github.com/shirou/gopsutil/v3 v3.23.9 h1:ZI5bWVeu2ep4/DIxB4U9okeYJ7zp/QLTO4auRb/ty/E=
github.com/shirou/gopsutil/v3 v3.23.9/go.mod h1:x/NWSb71eMcjFIO0vhyGW5nZ7oSIgVjrCnADckb85GA=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
Expand Down Expand Up @@ -2160,8 +2162,8 @@ github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG
github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62 h1:Oj2e7Sae4XrOsk3ij21QjjEgAcVSeo9nkp0dI//cD2o=
github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62/go.mod h1:qUzPVlSj2UgxJkVbH0ZwuuiR46U8RBMDT5KLY78Ifpw=
github.com/tedsuo/ifrit v0.0.0-20180802180643-bea94bb476cc/go.mod h1:eyZnKCc955uh98WQvzOm0dgAeLnf2O0Rz0LPoC5ze+0=
github.com/testcontainers/testcontainers-go v0.25.0 h1:erH6cQjsaJrH+rJDU9qIf89KFdhK0Bft0aEZHlYC3Vs=
github.com/testcontainers/testcontainers-go v0.25.0/go.mod h1:4sC9SiJyzD1XFi59q8umTQYWxnkweEc5OjVtTUlJzqQ=
github.com/testcontainers/testcontainers-go v0.26.0 h1:uqcYdoOHBy1ca7gKODfBd9uTHVK3a7UL848z09MVZ0c=
github.com/testcontainers/testcontainers-go v0.26.0/go.mod h1:ICriE9bLX5CLxL9OFQ2N+2N+f+803LNJ1utJb1+Inx0=
github.com/thomasklein94/packer-plugin-libvirt v0.5.0 h1:aj2HLHZZM/ClGLIwVp9rrgh+2TOU/w4EiaZHAwCpOgs=
github.com/thomasklein94/packer-plugin-libvirt v0.5.0/go.mod h1:GwN82FQ6KxCNKtS8LNUgLbwTZs90GGhBzCmTNkrTCrY=
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
Expand Down Expand Up @@ -2693,6 +2695,7 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
Expand Down
9 changes: 5 additions & 4 deletions plugins/common/opcua/input/input_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ import (
"time"

"github.com/gopcua/opcua/ua"
"github.com/stretchr/testify/require"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config"
"github.com/influxdata/telegraf/metric"
"github.com/influxdata/telegraf/plugins/common/opcua"
"github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/require"
)

func TestTagsSliceToMap(t *testing.T) {
m, err := tagsSliceToMap([][]string{{"foo", "bar"}, {"baz", "bat"}})
require.NoError(t, err)
require.Len(t, m, 2)
require.Equal(t, m["foo"], "bar")
require.Equal(t, m["baz"], "bat")
require.Equal(t, "bar", m["foo"])
require.Equal(t, "bat", m["baz"])
}

func TestTagsSliceToMap_twoStrings(t *testing.T) {
Expand Down Expand Up @@ -316,7 +317,7 @@ func TestNewNodeMetricMappingIdStrInstantiated(t *testing.T) {
TagsSlice: [][]string{},
}, map[string]string{})
require.NoError(t, err)
require.Equal(t, nmm.idStr, "ns=2;s=h")
require.Equal(t, "ns=2;s=h", nmm.idStr)
}

func TestValidateNodeToAdd(t *testing.T) {
Expand Down
11 changes: 6 additions & 5 deletions plugins/inputs/beat/beat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (
"os"
"testing"

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

"github.com/influxdata/telegraf/testutil"
)

func Test_BeatStats(t *testing.T) {
Expand Down Expand Up @@ -177,10 +178,10 @@ func Test_BeatRequest(t *testing.T) {

data, err := os.ReadFile(jsonFilePath)
require.NoErrorf(t, err, "could not read from data file %s", jsonFilePath)
require.Equal(t, request.Host, "beat.test.local")
require.Equal(t, request.Method, "POST")
require.Equal(t, request.Header.Get("Authorization"), "Basic YWRtaW46UFdE")
require.Equal(t, request.Header.Get("X-Test"), "test-value")
require.Equal(t, "beat.test.local", request.Host)
require.Equal(t, "POST", request.Method)
require.Equal(t, "Basic YWRtaW46UFdE", request.Header.Get("Authorization"))
require.Equal(t, "test-value", request.Header.Get("X-Test"))

_, err = w.Write(data)
require.NoError(t, err, "could not write data")
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/ceph/ceph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type expectedResult struct {

func TestParseSockId(t *testing.T) {
s := parseSockID(sockFile(osdPrefix, 1), osdPrefix, sockSuffix)
require.Equal(t, s, "1")
require.Equal(t, "1", s)
}

func TestParseMonDump(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions plugins/inputs/cgroup/cgroup_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ func (g *CGroup) generateDirs(list chan<- pathInfo) {
}

func (g *CGroup) generateFiles(dir string, list chan<- pathInfo) {
dir = strings.Replace(dir, "\\", "\\\\", -1)

defer close(list)
for _, file := range g.Files {
// getting all file paths that match the pattern 'dir + file'
Expand Down
26 changes: 26 additions & 0 deletions plugins/inputs/cgroup/cgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,29 @@ func TestCgroupStatistics_8(t *testing.T) {
require.NoError(t, acc.GatherError(cg.Gather))
require.Len(t, cg.logged, 1)
}

func TestCgroupEscapeDir(t *testing.T) {
var acc testutil.Accumulator
var cg = &CGroup{
Paths: []string{"testdata/backslash/machine-qemu\x2d1\x2d*"},
Files: []string{"cpu.stat"},
logged: make(map[string]bool),
}

expected := []telegraf.Metric{
metric.New(
"cgroup",
map[string]string{"path": `testdata/backslash/machine-qemu-1-ubuntu`},
map[string]interface{}{
"cpu.stat.core_sched.force_idle_usec": int64(0),
"cpu.stat.system_usec": int64(103537582650),
"cpu.stat.usage_usec": int64(614953149468),
"cpu.stat.user_usec": int64(511415566817),
},
time.Unix(0, 0),
),
}

require.NoError(t, acc.GatherError(cg.Gather))
testutil.RequireMetricsEqual(t, expected, acc.GetTelegrafMetrics(), testutil.IgnoreTime())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
usage_usec 614953149468
user_usec 511415566817
system_usec 103537582650
core_sched.force_idle_usec 0
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ func TestTCPDialoutMultiple(t *testing.T) {
require.NoError(t, conn.Close())

// We use the invalid dialout flags to let the server close the connection
require.Equal(t, acc.Errors, []error{errors.New("invalid dialout flags: 257"), errors.New("invalid dialout flags: 257")})
require.Equal(t, []error{errors.New("invalid dialout flags: 257"), errors.New("invalid dialout flags: 257")}, acc.Errors)

tags := map[string]string{
"path": "type:model/some/path",
Expand Down Expand Up @@ -1060,7 +1060,7 @@ func TestGRPCDialoutError(t *testing.T) {
require.True(t, err == nil || errors.Is(err, io.EOF))
c.Stop()

require.Equal(t, acc.Errors, []error{errors.New("GRPC dialout error: foobar")})
require.Equal(t, []error{errors.New("GRPC dialout error: foobar")}, acc.Errors)
}

func TestGRPCDialoutMultiple(t *testing.T) {
Expand Down Expand Up @@ -1119,7 +1119,7 @@ func TestGRPCDialoutMultiple(t *testing.T) {
c.Stop()
require.NoError(t, conn.Close())

require.Equal(t, acc.Errors, []error{errors.New("GRPC dialout error: testclose"), errors.New("GRPC dialout error: testclose")})
require.Equal(t, []error{errors.New("GRPC dialout error: testclose"), errors.New("GRPC dialout error: testclose")}, acc.Errors)

tags := map[string]string{
"path": "type:model/some/path",
Expand Down
10 changes: 5 additions & 5 deletions plugins/inputs/cloud_pubsub/cloud_pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestRunParse(t *testing.T) {
sub.messages <- msg

acc.Wait(1)
require.Equal(t, acc.NFields(), 1)
require.Equal(t, 1, acc.NFields())
metric := acc.Metrics[0]
validateTestInfluxMetric(t, metric)
}
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestRunBase64(t *testing.T) {
sub.messages <- msg

acc.Wait(1)
require.Equal(t, acc.NFields(), 1)
require.Equal(t, 1, acc.NFields())
metric := acc.Metrics[0]
validateTestInfluxMetric(t, metric)
}
Expand Down Expand Up @@ -151,7 +151,7 @@ func TestRunGzipDecode(t *testing.T) {
}
sub.messages <- msg
acc.Wait(1)
require.Equal(t, acc.NFields(), 1)
require.Equal(t, 1, acc.NFields())
metric := acc.Metrics[0]
validateTestInfluxMetric(t, metric)
}
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestRunInvalidMessages(t *testing.T) {
// Make sure we acknowledged message so we don't receive it again.
testTracker.WaitForAck(1)

require.Equal(t, acc.NFields(), 0)
require.Equal(t, 0, acc.NFields())
}

func TestRunOverlongMessages(t *testing.T) {
Expand Down Expand Up @@ -249,7 +249,7 @@ func TestRunOverlongMessages(t *testing.T) {
// Make sure we acknowledged message so we don't receive it again.
testTracker.WaitForAck(1)

require.Equal(t, acc.NFields(), 0)
require.Equal(t, 0, acc.NFields())
}

func TestRunErrorInSubscriber(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions plugins/inputs/exec/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestExec(t *testing.T) {
var acc testutil.Accumulator
err := acc.GatherError(e.Gather)
require.NoError(t, err)
require.Equal(t, acc.NFields(), 8, "non-numeric measurements should be ignored")
require.Equal(t, 8, acc.NFields(), "non-numeric measurements should be ignored")

fields := map[string]interface{}{
"num_processes": float64(82),
Expand All @@ -125,7 +125,7 @@ func TestExecMalformed(t *testing.T) {

var acc testutil.Accumulator
require.Error(t, acc.GatherError(e.Gather))
require.Equal(t, acc.NFields(), 0, "No new points should have been added")
require.Equal(t, 0, acc.NFields(), "No new points should have been added")
}

func TestCommandError(t *testing.T) {
Expand All @@ -140,7 +140,7 @@ func TestCommandError(t *testing.T) {

var acc testutil.Accumulator
require.Error(t, acc.GatherError(e.Gather))
require.Equal(t, acc.NFields(), 0, "No new points should have been added")
require.Equal(t, 0, acc.NFields(), "No new points should have been added")
}

func TestExecCommandWithGlob(t *testing.T) {
Expand Down
Loading

0 comments on commit f4fd7ce

Please sign in to comment.