From c6000e9839a3b8b3ad6cf564cb93b3d63622e6df Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Mon, 22 Jul 2019 20:03:26 +0200 Subject: [PATCH] Fix alternate_users test The alternate_users tests relied on other tests to create tablespace "tablespace1" and would fail if it was not there. The output of the tests had captured the incorrect state when "tablespace1" did not exist. This patch fixes the expected output and makes sure the tablespace required for the test actually exists. --- test/expected/alternate_users-10.out | 8 +++++++- test/expected/alternate_users-11.out | 8 +++++++- test/expected/alternate_users-9.6.out | 8 +++++++- test/sql/alternate_users.sql.in | 7 +++++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/test/expected/alternate_users-10.out b/test/expected/alternate_users-10.out index 6ef88f831..392da1794 100644 --- a/test/expected/alternate_users-10.out +++ b/test/expected/alternate_users-10.out @@ -46,6 +46,12 @@ INSERT INTO "one_Partition"("timeCustom", device_id, series_0, series_1) VALUES INSERT 0 1 \set QUIET on \c :TEST_DBNAME :ROLE_SUPERUSER +-- make sure tablespace1 exists +-- since there is no CREATE TABLESPACE IF EXISTS we drop with if exists and recreate +SET client_min_messages TO error; +DROP TABLESPACE IF EXISTS tablespace1; +RESET client_min_messages; +CREATE TABLESPACE tablespace1 OWNER :ROLE_DEFAULT_PERM_USER LOCATION :TEST_TABLESPACE1_PATH; --needed for ddl ops: CREATE SCHEMA IF NOT EXISTS "customSchema" AUTHORIZATION :ROLE_DEFAULT_PERM_USER_2; --needed for ROLE_DEFAULT_PERM_USER_2 to write to the 'one_Partition' schema which @@ -68,7 +74,7 @@ ERROR: must be owner of hypertable "one_Partition" select add_dimension('"one_Partition"', 'device_id', 2); ERROR: must be owner of hypertable "one_Partition" select attach_tablespace('tablespace1', '"one_Partition"'); -ERROR: tablespace "tablespace1" does not exist +ERROR: must be owner of hypertable "one_Partition" \set ON_ERROR_STOP 1 CREATE TABLE "1dim"(time timestamp, temp float); SELECT create_hypertable('"1dim"', 'time'); diff --git a/test/expected/alternate_users-11.out b/test/expected/alternate_users-11.out index b82b513a4..2a9cc308a 100644 --- a/test/expected/alternate_users-11.out +++ b/test/expected/alternate_users-11.out @@ -46,6 +46,12 @@ INSERT INTO "one_Partition"("timeCustom", device_id, series_0, series_1) VALUES INSERT 0 1 \set QUIET on \c :TEST_DBNAME :ROLE_SUPERUSER +-- make sure tablespace1 exists +-- since there is no CREATE TABLESPACE IF EXISTS we drop with if exists and recreate +SET client_min_messages TO error; +DROP TABLESPACE IF EXISTS tablespace1; +RESET client_min_messages; +CREATE TABLESPACE tablespace1 OWNER :ROLE_DEFAULT_PERM_USER LOCATION :TEST_TABLESPACE1_PATH; --needed for ddl ops: CREATE SCHEMA IF NOT EXISTS "customSchema" AUTHORIZATION :ROLE_DEFAULT_PERM_USER_2; --needed for ROLE_DEFAULT_PERM_USER_2 to write to the 'one_Partition' schema which @@ -68,7 +74,7 @@ ERROR: must be owner of hypertable "one_Partition" select add_dimension('"one_Partition"', 'device_id', 2); ERROR: must be owner of hypertable "one_Partition" select attach_tablespace('tablespace1', '"one_Partition"'); -ERROR: tablespace "tablespace1" does not exist +ERROR: must be owner of hypertable "one_Partition" \set ON_ERROR_STOP 1 CREATE TABLE "1dim"(time timestamp, temp float); SELECT create_hypertable('"1dim"', 'time'); diff --git a/test/expected/alternate_users-9.6.out b/test/expected/alternate_users-9.6.out index 6ef88f831..392da1794 100644 --- a/test/expected/alternate_users-9.6.out +++ b/test/expected/alternate_users-9.6.out @@ -46,6 +46,12 @@ INSERT INTO "one_Partition"("timeCustom", device_id, series_0, series_1) VALUES INSERT 0 1 \set QUIET on \c :TEST_DBNAME :ROLE_SUPERUSER +-- make sure tablespace1 exists +-- since there is no CREATE TABLESPACE IF EXISTS we drop with if exists and recreate +SET client_min_messages TO error; +DROP TABLESPACE IF EXISTS tablespace1; +RESET client_min_messages; +CREATE TABLESPACE tablespace1 OWNER :ROLE_DEFAULT_PERM_USER LOCATION :TEST_TABLESPACE1_PATH; --needed for ddl ops: CREATE SCHEMA IF NOT EXISTS "customSchema" AUTHORIZATION :ROLE_DEFAULT_PERM_USER_2; --needed for ROLE_DEFAULT_PERM_USER_2 to write to the 'one_Partition' schema which @@ -68,7 +74,7 @@ ERROR: must be owner of hypertable "one_Partition" select add_dimension('"one_Partition"', 'device_id', 2); ERROR: must be owner of hypertable "one_Partition" select attach_tablespace('tablespace1', '"one_Partition"'); -ERROR: tablespace "tablespace1" does not exist +ERROR: must be owner of hypertable "one_Partition" \set ON_ERROR_STOP 1 CREATE TABLE "1dim"(time timestamp, temp float); SELECT create_hypertable('"1dim"', 'time'); diff --git a/test/sql/alternate_users.sql.in b/test/sql/alternate_users.sql.in index a0e7551b8..7bfeb5837 100644 --- a/test/sql/alternate_users.sql.in +++ b/test/sql/alternate_users.sql.in @@ -6,6 +6,13 @@ \c :TEST_DBNAME :ROLE_SUPERUSER +-- make sure tablespace1 exists +-- since there is no CREATE TABLESPACE IF EXISTS we drop with if exists and recreate +SET client_min_messages TO error; +DROP TABLESPACE IF EXISTS tablespace1; +RESET client_min_messages; +CREATE TABLESPACE tablespace1 OWNER :ROLE_DEFAULT_PERM_USER LOCATION :TEST_TABLESPACE1_PATH; + --needed for ddl ops: CREATE SCHEMA IF NOT EXISTS "customSchema" AUTHORIZATION :ROLE_DEFAULT_PERM_USER_2;