Skip to content

Commit c143cfe

Browse files
authored
MCLOUD-6847: Improve functional tests execution speed (magento#777)
1 parent 46e7fc9 commit c143cfe

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ before_install:
4949

5050

5151
install:
52+
- phpenv config-add travis.php.ini
5253
- composer config http-basic.repo.magento.com ${REPO_USERNAME_CE} ${REPO_PASSWORD_CE}
5354
- composer config github-oauth.github.com ${GITHUB_TOKEN}
5455
- if [ -n "${MCC_VERSION}" ]; then composer config repositories.mcc git [email protected]:magento/magento-cloud-components.git && composer require "magento/magento-cloud-components:${MCC_VERSION}" --no-update; fi;

codeception.dist.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ modules:
2424
composer_magento_username: "%REPO_USERNAME%"
2525
composer_magento_password: "%REPO_PASSWORD%"
2626
composer_github_token: "%GITHUB_TOKEN%"
27+
use_cached_workdir: true
2728
printOutput: false
2829
Magento\CloudDocker\Test\Functional\Codeception\Docker:
2930
system_magento_dir: "%Magento.docker.settings.system.magento_dir%"

src/Test/Functional/Acceptance/AbstractCest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ protected function convertEnvFromArrayToJson(array $data): string
6161
protected function prepareWorkplace(\CliTester $I, string $templateVersion): void
6262
{
6363
$I->cleanupWorkDir();
64+
65+
if ($I->isCacheWorkDirExists($templateVersion)) {
66+
$I->restoreWorkDirFromCache($templateVersion);
67+
$this->removeESIfExists($I, $templateVersion);
68+
69+
return;
70+
}
71+
6472
$I->cloneTemplateToWorkDir($templateVersion);
6573
$I->createAuthJson();
6674
$I->createArtifactsDir();
@@ -90,6 +98,7 @@ protected function prepareWorkplace(\CliTester $I, string $templateVersion): voi
9098

9199
if ($this->runComposerUpdate) {
92100
$I->composerUpdate();
101+
$I->cacheWorkDir($templateVersion);
93102
}
94103

95104
$this->removeESIfExists($I, $templateVersion);

tests/travis/prepare_functional_parallel.sh

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,9 @@ trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit
88

99
php_version="${TRAVIS_PHP_VERSION//./}"
1010

11-
readarray -t test_set_list <<< "$(grep -Rl php${php_version} --exclude='*AcceptanceCest.php' --exclude='*AcceptanceCeCest.php' --exclude='*AcceptanceCe71Cest.php' --exclude='*AcceptanceCe72Cest.php' --exclude='*AcceptanceCe73Cest.php' --exclude='*AbstractCest.php' src/Test/Functional/Acceptance | sort)"
11+
test_set_list=($(grep -Rl php${php_version} --exclude='*AcceptanceCest.php' --exclude='*AcceptanceCeCest.php' --exclude='*AcceptanceCe71Cest.php' --exclude='*AcceptanceCe72Cest.php' --exclude='*AcceptanceCe73Cest.php' --exclude='*AbstractCest.php' src/Test/Functional/Acceptance | sort))
1212
group_count=6
1313

14-
if [ $(( ${#test_set_list[@]} % group_count )) -eq 0 ]; then
15-
element_in_group=$(printf "%.0f" "$(echo "scale=2;(${#test_set_list[@]})/${group_count}" | bc)")
16-
else
17-
element_in_group=$(printf "%.0f" "$(echo "scale=2;(${#test_set_list[@]} + ${group_count} - 1)/${group_count}" | bc)")
18-
fi
19-
2014
cp codeception.dist.yml codeception.yml
2115
echo "groups:" >> codeception.yml
2216
echo " parallel_${php_version}_*: tests/functional/_data/parallel_${php_version}_*" >> codeception.yml
@@ -30,15 +24,11 @@ else
3024
start_group_id=1
3125
fi
3226

33-
for((i=0, group_id=start_group_id; i < ${#test_set_list[@]}; i+=element_in_group, group_id++))
27+
for((i=0, group_id=start_group_id; i < ${#test_set_list[@]}; i+=1, group_id++))
3428
do
35-
test_file_group=( "${test_set_list[@]:i:element_in_group}" )
36-
echo "Batch #${group_id} = ${#test_file_group[@]}"
37-
29+
if [ $group_id -gt $group_count ]; then
30+
group_id=$start_group_id
31+
fi
3832
group_file="tests/functional/_data/parallel_${php_version}_$group_id.yml"
39-
40-
for test_file in "${test_file_group[@]}"
41-
do
42-
echo "$test_file" >> "$group_file"
43-
done
33+
echo "${test_set_list[i]}" >> "$group_file"
4434
done

travis.php.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
memory_limit = 4G

0 commit comments

Comments
 (0)