-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[automatic failover] Set and test default values for failover config&components #4298
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
Merged
atakavci
merged 3 commits into
redis:feature/automatic-failover-3
from
atakavci:ali/aa-failover-defaultValues
Oct 2, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/test/java/redis/clients/jedis/mcf/DefaultValuesTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| package redis.clients.jedis.mcf; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
|
||
| import java.time.Duration; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import redis.clients.jedis.DefaultJedisClientConfig; | ||
| import redis.clients.jedis.HostAndPort; | ||
| import redis.clients.jedis.JedisClientConfig; | ||
| import redis.clients.jedis.MultiClusterClientConfig; | ||
|
|
||
| public class DefaultValuesTest { | ||
|
|
||
| HostAndPort fakeEndpoint = new HostAndPort("fake", 6379); | ||
| JedisClientConfig config = DefaultJedisClientConfig.builder().build(); | ||
|
|
||
| @Test | ||
| void testDefaultValuesInConfig() { | ||
|
|
||
| MultiClusterClientConfig.ClusterConfig clusterConfig = MultiClusterClientConfig.ClusterConfig | ||
| .builder(fakeEndpoint, config).build(); | ||
| MultiClusterClientConfig multiConfig = new MultiClusterClientConfig.Builder( | ||
| new MultiClusterClientConfig.ClusterConfig[] { clusterConfig }).build(); | ||
|
|
||
| // check for grace period | ||
| assertEquals(60000, multiConfig.getGracePeriod()); | ||
|
|
||
| // check for cluster config | ||
| assertEquals(clusterConfig, multiConfig.getClusterConfigs()[0]); | ||
|
|
||
| // check healthchecks enabled | ||
| assertNotNull(clusterConfig.getHealthCheckStrategySupplier()); | ||
|
|
||
| // check default healthcheck strategy is echo | ||
| assertEquals(EchoStrategy.DEFAULT, clusterConfig.getHealthCheckStrategySupplier()); | ||
|
|
||
| // check number of probes | ||
| assertEquals(3, | ||
| clusterConfig.getHealthCheckStrategySupplier().get(fakeEndpoint, config).getNumProbes()); | ||
|
|
||
| assertEquals(500, clusterConfig.getHealthCheckStrategySupplier().get(fakeEndpoint, config) | ||
| .getDelayInBetweenProbes()); | ||
|
|
||
| assertEquals(ProbingPolicy.BuiltIn.ALL_SUCCESS, | ||
| clusterConfig.getHealthCheckStrategySupplier().get(fakeEndpoint, config).getPolicy()); | ||
|
|
||
| // check health check interval | ||
| assertEquals(5000, | ||
| clusterConfig.getHealthCheckStrategySupplier().get(fakeEndpoint, config).getInterval()); | ||
|
|
||
| // check lag aware tolerance | ||
| LagAwareStrategy.Config lagAwareConfig = LagAwareStrategy.Config | ||
| .builder(fakeEndpoint, config.getCredentialsProvider()).build(); | ||
| assertEquals(Duration.ofMillis(5000), lagAwareConfig.getAvailabilityLagTolerance()); | ||
|
|
||
| // TODO: check CB number of failures threshold -- 1000 | ||
| // assertEquals(1000, multiConfig.circuitBreakerMinNumOfFailures()); | ||
|
|
||
| // check CB failure rate threshold | ||
| assertEquals(10, multiConfig.getCircuitBreakerFailureRateThreshold()); | ||
|
|
||
| // check CB sliding window size | ||
| assertEquals(2, multiConfig.getCircuitBreakerSlidingWindowSize()); | ||
|
|
||
| // check failback check interval | ||
| assertEquals(120000, multiConfig.getFailbackCheckInterval()); | ||
|
|
||
| // check failover max attempts before give up | ||
| assertEquals(10, multiConfig.getMaxNumFailoverAttempts()); | ||
|
|
||
| // check delay between failover attempts | ||
| assertEquals(12000, multiConfig.getDelayInBetweenFailoverAttempts()); | ||
|
|
||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The constructor call is missing required method calls for interval, timeout, and numProbes that were previously set in the removed line. This will cause the parent class defaults to be used instead of calling the builder methods explicitly.