Skip to content

Commit

Permalink
Switch order of test_Connection_checkout_fails_due_to_error_establish… (
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahStapp authored Feb 15, 2024
1 parent 4191ca8 commit 5a86740
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions pymongo/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ class _ConnectionStatusMessage(str, enum.Enum):
ConnectionClosedReason.POOL_CLOSED: "Connection pool was closed",
ConnectionCheckOutFailedReason.POOL_CLOSED: "Connection pool was closed",
ConnectionClosedReason.STALE: "Connection pool was stale",
ConnectionClosedReason.ERROR: "Connection experienced an error",
ConnectionCheckOutFailedReason.CONN_ERROR: "Connection experienced an error",
ConnectionClosedReason.ERROR: "An error occurred while using the connection",
ConnectionCheckOutFailedReason.CONN_ERROR: "An error occurred while trying to establish a new connection",
ConnectionClosedReason.IDLE: "Connection was idle too long",
ConnectionCheckOutFailedReason.TIMEOUT: "Connection exceeded the specified timeout",
}
Expand Down
3 changes: 2 additions & 1 deletion pymongo/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,7 @@ def close_conn(self, reason: Optional[str]) -> None:
serverPort=self.address[1],
driverConnectionId=self.id,
reason=_verbose_connection_error_reason(reason),
error=reason,
)

def _close_conn(self) -> None:
Expand Down Expand Up @@ -1981,7 +1982,7 @@ def checkin(self, conn: Connection) -> None:
serverHost=self.address[0],
serverPort=self.address[1],
driverConnectionId=conn.id,
reason="An error occurred while using the connection",
reason=_verbose_connection_error_reason(ConnectionClosedReason.ERROR),
error=ConnectionClosedReason.ERROR,
)
else:
Expand Down
28 changes: 14 additions & 14 deletions test/connection_logging/connection-logging.json
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,13 @@
"level": "debug",
"component": "connection",
"data": {
"message": "Connection pool cleared",
"message": "Connection closed",
"driverConnectionId": {
"$$type": [
"int",
"long"
]
},
"serverHost": {
"$$type": "string"
},
Expand All @@ -438,20 +444,18 @@
"int",
"long"
]
},
"reason": "An error occurred while using the connection",
"error": {
"$$exists": true
}
}
},
{
"level": "debug",
"component": "connection",
"data": {
"message": "Connection closed",
"driverConnectionId": {
"$$type": [
"int",
"long"
]
},
"message": "Connection checkout failed",
"serverHost": {
"$$type": "string"
},
Expand All @@ -461,7 +465,7 @@
"long"
]
},
"reason": "An error occurred while using the connection",
"reason": "An error occurred while trying to establish a new connection",
"error": {
"$$exists": true
}
Expand All @@ -471,7 +475,7 @@
"level": "debug",
"component": "connection",
"data": {
"message": "Connection checkout failed",
"message": "Connection pool cleared",
"serverHost": {
"$$type": "string"
},
Expand All @@ -480,10 +484,6 @@
"int",
"long"
]
},
"reason": "An error occurred while trying to establish a new connection",
"error": {
"$$exists": true
}
}
}
Expand Down

0 comments on commit 5a86740

Please sign in to comment.