Skip to content

Commit

Permalink
Fix TestGatheringTimeout test for dns_query plugin (influxdata#4842)
Browse files Browse the repository at this point in the history
  • Loading branch information
kostya-sh authored and otherpirate committed Mar 15, 2019
1 parent f3e60d4 commit f3ee796
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions plugins/inputs/dns_query/dns_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,17 @@ func TestGatheringTimeout(t *testing.T) {
var acc testutil.Accumulator
dnsConfig.Port = 60054
dnsConfig.Timeout = 1
var err error

channel := make(chan error, 1)
go func() {
channel <- acc.GatherError(dnsConfig.Gather)
}()
select {
case res := <-channel:
err = res
case err := <-channel:
assert.NoError(t, err)
case <-time.After(time.Second * 2):
err = nil
assert.Fail(t, "DNS query did not timeout")
}

assert.Error(t, err)
assert.Contains(t, err.Error(), "i/o timeout")
}

func TestSettingDefaultValues(t *testing.T) {
Expand Down

0 comments on commit f3ee796

Please sign in to comment.