From d521f0a292f1d96011203273a5bc34934b49bc21 Mon Sep 17 00:00:00 2001 From: michel-laterman Date: Thu, 18 Jan 2024 10:03:13 -0600 Subject: [PATCH] Ignore DNSErrors caused by context cancelation in tests --- internal/pkg/server/fleet_integration_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/pkg/server/fleet_integration_test.go b/internal/pkg/server/fleet_integration_test.go index de14688d2..65ee08ce1 100644 --- a/internal/pkg/server/fleet_integration_test.go +++ b/internal/pkg/server/fleet_integration_test.go @@ -14,6 +14,7 @@ import ( "errors" "fmt" "io" + "net" "net/http" "net/http/httptest" "path" @@ -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 }