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

Switch *testing.T uses to equivalent interface + structured logging #935

Merged
merged 1 commit into from
Dec 13, 2019

Conversation

coryrc
Copy link
Contributor

@coryrc coryrc commented Dec 10, 2019

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.

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.
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 10, 2019
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Dec 10, 2019
@coryrc
Copy link
Contributor Author

coryrc commented Dec 10, 2019

/cc @yanweiguo
I'm not sure if the pkg tests are properly testing metricstest; should I be doing another test too?

@coryrc
Copy link
Contributor Author

coryrc commented Dec 10, 2019

@yanweiguo
I ran knative/serving units tests (go test -v -race ./...) with this branch [0]. They passed.
... which, I suppose, doesn't really help validate the change much.

[0] Gopkg.toml change:

 [[override]]
   name = "knative.dev/pkg"
-  branch = "release-0.11"
+  branch = "testingTcompat"
+  source = "github.com/coryrc/pkg"

@coryrc
Copy link
Contributor Author

coryrc commented Dec 10, 2019

/assign @chaodaiG
/assign @yanweiguo
/assign @mattmoor

@chaodaiG
Copy link
Contributor

@yanweiguo
I ran knative/serving units tests (go test -v -race ./...) with this branch [0]. They passed.
... which, I suppose, doesn't really help validate the change much.

[0] Gopkg.toml change:

 [[override]]
   name = "knative.dev/pkg"
-  branch = "release-0.11"
+  branch = "testingTcompat"
+  source = "github.com/coryrc/pkg"

@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

@yanweiguo
Copy link
Contributor

/cc @yanweiguo
I'm not sure if the pkg tests are properly testing metricstest; should I be doing another test too?

@coryrc Functions in metricstest are used for unit tests in serving or eventing. @chaodaiG's suggestion should work.

@coryrc
Copy link
Contributor Author

coryrc commented Dec 10, 2019

I did as you asked; it passed. (link just above this)

@coryrc
Copy link
Contributor Author

coryrc commented Dec 10, 2019

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.

@yanweiguo
Copy link
Contributor

/lgtm
/approve
for metrics dir change.

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 10, 2019
@adrcunha adrcunha requested review from mattmoor and removed request for adrcunha December 10, 2019 16:00
@chaodaiG
Copy link
Contributor

chaodaiG commented Dec 10, 2019

/approve
So that Cory is unblocked testing this feature out. @coryrc please loop me in when you are working on #907

@coryrc
Copy link
Contributor Author

coryrc commented Dec 13, 2019

/assign @vaikas

@vaikas
Copy link
Contributor

vaikas commented Dec 13, 2019

/lgtm
/approve

@knative-prow-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 13, 2019
@knative-prow-robot knative-prow-robot merged commit 9d8b936 into knative:master Dec 13, 2019
Copy link
Contributor

@vagababov vagababov left a 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

@knative-prow-robot
Copy link
Contributor

@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:

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

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.

@vagababov
Copy link
Contributor

For more context, I was writing metrics tests and I simply could not decipher what is wrong there at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test-and-release cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants