Skip to content
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

MAGECLOUD-4486: Docker functional tests and CI with ece-tools test framework #656

Merged
merged 38 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e942f4d
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Dec 19, 2019
4d2a8ce
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Jan 27, 2020
2be531c
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Jan 29, 2020
d507249
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Jan 30, 2020
c96c138
Merge remote-tracking branch 'origin/develop' into MAGECLOUD-4486
BaDos Jan 30, 2020
d76a305
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Jan 30, 2020
6439673
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Jan 30, 2020
973fa64
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 10, 2020
4fa0b40
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 10, 2020
38f8ad5
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 11, 2020
fff558d
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 12, 2020
04b276b
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 12, 2020
7cabfc8
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 12, 2020
4513cbf
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 13, 2020
686db60
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 13, 2020
60085cb
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 13, 2020
2d56d71
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 13, 2020
75815c4
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 13, 2020
0b0141a
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 13, 2020
01b3475
Merge remote-tracking branch 'origin/develop' into MAGECLOUD-4486
BaDos Feb 13, 2020
e8b61ae
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 13, 2020
39840d8
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 14, 2020
40c2c86
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 14, 2020
2c4ca43
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 14, 2020
9cdefbd
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 14, 2020
052ae90
Merge remote-tracking branch 'origin/develop' into MAGECLOUD-4486
BaDos Feb 26, 2020
942920d
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 26, 2020
2a46434
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 26, 2020
f955b66
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 26, 2020
6bf3b62
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Feb 28, 2020
0c561cf
Merge remote-tracking branch 'origin/develop' into MAGECLOUD-4486
BaDos Feb 28, 2020
e1db817
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Mar 2, 2020
b32b38f
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Mar 2, 2020
84e467b
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Mar 4, 2020
221b78d
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Mar 4, 2020
b07c658
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Mar 4, 2020
b46152c
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Mar 4, 2020
6c40632
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test fr…
BaDos Mar 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/docker-compose.yml
/auth.json
/codeception.yml
/_workdir
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dist: xenial
dist: bionic

addons:
hosts:
Expand Down Expand Up @@ -86,10 +86,7 @@ install:
- composer update -n --no-suggest

before_script:
- if [ $TEST_SUITE == "functional-ce" ]; then echo "COMPOSER_MAGENTO_USERNAME=${REPO_USERNAME_CE}" >> ./.docker/composer.env && echo "COMPOSER_MAGENTO_PASSWORD=${REPO_PASSWORD_CE}" >> ./.docker/composer.env; fi;
- if [ $TEST_SUITE == "functional-ee" ]; then echo "COMPOSER_MAGENTO_USERNAME=${REPO_USERNAME}" >> ./.docker/composer.env && echo "COMPOSER_MAGENTO_PASSWORD=${REPO_PASSWORD}" >> ./.docker/composer.env; fi;
- echo "COMPOSER_GITHUB_TOKEN=${GITHUB_TOKEN}" >> ./.docker/composer.env
- if [ $XDEBUG == "true" ]; then echo "PHP_ENABLE_XDEBUG=true" >> ./.docker/global.env; fi;
- if [ $TEST_SUITE == "functional-ce" ]; then cp codeception.dist.yml codeception.yml && sed -i "s/REPO_USERNAME/REPO_USERNAME_CE/" codeception.yml && sed -i "s/REPO_PASSWORD/REPO_PASSWORD_CE/" codeception.yml; fi;

script:
- if [ $TEST_SUITE == "functional-ce" ]; then ./tests/travis/functional_ce.sh; fi;
Expand Down
33 changes: 16 additions & 17 deletions codeception.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ paths:
tests: src/Test/Functional
output: tests/functional/_output
data: tests/functional/_data
support: tests/functional/_support
envs: tests/functional/_envs
support: vendor/magento/magento-cloud-docker/tests/functional/_support
actor_suffix: Tester
settings:
colors: true
Expand All @@ -12,27 +11,27 @@ extensions:
- Codeception\Extension\RunFailed
- Codeception\Extension\FailedInfo
params:
- tests/functional/configuration.dist.yml
- vendor/magento/magento-cloud-docker/tests/functional/configuration.dist.yml
- env
modules:
config:
Magento\MagentoCloud\Test\Functional\Codeception\Docker:
db_host: "%Magento.docker.settings.db.host%"
db_port: "%Magento.docker.settings.db.port%"
db_username: "%Magento.docker.settings.db.username%"
db_password: "%Magento.docker.settings.db.password%"
db_path: "%Magento.docker.settings.db.path%"
repo_url: "%Magento.docker.settings.repo.url%"
repo_branch: "%Magento.docker.settings.repo.branch%"
system_ece_tools_dir: "%Magento.docker.settings.system.ece_dir%"
Magento\CloudDocker\Test\Functional\Codeception\TestInfrastructure:
template_repo: "https://github.com/magento/magento-cloud.git"
mcd_repo: "https://github.com/magento/magento-cloud-docker.git"
mcc_repo: "https://github.com/magento/magento-cloud-components.git"
mcp_repo: "https://github.com/magento/magento-cloud-patches.git"
composer_magento_username: "%REPO_USERNAME%"
composer_magento_password: "%REPO_PASSWORD%"
composer_github_token: "%GITHUB_TOKEN%"
printOutput: false
Magento\CloudDocker\Test\Functional\Codeception\Docker:
system_magento_dir: "%Magento.docker.settings.system.magento_dir%"
env_base_url: "%Magento.docker.settings.env.url.base%"
env_secure_base_url: "%Magento.docker.settings.env.url.secure_base%"
volumes: []
printOutput: false
PhpBrowser:
url: "%Magento.docker.settings.env.url.base%"
Magento\MagentoCloud\Test\Functional\Codeception\MagentoDb:
dsn: "mysql:host=127.0.0.1;port=3306;dbname=%Magento.docker.settings.db.path%"
Magento\CloudDocker\Test\Functional\Codeception\MagentoDb:
dsn: "mysql:host=%Magento.docker.settings.db.host%;port=%Magento.docker.settings.db.port%;dbname=%Magento.docker.settings.db.path%"
user: "%Magento.docker.settings.db.username%"
password: "%Magento.docker.settings.db.password%"
exposed_port: "%Magento.docker.settings.db.port%"
reconnect: true
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@
},
"prefer-stable": true,
"extra": {
"map": [
[
"dist/.magento.env.yaml",
".magento.env.yaml.dist"
]
],
"include_files": [
"vendor/codeception/phpunit-wrapper/src/phpunit7-interfaces.php"
]
Expand Down
16 changes: 8 additions & 8 deletions config/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ MIN_LOGGING_LEVEL:
type: string
allowed:
- ''
- !php/const Magento\MagentoCloud\Config\Log::LEVEL_DEBUG
- !php/const Magento\MagentoCloud\Config\Log::LEVEL_INFO
- !php/const Magento\MagentoCloud\Config\Log::LEVEL_NOTICE
- !php/const Magento\MagentoCloud\Config\Log::LEVEL_WARNING
- !php/const Magento\MagentoCloud\Config\Log::LEVEL_ERROR
- !php/const Magento\MagentoCloud\Config\Log::LEVEL_CRITICAL
- !php/const Magento\MagentoCloud\Config\Log::LEVEL_ALERT
- !php/const Magento\MagentoCloud\Config\Log::LEVEL_EMERGENCY
- 'debug'
- 'info'
- 'notice'
- 'warning'
- 'error'
- 'critical'
- 'alert'
- 'emergency'
stages:
- global
default:
Expand Down
22 changes: 17 additions & 5 deletions src/Config/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Magento\MagentoCloud\Config;

use Magento\MagentoCloud\Filesystem\SystemList;
use Magento\MagentoCloud\Filesystem\Driver\File;
use Symfony\Component\Yaml\Parser;
use Symfony\Component\Yaml\Yaml;

Expand Down Expand Up @@ -39,6 +40,11 @@ class Schema
*/
private $parser;

/**
* @var File
*/
private $file;

/**
* @var array
*/
Expand All @@ -47,18 +53,24 @@ class Schema
/**
* @param SystemList $systemList
* @param Parser $parser
* @param File $file
*/
public function __construct(SystemList $systemList, Parser $parser)
{
public function __construct(
SystemList $systemList,
Parser $parser,
File $file
) {
$this->systemList = $systemList;
$this->parser = $parser;
$this->file = $file;
}

/**
* Returns default values for given stage.
*
* @param string $stage
* @return array
* @throws \Magento\MagentoCloud\Filesystem\FileSystemException
*/
public function getDefaults(string $stage): array
{
Expand All @@ -85,12 +97,12 @@ public function getDefaults(string $stage): array
* 'default_values' - array of default values
*
* @return array
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @throws \Magento\MagentoCloud\Filesystem\FileSystemException
*/
public function getSchema(): array
{
return $this->parser->parseFile(
$this->systemList->getConfig() . '/schema.yaml',
return $this->parser->parse(
$this->file->fileGetContents($this->systemList->getConfig() . '/schema.yaml'),
Yaml::PARSE_CONSTANT
);
}
Expand Down
5 changes: 3 additions & 2 deletions src/Test/Functional/Acceptance.suite.dist.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
actor: CliTester
modules:
enabled:
- Magento\MagentoCloud\Test\Functional\Codeception\Docker
- Magento\MagentoCloud\Test\Functional\Codeception\MagentoDb
- Magento\CloudDocker\Test\Functional\Codeception\TestInfrastructure
- Magento\CloudDocker\Test\Functional\Codeception\Docker
- Magento\CloudDocker\Test\Functional\Codeception\MagentoDb
- PhpBrowser
- Asserts
77 changes: 73 additions & 4 deletions src/Test/Functional/Acceptance/AbstractCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@
*/
abstract class AbstractCest
{
/**
* @var boolean
*/
protected $removeEs = true;

/**
* @var string
*/
protected $magentoCloudTemplate = 'master';

/**
* @param \CliTester $I
*/
public function _before(\CliTester $I)
public function _before(\CliTester $I): void
{
$I->generateDockerCompose();
$I->cleanUpEnvironment();
$this->prepareWorkplace($I, $this->magentoCloudTemplate);
}

/**
Expand All @@ -28,6 +37,66 @@ public function _before(\CliTester $I)
public function _after(\CliTester $I): void
{
$I->stopEnvironment();
$I->removeDockerCompose();
$I->removeWorkDir();
}

/**
* @param array $data
* @return string
*/
protected function convertEnvFromArrayToJson(array $data): string
{
return addslashes(json_encode($data));
}

/**
* @param \CliTester $I
* @param string $version
*/
protected function prepareWorkplace(\CliTester $I, string $version): void
{
$I->cleanupWorkDir();
$I->cloneTemplateToWorkDir($version);
$I->createAuthJson();
$I->createArtifactsDir();
$I->createArtifactCurrentTestedCode('ece-tools', '2002.1.99');
$I->addArtifactsRepoToComposer();
$I->addDependencyToComposer('magento/ece-tools', '2002.1.99');
$I->addEceDockerGitRepoToComposer();
$I->addCloudComponentsGitRepoToComposer();
$I->addCloudPatchesGitRepoToComposer();
$I->addDependencyToComposer(
'magento/magento-cloud-docker',
$I->getDependencyVersion('magento/magento-cloud-docker')
);
$I->addDependencyToComposer(
'magento/magento-cloud-components',
$I->getDependencyVersion('magento/magento-cloud-components')
);
$I->addDependencyToComposer(
'magento/magento-cloud-patches',
$I->getDependencyVersion('magento/magento-cloud-patches')
);
$I->composerUpdate();
$this->removeESIfExists($I);
}

/**
* @param \CliTester $I
*/
protected function removeESIfExists(\CliTester $I): void
{
if ($this->removeEs) {
$services = $I->readServicesYaml();

if (isset($services['elasticsearch'])) {
unset($services['elasticsearch']);
$I->writeServicesYaml($services);

$app = $I->readAppMagentoYaml();
unset($app['relationships']['elasticsearch']);
$I->writeAppMagentoYaml($app);
}
}
}
}
31 changes: 0 additions & 31 deletions src/Test/Functional/Acceptance/AbstractInstallCest.php

This file was deleted.

20 changes: 13 additions & 7 deletions src/Test/Functional/Acceptance/AcceptanceCeCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Magento\MagentoCloud\Test\Functional\Acceptance;

use Magento\MagentoCloud\Test\Functional\Codeception\Docker;
use Magento\CloudDocker\Test\Functional\Codeception\Docker;
use Robo\Exception\TaskException;
use CliTester;

Expand All @@ -16,9 +16,16 @@
*
* @group edition-ce
*/
class AcceptanceCeCest extends AbstractInstallCest
class AcceptanceCeCest extends AbstractCest
{
public const EDITION = 'CE';
public function _before(\CliTester $I): void
{
parent::_before($I);

$I->removeDependencyFromComposer('magento/magento-cloud-metapackage');
$I->addDependencyToComposer('magento/product-community-edition', '@stable');
$I->composerUpdate();
}

/**
* @param CliTester $I
Expand All @@ -27,11 +34,10 @@ class AcceptanceCeCest extends AbstractInstallCest
*/
public function testWithSplitBuildCommand(\CliTester $I): void
{
$I->assertTrue($I->runEceToolsCommand('build:generate', Docker::BUILD_CONTAINER));
$I->assertTrue($I->runEceToolsCommand('build:transfer', Docker::BUILD_CONTAINER));
$I->runEceDockerCommand('build:compose --mode=production');
$I->startEnvironment();
$I->assertTrue($I->runEceToolsCommand('deploy', Docker::DEPLOY_CONTAINER));
$I->assertTrue($I->runEceToolsCommand('post-deploy', Docker::DEPLOY_CONTAINER));
$I->runDockerComposeCommand('run build cloud-build');
$I->runDockerComposeCommand('run deploy cloud-deploy');
$I->amOnPage('/');
$I->see('Home page');
$I->see('CMS homepage content goes here.');
Expand Down