From 24ba77754a3722877af8bb4e509f9bc947a80a8d Mon Sep 17 00:00:00 2001 From: KiKoS0 <22998716+KiKoS0@users.noreply.github.com> Date: Sun, 24 Nov 2024 03:46:44 +0100 Subject: [PATCH] Fix monitor exclusion not being applied for newly detected nodes (#392) --- lib/cachex/router/ring/monitor.ex | 2 +- test/cachex/router/ring_test.exs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/cachex/router/ring/monitor.ex b/lib/cachex/router/ring/monitor.ex index 9c93c0d..e842e62 100644 --- a/lib/cachex/router/ring/monitor.ex +++ b/lib/cachex/router/ring/monitor.ex @@ -27,7 +27,7 @@ defmodule Cachex.Router.Ring.Monitor do type = Keyword.get(options, :monitor_type) includes = Keyword.get(options, :monitor_includes, []) - excludes = Keyword.get(options, :monitor_includes, []) + excludes = Keyword.get(options, :monitor_excludes, []) :ok = :net_kernel.monitor_nodes(true, node_type: type) diff --git a/test/cachex/router/ring_test.exs b/test/cachex/router/ring_test.exs index c35fbf6..86e889c 100644 --- a/test/cachex/router/ring_test.exs +++ b/test/cachex/router/ring_test.exs @@ -124,7 +124,7 @@ defmodule Cachex.Router.RingTest do @tag distributed: true test "routing keys via a ring router with excluded nodes" do # create a test cache cluster for nodes - {cache, _nodes, _cluster} = + {cache, _nodes, cluster} = TestUtils.create_cache_cluster(3, router: router( @@ -143,6 +143,13 @@ defmodule Cachex.Router.RingTest do # verify that only the manage was attached to the ring assert Cachex.Router.nodes(cache) == {:ok, [node()]} + + {:ok, [_member1]} = LocalCluster.start(cluster, 1) + + :timer.sleep(250) + + # make sure that the exclusion applies on newly detected nodes + assert Cachex.Router.nodes(cache) == {:ok, [node()]} end test "matching node names against include/exclude params" do