-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from AmpersandHQ/add-support-for-integration-tests
Add FULL_INSTALL flag so this can be used for integration tests
- Loading branch information
Showing
4 changed files
with
87 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
return [ | ||
'db-host' => '127.0.0.1', | ||
'db-user' => 'root', | ||
'db-password' => '', | ||
'db-name' => 'magento_integration_tests', | ||
'db-prefix' => 'trv_', | ||
'backend-frontname' => 'backend', | ||
'admin-user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME, | ||
'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD, | ||
'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL, | ||
'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME, | ||
'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
return [ | ||
'db-host' => '127.0.0.1', | ||
'db-user' => 'root', | ||
'db-password' => '', | ||
'db-name' => 'magento_integration_tests', | ||
'db-prefix' => 'trv_', | ||
'backend-frontname' => 'backend', | ||
'admin-user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME, | ||
'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD, | ||
'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL, | ||
'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME, | ||
'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME, | ||
'amqp-host' => 'localhost', | ||
'amqp-port' => '5672', | ||
'amqp-user' => 'guest', | ||
'amqp-password' => 'guest', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ DIR_INSTANCES="$DIR_BASE/instances" | |
NAME=$NAME | ||
NAME=${NAME//[-._]/} | ||
|
||
FULL_INSTALL=${FULL_INSTALL:-1} | ||
WITH_SAMPLE_DATA=${WITH_SAMPLE_DATA:-0} | ||
VERSION=$VERSION | ||
VERSION_NO_DOT=${VERSION//[-._]/} | ||
|
@@ -26,6 +27,11 @@ BASE_DOMAIN="magento-$NAME.localhost" | |
BASE_URL="https://$BASE_DOMAIN" | ||
|
||
function prepare_php_and_apache() { | ||
if [ "$FULL_INSTALL" -eq "0" ]; then | ||
echo "Not configuring php-fpm and apachec as this is not a full install" | ||
return 0; | ||
fi | ||
|
||
printf "\033[92m###### Configuring php fpm and apache ######\n\n\033[0m"; | ||
# fpm error logs are found here; /home/travis/.phpenv/versions/7.0.25/var/log/php-fpm.log | ||
sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf | ||
|
@@ -51,7 +57,7 @@ function prepare_php_and_apache() { | |
|
||
printf "\033[92m###### Updating /etc/hosts ######\n\n\033[0m"; | ||
|
||
if ! grep -q "127.0.0.1 $BASE_DOMAIN" "/etc/hosts"; then echo "127.0.0.1 $BASE_DOMAIN" | sudo tee -a /etc/hosts; fi; | ||
if ! grep -q "127.0.0.1 $BASE_DOMAIN" "/etc/hosts"; then echo "127.0.0.1 $BASE_DOMAIN" | sudo tee -a /etc/hosts; fi; | ||
|
||
printf "\033[92m###### Restarting apache ######\n\n\033[0m"; | ||
sudo a2ensite project.dev.conf | ||
|
@@ -83,21 +89,26 @@ function install_magento() { | |
with_sampledata | ||
fi | ||
|
||
printf "\033[92m###### Running installation ######\n\n\033[0m"; | ||
if [ "$FULL_INSTALL" -eq "1" ]; then | ||
printf "\033[92m###### Running installation ######\n\n\033[0m"; | ||
|
||
travis_wait 30 php bin/magento setup:install \ | ||
--admin-firstname=ampersand --admin-lastname=developer [email protected] \ | ||
--admin-user=admin --admin-password=somepassword123 \ | ||
--db-name=$DATABASE_NAME --db-user=root --db-host=127.0.0.1\ | ||
--backend-frontname=admin \ | ||
--base-url=$BASE_URL \ | ||
--language=en_GB --currency=GBP --timezone=Europe/London \ | ||
--use-rewrites=1 | ||
|
||
printf "\033[92m###### Running setup upgrade ######\n\n\033[0m"; | ||
|
||
php bin/magento setup:upgrade | ||
fi | ||
|
||
travis_wait 30 php bin/magento setup:install \ | ||
--admin-firstname=ampersand --admin-lastname=developer [email protected] \ | ||
--admin-user=admin --admin-password=somepassword123 \ | ||
--db-name=$DATABASE_NAME --db-user=root --db-host=127.0.0.1\ | ||
--backend-frontname=admin \ | ||
--base-url=$BASE_URL \ | ||
--language=en_GB --currency=GBP --timezone=Europe/London \ | ||
--use-rewrites=1 | ||
|
||
printf "\033[92m###### Running setup upgrade ######\n\n\033[0m"; | ||
cp $DIR_BASE/install-config-mysql*.dist dev/tests/integration/etc | ||
|
||
php bin/magento setup:upgrade | ||
|
||
mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini.bak ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini | ||
cd - | ||
} | ||
|
@@ -123,12 +134,28 @@ function with_sampledata() { | |
} | ||
|
||
function assert_alive() { | ||
if [ "$FULL_INSTALL" -eq "0" ]; then | ||
echo "Not performing any database checks as this is not a full instance" | ||
return 0; | ||
fi | ||
|
||
printf "\033[92m###### Asserting that you can see $BASE_URL with a 200 response ######\n\n\033[0m"; | ||
curl -s -k --head $BASE_URL | head -1 | grep 200 | ||
printf "\033[92m###### There are the following number of products in the database ######\n\n\033[0m"; | ||
mysql -hlocalhost -uroot $DATABASE_NAME -e "select count(*) from catalog_product_entity;" | ||
} | ||
|
||
function install_elasticsearch() { | ||
sudo apt-get remove elasticsearch -y | ||
curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2-amd64.deb | ||
sudo dpkg -i --force-confnew elasticsearch-7.6.2-amd64.deb | ||
sudo chown elasticsearch:elasticsearch /etc/default/elasticsearch | ||
sudo service elasticsearch restart | ||
sleep 5 | ||
curl -XGET 'localhost:9200' | grep "You Know, for Search" | ||
} | ||
|
||
install_elasticsearch | ||
install_magento | ||
prepare_php_and_apache | ||
assert_alive | ||
|