@@ -28,6 +28,7 @@ groups() ->
2828 single_node_vhost_deletion_forces_connection_closure ,
2929 vhost_failure_forces_connection_closure ,
3030 vhost_creation_idempotency ,
31+ vhost_update_idempotency ,
3132 parse_tags
3233 ],
3334 ClusterSize2Tests = [
@@ -321,6 +322,46 @@ vhost_creation_idempotency(Config) ->
321322 rabbit_ct_broker_helpers :delete_vhost (Config , VHost )
322323 end .
323324
325+ vhost_update_idempotency (Config ) ->
326+ VHost = <<" update-idempotency-test" >>,
327+ ActingUser = <<" acting-user" >>,
328+ try
329+ % load the dummy event handler on the node
330+ ok = rabbit_ct_broker_helpers :rpc (Config , 0 , test_rabbit_event_handler , okay , []),
331+
332+ ok = rabbit_ct_broker_helpers :rpc (Config , 0 , gen_event , add_handler ,
333+ [rabbit_event , test_rabbit_event_handler , []]),
334+
335+ ? assertEqual (ok , rabbit_ct_broker_helpers :add_vhost (Config , VHost )),
336+
337+ ? assertMatch ({vhost ,VHost , _ , #{tags := [private ,replicate ]}},
338+ rabbit_ct_broker_helpers :rpc (Config , 0 ,
339+ rabbit_vhost , update_tags ,
340+ [VHost , [private , replicate ], ActingUser ])),
341+ ? assertMatch ({vhost ,VHost , _ , #{tags := [private ,replicate ]}},
342+ rabbit_ct_broker_helpers :rpc (Config , 0 ,
343+ rabbit_vhost , update_tags ,
344+ [VHost , [replicate , private ], ActingUser ])),
345+
346+ Events = rabbit_ct_broker_helpers :rpc (Config , 0 ,
347+ gen_event , call ,
348+ [rabbit_event , test_rabbit_event_handler , events , 100 ]),
349+ ct :pal (? LOW_IMPORTANCE , " Events: ~p " , [lists :reverse (Events )]),
350+ TagsSetEvents = lists :filter (fun
351+ (# event {type = vhost_tags_set }) -> true ;
352+ (_ ) -> false
353+ end , Events ),
354+ ? assertMatch ([# event {type = vhost_tags_set ,
355+ props = [{name , VHost },
356+ {tags , [private , replicate ]},
357+ {user_who_performed_action , ActingUser }]}],
358+ TagsSetEvents )
359+ after
360+ rabbit_ct_broker_helpers :rpc (Config , 0 ,
361+ gen_event , delete_handler , [rabbit_event , test_rabbit_event_handler , []]),
362+ rabbit_ct_broker_helpers :delete_vhost (Config , VHost )
363+ end .
364+
324365vhost_is_created_with_default_limits (Config ) ->
325366 VHost = <<" vhost1" >>,
326367 Limits = [{<<" max-connections" >>, 10 }, {<<" max-queues" >>, 1 }],
0 commit comments