Enable running all tests via "installcheck"
NOTE: also makes CDB_TableMetadata triggers still functional when user quota and varnish invalidation functions are missing from the database (currently installed by cartodb ruby)
This commit is contained in:
parent
82c8259de6
commit
15740f2ef6
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
cartodb--*.sql
|
||||
results/
|
||||
regression.*
|
||||
expected/test
|
||||
sql/test
|
||||
|
29
Makefile
29
Makefile
@ -9,9 +9,10 @@ CDBSCRIPTS = \
|
||||
|
||||
DATA_built = $(EXTENSION)--$(EXTVERSION).sql
|
||||
DOCS = README.md
|
||||
REGRESS_EXTENSION = test_ddl_triggers
|
||||
REGRESS_LEGACY = test/CDB_DigitSeparatorTest
|
||||
REGRESS = $(REGRESS_EXTENSION)
|
||||
REGRESS_NEW = test_ddl_triggers
|
||||
REGRESS_OLD = $(wildcard test/*.sql)
|
||||
REGRESS_LEGACY = $(REGRESS_OLD:.sql=)
|
||||
REGRESS = test_setup $(REGRESS_NEW) $(REGRESS_LEGACY)
|
||||
|
||||
PG_CONFIG = pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
@ -24,3 +25,25 @@ $(EXTENSION)--$(EXTVERSION).sql: $(CDBSCRIPTS) cartodb_hooks.sql Makefile
|
||||
-e 's/:DATABASE_USERNAME/cdb_org_admin/g' >> $@
|
||||
echo "GRANT USAGE ON SCHEMA cartodb TO public;" >> $@
|
||||
cat cartodb_hooks.sql >> $@
|
||||
|
||||
legacy_regress: $(REGRESS_OLD) Makefile
|
||||
mkdir -p sql/test/
|
||||
mkdir -p expected/test/
|
||||
for f in $(REGRESS_OLD); do \
|
||||
tn=`basename $${f} .sql`; \
|
||||
of=sql/test/$${tn}.sql; \
|
||||
echo '\\set ECHO off' > $${of}; \
|
||||
echo '\\a' >> $${of}; \
|
||||
echo '\\t' >> $${of}; \
|
||||
echo '\\set QUIET off' >> $${of}; \
|
||||
cat $${f} | \
|
||||
sed -e 's/\<public\./cartodb./g' >> $${of}; \
|
||||
exp=expected/test/$${tn}.out; \
|
||||
echo '\\set ECHO off' > $${exp}; \
|
||||
cat test/$${tn}_expect >> $${exp}; \
|
||||
done
|
||||
|
||||
legacy_tests: legacy_regress
|
||||
|
||||
installcheck: legacy_tests
|
||||
|
||||
|
@ -1,8 +1,4 @@
|
||||
CREATE EXTENSION postgis;
|
||||
CREATE EXTENSION schema_triggers;
|
||||
CREATE EXTENSION cartodb;
|
||||
set search_path to public,cartodb,schema_triggers;
|
||||
--set client_min_messages to debug;
|
||||
\set VERBOSITY terse
|
||||
-- Create a stub cdb_invalidate_varnish function if not available
|
||||
--CREATE FUNCTION tmp() returns void AS $$
|
||||
DO $$
|
||||
@ -24,6 +20,11 @@ SET SESSION AUTHORIZATION 'cartodb_postgresql_unpriv_user';
|
||||
-- CREATE TABLE
|
||||
----------------------
|
||||
select 1 as i INTO c.t3;
|
||||
NOTICE: trigger "track_updates" for table "c.t3" does not exist, skipping
|
||||
NOTICE: trigger "update_the_geom_webmercator_trigger" for table "c.t3" does not exist, skipping
|
||||
NOTICE: trigger "update_updated_at_trigger" for table "c.t3" does not exist, skipping
|
||||
NOTICE: trigger "test_quota" for table "c.t3" does not exist, skipping
|
||||
NOTICE: trigger "test_quota_per_row" for table "c.t3" does not exist, skipping
|
||||
select
|
||||
cartodb_id, created_at=updated_at as "c=u",
|
||||
NOW() - updated_at < '1 secs' as "u<1s",
|
||||
@ -54,6 +55,15 @@ select pg_sleep(1);
|
||||
(1 row)
|
||||
|
||||
alter table c.t3 rename column the_geom_webmercator to webmerc;
|
||||
NOTICE: Column cartodb_id already exists
|
||||
NOTICE: Column created_at already exists
|
||||
NOTICE: Column updated_at already exists
|
||||
NOTICE: Column the_geom already exists
|
||||
NOTICE: event trigger "cdb_on_relation_create" does not exist, skipping
|
||||
NOTICE: event trigger "cdb_on_relation_drop" does not exist, skipping
|
||||
NOTICE: event trigger "cdb_on_alter_column" does not exist, skipping
|
||||
NOTICE: event trigger "cdb_on_drop_column" does not exist, skipping
|
||||
NOTICE: event trigger "cdb_on_add_column" does not exist, skipping
|
||||
select
|
||||
cartodb_id, created_at=updated_at as "c=u",
|
||||
NOW() - updated_at < '1 secs' as "u<1s",
|
||||
@ -81,6 +91,15 @@ select pg_sleep(1);
|
||||
(1 row)
|
||||
|
||||
alter table c.t3 rename column the_geom_webmercator to webmerc2;
|
||||
NOTICE: Column cartodb_id already exists
|
||||
NOTICE: Column created_at already exists
|
||||
NOTICE: Column updated_at already exists
|
||||
NOTICE: Column the_geom already exists
|
||||
NOTICE: event trigger "cdb_on_relation_create" does not exist, skipping
|
||||
NOTICE: event trigger "cdb_on_relation_drop" does not exist, skipping
|
||||
NOTICE: event trigger "cdb_on_alter_column" does not exist, skipping
|
||||
NOTICE: event trigger "cdb_on_drop_column" does not exist, skipping
|
||||
NOTICE: event trigger "cdb_on_add_column" does not exist, skipping
|
||||
select
|
||||
cartodb_id, created_at=updated_at as "c=u",
|
||||
NOW() - updated_at < '1 secs' as "u<1s",
|
||||
@ -111,6 +130,15 @@ select pg_sleep(1);
|
||||
(1 row)
|
||||
|
||||
alter table c.t3 drop column the_geom_webmercator;
|
||||
NOTICE: Column cartodb_id already exists
|
||||
NOTICE: Column created_at already exists
|
||||
NOTICE: Column updated_at already exists
|
||||
NOTICE: Column the_geom already exists
|
||||
NOTICE: event trigger "cdb_on_relation_create" does not exist, skipping
|
||||
NOTICE: event trigger "cdb_on_relation_drop" does not exist, skipping
|
||||
NOTICE: event trigger "cdb_on_alter_column" does not exist, skipping
|
||||
NOTICE: event trigger "cdb_on_drop_column" does not exist, skipping
|
||||
NOTICE: event trigger "cdb_on_add_column" does not exist, skipping
|
||||
select
|
||||
cartodb_id, created_at=updated_at as "c=u",
|
||||
NOW() - updated_at < '1 secs' as "u<1s",
|
||||
@ -166,6 +194,7 @@ FROM CDB_TableMetadata;
|
||||
----------------------------
|
||||
RESET SESSION AUTHORIZATION;
|
||||
drop schema c cascade;
|
||||
NOTICE: drop cascades to table c.t3
|
||||
select count(*) from CDB_TableMetadata;
|
||||
count
|
||||
-------
|
||||
|
3
expected/test_setup.out
Normal file
3
expected/test_setup.out
Normal file
@ -0,0 +1,3 @@
|
||||
CREATE EXTENSION postgis;
|
||||
CREATE EXTENSION schema_triggers;
|
||||
CREATE EXTENSION cartodb;
|
@ -35,7 +35,12 @@ BEGIN
|
||||
|
||||
IF dice < pbfact THEN
|
||||
RAISE DEBUG 'Checking quota on table % (dice:%, needed:<%)', TG_RELID::text, dice, pbfact;
|
||||
qmax := public._CDB_UserQuotaInBytes();
|
||||
BEGIN
|
||||
qmax := public._CDB_UserQuotaInBytes();
|
||||
EXCEPTION WHEN undefined_function THEN
|
||||
RAISE WARNING 'Missing _CDB_UserQuotaInBytes(), assuming no quota';
|
||||
RETURN NEW;
|
||||
END;
|
||||
SELECT CDB_UserDataSize() INTO quota;
|
||||
IF quota > qmax THEN
|
||||
RAISE EXCEPTION 'Quota exceeded by %KB', (quota-qmax)/1024;
|
||||
|
@ -82,7 +82,11 @@ BEGIN
|
||||
--
|
||||
-- LISTEN cdb_tabledata_update;
|
||||
--
|
||||
PERFORM cdb_invalidate_varnish(tabname);
|
||||
BEGIN
|
||||
PERFORM cdb_invalidate_varnish(tabname);
|
||||
EXCEPTION WHEN undefined_function THEN
|
||||
RAISE WARNING 'Missing cdb_invalidate_varnish()';
|
||||
END;
|
||||
|
||||
RETURN NULL;
|
||||
END;
|
||||
|
@ -22,7 +22,7 @@ AS $$
|
||||
'spatial_ref_sys'
|
||||
)
|
||||
), perms AS (
|
||||
SELECT t, has_table_privilege('publicuser', 'public.'||t, 'SELECT') as p
|
||||
SELECT t, has_table_privilege('publicuser', t, 'SELECT') as p
|
||||
FROM usertables
|
||||
)
|
||||
SELECT t FROM perms
|
||||
|
@ -1,10 +1,4 @@
|
||||
CREATE EXTENSION postgis;
|
||||
CREATE EXTENSION schema_triggers;
|
||||
CREATE EXTENSION cartodb;
|
||||
|
||||
set search_path to public,cartodb,schema_triggers;
|
||||
|
||||
--set client_min_messages to debug;
|
||||
\set VERBOSITY terse
|
||||
|
||||
-- Create a stub cdb_invalidate_varnish function if not available
|
||||
--CREATE FUNCTION tmp() returns void AS $$
|
||||
|
3
sql/test_setup.sql
Normal file
3
sql/test_setup.sql
Normal file
@ -0,0 +1,3 @@
|
||||
CREATE EXTENSION postgis;
|
||||
CREATE EXTENSION schema_triggers;
|
||||
CREATE EXTENSION cartodb;
|
Loading…
Reference in New Issue
Block a user