@@ -29,8 +29,7 @@ all_tests() ->
2929 amqpl_compat ,
3030 amqpl_table_x_header ,
3131 amqpl_table_x_header_array_of_tbls ,
32- amqpl_death_v1_records ,
33- amqpl_death_v2_records ,
32+ amqpl_death_records ,
3433 is_death_cycle ,
3534 amqpl_amqp_bin_amqpl ,
3635 amqpl_cc_amqp_bin_amqpl ,
@@ -198,50 +197,39 @@ amqpl_table_x_header_array_of_tbls(_Config) ->
198197 ]},
199198 mc :x_header (<<" x-fruit" >>, Msg )).
200199
201- amqpl_death_v1_records (_Config ) ->
202- ok = amqpl_death_records (#{? FF_MC_DEATHS_V2 => false }).
203-
204- amqpl_death_v2_records (_Config ) ->
205- ok = amqpl_death_records (#{? FF_MC_DEATHS_V2 => true }).
206-
207- amqpl_death_records (Env ) ->
200+ amqpl_death_records (_Config ) ->
208201 Content = # content {class_id = 60 ,
209202 properties = # 'P_basic' {headers = []},
210203 payload_fragments_rev = [<<" data" >>]},
211204 Msg0 = mc :prepare (store , mc :init (mc_amqpl , Content , annotations ())),
212205
213- Msg1 = mc :record_death (rejected , <<" q1 " >>, Msg0 , Env ),
214- ? assertEqual ([<<" q1 " >>], mc :death_queue_names (Msg1 )),
215- ? assertEqual (false , mc :is_death_cycle (<<" q1 " >>, Msg1 )),
206+ Msg1 = mc :record_death (rejected , <<" q " >>, Msg0 ),
207+ ? assertEqual ([<<" q " >>], mc :death_queue_names (Msg1 )),
208+ ? assertEqual (false , mc :is_death_cycle (<<" q " >>, Msg1 )),
216209
217210 # content {properties = # 'P_basic' {headers = H1 }} = mc :protocol_state (Msg1 ),
218211 ? assertMatch ({_ , array , [_ ]}, header (<<" x-death" >>, H1 )),
219- ? assertMatch ({_ , longstr , <<" q1 " >>}, header (<<" x-first-death-queue" >>, H1 )),
212+ ? assertMatch ({_ , longstr , <<" q " >>}, header (<<" x-first-death-queue" >>, H1 )),
220213 ? assertMatch ({_ , longstr , <<" exch" >>}, header (<<" x-first-death-exchange" >>, H1 )),
221214 ? assertMatch ({_ , longstr , <<" rejected" >>}, header (<<" x-first-death-reason" >>, H1 )),
222- ? assertMatch ({_ , longstr , <<" q1 " >>}, header (<<" x-last-death-queue" >>, H1 )),
215+ ? assertMatch ({_ , longstr , <<" q " >>}, header (<<" x-last-death-queue" >>, H1 )),
223216 ? assertMatch ({_ , longstr , <<" exch" >>}, header (<<" x-last-death-exchange" >>, H1 )),
224217 ? assertMatch ({_ , longstr , <<" rejected" >>}, header (<<" x-last-death-reason" >>, H1 )),
225218 {_ , array , [{table , T1 }]} = header (<<" x-death" >>, H1 ),
226219 ? assertMatch ({_ , long , 1 }, header (<<" count" >>, T1 )),
227220 ? assertMatch ({_ , longstr , <<" rejected" >>}, header (<<" reason" >>, T1 )),
228- ? assertMatch ({_ , longstr , <<" q1 " >>}, header (<<" queue" >>, T1 )),
221+ ? assertMatch ({_ , longstr , <<" q " >>}, header (<<" queue" >>, T1 )),
229222 ? assertMatch ({_ , longstr , <<" exch" >>}, header (<<" exchange" >>, T1 )),
230223 ? assertMatch ({_ , timestamp , _ }, header (<<" time" >>, T1 )),
231224 ? assertMatch ({_ , array , [{longstr , <<" apple" >>}]}, header (<<" routing-keys" >>, T1 )),
232225
233-
234- % % second dead letter, e.g. an expired reason returning to source queue
235-
236- % % record_death uses a timestamp for death record ordering, ensure
237- % % it is definitely higher than the last timestamp taken
238- timer :sleep (2 ),
239- Msg2 = mc :record_death (expired , <<" dl" >>, Msg1 , Env ),
240-
226+ % % 2nd dead letter, e.g. an expired reason
227+ Msg2 = mc :record_death (expired , <<" dead letter queue" >>, Msg1 ),
241228 # content {properties = # 'P_basic' {headers = H2 }} = mc :protocol_state (Msg2 ),
229+ % % We expect deaths to be ordered by recency
242230 {_ , array , [{table , T2a }, {table , T2b }]} = header (<<" x-death" >>, H2 ),
243- ? assertMatch ({_ , longstr , <<" dl " >>}, header (<<" queue" >>, T2a )),
244- ? assertMatch ({_ , longstr , <<" q1 " >>}, header (<<" queue" >>, T2b )),
231+ ? assertMatch ({_ , longstr , <<" dead letter queue " >>}, header (<<" queue" >>, T2a )),
232+ ? assertMatch ({_ , longstr , <<" q " >>}, header (<<" queue" >>, T2b )),
245233 ok .
246234
247235is_death_cycle (_Config ) ->
@@ -254,29 +242,29 @@ is_death_cycle(_Config) ->
254242 % % Q1 --rejected--> Q2 --expired--> Q3 --expired-->
255243 % % Q1 --rejected--> Q2 --expired--> Q3
256244
257- Msg1 = mc :record_death (rejected , <<" q1" >>, Msg0 , #{} ),
245+ Msg1 = mc :record_death (rejected , <<" q1" >>, Msg0 ),
258246 ? assertNot (mc :is_death_cycle (<<" q1" >>, Msg1 ),
259247 " A queue that dead letters to itself due to rejected is not considered a cycle." ),
260248 ? assertNot (mc :is_death_cycle (<<" q2" >>, Msg1 )),
261249 ? assertNot (mc :is_death_cycle (<<" q3" >>, Msg1 )),
262250
263- Msg2 = mc :record_death (expired , <<" q2" >>, Msg1 , #{} ),
251+ Msg2 = mc :record_death (expired , <<" q2" >>, Msg1 ),
264252 ? assertNot (mc :is_death_cycle (<<" q1" >>, Msg2 )),
265253 ? assert (mc :is_death_cycle (<<" q2" >>, Msg2 ),
266254 " A queue that dead letters to itself due to expired is considered a cycle." ),
267255 ? assertNot (mc :is_death_cycle (<<" q3" >>, Msg2 )),
268256
269- Msg3 = mc :record_death (expired , <<" q3" >>, Msg2 , #{} ),
257+ Msg3 = mc :record_death (expired , <<" q3" >>, Msg2 ),
270258 ? assertNot (mc :is_death_cycle (<<" q1" >>, Msg3 )),
271259 ? assert (mc :is_death_cycle (<<" q2" >>, Msg3 )),
272260 ? assert (mc :is_death_cycle (<<" q3" >>, Msg3 )),
273261
274- Msg4 = mc :record_death (rejected , <<" q1" >>, Msg3 , #{} ),
262+ Msg4 = mc :record_death (rejected , <<" q1" >>, Msg3 ),
275263 ? assertNot (mc :is_death_cycle (<<" q1" >>, Msg4 )),
276264 ? assertNot (mc :is_death_cycle (<<" q2" >>, Msg4 )),
277265 ? assertNot (mc :is_death_cycle (<<" q3" >>, Msg4 )),
278266
279- Msg5 = mc :record_death (expired , <<" q2" >>, Msg4 , #{} ),
267+ Msg5 = mc :record_death (expired , <<" q2" >>, Msg4 ),
280268 ? assertNot (mc :is_death_cycle (<<" q1" >>, Msg5 )),
281269 ? assert (mc :is_death_cycle (<<" q2" >>, Msg5 )),
282270 ? assertNot (mc :is_death_cycle (<<" q3" >>, Msg5 )),
0 commit comments