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

[CTK-4731] Add logging for flaking API server test #33365

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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