Skip to content
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

Disconnection test #76

Merged
merged 29 commits into from
Apr 13, 2020
Merged

Disconnection test #76

merged 29 commits into from
Apr 13, 2020

Conversation

zwx14700
Copy link
Contributor

@zwx14700 zwx14700 commented Mar 30, 2020

Change log description
Implement the disconnection test.

Purpose of the change
Fixes: #70 #81

How to verify it
tests should pass.

Copy link
Member

@tkaitchuck tkaitchuck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add a test that uses the connection pool to create a connection to the server and then that connection fails. (This need not be an integration test, you can mock the server)

low_version: 5,
});
let reply = connection.write(&request).await;
// TODO: Tests failed here. It will always gives BrokenPipe error.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a problem with the pool. If you don't have any ideas, just as a test rry running on top of this PR #75
which changes how the pool works and see if anything changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@zwx14700 zwx14700 changed the title Draft: Disconnection test Disconnection test Apr 7, 2020
@zwx14700 zwx14700 requested a review from shrids April 7, 2020 18:57
}),
Ok(mut conn) => {
// The connection may be closed by the server when it is in the pool.
if conn.is_valid().await {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can somehow use a loop to check every conn in the managed_pool until there is a valid one or there is nothing left. Right now it just checks one conn at most.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

Copy link
Member

@tkaitchuck tkaitchuck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments. Otherwise looks good.

async fn test_retry_with_no_connection() {
let retry_policy = RetryWithBackoff::default().max_tries(4);
// give a wrong endpoint
let endpoint = "127.0.0.1:12345"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible for something to actually be on that port, in which case this would fail in an unexpected way.
https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports
Maybe something like 2, would be better? Does 0 work? Because that definitivly can't have anything listening on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I change the port to 0.

Copy link
Contributor

@shrids shrids left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM...

@tkaitchuck tkaitchuck merged commit ca84999 into master Apr 13, 2020
@tkaitchuck tkaitchuck deleted the disconnection-test branch April 13, 2020 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add connection disconnect tests
4 participants