From 9243daeb0eb2f1e163bb32d37d3e038cab0ba723 Mon Sep 17 00:00:00 2001
From: Pierre Souchay
Date: Tue, 17 Apr 2018 10:36:12 +0200
Subject: [PATCH] Run new test in parallel
---
agent/dns_test.go | 45 ++++++++++++++++++++++++---------------------
1 file changed, 24 insertions(+), 21 deletions(-)
diff --git a/agent/dns_test.go b/agent/dns_test.go
index a428e153d9..1dec5100d7 100644
--- a/agent/dns_test.go
+++ b/agent/dns_test.go
@@ -2984,6 +2984,7 @@ func TestDNS_ServiceLookup_Randomize(t *testing.T) {
}
func TestBinarySearch(t *testing.T) {
+ t.Parallel()
msgSrc := new(dns.Msg)
msgSrc.Compress = true
msgSrc.SetQuestion("redis.service.consul.", dns.TypeSRV)
@@ -2994,27 +2995,29 @@ func TestBinarySearch(t *testing.T) {
msgSrc.Extra = append(msgSrc.Extra, &dns.CNAME{Hdr: dns.RR_Header{Name: target, Class: 1, Rrtype: dns.TypeCNAME, Ttl: 0x3c}, Target: fmt.Sprintf("fx.168.%d.%d.", i/256, i%256)})
}
for idx, maxSize := range []int{12, 256, 512, 8192, 65535} {
- msg := new(dns.Msg)
- msgSrc.Compress = true
- msgSrc.SetQuestion("redis.service.consul.", dns.TypeSRV)
- msg.Answer = msgSrc.Answer
- msg.Extra = msgSrc.Extra
- index := make(map[string]dns.RR, len(msg.Extra))
- indexRRs(msg.Extra, index)
- blen := dnsBinaryTruncate(msg, maxSize, index, true)
- msg.Answer = msg.Answer[:blen]
- syncExtra(index, msg)
- predicted := msg.Len()
- buf, err := msg.Pack()
- if err != nil {
- t.Error(err)
- }
- if predicted < len(buf) {
- t.Fatalf("Bug in DNS library: %d != %d", predicted, len(buf))
- }
- if len(buf) > maxSize || (idx != 0 && len(buf) < 16) || (maxSize == 65535 && blen != 50) {
- t.Fatalf("bad[%d]: %d > %d", idx, len(buf), maxSize)
- }
+ t.Run(fmt.Sprintf("binarySearch %d", maxSize), func(t *testing.T) {
+ msg := new(dns.Msg)
+ msgSrc.Compress = true
+ msgSrc.SetQuestion("redis.service.consul.", dns.TypeSRV)
+ msg.Answer = msgSrc.Answer
+ msg.Extra = msgSrc.Extra
+ index := make(map[string]dns.RR, len(msg.Extra))
+ indexRRs(msg.Extra, index)
+ blen := dnsBinaryTruncate(msg, maxSize, index, true)
+ msg.Answer = msg.Answer[:blen]
+ syncExtra(index, msg)
+ predicted := msg.Len()
+ buf, err := msg.Pack()
+ if err != nil {
+ t.Error(err)
+ }
+ if predicted < len(buf) {
+ t.Fatalf("Bug in DNS library: %d != %d", predicted, len(buf))
+ }
+ if len(buf) > maxSize || (idx != 0 && len(buf) < 16) || (maxSize == 65535 && blen != 50) {
+ t.Fatalf("bad[%d]: %d > %d", idx, len(buf), maxSize)
+ }
+ })
}
}