Skip to content

Commit 2506a15

Browse files
MCLOUD-6394: Help with running MFTF test generation commands (#1)
1 parent bc964b2 commit 2506a15

File tree

14 files changed

+375
-12
lines changed

14 files changed

+375
-12
lines changed

src/Command/BuildCompose.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ protected function configure(): void
225225
null,
226226
InputOption::VALUE_NONE,
227227
'Add Selenium latest version'
228+
)->addOption(
229+
Source\CliSource::OPTION_WITH_TEST,
230+
null,
231+
InputOption::VALUE_NONE,
232+
'Add container for tests running'
228233
)->addOption(
229234
Source\CliSource::OPTION_NO_TMP_MOUNTS,
230235
null,

src/Compose/ProductionBuilder.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ public function build(Config $config): Manager
140140
$manager->addNetwork(self::NETWORK_MAGENTO_BUILD, ['driver' => 'bridge']);
141141

142142
$mounts = $config->getMounts();
143-
$hasSelenium = $config->hasSelenium();
144143
$hasTmpMounts = $config->hasTmpMounts();
144+
$hasTest = $config->hasServiceEnabled(ServiceInterface::SERVICE_TEST);
145145

146146
$hasGenerated = !version_compare($config->getMagentoVersion(), '2.2.0', '<');
147147
$volumes = [];
@@ -163,13 +163,13 @@ public function build(Config $config): Manager
163163
));
164164
$volumesRo = $this->volumeResolver->normalize(array_merge(
165165
$this->volumeResolver->getRootVolume(true),
166-
$this->volumeResolver->getDevVolumes($hasSelenium),
166+
$this->volumeResolver->getDevVolumes($hasTest),
167167
$this->volumeResolver->getMagentoVolumes($mounts, true, $hasGenerated),
168168
$this->volumeResolver->getMountVolumes($hasTmpMounts)
169169
));
170170
$volumesRw = $this->volumeResolver->normalize(array_merge(
171171
$this->volumeResolver->getRootVolume(false),
172-
$this->volumeResolver->getDevVolumes($hasSelenium),
172+
$this->volumeResolver->getDevVolumes($hasTest),
173173
$this->volumeResolver->getMagentoVolumes($mounts, false, $hasGenerated),
174174
$this->volumeResolver->getMountVolumes($hasTmpMounts),
175175
$this->volumeResolver->getComposerVolumes()
@@ -294,6 +294,9 @@ public function build(Config $config): Manager
294294
[self::NETWORK_MAGENTO],
295295
[self::SERVICE_WEB => []]
296296
);
297+
}
298+
299+
if ($hasTest) {
297300
$manager->addService(
298301
self::SERVICE_TEST,
299302
$this->serviceFactory->create(

src/Compose/ProductionBuilder/VolumeResolver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public function getRootVolume(bool $isReadOnly): array
2828
}
2929

3030
/**
31-
* @param bool $hasSelenium
31+
* @param bool $hasTest
3232
* @return array
3333
*/
34-
public function getDevVolumes(bool $hasSelenium): array
34+
public function getDevVolumes(bool $hasTest): array
3535
{
36-
if ($hasSelenium) {
36+
if ($hasTest) {
3737
return [
3838
BuilderInterface::VOLUME_MAGENTO_DEV => [
3939
'path' => BuilderInterface::DIR_MAGENTO . '/dev',

src/Config/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ public function getVariables(): array
337337
{
338338
$config = $this->all();
339339

340-
if ($this->hasSelenium()) {
340+
if ($this->hasServiceEnabled(ServiceInterface::SERVICE_TEST)) {
341341
$config->set(SourceInterface::VARIABLES . '.' . 'MFTF_UTILS', 1);
342342
}
343343

src/Config/Source/CliSource.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class CliSource implements SourceInterface
4848
public const OPTION_WITH_CRON = 'with-cron';
4949
public const OPTION_NO_VARNISH = 'no-varnish';
5050
public const OPTION_WITH_SELENIUM = 'with-selenium';
51+
public const OPTION_WITH_TEST = 'with-test';
5152
public const OPTION_NO_TMP_MOUNTS = 'no-tmp-mounts';
5253
public const OPTION_SYNC_ENGINE = 'sync-engine';
5354
public const OPTION_WITH_XDEBUG = 'with-xdebug';
@@ -189,6 +190,12 @@ public function read(): Repository
189190
]);
190191
}
191192

193+
if ($this->input->getOption(self::OPTION_WITH_TEST)) {
194+
$repository->set([
195+
self::SERVICES_TEST_ENABLED => true
196+
]);
197+
}
198+
192199
if ($seleniumImage = $this->input->getOption(self::OPTION_SELENIUM_IMAGE)) {
193200
$repository->set([
194201
self::SERVICES_SELENIUM_ENABLED => true,

src/Config/Source/SourceInterface.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,18 @@ interface SourceInterface
2929
* Selenium
3030
*/
3131
public const SERVICES_SELENIUM = self::SERVICES . '.' . ServiceInterface::SERVICE_SELENIUM;
32+
public const SERVICES_TEST = self::SERVICES . '.' . ServiceInterface::SERVICE_TEST;
3233
public const SERVICES_SELENIUM_VERSION = self::SERVICES_SELENIUM . '.version';
3334
public const SERVICES_SELENIUM_IMAGE = self::SERVICES_SELENIUM . '.image';
3435
public const SERVICES_SELENIUM_ENABLED = self::SERVICES_SELENIUM . '.enabled';
36+
public const SERVICES_TEST_ENABLED = self::SERVICES_TEST . '.enabled';
3537

3638
/**
3739
* Varnish
3840
*/
3941
public const SERVICES_VARNISH = self::SERVICES . '.' . ServiceInterface::SERVICE_VARNISH;
4042
public const SERVICES_VARNISH_ENABLED = self::SERVICES_VARNISH . '.enabled';
4143

42-
/**
43-
* TLS
44-
*/
45-
public const SERVICES_TLS = self::SERVICES . '.' . ServiceInterface::SERVICE_TLS;
46-
4744
/**
4845
* DB
4946
*/

src/Service/ServiceInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ interface ServiceInterface
2828
public const SERVICE_NODE = 'node';
2929
public const SERVICE_VARNISH = 'varnish';
3030
public const SERVICE_SELENIUM = 'selenium';
31+
public const SERVICE_TEST = 'test';
3132
public const SERVICE_TLS = 'tls';
3233
public const SERVICE_GENERIC = 'generic';
3334
public const SERVICE_BLACKFIRE = 'blackfire';

src/Test/Integration/BuildComposeTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ public function buildDataProvider(): array
8484
[
8585
[CliSource::OPTION_MODE, BuilderFactory::BUILDER_PRODUCTION],
8686
[CliSource::OPTION_WITH_SELENIUM, true],
87+
[CliSource::OPTION_WITH_TEST, true],
88+
[CliSource::OPTION_WITH_CRON, true],
89+
[CliSource::OPTION_WITH_XDEBUG, true],
90+
[CliSource::OPTION_ES, '5.2'],
91+
[CliSource::OPTION_NO_ES, true],
92+
[CliSource::OPTION_DB_INCREMENT_INCREMENT, 3],
93+
[CliSource::OPTION_DB_INCREMENT_OFFSET, 2],
94+
[CliSource::OPTION_WITH_ENTRYPOINT, true],
95+
[CliSource::OPTION_WITH_MARIADB_CONF, true],
96+
[CliSource::OPTION_TLS_PORT, '4443'],
97+
[CliSource::OPTION_NO_MAILHOG, true]
98+
]
99+
],
100+
'cloud-base-test' => [
101+
__DIR__ . '/_files/cloud_base_test',
102+
[
103+
[CliSource::OPTION_MODE, BuilderFactory::BUILDER_PRODUCTION],
104+
[CliSource::OPTION_WITH_TEST, true],
87105
[CliSource::OPTION_WITH_CRON, true],
88106
[CliSource::OPTION_WITH_XDEBUG, true],
89107
[CliSource::OPTION_ES, '5.2'],

src/Test/Integration/_files/cloud_base_test/.docker/.gitignore

Whitespace-only changes.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
return [
4+
'MAGENTO_CLOUD_RELATIONSHIPS' => base64_encode(json_encode([
5+
'database' => [
6+
[
7+
'host' => 'db',
8+
'path' => 'magento2',
9+
'password' => 'magento2',
10+
'username' => 'magento2',
11+
'port' => '3306'
12+
]
13+
],
14+
'redis' => [
15+
[
16+
'host' => 'redis',
17+
'port' => '6379'
18+
]
19+
]
20+
])),
21+
'MAGENTO_CLOUD_ROUTES' => base64_encode(json_encode([
22+
'http://magento2.docker/' => [
23+
'type' => 'upstream',
24+
'original_url' => 'http://{default}'
25+
],
26+
'https://magento2.docker/' => [
27+
'type' => 'upstream',
28+
'original_url' => 'https://{default}'
29+
]
30+
])),
31+
'MAGENTO_CLOUD_VARIABLES' => base64_encode(json_encode([
32+
'ADMIN_EMAIL' => '[email protected]',
33+
'ADMIN_PASSWORD' => '123123q',
34+
'ADMIN_URL' => 'admin'
35+
])),
36+
'MAGENTO_CLOUD_APPLICATION' => base64_encode(json_encode([
37+
'hooks' => [
38+
39+
]
40+
])),
41+
];

0 commit comments

Comments
 (0)