@@ -51,6 +51,7 @@ all_tests() ->
51
51
aux_command ,
52
52
aux_command_v2 ,
53
53
aux_command_v1_and_v2 ,
54
+ aux_command_timeout ,
54
55
aux_monitor_effect ,
55
56
aux_and_machine_monitor_same_process ,
56
57
aux_and_machine_monitor_same_node ,
@@ -810,6 +811,37 @@ aux_command_v1_and_v2(Config) ->
810
811
ra :delete_cluster (Cluster ),
811
812
ok .
812
813
814
+ aux_command_timeout (Config ) ->
815
+ ClusterName = ? config (cluster_name , Config ),
816
+ ServerId1 = ? config (server_id , Config ),
817
+ Cluster = [ServerId1 ,
818
+ ? config (server_id2 , Config ),
819
+ ? config (server_id3 , Config )],
820
+ Mod = ? config (modname , Config ),
821
+ meck :new (Mod , [non_strict ]),
822
+ meck :expect (Mod , init , fun (_ ) -> [] end ),
823
+ meck :expect (Mod , init_aux , fun (_ ) -> undefined end ),
824
+ meck :expect (Mod , apply ,
825
+ fun
826
+ (_ , Cmd , State ) ->
827
+ ct :pal (" handling ~p " , [Cmd ]),
828
+ % % handle all
829
+ {State , ok }
830
+ end ),
831
+ meck :expect (Mod , handle_aux ,
832
+ fun
833
+ (_RaftState , {call , _From }, {sleep , Sleep }, AuxState , Opaque ) ->
834
+ timer :sleep (Sleep ),
835
+ {reply , ok , AuxState , Opaque };
836
+ (_RaftState , cast , _Msg , AuxState , Opaque ) ->
837
+ {no_reply , AuxState , Opaque }
838
+ end ),
839
+ ok = start_cluster (ClusterName , {module , Mod , #{}}, Cluster ),
840
+ ? assertEqual (ok , ra :aux_command (ServerId1 , {sleep , 100 }, 500 )),
841
+ ? assertExit ({timeout , _ }, ra :aux_command (ServerId1 , {sleep , 1000 }, 500 )),
842
+ ra :delete_cluster (Cluster ),
843
+ ok .
844
+
813
845
aux_eval (Config ) ->
814
846
% % aux handle is automatically passed an eval command after new entries
815
847
% % have been applied
0 commit comments