@@ -574,14 +574,11 @@ defmodule Group.DistributedTest do
574574
575575 start_group_on_peers ( peers , opts )
576576
577- # Wait for Erlang-level connectivity so disconnect_nodes actually works
578- TestCluster . assert_eventually (
579- fn ->
580- c_nodes = TestCluster . rpc! ( node_c , Node , :list , [ ] )
581- node_a in c_nodes and node_b in c_nodes
582- end ,
583- timeout: 5000
584- )
577+ # Finish discovery on every shard before cutting links. Erlang connectivity
578+ # alone can leave handshake sends in flight that trigger reconnect retries.
579+ TestCluster . assert_group_nodes ( node_a , name , [ node_b , node_c ] )
580+ TestCluster . assert_group_nodes ( node_b , name , [ node_a , node_c ] )
581+ TestCluster . assert_group_nodes ( node_c , name , [ node_a , node_b ] )
585582
586583 # Set up nodedown monitor on A
587584 TestCluster . monitor_nodes_on ( node_a , self ( ) )
@@ -593,8 +590,12 @@ defmodule Group.DistributedTest do
593590 # Wait for A to confirm it saw C go down
594591 assert_receive { :nodedown_on_remote , ^ node_c } , 5000
595592
593+ # A separate node monitor does not establish that every shard handled DOWN.
594+ TestCluster . assert_group_nodes ( node_a , name , [ node_b ] )
595+ TestCluster . assert_group_nodes ( node_b , name , [ node_a ] )
596+ TestCluster . assert_group_nodes ( node_c , name , [ ] )
597+
596598 # While partitioned: register keys on A, join groups on C
597- # flush_shards ensures nodedown is processed before registering
598599 TestCluster . spawn_register ( node_a , name , "user/from_a" , % { origin: :a } , flush_shards: 2 )
599600 TestCluster . spawn_join ( node_c , name , "room/from_c" , % { origin: :c } )
600601
@@ -1970,14 +1971,10 @@ defmodule Group.DistributedTest do
19701971 length ( nodes ) >= 1
19711972 end )
19721973
1973- # Wait for Erlang-level connectivity so disconnect_nodes actually works
1974- TestCluster . assert_eventually (
1975- fn ->
1976- c_nodes = TestCluster . rpc! ( node_c , Node , :list , [ ] )
1977- node_a in c_nodes and node_b in c_nodes
1978- end ,
1979- timeout: 5000
1980- )
1974+ # Wait for Group discovery, not just Erlang connectivity, before partitioning.
1975+ TestCluster . assert_group_nodes ( node_a , name , [ node_b , node_c ] )
1976+ TestCluster . assert_group_nodes ( node_b , name , [ node_a , node_c ] )
1977+ TestCluster . assert_group_nodes ( node_c , name , [ node_a , node_b ] )
19811978
19821979 # Set up nodedown monitors on A before partitioning
19831980 TestCluster . monitor_nodes_on ( node_a , self ( ) )
@@ -1990,9 +1987,12 @@ defmodule Group.DistributedTest do
19901987 assert_receive { :nodedown_on_remote , ^ node_c } , 5000
19911988
19921989 # Wait for Group's own peer tables to reflect the partition before writing.
1990+ TestCluster . assert_group_nodes ( node_a , name , [ node_b ] )
1991+ TestCluster . assert_group_nodes ( node_b , name , [ node_a ] )
1992+ TestCluster . assert_group_nodes ( node_c , name , [ ] )
1993+
19931994 TestCluster . assert_eventually ( fn ->
1994- node_c not in TestCluster . rpc! ( node_a , Group , :nodes , [ name ] ) and
1995- node_c not in TestCluster . rpc! ( node_a , Group , :nodes , [ name , "game" ] )
1995+ node_c not in TestCluster . rpc! ( node_a , Group , :nodes , [ name , "game" ] )
19961996 end )
19971997
19981998 # Register data during partition
0 commit comments