Skip to content

Commit

Permalink
Ignore DNSErrors caused by context cancelation in tests (#3228)
Browse files Browse the repository at this point in the history
  • Loading branch information
michel-laterman authored Jan 18, 2024
1 parent 5020fcb commit fbcce43
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/pkg/server/fleet_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"errors"
"fmt"
"io"
"net"
"net/http"
"net/http/httptest"
"path"
Expand Down Expand Up @@ -87,6 +88,17 @@ func (s *tserver) waitExit() error {
if errors.Is(err, context.Canceled) {
return nil
}

// FIXME: Below is a work around to net.DNSError not supporting the `Unwrap` method.
// It is so we can ignore errors caused by context cancelation.
// It can be removed when DNSError.Unwrap is added to the stdlib.
var dnsErr *net.DNSError
if errors.As(err, &dnsErr) {
if strings.Contains(dnsErr.Err, "operation was canceled") {
return nil
}
}

return err
}

Expand Down

0 comments on commit fbcce43

Please sign in to comment.