From cd756b366767f0af66f7d17b0a4256eae1929871 Mon Sep 17 00:00:00 2001 From: Kai Zong Khor <119512420+kkhor-datadog@users.noreply.github.com> Date: Fri, 24 Jan 2025 14:24:16 -0500 Subject: [PATCH] [CTK-4731] Add logging for flaking API server test (#33365) --- comp/process/apiserver/apiserver_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/comp/process/apiserver/apiserver_test.go b/comp/process/apiserver/apiserver_test.go index 4f8b7f2cca342..c57a236e84897 100644 --- a/comp/process/apiserver/apiserver_test.go +++ b/comp/process/apiserver/apiserver_test.go @@ -28,6 +28,7 @@ import ( workloadmetafx "github.com/DataDog/datadog-agent/comp/core/workloadmeta/fx" "github.com/DataDog/datadog-agent/pkg/api/util" "github.com/DataDog/datadog-agent/pkg/util/fxutil" + "github.com/DataDog/datadog-agent/pkg/util/log" ) func TestLifecycle(t *testing.T) { @@ -97,16 +98,20 @@ func TestPostAuthentication(t *testing.T) { url := fmt.Sprintf("https://localhost:%d/config/log_level?value=debug", port) req, err := http.NewRequest("POST", url, nil) require.NoError(c, err) + log.Infof("Issuing unauthenticated test request to url: %s", url) res, err := util.GetClient(false).Do(req) require.NoError(c, err) defer res.Body.Close() + log.Info("Received unauthenticated test response") assert.Equal(c, http.StatusUnauthorized, res.StatusCode) // With authentication req.Header.Set("Authorization", "Bearer "+util.GetAuthToken()) + log.Infof("Issuing authenticated test request to url: %s", url) res, err = util.GetClient(false).Do(req) require.NoError(c, err) defer res.Body.Close() + log.Info("Received authenticated test response") assert.Equal(c, http.StatusOK, res.StatusCode) }, 5*time.Second, time.Second) }