Add regress target
Runs the regress tests without installing the extension
This commit is contained in:
parent
a25efc3fc5
commit
8ff0ad74af
14
Makefile
14
Makefile
@ -127,7 +127,7 @@ EXTRA_CLEAN = cartodb_version.sql
|
||||
DOCS = README.md
|
||||
REGRESS_OLD = $(wildcard test/*.sql)
|
||||
REGRESS_LEGACY = $(REGRESS_OLD:.sql=)
|
||||
REGRESS = test_setup $(REGRESS_LEGACY)
|
||||
REGRESS = test/test_setup $(REGRESS_LEGACY)
|
||||
|
||||
PG_CONFIG = pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
@ -171,6 +171,10 @@ legacy_regress: $(REGRESS_OLD) Makefile
|
||||
mkdir -p sql/test/
|
||||
mkdir -p expected/test/
|
||||
mkdir -p results/test/
|
||||
cat sql/test_setup.sql | \
|
||||
$(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' -e 's/@extschema@/cartodb/g' -e "s/@postgisschema@/public/g" -e 's/plpythonu/$(PLPYTHONU)/g' \
|
||||
> sql/test/test_setup.sql
|
||||
cp sql/test_setup_expect expected/test/test_setup.out
|
||||
for f in $(REGRESS_OLD); do \
|
||||
tn=`basename $${f} .sql`; \
|
||||
of=sql/test/$${tn}.sql; \
|
||||
@ -179,7 +183,7 @@ legacy_regress: $(REGRESS_OLD) Makefile
|
||||
echo '\t' >> $${of}; \
|
||||
echo '\set QUIET off' >> $${of}; \
|
||||
cat $${f} | \
|
||||
$(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' -e 's/@extschema@/cartodb/g' -e "s/@postgisschema@/public/g" >> $${of}; \
|
||||
$(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' -e 's/@extschema@/cartodb/g' -e "s/@postgisschema@/public/g" -e 's/plpythonu/$(PLPYTHONU)/g' >> $${of}; \
|
||||
exp=expected/test/$${tn}.out; \
|
||||
echo '\set ECHO none' > $${exp}; \
|
||||
cat test/$${tn}_expect >> $${exp}; \
|
||||
@ -191,7 +195,11 @@ test_organization:
|
||||
test_extension_new:
|
||||
bash test/extension/test.sh
|
||||
|
||||
legacy_tests: legacy_regress
|
||||
legacy_tests: legacy_regress $(EXTENSION)--unpackaged--$(EXTVERSION).sql
|
||||
|
||||
PGREGRESS := $(shell dirname `$(PG_CONFIG) --pgxs`)/../../src/test/regress/pg_regress
|
||||
regress: legacy_tests
|
||||
$(PGREGRESS) --inputdir=./ --bindir='/usr/bin' --dbname=contrib_regression $(REGRESS)
|
||||
|
||||
installcheck: legacy_tests test_extension_new test_organization
|
||||
|
||||
|
@ -1,8 +1,14 @@
|
||||
\set ECHO none
|
||||
\set QUIET on
|
||||
SET client_min_messages TO error;
|
||||
CREATE EXTENSION cartodb CASCADE;
|
||||
CREATE EXTENSION postgis;
|
||||
CREATE EXTENSION plpythonu;
|
||||
CREATE SCHEMA cartodb;
|
||||
\i 'cartodb--unpackaged--@@VERSION@@.sql'
|
||||
CREATE FUNCTION public.cdb_invalidate_varnish(table_name text)
|
||||
RETURNS void AS $$
|
||||
BEGIN
|
||||
RAISE NOTICE 'cdb_invalidate_varnish(%) called', table_name;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
\set QUIET off
|
||||
|
1
sql/test_setup_expect
Normal file
1
sql/test_setup_expect
Normal file
@ -0,0 +1 @@
|
||||
\set ECHO none
|
@ -20,59 +20,4 @@ cat ${input} |
|
||||
cat >> ${output}
|
||||
|
||||
# Upgrade all functions
|
||||
cat ${input} | grep -v 'duplicated extension$' | grep -v '\quit$' >> ${output}
|
||||
|
||||
# Migrate CDB_TableMetadata
|
||||
cat >> ${output} <<'EOF'
|
||||
ALTER TABLE cartodb.CDB_TableMetadata DISABLE TRIGGER ALL;
|
||||
INSERT INTO cartodb.CDB_TableMetadata SELECT * FROM public.CDB_TableMetadata;
|
||||
ALTER TABLE cartodb.CDB_TableMetadata ENABLE TRIGGER ALL;
|
||||
DROP TABLE public.CDB_TableMetadata;
|
||||
|
||||
-- Set user quota
|
||||
-- NOTE: will fail if user quota wasn't set at database level, see
|
||||
-- http://github.com/CartoDB/cartodb-postgresql/issues/18
|
||||
DO $$
|
||||
DECLARE
|
||||
qmax int8;
|
||||
BEGIN
|
||||
BEGIN
|
||||
qmax := public._CDB_UserQuotaInBytes();
|
||||
EXCEPTION WHEN undefined_function THEN
|
||||
RAISE EXCEPTION 'Please set user quota before switching to cartodb extension';
|
||||
END;
|
||||
PERFORM cartodb.CDB_SetUserQuotaInBytes(qmax);
|
||||
DROP FUNCTION public._CDB_UserQuotaInBytes();
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
EOF
|
||||
|
||||
## Cartodbfy tables with a trigger using 'CDB_CheckQuota' or
|
||||
## 'CDB_TableMetadata_Trigger' from the 'public' schema
|
||||
#cat >> ${output} <<'EOF'
|
||||
#select cartodb.CDB_CartodbfyTable(relname::regclass) from (
|
||||
# -- names of tables using public.CDB_CheckQuota or
|
||||
# -- public.CDB_TableMetadata_Trigger in their triggers
|
||||
# SELECT distinct c.relname
|
||||
# FROM
|
||||
# pg_trigger t,
|
||||
# pg_class c,
|
||||
# pg_proc p,
|
||||
# pg_namespace n
|
||||
# WHERE
|
||||
# n.nspname = 'public' AND
|
||||
# p.pronamespace = n.oid AND
|
||||
# p.proname IN ( 'cdb_checkquota', 'cdb_tablemetadata_trigger' ) AND
|
||||
# t.tgrelid = c.oid AND
|
||||
# p.oid = t.tgfoid
|
||||
#) as foo;
|
||||
#EOF
|
||||
|
||||
## Drop any leftover function from public schema (there should be none)
|
||||
#cat ${input} |
|
||||
# grep '^ *CREATE OR REPLACE FUNCTION' |
|
||||
# grep -v ' cartodb\.' | # should only match DDL hooks
|
||||
# sed 's/).*$/);/' |
|
||||
# sed 's/DEFAULT [^ ,)]*//g' |
|
||||
# sed 's/CREATE OR REPLACE FUNCTION /DROP FUNCTION IF EXISTS public./' |
|
||||
# cat >> ${output}
|
||||
cat ${input} | grep -v 'duplicated extension$' | grep -v '\quit$' | grep -v 'pg_extension_config_dump' >> ${output}
|
||||
|
Loading…
Reference in New Issue
Block a user