-
Notifications
You must be signed in to change notification settings - Fork 331
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
Switch *testing.T uses to equivalent interface + structured logging #935
Conversation
Working to introduce structured logging to our tests. See knative#907 This work allows these test functions to be called by objects other than *testing.T. The t.Error() calls are made compatible with structured logging (wrapping Zap sugared logger calls) or code using testing.T.
/cc @yanweiguo |
@yanweiguo [0] Gopkg.toml change:
|
/assign @chaodaiG |
@coryrc , can you create a PR in serving with the same Gopkg.toml change as above, would like to see how it works in serving in action |
@coryrc Functions in metricstest are used for unit tests in serving or eventing. @chaodaiG's suggestion should work. |
I did as you asked; it passed. (link just above this) |
It doesn't actually exercise any of the calls I made (because I only changed how it prints errors & the tests all pass), but given it's a statically-typed language, I wouldn't expect it to break. |
/lgtm |
/assign @vaikas |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chaodaiG, coryrc, vaikas, yanweiguo The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
I've just experienced this and I am ready to say that this is horrendously bad UX.
L: TestMetricsReported (0.00s)
concurrency_reporter_test.go:303: Reporter got wrong number of tags metric request_concurrency got 6 want 5
concurrency_reporter_test.go:303: Reporter expected a different tag value for key metric request_concurrency key configuration_name got config-real-name want config-rev1
concurrency_reporter_test.go:303: Reporter got an extra tag metric request_concurrency gotName container_name gotValue activator
concurrency_reporter_test.go:303: Reporter expected a different tag value for key metric request_concurrency key service_name got service-real-name want service-rev1
is not a useful error reporting.
I never really understood the whole testing.T
to test.T
refactoring, but now experiencing it firsthand, I think it is an extremely bad way.
We should stop doing this. Formatters exist for a reason
/cc @mattmoor @coryrc @evankanderson
@vagababov: GitHub didn't allow me to request PR reviews from the following users: coryrc. Note that only knative members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
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. |
For more context, I was writing metrics tests and I simply could not decipher what is wrong there at all. |
Working to introduce structured logging to our tests. See #907
This work allows these test functions to be called by objects other
than *testing.T. The t.Error() calls are made compatible with
structured logging (wrapping Zap sugared logger calls) or code using
testing.T.