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

Shell executor logs through testing.T in upgrade tests #14495

Merged
merged 13 commits into from
Oct 16, 2023

Conversation

mgencur
Copy link
Contributor

@mgencur mgencur commented Oct 10, 2023

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

  • Use the new shell.TestingTStreams(t) to define StdOut and StdErr for shell executor.
  • Pull dependencies from knative.dev/pkg

Release Note


@knative-prow knative-prow bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 10, 2023
@knative-prow knative-prow bot added area/networking area/test-and-release It flags unit/e2e/conformance/perf test issues for product features labels Oct 10, 2023
@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (eac93b0) 86.09% compared to head (5722efc) 86.05%.

❗ Current head 5722efc differs from pull request most recent head c12de81. Consider uploading reports for the commit c12de81 to get more accurate results

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              

see 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mgencur
Copy link
Contributor Author

mgencur commented Oct 10, 2023

This run has induced a failure in ServingHead script. The logs are printed within the test scope.

This run is successful without any failures. The logs are hidden as expected.

loc, err := shell.NewProjectLocation("../../..")
if err != nil {
return err
}
exec := shell.NewExecutor(shell.ExecutorConfig{
ProjectLocation: loc,
Streams: shell.TestingTStreams(t),
Copy link

@cardil cardil Oct 10, 2023

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.

Copy link
Contributor Author

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.

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 10, 2023
@knative-prow-robot knative-prow-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 11, 2023
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 11, 2023
// Strip trailing newline because t.Log always adds one.
p = bytes.TrimRight(p, "\n")

w.t.Logf("%s", p)
Copy link

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)

See: https://prow.knative.dev/view/gs/knative-prow/pr-logs/pull/knative_serving/14495/upgrade-tests_serving_main/1712360626715627520

Something like:

Suggested change
w.t.Logf("%s", p)
for line := range strings.Split(p, "\n") {
w.t.Log(line)
}

Copy link
Contributor Author

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.

Copy link
Contributor Author

@mgencur mgencur Oct 16, 2023

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 14, 2023
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 16, 2023
@mgencur mgencur changed the title [WIP] Shell executor logs through testing.T in upgrade tests Shell executor logs through testing.T in upgrade tests Oct 16, 2023
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 16, 2023
@dprotaso
Copy link
Member

/lgtm
/approve

thanks everyone - great improvement

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Oct 16, 2023
@knative-prow
Copy link

knative-prow bot commented Oct 16, 2023

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

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 16, 2023
@knative-prow knative-prow bot merged commit 71085f8 into knative:main Oct 16, 2023
69 checks passed
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/networking area/test-and-release It flags unit/e2e/conformance/perf test issues for product features 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.

upgrade test shell invoker logs isn't showing up in a subtest log output
4 participants