Skip to content

[Imported] MCLOUD-6394: Help with running MFTF test generation commands #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Command/BuildCompose.php
Original file line number Diff line number Diff line change
@@ -225,6 +225,11 @@ protected function configure(): void
null,
InputOption::VALUE_NONE,
'Add Selenium latest version'
)->addOption(
Source\CliSource::OPTION_WITH_TEST,
null,
InputOption::VALUE_NONE,
'Add container for tests running'
)->addOption(
Source\CliSource::OPTION_NO_TMP_MOUNTS,
null,
9 changes: 6 additions & 3 deletions src/Compose/ProductionBuilder.php
Original file line number Diff line number Diff line change
@@ -140,8 +140,8 @@ public function build(Config $config): Manager
$manager->addNetwork(self::NETWORK_MAGENTO_BUILD, ['driver' => 'bridge']);

$mounts = $config->getMounts();
$hasSelenium = $config->hasSelenium();
$hasTmpMounts = $config->hasTmpMounts();
$hasTest = $config->hasServiceEnabled(ServiceInterface::SERVICE_TEST);

$hasGenerated = !version_compare($config->getMagentoVersion(), '2.2.0', '<');
$volumes = [];
@@ -163,13 +163,13 @@ public function build(Config $config): Manager
));
$volumesRo = $this->volumeResolver->normalize(array_merge(
$this->volumeResolver->getRootVolume(true),
$this->volumeResolver->getDevVolumes($hasSelenium),
$this->volumeResolver->getDevVolumes($hasTest),
$this->volumeResolver->getMagentoVolumes($mounts, true, $hasGenerated),
$this->volumeResolver->getMountVolumes($hasTmpMounts)
));
$volumesRw = $this->volumeResolver->normalize(array_merge(
$this->volumeResolver->getRootVolume(false),
$this->volumeResolver->getDevVolumes($hasSelenium),
$this->volumeResolver->getDevVolumes($hasTest),
$this->volumeResolver->getMagentoVolumes($mounts, false, $hasGenerated),
$this->volumeResolver->getMountVolumes($hasTmpMounts),
$this->volumeResolver->getComposerVolumes()
@@ -294,6 +294,9 @@ public function build(Config $config): Manager
[self::NETWORK_MAGENTO],
[self::SERVICE_WEB => []]
);
}

if ($hasTest) {
$manager->addService(
self::SERVICE_TEST,
$this->serviceFactory->create(
6 changes: 3 additions & 3 deletions src/Compose/ProductionBuilder/VolumeResolver.php
Original file line number Diff line number Diff line change
@@ -28,12 +28,12 @@ public function getRootVolume(bool $isReadOnly): array
}

/**
* @param bool $hasSelenium
* @param bool $hasTest
* @return array
*/
public function getDevVolumes(bool $hasSelenium): array
public function getDevVolumes(bool $hasTest): array
{
if ($hasSelenium) {
if ($hasTest) {
return [
BuilderInterface::VOLUME_MAGENTO_DEV => [
'path' => BuilderInterface::DIR_MAGENTO . '/dev',
2 changes: 1 addition & 1 deletion src/Config/Config.php
Original file line number Diff line number Diff line change
@@ -337,7 +337,7 @@ public function getVariables(): array
{
$config = $this->all();

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

7 changes: 7 additions & 0 deletions src/Config/Source/CliSource.php
Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@ class CliSource implements SourceInterface
public const OPTION_WITH_CRON = 'with-cron';
public const OPTION_NO_VARNISH = 'no-varnish';
public const OPTION_WITH_SELENIUM = 'with-selenium';
public const OPTION_WITH_TEST = 'with-test';
public const OPTION_NO_TMP_MOUNTS = 'no-tmp-mounts';
public const OPTION_SYNC_ENGINE = 'sync-engine';
public const OPTION_WITH_XDEBUG = 'with-xdebug';
@@ -189,6 +190,12 @@ public function read(): Repository
]);
}

if ($this->input->getOption(self::OPTION_WITH_TEST)) {
$repository->set([
self::SERVICES_TEST_ENABLED => true
]);
}

if ($seleniumImage = $this->input->getOption(self::OPTION_SELENIUM_IMAGE)) {
$repository->set([
self::SERVICES_SELENIUM_ENABLED => true,
7 changes: 2 additions & 5 deletions src/Config/Source/SourceInterface.php
Original file line number Diff line number Diff line change
@@ -29,21 +29,18 @@ interface SourceInterface
* Selenium
*/
public const SERVICES_SELENIUM = self::SERVICES . '.' . ServiceInterface::SERVICE_SELENIUM;
public const SERVICES_TEST = self::SERVICES . '.' . ServiceInterface::SERVICE_TEST;
public const SERVICES_SELENIUM_VERSION = self::SERVICES_SELENIUM . '.version';
public const SERVICES_SELENIUM_IMAGE = self::SERVICES_SELENIUM . '.image';
public const SERVICES_SELENIUM_ENABLED = self::SERVICES_SELENIUM . '.enabled';
public const SERVICES_TEST_ENABLED = self::SERVICES_TEST . '.enabled';

/**
* Varnish
*/
public const SERVICES_VARNISH = self::SERVICES . '.' . ServiceInterface::SERVICE_VARNISH;
public const SERVICES_VARNISH_ENABLED = self::SERVICES_VARNISH . '.enabled';

/**
* TLS
*/
public const SERVICES_TLS = self::SERVICES . '.' . ServiceInterface::SERVICE_TLS;

/**
* DB
*/
1 change: 1 addition & 0 deletions src/Service/ServiceInterface.php
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ interface ServiceInterface
public const SERVICE_NODE = 'node';
public const SERVICE_VARNISH = 'varnish';
public const SERVICE_SELENIUM = 'selenium';
public const SERVICE_TEST = 'test';
public const SERVICE_TLS = 'tls';
public const SERVICE_GENERIC = 'generic';
public const SERVICE_BLACKFIRE = 'blackfire';
18 changes: 18 additions & 0 deletions src/Test/Integration/BuildComposeTest.php
Original file line number Diff line number Diff line change
@@ -84,6 +84,24 @@ public function buildDataProvider(): array
[
[CliSource::OPTION_MODE, BuilderFactory::BUILDER_PRODUCTION],
[CliSource::OPTION_WITH_SELENIUM, true],
[CliSource::OPTION_WITH_TEST, true],
[CliSource::OPTION_WITH_CRON, true],
[CliSource::OPTION_WITH_XDEBUG, true],
[CliSource::OPTION_ES, '5.2'],
[CliSource::OPTION_NO_ES, true],
[CliSource::OPTION_DB_INCREMENT_INCREMENT, 3],
[CliSource::OPTION_DB_INCREMENT_OFFSET, 2],
[CliSource::OPTION_WITH_ENTRYPOINT, true],
[CliSource::OPTION_WITH_MARIADB_CONF, true],
[CliSource::OPTION_TLS_PORT, '4443'],
[CliSource::OPTION_NO_MAILHOG, true]
]
],
'cloud-base-test' => [
__DIR__ . '/_files/cloud_base_test',
[
[CliSource::OPTION_MODE, BuilderFactory::BUILDER_PRODUCTION],
[CliSource::OPTION_WITH_TEST, true],
[CliSource::OPTION_WITH_CRON, true],
[CliSource::OPTION_WITH_XDEBUG, true],
[CliSource::OPTION_ES, '5.2'],
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

return [
'MAGENTO_CLOUD_RELATIONSHIPS' => base64_encode(json_encode([
'database' => [
[
'host' => 'db',
'path' => 'magento2',
'password' => 'magento2',
'username' => 'magento2',
'port' => '3306'
]
],
'redis' => [
[
'host' => 'redis',
'port' => '6379'
]
]
])),
'MAGENTO_CLOUD_ROUTES' => base64_encode(json_encode([
'http://magento2.docker/' => [
'type' => 'upstream',
'original_url' => 'http://{default}'
],
'https://magento2.docker/' => [
'type' => 'upstream',
'original_url' => 'https://{default}'
]
])),
'MAGENTO_CLOUD_VARIABLES' => base64_encode(json_encode([
'ADMIN_EMAIL' => '[email protected]',
'ADMIN_PASSWORD' => '123123q',
'ADMIN_URL' => 'admin'
])),
'MAGENTO_CLOUD_APPLICATION' => base64_encode(json_encode([
'hooks' => [

]
])),
];
29 changes: 29 additions & 0 deletions src/Test/Integration/_files/cloud_base_test/.magento.app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: mymagento

type: php:7.3
build:
flavor: composer

runtime:
extensions:
- redis
- xsl
- json
- newrelic
- sodium

relationships:
database: "mysql:mysql"
redis: "redis:redis"
elasticsearch: "elasticsearch:elasticsearch"

mounts:
"var": "shared:files/var"
"app/etc": "shared:files/etc"
"pub/media": "shared:files/media"
"pub/static": "shared:files/static"

crons:
cronrun:
spec: "* * * * *"
cmd: "php bin/magento cron:run"
10 changes: 10 additions & 0 deletions src/Test/Integration/_files/cloud_base_test/.magento/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mysql:
type: mysql:10.2
disk: 2048

redis:
type: redis:5.0

elasticsearch:
type: elasticsearch:6.5
disk: 1024
6 changes: 6 additions & 0 deletions src/Test/Integration/_files/cloud_base_test/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "magento/project-enterprise-edition",
"description": "Composer file for integration tests",
"type": "project",
"version": "2.3.0"
}
Loading