Skip to content

Commit 77e804e

Browse files
committed
AC-6762::Random Integration B2B failures
1 parent c98e9d9 commit 77e804e

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

dev/tests/integration/framework/Magento/TestFramework/MessageQueue/PublisherConsumerController.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010

1111
use Magento\Framework\MessageQueue\PublisherInterface;
1212
use Magento\Framework\OsInfo;
13-
use Magento\TestFramework\Helper\Bootstrap;
1413
use Magento\TestFramework\Helper\Amqp;
1514

1615
class PublisherConsumerController
1716
{
1817
/**
19-
* @var string
18+
* @var string[]
2019
*/
2120
private $consumers = [];
2221

@@ -50,11 +49,6 @@ class PublisherConsumerController
5049
*/
5150
private $amqpHelper;
5251

53-
/**
54-
* @var ClearQueueProcessor
55-
*/
56-
private $clearQueueProcessor;
57-
5852
/**
5953
* PublisherConsumerController constructor.
6054
* @param PublisherInterface $publisher
@@ -64,7 +58,6 @@ class PublisherConsumerController
6458
* @param array $consumers
6559
* @param array $appInitParams
6660
* @param null|int $maxMessages
67-
* @param ClearQueueProcessor $clearQueueProcessor
6861
*/
6962
public function __construct(
7063
PublisherInterface $publisher,
@@ -73,8 +66,7 @@ public function __construct(
7366
$logFilePath,
7467
$consumers,
7568
$appInitParams,
76-
$maxMessages = null,
77-
ClearQueueProcessor $clearQueueProcessor = null
69+
$maxMessages = null
7870
) {
7971
$this->consumers = $consumers;
8072
$this->publisher = $publisher;
@@ -83,8 +75,6 @@ public function __construct(
8375
$this->osInfo = $osInfo;
8476
$this->appInitParams = $appInitParams;
8577
$this->amqpHelper = $amqpHelper;
86-
$this->clearQueueProcessor = $clearQueueProcessor
87-
?: Bootstrap::getObjectManager()->get(ClearQueueProcessor::class);
8878
}
8979

9080
/**
@@ -97,7 +87,12 @@ public function initialize()
9787
{
9888
$this->validateEnvironmentPreconditions();
9989

100-
$this->clearQueueProcessor->execute("async.operations.all");
90+
$connections = $this->amqpHelper->getConnections();
91+
foreach (array_keys($connections) as $connectionName) {
92+
$this->amqpHelper->deleteConnection($connectionName);
93+
}
94+
$this->amqpHelper->clearQueue("async.operations.all");
95+
10196
$this->stopConsumers();
10297
$this->startConsumers();
10398

@@ -125,6 +120,12 @@ private function validateEnvironmentPreconditions()
125120
"This test relies on *nix shell and should be skipped in Windows environment."
126121
);
127122
}
123+
124+
if (!$this->amqpHelper->isAvailable()) {
125+
throw new PreconditionFailedException(
126+
'This test relies on RabbitMQ Management Plugin.'
127+
);
128+
}
128129
}
129130

130131
/**

0 commit comments

Comments
 (0)