From bc5d5327350f4cd515b1efc398f0454f62c01924 Mon Sep 17 00:00:00 2001 From: Gonzalo Riestra Date: Wed, 13 Mar 2019 16:34:12 +0100 Subject: [PATCH] remove default TIS config --- scripts-available/CDB_GhostTables.sql | 9 ++++++--- test/CDB_GhostTables.sql | 13 +++++++++++-- test/CDB_GhostTables_expect | 4 ++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts-available/CDB_GhostTables.sql b/scripts-available/CDB_GhostTables.sql index cb48e88..6fed1e8 100644 --- a/scripts-available/CDB_GhostTables.sql +++ b/scripts-available/CDB_GhostTables.sql @@ -12,9 +12,12 @@ AS $$ json = GD['json'] tis_config = plpy.execute("select cartodb.CDB_Conf_GetConf('invalidation_service');")[0]['cdb_conf_getconf'] - tis_config_dict = json.loads(tis_config) if tis_config else {} - tis_host = tis_config_dict.get('host', '127.0.0.1') - tis_port = tis_config_dict.get('port', 3142) + if not tis_config: + return + + tis_config_dict = json.loads(tis_config) + tis_host = tis_config_dict.get('host') + tis_port = tis_config_dict.get('port') tis_timeout = tis_config_dict.get('timeout', 5) tis_retry = tis_config_dict.get('retry', 5) diff --git a/test/CDB_GhostTables.sql b/test/CDB_GhostTables.sql index 33fae5b..1c1e244 100644 --- a/test/CDB_GhostTables.sql +++ b/test/CDB_GhostTables.sql @@ -7,12 +7,21 @@ GRANT ALL ON SCHEMA cartodb TO "fulano"; GRANT SELECT ON cartodb.cdb_ddl_execution TO "fulano"; GRANT EXECUTE ON FUNCTION CDB_Username() TO "fulano"; GRANT EXECUTE ON FUNCTION CDB_LinkGhostTables(text) TO "fulano"; -INSERT INTO cdb_conf (key, value) VALUES ('api_keys_fulano', '{"username": "fulanito", "permissions":[]}'); -INSERT INTO cdb_conf (key, value) VALUES ('invalidation_service', '{"host": "fake-tis-host"}'); +SELECT cartodb.CDB_Conf_SetConf('api_keys_fulano', '{"username": "fulanito", "permissions":[]}'); +DELETE FROM cdb_conf WHERE key = 'invalidation_service'; SET SESSION AUTHORIZATION "fulano"; SET client_min_messages TO notice; \set QUIET off +SELECT CDB_LinkGhostTables(); -- _CDB_LinkGhostTables called, TIS connection not tried + +-- Disable Ghost tables trigger +\set QUIET on +SET SESSION AUTHORIZATION postgres; +SELECT cartodb.CDB_Conf_SetConf('invalidation_service', '{"host": "fake-tis-host", "port": 3142}'); +SET SESSION AUTHORIZATION "fulano"; +\set QUIET off + SELECT CDB_LinkGhostTables(); -- _CDB_LinkGhostTables called BEGIN; diff --git a/test/CDB_GhostTables_expect b/test/CDB_GhostTables_expect index 3e46518..4300a01 100644 --- a/test/CDB_GhostTables_expect +++ b/test/CDB_GhostTables_expect @@ -1,4 +1,8 @@ + +NOTICE: _CDB_LinkGhostTables() called with username=fulanito, event_name=USER + + WARNING: Invalidation Service error: Error -2 connecting fake-tis-host:3142. Name or service not known. NOTICE: _CDB_LinkGhostTables() called with username=fulanito, event_name=USER