Skip to content

Commit

Permalink
avoid using dns cache in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
boratanrikulu committed Jul 27, 2024
1 parent 14abf09 commit c0f59f1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/ebpf/testing.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ebpf

import (
"context"
"net"
"testing"
"time"
Expand Down Expand Up @@ -104,9 +105,16 @@ func TTCPWrite(c *qt.C, address string, ok bool) {
c.Assert(err, qt.IsNil)
}

// TDNSLookup tests if the DNS lookup works well.
// TDNSLookup tests if the DNS lookup works well without using DNS cache.
func TDNSLookup(c *qt.C, dns string, ok bool) {
_, err := net.LookupIP(dns)
r := &net.Resolver{
PreferGo: true,
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
return net.Dial(network, "8.8.8.8:53")
},
}

_, err := r.LookupIP(context.Background(), "ip", dns)
if !ok {
c.Assert(err, qt.IsNotNil)
return
Expand Down

0 comments on commit c0f59f1

Please sign in to comment.