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

test/integration: Capture component setup output #12069

Merged
merged 1 commit into from
Feb 4, 2023

Conversation

abhinav
Copy link
Contributor

@abhinav abhinav commented Feb 3, 2023

Issue #12050 would have been a lot easier to debug
if we had been capturing the output of the commands.

This changes runComponentSetup to execute bash with -x
so that every command in the shell script is logged before it's run.

This feeds that output into an io.Writer that logs to the testing.TB.
This way, if the test fails or times out,
we'll have a bunch of meaningful log output
associated with the tests that ran them.

Capturing the command output in a reliable way
required introduction of something slightly more complicated
than strings.Split(\n) because there's a good chance
that we'll have partial lines written to the writer.

The approach taken by the Writer here is:
it will log the input one line at a time usually,
but when it sees a partial line, it will buffer it in-memory
to be combined with the next write or flush.
Approach inspired by https://github.com/uber-go/zap/blob/v1.24.0/zapio/writer.go

Refs #12050

@abhinav abhinav added the impact/no-changelog-required This issue doesn't require a CHANGELOG update label Feb 3, 2023
Copy link
Contributor Author

abhinav commented Feb 3, 2023

@pulumi-bot
Copy link
Contributor

Changelog

[uncommitted] (2023-02-03)

//
// Use newTestLogWriter to ensure it is flushed
// of any input when the test finishes.
type testLogWriter struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can likely be re-used elsewhere.
I will defer moving this somewhere shared for when we need it.

tests/integration/integration_util_test.go Outdated Show resolved Hide resolved
Issue #12050 would have been a lot easier to debug
if we had been capturing the output of the commands.

This changes runComponentSetup to execute bash with `-x`
so that every command in the shell script is logged before it's run.

This feeds that output into an `io.Writer` that logs to the testing.TB.
This way, if the test fails or times out,
we'll have a bunch of meaningful log output
associated with the tests that ran them.

Capturing the command output in a reliable way
required introduction of something slightly more complicated
than `strings.Split(\n)` because there's a good chance
that we'll have partial lines written to the writer.

The approach taken by the Writer here is:
it will log the input one line at a time usually,
but when it sees a partial line, it will buffer it in-memory
to be combined with the next write or flush.
Approach inspired by https://github.com/uber-go/zap/blob/v1.24.0/zapio/writer.go

Refs #12050
@abhinav abhinav force-pushed the abhinav/verbose-component-setup branch from 67de6f9 to 4841686 Compare February 3, 2023 22:28
Base automatically changed from abhinav/integration-no-panic to master February 4, 2023 01:53
@abhinav
Copy link
Contributor Author

abhinav commented Feb 4, 2023

bors r+

@bors
Copy link
Contributor

bors bot commented Feb 4, 2023

Build succeeded:

@bors bors bot merged commit ad58313 into master Feb 4, 2023
@bors bors bot deleted the abhinav/verbose-component-setup branch February 4, 2023 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact/no-changelog-required This issue doesn't require a CHANGELOG update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants