summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Hesketh <josh@nitrotech.org>2016-03-22 17:26:05 +1100
committerJoshua Hesketh <josh@nitrotech.org>2016-03-22 17:29:30 +1100
commit2855d34f023b5c0957175a167fde0919b1350f3d (patch)
tree6102a0774301f6cfb1138dba64b9c8efa90cde66
parente946029b5e9f148332220cc16923790f9a9ddb63 (diff)
downloadturbo-hipster-2855d34f023b5c0957175a167fde0919b1350f3d.tar.gz
Allow databases to be preloaded
To speed up bootstrapping time for turbo-hipster, check if the database exists before creating it with the seed data as part of the job run. This allows us to preload the database (as part of a nodepool image build) which will save a lot of time. Change-Id: Ieb09e714e24fe6df3ce148e44d5c1148739751c0
-rwxr-xr-xturbo_hipster/task_plugins/real_db_upgrade/nova_mysql_migrations.sh10
1 files changed, 6 insertions, 4 deletions
diff --git a/turbo_hipster/task_plugins/real_db_upgrade/nova_mysql_migrations.sh b/turbo_hipster/task_plugins/real_db_upgrade/nova_mysql_migrations.sh
index 62d9e53..bf27da0 100755
--- a/turbo_hipster/task_plugins/real_db_upgrade/nova_mysql_migrations.sh
+++ b/turbo_hipster/task_plugins/real_db_upgrade/nova_mysql_migrations.sh
@@ -244,11 +244,13 @@ which mkvirtualenv
set +x
# Restore database to known good state
-echo "Restoring test database $DB_NAME"
+echo "Loading test database $DB_NAME"
set -x
-mysql -u $DB_USER --password=$DB_PASS -e "drop database $DB_NAME"
-mysql -u $DB_USER --password=$DB_PASS -e "create database $DB_NAME"
-mysql -u $DB_USER --password=$DB_PASS $DB_NAME < $DATASET_SEED_SQL
+if ! mysql -u $DB_USER --password=$DB_PASS -e 'use $DB_NAME'
+then
+ mysql -u $DB_USER --password=$DB_PASS -e "create database $DB_NAME"
+ mysql -u $DB_USER --password=$DB_PASS $DB_NAME < $DATASET_SEED_SQL
+fi
set +x
echo "Build test environment"