Skip to content

Commit e649634

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

14 files changed

+424
-236
lines changed

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
55
*/
66

77
declare(strict_types=1);
@@ -30,18 +30,30 @@ class TopologyTest extends TestCase
3030
*/
3131
private $helper;
3232

33+
/**
34+
* @var string
35+
*/
36+
private $connectionType;
37+
3338
/**
3439
* @return void
3540
*/
3641
protected function setUp(): void
3742
{
38-
$this->helper = Bootstrap::getObjectManager()->create(Amqp::class);
43+
$objectManager = Bootstrap::getObjectManager();
44+
/** @var DefaultValueProvider $defaultValueProvider */
45+
$defaultValueProvider = $objectManager->get(DefaultValueProvider::class);
46+
$this->connectionType = $defaultValueProvider->getConnection();
3947

40-
if (!$this->helper->isAvailable()) {
41-
$this->fail('This test relies on RabbitMQ Management Plugin.');
42-
}
48+
if ($this->connectionType === 'amqp') {
49+
$this->helper = Bootstrap::getObjectManager()->create(Amqp::class);
4350

44-
$this->declaredExchanges = $this->helper->getExchanges();
51+
if (!$this->helper->isAvailable()) {
52+
$this->fail('This test relies on RabbitMQ Management Plugin.');
53+
}
54+
55+
$this->declaredExchanges = $this->helper->getExchanges();
56+
}
4557
}
4658

4759
/**
@@ -51,6 +63,10 @@ protected function setUp(): void
5163
*/
5264
public function testTopologyInstallation(array $expectedConfig, array $bindingConfig): void
5365
{
66+
if ($this->connectionType === 'stomp') {
67+
$this->markTestSkipped('AMQP test skipped because STOMP connection is available. This test is AMQP-specific.');
68+
}
69+
5470
$name = $expectedConfig['name'];
5571
$this->assertArrayHasKey($name, $this->declaredExchanges);
5672
unset(

dev/tests/integration/testsuite/Magento/Framework/MessageQueue/UseCase/AsyncMultipleHandlersTest.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Framework\MessageQueue\UseCase;
77

8+
use Magento\Framework\MessageQueue\DefaultValueProvider;
9+
use Magento\TestFramework\Helper\Bootstrap;
810
use Magento\TestModuleAsyncAmqp\Model\AsyncTestData;
911

1012
class AsyncMultipleHandlersTest extends QueueTestCaseAbstract
@@ -42,6 +44,26 @@ class AsyncMultipleHandlersTest extends QueueTestCaseAbstract
4244
'mixed-mtmh.topic.2-2'
4345
];
4446

47+
/**
48+
* @var string
49+
*/
50+
private $connectionType;
51+
52+
/**
53+
* @inheritdoc
54+
*/
55+
protected function setUp(): void
56+
{
57+
$this->objectManager = Bootstrap::getObjectManager();
58+
/** @var DefaultValueProvider $defaultValueProvider */
59+
$defaultValueProvider = $this->objectManager->get(DefaultValueProvider::class);
60+
$this->connectionType = $defaultValueProvider->getConnection();
61+
62+
if ($this->connectionType === 'amqp') {
63+
parent::setUp();
64+
}
65+
}
66+
4567
/**
4668
* Verify that Queue Framework supports multiple topics per queue.
4769
*
@@ -50,6 +72,10 @@ class AsyncMultipleHandlersTest extends QueueTestCaseAbstract
5072
*/
5173
public function testAsynchronousRpcCommunication()
5274
{
75+
if ($this->connectionType === 'stomp') {
76+
$this->markTestSkipped('AMQP test skipped because STOMP connection is available. This test is AMQP-specific.');
77+
}
78+
5379
foreach ($this->topicValueMap as $topic => $data) {
5480
$message = null;
5581
if (is_array($data)) {

dev/tests/integration/testsuite/Magento/Framework/MessageQueue/UseCase/AsyncMultipleTopicsWithEachQueueTest.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Framework\MessageQueue\UseCase;
77

8+
use Magento\Framework\MessageQueue\DefaultValueProvider;
9+
use Magento\TestFramework\Helper\Bootstrap;
810
use Magento\TestModuleAsyncAmqp\Model\AsyncTestData;
911

1012
class AsyncMultipleTopicsWithEachQueueTest extends QueueTestCaseAbstract
@@ -29,13 +31,37 @@ class AsyncMultipleTopicsWithEachQueueTest extends QueueTestCaseAbstract
2931
*/
3032
private $topics = ['multi.topic.queue.topic.y', 'multi.topic.queue.topic.z'];
3133

34+
/**
35+
* @var string
36+
*/
37+
private $connectionType;
38+
39+
/**
40+
* @inheritdoc
41+
*/
42+
protected function setUp(): void
43+
{
44+
$this->objectManager = Bootstrap::getObjectManager();
45+
/** @var DefaultValueProvider $defaultValueProvider */
46+
$defaultValueProvider = $this->objectManager->get(DefaultValueProvider::class);
47+
$this->connectionType = $defaultValueProvider->getConnection();
48+
49+
if ($this->connectionType === 'amqp') {
50+
parent::setUp();
51+
}
52+
}
53+
3254
/**
3355
* Verify that Queue Framework processes multiple asynchronous topics sent to the same queue.
3456
*
3557
* Current test is not test of Web API framework itself, it just utilizes its infrastructure to test Message Queue.
3658
*/
3759
public function testAsyncMultipleTopicsPerQueue()
3860
{
61+
if ($this->connectionType === 'stomp') {
62+
$this->markTestSkipped('AMQP test skipped because STOMP connection is available. This test is AMQP-specific.');
63+
}
64+
3965
$this->msgObject = $this->objectManager->create(AsyncTestData::class); // @phpstan-ignore-line
4066

4167
foreach ($this->topics as $topic) {

dev/tests/integration/testsuite/Magento/Framework/MessageQueue/UseCase/DeprecatedFormat/AsyncMultiTopicsSeparateQueuesTest.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Framework\MessageQueue\UseCase\DeprecatedFormat;
77

8+
use Magento\Framework\MessageQueue\DefaultValueProvider;
9+
use Magento\TestFramework\Helper\Bootstrap;
810
use Magento\Framework\MessageQueue\UseCase\QueueTestCaseAbstract;
911
use Magento\TestModuleAsyncAmqp\Model\AsyncTestData;
1012

@@ -33,13 +35,37 @@ class AsyncMultiTopicsSeparateQueuesTest extends QueueTestCaseAbstract
3335
*/
3436
private $topics = ['multi.topic.queue.topic.c.deprecated', 'multi.topic.queue.topic.d.deprecated'];
3537

38+
/**
39+
* @var string
40+
*/
41+
private $connectionType;
42+
43+
/**
44+
* @inheritdoc
45+
*/
46+
protected function setUp(): void
47+
{
48+
$this->objectManager = Bootstrap::getObjectManager();
49+
/** @var DefaultValueProvider $defaultValueProvider */
50+
$defaultValueProvider = $this->objectManager->get(DefaultValueProvider::class);
51+
$this->connectionType = $defaultValueProvider->getConnection();
52+
53+
if ($this->connectionType === 'amqp') {
54+
parent::setUp();
55+
}
56+
}
57+
3658
/**
3759
* Verify that Queue Framework processes multiple asynchronous topics sent to the same queue.
3860
*
3961
* Current test is not test of Web API framework itself, it just utilizes its infrastructure to test Message Queue.
4062
*/
4163
public function testAsyncMultipleTopicsPerQueue()
4264
{
65+
if ($this->connectionType === 'stomp') {
66+
$this->markTestSkipped('AMQP test skipped because STOMP connection is available. This test is AMQP-specific.');
67+
}
68+
4369
$this->msgObject = $this->objectManager->create(AsyncTestData::class); // @phpstan-ignore-line
4470

4571
foreach ($this->topics as $topic) {

dev/tests/integration/testsuite/Magento/Framework/MessageQueue/UseCase/DeprecatedFormat/RpcCommunicationTest.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Framework\MessageQueue\UseCase\DeprecatedFormat;
77

8+
use Magento\Framework\MessageQueue\DefaultValueProvider;
89
use Magento\Framework\MessageQueue\UseCase\QueueTestCaseAbstract;
10+
use Magento\TestFramework\Helper\Bootstrap;
911

1012
class RpcCommunicationTest extends QueueTestCaseAbstract
1113
{
@@ -14,13 +16,37 @@ class RpcCommunicationTest extends QueueTestCaseAbstract
1416
*/
1517
protected $consumers = ['synchronousRpcTestConsumer.deprecated'];
1618

19+
/**
20+
* @var string
21+
*/
22+
private $connectionType;
23+
24+
/**
25+
* @inheritdoc
26+
*/
27+
protected function setUp(): void
28+
{
29+
$this->objectManager = Bootstrap::getObjectManager();
30+
/** @var DefaultValueProvider $defaultValueProvider */
31+
$defaultValueProvider = $this->objectManager->get(DefaultValueProvider::class);
32+
$this->connectionType = $defaultValueProvider->getConnection();
33+
34+
if ($this->connectionType === 'amqp') {
35+
parent::setUp();
36+
}
37+
}
38+
1739
/**
1840
* Verify that RPC call based on Rabbit MQ is processed correctly.
1941
*
2042
* Current test is not test of Web API framework itself, it just utilizes its infrastructure to test RPC.
2143
*/
2244
public function testSynchronousRpcCommunication()
2345
{
46+
if ($this->connectionType === 'stomp') {
47+
$this->markTestSkipped('AMQP test skipped because STOMP connection is available. This test is AMQP-specific.');
48+
}
49+
2450
$input = 'Input value';
2551
$response = $this->publisher->publish('synchronous.rpc.test.deprecated', $input);
2652
$this->assertEquals($input . ' processed by RPC handler', $response);

dev/tests/integration/testsuite/Magento/Framework/MessageQueue/UseCase/MixSyncAndAsyncSingleQueueTest.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Framework\MessageQueue\UseCase;
77

8+
use Magento\Framework\MessageQueue\DefaultValueProvider;
9+
use Magento\TestFramework\Helper\Bootstrap;
810
use Magento\TestModuleAsyncAmqp\Model\AsyncTestData;
911

1012
class MixSyncAndAsyncSingleQueueTest extends QueueTestCaseAbstract
@@ -29,8 +31,32 @@ class MixSyncAndAsyncSingleQueueTest extends QueueTestCaseAbstract
2931
*/
3032
protected $maxMessages = 4;
3133

34+
/**
35+
* @var string
36+
*/
37+
private $connectionType;
38+
39+
/**
40+
* @inheritdoc
41+
*/
42+
protected function setUp(): void
43+
{
44+
$this->objectManager = Bootstrap::getObjectManager();
45+
/** @var DefaultValueProvider $defaultValueProvider */
46+
$defaultValueProvider = $this->objectManager->get(DefaultValueProvider::class);
47+
$this->connectionType = $defaultValueProvider->getConnection();
48+
49+
if ($this->connectionType === 'amqp') {
50+
parent::setUp();
51+
}
52+
}
53+
3254
public function testMixSyncAndAsyncSingleQueue()
3355
{
56+
if ($this->connectionType === 'stomp') {
57+
$this->markTestSkipped('AMQP test skipped because STOMP connection is available. This test is AMQP-specific.');
58+
}
59+
3460
$this->msgObject = $this->objectManager->create(AsyncTestData::class); // @phpstan-ignore-line
3561

3662
// Publish asynchronous messages

dev/tests/integration/testsuite/Magento/Framework/MessageQueue/UseCase/MultipleTopicsPerQueueTest.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Framework\MessageQueue\UseCase;
77

8+
use Magento\Framework\MessageQueue\DefaultValueProvider;
9+
use Magento\TestFramework\Helper\Bootstrap;
10+
811
class MultipleTopicsPerQueueTest extends QueueTestCaseAbstract
912
{
1013
/**
@@ -15,6 +18,26 @@ class MultipleTopicsPerQueueTest extends QueueTestCaseAbstract
1518
'queue.for.multiple.topics.test.b'
1619
];
1720

21+
/**
22+
* @var string
23+
*/
24+
private $connectionType;
25+
26+
/**
27+
* @inheritdoc
28+
*/
29+
protected function setUp(): void
30+
{
31+
$this->objectManager = Bootstrap::getObjectManager();
32+
/** @var DefaultValueProvider $defaultValueProvider */
33+
$defaultValueProvider = $this->objectManager->get(DefaultValueProvider::class);
34+
$this->connectionType = $defaultValueProvider->getConnection();
35+
36+
if ($this->connectionType === 'amqp') {
37+
parent::setUp();
38+
}
39+
}
40+
1841
/**
1942
* Verify that Queue Framework supports multiple topics per queue.
2043
*
@@ -23,6 +46,10 @@ class MultipleTopicsPerQueueTest extends QueueTestCaseAbstract
2346
*/
2447
public function testSynchronousRpcCommunication()
2548
{
49+
if ($this->connectionType === 'stomp') {
50+
$this->markTestSkipped('AMQP test skipped because STOMP connection is available. This test is AMQP-specific.');
51+
}
52+
2653
foreach (['multi.topic.queue.topic.a', 'multi.topic.queue.topic.b'] as $topic) {
2754
$input = "Input value for topic '{$topic}'";
2855
$response = $this->publisher->publish($topic, $input);

0 commit comments

Comments
 (0)