From 2855d34f023b5c0957175a167fde0919b1350f3d Mon Sep 17 00:00:00 2001 From: Joshua Hesketh Date: Tue, 22 Mar 2016 17:26:05 +1100 Subject: 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 --- .../task_plugins/real_db_upgrade/nova_mysql_migrations.sh | 10 ++++++---- 1 file 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" -- cgit v1.2.1