-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Shell executor logs through testing.T in upgrade tests #14495
Shell executor logs through testing.T in upgrade tests #14495
Conversation
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #14495 +/- ##
==========================================
- Coverage 86.09% 86.05% -0.05%
==========================================
Files 196 196
Lines 14887 14887
==========================================
- Hits 12817 12811 -6
- Misses 1759 1765 +6
Partials 311 311 ☔ View full report in Codecov by Sentry. |
test/upgrade/installation/shell.go
Outdated
loc, err := shell.NewProjectLocation("../../..") | ||
if err != nil { | ||
return err | ||
} | ||
exec := shell.NewExecutor(shell.ExecutorConfig{ | ||
ProjectLocation: loc, | ||
Streams: shell.TestingTStreams(t), |
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.
As I wrote in knative/pkg#2856 (comment), I think it's a bad idea to allow not to pass this custom streams. People may just replace deprecated package, and don't even know they should pass this.
How about the API look like:
exec := sheell.NewExecutor(t, loc, shell.ExecutorConfig{})
In Golang it's a good idea to default to an empty struct whenever it's possible.
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 ExecutorConfig
is a configuration object and I suppose it was created specifically to prevent passing too many arguments to NewExecutor
(which it does nicely).
As I answered in the other PR, the custom streams are really "custom" , the executor doesn't need to log into testing.T if the user wants normal stdout/stderr. So if we want to keep this shell executor generic like it was before we should not enforce logging to testing.T.
f4127a3
to
9f4d95a
Compare
ee3ebd5
to
f9b9908
Compare
// Strip trailing newline because t.Log always adds one. | ||
p = bytes.TrimRight(p, "\n") | ||
|
||
w.t.Logf("%s", p) |
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.
It would be a good idea to Log every line of the output. Just for ascetic reasons. Now some lines are skewed in the output:
executor.go:207: Oct 12 07:08:25.738 install_head_reuse_ingress [OUT] ***************************************
Oct 12 07:08:25.738 install_head_reuse_ingress [OUT] *** E2E TEST FAILED ***
Oct 12 07:08:25.738 install_head_reuse_ingress [OUT] *** Start of information dump ***
Oct 12 07:08:25.738 install_head_reuse_ingress [OUT] ***************************************
executor.go:207: Oct 12 07:08:25.739 install_head_reuse_ingress [OUT] >>> The dump is located at /logs/artifacts/k8s.dump-.txt
executor.go:207: Oct 12 07:08:26.048 install_head_reuse_ingress [OUT] >>> allowlistedv2workloads.auto.gke.io (0 objects)
Something like:
w.t.Logf("%s", p) | |
for line := range strings.Split(p, "\n") { | |
w.t.Log(line) | |
} |
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.
It's a cosmetic change but why not. I've tested this in https://prow.knative.dev/view/gs/knative-prow/pr-logs/pull/knative_serving/14495/upgrade-tests_serving_main/1713811249294217216.
Anyway, this change would be in knative.dev/pkg so I can do it later. It doesn't affect this PR.
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 updated this PR and it's ready for review/merging.
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.
Done in knative/pkg#2867
This reverts commit f5a5b50.
87d1a47
to
5722efc
Compare
/lgtm thanks everyone - great improvement |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dprotaso, mgencur 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 |
Fixes #14461
Depends on knative/pkg#2856
Temporarily depends on mgencur's fork of knative.dev/pkg. I will fix it once knative/pkg#2856 is merged.
Proposed Changes
shell.TestingTStreams(t)
to define StdOut and StdErr for shell executor.Release Note