@@ -1226,27 +1226,29 @@ events(Config) ->
1226
1226
end ,
1227
1227
ok = close_connection_sync (Connection ),
1228
1228
1229
- [ E0 , E1 , E2 ] = event_recorder :get_events (Config ),
1229
+ Events = event_recorder :get_events (Config ),
1230
1230
ok = event_recorder :stop (Config ),
1231
+ ct :pal (" Recorded events: ~p " , [Events ]),
1231
1232
1232
- assert_event_type (user_authentication_success , E0 ),
1233
1233
Protocol = {protocol , {1 , 0 }},
1234
- assert_event_prop ( [{name , <<" guest" >>},
1234
+ AuthProps = [{name , <<" guest" >>},
1235
1235
{auth_mechanism , <<" PLAIN" >>},
1236
1236
{ssl , false },
1237
1237
Protocol ],
1238
- E0 ),
1238
+ ? assertMatch (
1239
+ {value , _ },
1240
+ find_event (user_authentication_success , AuthProps , Events )),
1239
1241
1240
- assert_event_type (connection_created , E1 ),
1241
1242
Node = get_node_config (Config , 0 , nodename ),
1242
- assert_event_prop (
1243
- [Protocol ,
1244
- {node , Node },
1245
- {vhost , <<" /" >>},
1246
- {user , <<" guest" >>},
1247
- {type , network }],
1248
- E1 ),
1249
- Props = E1 # event .props ,
1243
+ ConnectionCreatedProps = [Protocol ,
1244
+ {node , Node },
1245
+ {vhost , <<" /" >>},
1246
+ {user , <<" guest" >>},
1247
+ {type , network }],
1248
+ {value , ConnectionCreatedEvent } = find_event (
1249
+ connection_created ,
1250
+ ConnectionCreatedProps , Events ),
1251
+ Props = ConnectionCreatedEvent # event .props ,
1250
1252
Name = proplists :lookup (name , Props ),
1251
1253
Pid = proplists :lookup (pid , Props ),
1252
1254
ClientProperties = {client_properties , List } = proplists :lookup (client_properties , Props ),
@@ -1257,13 +1259,14 @@ events(Config) ->
1257
1259
{<<" ignore-maintenance" >>, bool , true },
1258
1260
List )),
1259
1261
1260
- assert_event_type (connection_closed , E2 ),
1261
- assert_event_prop (
1262
- [{node , Node },
1263
- Name ,
1264
- Pid ,
1265
- ClientProperties ],
1266
- E2 ).
1262
+ ConnectionClosedProps = [{node , Node },
1263
+ Name ,
1264
+ Pid ,
1265
+ ClientProperties ],
1266
+ ? assertMatch (
1267
+ {value , _ },
1268
+ find_event (connection_closed , ConnectionClosedProps , Events )),
1269
+ ok .
1267
1270
1268
1271
sync_get_unsettled_classic_queue (Config ) ->
1269
1272
sync_get_unsettled (<<" classic" >>, Config ).
@@ -4193,3 +4196,19 @@ has_local_member(QName) ->
4193
4196
{error , _ } ->
4194
4197
false
4195
4198
end .
4199
+
4200
+ - spec find_event (Type , Props , Events ) -> Ret when
4201
+ Type :: atom (),
4202
+ Props :: proplists :proplist (),
4203
+ Events :: [# event {}],
4204
+ Ret :: {value , # event {}} | false .
4205
+
4206
+ find_event (Type , Props , Events ) when is_list (Props ), is_list (Events ) ->
4207
+ lists :search (
4208
+ fun (# event {type = EventType , props = EventProps }) ->
4209
+ Type =:= EventType andalso
4210
+ lists :all (
4211
+ fun ({Key , _Value }) ->
4212
+ lists :keymember (Key , 1 , EventProps )
4213
+ end , Props )
4214
+ end , Events ).
0 commit comments