From c5fd5a45b55b31c30fc5e2fda64ccaae09d12532 Mon Sep 17 00:00:00 2001 From: Gabriel Simmer Date: Wed, 24 Apr 2024 09:12:29 +0100 Subject: [PATCH] Tweak test expected values, share same ID for queries --- collector/collector.go | 5 ++--- collector/collector_test.go | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/collector/collector.go b/collector/collector.go index df91dce..4066a28 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -158,12 +158,11 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) { "auth.bind.", "servers.bind.", } - + id := dns.Id() for _, q := range questions { msg := &dns.Msg{ MsgHdr: dns.MsgHdr{ - Id: dns.Id(), - RecursionDesired: true, + Id: id, }, Question: []dns.Question{ question(q), diff --git a/collector/collector_test.go b/collector/collector_test.go index fb0fdd7..5882bb1 100644 --- a/collector/collector_test.go +++ b/collector/collector_test.go @@ -96,7 +96,7 @@ func TestDnsmasqExporter(t *testing.T) { want := map[string]string{ "dnsmasq_leases": "2", "dnsmasq_cachesize": "666", - "dnsmasq_hits": "1", + "dnsmasq_hits": "5", "dnsmasq_misses": "0", } for key, val := range want { @@ -111,7 +111,7 @@ func TestDnsmasqExporter(t *testing.T) { want := map[string]string{ "dnsmasq_leases": "2", "dnsmasq_cachesize": "666", - "dnsmasq_hits": "2", + "dnsmasq_hits": "12", "dnsmasq_misses": "0", } for key, val := range want { @@ -133,7 +133,7 @@ func TestDnsmasqExporter(t *testing.T) { want := map[string]string{ "dnsmasq_leases": "2", "dnsmasq_cachesize": "666", - "dnsmasq_hits": "3", + "dnsmasq_hits": "19", "dnsmasq_misses": "1", } for key, val := range want { @@ -159,7 +159,7 @@ func TestDnsmasqExporter(t *testing.T) { want := map[string]string{ "dnsmasq_leases": "2", "dnsmasq_cachesize": "666", - "dnsmasq_hits": "5", + "dnsmasq_hits": "33", "dnsmasq_misses": "1", "dnsmasq_lease_expiry{client_id=\"00:00:00:00:00:00\",computer_name=\"host-1\",ip_addr=\"10.10.10.10\",mac_addr=\"00:00:00:00:00:00\"}": "1.625595932e+09", "dnsmasq_lease_expiry{client_id=\"00:00:00:00:00:01\",computer_name=\"host-2\",ip_addr=\"10.10.10.11\",mac_addr=\"00:00:00:00:00:01\"}": "0", @@ -178,7 +178,7 @@ func TestDnsmasqExporter(t *testing.T) { want := map[string]string{ "dnsmasq_leases": "0", "dnsmasq_cachesize": "666", - "dnsmasq_hits": "6", + "dnsmasq_hits": "40", "dnsmasq_misses": "1", } for key, val := range want {