Merge branch 'master' into 498-pgtypes

This commit is contained in:
Daniel García Aubert 2019-06-03 20:49:10 +02:00
commit 4a342bce83
6 changed files with 21 additions and 45 deletions

View File

@ -8,11 +8,8 @@ var net = require('net');
var sql_server_port = 5540; var sql_server_port = 5540;
var sql_server = net.createServer(function(c) { var sql_server = net.createServer(function(c) {
console.log('server connected');
c.destroy(); c.destroy();
console.log('server socket destroyed.');
sql_server.close(function() { 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 // See https://github.com/CartoDB/CartoDB-SQL-API/issues/135
it('does not hang server', function(done){ it('does not hang server', function(done){
//console.log("settings:"); console.dir(global.settings);
var db_host_backup = global.settings.db_host; var db_host_backup = global.settings.db_host;
var db_port_backup = global.settings.db_port; var db_port_backup = global.settings.db_port;
global.settings.db_host = 'localhost'; global.settings.db_host = 'localhost';

View File

@ -60,8 +60,6 @@ describe('results-pagination', function() {
} }
} }
var prcur = pr[testing++]; var prcur = pr[testing++];
console.log("Test " + testing + "/" + pr.length + " method " + methods[method] + " " +
( authorized ? "authenticated" : "" ) );
var page = prcur[0]; var page = prcur[0];
var nrows = prcur[1]; var nrows = prcur[1];
var data_obj = { var data_obj = {

View File

@ -7,7 +7,6 @@
PREPARE_REDIS=yes PREPARE_REDIS=yes
PREPARE_PGSQL=yes PREPARE_PGSQL=yes
OFFLINE=no
while [ -n "$1" ]; do while [ -n "$1" ]; do
if test "$1" = "--skip-pg"; then if test "$1" = "--skip-pg"; then
@ -16,9 +15,6 @@ while [ -n "$1" ]; do
elif test "$1" = "--skip-redis"; then elif test "$1" = "--skip-redis"; then
PREPARE_REDIS=no PREPARE_REDIS=no
shift; continue shift; continue
elif test "$1" = "--offline"; then
OFFLINE=yes
shift; continue
fi fi
done done
@ -70,28 +66,14 @@ if test x"$PREPARE_PGSQL" = xyes; then
echo "preparing postgres..." echo "preparing postgres..."
echo "PostgreSQL server version: `psql -A -t -c 'select version()'`" 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 echo "PAUSE; RESUME;" | psql pgbouncer 2>/dev/null # make sure there are no connections pgbouncer -> test_db
dropdb ${TEST_DB} # 2> /dev/null # error expected if doesn't exist, but not otherwise 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" 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 "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' 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' for i in ${LOCAL_SQL_SCRIPTS}
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}
do do
cat support/sql/${i}.sql | cat support/sql/${i}.sql |
sed -e 's/cartodb\./public./g' -e "s/''cartodb''/''public''/g" | sed -e 's/cartodb\./public./g' -e "s/''cartodb''/''public''/g" |

View File

@ -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_PGSQL=yes # drop the postgreql test environment
OPT_DROP_REDIS=yes # drop the redis test environment OPT_DROP_REDIS=yes # drop the redis test environment
OPT_COVERAGE=no # run tests with coverage OPT_COVERAGE=no # run tests with coverage
OPT_OFFLINE=no # do not donwload scripts
cd $(dirname $0) cd $(dirname $0)
BASEDIR=$(pwd) BASEDIR=$(pwd)
@ -87,10 +85,6 @@ while [ -n "$1" ]; do
OPT_COVERAGE=yes OPT_COVERAGE=yes
shift shift
continue continue
elif test "$1" = "--offline"; then
OPT_OFFLINE=yes
shift
continue
else else
break break
fi fi
@ -129,9 +123,6 @@ fi
if test x"$OPT_CREATE_REDIS" != xyes; then if test x"$OPT_CREATE_REDIS" != xyes; then
PREPARE_DB_OPTS="$PREPARE_DB_OPTS --skip-redis" PREPARE_DB_OPTS="$PREPARE_DB_OPTS --skip-redis"
fi fi
if test x"$OPT_OFFLINE" == xyes; then
PREPARE_DB_OPTS="$PREPARE_DB_OPTS --offline"
fi
echo "Preparing the environment" echo "Preparing the environment"
cd ${BASEDIR} cd ${BASEDIR}

View File

@ -7,6 +7,10 @@ source /src/nodejs-install.sh
# Configure # Configure
./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: " echo "Node.js version: "
node -v node -v

View File

@ -16,7 +16,7 @@ SET standard_conforming_strings = off;
SET check_function_bodies = false; SET check_function_bodies = false;
SET client_min_messages = warning; SET client_min_messages = warning;
SET escape_string_warning = off; SET escape_string_warning = off;
SET search_path = public, pg_catalog; SET search_path = public, cartodb, pg_catalog;
SET default_tablespace = ''; SET default_tablespace = '';
SET default_with_oids = false; SET default_with_oids = false;
@ -160,6 +160,8 @@ DROP USER IF EXISTS :PUBLICUSER;
CREATE USER :PUBLICUSER WITH PASSWORD ':PUBLICPASS'; CREATE USER :PUBLICUSER WITH PASSWORD ':PUBLICPASS';
ALTER ROLE :PUBLICUSER SET statement_timeout = 2000; ALTER ROLE :PUBLICUSER SET statement_timeout = 2000;
GRANT SELECT ON TABLE scoped_table_1 TO :PUBLICUSER; 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 -- regular user role 1
DROP USER IF EXISTS regular_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 TABLE scoped_table_1 TO regular_1;
GRANT ALL ON SEQUENCE scoped_table_1_cartodb_id_seq 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 -- regular user role 2
DROP USER IF EXISTS regular_2; DROP USER IF EXISTS regular_2;
CREATE USER regular_2 WITH PASSWORD 'regular2'; CREATE USER regular_2 WITH PASSWORD 'regular2';
ALTER ROLE regular_2 SET statement_timeout = 2000; 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 -- fallback user role
DROP USER IF EXISTS test_cartodb_user_2; DROP USER IF EXISTS test_cartodb_user_2;
CREATE USER test_cartodb_user_2 WITH PASSWORD 'test_cartodb_user_2_pass'; 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 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 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 -- db owner role
DROP USER IF EXISTS :TESTUSER; DROP USER IF EXISTS :TESTUSER;
CREATE USER :TESTUSER WITH PASSWORD ':TESTPASS'; 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 ALL ON TABLE untitle_table_4 TO :TESTUSER;
GRANT SELECT ON TABLE untitle_table_4 TO :PUBLICUSER; GRANT SELECT ON TABLE untitle_table_4 TO :PUBLICUSER;
GRANT ALL ON TABLE private_table TO :TESTUSER; 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; 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 ('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 ('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'); INSERT INTO CDB_TableMetadata (tabname, updated_at) VALUES ('scoped_table_1'::regclass, '2015-01-01T23:31:30.123Z');