-
Notifications
You must be signed in to change notification settings - Fork 447
clean up HttpConnectionTests #1208
Conversation
* Add some helpers to reduce duplication * Refactor some tests to clarify what they test * Removed a few redundant test cases
|
wtf is a SyncPoint... |
|
Read the code and find out. It's a pair of TCSes that replace a bunch of repeated code in our tests. |
| @@ -0,0 +1,128 @@ | |||
| using System; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: (c) notice. </ TroyMode>
| @@ -0,0 +1,91 @@ | |||
| using System; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(c) here and other new files.
muratg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! There could be further clean-up but no need to block this one.
| @@ -0,0 +1,366 @@ | |||
| using System; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy
| @@ -0,0 +1,104 @@ | |||
| using System; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy
| @@ -0,0 +1,119 @@ | |||
| using System; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy
| { | ||
| return Task.FromException<HttpResponseMessage>(new InvalidOperationException($"Http endpoint not implemented: {request.RequestUri}")); | ||
| } | ||
| // Just block until cancelled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
canceled
|
I'm going to take a look at some of the test flakiness after this. I don't like how hard it is to get the checks to go green. |
No changes to product code at all, just to test code.
try { ... } finally { DisposeAsync() }pattern gets noisy fast so I addedWithConnectionAsync()which runs a provided delegate in the body of that try-finally patternTestTransportandTestHttpMessageHandlercode to remove most of the duplication.SyncPointhelper I introduced in Making HttpConnection restartable (C#) #1147 does (having a pair of TCSes to allow test code to wait for code-under-test to reach a certain point and then release it to continue after a condition is met). So I refactored to use that.EventsAreNotRunningOnMainLoopwas depending upon a race. It was testing that whenTryWriteon the channel was called, aTryReadimmediately following would fail because theHttpConnectionreceive loop already read the message. This depends on the way inline-continuations work in Channels and may break with other configurations. The refactored test waits forWaitToReadAsyncto block, which should be more reliableEventQueueTimeoutWithExceptionjust seemed to be checking that exceptions in OnReceive are handled, which other tests already do. So I just removed it.