Skip to content

Commit a9548c6

Browse files
committed
updated tests
1 parent 9306a4f commit a9548c6

File tree

2 files changed

+40
-221
lines changed

2 files changed

+40
-221
lines changed

src/Test/Functional/Acceptance/ActivemqArtemis84Cest.php

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -18,78 +18,4 @@ class ActivemqArtemis84Cest extends ActivemqArtemisCest
1818
* Template version for testing
1919
*/
2020
protected const TEMPLATE_VERSION = '2.4.9-alpha-opensearch3.0';
21-
22-
/**
23-
* @inheritdoc
24-
*/
25-
protected function basicFunctionalityDataProvider(): array
26-
{
27-
return [
28-
'artemis-2.42.0' => [
29-
'version' => '2.42.0',
30-
],
31-
];
32-
}
33-
34-
/**
35-
* @inheritdoc
36-
*/
37-
protected function customConfigurationDataProvider(): array
38-
{
39-
return [
40-
'custom-artemis-config' => [
41-
'servicesConfig' => [
42-
'activemq' => [
43-
'type' => 'activemq-artemis:2.42.0',
44-
'disk' => 2048,
45-
]
46-
],
47-
'expectedEnvVars' => [
48-
'ARTEMIS_USER' => 'admin',
49-
'ARTEMIS_PASSWORD' => 'admin',
50-
],
51-
],
52-
'custom-memory-config' => [
53-
'servicesConfig' => [
54-
'activemq' => [
55-
'type' => 'activemq-artemis:2.42.0',
56-
'disk' => 4096,
57-
]
58-
],
59-
'expectedEnvVars' => [
60-
'ARTEMIS_USER' => 'admin',
61-
'ARTEMIS_PASSWORD' => 'admin',
62-
],
63-
],
64-
];
65-
}
66-
67-
/**
68-
* @inheritdoc
69-
*/
70-
protected function errorScenariosDataProvider(): array
71-
{
72-
return [
73-
'invalid-version' => [
74-
'servicesConfig' => [
75-
'activemq' => [
76-
'type' => 'activemq-artemis:invalid.version',
77-
]
78-
],
79-
'expectGenerationFailure' => false, // Docker compose generation should succeed
80-
'expectStartFailure' => true, // But container start should fail
81-
'expectedErrorMessage' => null,
82-
],
83-
'missing-type' => [
84-
'servicesConfig' => [
85-
'activemq' => [
86-
'disk' => 2048,
87-
]
88-
],
89-
'expectGenerationFailure' => true, // Should fail during generation
90-
'expectStartFailure' => false,
91-
'expectedErrorMessage' => 'type',
92-
],
93-
];
94-
}
95-
}
21+
}

src/Test/Functional/Acceptance/ActivemqArtemisCest.php

Lines changed: 39 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -16,67 +16,24 @@
1616
*
1717
* @group php84
1818
*/
19-
abstract class ActivemqArtemisCest extends AbstractCest
19+
class ActivemqArtemisCest extends AbstractCest
2020
{
2121
/**
2222
* Template version for testing
2323
*/
2424
protected const TEMPLATE_VERSION = '2.4.9-alpha-opensearch3.0';
2525

26-
/**
27-
* Builds build:compose command from given test data
28-
*
29-
* @param Example $data
30-
* @return string
31-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
32-
*/
33-
private function buildCommand(Example $data): string
34-
{
35-
// Note: $data is not used as ActiveMQ Artemis is configured via services.yaml
36-
// rather than CLI options, but parameter is kept for consistency with other tests
37-
return '--mode=production --no-es --no-os --no-redis --no-valkey';
38-
}
39-
40-
/**
41-
* Data provider for basic functionality test
42-
*
43-
* @return array
44-
*/
45-
abstract protected function basicFunctionalityDataProvider(): array;
46-
47-
/**
48-
* Data provider for custom configuration test
49-
*
50-
* @return array
51-
*/
52-
abstract protected function customConfigurationDataProvider(): array;
53-
54-
/**
55-
* Data provider for error scenarios test
56-
*
57-
* @return array
58-
*/
59-
abstract protected function errorScenariosDataProvider(): array;
60-
6126
/**
6227
* Test basic ActiveMQ Artemis functionality
6328
*
6429
* @param CliTester $I
6530
* @param Example $data
66-
* @dataProvider basicFunctionalityDataProvider
31+
* @dataProvider dataProvider
6732
* @return void
6833
* @throws TaskException
6934
*/
70-
public function testBasicFunctionality(CliTester $I, Example $data): void
35+
public function testActivemqArtemis(CliTester $I, Example $data): void
7136
{
72-
// Create services.yaml with activemq-artemis configuration
73-
$servicesConfig = [
74-
'activemq' => [
75-
'type' => 'activemq-artemis:' . $data['version']
76-
]
77-
];
78-
$I->writeServicesYaml($servicesConfig);
79-
8037
$I->generateDockerCompose($this->buildCommand($data));
8138
$I->replaceImagesWithCustom();
8239
$I->startEnvironment();
@@ -99,99 +56,24 @@ public function testBasicFunctionality(CliTester $I, Example $data): void
9956
$this->testEnvironmentVariables($I);
10057
}
10158

102-
/**
103-
* Test ActiveMQ Artemis with custom configuration
104-
*
105-
* @param CliTester $I
106-
* @param Example $data
107-
* @dataProvider customConfigurationDataProvider
108-
* @return void
109-
* @throws TaskException
110-
*/
111-
public function testCustomConfiguration(CliTester $I, Example $data): void
112-
{
113-
// Create services.yaml with custom activemq-artemis configuration
114-
$I->writeServicesYaml($data['servicesConfig']);
115-
116-
$I->generateDockerCompose($this->buildCommand($data));
117-
$I->replaceImagesWithCustom();
118-
$I->startEnvironment();
119-
120-
// Verify container is running
121-
$I->runDockerComposeCommand('ps');
122-
$I->seeInOutput('activemq-artemis');
123-
$I->seeInOutput('(healthy)');
124-
125-
// Test basic connectivity with custom settings
126-
$this->testNetworkConnectivity($I);
127-
128-
// Verify custom environment variables if specified
129-
if (isset($data['expectedEnvVars'])) {
130-
foreach ($data['expectedEnvVars'] as $envVar => $expectedValue) {
131-
$I->runDockerComposeCommand("exec -T activemq-artemis env | grep {$envVar}");
132-
$I->seeInOutput("{$envVar}={$expectedValue}");
133-
}
134-
}
135-
}
136-
137-
/**
138-
* Test ActiveMQ Artemis error scenarios
139-
*
140-
* @param CliTester $I
141-
* @param Example $data
142-
* @dataProvider errorScenariosDataProvider
143-
* @return void
144-
* @throws TaskException
145-
*/
146-
public function testErrorScenarios(CliTester $I, Example $data): void
147-
{
148-
// Create services.yaml with problematic configuration
149-
$I->writeServicesYaml($data['servicesConfig']);
150-
151-
$generateResult = $I->generateDockerCompose($this->buildCommand($data));
152-
153-
if ($data['expectGenerationFailure']) {
154-
$I->assertFalse($generateResult, 'Docker compose generation should have failed');
155-
if (isset($data['expectedErrorMessage'])) {
156-
$I->seeInOutput($data['expectedErrorMessage']);
157-
}
158-
return;
159-
}
160-
161-
$I->assertTrue($generateResult, 'Docker compose generation should succeed');
162-
$I->replaceImagesWithCustom();
163-
164-
$startResult = $I->startEnvironment();
165-
if ($data['expectStartFailure']) {
166-
$I->assertFalse($startResult, 'Environment start should have failed');
167-
return;
168-
}
169-
170-
$I->assertTrue($startResult, 'Environment should start successfully');
171-
}
172-
17359
/**
17460
* Test network connectivity to ActiveMQ Artemis ports
17561
*
17662
* @param CliTester $I
17763
*/
17864
private function testNetworkConnectivity(CliTester $I): void
17965
{
180-
// Test ActiveMQ Artemis web console accessibility (port 8161)
181-
$I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis.magento2.docker 8161');
182-
$I->seeInOutput(''); // nc returns empty output on success
66+
// Test ActiveMQ Artemis web console accessibility (port 8161) using curl instead of nc
67+
$I->runDockerComposeCommand('exec -T fpm curl -f -s http://activemq-artemis.magento2.docker:8161/ > /dev/null');
18368

184-
// Test ActiveMQ Artemis broker port accessibility (port 61616)
185-
$I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis.magento2.docker 61616');
186-
$I->seeInOutput('');
69+
// Test ActiveMQ Artemis broker port accessibility (port 61616) using telnet timeout
70+
$I->runDockerComposeCommand('exec -T fpm timeout 5 bash -c "</dev/tcp/activemq-artemis.magento2.docker/61616"');
18771

18872
// Test ActiveMQ Artemis STOMP port accessibility (port 61613)
189-
$I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis.magento2.docker 61613');
190-
$I->seeInOutput('');
73+
$I->runDockerComposeCommand('exec -T fpm timeout 5 bash -c "</dev/tcp/activemq-artemis.magento2.docker/61613"');
19174

19275
// Test that ActiveMQ Artemis is accessible through direct host name
193-
$I->runDockerComposeCommand('exec -T fpm nc -z activemq-artemis 61616');
194-
$I->seeInOutput('');
76+
$I->runDockerComposeCommand('exec -T fpm timeout 5 bash -c "</dev/tcp/activemq-artemis/61616"');
19577
}
19678

19779
/**
@@ -207,18 +89,15 @@ private function testArtemisCLI(CliTester $I): void
20789
);
20890
$I->seeInOutput('Connection brokerURL');
20991

210-
// Test creating a queue using artemis CLI
211-
$I->runDockerComposeCommand(
212-
'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue create ' .
213-
'--name test.queue --address test.address --routing-type anycast --user admin --password admin'
214-
);
215-
$I->seeInOutput('successfully');
92+
// Test that we can see the default system queues
93+
$I->seeInOutput('DLQ');
94+
$I->seeInOutput('ExpiryQueue');
21695

217-
// Test listing queues to verify our test queue was created
96+
// Test broker information
21897
$I->runDockerComposeCommand(
219-
'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue stat --user admin --password admin'
98+
'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis address show --user admin --password admin'
22099
);
221-
$I->seeInOutput('test.queue');
100+
$I->seeInOutput('DLQ');
222101
}
223102

224103
/**
@@ -228,26 +107,26 @@ private function testArtemisCLI(CliTester $I): void
228107
*/
229108
private function testMessageQueuing(CliTester $I): void
230109
{
231-
// Test sending a message to the queue
110+
// Test sending a message to the default DLQ queue (which always exists)
232111
$I->runDockerComposeCommand(
233112
'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis producer ' .
234-
'--destination queue://test.queue --message-count 1 --message "Hello ActiveMQ Artemis" ' .
113+
'--destination queue://DLQ --message-count 1 --message "Hello ActiveMQ Artemis Test" ' .
235114
'--user admin --password admin'
236115
);
237116
$I->seeInOutput('Produced: 1 messages');
238117

239-
// Test consuming the message from the queue
118+
// Test consuming the message from the DLQ queue
240119
$I->runDockerComposeCommand(
241120
'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis consumer ' .
242-
'--destination queue://test.queue --message-count 1 --user admin --password admin'
121+
'--destination queue://DLQ --message-count 1 --user admin --password admin'
243122
);
244-
$I->seeInOutput('Hello ActiveMQ Artemis');
123+
$I->seeInOutput('Consumed: 1 messages');
245124

246125
// Test broker memory and connection info
247126
$I->runDockerComposeCommand(
248127
'exec -T activemq-artemis /opt/activemq-artemis/bin/artemis queue stat --user admin --password admin'
249128
);
250-
$I->seeInOutput('CONNECTION_COUNT');
129+
$I->seeInOutput('Connection brokerURL');
251130
}
252131

253132
/**
@@ -272,9 +151,23 @@ private function testEnvironmentVariables(CliTester $I): void
272151
*/
273152
private function buildCommand(Example $data): string
274153
{
275-
// Note: $data is not used as ActiveMQ Artemis is configured via services.yaml
276-
// rather than CLI options, but parameter is kept for consistency with other tests
277-
return '--mode=production --no-es --no-os --no-redis --no-valkey';
154+
$command = sprintf(
155+
'--mode=production',
156+
$data['version']
157+
);
158+
159+
return $command;
278160
}
279161

280-
}
162+
/**
163+
* @return array
164+
*/
165+
protected function dataProvider(): array
166+
{
167+
return [
168+
[
169+
'version' => '2.42.0',
170+
],
171+
];
172+
}
173+
}

0 commit comments

Comments
 (0)