@@ -322,6 +322,143 @@ fn test_unit_queue_info_policy_matching_case2() {
322
322
}"# ;
323
323
let cq = serde_json:: from_str :: < QueueInfo > ( input) . unwrap ( ) ;
324
324
325
+ // names do not match
326
+ assert_eq ! ( false , cq. does_match( & p) ) ;
327
+ assert_eq ! ( false , p. does_match_object( & cq) ) ;
328
+ }
329
+
330
+ #[ test]
331
+ fn test_unit_queue_info_policy_matching_case3 ( ) {
332
+ let mut m = Map :: new ( ) ;
333
+ m. insert ( "max-length" . to_owned ( ) , json ! ( 100000 ) ) ;
334
+ let defs = PolicyDefinition ( Some ( m) ) ;
335
+ let p = Policy {
336
+ name : "policy.2" . to_owned ( ) ,
337
+ vhost : "/" . to_owned ( ) ,
338
+ pattern : r"^events\." . to_owned ( ) ,
339
+ // won't match a classic queue
340
+ apply_to : PolicyTarget :: QuorumQueues ,
341
+ priority : 11 ,
342
+ definition : defs. clone ( ) ,
343
+ } ;
344
+
345
+ let input = r#"{
346
+ "arguments": {
347
+ "x-queue-type": "classic"
348
+ },
349
+ "auto_delete": false,
350
+ "consumer_capacity": 0,
351
+ "consumer_utilisation": 0,
352
+ "consumers": 0,
353
+ "durable": true,
354
+ "effective_policy_definition": {},
355
+ "exclusive": false,
356
+ "memory": 21968,
357
+ "message_bytes": 21,
358
+ "message_bytes_paged_out": 0,
359
+ "message_bytes_persistent": 21,
360
+ "message_bytes_ram": 3,
361
+ "message_bytes_ready": 21,
362
+ "message_bytes_unacknowledged": 0,
363
+ "messages": 7,
364
+ "messages_details": {
365
+ "rate": 0.0
366
+ },
367
+ "messages_paged_out": 0,
368
+ "messages_persistent": 7,
369
+ "messages_ram": 1,
370
+ "messages_ready": 7,
371
+ "messages_ready_details": {
372
+ "rate": 0.0
373
+ },
374
+ "messages_ready_ram": 1,
375
+ "messages_unacknowledged": 0,
376
+ "messages_unacknowledged_details": {
377
+ "rate": 0.0
378
+ },
379
+ "messages_unacknowledged_ram": 0,
380
+ "name": "events.signin.attempts",
381
+ "node": "rabbit@hostname",
382
+ "reductions": 6939,
383
+ "reductions_details": {
384
+ "rate": 0.0
385
+ },
386
+ "state": "running",
387
+ "storage_version": 2,
388
+ "type": "classic",
389
+ "vhost": "/"
390
+ }"# ;
391
+ let cq = serde_json:: from_str :: < QueueInfo > ( input) . unwrap ( ) ;
392
+
393
+ // policy target does not match
394
+ assert_eq ! ( false , cq. does_match( & p) ) ;
395
+ assert_eq ! ( false , p. does_match_object( & cq) ) ;
396
+ }
397
+
398
+ #[ test]
399
+ fn test_unit_queue_info_policy_matching_case4 ( ) {
400
+ let mut m = Map :: new ( ) ;
401
+ m. insert ( "max-length" . to_owned ( ) , json ! ( 100000 ) ) ;
402
+ let defs = PolicyDefinition ( Some ( m) ) ;
403
+ let p = Policy {
404
+ name : "policy.3" . to_owned ( ) ,
405
+ vhost : "vh-1" . to_owned ( ) ,
406
+ pattern : r"^events\." . to_owned ( ) ,
407
+ // won't match a classic queue
408
+ apply_to : PolicyTarget :: QuorumQueues ,
409
+ priority : 11 ,
410
+ definition : defs. clone ( ) ,
411
+ } ;
412
+
413
+ let input = r#"{
414
+ "arguments": {
415
+ "x-queue-type": "quorum"
416
+ },
417
+ "auto_delete": false,
418
+ "consumer_capacity": 0,
419
+ "consumer_utilisation": 0,
420
+ "consumers": 0,
421
+ "durable": true,
422
+ "effective_policy_definition": {},
423
+ "exclusive": false,
424
+ "memory": 21968,
425
+ "message_bytes": 21,
426
+ "message_bytes_paged_out": 0,
427
+ "message_bytes_persistent": 21,
428
+ "message_bytes_ram": 3,
429
+ "message_bytes_ready": 21,
430
+ "message_bytes_unacknowledged": 0,
431
+ "messages": 7,
432
+ "messages_details": {
433
+ "rate": 0.0
434
+ },
435
+ "messages_paged_out": 0,
436
+ "messages_persistent": 7,
437
+ "messages_ram": 1,
438
+ "messages_ready": 7,
439
+ "messages_ready_details": {
440
+ "rate": 0.0
441
+ },
442
+ "messages_ready_ram": 1,
443
+ "messages_unacknowledged": 0,
444
+ "messages_unacknowledged_details": {
445
+ "rate": 0.0
446
+ },
447
+ "messages_unacknowledged_ram": 0,
448
+ "name": "events.signin.attempts",
449
+ "node": "rabbit@hostname",
450
+ "reductions": 6939,
451
+ "reductions_details": {
452
+ "rate": 0.0
453
+ },
454
+ "state": "running",
455
+ "storage_version": 2,
456
+ "type": "quorum",
457
+ "vhost": "vh-abc-126387"
458
+ }"# ;
459
+ let cq = serde_json:: from_str :: < QueueInfo > ( input) . unwrap ( ) ;
460
+
461
+ // virtual hosts do not match
325
462
assert_eq ! ( false , cq. does_match( & p) ) ;
326
463
assert_eq ! ( false , p. does_match_object( & cq) ) ;
327
464
}
0 commit comments