1212
1313-include_lib (" amqp10_common/include/amqp10_framing.hrl" ).
1414
15- -include (" src/amqp10_client.hrl" ).
16-
1715-compile ([export_all , nowarn_export_all ]).
1816
17+ -define (TIMEOUT , 30000 ).
18+
1919suite () ->
2020 [{timetrap , {minutes , 4 }}].
2121
@@ -184,7 +184,7 @@ open_close_connection(Config) ->
184184 {ok , Connection2 } = amqp10_client :open_connection (OpnConf ),
185185 receive
186186 {amqp10_event , {connection , Connection2 , opened }} -> ok
187- after 5000 -> exit (connection_timeout )
187+ after ? TIMEOUT -> exit (connection_timeout )
188188 end ,
189189 ok = amqp10_client :close_connection (Connection2 ),
190190 ok = amqp10_client :close_connection (Connection ).
@@ -201,7 +201,7 @@ open_connection_plain_sasl(Config) ->
201201 {ok , Connection } = amqp10_client :open_connection (OpnConf ),
202202 receive
203203 {amqp10_event , {connection , Connection , opened }} -> ok
204- after 5000 -> exit (connection_timeout )
204+ after ? TIMEOUT -> exit (connection_timeout )
205205 end ,
206206 ok = amqp10_client :close_connection (Connection ).
207207
@@ -225,7 +225,7 @@ open_connection_plain_sasl_parse_uri(Config) ->
225225 {ok , Connection } = amqp10_client :open_connection (OpnConf ),
226226 receive
227227 {amqp10_event , {connection , Connection , opened }} -> ok
228- after 5000 -> exit (connection_timeout )
228+ after ? TIMEOUT -> exit (connection_timeout )
229229 end ,
230230 ok = amqp10_client :close_connection (Connection ).
231231
@@ -245,7 +245,7 @@ open_connection_plain_sasl_failure(Config) ->
245245 % some implementation may simply close the tcp_connection
246246 {amqp10_event , {connection , Connection , {closed , shutdown }}} -> ok
247247
248- after 5000 ->
248+ after ? TIMEOUT ->
249249 ct :pal (" Connection process is alive? = ~tp~n " ,
250250 [erlang :is_process_alive (Connection )]),
251251 exit (connection_timeout )
@@ -469,27 +469,27 @@ notify_with_performative(Config) ->
469469
470470 {ok , Connection } = amqp10_client :open_connection (OpenConf ),
471471 receive {amqp10_event , {connection , Connection , {opened , # 'v1_0.open' {}}}} -> ok
472- after 5000 -> ct :fail ({missing_event , ? LINE })
472+ after ? TIMEOUT -> ct :fail ({missing_event , ? LINE })
473473 end ,
474474
475475 {ok , Session1 } = amqp10_client :begin_session (Connection ),
476476 receive {amqp10_event , {session , Session1 , {begun , # 'v1_0.begin' {}}}} -> ok
477- after 5000 -> ct :fail ({missing_event , ? LINE })
477+ after ? TIMEOUT -> ct :fail ({missing_event , ? LINE })
478478 end ,
479479
480480 {ok , Sender1 } = amqp10_client :attach_sender_link (Session1 , <<" sender 1" >>, <<" /exchanges/amq.fanout" >>),
481481 receive {amqp10_event , {link , Sender1 , {attached , # 'v1_0.attach' {}}}} -> ok
482- after 5000 -> ct :fail ({missing_event , ? LINE })
482+ after ? TIMEOUT -> ct :fail ({missing_event , ? LINE })
483483 end ,
484484
485485 ok = amqp10_client :detach_link (Sender1 ),
486486 receive {amqp10_event , {link , Sender1 , {detached , # 'v1_0.detach' {}}}} -> ok
487- after 5000 -> ct :fail ({missing_event , ? LINE })
487+ after ? TIMEOUT -> ct :fail ({missing_event , ? LINE })
488488 end ,
489489
490490 ok = amqp10_client :end_session (Session1 ),
491491 receive {amqp10_event , {session , Session1 , {ended , # 'v1_0.end' {}}}} -> ok
492- after 5000 -> ct :fail ({missing_event , ? LINE })
492+ after ? TIMEOUT -> ct :fail ({missing_event , ? LINE })
493493 end ,
494494
495495 % % Test that the amqp10_client:*_sync functions work.
@@ -501,7 +501,7 @@ notify_with_performative(Config) ->
501501
502502 ok = amqp10_client :close_connection (Connection ),
503503 receive {amqp10_event , {connection , Connection , {closed , # 'v1_0.close' {}}}} -> ok
504- after 5000 -> ct :fail ({missing_event , ? LINE })
504+ after ? TIMEOUT -> ct :fail ({missing_event , ? LINE })
505505 end .
506506
507507% a message is sent before the link attach is guaranteed to
@@ -600,13 +600,13 @@ subscribe(Config) ->
600600 [begin
601601 receive {amqp10_msg , Receiver , Msg } ->
602602 ok = amqp10_client :accept_msg (Receiver , Msg )
603- after 2000 -> ct :fail (timeout )
603+ after ? TIMEOUT -> ct :fail (timeout )
604604 end
605605 end || _ <- lists :seq (1 , 10 )],
606606 ok = assert_no_message (Receiver ),
607607
608608 receive {amqp10_event , {link , Receiver , credit_exhausted }} -> ok
609- after 5000 -> flush (),
609+ after ? TIMEOUT -> flush (),
610610 exit (credit_exhausted_assert )
611611 end ,
612612
@@ -854,7 +854,7 @@ multi_transfer_without_delivery_id(Config) ->
854854 receive
855855 {amqp10_msg , Receiver , _InMsg } ->
856856 ok
857- after 2000 ->
857+ after ? TIMEOUT ->
858858 exit (delivery_timeout )
859859 end ,
860860
@@ -909,7 +909,7 @@ incoming_heartbeat(Config) ->
909909 {closed , _ }}}
910910 when Connection0 =:= Connection ->
911911 ok
912- after 5000 ->
912+ after ? TIMEOUT ->
913913 exit (incoming_heartbeat_assert )
914914 end ,
915915 demonitor (MockRef ).
@@ -926,7 +926,7 @@ await_link(Who, What, Err) ->
926926 {amqp10_event , {link , Who0 , {detached , Why }}}
927927 when Who0 =:= Who ->
928928 ct :fail (Why )
929- after 5000 ->
929+ after ? TIMEOUT ->
930930 flush (),
931931 ct :fail (Err )
932932 end .
@@ -943,7 +943,7 @@ await_disposition(DeliveryTag) ->
943943 receive
944944 {amqp10_disposition , {accepted , DeliveryTag0 }}
945945 when DeliveryTag0 =:= DeliveryTag -> ok
946- after 3000 ->
946+ after ? TIMEOUT ->
947947 flush (),
948948 ct :fail (dispostion_timeout )
949949 end .
@@ -955,7 +955,7 @@ count_received_messages0(Receiver, Count) ->
955955 receive
956956 {amqp10_msg , Receiver , _Msg } ->
957957 count_received_messages0 (Receiver , Count + 1 )
958- after 500 ->
958+ after 5000 ->
959959 Count
960960 end .
961961
@@ -968,7 +968,7 @@ receive_messages0(Receiver, N, Acc) ->
968968 receive
969969 {amqp10_msg , Receiver , Msg } ->
970970 receive_messages0 (Receiver , N - 1 , [Msg | Acc ])
971- after 5000 ->
971+ after ? TIMEOUT ->
972972 LastReceivedMsg = case Acc of
973973 [] -> none ;
974974 [M | _ ] -> M
0 commit comments