Browse Source

Remove unnecessary cleaning of processes in tests.

Roberto Ostinelli 5 years ago
parent
commit
be6f004555
3 changed files with 22 additions and 103 deletions
  1. 1 3
      src/syn_registry.erl
  2. 12 60
      test/syn_groups_SUITE.erl
  3. 9 40
      test/syn_registry_SUITE.erl

+ 1 - 3
src/syn_registry.erl

@@ -36,9 +36,7 @@
 %% sync API
 -export([sync_get_local_registry_tuples/1]).
 -export([raise_inconsistent_name_data/5]).
--export([add_remote_to_local_table/3]).
--export([add_to_local_table/4]).
--export([remove_from_local_table/1]).
+-export([add_remote_to_local_table/3, add_to_local_table/4, remove_from_local_table/1]).
 
 %% gen_server callbacks
 -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).

+ 12 - 60
test/syn_groups_SUITE.erl

@@ -266,10 +266,7 @@ single_node_join_and_leave(_Config) ->
     [] = syn:get_members(GroupName),
     [] = syn:get_members(GroupName, with_meta),
     false = syn:member(Pid, GroupName),
-    false = syn:member(PidWithMeta, GroupName),
-    %% kill processes
-    syn_test_suite_helper:kill_process(Pid),
-    syn_test_suite_helper:kill_process(PidWithMeta).
+    false = syn:member(PidWithMeta, GroupName).
 
 single_node_join_errors(_Config) ->
     GroupName = "my group",
@@ -290,9 +287,7 @@ single_node_join_errors(_Config) ->
     syn_test_suite_helper:kill_process(Pid2),
     timer:sleep(200),
     {error, not_in_group} = syn:leave(GroupName, Pid2),
-    {error, not_alive} = syn:join(GroupName, Pid2),
-    %% kill processes
-    syn_test_suite_helper:kill_process(Pid).
+    {error, not_alive} = syn:join(GroupName, Pid2).
 
 single_node_publish(_Config) ->
     GroupName = "my group",
@@ -326,10 +321,7 @@ single_node_publish(_Config) ->
         {received, Pid2, Message} -> ok
     after 2000 ->
         ok = published_message_was_not_received_by_pid_2
-    end,
-    %% kill processes
-    syn_test_suite_helper:kill_process(Pid),
-    syn_test_suite_helper:kill_process(Pid2).
+    end.
 
 single_node_multicall(_Config) ->
     GroupName = <<"my group">>,
@@ -356,11 +348,7 @@ single_node_multicall(_Config) ->
         {Pid1, {pong, Pid1}},
         {Pid2, {pong, Pid2}}
     ]) =:= lists:sort(Replies),
-    [PidUnresponsive] = BadPids,
-    %% kill processes
-    syn_test_suite_helper:kill_process(Pid1),
-    syn_test_suite_helper:kill_process(Pid2),
-    syn_test_suite_helper:kill_process(PidUnresponsive).
+    [PidUnresponsive] = BadPids.
 
 single_node_multicall_with_custom_timeout(_Config) ->
     GroupName = <<"my group">>,
@@ -391,11 +379,7 @@ single_node_multicall_with_custom_timeout(_Config) ->
     {Replies, BadPids} = syn:multi_call(GroupName, get_pid_name, 2000),
     %% check responses
     [{Pid1, {pong, Pid1}}] = Replies,
-    true = lists:sort([PidTakesLong, PidUnresponsive]) =:= lists:sort(BadPids),
-    %% kill processes
-    syn_test_suite_helper:kill_process(Pid1),
-    syn_test_suite_helper:kill_process(PidTakesLong),
-    syn_test_suite_helper:kill_process(PidUnresponsive).
+    true = lists:sort([PidTakesLong, PidUnresponsive]) =:= lists:sort(BadPids).
 
 single_node_callback_on_process_exit(_Config) ->
     %% use custom handler
@@ -528,10 +512,7 @@ two_nodes_join_monitor_and_unregister(Config) ->
     false = rpc:call(SlaveNode, syn, member, [LocalPid, GroupName]),
     false = rpc:call(SlaveNode, syn, member, [RemotePid, GroupName]),
     false = rpc:call(SlaveNode, syn, member, [RemotePidJoinRemote, GroupName]),
-    false = rpc:call(SlaveNode, syn, member, [OtherPid, GroupName]),
-    %% kill processes
-    syn_test_suite_helper:kill_process(LocalPid),
-    syn_test_suite_helper:kill_process(RemotePid).
+    false = rpc:call(SlaveNode, syn, member, [OtherPid, GroupName]).
 
 two_nodes_local_members(Config) ->
     GroupName = "my group",
@@ -595,10 +576,7 @@ two_nodes_local_members(Config) ->
     [] = syn:get_local_members(GroupName, with_meta),
     %% remote members
     [] = rpc:call(SlaveNode, syn, get_local_members, [GroupName]),
-    [] = rpc:call(SlaveNode, syn, get_local_members, [GroupName, with_meta]),
-    %% kill processes
-    syn_test_suite_helper:kill_process(LocalPid),
-    syn_test_suite_helper:kill_process(RemotePid).
+    [] = rpc:call(SlaveNode, syn, get_local_members, [GroupName, with_meta]).
 
 two_nodes_publish(Config) ->
     GroupName = "my group",
@@ -655,13 +633,7 @@ two_nodes_publish(Config) ->
             ok = published_message_was_received_by_other_pid
     after 250 ->
         ok
-    end,
-    %% kill processes
-    syn_test_suite_helper:kill_process(LocalPid),
-    syn_test_suite_helper:kill_process(LocalPid2),
-    syn_test_suite_helper:kill_process(RemotePid),
-    syn_test_suite_helper:kill_process(RemotePid2),
-    syn_test_suite_helper:kill_process(OtherPid).
+    end.
 
 two_nodes_local_publish(Config) ->
     GroupName = "my group",
@@ -720,13 +692,7 @@ two_nodes_local_publish(Config) ->
             ok = published_message_was_received_by_other_pid
     after 250 ->
         ok
-    end,
-    %% kill processes
-    syn_test_suite_helper:kill_process(LocalPid),
-    syn_test_suite_helper:kill_process(LocalPid2),
-    syn_test_suite_helper:kill_process(RemotePid),
-    syn_test_suite_helper:kill_process(RemotePid2),
-    syn_test_suite_helper:kill_process(OtherPid).
+    end.
 
 two_nodes_multicall(Config) ->
     GroupName = <<"my group">>,
@@ -758,11 +724,7 @@ two_nodes_multicall(Config) ->
         {Pid1, {pong, Pid1}},
         {Pid2, {pong, Pid2}}
     ]) =:= lists:sort(Replies),
-    [PidUnresponsive] = BadPids,
-    %% kill processes
-    syn_test_suite_helper:kill_process(Pid1),
-    syn_test_suite_helper:kill_process(Pid2),
-    syn_test_suite_helper:kill_process(PidUnresponsive).
+    [PidUnresponsive] = BadPids.
 
 three_nodes_partial_netsplit_consistency(Config) ->
     GroupName = "my group",
@@ -936,12 +898,7 @@ three_nodes_partial_netsplit_consistency(Config) ->
     false = rpc:call(SlaveNode2, syn, member, [Pid0Changed, GroupName]),
     true = rpc:call(SlaveNode2, syn, member, [Pid1, GroupName]),
     true = rpc:call(SlaveNode2, syn, member, [Pid2, GroupName]),
-    false = rpc:call(SlaveNode2, syn, member, [OtherPid, GroupName]),
-    %% kill processes
-    syn_test_suite_helper:kill_process(Pid0),
-    syn_test_suite_helper:kill_process(Pid0Changed),
-    syn_test_suite_helper:kill_process(Pid1),
-    syn_test_suite_helper:kill_process(Pid2).
+    false = rpc:call(SlaveNode2, syn, member, [OtherPid, GroupName]).
 
 three_nodes_full_netsplit_consistency(Config) ->
     GroupName = "my group",
@@ -1089,9 +1046,4 @@ three_nodes_full_netsplit_consistency(Config) ->
     false = rpc:call(SlaveNode2, syn, member, [Pid0Changed, GroupName]),
     true = rpc:call(SlaveNode2, syn, member, [Pid1, GroupName]),
     true = rpc:call(SlaveNode2, syn, member, [Pid2, GroupName]),
-    false = rpc:call(SlaveNode2, syn, member, [OtherPid, GroupName]),
-    %% kill processes
-    syn_test_suite_helper:kill_process(Pid0),
-    syn_test_suite_helper:kill_process(Pid0Changed),
-    syn_test_suite_helper:kill_process(Pid1),
-    syn_test_suite_helper:kill_process(Pid2).
+    false = rpc:call(SlaveNode2, syn, member, [OtherPid, GroupName]).

+ 9 - 40
test/syn_registry_SUITE.erl

@@ -256,9 +256,7 @@ single_node_register_and_unregister(_Config) ->
     {error, undefined} = syn:unregister(<<"my proc 2">>),
     %% retrieve
     undefined = syn:whereis(<<"my proc">>),
-    undefined = syn:whereis(<<"my proc 2">>),
-    %% kill process
-    syn_test_suite_helper:kill_process(Pid).
+    undefined = syn:whereis(<<"my proc 2">>).
 
 single_node_registration_errors(_Config) ->
     %% start
@@ -424,9 +422,7 @@ two_nodes_register_monitor_and_unregister(Config) ->
     undefined = syn:whereis(<<"remote proc reg_remote">>),
     undefined = rpc:call(SlaveNode, syn, whereis, [<<"local proc">>]),
     undefined = rpc:call(SlaveNode, syn, whereis, [<<"remote proc">>]),
-    undefined = rpc:call(SlaveNode, syn, whereis, [<<"remote proc reg_remote">>]),
-    %% kill proc
-    syn_test_suite_helper:kill_process(RemotePid).
+    undefined = rpc:call(SlaveNode, syn, whereis, [<<"remote proc reg_remote">>]).
 
 two_nodes_registry_count(Config) ->
     %% get slave
@@ -457,10 +453,7 @@ two_nodes_registry_count(Config) ->
     %% count
     0 = syn:registry_count(),
     0 = syn:registry_count(node()),
-    0 = syn:registry_count(SlaveNode),
-    %% kill proc
-    syn_test_suite_helper:kill_process(RemotePid),
-    syn_test_suite_helper:kill_process(PidUnregistered).
+    0 = syn:registry_count(SlaveNode).
 
 two_nodes_registration_race_condition_conflict_resolution(Config) ->
     ConflictingName = "COMMON",
@@ -496,10 +489,7 @@ two_nodes_registration_race_condition_conflict_resolution(Config) ->
             true = rpc:call(SlaveNode, erlang, is_process_alive, [Pid1]);
         _ ->
             ok = no_process_is_registered_with_conflicting_name
-    end,
-    %% kill processes
-    syn_test_suite_helper:kill_process(Pid0),
-    syn_test_suite_helper:kill_process(Pid1).
+    end.
 
 three_nodes_partial_netsplit_consistency(Config) ->
     %% get slaves
@@ -586,11 +576,7 @@ three_nodes_partial_netsplit_consistency(Config) ->
     Pid0 = rpc:call(SlaveNode2, syn, whereis, [<<"proc0">>]),
     undefined = rpc:call(SlaveNode2, syn, whereis, [<<"proc0-changed">>]),
     Pid1 = rpc:call(SlaveNode2, syn, whereis, [<<"proc1">>]),
-    Pid2 = rpc:call(SlaveNode2, syn, whereis, [<<"proc2">>]),
-    %% kill processes
-    syn_test_suite_helper:kill_process(Pid0),
-    syn_test_suite_helper:kill_process(Pid1),
-    syn_test_suite_helper:kill_process(Pid2).
+    Pid2 = rpc:call(SlaveNode2, syn, whereis, [<<"proc2">>]).
 
 three_nodes_full_netsplit_consistency(Config) ->
     %% get slaves
@@ -691,12 +677,7 @@ three_nodes_full_netsplit_consistency(Config) ->
     Pid0 = rpc:call(SlaveNode2, syn, whereis, [<<"proc0">>]),
     undefined = rpc:call(SlaveNode2, syn, whereis, [<<"proc0-changed">>]),
     Pid1 = rpc:call(SlaveNode2, syn, whereis, [<<"proc1">>]),
-    Pid2 = rpc:call(SlaveNode2, syn, whereis, [<<"proc2">>]),
-    %% kill processes
-    syn_test_suite_helper:kill_process(Pid0),
-    syn_test_suite_helper:kill_process(Pid0Changed),
-    syn_test_suite_helper:kill_process(Pid1),
-    syn_test_suite_helper:kill_process(Pid2).
+    Pid2 = rpc:call(SlaveNode2, syn, whereis, [<<"proc2">>]).
 
 three_nodes_start_syn_before_connecting_cluster_with_conflict(Config) ->
     ConflictingName = "COMMON",
@@ -762,11 +743,7 @@ three_nodes_start_syn_before_connecting_cluster_with_conflict(Config) ->
             true = rpc:call(SlaveNode2, erlang, is_process_alive, [Pid2]);
         _ ->
             ok = no_process_is_registered_with_conflicting_name
-    end,
-    %% kill processes
-    syn_test_suite_helper:kill_process(Pid0),
-    syn_test_suite_helper:kill_process(Pid1),
-    syn_test_suite_helper:kill_process(Pid2).
+    end.
 
 three_nodes_start_syn_before_connecting_cluster_with_custom_conflict_resolution(Config) ->
     ConflictingName = "COMMON",
@@ -818,11 +795,7 @@ three_nodes_start_syn_before_connecting_cluster_with_custom_conflict_resolution(
     %% check that other processes are still alive because we didn't kill them
     true = is_process_alive(Pid0),
     true = rpc:call(SlaveNode1, erlang, is_process_alive, [Pid1]),
-    true = rpc:call(SlaveNode2, erlang, is_process_alive, [Pid2]),
-    %% kill processes
-    syn_test_suite_helper:kill_process(Pid0),
-    syn_test_suite_helper:kill_process(Pid1),
-    syn_test_suite_helper:kill_process(Pid2).
+    true = rpc:call(SlaveNode2, erlang, is_process_alive, [Pid2]).
 
 three_nodes_registration_race_condition_custom_conflict_resolution(Config) ->
     ConflictingName = "COMMON",
@@ -859,11 +832,7 @@ three_nodes_registration_race_condition_custom_conflict_resolution(Config) ->
     %% check that other processes are still alive because we didn't kill them
     true = is_process_alive(Pid0),
     true = rpc:call(SlaveNode1, erlang, is_process_alive, [Pid1]),
-    true = rpc:call(SlaveNode2, erlang, is_process_alive, [Pid2]),
-    %% kill processes
-    syn_test_suite_helper:kill_process(Pid0),
-    syn_test_suite_helper:kill_process(Pid1),
-    syn_test_suite_helper:kill_process(Pid2).
+    true = rpc:call(SlaveNode2, erlang, is_process_alive, [Pid2]).
 
 %% ===================================================================
 %% Internal