Last active
October 20, 2015 09:21
-
-
Save duykhoa/27b15ba4620d1b19474e to your computer and use it in GitHub Desktop.
script to setup and run parallel test
This file contains hidden or 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
function setupdb { | |
# Remove it, Just worked for me. | |
for I in {1..8} | |
do | |
echo "[33m Setup db $I [0m" | |
TEST_ENV_NUMBER=$I RAILS_ENV=crm_test rake db:drop | |
TEST_ENV_NUMBER=$I RAILS_ENV=crm_test rake db:create | |
TEST_ENV_NUMBER=$I RAILS_ENV=test rake crm:setup | |
TEST_ENV_NUMBER=$I RAILS_ENV=test rake crm:seed | |
done | |
export PARALLEL_TEST_PROCESSORS=8 # 8 threads | |
# prepare DB | |
rake parallel:drop | |
rake parallel:create | |
rake parallel:prepare | |
} | |
function execute { | |
echo 'Make sure that you have config your database.yml with crm_test & test db with' | |
echo | |
echo ' test:' | |
echo ' database_name: spanif_pg_test<%= ENV['TEST_ENV_NUMBER'] %>' | |
echo | |
echo ' crm_test:' | |
echo ' database_name: crm_test<%= ENV['TEST_ENV_NUMBER'] %>' | |
echo | |
read -p '[33m Did you want setup crm db and test db in parallel test mode? Remember there are multiple databases (y/n)? [0m' CONFIRM | |
if [ $CONFIRM == 'Y' ] || [ $CONFIRM == 'y' ]; then | |
setupdb | |
else | |
echo '[32m Skip setting db, now try to run the specs in parallel mode [0m' | |
fi | |
echo '[35m Start running test[0m' | |
DISABLE_SPRING=1 rake parallel:spec # spring doesn't work with parallel_test | |
} | |
execute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment