|
| 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