New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Discussion] Add more connection failure tracking and tests. #7588
base: master
Are you sure you want to change the base?
Conversation
@@ -1022,6 +1022,8 @@ open class CallTest { | |||
executeSynchronously(request) | |||
.assertCode(200) | |||
.assertBody("success!") | |||
|
|||
assertThat(client.routeDatabase.failedRoutes.single().proxy.address()).isEqualTo(server.toProxyAddress().address()) |
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 the only failing test when routeDatabase.failed
is not called. Seems like we are missing coverage.
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.
Or perhaps, the coverage we do have (in RouteFailureTest) is overly pessimistic??
Only failure from disabling the RouteDatabase tracking prior to this
|
@@ -132,6 +132,7 @@ class ConnectPlan( | |||
success = true | |||
return ConnectResult(plan = this) | |||
} catch (e: IOException) { | |||
client.routeDatabase.failed(route) |
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 will also capture cases where the call was canceled. Hmm.
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.
And looking at the other call to routeDatabase.failed(), I think we should notify the proxy selector.
This is from RealConnection.kt
:
// Tell the proxy selector when we fail to connect on a fresh connection.
if (failedRoute.proxy.type() != Proxy.Type.DIRECT) {
val address = failedRoute.address
address.proxySelector.connectFailed(
address.url.toUri(), failedRoute.proxy.address(), failure
)
}
Perhaps the nicest structure is to move that snippet out of RealConnection
and into RouteDatabase
, so the two are always in sync.
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.
Yep, I wanted this to prompt discussion. I'm not clear that the current exception filtering is obviously right.
I'll split it out and use the opportunity to make a test.
.apply { | ||
retryOnConnectionFailure = true | ||
} | ||
.build() | ||
|
||
executeSynchronously(request) | ||
.assertFailureMatches("stream was reset: REFUSED_STREAM") | ||
.assertCode(200) |
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.
ooooh does your fix cause this to connect to a good host? That is PRETTY RAD
@@ -1022,6 +1022,8 @@ open class CallTest { | |||
executeSynchronously(request) | |||
.assertCode(200) | |||
.assertBody("success!") | |||
|
|||
assertThat(client.routeDatabase.failedRoutes.single().proxy.address()).isEqualTo(server.toProxyAddress().address()) |
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.
Or perhaps, the coverage we do have (in RouteFailureTest) is overly pessimistic??
# Conflicts: # okhttp/src/jvmTest/java/okhttp3/RouteFailureTest.kt
Unlikely to be correct, but if the ConnectPlan is the right place, then a few more questions.
routeDatabase.failed
?routeDatabase.connected
be called?RealConnection.trackFailure doesn't look right for HTTP/2.