From 30cd4cf1f9dc950be97e8df305cd01b22b95b7a1 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Mon, 17 Oct 2016 16:31:06 +0200 Subject: [PATCH] Fix tests: race condition with publicuser #157 --- test/extension/test.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/extension/test.sh b/test/extension/test.sh index a8807ef..1e56864 100755 --- a/test/extension/test.sh +++ b/test/extension/test.sh @@ -227,6 +227,7 @@ function tear_down() { sql 'DROP ROLE cdb_testmember_2;' 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_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 TABLE test_fdw.foo (a int);' DATABASE=fdw_target sql postgres 'INSERT INTO test_fdw.foo (a) values (42);'