diff --git a/test/acceptance/backend_crash.js b/test/acceptance/backend_crash.js index 7da4bd64..897638f9 100644 --- a/test/acceptance/backend_crash.js +++ b/test/acceptance/backend_crash.js @@ -8,11 +8,8 @@ var net = require('net'); var sql_server_port = 5540; var sql_server = net.createServer(function(c) { - console.log('server connected'); c.destroy(); - console.log('server socket destroyed.'); sql_server.close(function() { - console.log('server closed'); }); }); @@ -24,7 +21,6 @@ before(function(done){ // See https://github.com/CartoDB/CartoDB-SQL-API/issues/135 it('does not hang server', function(done){ -//console.log("settings:"); console.dir(global.settings); var db_host_backup = global.settings.db_host; var db_port_backup = global.settings.db_port; global.settings.db_host = 'localhost'; diff --git a/test/acceptance/pagination.js b/test/acceptance/pagination.js index b371e3f9..5aae8747 100644 --- a/test/acceptance/pagination.js +++ b/test/acceptance/pagination.js @@ -60,8 +60,6 @@ describe('results-pagination', function() { } } var prcur = pr[testing++]; - console.log("Test " + testing + "/" + pr.length + " method " + methods[method] + " " + - ( authorized ? "authenticated" : "" ) ); var page = prcur[0]; var nrows = prcur[1]; var data_obj = { diff --git a/test/prepare_db.sh b/test/prepare_db.sh index e633e07e..bcc26c03 100755 --- a/test/prepare_db.sh +++ b/test/prepare_db.sh @@ -7,7 +7,6 @@ PREPARE_REDIS=yes PREPARE_PGSQL=yes -OFFLINE=no while [ -n "$1" ]; do if test "$1" = "--skip-pg"; then @@ -16,9 +15,6 @@ while [ -n "$1" ]; do elif test "$1" = "--skip-redis"; then PREPARE_REDIS=no shift; continue - elif test "$1" = "--offline"; then - OFFLINE=yes - shift; continue fi done @@ -70,28 +66,14 @@ if test x"$PREPARE_PGSQL" = xyes; then echo "preparing postgres..." echo "PostgreSQL server version: `psql -A -t -c 'select version()'`" - echo "PAUSE; RESUME;" | psql -p 6432 pgbouncer # make sure there are no connections pgbouncer -> test_db - 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" + echo "PAUSE; RESUME;" | psql pgbouncer 2>/dev/null # make sure there are no connections pgbouncer -> test_db + dropdb --if-exists ${TEST_DB} || die "Could not drop test database ${TEST_DB}" + createdb -Ttemplate_postgis -EUTF8 ${TEST_DB} || die "Could not create test database ${TEST_DB}" psql -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";' ${TEST_DB} - psql -c "CREATE EXTENSION IF NOT EXISTS plpythonu;" ${TEST_DB} + psql -c "CREATE EXTENSION IF NOT EXISTS cartodb CASCADE;" ${TEST_DB} LOCAL_SQL_SCRIPTS='test populated_places_simple_reduced py_sleep quota_mock' - REMOTE_SQL_SCRIPTS='CDB_QueryStatements CDB_QueryTables CDB_CartodbfyTable CDB_TableMetadata CDB_ForeignTable CDB_UserTables CDB_ColumnNames CDB_ZoomFromScale CDB_OverviewsSupport CDB_Overviews' - - if test x"$OFFLINE" = xno; then - CURL_ARGS="" - for i in ${REMOTE_SQL_SCRIPTS} - do - 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 - fi - - 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} + for i in ${LOCAL_SQL_SCRIPTS} do cat support/sql/${i}.sql | sed -e 's/cartodb\./public./g' -e "s/''cartodb''/''public''/g" | diff --git a/test/run_tests.sh b/test/run_tests.sh index 95a0a280..fb2239c3 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -17,8 +17,6 @@ OPT_CREATE_REDIS=yes # create/prepare the redis test databases OPT_DROP_PGSQL=yes # drop the postgreql test environment OPT_DROP_REDIS=yes # drop the redis test environment OPT_COVERAGE=no # run tests with coverage -OPT_OFFLINE=no # do not donwload scripts - cd $(dirname $0) BASEDIR=$(pwd) @@ -87,10 +85,6 @@ while [ -n "$1" ]; do OPT_COVERAGE=yes shift continue - elif test "$1" = "--offline"; then - OPT_OFFLINE=yes - shift - continue else break fi @@ -129,9 +123,6 @@ fi if test x"$OPT_CREATE_REDIS" != xyes; then PREPARE_DB_OPTS="$PREPARE_DB_OPTS --skip-redis" fi -if test x"$OPT_OFFLINE" == xyes; then - PREPARE_DB_OPTS="$PREPARE_DB_OPTS --offline" -fi echo "Preparing the environment" cd ${BASEDIR} diff --git a/test/run_tests_docker.sh b/test/run_tests_docker.sh index c88f5896..217ce06b 100644 --- a/test/run_tests_docker.sh +++ b/test/run_tests_docker.sh @@ -7,6 +7,10 @@ source /src/nodejs-install.sh # Configure ./configure +# Install cartodb-postgresql extension +git clone https://github.com/CartoDB/cartodb-postgresql.git +cd cartodb-postgresql && make && make install && cd .. + echo "Node.js version: " node -v diff --git a/test/support/sql/test.sql b/test/support/sql/test.sql index 33d02f1b..fe33ed8f 100644 --- a/test/support/sql/test.sql +++ b/test/support/sql/test.sql @@ -16,7 +16,7 @@ SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -SET search_path = public, pg_catalog; +SET search_path = public, cartodb, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; @@ -160,6 +160,8 @@ DROP USER IF EXISTS :PUBLICUSER; CREATE USER :PUBLICUSER WITH PASSWORD ':PUBLICPASS'; ALTER ROLE :PUBLICUSER SET statement_timeout = 2000; GRANT SELECT ON TABLE scoped_table_1 TO :PUBLICUSER; +GRANT USAGE ON SCHEMA cartodb TO :PUBLICUSER; +GRANT ALL ON CDB_TableMetadata TO :PUBLICUSER; -- regular user role 1 DROP USER IF EXISTS regular_1; @@ -168,22 +170,31 @@ ALTER ROLE regular_1 SET statement_timeout = 2000; GRANT ALL ON TABLE scoped_table_1 TO regular_1; GRANT ALL ON SEQUENCE scoped_table_1_cartodb_id_seq TO regular_1; +GRANT USAGE ON SCHEMA cartodb TO regular_1; +GRANT ALL ON CDB_TableMetadata TO regular_1; -- regular user role 2 DROP USER IF EXISTS regular_2; CREATE USER regular_2 WITH PASSWORD 'regular2'; ALTER ROLE regular_2 SET statement_timeout = 2000; +GRANT USAGE ON SCHEMA cartodb TO regular_2; +GRANT ALL ON CDB_TableMetadata TO regular_2; -- fallback user role DROP USER IF EXISTS test_cartodb_user_2; CREATE USER test_cartodb_user_2 WITH PASSWORD 'test_cartodb_user_2_pass'; GRANT ALL ON TABLE scoped_table_1 TO test_cartodb_user_2; GRANT ALL ON SEQUENCE scoped_table_1_cartodb_id_seq TO test_cartodb_user_2; +GRANT USAGE ON SCHEMA cartodb TO test_cartodb_user_2; +GRANT ALL ON CDB_TableMetadata TO test_cartodb_user_2; -- db owner role DROP USER IF EXISTS :TESTUSER; CREATE USER :TESTUSER WITH PASSWORD ':TESTPASS'; +GRANT USAGE ON SCHEMA cartodb TO :TESTUSER; +GRANT ALL ON CDB_TableMetadata TO :TESTUSER; + GRANT ALL ON TABLE untitle_table_4 TO :TESTUSER; GRANT SELECT ON TABLE untitle_table_4 TO :PUBLICUSER; GRANT ALL ON TABLE private_table TO :TESTUSER; @@ -205,12 +216,6 @@ GRANT ALL ON TABLE cpg_test TO :TESTUSER; GRANT SELECT ON TABLE cpg_test TO :PUBLICUSER; -CREATE TABLE IF NOT EXISTS - CDB_TableMetadata ( - tabname regclass not null primary key, - updated_at timestamp with time zone not null default now() - ); - INSERT INTO CDB_TableMetadata (tabname, updated_at) VALUES ('untitle_table_4'::regclass, '2014-01-01T23:31:30.123Z'); INSERT INTO CDB_TableMetadata (tabname, updated_at) VALUES ('private_table'::regclass, '2015-01-01T23:31:30.123Z'); INSERT INTO CDB_TableMetadata (tabname, updated_at) VALUES ('scoped_table_1'::regclass, '2015-01-01T23:31:30.123Z');