-
Notifications
You must be signed in to change notification settings - Fork 39.9k
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
filter go test
output live with gotestsum
#125534
Conversation
go test
output live with gotestsumgo test
output live with gotestsum
@dims: I removed the dependency on an unreleased gotestsum feature, so we could merge it now. But see #125534 (comment)... A test run looks good: https://prow.k8s.io/log?container=test&id=1818617277273083904&job=pull-kubernetes-unit Same number of tests as in other runs (1099). What stands out more now is the amount of logging that still goes to stderr. Contextual logging with per-test logging would get rid of all that. /hold Before we merge I should break one unit test temporarily to ensure that this gets recorded properly. |
/assign @BenTheElder |
/test pull-kubernetes-unit After breaking staging/src/k8s.io/dynamic-resource-allocation/cel/compile_test.go |
5cafa74
to
f33eab4
Compare
@aojea, @BenTheElder: I rebased. Okay to merge now? |
the job failure seems related
|
Filtering the output with grep leads to hard to read log output, e.g. from pull-kubernetes-unit: [0613 15:32:48] Running tests without code coverage and with -race {"Time":"2024-06-13T15:33:47.845457374Z","Action":"output","Package":"k8s.io/kubernetes/cluster/gce/cos","Test":"TestCreateMasterAuditPolicy","Output":" /tmp/configure-helper-test47992121/kube-env: line 1: `}'\n"} {"Time":"2024-06-13T15:33:49.053732803Z","Action":"output","Package":"k8s.io/kubernetes/cluster/gce/cos","Output":"ok \tk8s.io/kubernetes/cluster/gce/cos\t2.906s\n"} We can do better than that. When feeding the output of the "go test" command(s) into gotestsum *while it runs*, we can use --format=standard-quiet (= normal go test output) or --format=standard-verbose (= `go test -v`) when FULL_LOG is requested to get nicer output. This works when testing everything at once. This was said to be not possible when doing coverage profiling. But recent Go no longer has that limitation, so the xargs trick gets removed. All that we need to do for coverage profiling is to add some additional parameters and the conversion to HTML.
Indeed. I need to initialize the variable when not entering the |
Tests are passing now. |
LGTM for final approval |
thanks @aojea /approve |
LGTM label has been added. Git tree hash: 3d061c7366ab57206c943cee332a0da3bef046cc
|
/hold cancel I think this had enough reviews. Let's merge it. |
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.
/lgtm
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: BenTheElder, dims, pohly 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 |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Running
go test -json
in pull-kubernetes-unit and grepping the output does not work well and against the intent of the grep includes log output:kubernetes/hack/make-rules/test.sh
Lines 148 to 149 in 9de747c
->
A better approach is to let
gotestsum
process filter thego test
output while it is produced. Then we can control via-format
whatgotestsum
prints to the console. The default is a short summary. With--format=standard-verbose
(enabled byFULL_LOG
) we get the normalgo test -v
output.Special notes for your reviewer:
Our bash code for running
go test
is fairly complex, in particular when using coverage and invoking each test by itself. I briefly tried generating a bash script which then can be given togotestsum --raw-command <script>
, but getting the quoting right is tricky. The current solution is to not use a pipe and let xargs read from a temporary file instead.Does this PR introduce a user-facing change?