dns query: Don't use mjasion.pl for unit tests, check errs
This commit is contained in:
parent
5a471d6568
commit
db169fe59a
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
- [#701](https://github.com/influxdata/telegraf/pull/701): output write count shouldnt print in quiet mode.
|
- [#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]
|
## v0.10.3 [2016-02-18]
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var servers = []string{"8.8.8.8"}
|
var servers = []string{"8.8.8.8"}
|
||||||
var domains = []string{"mjasion.pl"}
|
var domains = []string{"google.com"}
|
||||||
|
|
||||||
func TestGathering(t *testing.T) {
|
func TestGathering(t *testing.T) {
|
||||||
var dnsConfig = DnsQuery{
|
var dnsConfig = DnsQuery{
|
||||||
|
@ -18,8 +18,10 @@ func TestGathering(t *testing.T) {
|
||||||
}
|
}
|
||||||
var acc testutil.Accumulator
|
var acc testutil.Accumulator
|
||||||
|
|
||||||
dnsConfig.Gather(&acc)
|
err := dnsConfig.Gather(&acc)
|
||||||
metric, _ := acc.Get("dns_query")
|
assert.NoError(t, err)
|
||||||
|
metric, ok := acc.Get("dns_query")
|
||||||
|
assert.True(t, ok)
|
||||||
queryTime, _ := metric.Fields["query_time_ms"].(float64)
|
queryTime, _ := metric.Fields["query_time_ms"].(float64)
|
||||||
|
|
||||||
assert.NotEqual(t, 0, queryTime)
|
assert.NotEqual(t, 0, queryTime)
|
||||||
|
@ -33,8 +35,10 @@ func TestGatheringMxRecord(t *testing.T) {
|
||||||
var acc testutil.Accumulator
|
var acc testutil.Accumulator
|
||||||
dnsConfig.RecordType = "MX"
|
dnsConfig.RecordType = "MX"
|
||||||
|
|
||||||
dnsConfig.Gather(&acc)
|
err := dnsConfig.Gather(&acc)
|
||||||
metric, _ := acc.Get("dns_query")
|
assert.NoError(t, err)
|
||||||
|
metric, ok := acc.Get("dns_query")
|
||||||
|
assert.True(t, ok)
|
||||||
queryTime, _ := metric.Fields["query_time_ms"].(float64)
|
queryTime, _ := metric.Fields["query_time_ms"].(float64)
|
||||||
|
|
||||||
assert.NotEqual(t, 0, queryTime)
|
assert.NotEqual(t, 0, queryTime)
|
||||||
|
@ -54,8 +58,10 @@ func TestGatheringRootDomain(t *testing.T) {
|
||||||
}
|
}
|
||||||
fields := map[string]interface{}{}
|
fields := map[string]interface{}{}
|
||||||
|
|
||||||
dnsConfig.Gather(&acc)
|
err := dnsConfig.Gather(&acc)
|
||||||
metric, _ := acc.Get("dns_query")
|
assert.NoError(t, err)
|
||||||
|
metric, ok := acc.Get("dns_query")
|
||||||
|
assert.True(t, ok)
|
||||||
queryTime, _ := metric.Fields["query_time_ms"].(float64)
|
queryTime, _ := metric.Fields["query_time_ms"].(float64)
|
||||||
|
|
||||||
fields["query_time_ms"] = queryTime
|
fields["query_time_ms"] = queryTime
|
||||||
|
@ -70,13 +76,15 @@ func TestMetricContainsServerAndDomainAndRecordTypeTags(t *testing.T) {
|
||||||
var acc testutil.Accumulator
|
var acc testutil.Accumulator
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"server": "8.8.8.8",
|
"server": "8.8.8.8",
|
||||||
"domain": "mjasion.pl",
|
"domain": "google.com",
|
||||||
"record_type": "NS",
|
"record_type": "NS",
|
||||||
}
|
}
|
||||||
fields := map[string]interface{}{}
|
fields := map[string]interface{}{}
|
||||||
|
|
||||||
dnsConfig.Gather(&acc)
|
err := dnsConfig.Gather(&acc)
|
||||||
metric, _ := acc.Get("dns_query")
|
assert.NoError(t, err)
|
||||||
|
metric, ok := acc.Get("dns_query")
|
||||||
|
assert.True(t, ok)
|
||||||
queryTime, _ := metric.Fields["query_time_ms"].(float64)
|
queryTime, _ := metric.Fields["query_time_ms"].(float64)
|
||||||
|
|
||||||
fields["query_time_ms"] = queryTime
|
fields["query_time_ms"] = queryTime
|
||||||
|
|
Loading…
Reference in New Issue