Skip to content

Commit

Permalink
dns query: Don't use mjasion.pl for unit tests, check errs
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc committed Feb 23, 2016
1 parent 3e8f96a commit 83c27cc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Bugfixes
- [#701](https://github.com/influxdata/telegraf/pull/701): output write count shouldnt print in quiet mode.
- [#746](https://github.com/influxdata/telegraf/pull/746): httpjson plugin: Fix HTTP GET parameters.

## v0.10.3 [2016-02-18]

Expand Down
28 changes: 18 additions & 10 deletions plugins/inputs/dns_query/dns_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

var servers = []string{"8.8.8.8"}
var domains = []string{"mjasion.pl"}
var domains = []string{"google.com"}

func TestGathering(t *testing.T) {
var dnsConfig = DnsQuery{
Expand All @@ -18,8 +18,10 @@ func TestGathering(t *testing.T) {
}
var acc testutil.Accumulator

dnsConfig.Gather(&acc)
metric, _ := acc.Get("dns_query")
err := dnsConfig.Gather(&acc)
assert.NoError(t, err)
metric, ok := acc.Get("dns_query")
assert.True(t, ok)
queryTime, _ := metric.Fields["query_time_ms"].(float64)

assert.NotEqual(t, 0, queryTime)
Expand All @@ -33,8 +35,10 @@ func TestGatheringMxRecord(t *testing.T) {
var acc testutil.Accumulator
dnsConfig.RecordType = "MX"

dnsConfig.Gather(&acc)
metric, _ := acc.Get("dns_query")
err := dnsConfig.Gather(&acc)
assert.NoError(t, err)
metric, ok := acc.Get("dns_query")
assert.True(t, ok)
queryTime, _ := metric.Fields["query_time_ms"].(float64)

assert.NotEqual(t, 0, queryTime)
Expand All @@ -54,8 +58,10 @@ func TestGatheringRootDomain(t *testing.T) {
}
fields := map[string]interface{}{}

dnsConfig.Gather(&acc)
metric, _ := acc.Get("dns_query")
err := dnsConfig.Gather(&acc)
assert.NoError(t, err)
metric, ok := acc.Get("dns_query")
assert.True(t, ok)
queryTime, _ := metric.Fields["query_time_ms"].(float64)

fields["query_time_ms"] = queryTime
Expand All @@ -70,13 +76,15 @@ func TestMetricContainsServerAndDomainAndRecordTypeTags(t *testing.T) {
var acc testutil.Accumulator
tags := map[string]string{
"server": "8.8.8.8",
"domain": "mjasion.pl",
"domain": "google.com",
"record_type": "NS",
}
fields := map[string]interface{}{}

dnsConfig.Gather(&acc)
metric, _ := acc.Get("dns_query")
err := dnsConfig.Gather(&acc)
assert.NoError(t, err)
metric, ok := acc.Get("dns_query")
assert.True(t, ok)
queryTime, _ := metric.Fields["query_time_ms"].(float64)

fields["query_time_ms"] = queryTime
Expand Down

0 comments on commit 83c27cc

Please sign in to comment.