@@ -244,7 +244,6 @@ public async Task RecoveryTopologyShouldRecoverTheTempQueues()
244
244
Assert . Null ( _connection ) ;
245
245
Assert . Null ( _management ) ;
246
246
247
- string queueName = $ "temp-queue-should-recover-{ true } ";
248
247
IConnection connection = await AmqpConnection . CreateAsync (
249
248
ConnectionSettingBuilder . Create ( )
250
249
. RecoveryConfiguration ( RecoveryConfiguration . Create ( )
@@ -263,18 +262,18 @@ public async Task RecoveryTopologyShouldRecoverTheTempQueues()
263
262
} ;
264
263
IManagement management = connection . Management ( ) ;
265
264
ITopologyListener topologyListener = ( ( IManagementTopology ) management ) . TopologyListener ( ) ;
266
- await management . Queue ( ) . Name ( queueName ) . AutoDelete ( true ) . Exclusive ( true ) . DeclareAsync ( ) ;
265
+ await management . Queue ( ) . Name ( _queueName ) . AutoDelete ( true ) . Exclusive ( true ) . DeclareAsync ( ) ;
267
266
Assert . Equal ( 1 , topologyListener . QueueCount ( ) ) ;
268
267
269
268
await SystemUtils . WaitUntilConnectionIsKilled ( _containerId ) ;
270
269
await twoRecoveryEventsSeenTcs . Task . WaitAsync ( TimeSpan . FromSeconds ( 10 ) ) ;
271
270
await SystemUtils . WaitUntilFuncAsync ( ( ) => recoveryEvents == 2 ) ;
272
271
273
- await SystemUtils . WaitUntilQueueExistsAsync ( queueName ) ;
272
+ await SystemUtils . WaitUntilQueueExistsAsync ( _queueName ) ;
274
273
275
274
await connection . CloseAsync ( ) ;
276
275
277
- await SystemUtils . WaitUntilQueueDeletedAsync ( queueName ) ;
276
+ await SystemUtils . WaitUntilQueueDeletedAsync ( _queueName ) ;
278
277
279
278
Assert . Equal ( 0 , topologyListener . QueueCount ( ) ) ;
280
279
}
@@ -292,7 +291,6 @@ public async Task RecoveryTopologyShouldNotRecoverTheTempQueues()
292
291
Assert . Null ( _connection ) ;
293
292
Assert . Null ( _management ) ;
294
293
295
- string queueName = $ "temp-queue-should-recover-{ false } ";
296
294
IConnection connection = await AmqpConnection . CreateAsync (
297
295
ConnectionSettingBuilder . Create ( )
298
296
. RecoveryConfiguration ( RecoveryConfiguration . Create ( )
@@ -311,13 +309,13 @@ public async Task RecoveryTopologyShouldNotRecoverTheTempQueues()
311
309
} ;
312
310
IManagement management = connection . Management ( ) ;
313
311
ITopologyListener topologyListener = ( ( IManagementTopology ) management ) . TopologyListener ( ) ;
314
- await management . Queue ( ) . Name ( queueName ) . AutoDelete ( true ) . Exclusive ( true ) . DeclareAsync ( ) ;
312
+ await management . Queue ( ) . Name ( _queueName ) . AutoDelete ( true ) . Exclusive ( true ) . DeclareAsync ( ) ;
315
313
Assert . Equal ( 1 , topologyListener . QueueCount ( ) ) ;
316
314
317
315
await SystemUtils . WaitUntilConnectionIsKilled ( _containerId ) ;
318
316
await oneRecoveryEventSeenTcs . Task . WaitAsync ( TimeSpan . FromSeconds ( 10 ) ) ;
319
317
320
- await SystemUtils . WaitUntilQueueDeletedAsync ( queueName ) ;
318
+ await SystemUtils . WaitUntilQueueDeletedAsync ( _queueName ) ;
321
319
322
320
await connection . CloseAsync ( ) ;
323
321
Assert . Equal ( 0 , topologyListener . QueueCount ( ) ) ;
@@ -331,7 +329,6 @@ public async Task RecoveryTopologyShouldRecoverExchanges(bool topologyEnabled)
331
329
Assert . Null ( _connection ) ;
332
330
Assert . Null ( _management ) ;
333
331
334
- const string exchangeName = "exchange-should-recover" ;
335
332
IConnection connection = await AmqpConnection . CreateAsync (
336
333
ConnectionSettingBuilder . Create ( )
337
334
. RecoveryConfiguration ( RecoveryConfiguration . Create ( )
@@ -350,26 +347,26 @@ public async Task RecoveryTopologyShouldRecoverExchanges(bool topologyEnabled)
350
347
} ;
351
348
IManagement management = connection . Management ( ) ;
352
349
ITopologyListener topologyListener = ( ( IManagementTopology ) management ) . TopologyListener ( ) ;
353
- IExchangeSpecification exSpec = management . Exchange ( ) . Name ( exchangeName ) . AutoDelete ( true )
350
+ IExchangeSpecification exSpec = management . Exchange ( ) . Name ( _exchangeName ) . AutoDelete ( true )
354
351
. Type ( ExchangeType . DIRECT ) ;
355
352
await exSpec . DeclareAsync ( ) ;
356
353
Assert . Equal ( 1 , topologyListener . ExchangeCount ( ) ) ;
357
354
358
355
// Since we cannot reboot the broker for this test we delete the exchange manually to simulate check if
359
356
// the exchange is recovered.
360
- await SystemUtils . DeleteExchangeAsync ( "exchange-should-recover" ) ;
357
+ await SystemUtils . DeleteExchangeAsync ( _exchangeName ) ;
361
358
362
359
await SystemUtils . WaitUntilConnectionIsKilled ( _containerId ) ;
363
360
364
361
await twoRecoveryEventsSeenTcs . Task . WaitAsync ( TimeSpan . FromSeconds ( 10 ) ) ;
365
362
366
363
if ( topologyEnabled )
367
364
{
368
- await SystemUtils . WaitUntilExchangeExistsAsync ( exchangeName ) ;
365
+ await SystemUtils . WaitUntilExchangeExistsAsync ( _exchangeName ) ;
369
366
}
370
367
else
371
368
{
372
- await SystemUtils . WaitUntilExchangeDeletedAsync ( exchangeName ) ;
369
+ await SystemUtils . WaitUntilExchangeDeletedAsync ( _exchangeName ) ;
373
370
}
374
371
375
372
Assert . Equal ( 1 , topologyListener . ExchangeCount ( ) ) ;
@@ -408,12 +405,14 @@ public async Task RecoveryTopologyShouldRecoverBindings(bool topologyEnabled)
408
405
} ;
409
406
IManagement management = connection . Management ( ) ;
410
407
ITopologyListener topologyListener = ( ( IManagementTopology ) management ) . TopologyListener ( ) ;
411
- IExchangeSpecification exSpec = management . Exchange ( ) . Name ( "exchange-should-recover-binding" ) . AutoDelete ( true )
408
+ IExchangeSpecification exSpec = management . Exchange ( ) . Name ( _exchangeName ) . AutoDelete ( true )
412
409
. Type ( ExchangeType . DIRECT ) ;
413
410
await exSpec . DeclareAsync ( ) ;
414
411
Assert . Equal ( 1 , topologyListener . ExchangeCount ( ) ) ;
415
- IQueueSpecification queueSpec = management . Queue ( ) . Name ( "queue-should-recover-binding" ) . AutoDelete ( true ) . Exclusive ( true ) ;
412
+
413
+ IQueueSpecification queueSpec = management . Queue ( ) . Name ( _queueName ) . AutoDelete ( true ) . Exclusive ( true ) ;
416
414
await queueSpec . DeclareAsync ( ) ;
415
+
417
416
Assert . Equal ( 1 , topologyListener . QueueCount ( ) ) ;
418
417
IBindingSpecification bindingSpec =
419
418
management . Binding ( ) . SourceExchange ( exSpec ) . DestinationQueue ( queueSpec ) . Key ( "key" ) ;
@@ -422,25 +421,23 @@ public async Task RecoveryTopologyShouldRecoverBindings(bool topologyEnabled)
422
421
423
422
// Since we cannot reboot the broker for this test we delete the exchange manually to simulate check if
424
423
// the exchange is recovered.
425
- await SystemUtils . DeleteExchangeAsync ( "exchange-should-recover-binding" ) ;
424
+ await SystemUtils . DeleteExchangeAsync ( _exchangeName ) ;
426
425
427
426
// The queue will be deleted due of the auto-delete flag
428
427
await SystemUtils . WaitUntilConnectionIsKilled ( _containerId ) ;
429
428
await twoRecoveryEventsSeenTcs . Task . WaitAsync ( TimeSpan . FromSeconds ( 10 ) ) ;
430
429
431
430
if ( topologyEnabled )
432
431
{
433
- await SystemUtils . WaitUntilExchangeExistsAsync ( "exchange-should-recover-binding" ) ;
434
- await SystemUtils . WaitUntilQueueExistsAsync ( "queue-should-recover-binding" ) ;
435
- await SystemUtils . WaitUntilBindingsBetweenExchangeAndQueueExistAsync ( "exchange-should-recover-binding" ,
436
- "queue-should-recover-binding" ) ;
432
+ await SystemUtils . WaitUntilExchangeExistsAsync ( _exchangeName ) ;
433
+ await SystemUtils . WaitUntilQueueExistsAsync ( _queueName ) ;
434
+ await SystemUtils . WaitUntilBindingsBetweenExchangeAndQueueExistAsync ( _exchangeName , _queueName ) ;
437
435
}
438
436
else
439
437
{
440
- await SystemUtils . WaitUntilExchangeDeletedAsync ( "exchange-should-recover-binding" ) ;
441
- await SystemUtils . WaitUntilQueueDeletedAsync ( "queue-should-recover-binding" ) ;
442
- await SystemUtils . WaitUntilBindingsBetweenExchangeAndQueueDontExistAsync ( "exchange-should-recover-binding" ,
443
- "queue-should-recover-binding" ) ;
438
+ await SystemUtils . WaitUntilExchangeDeletedAsync ( _exchangeName ) ;
439
+ await SystemUtils . WaitUntilQueueDeletedAsync ( _queueName ) ;
440
+ await SystemUtils . WaitUntilBindingsBetweenExchangeAndQueueDontExistAsync ( _exchangeName , _queueName ) ;
444
441
}
445
442
446
443
Assert . Equal ( 1 , topologyListener . ExchangeCount ( ) ) ;
@@ -471,6 +468,8 @@ public async Task RemoveAQueueShouldRemoveTheBindings()
471
468
Assert . Null ( _connection ) ;
472
469
Assert . Null ( _management ) ;
473
470
471
+ string wontDeleteQueueName = _queueName + "-wont-delete" ;
472
+
474
473
IConnection connection = await AmqpConnection . CreateAsync (
475
474
ConnectionSettingBuilder . Create ( )
476
475
. RecoveryConfiguration ( RecoveryConfiguration . Create ( )
@@ -481,43 +480,39 @@ public async Task RemoveAQueueShouldRemoveTheBindings()
481
480
482
481
IManagement management = connection . Management ( ) ;
483
482
ITopologyListener topologyListener = ( ( IManagementTopology ) management ) . TopologyListener ( ) ;
484
- IExchangeSpecification exSpec = management . Exchange ( ) . Name ( "e-remove-a-should-remove-binding" )
483
+ IExchangeSpecification exSpec = management . Exchange ( ) . Name ( _exchangeName )
485
484
. Type ( ExchangeType . DIRECT ) ;
486
485
487
486
await exSpec . DeclareAsync ( ) ;
488
487
489
- IQueueSpecification queueSpec = management . Queue ( ) . Name ( "q-remove-a-should-remove-binding" )
488
+ IQueueSpecification queueSpec = management . Queue ( ) . Name ( _queueName )
490
489
. AutoDelete ( true ) . Exclusive ( true ) ;
491
490
await queueSpec . DeclareAsync ( ) ;
492
491
493
- IQueueSpecification queueSpecWontDeleted = management . Queue ( ) . Name ( "q-remove-a-should-remove-binding-wont-delete" )
492
+ IQueueSpecification queueSpecWontDelete = management . Queue ( ) . Name ( wontDeleteQueueName )
494
493
. AutoDelete ( true ) . Exclusive ( true ) ;
495
-
496
- await queueSpecWontDeleted . DeclareAsync ( ) ;
494
+ await queueSpecWontDelete . DeclareAsync ( ) ;
497
495
498
496
for ( int i = 0 ; i < 10 ; i ++ )
499
497
{
500
498
await management . Binding ( ) . SourceExchange ( exSpec )
501
499
. DestinationQueue ( queueSpec ) . Key ( $ "key_{ i } ") . BindAsync ( ) ;
502
500
503
501
await management . Binding ( ) . SourceExchange ( exSpec )
504
- . DestinationQueue ( queueSpecWontDeleted ) . Key ( $ "key_{ i } ") . BindAsync ( ) ;
502
+ . DestinationQueue ( queueSpecWontDelete ) . Key ( $ "key_{ i } ") . BindAsync ( ) ;
505
503
}
506
504
507
- await SystemUtils . WaitUntilBindingsBetweenExchangeAndQueueExistAsync ( "e-remove-a-should-remove-binding" ,
508
- "q-remove-a-should-remove-binding" ) ;
505
+ await SystemUtils . WaitUntilBindingsBetweenExchangeAndQueueExistAsync ( _exchangeName , _queueName ) ;
509
506
510
- await SystemUtils . WaitUntilBindingsBetweenExchangeAndQueueExistAsync ( "e-remove-a-should-remove-binding" ,
511
- "q-remove-a-should-remove-binding-wont-delete" ) ;
507
+ await SystemUtils . WaitUntilBindingsBetweenExchangeAndQueueExistAsync ( _exchangeName , wontDeleteQueueName ) ;
512
508
513
509
Assert . Equal ( 20 , topologyListener . BindingCount ( ) ) ;
514
510
await queueSpec . DeleteAsync ( ) ;
515
511
516
- await SystemUtils . WaitUntilBindingsBetweenExchangeAndQueueDontExistAsync ( "e-remove-a-should-remove-binding" ,
517
- "q-remove-a-should-remove-binding" ) ;
512
+ await SystemUtils . WaitUntilBindingsBetweenExchangeAndQueueDontExistAsync ( _exchangeName , _queueName ) ;
518
513
519
514
Assert . Equal ( 10 , topologyListener . BindingCount ( ) ) ;
520
- await queueSpecWontDeleted . DeleteAsync ( ) ;
515
+ await queueSpecWontDelete . DeleteAsync ( ) ;
521
516
522
517
await exSpec . DeleteAsync ( ) ;
523
518
@@ -533,6 +528,8 @@ public async Task RemoveAnExchangeShouldRemoveTheBindings()
533
528
Assert . Null ( _connection ) ;
534
529
Assert . Null ( _management ) ;
535
530
531
+ string wontDeleteExchangeName = _exchangeName + "-wont-delete" ;
532
+
536
533
IConnection connection = await AmqpConnection . CreateAsync (
537
534
ConnectionSettingBuilder . Create ( )
538
535
. RecoveryConfiguration ( RecoveryConfiguration . Create ( )
@@ -543,17 +540,17 @@ public async Task RemoveAnExchangeShouldRemoveTheBindings()
543
540
544
541
IManagement management = connection . Management ( ) ;
545
542
ITopologyListener topologyListener = ( ( IManagementTopology ) management ) . TopologyListener ( ) ;
546
- IExchangeSpecification exSpec = management . Exchange ( ) . Name ( "e-remove-exchange-should-remove-binding" )
543
+ IExchangeSpecification exSpec = management . Exchange ( ) . Name ( _exchangeName )
547
544
. Type ( ExchangeType . DIRECT ) ;
548
545
549
546
await exSpec . DeclareAsync ( ) ;
550
547
551
- IExchangeSpecification exSpecWontDeleted = management . Exchange ( ) . Name ( "e-remove-exchange-should-remove-binding-wont-delete" )
548
+ IExchangeSpecification exSpecWontDeleted = management . Exchange ( ) . Name ( wontDeleteExchangeName )
552
549
. Type ( ExchangeType . DIRECT ) ;
553
550
554
551
await exSpecWontDeleted . DeclareAsync ( ) ;
555
552
556
- IQueueSpecification queueSpec = management . Queue ( ) . Name ( "q-remove-exchange-should-remove-binding" )
553
+ IQueueSpecification queueSpec = management . Queue ( ) . Name ( _queueName )
557
554
. AutoDelete ( true ) . Exclusive ( true ) ;
558
555
await queueSpec . DeclareAsync ( ) ;
559
556
@@ -566,19 +563,19 @@ await management.Binding().SourceExchange(exSpecWontDeleted)
566
563
. DestinationQueue ( queueSpec ) . Key ( $ "key_{ i } ") . BindAsync ( ) ;
567
564
}
568
565
569
- await SystemUtils . WaitUntilBindingsBetweenExchangeAndQueueExistAsync ( "e-remove-exchange-should-remove-binding" ,
570
- "q-remove-exchange-should-remove-binding" ) ;
566
+ await SystemUtils . WaitUntilBindingsBetweenExchangeAndQueueExistAsync ( _exchangeName ,
567
+ _queueName ) ;
571
568
572
569
await SystemUtils . WaitUntilBindingsBetweenExchangeAndQueueExistAsync (
573
- "e-remove-exchange-should-remove-binding-wont-delete" ,
574
- "q-remove-exchange-should-remove-binding" ) ;
570
+ wontDeleteExchangeName ,
571
+ _queueName ) ;
575
572
576
573
Assert . Equal ( 20 , topologyListener . BindingCount ( ) ) ;
577
574
await exSpec . DeleteAsync ( ) ;
578
575
579
576
await SystemUtils . WaitUntilBindingsBetweenExchangeAndQueueDontExistAsync (
580
- "e-remove-exchange-should-remove-binding" ,
581
- "q-remove-exchange-should-remove-binding" ) ;
577
+ _exchangeName ,
578
+ _queueName ) ;
582
579
583
580
Assert . Equal ( 10 , topologyListener . BindingCount ( ) ) ;
584
581
await exSpecWontDeleted . DeleteAsync ( ) ;
@@ -600,6 +597,8 @@ public async Task RemoveAnExchangeBoundToAnotherExchangeShouldRemoveTheBindings(
600
597
Assert . Null ( _connection ) ;
601
598
Assert . Null ( _management ) ;
602
599
600
+ string destinationExchangeName = _exchangeName + "-destination" ;
601
+
603
602
IConnection connection = await AmqpConnection . CreateAsync (
604
603
ConnectionSettingBuilder . Create ( )
605
604
. RecoveryConfiguration ( RecoveryConfiguration . Create ( )
@@ -611,13 +610,13 @@ public async Task RemoveAnExchangeBoundToAnotherExchangeShouldRemoveTheBindings(
611
610
IManagement management = connection . Management ( ) ;
612
611
ITopologyListener topologyListener = ( ( IManagementTopology ) management ) . TopologyListener ( ) ;
613
612
614
- IExchangeSpecification exSpec = management . Exchange ( ) . Name ( "e-remove-exchange-bound-to-another-exchange-should-remove-binding" )
613
+ IExchangeSpecification exSpec = management . Exchange ( ) . Name ( _exchangeName )
615
614
. Type ( ExchangeType . DIRECT ) ;
616
615
617
616
await exSpec . DeclareAsync ( ) ;
618
617
619
618
IExchangeSpecification exSpecDestination = management . Exchange ( )
620
- . Name ( "e-remove-exchange-bound-to-another-exchange-should-remove-binding-destination" )
619
+ . Name ( destinationExchangeName )
621
620
. Type ( ExchangeType . DIRECT ) ;
622
621
623
622
await exSpecDestination . DeclareAsync ( ) ;
@@ -628,9 +627,7 @@ await management.Binding().SourceExchange(exSpec)
628
627
. DestinationExchange ( exSpecDestination ) . Key ( $ "key_{ i } ") . BindAsync ( ) ;
629
628
}
630
629
631
- await SystemUtils . WaitUntilBindingsBetweenExchangeAndExchangeExistAsync (
632
- "e-remove-exchange-bound-to-another-exchange-should-remove-binding" ,
633
- "e-remove-exchange-bound-to-another-exchange-should-remove-binding-destination" ) ;
630
+ await SystemUtils . WaitUntilBindingsBetweenExchangeAndExchangeExistAsync ( _exchangeName , destinationExchangeName ) ;
634
631
635
632
Assert . Equal ( 10 , topologyListener . BindingCount ( ) ) ;
636
633
@@ -639,9 +636,7 @@ await SystemUtils.WaitUntilBindingsBetweenExchangeAndExchangeExistAsync(
639
636
640
637
await exSpec . DeleteAsync ( ) ;
641
638
642
- await SystemUtils . WaitUntilBindingsBetweenExchangeAndExchangeDontExistAsync (
643
- "e-remove-exchange-bound-to-another-exchange-should-remove-binding" ,
644
- "e-remove-exchange-bound-to-another-exchange-should-remove-binding-destination" ) ;
639
+ await SystemUtils . WaitUntilBindingsBetweenExchangeAndExchangeDontExistAsync ( _exchangeName , destinationExchangeName ) ;
645
640
646
641
Assert . Equal ( 0 , topologyListener . ExchangeCount ( ) ) ;
647
642
0 commit comments