From 47f06f40df6a1299d78f1d9df2f447353505ce88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Mar=C3=ADn?= Date: Thu, 26 Mar 2020 12:49:15 +0100 Subject: [PATCH 1/5] Remove leftover plpython warnings --- scripts-available/CDB_Groups_API.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts-available/CDB_Groups_API.sql b/scripts-available/CDB_Groups_API.sql index f5562a0..a0a3044 100644 --- a/scripts-available/CDB_Groups_API.sql +++ b/scripts-available/CDB_Groups_API.sql @@ -201,13 +201,10 @@ $$ import base64 data_to_encode = '%s:%s' % (username, password) - plpy.warning('DEBUG: _CDB_Group_API_Auth python v' + str(sys.version_info[0])) if sys.version_info[0] < 3: data_encoded = base64.encodestring(data_to_encode) else: - plpy.warning('DEBUG: _CDB_Group_API_Auth entra') data_encoded = base64.b64encode(data_to_encode.encode()).decode() - plpy.warning('DEBUG: _CDB_Group_API_Auth sale') data_encoded = data_encoded.replace('\n', '') return data_encoded From 2fcdd563384ab1817ffa46fc6dfdb6943f29e650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Mar=C3=ADn?= Date: Thu, 26 Mar 2020 16:37:18 +0100 Subject: [PATCH 2/5] Travis: Keep installed releases, and only rebuild the target --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 28e2200..1bbb0fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,6 @@ env: - PGUSER=postgres - PGDATABASE=postgres - PGOPTIONS='-c client_min_messages=NOTICE' - - PGPORT=5432 jobs: include: @@ -22,17 +21,16 @@ jobs: dist: bionic script: - - sudo service postgresql stop; - - sudo apt-get remove postgresql* -y - sudo apt-get install -y --allow-unauthenticated --no-install-recommends --no-install-suggests postgresql-$POSTGRESQL_VERSION postgresql-client-$POSTGRESQL_VERSION postgresql-server-dev-$POSTGRESQL_VERSION postgresql-common - if [[ $POSTGRESQL_VERSION == '9.6' ]]; then sudo apt-get install -y postgresql-contrib-9.6; fi; - sudo apt-get install -y --allow-unauthenticated postgresql-$POSTGRESQL_VERSION-postgis-$POSTGIS_VERSION postgresql-$POSTGRESQL_VERSION-postgis-$POSTGIS_VERSION-scripts postgis # For pre12, install plpython2. For PG12 install plpython3 - if [[ $POSTGRESQL_VERSION != '12' ]]; then sudo apt-get install -y postgresql-plpython-$POSTGRESQL_VERSION python python-redis; else sudo apt-get install -y postgresql-plpython3-12 python3 python3-redis; fi; - sudo pg_dropcluster --stop $POSTGRESQL_VERSION main - - sudo rm -rf /etc/postgresql/$POSTGRESQL_VERSION /var/lib/postgresql/$POSTGRESQL_VERSION + - sudo rm -rf /etc/postgresql/$POSTGRESQL_VERSION /var/lib/postgresql/$POSTGRESQL_VERSION /var/ramfs/postgresql/$POSTGRESQL_VERSION - sudo pg_createcluster -u postgres $POSTGRESQL_VERSION main -- --auth-local trust --auth-host password - sudo /etc/init.d/postgresql start $POSTGRESQL_VERSION || sudo journalctl -xe + - export PGPORT=$(pg_lsclusters | grep $POSTGRESQL_VERSION | awk '{print $3}') - make - sudo make install - make installcheck @@ -41,3 +39,4 @@ after_failure: - pg_lsclusters - cat regression.out - cat regression.diffs + - echo $PGPORT From f790dc187296770eb3692230cee07de8d53c8194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Mar=C3=ADn?= Date: Thu, 26 Mar 2020 16:37:58 +0100 Subject: [PATCH 3/5] Adapt tests to work with other ports (not 5432) --- test/CDB_FederatedServerDiagnostics.sql | 11 ++++++----- test/CDB_FederatedServerDiagnostics_expect | 2 -- test/CDB_FederatedServer_expect | 22 +++++++++++----------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/test/CDB_FederatedServerDiagnostics.sql b/test/CDB_FederatedServerDiagnostics.sql index da5e8cb..45cdd5b 100644 --- a/test/CDB_FederatedServerDiagnostics.sql +++ b/test/CDB_FederatedServerDiagnostics.sql @@ -99,11 +99,12 @@ FROM latency; \echo '%% It raises an error if the wrong port is provided' SELECT '3.0', cartodb.CDB_Federated_Server_Diagnostics(server => 'wrong-port'); -\echo '%% Latency stats: can get them on default PG port 5432 when not provided' -WITH latency AS ( - SELECT CDB_Federated_Server_Diagnostics('loopback-no-port')->'server_latency_ms' ms -) SELECT '2.4', 0.0 <= (latency.ms->'min')::text::float, (latency.ms->'max')::text::float <= 1000.0 -FROM latency; +-- Disabled: It's not compatibly with Travis since the target database (self) might be in a different port +-- \echo '%% Latency stats: can get them on default PG port 5432 when not provided' +-- WITH latency AS ( +-- SELECT CDB_Federated_Server_Diagnostics('loopback-no-port')->'server_latency_ms' ms +-- ) SELECT '2.4', 0.0 <= (latency.ms->'min')::text::float, (latency.ms->'max')::text::float <= 1000.0 +-- FROM latency; -- =================================================================== diff --git a/test/CDB_FederatedServerDiagnostics_expect b/test/CDB_FederatedServerDiagnostics_expect index 044ad2f..2843c64 100644 --- a/test/CDB_FederatedServerDiagnostics_expect +++ b/test/CDB_FederatedServerDiagnostics_expect @@ -21,8 +21,6 @@ ERROR: Server "doesNotExist" does not exist 2.3|t %% It raises an error if the wrong port is provided ERROR: could not connect to server "cdb_fs_wrong-port" -%% Latency stats: can get them on default PG port 5432 when not provided -2.4|t|t D1| D2| D3| diff --git a/test/CDB_FederatedServer_expect b/test/CDB_FederatedServer_expect index 836646d..5e6fe72 100644 --- a/test/CDB_FederatedServer_expect +++ b/test/CDB_FederatedServer_expect @@ -2,20 +2,20 @@ ## List non-existent server shows nothing ## Create and list a server works 1.3| -1.4|(myRemote,postgres_fdw,localhost,5432,,read-only,fdw_user) +1.4|(myRemote,postgres_fdw,localhost,@@PGPORT@@,,read-only,fdw_user) ## Create and list a second server works 2.1| -2.2|(myRemote,postgres_fdw,localhost,5432,,read-only,fdw_user) -2.2|(myRemote2,postgres_fdw,localhost,5432,fdw_target,read-only,fdw_user) +2.2|(myRemote,postgres_fdw,localhost,@@PGPORT@@,,read-only,fdw_user) +2.2|(myRemote2,postgres_fdw,localhost,@@PGPORT@@,fdw_target,read-only,fdw_user) ## List server by name works -2.3|(myRemote,postgres_fdw,localhost,5432,,read-only,fdw_user) +2.3|(myRemote,postgres_fdw,localhost,@@PGPORT@@,,read-only,fdw_user) ## Re-register a second server works 3.1| -3.2|(myRemote,postgres_fdw,localhost,5432,,read-only,fdw_user) -3.2|(myRemote2,postgres_fdw,localhost,5432,fdw_target,read-only,other_remote_user) +3.2|(myRemote,postgres_fdw,localhost,@@PGPORT@@,,read-only,fdw_user) +3.2|(myRemote2,postgres_fdw,localhost,@@PGPORT@@,fdw_target,read-only,other_remote_user) ## Unregister server 1 works 4.1| -4.2|(myRemote2,postgres_fdw,localhost,5432,fdw_target,read-only,other_remote_user) +4.2|(myRemote2,postgres_fdw,localhost,@@PGPORT@@,fdw_target,read-only,other_remote_user) ## Unregistering a server that does not exist fails ERROR: Server "doesNotExist" does not exist ## Unregister the second server works @@ -30,25 +30,25 @@ ERROR: Server information is mandatory ERROR: Credentials are mandatory ## Create a server with empty credentials works 7.3| -7.4|(empty,postgres_fdw,localhost,5432,fdw_target,read-only,) +7.4|(empty,postgres_fdw,localhost,@@PGPORT@@,fdw_target,read-only,) 7.5| ## Create a server without options fails ERROR: Server information is mandatory ## Create a server with special characters works 8.1| -8.2|("myRemote"" or'not",postgres_fdw,localhost,5432,"fdw target",read-only,"fdw user") +8.2|("myRemote"" or'not",postgres_fdw,localhost,@@PGPORT@@,"fdw target",read-only,"fdw user") 8.3| 9.1| You are now connected to database "contrib_regression" as user "cdb_fs_tester". ## All users are able to list servers -9.2|(myRemote3,postgres_fdw,localhost,5432,,read-only,) +9.2|(myRemote3,postgres_fdw,localhost,@@PGPORT@@,,read-only,) ## Only superadmins can create servers ERROR: Could not create server myRemote4: permission denied for foreign-data wrapper postgres_fdw You are now connected to database "contrib_regression" as user "postgres". ## Granting access to a user works 9.5| You are now connected to database "contrib_regression" as user "cdb_fs_tester". -9.55|(myRemote3,postgres_fdw,localhost,5432,,read-only,fdw_user) +9.55|(myRemote3,postgres_fdw,localhost,@@PGPORT@@,,read-only,fdw_user) You are now connected to database "contrib_regression" as user "postgres". ERROR: Server "does not exist" does not exist ERROR: Could not grant access on "myRemote3" to "does not exist": role "does not exist" does not exist From 422d1a0acd9fc47ff39c68af165b55861de659c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Mar=C3=ADn?= Date: Thu, 26 Mar 2020 16:49:53 +0100 Subject: [PATCH 4/5] Try to initialize in the same command as the creation --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1bbb0fb..0320fe1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,8 +28,7 @@ script: - if [[ $POSTGRESQL_VERSION != '12' ]]; then sudo apt-get install -y postgresql-plpython-$POSTGRESQL_VERSION python python-redis; else sudo apt-get install -y postgresql-plpython3-12 python3 python3-redis; fi; - sudo pg_dropcluster --stop $POSTGRESQL_VERSION main - sudo rm -rf /etc/postgresql/$POSTGRESQL_VERSION /var/lib/postgresql/$POSTGRESQL_VERSION /var/ramfs/postgresql/$POSTGRESQL_VERSION - - sudo pg_createcluster -u postgres $POSTGRESQL_VERSION main -- --auth-local trust --auth-host password - - sudo /etc/init.d/postgresql start $POSTGRESQL_VERSION || sudo journalctl -xe + - sudo pg_createcluster -u postgres $POSTGRESQL_VERSION main --start -- --auth-local trust --auth-host password - export PGPORT=$(pg_lsclusters | grep $POSTGRESQL_VERSION | awk '{print $3}') - make - sudo make install @@ -40,3 +39,4 @@ after_failure: - cat regression.out - cat regression.diffs - echo $PGPORT + - cat /var/log/postgresql/postgresql-$POSTGRESQL_VERSION-main.log From 38f26f4e8bb3af6724236fc65d94760b2c05b2ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Mar=C3=ADn?= Date: Thu, 26 Mar 2020 17:03:27 +0100 Subject: [PATCH 5/5] Typo --- test/CDB_FederatedServerDiagnostics.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CDB_FederatedServerDiagnostics.sql b/test/CDB_FederatedServerDiagnostics.sql index 45cdd5b..bafefaa 100644 --- a/test/CDB_FederatedServerDiagnostics.sql +++ b/test/CDB_FederatedServerDiagnostics.sql @@ -99,7 +99,7 @@ FROM latency; \echo '%% It raises an error if the wrong port is provided' SELECT '3.0', cartodb.CDB_Federated_Server_Diagnostics(server => 'wrong-port'); --- Disabled: It's not compatibly with Travis since the target database (self) might be in a different port +-- Disabled: It's not compatible with Travis since the target database (self) might be in a different port -- \echo '%% Latency stats: can get them on default PG port 5432 when not provided' -- WITH latency AS ( -- SELECT CDB_Federated_Server_Diagnostics('loopback-no-port')->'server_latency_ms' ms