From 4014c18d9fb3fd0b68d6e58c5485f663a301c29f Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai <mchellathura@ebay.com>
Date: Fri, 5 Jun 2015 15:48:52 -0500
Subject: [PATCH] MAGETWO-38216: Reduce Execution Time of Integration Tests on
 Travis CI

-CR comments
---
 .travis.yml                                   |  2 +-
 .../integration/IntegationTestsForTravis.sh   | 35 +++++--------------
 2 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a78315b597c..a04714efe64 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -33,7 +33,7 @@ before_script:
   - echo '' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
   # Install MySQL 5.6, create DB for integration tests
   - >
-      sh -c "if [ '$TEST_SUITE' = 'integration_integrity' ]; then
+      sh -c "if [ '$TEST_SUITE' = 'integrationPart1' ] || [ '$TEST_SUITE' = 'integrationPart2' ] || [ '$TEST_SUITE' = 'integration_integrity' ]; then
       sudo apt-get remove --purge mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5;
       sudo apt-get autoremove;
       sudo apt-get autoclean;
diff --git a/dev/tests/integration/IntegationTestsForTravis.sh b/dev/tests/integration/IntegationTestsForTravis.sh
index f689a7e321e..3e243987a3e 100644
--- a/dev/tests/integration/IntegationTestsForTravis.sh
+++ b/dev/tests/integration/IntegationTestsForTravis.sh
@@ -1,42 +1,27 @@
-#usr/bin/bash
+#!usr/bin/bash
 
-#get number of files in directory
+# Get number of files in directory
 NUMBER_OF_SUITES=$1
 FOLDERSIZE=$(find ./testsuite/Magento/ -maxdepth 1 -type d|wc -l)
 FOLDERSIZE=$((FOLDERSIZE/NUMBER_OF_SUITES))
 
-#get folders
+# Get folders
 FOLDERS=$(ls  "./testsuite/Magento")
 
-#mysql 5.6
-sudo apt-get remove --purge mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5;
-sudo apt-get autoremove;
-sudo apt-get autoclean;
-sudo apt-add-repository ppa:ondrej/mysql-5.6 -y;
-sudo apt-get update;
-sudo apt-get install mysql-server-5.6 mysql-client-5.6;
-
-#create n testsuites and n databases
+# Create n testsuites
 i=0
 for i in `seq 1 $NUMBER_OF_SUITES`
 do
 	cp phpunit.xml.dist phpunit.xml.travis$i
-	perl -pi -e "s/<directory suffix=\"Test.php\">testsuite<\/directory>//g" phpunit.xml.travis$i
-	cp etc/install-config-mysql.php.dist etc/install-config-mysql$i.php
-	mysql -uroot -e "SET @@global.sql_mode = NO_ENGINE_SUBSTITUTION; create database magento_integration_tests${i}";
 done
 
-#replace Memory Usage Tests in all except testsuite 1
+# Replace Memory Usage Tests in all except testsuite 1
 for i in `seq 2 $NUMBER_OF_SUITES`
 do
-	perl -pi -e 's/<!-- Memory tests run first to prevent influence of other tests on accuracy of memory measurements -->//g' phpunit.xml.travis$i
-	perl -pi -e 's/<testsuite name="Memory Usage Tests">//g' phpunit.xml.travis$i
-	perl -pi -e 's/<file>testsuite\/Magento\/MemoryUsageTest.php<\/file>//g' phpunit.xml.travis$i
-	perl -pi -e 's/<\/testsuite>//g' phpunit.xml.travis$i
-	perl -pi -e "s/<\/testsuites>/<\/testsuite><\/testsuites>/g" phpunit.xml.travis$i
+	perl -i -0pe 's/(<!-- Memory)(.*?)(<\/testsuite>)//ims' phpunit.xml.travis$i
 done
 
-#create list of folders on which tests are to be run
+# Create list of folders on which tests are to be run
 i=0
 j=1
 for FOLDER in $FOLDERS
@@ -49,10 +34,8 @@ do
 	fi
 done
 
-# finally replacing in config files.
+# Finally replacing in config files.
 for i in `seq 1 $NUMBER_OF_SUITES`
 do
-	perl -pi -e "s/<directory suffix=\"Test.php\">..\/..\/..\/update\/dev\/tests\/integration\/testsuite<\/directory>/${FILE[i]}/g" phpunit.xml.travis$i
-	perl -pi -e "s/magento_integration_tests/magento_integration_tests${i}/g" etc/install-config-mysql${i}.php
-	perl -pi -e "s/etc\/install-config-mysql.php/etc\/install-config-mysql${i}.php/g" phpunit.xml.travis$i
+	perl -pi -e "s/<directory suffix=\"Test.php\">testsuite<\/directory>/${FILE[i]}/g" phpunit.xml.travis$i
 done
\ No newline at end of file
-- 
GitLab