From db169fe59ac7cf95c2ad4ef76889b1ba0080bfef Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Tue, 23 Feb 2016 11:10:28 -0700 Subject: [PATCH] dns query: Don't use mjasion.pl for unit tests, check errs --- CHANGELOG.md | 1 + plugins/inputs/dns_query/dns_query_test.go | 28 ++++++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f5b72e28..05fc7b09d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] diff --git a/plugins/inputs/dns_query/dns_query_test.go b/plugins/inputs/dns_query/dns_query_test.go index ff923dae3..076db5fab 100644 --- a/plugins/inputs/dns_query/dns_query_test.go +++ b/plugins/inputs/dns_query/dns_query_test.go @@ -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{ @@ -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) @@ -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) @@ -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 @@ -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