Skip to content

Commit

Permalink
MCLOUD-6847: Improve functional tests execution speed (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
oshmyheliuk authored Sep 14, 2020
1 parent 46e7fc9 commit c143cfe
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ before_install:


install:
- phpenv config-add travis.php.ini
- composer config http-basic.repo.magento.com ${REPO_USERNAME_CE} ${REPO_PASSWORD_CE}
- composer config github-oauth.github.com ${GITHUB_TOKEN}
- 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;
Expand Down
1 change: 1 addition & 0 deletions codeception.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ modules:
composer_magento_username: "%REPO_USERNAME%"
composer_magento_password: "%REPO_PASSWORD%"
composer_github_token: "%GITHUB_TOKEN%"
use_cached_workdir: true
printOutput: false
Magento\CloudDocker\Test\Functional\Codeception\Docker:
system_magento_dir: "%Magento.docker.settings.system.magento_dir%"
Expand Down
9 changes: 9 additions & 0 deletions src/Test/Functional/Acceptance/AbstractCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ protected function convertEnvFromArrayToJson(array $data): string
protected function prepareWorkplace(\CliTester $I, string $templateVersion): void
{
$I->cleanupWorkDir();

if ($I->isCacheWorkDirExists($templateVersion)) {
$I->restoreWorkDirFromCache($templateVersion);
$this->removeESIfExists($I, $templateVersion);

return;
}

$I->cloneTemplateToWorkDir($templateVersion);
$I->createAuthJson();
$I->createArtifactsDir();
Expand Down Expand Up @@ -90,6 +98,7 @@ protected function prepareWorkplace(\CliTester $I, string $templateVersion): voi

if ($this->runComposerUpdate) {
$I->composerUpdate();
$I->cacheWorkDir($templateVersion);
}

$this->removeESIfExists($I, $templateVersion);
Expand Down
22 changes: 6 additions & 16 deletions tests/travis/prepare_functional_parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@ trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit

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

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)"
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))
group_count=6

if [ $(( ${#test_set_list[@]} % group_count )) -eq 0 ]; then
element_in_group=$(printf "%.0f" "$(echo "scale=2;(${#test_set_list[@]})/${group_count}" | bc)")
else
element_in_group=$(printf "%.0f" "$(echo "scale=2;(${#test_set_list[@]} + ${group_count} - 1)/${group_count}" | bc)")
fi

cp codeception.dist.yml codeception.yml
echo "groups:" >> codeception.yml
echo " parallel_${php_version}_*: tests/functional/_data/parallel_${php_version}_*" >> codeception.yml
Expand All @@ -30,15 +24,11 @@ else
start_group_id=1
fi

for((i=0, group_id=start_group_id; i < ${#test_set_list[@]}; i+=element_in_group, group_id++))
for((i=0, group_id=start_group_id; i < ${#test_set_list[@]}; i+=1, group_id++))
do
test_file_group=( "${test_set_list[@]:i:element_in_group}" )
echo "Batch #${group_id} = ${#test_file_group[@]}"

if [ $group_id -gt $group_count ]; then
group_id=$start_group_id
fi
group_file="tests/functional/_data/parallel_${php_version}_$group_id.yml"

for test_file in "${test_file_group[@]}"
do
echo "$test_file" >> "$group_file"
done
echo "${test_set_list[i]}" >> "$group_file"
done
1 change: 1 addition & 0 deletions travis.php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
memory_limit = 4G

0 comments on commit c143cfe

Please sign in to comment.