mirror of https://github.com/citusdata/citus.git
Add a config to our test suite for non owning users
This would have found the bug that's fixed in #5441pull/5442/head
parent
aaaf637a6b
commit
bb430fa0c7
|
@ -34,7 +34,7 @@ testResults = {}
|
|||
parallel_thread_amount = 1
|
||||
|
||||
|
||||
def _run_pg_regress_on_port(config, port, schedule_name, extra_tests=""):
|
||||
def _run_pg_regress_on_port(config, port, schedule_name, user, extra_tests=""):
|
||||
return common.run_pg_regress_without_exit(
|
||||
config.bindir,
|
||||
config.pg_srcdir,
|
||||
|
@ -42,7 +42,7 @@ def _run_pg_regress_on_port(config, port, schedule_name, extra_tests=""):
|
|||
schedule_name,
|
||||
config.output_dir,
|
||||
config.input_dir,
|
||||
config.user,
|
||||
user,
|
||||
extra_tests,
|
||||
)
|
||||
|
||||
|
@ -54,11 +54,10 @@ def run_for_config(config, lock, sql_schedule_name):
|
|||
common.initialize_citus_cluster(
|
||||
config.bindir, config.datadir, config.settings, config
|
||||
)
|
||||
if config.user == cfg.REGULAR_USER_NAME:
|
||||
common.create_role(
|
||||
config.bindir,
|
||||
config.node_name_to_ports.values(),
|
||||
config.user,
|
||||
cfg.REGULAR_USER_NAME,
|
||||
)
|
||||
|
||||
copy_copy_modified_binary(config.datadir)
|
||||
|
@ -91,20 +90,25 @@ def run_for_config(config, lock, sql_schedule_name):
|
|||
)
|
||||
|
||||
exitCode |= _run_pg_regress_on_port(
|
||||
config, config.coordinator_port(), cfg.CREATE_SCHEDULE
|
||||
config, config.coordinator_port(), cfg.CREATE_SCHEDULE, config.owner_role
|
||||
)
|
||||
common.save_regression_diff("create", config.output_dir)
|
||||
|
||||
extra_tests = os.getenv("EXTRA_TESTS", "")
|
||||
if config.is_mx and config.worker_amount > 0:
|
||||
exitCode |= _run_pg_regress_on_port(
|
||||
config, config.random_port(), sql_schedule_name, extra_tests=extra_tests
|
||||
config,
|
||||
config.random_port(),
|
||||
sql_schedule_name,
|
||||
config.user,
|
||||
extra_tests=extra_tests,
|
||||
)
|
||||
else:
|
||||
exitCode |= _run_pg_regress_on_port(
|
||||
config,
|
||||
config.coordinator_port(),
|
||||
sql_schedule_name,
|
||||
config.user,
|
||||
extra_tests=extra_tests,
|
||||
)
|
||||
|
||||
|
|
|
@ -99,7 +99,12 @@ class CitusBaseClusterConfig(object, metaclass=NewInitCaller):
|
|||
self.pg_srcdir = arguments["--pgxsdir"]
|
||||
self.temp_dir = CITUS_ARBITRARY_TEST_DIR
|
||||
self.worker_amount = 2
|
||||
# User is that will execute the sql scripts
|
||||
self.user = REGULAR_USER_NAME
|
||||
# If owner_role is set to something else than None, that role will be
|
||||
# used to execute all the xyz_create.sql scripts, so that the tables
|
||||
# are owned by that role.
|
||||
self.owner_role = None
|
||||
self.dbname = DATABASE_NAME
|
||||
self.is_mx = True
|
||||
self.is_citus = True
|
||||
|
@ -129,6 +134,8 @@ class CitusBaseClusterConfig(object, metaclass=NewInitCaller):
|
|||
self.output_file = os.path.join(self.datadir, "run.out")
|
||||
if self.worker_amount > 0:
|
||||
self.chosen_random_worker_port = self.random_worker_port()
|
||||
if self.owner_role is None:
|
||||
self.owner_role = self.user
|
||||
self.settings.update(self.new_settings)
|
||||
|
||||
def coordinator_port(self):
|
||||
|
@ -177,6 +184,11 @@ class CitusDefaultClusterConfig(CitusBaseClusterConfig):
|
|||
"arbitrary_configs_alter_table_add_constraint_without_name",
|
||||
]
|
||||
|
||||
class CitusGrantedPermissionsClusterConfig(CitusDefaultClusterConfig):
|
||||
def __init__(self, arguments):
|
||||
super().__init__(arguments)
|
||||
self.owner_role = SUPER_USER_NAME
|
||||
|
||||
|
||||
class CitusUpgradeConfig(CitusBaseClusterConfig):
|
||||
def __init__(self, arguments, pre_tar, post_tar):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
test: auto_grant_all_to_regularuser
|
||||
test: intermediate_result_pruning_create
|
||||
test: prepared_statements_create_load ch_benchmarks_create_load
|
||||
test: dropped_columns_create_load distributed_planning_create_load
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA truncate_cascade_tests_schema;
|
||||
SET search_path TO truncate_cascade_tests_schema;
|
||||
GRANT ALL ON SCHEMA truncate_cascade_tests_schema TO regularuser;
|
||||
-- tables connected with foreign keys
|
||||
CREATE TABLE table_with_pk(a bigint PRIMARY KEY);
|
||||
CREATE TABLE table_with_fk_1(a bigint, b bigint, FOREIGN KEY (b) REFERENCES table_with_pk(a));
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA truncate_tests_schema;
|
||||
SET search_path TO truncate_tests_schema;
|
||||
GRANT ALL ON SCHEMA truncate_tests_schema TO regularuser;
|
||||
-- simple table
|
||||
CREATE TABLE basic_table(a int);
|
||||
-- partioned table
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA truncate_partition_tests_schema;
|
||||
SET search_path TO truncate_partition_tests_schema;
|
||||
GRANT ALL ON SCHEMA truncate_partition_tests_schema TO regularuser;
|
||||
-- partioned table
|
||||
CREATE TABLE partitioned_table(a int) PARTITION BY RANGE(a);
|
||||
CREATE TABLE partitioned_table_0 PARTITION OF partitioned_table
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
ALTER DEFAULT PRIVILEGES GRANT ALL ON SCHEMAS TO regularuser; -- does not work with citus
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON TABLES TO regularuser; -- does not work for views with citus
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON TYPES TO regularuser;
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON SEQUENCES TO regularuser;
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON FUNCTIONS TO regularuser;
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA "ch benchmarks";
|
||||
SET search_path to "ch benchmarks";
|
||||
GRANT ALL ON SCHEMA "ch benchmarks" TO regularuser;
|
||||
CREATE TABLE order_line (
|
||||
ol_w_id int NOT NULL,
|
||||
ol_d_id int NOT NULL,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA "distributed planning";
|
||||
SET search_path TO "distributed planning";
|
||||
GRANT ALL ON SCHEMA "distributed planning" TO regularuser;
|
||||
CREATE TABLE
|
||||
date_part_table (event_time timestamp, event int, user_id int)
|
||||
partition by range (event_time);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA local_shard_execution_dropped_column;
|
||||
SET search_path TO local_shard_execution_dropped_column;
|
||||
GRANT ALL ON SCHEMA local_shard_execution_dropped_column TO regularuser;
|
||||
CREATE TABLE t1 (a int, b int, c int UNIQUE, d int, e int);
|
||||
ALTER TABLE t1 DROP COLUMN e;
|
||||
SELECT create_distributed_table('t1', 'c');
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
\set VERBOSITY terse
|
||||
CREATE SCHEMA function_create;
|
||||
SET search_path TO function_create;
|
||||
GRANT ALL ON SCHEMA function_create TO regularuser;
|
||||
-- helper function to verify the function of a coordinator is the same on all workers
|
||||
CREATE OR REPLACE FUNCTION verify_function_is_same_on_workers(funcname text)
|
||||
RETURNS bool
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA index_create;
|
||||
SET search_path TO index_create;
|
||||
GRANT ALL ON SCHEMA index_create TO regularuser;
|
||||
CREATE TABLE test_tbl (a INT NOT NULL PRIMARY KEY, b text, c BIGINT);
|
||||
CREATE UNIQUE INDEX CONCURRENTLY a_index ON test_tbl (a);
|
||||
SELECT create_distributed_table('test_tbl','a');
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA "intermediate result pruning";
|
||||
SET search_path TO "intermediate result pruning";
|
||||
GRANT ALL ON SCHEMA "intermediate result pruning" TO regularuser;
|
||||
CREATE TABLE table_1 (key int, value text);
|
||||
SELECT create_distributed_table('table_1', 'key');
|
||||
create_distributed_table
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA local_dist_join_mixed;
|
||||
SET search_path TO local_dist_join_mixed;
|
||||
GRANT ALL ON SCHEMA local_dist_join_mixed TO regularuser;
|
||||
CREATE TABLE distributed (key int, id bigserial PRIMARY KEY,
|
||||
name text,
|
||||
created_at timestamptz DEFAULT now(), b int);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA nested_execution;
|
||||
SET search_path TO nested_execution;
|
||||
GRANT ALL ON SCHEMA nested_execution TO regularuser;
|
||||
-- some of the next_execution tests change for single shard
|
||||
SET citus.shard_count TO 4;
|
||||
CREATE TABLE distributed (key int, name text,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA "partitioned indexes";
|
||||
SET search_path TO "partitioned indexes";
|
||||
GRANT ALL ON SCHEMA "partitioned indexes" TO regularuser;
|
||||
-- test with proper table
|
||||
CREATE TABLE dist_partitioned_table (dist_col int, another_col int, partition_col timestamp) PARTITION BY RANGE (partition_col);
|
||||
SELECT create_distributed_table('dist_partitioned_table', 'dist_col');
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA "prepared statements";
|
||||
SET search_path TO "prepared statements";
|
||||
GRANT ALL ON SCHEMA "prepared statements" TO regularuser;
|
||||
CREATE TABLE repartition_prepared_test (a int, b int);
|
||||
SELECT create_distributed_table('repartition_prepared_test', 'a');
|
||||
create_distributed_table
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
CREATE SCHEMA test_schema_1;
|
||||
GRANT ALL ON SCHEMA test_schema_1 TO regularuser;
|
||||
CREATE SCHEMA IF NOT EXISTS test_schema_2;
|
||||
GRANT ALL ON SCHEMA test_schema_2 TO regularuser;
|
||||
CREATE SCHEMA test_schema_3 CREATE TABLE test_table(a INT PRIMARY KEY);
|
||||
GRANT ALL ON SCHEMA test_schema_3 TO regularuser;
|
||||
SELECT create_distributed_table('test_schema_3.test_table','a');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
@ -10,6 +13,7 @@ SELECT create_distributed_table('test_schema_3.test_table','a');
|
|||
INSERT INTO test_schema_3.test_table VALUES (1), (2);
|
||||
DROP SCHEMA test_schema_2;
|
||||
CREATE SCHEMA test_schema_4;
|
||||
GRANT ALL ON SCHEMA test_schema_4 TO regularuser;
|
||||
ALTER TABLE test_schema_3.test_table SET SCHEMA test_schema_4;
|
||||
ALTER SCHEMA test_schema_3 RENAME TO test_schema_3_renamed;
|
||||
ALTER SCHEMA test_schema_4 RENAME TO test_schema_5;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA sequences_schema;
|
||||
SET search_path TO sequences_schema;
|
||||
GRANT ALL ON SCHEMA sequences_schema TO regularuser;
|
||||
CREATE SEQUENCE seq_0;
|
||||
ALTER SEQUENCE seq_0 AS smallint;
|
||||
CREATE SEQUENCE seq_1;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA views_create;
|
||||
SET search_path TO views_create;
|
||||
GRANT ALL ON SCHEMA views_create TO regularuser;
|
||||
CREATE TABLE view_test_table(a INT NOT NULL PRIMARY KEY, b BIGINT, c text);
|
||||
SELECT create_distributed_table('view_test_table', 'a');
|
||||
create_distributed_table
|
||||
|
@ -88,10 +89,15 @@ CREATE TABLE local (id bigserial PRIMARY KEY,
|
|||
title text);
|
||||
SET client_min_messages TO ERROR;
|
||||
CREATE VIEW "local regular view" AS SELECT * FROM local;
|
||||
GRANT ALL ON TABLE "local regular view" TO regularuser;
|
||||
CREATE VIEW dist_regular_view AS SELECT * FROM distributed;
|
||||
GRANT ALL ON TABLE dist_regular_view TO regularuser;
|
||||
CREATE VIEW local_regular_view2 as SELECT count(*) FROM distributed JOIN "local regular view" USING (id);
|
||||
GRANT ALL ON TABLE local_regular_view2 TO regularuser;
|
||||
CREATE VIEW local_regular_view3 as SELECT count(*) FROM local JOIN dist_regular_view USING (id);
|
||||
GRANT ALL ON TABLE local_regular_view3 TO regularuser;
|
||||
CREATE VIEW "local regular view4" as SELECT count(*) as "my cny" FROM dist_regular_view JOIN "local regular view" USING (id);
|
||||
GRANT ALL ON TABLE "local regular view4" TO regularuser;
|
||||
RESET client_min_messages;
|
||||
-- these above restrictions brought us to the following schema
|
||||
SELECT create_reference_table('reference');
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA truncate_cascade_tests_schema;
|
||||
SET search_path TO truncate_cascade_tests_schema;
|
||||
GRANT ALL ON SCHEMA truncate_cascade_tests_schema TO regularuser;
|
||||
|
||||
-- tables connected with foreign keys
|
||||
CREATE TABLE table_with_pk(a bigint PRIMARY KEY);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA truncate_tests_schema;
|
||||
SET search_path TO truncate_tests_schema;
|
||||
GRANT ALL ON SCHEMA truncate_tests_schema TO regularuser;
|
||||
|
||||
-- simple table
|
||||
CREATE TABLE basic_table(a int);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA truncate_partition_tests_schema;
|
||||
SET search_path TO truncate_partition_tests_schema;
|
||||
GRANT ALL ON SCHEMA truncate_partition_tests_schema TO regularuser;
|
||||
|
||||
-- partioned table
|
||||
CREATE TABLE partitioned_table(a int) PARTITION BY RANGE(a);
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
ALTER DEFAULT PRIVILEGES GRANT ALL ON SCHEMAS TO regularuser; -- does not work with citus
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON TABLES TO regularuser; -- does not work for views with citus
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON TYPES TO regularuser;
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON SEQUENCES TO regularuser;
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON FUNCTIONS TO regularuser;
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA "ch benchmarks";
|
||||
SET search_path to "ch benchmarks";
|
||||
GRANT ALL ON SCHEMA "ch benchmarks" TO regularuser;
|
||||
|
||||
|
||||
CREATE TABLE order_line (
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA "distributed planning";
|
||||
SET search_path TO "distributed planning";
|
||||
GRANT ALL ON SCHEMA "distributed planning" TO regularuser;
|
||||
|
||||
CREATE TABLE
|
||||
date_part_table (event_time timestamp, event int, user_id int)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA local_shard_execution_dropped_column;
|
||||
SET search_path TO local_shard_execution_dropped_column;
|
||||
GRANT ALL ON SCHEMA local_shard_execution_dropped_column TO regularuser;
|
||||
|
||||
CREATE TABLE t1 (a int, b int, c int UNIQUE, d int, e int);
|
||||
ALTER TABLE t1 DROP COLUMN e;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
\set VERBOSITY terse
|
||||
CREATE SCHEMA function_create;
|
||||
SET search_path TO function_create;
|
||||
GRANT ALL ON SCHEMA function_create TO regularuser;
|
||||
|
||||
-- helper function to verify the function of a coordinator is the same on all workers
|
||||
CREATE OR REPLACE FUNCTION verify_function_is_same_on_workers(funcname text)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA index_create;
|
||||
SET search_path TO index_create;
|
||||
GRANT ALL ON SCHEMA index_create TO regularuser;
|
||||
|
||||
CREATE TABLE test_tbl (a INT NOT NULL PRIMARY KEY, b text, c BIGINT);
|
||||
CREATE UNIQUE INDEX CONCURRENTLY a_index ON test_tbl (a);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA "intermediate result pruning";
|
||||
SET search_path TO "intermediate result pruning";
|
||||
GRANT ALL ON SCHEMA "intermediate result pruning" TO regularuser;
|
||||
|
||||
CREATE TABLE table_1 (key int, value text);
|
||||
SELECT create_distributed_table('table_1', 'key');
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA local_dist_join_mixed;
|
||||
SET search_path TO local_dist_join_mixed;
|
||||
GRANT ALL ON SCHEMA local_dist_join_mixed TO regularuser;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA nested_execution;
|
||||
SET search_path TO nested_execution;
|
||||
GRANT ALL ON SCHEMA nested_execution TO regularuser;
|
||||
|
||||
-- some of the next_execution tests change for single shard
|
||||
SET citus.shard_count TO 4;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA "partitioned indexes";
|
||||
SET search_path TO "partitioned indexes";
|
||||
GRANT ALL ON SCHEMA "partitioned indexes" TO regularuser;
|
||||
|
||||
-- test with proper table
|
||||
CREATE TABLE dist_partitioned_table (dist_col int, another_col int, partition_col timestamp) PARTITION BY RANGE (partition_col);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA "prepared statements";
|
||||
SET search_path TO "prepared statements";
|
||||
GRANT ALL ON SCHEMA "prepared statements" TO regularuser;
|
||||
|
||||
CREATE TABLE repartition_prepared_test (a int, b int);
|
||||
SELECT create_distributed_table('repartition_prepared_test', 'a');
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
CREATE SCHEMA test_schema_1;
|
||||
GRANT ALL ON SCHEMA test_schema_1 TO regularuser;
|
||||
CREATE SCHEMA IF NOT EXISTS test_schema_2;
|
||||
GRANT ALL ON SCHEMA test_schema_2 TO regularuser;
|
||||
CREATE SCHEMA test_schema_3 CREATE TABLE test_table(a INT PRIMARY KEY);
|
||||
GRANT ALL ON SCHEMA test_schema_3 TO regularuser;
|
||||
|
||||
SELECT create_distributed_table('test_schema_3.test_table','a');
|
||||
INSERT INTO test_schema_3.test_table VALUES (1), (2);
|
||||
|
||||
DROP SCHEMA test_schema_2;
|
||||
CREATE SCHEMA test_schema_4;
|
||||
GRANT ALL ON SCHEMA test_schema_4 TO regularuser;
|
||||
|
||||
ALTER TABLE test_schema_3.test_table SET SCHEMA test_schema_4;
|
||||
ALTER SCHEMA test_schema_3 RENAME TO test_schema_3_renamed;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA sequences_schema;
|
||||
SET search_path TO sequences_schema;
|
||||
GRANT ALL ON SCHEMA sequences_schema TO regularuser;
|
||||
|
||||
CREATE SEQUENCE seq_0;
|
||||
ALTER SEQUENCE seq_0 AS smallint;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE SCHEMA views_create;
|
||||
SET search_path TO views_create;
|
||||
GRANT ALL ON SCHEMA views_create TO regularuser;
|
||||
|
||||
CREATE TABLE view_test_table(a INT NOT NULL PRIMARY KEY, b BIGINT, c text);
|
||||
SELECT create_distributed_table('view_test_table', 'a');
|
||||
|
@ -51,11 +52,16 @@ CREATE TABLE local (id bigserial PRIMARY KEY,
|
|||
title text);
|
||||
SET client_min_messages TO ERROR;
|
||||
CREATE VIEW "local regular view" AS SELECT * FROM local;
|
||||
GRANT ALL ON TABLE "local regular view" TO regularuser;
|
||||
CREATE VIEW dist_regular_view AS SELECT * FROM distributed;
|
||||
GRANT ALL ON TABLE dist_regular_view TO regularuser;
|
||||
|
||||
CREATE VIEW local_regular_view2 as SELECT count(*) FROM distributed JOIN "local regular view" USING (id);
|
||||
GRANT ALL ON TABLE local_regular_view2 TO regularuser;
|
||||
CREATE VIEW local_regular_view3 as SELECT count(*) FROM local JOIN dist_regular_view USING (id);
|
||||
GRANT ALL ON TABLE local_regular_view3 TO regularuser;
|
||||
CREATE VIEW "local regular view4" as SELECT count(*) as "my cny" FROM dist_regular_view JOIN "local regular view" USING (id);
|
||||
GRANT ALL ON TABLE "local regular view4" TO regularuser;
|
||||
RESET client_min_messages;
|
||||
|
||||
-- these above restrictions brought us to the following schema
|
||||
|
|
Loading…
Reference in New Issue