Didja know, RavenDB include a proxy server
This is one of those things that I had to read several times to realize what was actually going on.
The code for that is here: https://github.com/ayende/ravendb/blob/c0c9ccf98011fb64b5eb5406a900ec1338ea78e4/Raven.Tests/Issues/RavenDB_1603.cs#L32
And it appears that along with every else, RavenDB also include a proxy server.
Now, to be fair, this is required for our tests, to see what happens when we have a forced disconnect / timeout at the network level, so it make sense. And the whole thing is under 100 lines of code.
This sort of thing explains why we really need to do a whole bunch of work on our tests. We want to get to a 500 – 1000 tests (currently we have close to 3,200) that run in under 5 minutes.
Comments
Nice proxy, and some clever use of async I yet have to get used to. But for a beginning, what's the difference between
var read = await incomingStream.ReadAsync(buffer, 0, 4096, token);
and
var read = incomingStream.Read(buffer, 0, 4096)
is the first one any better?
It looks like there are a couple of "bugs". Two of the while(true) loops look like will never exit (except on exception). In Forward it should probably use "!cancellationTokenSource.IsCancellationRequested" In the writeTask it should probably "break" when "read == 0" as the readTask does. An "extract method" refactoring would help.
Without these I think there's a task leak. Though as this is "just test code" it's safe enough :)
Rafal, The first one is better because it will yield the thread for the duration of the actual IO, leaving it free to do other work.
Comment preview