Closed blairlearn closed 2 years ago
This appears to have been caused by the Stream object containing the mock response not being Disposed properly.
This has also surfaced NCIOCPL/NCI.OCPL.Api.Shared#41
There seems to be something subtly "wrong" about the manner in which we place a stream into the response object when testing handling of partial (i.e. "interrupted") responses. This impacts both GetSuggestions_TestInvalidResponse
and GetCount_InvalidResponse
.
Annoyingly, this only happens when the tests are run as a whole, not when being debugged.
Clearly, it's a race condition.
Putting a using
around the stream assignment allows the test to run, however since this closes the stream, it may simply be causing NEST to encounter, and swallow, an exception due to an attempt at reading a closed stream.
Similarly, adding code to the query service to write a dump of the response object also causes the error to go away.
In the end, with agreement from @bryanpizzillo, since all we really care about on those tests is setting the response, the fix is to replace the ElasticsearchInterceptingConnection
with NEST's InMemoryConnection
.
Issue description
Following the update to Elasticsearch 7.9 and the NEST client, the
GetSuggestions_TestInvalidResponse
test now fails.The test fails when run from the command line via
dotnet test
but succeeds when run in the debugger.Steps to reproduce the issue
What's the expected result?
What's the actual result?
GetSuggestions_TestInvalidResponse
failsAdditional details / screenshot
Related Tickets