Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-1.14] Fix flaky dns test #6936

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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