-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Use generic test handling for remote server failures. #25910
Conversation
3237719 to
d37b86e
Compare
|
@dotnet-bot test outerloop linux x64 debug build please |
|
The test failures are not related to this PR. |
|
It looks ok to me. With "Likely external issue with remote server", would it make sense to claim it only on specific underlying exceptions e.g. timeout and reset? |
Yes, that's what the lambda you pass in to the API is for, only when the lambda returns true, the remoteserverexception is thrown. |
| public RemoteServerException() | ||
| : this(null, null) { } | ||
|
|
||
| public RemoteServerException(string server) |
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.
Can we remove this overload? - to force everyone to use the original exception as well?
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.
sure
| public RemoteServerException(string server, Exception inner) | ||
| : base(GetMessage(server), inner) { } | ||
|
|
||
| public static string GetMessage(string server) |
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 like helper method, do we need it public?
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.
This is not exposed in any api or anything, the whole class in internal. But yeah it can be private.
| using (HttpClient client = CreateHttpClient()) | ||
| { | ||
| await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(url)); | ||
| await RemoteServerQuery.ThrowsAsync<HttpRequestException>(() => client.GetAsync(url), remoteServerExceptionWrapper, url); |
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.
What if we just wrap the exception around the call?
await Assert.ThrowsAsync<HttpRequestException>(() => RemoteServerQuery.Run(() => client.GetAsync(url), remoteServerExceptionWrapper, url));|
|
||
| internal static async Task ThrowsAsync<T>(Func<Task> testCode, Func<Exception, bool> remoteExceptionWrapper, string serverName) | ||
| where T : Exception | ||
| { |
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.
We're now playing the role of XUnit a bit by comparing the exception type and not its subtypes (it may be xunit default behavior). Do we really need it? What if we stick to just wrapping the exception? (see next comment)
|
the desktop run failed with |
Use generic test handling for remote server failures. Commit migrated from dotnet/corefx@2fe2cd5
cc @karelz @wfurt @davidsh
fixes #25878
fixes #25892
When any test with remote server dependency fails, it will output something like this: