Skip to content

Commit 5a714cd

Browse files
MAGECLOUD-3542: Stabilize functional tests on the Docker (#456)
1 parent 259b38f commit 5a714cd

File tree

5 files changed

+43
-8
lines changed

5 files changed

+43
-8
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ env:
2424

2525
cache:
2626
apt: true
27-
directories:
28-
- $HOME/.composer/cache
2927

3028
before_install:
3129
- echo "COMPOSER_MAGENTO_USERNAME=${REPO_USERNAME}" >> ./docker/composer.env

codeception.dist.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,10 @@ modules:
2626
system_magento_dir: "%Magento.docker.settings.system.magento_dir%"
2727
env_base_url: "%Magento.docker.settings.env.url.base%"
2828
env_secure_base_url: "%Magento.docker.settings.env.url.secure_base%"
29+
volumes:
30+
- /var/www/magento/pub/static
31+
- /var/www/magento/pub/media
32+
- /var/www/magento/var
33+
- /var/www/magento/app/etc
2934
PhpBrowser:
3035
url: "%Magento.docker.settings.env.url.base%"

tests/functional/Codeception/Docker.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class Docker extends Module implements BuilderAwareInterface, ContainerAwareInte
3535
const BUILD_CONTAINER = 'build';
3636
const DEPLOY_CONTAINER = 'deploy';
3737

38+
/**
39+
* @var array
40+
*/
3841
protected $config = [
3942
'db_host' => '',
4043
'db_port' => '3306',
@@ -47,6 +50,7 @@ class Docker extends Module implements BuilderAwareInterface, ContainerAwareInte
4750
'system_magento_dir' => '',
4851
'env_base_url' => '',
4952
'env_secure_base_url' => '',
53+
'volumes' => []
5054
];
5155

5256
/**
@@ -66,7 +70,7 @@ public function _initialize()
6670
*/
6771
public function _before(TestInterface $test)
6872
{
69-
$this->taskEnvUp()
73+
$this->taskEnvUp($this->_getConfig('volumes'))
7074
->run()
7175
->stopOnFail();
7276
}

tests/functional/Robo/Tasks.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ trait Tasks
1818
use TaskAccessor;
1919

2020
/**
21+
* @param array $volumes
2122
* @return Tasks\EnvUp|CollectionBuilder
2223
*/
23-
protected function taskEnvUp(): CollectionBuilder
24+
protected function taskEnvUp(array $volumes): CollectionBuilder
2425
{
25-
return $this->task(Tasks\EnvUp::class);
26+
return $this->task(Tasks\EnvUp::class, $volumes);
2627
}
2728

2829
/**

tests/functional/Robo/Tasks/EnvUp.php

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,50 @@
99

1010
use Robo\Common\ExecOneCommand;
1111
use Robo\Contract\CommandInterface;
12-
use Robo\Contract\TaskInterface;
1312
use Robo\Result;
1413
use Robo\Task\BaseTask;
14+
use Magento\MagentoCloud\Test\Functional\Codeception\Docker;
1515

1616
/**
1717
* Up Docker environment
1818
*/
19-
class EnvUp extends BaseTask implements CommandInterface, TaskInterface
19+
class EnvUp extends BaseTask implements CommandInterface
2020
{
2121
use ExecOneCommand;
2222

23+
/**
24+
* @var array
25+
*/
26+
private $volumes;
27+
28+
/**
29+
* @param array $volumes
30+
*/
31+
public function __construct(array $volumes)
32+
{
33+
$this->volumes = $volumes;
34+
}
35+
2336
/**
2437
* @inheritdoc
2538
*/
2639
public function getCommand(): string
2740
{
28-
return 'docker-compose down -v && docker-compose up -d';
41+
$commands = [
42+
'docker-compose down -v',
43+
];
44+
45+
foreach ($this->volumes as $volume) {
46+
$commands[] = sprintf(
47+
'docker-compose run %s bash -c "mkdir -p %s"',
48+
Docker::BUILD_CONTAINER,
49+
$volume
50+
);
51+
}
52+
53+
$commands[] = 'docker-compose up -d';
54+
55+
return implode(' && ', $commands);
2956
}
3057

3158
/**

0 commit comments

Comments
 (0)