Skip to content
This repository has been archived by the owner on Feb 4, 2019. It is now read-only.

Commit

Permalink
prepare testing enviroment
Browse files Browse the repository at this point in the history
  • Loading branch information
Auris committed Sep 12, 2016
1 parent bb93462 commit 12a7c82
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 4 deletions.
12 changes: 9 additions & 3 deletions config/Shared/config_default-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

use Spryker\Shared\Application\ApplicationConstants;
use Spryker\Shared\Payone\PayoneConstants;
use Spryker\Shared\Search\SearchConstants;
use Spryker\Shared\Session\SessionConstants;
use Spryker\Shared\Storage\StorageConstants;

$config[ApplicationConstants::ZED_DB_ENGINE] = $config[ApplicationConstants::ZED_DB_ENGINE_PGSQL];
$config[ApplicationConstants::ZED_DB_USERNAME] = 'development';
$config[ApplicationConstants::ZED_DB_PASSWORD] = 'mate20mg';
$config[ApplicationConstants::ZED_DB_DATABASE] = 'DE_development_zed';
$config[ApplicationConstants::ZED_DB_DATABASE] = 'DE_test_zed';
$config[ApplicationConstants::ZED_DB_HOST] = '127.0.0.1';
$config[ApplicationConstants::ZED_DB_PORT] = 5432;

Expand All @@ -23,7 +24,8 @@
$config[StorageConstants::STORAGE_REDIS_HOST] = '127.0.0.1';
$config[StorageConstants::STORAGE_REDIS_PORT] = '10009';
$config[StorageConstants::STORAGE_REDIS_PASSWORD] = '';
$config[StorageConstants::STORAGE_REDIS_DATABASE] = 0;
$config[StorageConstants::STORAGE_REDIS_DATABASE] = 3;


$config[SessionConstants::YVES_SESSION_REDIS_PROTOCOL] = $config[StorageConstants::STORAGE_REDIS_PROTOCOL];
$config[SessionConstants::YVES_SESSION_REDIS_HOST] = $config[StorageConstants::STORAGE_REDIS_HOST];
Expand All @@ -36,7 +38,7 @@
$config[SessionConstants::ZED_SESSION_REDIS_PORT] = $config[SessionConstants::YVES_SESSION_REDIS_PORT];
$config[SessionConstants::ZED_SESSION_REDIS_PASSWORD] = $config[SessionConstants::YVES_SESSION_REDIS_PASSWORD];

$config[SessionConstants::SESSION_IS_TEST] = true;
$config[SessionConstants::SESSION_IS_TEST] = false;

$config[PayoneConstants::PAYONE] = [
PayoneConstants::PAYONE_MODE => '',
Expand All @@ -46,3 +48,7 @@
$config[ApplicationConstants::JENKINS_DIRECTORY] = '/data/shop/development/shared/data/common/jenkins';

$config[ApplicationConstants::APPLICATION_SPRYKER_ROOT] = APPLICATION_ROOT_DIR . '/vendor/spryker/spryker/Bundles';

$config[ApplicationConstants::ELASTICA_PARAMETER__INDEX_NAME] = 'de_search_test';

$config[SearchConstants::SEARCH_INDEX_NAME_SUFFIX] = '_test';
2 changes: 2 additions & 0 deletions config/Shared/config_default.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@
$config[ApplicationConstants::ELASTICA_PARAMETER__INDEX_NAME] = null; // Store related config
$config[ApplicationConstants::ELASTICA_PARAMETER__DOCUMENT_TYPE] = 'page';


/**
* Page search settings
*/
$config[SearchConstants::SEARCH_CONFIG_CACHE_KEY] = 'search_config_cache';
$config[SearchConstants::FULL_TEXT_BOOSTED_BOOSTING_VALUE] = 3;
$config[SearchConstants::SEARCH_INDEX_NAME_SUFFIX] = '';

/**
* Hostname(s) for Yves - Shop frontend
Expand Down
8 changes: 7 additions & 1 deletion deploy/setup/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ function dumpDevelopmentDatabase {
export PGPASSWORD=$DATABASE_PASSWORD
export LC_ALL="en_US.UTF-8"

pg_dump -i -h 127.0.0.1 -U $DATABASE_USER -F c -b -v -f $DATABASE_NAME.backup $DATABASE_NAME
if [[ -z "$1" ]]; then
DATABASE_BACKUP_PATH=$DATABASE_NAME.backup;
else
DATABASE_BACKUP_PATH=$1
fi

pg_dump -i -h 127.0.0.1 -U $DATABASE_USER -F c -b -v -f $DATABASE_BACKUP_PATH $DATABASE_NAME
}

function restoreDevelopmentDatabase {
Expand Down
3 changes: 3 additions & 0 deletions deploy/test/functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash


99 changes: 99 additions & 0 deletions setup_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/bash

set -o pipefail


SETUP='spryker'
DATABASE_NAME='DE_test_zed'
DATABASE_USER='development'
DATABASE_PASSWORD='mate20mg'
VERBOSITY='-v'
CONSOLE=vendor/bin/console
PHANTOMJS_CDNURL='https://github.com/Medium/phantomjs/'
export APPLICATION_ENV='test'

. deploy/setup/functions.sh

warningText "This script should be used only in development and NEVER IN PRODUCTION"


function installTestingEnv {

# zed
labelText "Flushing Elasticsearch de_search_test"
curl -XDELETE 'http://localhost:10005/de_search_test/'
writeErrorMessage "Elasticsearch reset failed"

labelText "Flushing Redis db 3"
echo -e "select 3\nflushdb" | redis-cli -p 10009
writeErrorMessage "Redis reset failed"

dropDevelopmentDatabase

$CONSOLE setup:install $VERBOSITY
writeErrorMessage "Setup install failed"

$CONSOLE propel:install $VERBOSITY
$CONSOLE propel:diff $VERBOSITY
$CONSOLE propel:migrate $VERBOSITY

labelText "Initializing DB"
$CONSOLE setup:init-db $VERBOSITY
writeErrorMessage "DB setup failed"

labelText "Setting up data stores"
$CONSOLE collector:search:export $VERBOSITY
$CONSOLE collector:storage:export $VERBOSITY
writeErrorMessage "DataStore setup failed"


# backup
dumpDevelopmentDatabase "data/test.backup"

labelText "Backup redis to data/test.backup"
echo -e "select 3\nsave" | redis-cli -p 10009

labelText "Backup elastic search"
curl -XPUT http://localhost:10005/_snapshot/test -d '{"type":"fs","settings":{"location":"test","compress":true}}'
curl -XPUT http://localhost:10005/_snapshot/test/de_search_test -d '{"indicies":"de_search_test"}'

#---

#antelopeInstallZed

sleep 1

# yves
#installYves

configureCodeception

successText "Setup successful"
infoText "\nYves URL: http://www.de.spryker.dev/\nZed URL: http://zed.de.spryker.dev/\n"
}

if [ $# -eq 0 ]; then
displayHelp
exit 0
fi

for arg in "$@"
do
case $arg in

"--test" | "-t" )
installTestingEnv
;;
*)
displayHeader
echo ""
echo "Unrecognized option: $@. Use -h to display help."
exit 1
;;
esac
done




exit 0

0 comments on commit 12a7c82

Please sign in to comment.