-
Notifications
You must be signed in to change notification settings - Fork 70
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
Testing: improve Windows test logs #499
Open
martijnvans
wants to merge
12
commits into
master
Choose a base branch
from
martijnvans-windows-stderr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
martijnvans
commented
Mar 29, 2022
[]string{winRM(), | ||
"--host=" + vm.IPAddress, | ||
"--username=" + vm.WindowsCredentials.Username, | ||
"--password=" + vm.WindowsCredentials.Password, | ||
fmt.Sprintf("--command=powershell -NonInteractive -encodedcommand %q", base64.StdEncoding.EncodeToString([]byte(encoded))), | ||
fmt.Sprintf("--command=powershell -NonInteractive -OutputFormat Text -EncodedCommand %q", base64.StdEncoding.EncodeToString([]byte(encoded))), |
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.
adding -OutputFormat Text does nothing, but I included it here because:
- it's always bothered me how this seemingly-useful option is not called out in our code anywhere
- if microsoft ever fixes powershell's behavior, we'll start using the fix automatically.
martijnvans
changed the title
Testing: parse XML returned by powershell over stderr
Testing: improve Windows test logs
Mar 30, 2022
martijnvans
requested review from
a team and
igorpeshansky
and removed request for
a team
April 27, 2022 15:26
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The idea is to parse the XML returned by powershell over stderr, and extract the human readable part and print that.
To do this, I had to separate out the part of runCommand() that logs the command and the raw stdout/stderr into a function runAndLog(), and for runRemotelyWindows(), get it to call runCommand() directly, skipping runAndLog() in order to do its own logging.
This whole thing is just a workaround for the fact that powershell ignores -OutputFormat Text when run noninteractively.
Before: https://storage.cloud.google.com/ops-agents-public-buckets-test-logs/prod/stackdriver_agents/testing/consumer/ops_agent/presubmit_github/windows/449/20220322-104940/logs/TestLoggingAgentCrashRestart_windows-2019/main_log.txt
After: https://storage.googleapis.com/ops-agents-public-buckets-test-logs/prod/stackdriver_agents/testing/consumer/ops_agent/test/windows/1043/20220808-084805/logs/TestLoggingAgentCrashRestart_windows-2019/main_log.txt
I also checked that when there is something useful on stderr, like a "missing cmdlet" error, it does show up right, and I checked that if the XML fails to parse, that the raw XML is dumped to the log, as desired.