From 299490f46fc3fa25285bdacbccdebef966fdab07 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Wed, 1 Jun 2016 10:52:54 +0200 Subject: [PATCH] Put all remote sql script together --- test/prepare_db.sh | 42 ++++++++++--------- .../sql}/populated_places_simple_reduced.sql | 0 test/{ => support/sql}/test.sql | 0 3 files changed, 22 insertions(+), 20 deletions(-) rename test/{fixtures => support/sql}/populated_places_simple_reduced.sql (100%) rename test/{ => support/sql}/test.sql (100%) diff --git a/test/prepare_db.sh b/test/prepare_db.sh index 7f92e1ab..3c54cce7 100755 --- a/test/prepare_db.sh +++ b/test/prepare_db.sh @@ -68,29 +68,31 @@ if test x"$PREPARE_PGSQL" = xyes; then echo "PostgreSQL server version: `psql -A -t -c 'select version()'`" dropdb ${TEST_DB} # 2> /dev/null # error expected if doesn't exist, but not otherwise createdb -Ttemplate_postgis -EUTF8 ${TEST_DB} || die "Could not create test database" - psql -c 'CREATE EXTENSION "uuid-ossp";' ${TEST_DB} - cat test.sql | - sed "s/:PUBLICUSER/${PUBLICUSER}/" | - sed "s/:PUBLICPASS/${PUBLICPASS}/" | - sed "s/:TESTUSER/${TESTUSER}/" | - sed "s/:TESTPASS/${TESTPASS}/" | - psql -v ON_ERROR_STOP=1 ${TEST_DB} || exit 1 + psql -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";' ${TEST_DB} + psql -c "CREATE EXTENSION IF NOT EXISTS plpythonu;" ${TEST_DB} - echo "Populating windshaft_test database with reduced populated places data" - cat ./fixtures/populated_places_simple_reduced.sql | - sed "s/:PUBLICUSER/${PUBLICUSER}/" | - sed "s/:PUBLICPASS/${PUBLICPASS}/" | - sed "s/:TESTUSER/${TESTUSER}/" | - sed "s/:TESTPASS/${TESTPASS}/" | - psql -v ON_ERROR_STOP=1 ${TEST_DB} || exit 1 + LOCAL_SQL_SCRIPTS='test populated_places_simple_reduced' + REMOTE_SQL_SCRIPTS='CDB_QueryStatements CDB_QueryTables CDB_CartodbfyTable CDB_TableMetadata CDB_ForeignTable CDB_UserTables CDB_ColumnNames CDB_ZoomFromScale CDB_Overviews' - # TODO: send in a single run, togheter with test.sql - psql -c "CREATE EXTENSION plpythonu;" ${TEST_DB} - for i in CDB_QueryStatements CDB_QueryTables CDB_CartodbfyTable CDB_TableMetadata CDB_ForeignTable CDB_UserTables CDB_ColumnNames CDB_ZoomFromScale CDB_Overviews + CURL_ARGS="" + for i in ${REMOTE_SQL_SCRIPTS} do - curl -L -s https://github.com/CartoDB/cartodb-postgresql/raw/master/scripts-available/$i.sql -o support/$i.sql - cat support/$i.sql | sed -e 's/cartodb\./public./g' -e "s/''cartodb''/''public''/g" \ - | psql -v ON_ERROR_STOP=1 ${TEST_DB} || exit 1 + CURL_ARGS="${CURL_ARGS}\"https://github.com/CartoDB/cartodb-postgresql/raw/master/scripts-available/$i.sql\" -o support/sql/$i.sql " + done + echo "Downloading and updating: ${REMOTE_SQL_SCRIPTS}" + echo ${CURL_ARGS} | xargs curl -L -s + + psql -c "CREATE EXTENSION IF NOT EXISTS plpythonu;" ${TEST_DB} + ALL_SQL_SCRIPTS="${REMOTE_SQL_SCRIPTS} ${LOCAL_SQL_SCRIPTS}" + for i in ${ALL_SQL_SCRIPTS} + do + cat support/sql/${i}.sql | + sed -e 's/cartodb\./public./g' -e "s/''cartodb''/''public''/g" | + sed "s/:PUBLICUSER/${PUBLICUSER}/" | + sed "s/:PUBLICPASS/${PUBLICPASS}/" | + sed "s/:TESTUSER/${TESTUSER}/" | + sed "s/:TESTPASS/${TESTPASS}/" | + PGOPTIONS='--client-min-messages=WARNING' psql -q -v ON_ERROR_STOP=1 ${TEST_DB} > /dev/null || exit 1 done fi diff --git a/test/fixtures/populated_places_simple_reduced.sql b/test/support/sql/populated_places_simple_reduced.sql similarity index 100% rename from test/fixtures/populated_places_simple_reduced.sql rename to test/support/sql/populated_places_simple_reduced.sql diff --git a/test/test.sql b/test/support/sql/test.sql similarity index 100% rename from test/test.sql rename to test/support/sql/test.sql