Skip to content

Commit 7fb5e19

Browse files
committed
added test for Valkey service
1 parent c5e37d9 commit 7fb5e19

File tree

4 files changed

+180
-0
lines changed

4 files changed

+180
-0
lines changed
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 php82
12+
*/
13+
class Valkey82Cest extends ValkeyCest
14+
{
15+
/**
16+
* Template version for testing
17+
*/
18+
protected const TEMPLATE_VERSION = '2.4.6';
19+
}
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 php83
12+
*/
13+
class Valkey83Cest extends ValkeyCest
14+
{
15+
/**
16+
* Template version for testing
17+
*/
18+
protected const TEMPLATE_VERSION = '2.4.7';
19+
}
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 Valkey84Cest extends ValkeyCest
14+
{
15+
/**
16+
* Template version for testing
17+
*/
18+
protected const TEMPLATE_VERSION = '2.4.7';
19+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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 php83
16+
*/
17+
class ValkeyCest extends AbstractCest
18+
{
19+
/**
20+
* Template version for testing
21+
*/
22+
protected const TEMPLATE_VERSION = '2.4.7';
23+
24+
/**
25+
* @param CliTester $I
26+
* @param Example $data
27+
* @dataProvider dataProvider
28+
* @return void
29+
* @throws TaskException
30+
*/
31+
public function testValkey(CliTester $I, Example $data)
32+
{
33+
$I->generateDockerCompose($this->buildCommand($data));
34+
$I->replaceImagesWithCustom();
35+
$I->startEnvironment();
36+
37+
// Test that Valkey is running
38+
$I->runDockerComposeCommand('exec -T valkey ps aux | grep valkey');
39+
$I->seeInOutput('valkey-server');
40+
41+
// Test Valkey connectivity using valkey-cli
42+
$I->runDockerComposeCommand('exec -T valkey valkey-cli ping');
43+
$I->seeInOutput('PONG');
44+
45+
// Test that Valkey is accessible through cache alias
46+
$I->runDockerComposeCommand('exec -T fpm valkey-cli -h cache ping');
47+
$I->seeInOutput('PONG');
48+
49+
// Test that Valkey is accessible through valkey.magento2.docker alias
50+
$I->runDockerComposeCommand('exec -T fpm valkey-cli -h valkey.magento2.docker ping');
51+
$I->seeInOutput('PONG');
52+
53+
// Test basic Valkey functionality
54+
$I->runDockerComposeCommand('exec -T valkey valkey-cli set test_key "test_value"');
55+
$I->seeInOutput('OK');
56+
57+
$I->runDockerComposeCommand('exec -T valkey valkey-cli get test_key');
58+
$I->seeInOutput('test_value');
59+
60+
// Test Valkey info command to verify version
61+
$I->runDockerComposeCommand('exec -T valkey valkey-cli info server');
62+
$I->seeInOutput('valkey_version:' . $data['version']);
63+
64+
// Test that Valkey is running on the expected port
65+
$I->runDockerComposeCommand('exec -T valkey netstat -tlnp | grep 6379');
66+
$I->seeInOutput('6379');
67+
68+
// Test memory usage reporting
69+
$I->runDockerComposeCommand('exec -T valkey valkey-cli info memory');
70+
$I->seeInOutput('used_memory:');
71+
$I->seeInOutput('used_memory_human:');
72+
73+
// Test health check functionality
74+
$I->runDockerComposeCommand('exec -T valkey valkey-cli ping');
75+
$I->seeInOutput('PONG');
76+
77+
// Test data persistence
78+
$I->runDockerComposeCommand('exec -T valkey valkey-cli set persistent_key "persistent_value"');
79+
$I->seeInOutput('OK');
80+
81+
$I->runDockerComposeCommand('exec -T valkey valkey-cli get persistent_key');
82+
$I->seeInOutput('persistent_value');
83+
84+
// Test database operations
85+
$I->runDockerComposeCommand('exec -T valkey valkey-cli dbsize');
86+
$I->seeInOutput('2'); // We should have 2 keys: test_key and persistent_key
87+
88+
// Test that Valkey configuration is accessible
89+
$I->runDockerComposeCommand('exec -T valkey valkey-cli config get save');
90+
$I->seeInOutput('save');
91+
}
92+
93+
/**
94+
* Builds build:compose command from given test data
95+
*
96+
* @param Example $data
97+
* @return string
98+
*/
99+
private function buildCommand(Example $data): string
100+
{
101+
$command = sprintf(
102+
'--mode=production --valkey=%s --no-es --no-os',
103+
$data['version']
104+
);
105+
106+
return $command;
107+
}
108+
109+
/**
110+
* @return array
111+
*/
112+
protected function dataProvider(): array
113+
{
114+
return [
115+
[
116+
'version' => '8.0',
117+
],
118+
[
119+
'version' => '7.2',
120+
],
121+
];
122+
}
123+
}

0 commit comments

Comments
 (0)