From ee7b290b02222dc888a66911916828e7acc16fc7 Mon Sep 17 00:00:00 2001 From: Auris Date: Wed, 14 Sep 2016 14:50:34 +0200 Subject: [PATCH] acceptance test changes --- codeception.yml | 3 +- composer.json | 2 +- deploy/setup/functions.sh | 25 ++++++++++---- setup | 2 +- setup_test.sh | 71 ++++++++++++++++++--------------------- 5 files changed, 55 insertions(+), 48 deletions(-) diff --git a/codeception.yml b/codeception.yml index 7eb8eafb1..ff367bf7b 100644 --- a/codeception.yml +++ b/codeception.yml @@ -1,7 +1,8 @@ actor: Tester include: - - vendor/spryker/spryker/Bundles/* + - tests/* + paths: tests: tests diff --git a/composer.json b/composer.json index 75f99ea20..f3c4752a7 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Project", "license": "MIT", "require": { - "spryker/spryker": "dev-master", + "spryker/spryker": "dev-testing_enviroment", "php": "~5.6.0", "braintree/braintree_php": "~3.15.0", "guzzlehttp/guzzle": "~6.2.1", diff --git a/deploy/setup/functions.sh b/deploy/setup/functions.sh index 5c09dc519..57edadeff 100644 --- a/deploy/setup/functions.sh +++ b/deploy/setup/functions.sh @@ -93,13 +93,7 @@ function restoreDevelopmentDatabase { read -r -p "Restore database ${DATABASE_NAME} ? [y/N] " response case $response in [yY][eE][sS]|[yY]) - export PGPASSWORD=$DATABASE_PASSWORD - export LC_ALL="en_US.UTF-8" - - sudo pg_ctlcluster 9.4 main restart --force - sudo dropdb $DATABASE_NAME - sudo createdb $DATABASE_NAME - pg_restore -i -h 127.0.0.1 -p 5432 -U $DATABASE_USER -d $DATABASE_NAME -v $DATABASE_NAME.backup + dropAndRestoreDatabase ;; *) echo "Nothing done." @@ -107,6 +101,23 @@ function restoreDevelopmentDatabase { esac } +function dropAndRestoreDatabase { + + if [[ -z "$1" ]]; then + DATABASE_BACKUP_PATH=$DATABASE_NAME.backup; + else + DATABASE_BACKUP_PATH=$1 + fi + + export PGPASSWORD=$DATABASE_PASSWORD + export LC_ALL="en_US.UTF-8" + + sudo pg_ctlcluster 9.4 main restart --force + sudo dropdb $DATABASE_NAME + sudo createdb $DATABASE_NAME + pg_restore -i -h 127.0.0.1 -p 5432 -U $DATABASE_USER -d $DATABASE_NAME -v $DATABASE_BACKUP_PATH + +} function installDemoshop { labelText "Preparing to install Spryker Platform..." diff --git a/setup b/setup index 1acc6f27d..482d8d846 100755 --- a/setup +++ b/setup @@ -40,7 +40,7 @@ do installZed ;; "--reset" | "-r" ) - resetDevelopmentState + resetDevelopmentState ΓΈ ;; "--dump-db" | "-ddb" ) dumpDevelopmentDatabase diff --git a/setup_test.sh b/setup_test.sh index 212897494..b6b96e202 100755 --- a/setup_test.sh +++ b/setup_test.sh @@ -2,7 +2,6 @@ set -o pipefail - SETUP='spryker' DATABASE_NAME='DE_test_zed' DATABASE_USER='development' @@ -10,66 +9,56 @@ DATABASE_PASSWORD='mate20mg' VERBOSITY='-v' CONSOLE=vendor/bin/console PHANTOMJS_CDNURL='https://github.com/Medium/phantomjs/' +DATABASE_BACKUP_PATH='data/test.backup' + 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" +function backupTestingEnvData { dropDevelopmentDatabase + labelText "Running setup:install" $CONSOLE setup:install $VERBOSITY writeErrorMessage "Setup install failed" + labelText "Running propel code generation/migrations" $CONSOLE propel:install $VERBOSITY $CONSOLE propel:diff $VERBOSITY $CONSOLE propel:migrate $VERBOSITY + labelText "Importing Demo data" + $CONSOLE import:demo-data $VERBOSITY + writeErrorMessage "DemoData import failed" + 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 + runCollectors - 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"}' + dumpDevelopmentDatabase $DATABASE_BACKUP_PATH - #--- + successText "Backup successful." +} - #antelopeInstallZed +function restoreTestingEnvData { - sleep 1 + dropAndRestoreDatabase $DATABASE_BACKUP_PATH +} - # yves - #installYves +function runCollectors() { - configureCodeception + export PGPASSWORD=$DATABASE_PASSWORD + labelText "Reset touch table." + psql -h 127.0.0.1 -U $DATABASE_USER -d $DATABASE_NAME -c 'UPDATE spy_touch set touched=now()' -w - successText "Setup successful" - infoText "\nYves URL: http://www.de.spryker.dev/\nZed URL: http://zed.de.spryker.dev/\n" + labelText "Run collectors." + $CONSOLE collector:search:export $VERBOSITY + $CONSOLE collector:storage:export $VERBOSITY } if [ $# -eq 0 ]; then @@ -81,9 +70,17 @@ for arg in "$@" do case $arg in - "--test" | "-t" ) - installTestingEnv + "--restore" | "-r" ) + restoreTestingEnvData + ;; + + "--backup" | "-b" ) + backupTestingEnvData ;; + "--collectors" | "-c" ) + runCollectors + ;; + *) displayHeader echo "" @@ -94,6 +91,4 @@ do done - - exit 0