GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Fix Enter-PSHostProcess tests flakiness by TylerLeonhardt · Pull Request #9007 · PowerShell/PowerShell Conversation
Member
PR SummaryThis PR totally refactors the fixes #8971 PR ContextThe biggest change was that rather then sharing an instance of PowerShell, the tests will each have their own instance of PowerShell to interact with. PR Checklist
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was an error while loading. Please reload this page.
|
I'd can restart but it is already failed :-( |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Jeez... OK... Ran this like 20 times in a container and couldn't repro the issue. Back to the drawing board... |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I can repro the same problem if I do this: > "Enter-PSHostProcess -Id 40328 -ErrorAction Stop `$pid Exit-PSHostProcess" > test.ps1 > ./test.ps1 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Looks tricky! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
The odd thing is... I added "Enter-PSHostProcess -Id $($pwsh.Id) -ErrorAction Stop `$pid Exit-PSHostProcess" | pwsh -c - | Should -Be $pwsh.Id In my local testing... I noticed that:
1432 was typically the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
TylerLeonhardt Maybe #1995? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
TylerLeonhardt does this repro the issue? @' try {{ Enter-PSHostProcess -Id {0} -ErrorAction Stop $pid }} finally {{ Exit-PSHostProcess }} '@ -f $pwsh.Id | pwsh -c - | Should -Be $pwsh.Id In other words, is the -ErrorAction Stop behaving as we expect? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| It "Should throw if CustomPipeName is too long on Linux or macOS" { | ||
| It "Should throw if CustomPipeName is too long on Linux or macOS" -Skip:($IsWindows) { | ||
| $longPipeName = "DoggoipsumwaggywagssmolborkingdoggowithalongsnootforpatsdoingmeafrightenporgoYapperporgolongwatershoobcloudsbigolpupperlengthboy" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why is this a thing?
(just wondering)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
because on unix they're not called "Named Pipes" they're called "UNIX domain sockets" which have a limit on macOS and Linux.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I meant $longPipeName = "DoggoipsumwaggywagssmolborkingdoggowithalongsnootforpatsdoingmeafrightenporgoYapperporgolongwatershoobcloudsbigolpupperlengthboy"
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
+1 to generate needed length and add a comment.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I see.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) Maybe... but I had 100% success rate from 20 runs on my mac and in an ubuntu container. Rain Sallow (/u/ta11ow) (@vexx32) I'm open to give that a try... the test should still fail, but maybe we'll get more info as to why (also edited your comment to escape the {}) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
TylerLeonhardt I suggest replace "-c" with "-file" to avoid escaping problem. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -0,0 +1,3 @@ | |||
| Enter-PSHostProcess -Id 40328 -ErrorAction Stop | |||
| $pid | |||
| Exit-PSHostProcess | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please remove.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
will do. Still getting data. moved to WIP
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, where exactly? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| }} | ||
| finally {{ | ||
| Exit-PSHostProcess | ||
| }} |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
double braces?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You need this for template strings to escape { and } otherwise it throws a bad formatting exception
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
jeez... |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| } | ||
| It "Can enter, exit, and re-enter another PSHost" { | ||
| # $pwsh = Start-PSProcess |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why commented?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You should probably just hold off on reviewing. This issue only repros in CI... so it'll be a lot of trial and error.
When I remove WIP, you can review for real.
Open to suggestions on how to fix the tests though 😅
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
My suggestion was above - use "-file" parameter and put the temporary test script in file.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
If this succeeds CI, please restart a few times. I need 😴 If this works, I'll need to add a test to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
it... passed once so far. Triggered again with some comments... now time for bed. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I restarted CI-windows as you ask (previous was Ok). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I spoke to Paul Higinbotham (@PaulHigin) about this and we agreed that since the tests have been reliable in this PR, we'll keep them in. If they become a problem again, we can remove the ones that use |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ardt/PowerShell into fix-enter-pshostprocess-tests
| $pipePath = Get-PipePath $pipeName | ||
|
|
||
| # The pipePath should be created by the time the -Command is executed. | ||
| pwsh -CustomPipeName $pipeName -Command "Test-Path '$pipePath'" | Should -BeTrue |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
use $powershell instead. Using pwsh will call the installed pwsh on the system, not the one which we build.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If what you say is true, then none of my CustomPipeName tests would be passing, right? I'm willing to change it though. Is that a magic variable or something?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Probably set during the build or on test initialization with Start-PSPester, I'd imagine. 🙂
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Oh I see what you're saying now :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I've fixed this so it's consistent
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| "`$pid" | & $powershell -CustomPipeName $longPipeName -c - | ||
| # 64 is the ExitCode for BadCommandLineParameter | ||
| $LASTEXITCODE | Should -Be 64 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You can check for FullyQualifiedErrorId that is not localized.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Should -BeTrue -Because "The script was able to re-enter another process and grab the pid of '$powershellId'." | ||
|
|
||
| } finally { | ||
| $powershellJob | Stop-Process -Force -ErrorAction SilentlyContinue |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Should this be Stop-Job | Remove-Job instead?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
you're totally right. Added.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| $ps.AddScript('$pid').Invoke() | Should -Be $pwsh.Id | ||
| $ps.AddScript('$pid').Invoke() | Should -Be $pwshId | ||
| } finally { | ||
| $rs.Dispose() |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Also add $ps.Dispose()
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
added
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
TylerLeonhardt - To fix the static analysis CI - update the link to https://www.itprotoday.com/powershell/powershell-basics-remote-management |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Restarted Windows CI |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Travis Plunk (@TravisEz13) can you update your review? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ardt/PowerShell into fix-enter-pshostprocess-tests
|
TylerLeonhardt Just realized the tests that were changed are tagged as |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ardt/PowerShell into fix-enter-pshostprocess-tests
|
triggered |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This has become unreliable again. I have filed #11168 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Enter-PSHostProcess tests.By Process Id.Can enter using NamedPipeConnectionInfo is Failing 6% of the time
There was an error while loading. Please reload this page.