Skip to content

Commit

Permalink
dnsforward: imp test more
Browse files Browse the repository at this point in the history
  • Loading branch information
ainar-g committed Oct 3, 2024
1 parent ce743a3 commit 006391c
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions internal/dnsforward/dnsforward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,19 +583,15 @@ func TestSafeSearch(t *testing.T) {
t.Run(tc.host, func(t *testing.T) {
req := createTestMessage(tc.host)

// TODO(a.garipov): Create our own helper for this.
var reply *dns.Msg

// Use a mutex, since require.Eventually uses goroutines.
mu := &sync.Mutex{}
require.Eventually(t, func() (ok bool) {
mu.Lock()
defer mu.Unlock()

reply, _, err = client.Exchange(req, addr)

return err == nil
once := &sync.Once{}
require.EventuallyWithT(t, func(c *assert.CollectT) {
r, _, errExch := client.Exchange(req, addr)
if assert.NoError(c, errExch) {
once.Do(func() { reply = r })
}
}, testTimeout*10, testTimeout)
require.NoErrorf(t, err, "couldn't talk to server %s: %s", addr, err)

if tc.wantCNAME != "" {
require.Len(t, reply.Answer, 2)
Expand Down

0 comments on commit 006391c

Please sign in to comment.