Skip to content

Commit 6b173bd

Browse files
committed
B2B-1816: AWS Managed Queue: Get Cloud-Native-Testing Integration Test Builds to Work Against AWS Managed Queue
1 parent 1807f70 commit 6b173bd

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

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

Lines changed: 15 additions & 4 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
@@ -36,6 +37,13 @@ class Amqp
3637
*/
3738
private $host;
3839

40+
/**
41+
* RabbitMQ virtual host
42+
*
43+
* @var string
44+
*/
45+
private $virtualHost;
46+
3947
/**
4048
* Initialize dependencies.
4149
* @param \Magento\Framework\App\DeploymentConfig $deploymentConfig
@@ -59,6 +67,7 @@ public function __construct(
5967
$this->deploymentConfig->get(self::CONFIG_PATH_HOST),
6068
defined('RABBITMQ_MANAGEMENT_PORT') ? RABBITMQ_MANAGEMENT_PORT : self::DEFAULT_MANAGEMENT_PORT
6169
);
70+
$this->virtualHost = defined('RABBITMQ_VIRTUALHOST') ? RABBITMQ_VIRTUALHOST : self::DEFAULT_VIRTUALHOST;
6271
}
6372

6473
/**
@@ -82,7 +91,7 @@ public function isAvailable(): bool
8291
*/
8392
public function getExchanges()
8493
{
85-
$this->curl->get($this->host . 'exchanges');
94+
$this->curl->get($this->host . 'exchanges/' . urlencode($this->virtualHost));
8695
$data = $this->curl->getBody();
8796
$data = json_decode($data, true);
8897
$output = [];
@@ -100,7 +109,7 @@ public function getExchanges()
100109
*/
101110
public function getExchangeBindings($name)
102111
{
103-
$this->curl->get($this->host . 'exchanges/%2f/' . $name . '/bindings/source');
112+
$this->curl->get($this->host . 'exchanges/' . urlencode($this->virtualHost) . '/' . $name . '/bindings/source');
104113
$data = $this->curl->getBody();
105114
return json_decode($data, true);
106115
}
@@ -112,7 +121,7 @@ public function getExchangeBindings($name)
112121
*/
113122
public function getConnections()
114123
{
115-
$this->curl->get($this->host . 'connections');
124+
$this->curl->get($this->host . 'vhosts/' . urlencode($this->virtualHost) . '/connections');
116125
$data = $this->curl->getBody();
117126
$data = json_decode($data, true);
118127
$output = [];
@@ -137,7 +146,9 @@ public function clearQueue(string $name, int $numMessages = 50)
137146
"encoding" => "auto",
138147
"truncate" => 50000
139148
];
140-
$this->curl->post($this->host . 'queue/%2f/' . $name . '/get', json_encode($body));
149+
$this->curl->post(
150+
$this->host . 'queue/' . urlencode($this->virtualHost) . '/' . $name . '/get', json_encode($body)
151+
);
141152
return $this->curl->getBody();
142153
}
143154

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>

0 commit comments

Comments
 (0)