Skip to content

Commit

Permalink
[CTK-4731] Add logging for flaking API server test (#33365)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkhor-datadog authored Jan 24, 2025
1 parent ef172eb commit cd756b3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions comp/process/apiserver/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}

0 comments on commit cd756b3

Please sign in to comment.