Prevent background process from crashing test when writing to the test output helper #20254
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.
I think I know what's causing the crashes.
The interop tests are set up like the following:
A single server is launched in a test fixture for all test cases.
The server is passed an ITestOutputHelper that's used during the entire duration of the tests.
If the test server tries to write anything to the ITestOutputHelper in between the test cases, the ITestOutputHelper is in an invalid state since no test is active. This causes a crash.
I think the proper fix is to have the server not write to the ITestOutputHelper in between test cases. As a tactical fix though I think we can just ignore these exceptions when they are thrown.Or better yet, use file logging instead so there's no contention. In this case, the server maintains its own logs and write to file. During each test case run, the server also writes to the test case's file logs so that it's easy to correlate between server/client logs.We ended up deciding to just launch a server instance for each test case.