From 7f9905cbd5979a2902a61105f4f2257611d53ad1 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Thu, 14 Nov 2019 17:56:29 +0100 Subject: [PATCH] Test what happens when missing PG port --- test/CDB_FederatedServerDiagnostics.sql | 39 +++++++++++++++++-------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/test/CDB_FederatedServerDiagnostics.sql b/test/CDB_FederatedServerDiagnostics.sql index aadb124..da5e8cb 100644 --- a/test/CDB_FederatedServerDiagnostics.sql +++ b/test/CDB_FederatedServerDiagnostics.sql @@ -23,6 +23,27 @@ SELECT 'C1', cartodb.CDB_Federated_Server_Register_PG(server => 'loopback'::text } }'::jsonb); +SELECT 'C2', cartodb.CDB_Federated_Server_Register_PG(server => 'wrong-port'::text, config => '{ + "server": { + "host": "localhost", + "port": "12345" + }, + "credentials": { + "username": "cdb_fs_tester", + "password": "cdb_fs_passwd" + } +}'::jsonb); + +SELECT 'C3', cartodb.CDB_Federated_Server_Register_PG(server => 'loopback-no-port'::text, config => '{ + "server": { + "host": "localhost" + }, + "credentials": { + "username": "cdb_fs_tester", + "password": "cdb_fs_passwd" + } +}'::jsonb); + \c cdb_fs_tester postgres CREATE EXTENSION postgis; \c contrib_regression postgres @@ -75,21 +96,14 @@ WITH latency AS ( ) SELECT '2.3', (latency.ms->'stdev')::text::float >= 0.0 FROM latency; - - \echo '%% It raises an error if the wrong port is provided' -SELECT 'C2', cartodb.CDB_Federated_Server_Register_PG(server => 'wrong-port'::text, config => '{ - "server": { - "host": "localhost", - "port": "12345" - }, - "credentials": { - "username": "cdb_fs_tester", - "password": "cdb_fs_passwd" - } -}'::jsonb); 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; -- =================================================================== @@ -98,6 +112,7 @@ SELECT '3.0', cartodb.CDB_Federated_Server_Diagnostics(server => 'wrong-port'); \set QUIET on SELECT 'D1', cartodb.CDB_Federated_Server_Unregister(server => 'loopback'::text); SELECT 'D2', cartodb.CDB_Federated_Server_Unregister(server => 'wrong-port'::text); +SELECT 'D3', cartodb.CDB_Federated_Server_Unregister(server => 'loopback-no-port'::text); -- Reconnect, using a new session in order to close FDW connections \connect DROP DATABASE cdb_fs_tester;