2011-10-20 22:44:37 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# this script prepare database and redis instance to run accpetance test
|
2012-07-04 01:31:30 +08:00
|
|
|
#
|
|
|
|
# NOTE: assumes existance of a "template_postgis"
|
|
|
|
# NOTE2: use PG* environment variables to control who and where
|
2012-07-09 21:50:23 +08:00
|
|
|
#
|
|
|
|
# NOTE3: a side effect of the db preparation is the persistent creation
|
|
|
|
# of two database roles which will be valid for the whole cluster
|
|
|
|
# TODO: fix that
|
|
|
|
#
|
2012-07-04 01:31:30 +08:00
|
|
|
|
|
|
|
die() {
|
|
|
|
msg=$1
|
|
|
|
echo "${msg}" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
2011-10-20 22:44:37 +08:00
|
|
|
|
2012-07-09 21:44:01 +08:00
|
|
|
TEST_DB="cartodb_test_user_1_db"
|
2012-07-10 00:56:09 +08:00
|
|
|
REDIS_PORT=6333
|
2011-10-20 22:44:37 +08:00
|
|
|
|
|
|
|
echo "preparing postgres..."
|
2012-07-09 21:44:01 +08:00
|
|
|
dropdb "${TEST_DB}"
|
|
|
|
createdb -Ttemplate_postgis -EUTF8 "${TEST_DB}" || die "Could not create test database"
|
|
|
|
psql "${TEST_DB}" < ./sql/windshaft.test.sql
|
|
|
|
psql "${TEST_DB}" < ./sql/gadm4.sql
|
2011-10-20 22:44:37 +08:00
|
|
|
|
2012-07-10 00:56:09 +08:00
|
|
|
echo "preparing redis..."
|
2012-07-11 01:37:24 +08:00
|
|
|
echo "HSET rails:users:vizzuality id 1" | redis-cli -p ${REDIS_PORT} -n 5
|
|
|
|
echo 'HSET rails:users:vizzuality database_name "'"${TEST_DB}"'"' | redis-cli -p ${REDIS_PORT} -n 5
|
2012-08-02 16:42:12 +08:00
|
|
|
echo "HSET rails:users:vizzuality map_key 1234" | redis-cli -p ${REDIS_PORT} -n 5
|
|
|
|
echo "SADD rails:users:vizzuality:map_key 1235" | redis-cli -p ${REDIS_PORT} -n 5
|
2012-07-11 01:37:24 +08:00
|
|
|
echo 'HSET rails:'"${TEST_DB}"':my_table infowindow "this, that, the other"' | redis-cli -p ${REDIS_PORT} -n 0
|
2012-07-10 00:56:09 +08:00
|
|
|
|
2011-12-13 02:02:10 +08:00
|
|
|
echo "Finished preparing data. Run tests with expresso."
|