From 266222f44936b8526bc97101a7189dfe571df386 Mon Sep 17 00:00:00 2001 From: Stefan Miklosovic Date: Tue, 28 Nov 2023 14:45:48 +0100 Subject: [PATCH] fix counter test --- byteman/4.0/election_counter_leader_favor_node2.btm | 4 ++-- counter_test.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/byteman/4.0/election_counter_leader_favor_node2.btm b/byteman/4.0/election_counter_leader_favor_node2.btm index ae5b880f28..2e627c3d23 100644 --- a/byteman/4.0/election_counter_leader_favor_node2.btm +++ b/byteman/4.0/election_counter_leader_favor_node2.btm @@ -7,8 +7,8 @@ RULE election counter leader cheat CLASS org.apache.cassandra.service.StorageProxy METHOD findSuitableEndpoint AT EXIT -BIND isthere:boolean = $localEndpoints.contains(org.apache.cassandra.locator.InetAddressAndPort.getByName("127.0.0.2")); +BIND isthere:boolean = $localReplicas.stream().anyMatch(r -> { try { return r.endpoint().equals(org.apache.cassandra.locator.InetAddressAndPort.getByName("127.0.0.2")); } catch (Throwable t) { return false; } }); if isthere DO - return org.apache.cassandra.locator.InetAddressAndPort.getByName("127.0.0.2"); + return localReplicas.stream().filter(lr -> { try { return lr.endpoint().equals(InetAddressAndPort.getByName("127.0.0.2")); } catch (Throwable t) { return null; } }).findFirst().get(); ENDRULE diff --git a/counter_test.py b/counter_test.py index 2a9837d703..4a484ea700 100644 --- a/counter_test.py +++ b/counter_test.py @@ -114,8 +114,11 @@ def test_counter_leader_with_partial_view(self): # Now stop the node and restart but first install a rule to slow down how fast node 2 will update the list # nodes that are alive - nodes[1].stop(wait=True, wait_other_notice=False) - nodes[1].update_startup_byteman_script(mk_bman_path('gossip_alive_callback_sleep.btm')) + nodes[1].stop(wait=True, wait_other_notice=True) + + if cluster.version() < '5.1': + nodes[1].update_startup_byteman_script(mk_bman_path('gossip_alive_callback_sleep.btm')) + nodes[1].start(no_wait=True, wait_other_notice=False) # Until node 2 is fully alive try to force other nodes to pick him as mutation leader.