diff options
author | Bar Shaul <88437685+barshaul@users.noreply.github.com> | 2022-06-23 19:28:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-23 19:28:02 +0300 |
commit | 63cf7ec5cbaca533b7607196dbf993917a65c0f9 (patch) | |
tree | fd02285634cdd1d7978e5c521edf89b201bb94a0 /tests/test_cluster.py | |
parent | d3a7a75c7b106e0864b3927c0904058e25c99958 (diff) | |
download | redis-py-63cf7ec5cbaca533b7607196dbf993917a65c0f9.tar.gz |
Added dynamic_startup_nodes configuration to RedisCluster. (#2244)
* Added dynamic_startup_nodes configuration to RedisCluster. By default, uses only the initial passed startup nodes to refresh the cluster topology. If set to true, sets the startup nodes to all of the discovered nodes.
* Added RedisCluster specific options to the README file and updated CHANGES
* Fixed timeout_error_topology_refresh test
Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
Diffstat (limited to 'tests/test_cluster.py')
-rw-r--r-- | tests/test_cluster.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/test_cluster.py b/tests/test_cluster.py index 438ef73..0353323 100644 --- a/tests/test_cluster.py +++ b/tests/test_cluster.py @@ -673,7 +673,7 @@ class TestRedisClusterObj: def moved_redirect_effect(connection, *args, **options): # raise a timeout for 5 times so we'll need to reinitilize the topology - if count.val >= 5: + if count.val == 4: parse_response.side_effect = real_func count.val += 1 raise TimeoutError() @@ -2285,6 +2285,27 @@ class TestNodesManager: assert rc.get_node(host=default_host, port=7001) is not None assert rc.get_node(host=default_host, port=7002) is not None + @pytest.mark.parametrize("dynamic_startup_nodes", [True, False]) + def test_init_slots_dynamic_startup_nodes(self, dynamic_startup_nodes): + rc = get_mocked_redis_client( + host="my@DNS.com", + port=7000, + cluster_slots=default_cluster_slots, + dynamic_startup_nodes=dynamic_startup_nodes, + ) + # Nodes are taken from default_cluster_slots + discovered_nodes = [ + "127.0.0.1:7000", + "127.0.0.1:7001", + "127.0.0.1:7002", + "127.0.0.1:7003", + ] + startup_nodes = list(rc.nodes_manager.startup_nodes.keys()) + if dynamic_startup_nodes is True: + assert startup_nodes.sort() == discovered_nodes.sort() + else: + assert startup_nodes == ["my@DNS.com:7000"] + @pytest.mark.onlycluster class TestClusterPubSubObject: |