Skip to content

Commit c0d2290

Browse files
authored
MAGECLOUD-4486: Docker functional tests and CI with ece-tools test framework (#120)
1 parent b998142 commit c0d2290

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2330
-528
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/composer.phar
55
/composer.lock
66
/auth.json
7+
/_workdir

.travis.yml

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,58 @@
1-
dist: trusty
1+
dist: bionic
22

33
git:
44
depth: false
55

6+
addons:
7+
hosts:
8+
- magento2.docker
9+
10+
services:
11+
- docker
12+
613
language: php
714
php:
815
- '7.1'
916
- '7.2'
1017
- '7.3'
1118

19+
env:
20+
- TEST_SUITE=functional
21+
22+
stages:
23+
- static-unit
24+
- integration
25+
- test
26+
27+
jobs:
28+
include:
29+
- stage: static-unit
30+
script: ./tests/travis/static-unit.sh;
31+
env:
32+
- TEST_SUITE=static-unit
33+
- script: ./tests/travis/static-unit.sh;
34+
php: '7.2'
35+
env:
36+
- TEST_SUITE=static-unit
37+
- script: ./tests/travis/static-unit.sh;
38+
php: '7.3'
39+
env:
40+
- TEST_SUITE=static-unit
41+
- stage: integration
42+
script: ./vendor/bin/phpunit --configuration ./tests/integration;
43+
env:
44+
- TEST_SUITE=integration
45+
- script: ./vendor/bin/phpunit --configuration ./tests/integration;
46+
php: '7.2'
47+
env:
48+
- TEST_SUITE=integration
49+
- script: ./vendor/bin/phpunit --configuration ./tests/integration;
50+
php: '7.3'
51+
env:
52+
- TEST_SUITE=integration
53+
1254
install: composer update
1355

1456
script:
15-
- ./vendor/bin/phpstan analyse -c ./tests/static/phpstan.neon
16-
- ./vendor/bin/phpcs ./src --standard=./tests/static/phpcs-ruleset.xml -p -n
17-
- ./vendor/bin/phpmd ./src xml ./tests/static/phpmd-ruleset.xml
18-
- ./vendor/bin/phpunit --configuration ./tests/unit
19-
- ./vendor/bin/phpunit --configuration ./tests/integration
57+
- if [ $TRAVIS_SECURE_ENV_VARS == "true" ] && [ $TEST_SUITE == "functional" ]; then ./tests/travis/functional.sh; fi;
58+

codeception.dist.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
paths:
2+
tests: src/Test/Functional
3+
output: tests/functional/_output
4+
data: tests/functional/_data
5+
support: tests/functional/_support
6+
envs: tests/functional/_envs
7+
actor_suffix: Tester
8+
settings:
9+
colors: true
10+
extensions:
11+
enabled:
12+
- Codeception\Extension\RunFailed
13+
params:
14+
- tests/functional/configuration.dist.yml
15+
- env
16+
modules:
17+
config:
18+
Magento\CloudDocker\Test\Functional\Codeception\TestInfrastructure:
19+
template_repo: "https://github.com/magento/magento-cloud.git"
20+
mcd_repo: "https://github.com/magento/magento-cloud-docker.git"
21+
mcc_repo: "https://github.com/magento/magento-cloud-components.git"
22+
mcp_repo: "https://github.com/magento/magento-cloud-patches.git"
23+
composer_magento_username: "%REPO_USERNAME%"
24+
composer_magento_password: "%REPO_PASSWORD%"
25+
composer_github_token: "%GITHUB_TOKEN%"
26+
printOutput: false
27+
Magento\CloudDocker\Test\Functional\Codeception\Docker:
28+
system_magento_dir: "%Magento.docker.settings.system.magento_dir%"
29+
printOutput: false
30+
PhpBrowser:
31+
url: "%Magento.docker.settings.env.url.base%"
32+
Magento\CloudDocker\Test\Functional\Codeception\MagentoDb:
33+
dsn: "mysql:host=%Magento.docker.settings.db.host%;port=%Magento.docker.settings.db.port%;dbname=%Magento.docker.settings.db.path%"
34+
user: "%Magento.docker.settings.db.username%"
35+
password: "%Magento.docker.settings.db.password%"
36+
exposed_port: "%Magento.docker.settings.db.port%"
37+
reconnect: true

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,18 @@
2222
"phpmd/phpmd": "@stable",
2323
"phpstan/phpstan": "^0.11",
2424
"phpunit/phpunit": "^7.2",
25-
"squizlabs/php_codesniffer": "^3.0"
25+
"squizlabs/php_codesniffer": "^3.0",
26+
"codeception/codeception": "^2.5.3",
27+
"consolidation/robo": "^1.2"
2628
},
2729
"bin": [
2830
"bin/ece-docker"
2931
],
3032
"autoload": {
3133
"psr-4": {
3234
"Magento\\CloudDocker\\": "src/",
33-
"Magento\\CloudDocker\\Test\\Integration\\": "tests/integration"
35+
"Magento\\CloudDocker\\Test\\Integration\\": "tests/integration",
36+
"Magento\\CloudDocker\\Test\\Functional\\": "tests/functional/"
3437
}
3538
},
3639
"scripts": {

config/services.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
<argument key="$strategies" type="collection">
1515
<argument key="developer">Magento\CloudDocker\Compose\DeveloperBuilder</argument>
1616
<argument key="production">Magento\CloudDocker\Compose\ProductionBuilder</argument>
17-
<argument key="functional">Magento\CloudDocker\Compose\FunctionalBuilder</argument>
1817
</argument>
1918
</service>
2019
<service id="Magento\CloudDocker\Filesystem\DirectoryList" autowire="false"/>
@@ -25,7 +24,6 @@
2524
<service id="Magento\CloudDocker\App\GenericException" autowire="false"/>
2625
<service id="Magento\CloudDocker\Compose\DeveloperBuilder" shared="false"/>
2726
<service id="Magento\CloudDocker\Compose\ProductionBuilder" shared="false"/>
28-
<service id="Magento\CloudDocker\Compose\FunctionalBuilder" shared="false"/>
2927
<service id="Magento\CloudDocker\Config\Config" autowire="false"/>
3028
<service id="Magento\CloudDocker\Config\Source\CliSource" autowire="false"/>
3129
<service id="Composer\Semver\VersionParser"/>

src/Command/BuildCompose.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ protected function configure(): void
158158
[
159159
BuilderFactory::BUILDER_DEVELOPER,
160160
BuilderFactory::BUILDER_PRODUCTION,
161-
BuilderFactory::BUILDER_FUNCTIONAL,
162161
]
163162
)
164163
),
@@ -171,8 +170,7 @@ protected function configure(): void
171170
sprintf(
172171
'File sync engine. Works only with developer mode. Available: (%s)',
173172
implode(', ', DeveloperBuilder::SYNC_ENGINES_LIST)
174-
),
175-
DeveloperBuilder::SYNC_ENGINE_NATIVE
173+
)
176174
)
177175
->addOption(
178176
Source\CliSource::OPTION_WITH_CRON,
@@ -201,6 +199,12 @@ protected function configure(): void
201199
null,
202200
InputOption::VALUE_NONE,
203201
'Enables XDebug'
202+
)
203+
->addOption(
204+
Source\CliSource::OPTION_ENV_VARIABLES,
205+
null,
206+
InputOption::VALUE_OPTIONAL,
207+
'Cloud environment variables'
204208
);
205209

206210
parent::configure();
@@ -223,14 +227,7 @@ public function execute(InputInterface $input, OutputInterface $output)
223227
new Source\CliSource($input)
224228
]);
225229

226-
if (in_array(
227-
$config->getMode(),
228-
[BuilderFactory::BUILDER_DEVELOPER, BuilderFactory::BUILDER_PRODUCTION],
229-
true
230-
)) {
231-
$this->distGenerator->generate($config);
232-
}
233-
230+
$this->distGenerator->generate($config);
234231
$compose = $builder->build($config);
235232

236233
$this->filesystem->put(

src/Compose/BuilderFactory.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class BuilderFactory
1919
{
2020
public const BUILDER_DEVELOPER = 'developer';
2121
public const BUILDER_PRODUCTION = 'production';
22-
public const BUILDER_FUNCTIONAL = 'functional';
2322

2423
/**
2524
* @var array

src/Compose/DeveloperBuilder.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ public function build(Config $config): Manager
153153
]);
154154
$manager->updateService(self::SERVICE_GENERIC, [
155155
'environment' => $this->converter->convert(array_merge(
156-
$config->getVariables(),
157156
['MAGENTO_RUN_MODE' => 'developer'],
158157
['PHP_EXTENSIONS' => implode(' ', $this->extensionResolver->get($config))]
159158
))

0 commit comments

Comments
 (0)