-
Notifications
You must be signed in to change notification settings - Fork 24
[VC-43793] Add debug roundtripper to discovery and identity clients for easier debugging #683
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ import ( | |
| "github.com/jetstack/preflight/pkg/internal/cyberark/dataupload" | ||
| "github.com/jetstack/preflight/pkg/internal/cyberark/identity" | ||
| "github.com/jetstack/preflight/pkg/internal/cyberark/servicediscovery" | ||
|
|
||
| _ "k8s.io/klog/v2/ktesting/init" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sets up the |
||
| ) | ||
|
|
||
| func TestCyberArkClient_PostDataReadingsWithOptions(t *testing.T) { | ||
|
|
@@ -126,6 +128,11 @@ func TestCyberArkClient_PostDataReadingsWithOptions(t *testing.T) { | |
| // An API token is obtained by authenticating with the ARK_USERNAME and ARK_SECRET from the environment. | ||
| // ARK_SUBDOMAIN should be your tenant subdomain. | ||
| // ARK_PLATFORM_DOMAIN should be either integration-cyberark.cloud or cyberark.cloud | ||
| // | ||
| // To enable verbose request logging: | ||
| // | ||
| // go test ./pkg/internal/cyberark/dataupload/... \ | ||
| // -v -count 1 -run TestPostDataReadingsWithOptionsWithRealAPI -args -testing.v 6 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I pasted some examples in the PR description. |
||
| func TestPostDataReadingsWithOptionsWithRealAPI(t *testing.T) { | ||
| platformDomain := os.Getenv("ARK_PLATFORM_DOMAIN") | ||
| subdomain := os.Getenv("ARK_SUBDOMAIN") | ||
|
|
@@ -137,7 +144,7 @@ func TestPostDataReadingsWithOptionsWithRealAPI(t *testing.T) { | |
| return | ||
| } | ||
|
|
||
| logger := ktesting.NewLogger(t, ktesting.NewConfig()) | ||
| logger := ktesting.NewLogger(t, ktesting.DefaultConfig) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DefaultConfig has the flag names which are registered by importing the init package (above) |
||
| ctx := klog.NewContext(t.Context(), logger) | ||
|
|
||
| const ( | ||
|
|
@@ -165,7 +172,7 @@ func TestPostDataReadingsWithOptionsWithRealAPI(t *testing.T) { | |
| cyberArkClient, err := dataupload.NewCyberArkClient(nil, serviceURL, identityClient.AuthenticateRequest) | ||
| require.NoError(t, err) | ||
|
|
||
| err = cyberArkClient.PostDataReadingsWithOptions(t.Context(), api.DataReadingsPost{}, dataupload.Options{ | ||
| err = cyberArkClient.PostDataReadingsWithOptions(ctx, api.DataReadingsPost{}, dataupload.Options{ | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a mistake I made in #681 |
||
| ClusterName: "bb068932-c80d-460d-88df-34bc7f3f3297", | ||
| }) | ||
| require.NoError(t, err) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
DebugWrappersfunction is better in a way because it only wraps the transport if the global logger has been configured at level >=6....which avoids the inefficiency of looking up the log level for each request if the log level is at its default level.But it makes it harder to control the logging verbosity from tests because the wrapper doesn't know about the verbosity setting on the
ktestinglogger.I might revert back to
DebugWrapperin future, but for now this makes it easier for me to see what's going on in the test logs.