Improve E2E Test Fixtures to be less flaky#2208
Conversation
5cb7349 to
1d8a574
Compare
|
@andyleejordan @SeeminglyScience Did a lot of cleanup here, DAP tests run much faster and I should have cleaned up the race conditions, they've been completely reliable for me so far. The tests should also read fairly cleaner now as well. |
7f0083c to
7ecdd5a
Compare
|
@JustinGrote running this through the internal pipeline right now! |
Sooo actually per 20fa478 we cannot currently run the tests on OneBranch since it's stuck with PowerShell 7.3...so this will have to wait until January 😵 |
7ecdd5a to
b1bafa3
Compare
|
Hi @JustinGrote, we can finally run the tests again in ADO. Would you want to get this PR updated? Note that I had to skip the |
b1bafa3 to
b5c00a3
Compare
|
@andyleejordan rebased and passed locally for me. Lets see if ADO likes it. |
|
Looks like it works. I can do the logging fixups as a separate item especially now that the other logging stuff was implemented. |
There was a problem hiding this comment.
PR Overview
This PR improves the stability and clarity of the E2E test fixtures by reworking the PSES process host to use task- and interface-based patterns and by replacing the legacy LoggingStream with DebugOutputStream for logging LSP communication.
- Converted the StdioLanguageServerProcessHost and related test fixtures to use updated process management with task completion sources.
- Replaced LoggingStream with DebugOutputStream to log stream activity only when a debugger is attached.
- Updated references in tests and LSP fixtures to use the new host implementation.
Reviewed Changes
| File | Description |
|---|---|
| test/PowerShellEditorServices.Test.E2E/Hosts/StdioLanguageServerProcessHost.cs | Refactored host start/stop logic to use task-based state tracking. |
| test/PowerShellEditorServices.Test.E2E/Hosts/PsesStdioLanguageServerProcessHost.cs | Updated host constructor and environment variable references for improved test stability. |
| test/PowerShellEditorServices.Test.E2E/Hosts/DebugOutputStream.cs | Introduced DebugOutputStream to log read/write operations when debugging tests. |
| test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs | Updated tests to use the new host and logging methods; removed dependency on LoggingStream. |
| test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs, LSPTestsFixtures.cs, IDebugAdapterClientExtensions.cs | Updated usage and references from the legacy process host to the new one. |
| Various Process files | Removed legacy PsesStdioProcess and related files to consolidate host management. |
| src/PowerShellEditorServices/Server/PsesDebugServer.cs | Minor formatting adjustment in the debug server response initialization. |
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs
Show resolved
Hide resolved
e12f94b to
5642221
Compare
andyleejordan
left a comment
There was a problem hiding this comment.
Nice, I like this a lot, just some questions. Also as far as ADO goes at this point we just have to YOLO it. I can't easily test a PR against the pipeline that would actually block us from releasing if it broke. 🤷 (Long story, really annoying.)
test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs
Show resolved
Hide resolved
|
|
||
| <ItemGroup> | ||
| <!-- Used for Update-Help for some test fixtures --> | ||
| <Content Include="..\PowerShellEditorServices.Test.Shared\PSHelp\**\*" |
There was a problem hiding this comment.
Would this fix all the tests that depend on help, and could we remove the build step where we Update-Help for the tests?
There was a problem hiding this comment.
Only if the tests use Microsoft.PowerShell.Utility cmdlets for their reference. This is only required for Windows PowerShell since it doesn't ship this help in-box, all pwsh flavors do ship help in-box and so we don't have to do this. Assuming we find/adjust all help-based tests to use Microsoft.PowerShell.Utility, then yes this should fix them in AzDO CI
| { | ||
| Skip.If(PsesStdioProcess.RunningInConstrainedLanguageMode && PsesStdioProcess.IsWindowsPowerShell, | ||
| Skip.If(PsesStdioLanguageServerProcessHost.RunningInConstrainedLanguageMode && PsesStdioLanguageServerProcessHost.IsWindowsPowerShell, | ||
| "Windows PowerShell doesn't trust PSScriptAnalyzer by default so it won't load."); |
There was a problem hiding this comment.
Hey, is this why people are having problems with the formatter "hanging" when they use Windows PowerShell? Food for thought...
There was a problem hiding this comment.
It might be! Maybe I can get some LSP trace logs from them and stick in some telemetry to find out.
| [SkippableFact] | ||
| public async Task CanSendHoverRequestAsync() | ||
| { | ||
| Skip.If(IsLinux, "This depends on the help system, which is flaky on Linux."); |
There was a problem hiding this comment.
Do we still need to skip this test now that the help is mocked?
There was a problem hiding this comment.
Maybe not? As you said lets YOLO it as a test.
There was a problem hiding this comment.
I also think I separately fixed this test in the other branch so there might be a conflict, I'll rebase.
| new EvaluateRequestArguments | ||
| { | ||
| Expression = "Import-Module Microsoft.PowerShell.Archive -Prefix Slow" | ||
| Expression = $"Update-Help Microsoft.Powershell.Utility -SourcePath {s_binDir};Import-Module Microsoft.PowerShell.Utility -Prefix Test -Force" |
There was a problem hiding this comment.
Ahh sweet, ok yeah, I think there's an Update-Help in the build script too...
| s_binDir, $"pses_test_logs_{Path.GetRandomFileName()}"); | ||
|
|
||
| private const string s_logLevel = "Diagnostic"; | ||
| private static readonly string[] s_featureFlags = { "PSReadLine" }; |
There was a problem hiding this comment.
Do we really pass this through in feature flags still? I didn't think we had anything in feature flags.
There was a problem hiding this comment.
I just looked and I didn't see this feature flag actually referenced anywhere, so it can probably be removed but I think that should be the scope of another PR. You're probably seeing it here as a "change" because I moved the file to a new folder I belieeve.
5642221 to
4e68bf6
Compare
4e68bf6 to
52feb6c
Compare
e0e8c1e to
a476e9f
Compare
It took longer than 1 minute in Github Actions!
22993ea to
34347ba
Compare
34347ba to
b22510a
Compare
Oops. I don't think I'm expecting something else. And if I remember correctly on the sortText, VS Code completely ignored it and applies their own sorting. |
3eb0adb to
50a806f
Compare
50a806f to
2a65e3d
Compare
|
@andyleejordan this should be ready for re-review and an internal pipeline test. Changes summary:
|
andyleejordan
left a comment
There was a problem hiding this comment.
Sorry I was being picky about my build script lol, going to commit these, test, and merge!
|
|
||
| - name: If Debugging, start upterm for interactive pipeline troubleshooting | ||
| if: ${{ runner.debug == 1 }} | ||
| uses: lhotari/action-upterm@v1 |
There was a problem hiding this comment.
Well that's cool...I need to share with Steve. He's been asking for something exactly like this.
There was a problem hiding this comment.
I'm working on a version that lets you vscode remote into the github action, the tricky part is the authentication but it's definitely doable :)
|
That's what I get for doing this on GitHub. |
fd596da to
4cddce2
Compare
|
It was because I added a single quote...inside single quotes 🫨 |
|
@andyleejordan thank you! |

LoggingStreamwithDebugOutputStreamto log LSP communication to debug console when debugging tests- [ ] Wire up LSP Client logging to XUnitITestOutputHelper- [ ] Wire up PSES Initial File Logging to debug console