Skip to content

Commit

Permalink
Merge pull request #6936 from cert-manager-bot/cherry-pick-6923-to-re…
Browse files Browse the repository at this point in the history
…lease-1.14

[release-1.14] Fix flaky dns test
  • Loading branch information
cert-manager-prow[bot] committed Apr 22, 2024
2 parents 47b9f4a + c35059a commit ca8832b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pkg/issuer/acme/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,15 @@ func TestReachabilityCustomDnsServers(t *testing.T) {
t.Fatalf("Failed to resolve %s: %v", u.Host, err)
}

dnsServerStarted := make(chan struct{})
dnsServerCalled := int32(0)

server := &dns.Server{Addr: "127.0.0.1:15353", Net: "udp"}
server := &dns.Server{Addr: "127.0.0.1:15353", Net: "udp", NotifyStartedFunc: func() { close(dnsServerStarted) }}
defer server.Shutdown()

dns.HandleFunc(".", func(w dns.ResponseWriter, r *dns.Msg) {
mux := &dns.ServeMux{}
server.Handler = mux
mux.HandleFunc(".", func(w dns.ResponseWriter, r *dns.Msg) {
m := new(dns.Msg)
m.SetReply(r)

Expand Down Expand Up @@ -154,7 +157,15 @@ func TestReachabilityCustomDnsServers(t *testing.T) {
t.Errorf("failed to write DNS response: %v", err)
}
})
go server.ListenAndServe()

go func() {
if err := server.ListenAndServe(); err != nil {
t.Error(err)
}
}()

// Wait for server to have started
<-dnsServerStarted

key := "there is no key"

Expand Down

0 comments on commit ca8832b

Please sign in to comment.