|
| 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 php82 |
| 16 | + */ |
| 17 | +class Elasticsearch82Cest extends ElasticsearchCest |
| 18 | +{ |
| 19 | + /** |
| 20 | + * Template version for testing |
| 21 | + */ |
| 22 | + protected const TEMPLATE_VERSION = '2.4.6'; |
| 23 | + |
| 24 | + /** |
| 25 | + * @param CliTester $I |
| 26 | + * @param Example $data |
| 27 | + * @dataProvider dataProvider |
| 28 | + * @return void |
| 29 | + * @throws TaskException |
| 30 | + */ |
| 31 | + public function testElasticsearch(CliTester $I, Example $data) |
| 32 | + { |
| 33 | + $I->generateDockerCompose($this->buildCommand($data)); |
| 34 | + $I->replaceImagesWithCustom(); |
| 35 | + $I->startEnvironment(); |
| 36 | + if (!empty($data['plugins'])) { |
| 37 | + $I->runDockerComposeCommand('logs elasticsearch'); |
| 38 | + foreach ($data['plugins'] as $plugin) { |
| 39 | + $I->seeInOutput($plugin); |
| 40 | + } |
| 41 | + } |
| 42 | + $I->runDockerComposeCommand('exec -T elasticsearch ps aux | grep elasticsearch'); |
| 43 | + $I->seeInOutput('-Xms' . $data['xms']); |
| 44 | + $I->seeInOutput('-Xmx' . $data['xmx']); |
| 45 | + |
| 46 | + if (!empty($data['param'])) { |
| 47 | + $I->runDockerComposeCommand('exec -T elasticsearch curl http://localhost:9200/_nodes/settings'); |
| 48 | + $I->seeInOutput($data['param']['needle']); |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Builds build:compose command from given test data |
| 54 | + * |
| 55 | + * @param Example $data |
| 56 | + * @return string |
| 57 | + */ |
| 58 | + private function buildCommand(Example $data): string |
| 59 | + { |
| 60 | + $command = sprintf( |
| 61 | + '--mode=production --es=%s --es-env-var="ES_JAVA_OPTS=-Xms%s -Xmx%s" --no-os', |
| 62 | + $data['version'], |
| 63 | + $data['xms'], |
| 64 | + $data['xmx'] |
| 65 | + ); |
| 66 | + |
| 67 | + if (!empty($data['param'])) { |
| 68 | + $command .= " --es-env-var={$data['param']['key']}={$data['param']['value']}"; |
| 69 | + } |
| 70 | + if (!empty($data['plugins'])) { |
| 71 | + $command .= sprintf(' --es-env-var="ES_PLUGINS=%s"', implode(' ', $data['plugins'])); |
| 72 | + } |
| 73 | + |
| 74 | + return $command; |
| 75 | + } |
| 76 | + |
| 77 | + /** |
| 78 | + * @return array |
| 79 | + */ |
| 80 | + protected function dataProvider(): array |
| 81 | + { |
| 82 | + return [ |
| 83 | + [ |
| 84 | + 'version' => '7.10', |
| 85 | + 'xms' => '520m', |
| 86 | + 'xmx' => '520m', |
| 87 | + 'plugins' => ['analysis-nori'], |
| 88 | + 'param' => [ |
| 89 | + 'key' => 'node.store.allow_mmap', |
| 90 | + 'value' => 'false', |
| 91 | + 'needle' => '"store":{"allow_mmap":"false"}', |
| 92 | + ] |
| 93 | + ], |
| 94 | + ]; |
| 95 | + } |
| 96 | +} |
0 commit comments