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

Add "sanity check" tests for AgentClient#ping #268

Merged
merged 1 commit into from
Aug 18, 2023

Conversation

sleberknight
Copy link
Member

This relates to an issue that was in the original consul-client library: rickfast/consul-client#282

The issue claimed that calling AgentClient#ping resulted in a java.io.EOFException which we've never seen. But, go ahead and add an explicit test for this method. Since it is void, the best we can do here is assert that no exception is thrown when Consul is running.

Add test for successful ping and for a failed ping when Consul cannot be connected to.

The failed test is a RetryingTest that attempts to connect to Consul using a random port between 50000 and 65535. It will make up to five attempts before giving up. This should be more than enough attempts to find a port that causes a failure. I expect this to usually only make one attempt, but don't want to hard code the port, and don't want to fail in the (very unlikely) event there actually is a Consul running on the randomly selected port.

This relates to an issue that was in the original consul-client
library: rickfast/consul-client#282

The issue claimed that calling AgentClient#ping resulted in a
java.io.EOFException which we've never seen. But, go ahead and
add an explicit test for this method. Since it is void, the best
we can do here is assert that no exception is thrown when
Consul is running.

Add test for successful ping and for a failed ping when Consul
cannot be connected to.

The failed test is a RetryingTest that attempts to connect to
Consul using a random port between 50000 and 65535. It will make
up to five attempts before giving up. This should be more than
enough attempts to find a port that causes a failure. I expect
this to usually only make one attempt, but don't want to hard
code the port, and don't want to fail in the (very unlikely) event
there actually is a Consul running on the randomly selected port.
@sleberknight sleberknight added the code cleanup Fix issues reported by Sonar or any other code analysis tools label Aug 18, 2023
@sleberknight sleberknight added this to the 1.1.1 milestone Aug 18, 2023
@sleberknight sleberknight self-assigned this Aug 18, 2023
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sleberknight sleberknight merged commit 0759326 into master Aug 18, 2023
@sleberknight sleberknight deleted the add-sanity-check-test-for-ping branch August 18, 2023 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code cleanup Fix issues reported by Sonar or any other code analysis tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant