Skip to content

Commit

Permalink
fix x509 cert timeout issue (#8741)
Browse files Browse the repository at this point in the history
(cherry picked from commit eda1dbc)
  • Loading branch information
viperstars authored and ssoroka committed Jan 27, 2021
1 parent 03aafe0 commit 6428072
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/inputs/x509_cert/x509_cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (c *X509Cert) Gather(acc telegraf.Accumulator) error {
return nil
}

certs, err := c.getCert(u, c.Timeout.Duration*time.Second)
certs, err := c.getCert(u, c.Timeout.Duration)
if err != nil {
acc.AddError(fmt.Errorf("cannot get SSL cert '%s': %s", location, err.Error()))
}
Expand Down
18 changes: 18 additions & 0 deletions plugins/inputs/x509_cert/x509_cert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,24 @@ func TestGatherCert(t *testing.T) {
assert.True(t, acc.HasMeasurement("x509_cert"))
}

func TestGatherCertMustNotTimeout(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
duration := time.Duration(15) * time.Second
m := &X509Cert{
Sources: []string{"https://www.influxdata.com:443"},
Timeout: internal.Duration{Duration: duration},
}
m.Init()

var acc testutil.Accumulator
err := m.Gather(&acc)
require.NoError(t, err)
require.Empty(t, acc.Errors)
assert.True(t, acc.HasMeasurement("x509_cert"))
}

func TestServerName(t *testing.T) {
tests := []struct {
name string
Expand Down

0 comments on commit 6428072

Please sign in to comment.