Skip to content

Commit aab328e

Browse files
committed
AC-14558::Migration form RabbitMQ to Apache ActiveMQ
1 parent 49bda94 commit aab328e

File tree

2 files changed

+46
-24
lines changed

2 files changed

+46
-24
lines changed

dev/tests/integration/testsuite/Magento/Framework/Stomp/TopologyTest.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,32 @@ class TopologyTest extends TestCase
3434
*/
3535
private $objectManager;
3636

37+
38+
/**
39+
* @var string
40+
*/
41+
private $connectionType;
42+
3743
/**
3844
* @return void
3945
*/
4046
protected function setUp(): void
4147
{
4248
$this->objectManager = Bootstrap::getObjectManager();
43-
44-
// Check if AMQP connection is available - skip STOMP test if AMQP is working
45-
try {
46-
$stompConfig = $this->objectManager->get(Config::class);
47-
$stompConfig->getConnection();
48-
} catch (\Throwable $e) {
49-
$this->markTestSkipped('STOMP test skipped because AMQP connection is available. This test is STOMP-specific.');
50-
}
5149

52-
$this->helper = $this->objectManager->create(Stomp::class);
50+
// Check if STOMP is configured as the queue connection
51+
/** @var \Magento\Framework\MessageQueue\DefaultValueProvider $defaultValueProvider */
52+
$defaultValueProvider = $this->objectManager->get(\Magento\Framework\MessageQueue\DefaultValueProvider::class);
53+
$this->connectionType = $defaultValueProvider->getConnection();
54+
55+
if($this->connectionType === 'stomp') {
56+
$this->helper = $this->objectManager->create(Stomp::class);
5357

54-
if (!$this->helper->isAvailable()) {
55-
$this->fail('This test relies on ActiveMq JMX/Jalokia.');
58+
if (!$this->helper->isAvailable()) {
59+
$this->fail('This test relies on ActiveMq JMX/Jalokia.');
60+
}
61+
$this->declaredQueues = $this->helper->getQueues();
5662
}
57-
$this->declaredQueues = $this->helper->getQueues();
5863
}
5964

6065
/**
@@ -63,6 +68,10 @@ protected function setUp(): void
6368
*/
6469
public function testTopologyInstallation(array $expectedConfig): void
6570
{
71+
if($this->connectionType !== 'stomp') {
72+
$this->markTestSkipped('STOMP test skipped because AMQP connection is available. This test is STOMP-specific.');
73+
}
74+
6675
$name = $expectedConfig['name'];
6776
$this->assertArrayHasKey($name, $this->declaredQueues);
6877

dev/tests/integration/testsuite/Magento/Framework/Stomp/WaitAndNotWaitMessagesTest.php

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\Config\File\ConfigFilePool;
1111
use Magento\Framework\Filesystem;
1212
use Magento\Framework\MessageQueue\UseCase\QueueTestCaseAbstract;
13+
use Magento\TestFramework\Helper\Bootstrap;
1314
use Magento\TestModuleAsyncStomp\Model\AsyncTestData;
1415

1516
class WaitAndNotWaitMessagesTest extends QueueTestCaseAbstract
@@ -49,24 +50,28 @@ class WaitAndNotWaitMessagesTest extends QueueTestCaseAbstract
4950
*/
5051
protected $maxMessages = 4;
5152

53+
/**
54+
* @var string
55+
*/
56+
private $connectionType;
57+
5258
/**
5359
* @inheritdoc
5460
*/
5561
protected function setUp(): void
5662
{
57-
// Check if STOMP connection is available
58-
try {
59-
$stompConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
60-
->get(\Magento\Framework\Stomp\Config::class);
61-
$stompConfig->getConnection();
62-
} catch (\Exception $e) {
63-
$this->markTestSkipped('STOMP test skipped because AMQP connection is available. This test is STOMP-specific');
63+
$this->objectManager = Bootstrap::getObjectManager();
64+
// Check if STOMP is configured as the queue connection
65+
/** @var \Magento\Framework\MessageQueue\DefaultValueProvider $defaultValueProvider */
66+
$defaultValueProvider = $this->objectManager->get(\Magento\Framework\MessageQueue\DefaultValueProvider::class);
67+
$this->connectionType = $defaultValueProvider->getConnection();
68+
69+
if ($this->connectionType === 'stomp') {
70+
parent::setUp();
71+
$this->reader = $this->objectManager->get(FileReader::class);
72+
$this->filesystem = $this->objectManager->get(Filesystem::class);
73+
$this->config = $this->loadConfig();
6474
}
65-
66-
parent::setUp();
67-
$this->reader = $this->objectManager->get(FileReader::class);
68-
$this->filesystem = $this->objectManager->get(Filesystem::class);
69-
$this->config = $this->loadConfig();
7075
}
7176

7277
/**
@@ -88,6 +93,10 @@ private function getMsgObject(): AsyncTestData
8893
*/
8994
public function testWaitForMessages()
9095
{
96+
if ($this->connectionType !== 'stomp'){
97+
$this->markTestSkipped('STOMP test skipped because AMQP connection is available. This test is STOMP-specific.');
98+
}
99+
91100
$this->publisherConsumerController->stopConsumers();
92101

93102
$config = $this->config;
@@ -119,6 +128,10 @@ public function testWaitForMessages()
119128
*/
120129
public function testNotWaitForMessages(): void
121130
{
131+
if ($this->connectionType !== 'stomp'){
132+
$this->markTestSkipped('STOMP test skipped because AMQP connection is available. This test is STOMP-specific.');
133+
}
134+
122135
$this->publisherConsumerController->stopConsumers();
123136

124137
$config = $this->config;

0 commit comments

Comments
 (0)