Skip to content

Commit 3309b84

Browse files
author
“Ashvin
committed
code refactor and funcational test added
1 parent 87a47a1 commit 3309b84

File tree

5 files changed

+167
-10
lines changed

5 files changed

+167
-10
lines changed

src/Compose/ProductionBuilder/Service/ActiveMqArtemis.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ActiveMqArtemis implements ServiceBuilderInterface
2020
/**
2121
* @var ServiceFactory
2222
*/
23-
private $serviceFactory;
23+
private ServiceFactory $serviceFactory;
2424

2525
/**
2626
* @param ServiceFactory $serviceFactory

src/Config/Source/CloudSource.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ class CloudSource implements SourceInterface
2525
/**
2626
* @var FileList
2727
*/
28-
private $fileList;
28+
private FileList $fileList;
2929

3030
/**
3131
* @var Filesystem
3232
*/
33-
private $filesystem;
33+
private Filesystem $filesystem;
3434

3535
/**
3636
* @var ServiceFactory
3737
*/
38-
private $serviceFactory;
38+
private ServiceFactory $serviceFactory;
3939

4040
/**
4141
* @var array
4242
*/
43-
private static $map = [
43+
private static array $map = [
4444
ServiceInterface::SERVICE_DB => ['db', 'database', 'mysql'],
4545
ServiceInterface::SERVICE_DB_QUOTE => ['mysql-quote'],
4646
ServiceInterface::SERVICE_DB_SALES => ['mysql-sales'],
@@ -67,9 +67,10 @@ public function __construct(
6767
$this->serviceFactory = $serviceFactory;
6868
}
6969

70-
/**
71-
* @inheritDoc
72-
*/
70+
/**
71+
* @inheritDoc
72+
* @throws ConfigurationMismatchException
73+
*/
7374
public function read(): Repository
7475
{
7576
$appConfigFile = $this->fileList->getAppConfig();

src/Service/ServiceFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ServiceFactory
5252
/**
5353
* @var array
5454
*/
55-
private static $config = [
55+
private static array $config = [
5656
ServiceInterface::SERVICE_PHP_CLI => [
5757
'image' => 'magento/magento-cloud-docker-php',
5858
'pattern' => '%s:%s-cli-%s',
@@ -207,7 +207,7 @@ class ServiceFactory
207207
/**
208208
* @var FileList
209209
*/
210-
private $fileList;
210+
private FileList $fileList;
211211

212212
/**
213213
* @var string
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CloudDocker\Test\Functional\Acceptance;
9+
10+
/**
11+
* @group php84
12+
*/
13+
class ActivemqArtemis84Cest extends ActivemqArtemisCest
14+
{
15+
/**
16+
* Template version for testing
17+
*/
18+
protected const TEMPLATE_VERSION = '2.4.9';
19+
}
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CloudDocker\Test\Functional\Acceptance;
9+
10+
use CliTester;
11+
use Codeception\Example;
12+
use Robo\Exception\TaskException;
13+
14+
/**
15+
* @group php84
16+
*/
17+
class ActivemqArtemisCest extends AbstractCest
18+
{
19+
/**
20+
* Template version for testing
21+
*/
22+
protected const TEMPLATE_VERSION = '2.4.9';
23+
24+
/**
25+
* @param CliTester $I
26+
* @param Example $data
27+
* @dataProvider dataProvider
28+
* @return void
29+
* @throws TaskException
30+
*/
31+
public function testActivemqArtemis(CliTester $I, Example $data): void
32+
{
33+
// Create services.yaml with activemq-artemis configuration
34+
$servicesConfig = [
35+
'activemq' => [
36+
'type' => 'activemq-artemis:' . $data['version']
37+
]
38+
];
39+
$I->writeServicesYaml($servicesConfig);
40+
41+
$I->generateDockerCompose($this->buildCommand($data));
42+
$I->replaceImagesWithCustom();
43+
$I->startEnvironment();
44+
45+
// Test that ActiveMQ Artemis container is running and healthy
46+
$I->runDockerComposeCommand('ps');
47+
$I->seeInOutput('activemq-artemis');
48+
$I->seeInOutput('(healthy)');
49+
50+
// Test ActiveMQ Artemis web console accessibility (port 8161)
51+
$I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis.magento2.docker 8161');
52+
$I->seeInOutput(''); // nc returns empty output on success
53+
54+
// Test ActiveMQ Artemis broker port accessibility (port 61616)
55+
$I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis.magento2.docker 61616');
56+
$I->seeInOutput('');
57+
58+
// Test ActiveMQ Artemis STOMP port accessibility (port 61613)
59+
$I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis.magento2.docker 61613');
60+
$I->seeInOutput('');
61+
62+
// Test that ActiveMQ Artemis is accessible through direct host name
63+
$I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis 61616');
64+
$I->seeInOutput('');
65+
66+
// Test ActiveMQ Artemis broker status using artemis CLI
67+
$I->runDockerComposeCommand(
68+
'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue stat --user admin --password admin'
69+
);
70+
$I->seeInOutput('Connection brokerURL');
71+
72+
// Test creating a queue using artemis CLI
73+
$I->runDockerComposeCommand(
74+
'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue create ' .
75+
'--name test.queue --address test.address --routing-type anycast --user admin --password admin'
76+
);
77+
$I->seeInOutput('successfully');
78+
79+
// Test listing queues to verify our test queue was created
80+
$I->runDockerComposeCommand(
81+
'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue stat --user admin --password admin'
82+
);
83+
$I->seeInOutput('test.queue');
84+
85+
// Test sending a message to the queue
86+
$I->runDockerComposeCommand(
87+
'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis producer ' .
88+
'--destination queue://test.queue --message-count 1 --message "Hello ActiveMQ Artemis" ' .
89+
'--user admin --password admin'
90+
);
91+
$I->seeInOutput('Produced: 1 messages');
92+
93+
// Test consuming the message from the queue
94+
$I->runDockerComposeCommand(
95+
'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis consumer ' .
96+
'--destination queue://test.queue --message-count 1 --user admin --password admin'
97+
);
98+
$I->seeInOutput('Hello ActiveMQ Artemis');
99+
100+
// Test broker memory and connection info
101+
$I->runDockerComposeCommand(
102+
'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue stat --user admin --password admin'
103+
);
104+
$I->seeInOutput('CONNECTION_COUNT');
105+
106+
// Test that environment variables are properly set
107+
$I->runDockerComposeCommand('exec -T activemq-artemis env | grep ARTEMIS');
108+
$I->seeInOutput('ARTEMIS_USER=admin');
109+
$I->seeInOutput('ARTEMIS_PASSWORD=admin');
110+
}
111+
112+
/**
113+
* Builds build:compose command from given test data
114+
*
115+
* @param Example $data
116+
* @return string
117+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
118+
*/
119+
private function buildCommand(Example $data): string
120+
{
121+
// Note: $data is not used as ActiveMQ Artemis is configured via services.yaml
122+
// rather than CLI options, but parameter is kept for consistency with other tests
123+
return '--mode=production --no-es --no-os --no-redis --no-valkey';
124+
}
125+
126+
/**
127+
* @return array
128+
*/
129+
protected function dataProvider(): array
130+
{
131+
return [
132+
[
133+
'version' => '2.17',
134+
],
135+
];
136+
}
137+
}

0 commit comments

Comments
 (0)