Skip to content

Commit b21f60c

Browse files
committed
Merge remote-tracking branch 'arcticfoxes/B2B-1816' into 2.4-develop-pr
2 parents e88d5bd + dbe176d commit b21f60c

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

dev/tests/integration/framework/Magento/TestFramework/Helper/Amqp.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Amqp
1818
const CONFIG_PATH_PASSWORD = 'queue/amqp/password';
1919
const DEFAULT_MANAGEMENT_PROTOCOL = 'http';
2020
const DEFAULT_MANAGEMENT_PORT = '15672';
21+
const DEFAULT_VIRTUALHOST = '/';
2122

2223
/**
2324
* @var Curl
@@ -30,12 +31,15 @@ class Amqp
3031
private $deploymentConfig;
3132

3233
/**
33-
* RabbitMQ API host
34-
*
3534
* @var string
3635
*/
3736
private $host;
3837

38+
/**
39+
* @var string
40+
*/
41+
private $virtualHost;
42+
3943
/**
4044
* Initialize dependencies.
4145
* @param \Magento\Framework\App\DeploymentConfig $deploymentConfig
@@ -59,6 +63,7 @@ public function __construct(
5963
$this->deploymentConfig->get(self::CONFIG_PATH_HOST),
6064
defined('RABBITMQ_MANAGEMENT_PORT') ? RABBITMQ_MANAGEMENT_PORT : self::DEFAULT_MANAGEMENT_PORT
6165
);
66+
$this->virtualHost = defined('RABBITMQ_VIRTUALHOST') ? RABBITMQ_VIRTUALHOST : self::DEFAULT_VIRTUALHOST;
6267
}
6368

6469
/**
@@ -82,7 +87,7 @@ public function isAvailable(): bool
8287
*/
8388
public function getExchanges()
8489
{
85-
$this->curl->get($this->host . 'exchanges');
90+
$this->curl->get($this->host . 'exchanges/' . urlencode($this->virtualHost));
8691
$data = $this->curl->getBody();
8792
$data = json_decode($data, true);
8893
$output = [];
@@ -100,7 +105,7 @@ public function getExchanges()
100105
*/
101106
public function getExchangeBindings($name)
102107
{
103-
$this->curl->get($this->host . 'exchanges/%2f/' . $name . '/bindings/source');
108+
$this->curl->get($this->host . 'exchanges/' . urlencode($this->virtualHost) . '/' . $name . '/bindings/source');
104109
$data = $this->curl->getBody();
105110
return json_decode($data, true);
106111
}
@@ -112,7 +117,7 @@ public function getExchangeBindings($name)
112117
*/
113118
public function getConnections()
114119
{
115-
$this->curl->get($this->host . 'connections');
120+
$this->curl->get($this->host . 'vhosts/' . urlencode($this->virtualHost) . '/connections');
116121
$data = $this->curl->getBody();
117122
$data = json_decode($data, true);
118123
$output = [];
@@ -137,7 +142,10 @@ public function clearQueue(string $name, int $numMessages = 50)
137142
"encoding" => "auto",
138143
"truncate" => 50000
139144
];
140-
$this->curl->post($this->host . 'queue/%2f/' . $name . '/get', json_encode($body));
145+
$this->curl->post(
146+
$this->host . 'queue/' . urlencode($this->virtualHost) . '/' . $name . '/get',
147+
json_encode($body)
148+
);
141149
return $this->curl->getBody();
142150
}
143151

dev/tests/integration/phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
<!-- Connection parameters for RabbitMQ tests -->
8383
<!--<const name="RABBITMQ_MANAGEMENT_PROTOCOL" value="https"/>-->
8484
<!--<const name="RABBITMQ_MANAGEMENT_PORT" value="15672"/>-->
85+
<!--<const name="RABBITMQ_VIRTUALHOST" value="/"/>-->
8586
<!--<const name="TESTS_PARALLEL_RUN" value="1"/>-->
8687
<const name="USE_OVERRIDE_CONFIG" value="enabled"/>
8788
</php>

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,12 @@ public function testTopologyInstallation(array $expectedConfig, array $bindingCo
8383
*/
8484
public function exchangeDataProvider(): array
8585
{
86+
$virtualHost = defined('RABBITMQ_VIRTUALHOST') ? RABBITMQ_VIRTUALHOST : Amqp::DEFAULT_VIRTUALHOST;
8687
return [
8788
'magento-topic-based-exchange1' => [
8889
'exchangeConfig' => [
8990
'name' => 'magento-topic-based-exchange1',
90-
'vhost' => '/',
91+
'vhost' => $virtualHost,
9192
'type' => 'topic',
9293
'durable' => true,
9394
'auto_delete' => false,
@@ -99,7 +100,7 @@ public function exchangeDataProvider(): array
99100
'bindingConfig' => [
100101
[
101102
'source' => 'magento-topic-based-exchange1',
102-
'vhost' => '/',
103+
'vhost' => $virtualHost,
103104
'destination' => 'topic-queue1',
104105
'destination_type' => 'queue',
105106
'routing_key' => 'anotherTopic1',
@@ -112,7 +113,7 @@ public function exchangeDataProvider(): array
112113
'magento-topic-based-exchange2' => [
113114
'exchangeConfig' => [
114115
'name' => 'magento-topic-based-exchange2',
115-
'vhost' => '/',
116+
'vhost' => $virtualHost,
116117
'type' => 'topic',
117118
'durable' => true,
118119
'auto_delete' => false,
@@ -125,7 +126,7 @@ public function exchangeDataProvider(): array
125126
'bindingConfig' => [
126127
[
127128
'source' => 'magento-topic-based-exchange2',
128-
'vhost' => '/',
129+
'vhost' => $virtualHost,
129130
'destination' => 'topic-queue2',
130131
'destination_type' => 'queue',
131132
'routing_key' => 'anotherTopic2',
@@ -140,7 +141,7 @@ public function exchangeDataProvider(): array
140141
'magento-topic-based-exchange3' => [
141142
'exchangeConfig' => [
142143
'name' => 'magento-topic-based-exchange3',
143-
'vhost' => '/',
144+
'vhost' => $virtualHost,
144145
'type' => 'topic',
145146
'durable' => false,
146147
'auto_delete' => true,
@@ -152,7 +153,7 @@ public function exchangeDataProvider(): array
152153
'magento-topic-based-exchange4' => [
153154
'exchangeConfig' => [
154155
'name' => 'magento-topic-based-exchange4',
155-
'vhost' => '/',
156+
'vhost' => $virtualHost,
156157
'type' => 'topic',
157158
'durable' => true,
158159
'auto_delete' => false,
@@ -162,7 +163,7 @@ public function exchangeDataProvider(): array
162163
'bindingConfig' => [
163164
[
164165
'source' => 'magento-topic-based-exchange4',
165-
'vhost' => '/',
166+
'vhost' => $virtualHost,
166167
'destination' => 'topic-queue1',
167168
'destination_type' => 'queue',
168169
'routing_key' => '#',
@@ -172,7 +173,7 @@ public function exchangeDataProvider(): array
172173
],
173174
[
174175
'source' => 'magento-topic-based-exchange4',
175-
'vhost' => '/',
176+
'vhost' => $virtualHost,
176177
'destination' => 'topic-queue2',
177178
'destination_type' => 'queue',
178179
'routing_key' => '*.*.*',

0 commit comments

Comments
 (0)