Tweak test expected values, share same ID for queries

This commit is contained in:
Gabriel Simmer 2024-04-24 09:12:29 +01:00
parent 9382391c30
commit c5fd5a45b5
Signed by: arch
SSH key fingerprint: SHA256:m3OEcdtrnBpMX+2BDGh/byv3hrCekCLzDYMdvGEKPPQ
2 changed files with 7 additions and 8 deletions

View file

@ -158,12 +158,11 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) {
"auth.bind.", "auth.bind.",
"servers.bind.", "servers.bind.",
} }
id := dns.Id()
for _, q := range questions { for _, q := range questions {
msg := &dns.Msg{ msg := &dns.Msg{
MsgHdr: dns.MsgHdr{ MsgHdr: dns.MsgHdr{
Id: dns.Id(), Id: id,
RecursionDesired: true,
}, },
Question: []dns.Question{ Question: []dns.Question{
question(q), question(q),

View file

@ -96,7 +96,7 @@ func TestDnsmasqExporter(t *testing.T) {
want := map[string]string{ want := map[string]string{
"dnsmasq_leases": "2", "dnsmasq_leases": "2",
"dnsmasq_cachesize": "666", "dnsmasq_cachesize": "666",
"dnsmasq_hits": "1", "dnsmasq_hits": "5",
"dnsmasq_misses": "0", "dnsmasq_misses": "0",
} }
for key, val := range want { for key, val := range want {
@ -111,7 +111,7 @@ func TestDnsmasqExporter(t *testing.T) {
want := map[string]string{ want := map[string]string{
"dnsmasq_leases": "2", "dnsmasq_leases": "2",
"dnsmasq_cachesize": "666", "dnsmasq_cachesize": "666",
"dnsmasq_hits": "2", "dnsmasq_hits": "12",
"dnsmasq_misses": "0", "dnsmasq_misses": "0",
} }
for key, val := range want { for key, val := range want {
@ -133,7 +133,7 @@ func TestDnsmasqExporter(t *testing.T) {
want := map[string]string{ want := map[string]string{
"dnsmasq_leases": "2", "dnsmasq_leases": "2",
"dnsmasq_cachesize": "666", "dnsmasq_cachesize": "666",
"dnsmasq_hits": "3", "dnsmasq_hits": "19",
"dnsmasq_misses": "1", "dnsmasq_misses": "1",
} }
for key, val := range want { for key, val := range want {
@ -159,7 +159,7 @@ func TestDnsmasqExporter(t *testing.T) {
want := map[string]string{ want := map[string]string{
"dnsmasq_leases": "2", "dnsmasq_leases": "2",
"dnsmasq_cachesize": "666", "dnsmasq_cachesize": "666",
"dnsmasq_hits": "5", "dnsmasq_hits": "33",
"dnsmasq_misses": "1", "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: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", "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{ want := map[string]string{
"dnsmasq_leases": "0", "dnsmasq_leases": "0",
"dnsmasq_cachesize": "666", "dnsmasq_cachesize": "666",
"dnsmasq_hits": "6", "dnsmasq_hits": "40",
"dnsmasq_misses": "1", "dnsmasq_misses": "1",
} }
for key, val := range want { for key, val := range want {