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

Set user-agent per test in e2e framework #64790

Closed
hh opened this issue Jun 5, 2018 · 10 comments
Closed

Set user-agent per test in e2e framework #64790

hh opened this issue Jun 5, 2018 · 10 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. sig/testing Categorizes an issue or PR as relevant to SIG Testing.

Comments

@hh
Copy link
Member

hh commented Jun 5, 2018

In order to identify which e2e test is hitting a specific API endpoint

Given an e2e test using e2e/framework/utils
When the user agent is set via client-go config
Then we will be able to log which e2e test called a specific API

Prior discussion: https://groups.google.com/d/msg/kubernetes-sig-api-machinery/R-z_NjiLzmg/q1kWg9jSAQAJ

/kind feature
/cc @kubernetes/api-reviewers @kubernetes/sig-testing-feature-requests @liggitt @lavalamp @bgrant0607

@k8s-ci-robot k8s-ci-robot added sig/testing Categorizes an issue or PR as relevant to SIG Testing. kind/feature Categorizes issue or PR as related to a new feature. labels Jun 5, 2018
@hzxuzhonghu
Copy link
Member

If we want to only set User-Agent in a common place,  I think add config.UserAgent = f.BaseName here can work well.

config, err := LoadConfig()
Expect(err).NotTo(HaveOccurred())
config.QPS = f.Options.ClientQPS
config.Burst = f.Options.ClientBurst

@hzxuzhonghu
Copy link
Member

cc @sttts @tallclair @CaoShuFeng

@sttts
Copy link
Contributor

sttts commented Jun 6, 2018

@hzxuzhonghu had the same thought.

@rohfle
Copy link

rohfle commented Jun 7, 2018

Since User-Agent is a HTTP header itself, would it be better to create descriptive headers specifically and then log all headers in audit logs?

Something like:

GET / HTTP/1.1
Host: kubernetes.master
User-Agent: curl/7.58.0
Accept: */*
Kubetest-Name: "[storage] storage related tests"
Kubetest-Description: "should do the thing"
Kubetest-File: "path/to/test.go:43"
...
HTTP/1.1 200 OK

@tallclair
Copy link
Member

For the sake of argument, alternative approaches that wouldn't require changes to auditing:

  • Append a custom query string, which would generally be ignored but show up in the audit log URL field
  • Act as a per-test service account. Requires creating the account & RBAC bindings.

However, since we want to add user-agent to the audit logs anyway, I agree that's the preferred approach.

@hh
Copy link
Member Author

hh commented Jun 13, 2018

What about generically add support in kubernetes/client-go to set user-agent to the calling src code file and line using runtime.Caller.

An off-by-default option, having this level of insight for any k8s application seems like an easy win. Generating an index of test data that includes links to github for all calling/called functions.

I'm exploring this idea a bit further: https://github.com/cncf/apisnoop/issues/23

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 11, 2018
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Oct 11, 2018
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. sig/testing Categorizes an issue or PR as relevant to SIG Testing.
Projects
None yet
Development

No branches or pull requests

7 participants