Fix tests: race condition with publicuser #157

This commit is contained in:
Rafa de la Torre 2016-10-17 16:31:06 +02:00
parent 091aea088e
commit 30cd4cf1f9

View File

@ -227,6 +227,7 @@ function tear_down() {
sql 'DROP ROLE cdb_testmember_2;' sql 'DROP ROLE cdb_testmember_2;'
tear_down_database tear_down_database
DATABASE=postgres sql postgres 'DROP ROLE IF EXISTS publicuser';
} }
@ -485,6 +486,18 @@ function test_foreign_tables() {
${CMD} -d fdw_target -f scripts-available/CDB_QueryTables.sql ${CMD} -d fdw_target -f scripts-available/CDB_QueryTables.sql
${CMD} -d fdw_target -f scripts-available/CDB_TableMetadata.sql ${CMD} -d fdw_target -f scripts-available/CDB_TableMetadata.sql
DATABASE=fdw_target sql postgres "DO
\$\$
BEGIN
IF NOT EXISTS (
SELECT *
FROM pg_catalog.pg_user
WHERE usename = 'publicuser') THEN
CREATE ROLE publicuser LOGIN;
END IF;
END
\$\$;"
DATABASE=fdw_target sql postgres 'CREATE SCHEMA test_fdw;' DATABASE=fdw_target sql postgres 'CREATE SCHEMA test_fdw;'
DATABASE=fdw_target sql postgres 'CREATE TABLE test_fdw.foo (a int);' DATABASE=fdw_target sql postgres 'CREATE TABLE test_fdw.foo (a int);'
DATABASE=fdw_target sql postgres 'INSERT INTO test_fdw.foo (a) values (42);' DATABASE=fdw_target sql postgres 'INSERT INTO test_fdw.foo (a) values (42);'