Merge pull request #2911 from citusdata/test_merge_files_and_query_more

Extend tests from release testing
pull/2940/head^2
Philip Dubé 2019-09-05 16:57:54 +00:00 committed by GitHub
commit b4a1a0fb80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 116 additions and 8 deletions

View File

@ -402,7 +402,7 @@ INSERT INTO full_access_user_schema.t1 VALUES (1),(2),(3);
-- not allowed to create a table
SELECT create_distributed_table('full_access_user_schema.t1', 'id');
ERROR: permission denied for schema full_access_user_schema
CONTEXT: while executing command on localhost:57638
CONTEXT: while executing command on localhost:57637
RESET ROLE;
-- now we distribute the table as super user
SELECT create_distributed_table('full_access_user_schema.t1', 'id');
@ -536,7 +536,7 @@ ERROR: could not receive file "base/pgsql_job_cache/job_0042/task_000001/p_0000
-- different user should not be able to fetch partition file
SET ROLE usage_access;
SELECT worker_fetch_partition_file(42, 1, 1, 1, 'localhost', :worker_1_port);
WARNING: could not open file "base/pgsql_job_cache/job_0042/task_000001/p_00001.18007": No such file or directory
WARNING: could not open file "base/pgsql_job_cache/job_0042/task_000001/p_00001.17981": No such file or directory
CONTEXT: while executing command on localhost:57637
ERROR: could not receive file "base/pgsql_job_cache/job_0042/task_000001/p_00001" from localhost:57637
-- only the user whom created the files should be able to fetch
@ -575,7 +575,7 @@ RESET ROLE;
-- test that the super user is unable to read the contents of the intermediate file,
-- although it does create the table
SELECT worker_merge_files_into_table(42, 1, ARRAY['a'], ARRAY['integer']);
WARNING: Task file "task_000001.18003" does not have expected suffix ".10"
WARNING: Task file "task_000001.17977" does not have expected suffix ".10"
worker_merge_files_into_table
-------------------------------
@ -617,7 +617,7 @@ SELECT worker_merge_files_and_run_query(42, 1,
'CREATE TABLE task_000001_merge(merge_column_0 int)',
'CREATE TABLE task_000001 (a) AS SELECT sum(merge_column_0) FROM task_000001_merge'
);
WARNING: Task file "task_000001.18003" does not have expected suffix ".10"
WARNING: Task file "task_000001.17977" does not have expected suffix ".10"
worker_merge_files_and_run_query
----------------------------------
@ -647,6 +647,19 @@ SELECT worker_merge_files_and_run_query(42, 1,
(1 row)
-- test that owner of task cannot execute arbitrary sql
SELECT worker_merge_files_and_run_query(42, 1,
'CREATE TABLE task_000002_merge(merge_column_0 int)',
'DROP USER usage_access'
);
ERROR: permission denied to drop role
CONTEXT: SQL statement "DROP USER usage_access"
SELECT worker_merge_files_and_run_query(42, 1,
'DROP USER usage_access',
'CREATE TABLE task_000002 (a) AS SELECT sum(merge_column_0) FROM task_000002_merge'
);
ERROR: permission denied to drop role
CONTEXT: SQL statement "DROP USER usage_access"
SELECT count(*) FROM pg_merge_job_0042.task_000001_merge;
count
-------

View File

@ -536,7 +536,7 @@ ERROR: could not receive file "base/pgsql_job_cache/job_0042/task_000001/p_0000
-- different user should not be able to fetch partition file
SET ROLE usage_access;
SELECT worker_fetch_partition_file(42, 1, 1, 1, 'localhost', :worker_1_port);
WARNING: could not open file "base/pgsql_job_cache/job_0042/task_000001/p_00001.18058": No such file or directory
WARNING: could not open file "base/pgsql_job_cache/job_0042/task_000001/p_00001.18007": No such file or directory
CONTEXT: while executing command on localhost:57637
ERROR: could not receive file "base/pgsql_job_cache/job_0042/task_000001/p_00001" from localhost:57637
-- only the user whom created the files should be able to fetch
@ -575,7 +575,7 @@ RESET ROLE;
-- test that the super user is unable to read the contents of the intermediate file,
-- although it does create the table
SELECT worker_merge_files_into_table(42, 1, ARRAY['a'], ARRAY['integer']);
WARNING: Task file "task_000001.18054" does not have expected suffix ".10"
WARNING: Task file "task_000001.18003" does not have expected suffix ".10"
worker_merge_files_into_table
-------------------------------
@ -617,7 +617,7 @@ SELECT worker_merge_files_and_run_query(42, 1,
'CREATE TABLE task_000001_merge(merge_column_0 int)',
'CREATE TABLE task_000001 (a) AS SELECT sum(merge_column_0) FROM task_000001_merge'
);
WARNING: Task file "task_000001.18054" does not have expected suffix ".10"
WARNING: Task file "task_000001.18003" does not have expected suffix ".10"
worker_merge_files_and_run_query
----------------------------------
@ -647,6 +647,19 @@ SELECT worker_merge_files_and_run_query(42, 1,
(1 row)
-- test that owner of task cannot execute arbitrary sql
SELECT worker_merge_files_and_run_query(42, 1,
'CREATE TABLE task_000002_merge(merge_column_0 int)',
'DROP USER usage_access'
);
ERROR: permission denied to drop role
CONTEXT: SQL statement "DROP USER usage_access"
SELECT worker_merge_files_and_run_query(42, 1,
'DROP USER usage_access',
'CREATE TABLE task_000002 (a) AS SELECT sum(merge_column_0) FROM task_000002_merge'
);
ERROR: permission denied to drop role
CONTEXT: SQL statement "DROP USER usage_access"
SELECT count(*) FROM pg_merge_job_0042.task_000001_merge;
count
-------

View File

@ -5,6 +5,31 @@ SET citus.next_shard_id TO 1060000;
\set JobId 401010
\set CompletedTaskId 801107
\set RunningTaskId 801108
-- Test worker_cleanup_job_schema_cache
SELECT * FROM task_tracker_assign_task(2, 2, '');
task_tracker_assign_task
--------------------------
(1 row)
SELECT count(*) FROM pg_catalog.pg_namespace WHERE nspname = 'pg_merge_job_0002';
count
-------
1
(1 row)
SELECT worker_cleanup_job_schema_cache();
worker_cleanup_job_schema_cache
---------------------------------
(1 row)
SELECT count(*) FROM pg_catalog.pg_namespace WHERE nspname = 'pg_merge_job_0002';
count
-------
0
(1 row)
-- We assign two tasks to the task tracker. The first task should complete and
-- the second task should continue to keep running.
SELECT task_tracker_assign_task(:JobId, :CompletedTaskId,

View File

@ -67,8 +67,27 @@ ERROR: column name array size: 2 and type array size: 3 do not match
SELECT worker_merge_files_into_table(:JobId, :TaskId,
ARRAY['textcolumn', 'binarycolumn'],
ARRAY['text', 'integer']);
ERROR: invalid input syntax for integer: "\x0b50"
ERROR: invalid input syntax for type integer: "\x0b50"
CONTEXT: COPY task_101108, line 1, column binarycolumn: "\x0b50"
-- Check that we fail to merge when ids are wrong
SELECT worker_merge_files_into_table(-1, :TaskId,
ARRAY['textcolumn', 'binarycolumn'],
ARRAY['text', 'bytea']);
ERROR: could not open directory "base/pgsql_job_cache/job_18446744073709551615/task_101108": No such file or directory
SELECT worker_merge_files_into_table(:JobId, -1,
ARRAY['textcolumn', 'binarycolumn'],
ARRAY['text', 'bytea']);
ERROR: could not open directory "base/pgsql_job_cache/job_201010/task_4294967295": No such file or directory
SELECT worker_merge_files_and_run_query(-1, :TaskId,
'CREATE TABLE task_000001_merge(merge_column_0 int)',
'CREATE TABLE task_000001 (a) AS SELECT sum(merge_column_0) FROM task_000001_merge'
);
ERROR: could not open directory "base/pgsql_job_cache/job_18446744073709551615/task_101108": No such file or directory
SELECT worker_merge_files_and_run_query(:JobId, -1,
'CREATE TABLE task_000001_merge(merge_column_0 int)',
'CREATE TABLE task_000001 (a) AS SELECT sum(merge_column_0) FROM task_000001_merge'
);
ERROR: could not open directory "base/pgsql_job_cache/job_201010/task_4294967295": No such file or directory
-- Finally, merge partitioned files using valid arguments
SELECT worker_merge_files_into_table(:JobId, :TaskId,
ARRAY['textcolumn', 'binarycolumn'],

View File

@ -411,6 +411,18 @@ SELECT worker_merge_files_and_run_query(42, 1,
'CREATE TABLE task_000001_merge(merge_column_0 int)',
'CREATE TABLE task_000001 (a) AS SELECT sum(merge_column_0) FROM task_000001_merge'
);
-- test that owner of task cannot execute arbitrary sql
SELECT worker_merge_files_and_run_query(42, 1,
'CREATE TABLE task_000002_merge(merge_column_0 int)',
'DROP USER usage_access'
);
SELECT worker_merge_files_and_run_query(42, 1,
'DROP USER usage_access',
'CREATE TABLE task_000002 (a) AS SELECT sum(merge_column_0) FROM task_000002_merge'
);
SELECT count(*) FROM pg_merge_job_0042.task_000001_merge;
SELECT count(*) FROM pg_merge_job_0042.task_000001;
DROP TABLE pg_merge_job_0042.task_000001, pg_merge_job_0042.task_000001_merge; -- drop table so we can reuse the same files for more tests

View File

@ -10,6 +10,12 @@ SET citus.next_shard_id TO 1060000;
\set CompletedTaskId 801107
\set RunningTaskId 801108
-- Test worker_cleanup_job_schema_cache
SELECT * FROM task_tracker_assign_task(2, 2, '');
SELECT count(*) FROM pg_catalog.pg_namespace WHERE nspname = 'pg_merge_job_0002';
SELECT worker_cleanup_job_schema_cache();
SELECT count(*) FROM pg_catalog.pg_namespace WHERE nspname = 'pg_merge_job_0002';
-- We assign two tasks to the task tracker. The first task should complete and
-- the second task should continue to keep running.

View File

@ -75,6 +75,26 @@ SELECT worker_merge_files_into_table(:JobId, :TaskId,
ARRAY['textcolumn', 'binarycolumn'],
ARRAY['text', 'integer']);
-- Check that we fail to merge when ids are wrong
SELECT worker_merge_files_into_table(-1, :TaskId,
ARRAY['textcolumn', 'binarycolumn'],
ARRAY['text', 'bytea']);
SELECT worker_merge_files_into_table(:JobId, -1,
ARRAY['textcolumn', 'binarycolumn'],
ARRAY['text', 'bytea']);
SELECT worker_merge_files_and_run_query(-1, :TaskId,
'CREATE TABLE task_000001_merge(merge_column_0 int)',
'CREATE TABLE task_000001 (a) AS SELECT sum(merge_column_0) FROM task_000001_merge'
);
SELECT worker_merge_files_and_run_query(:JobId, -1,
'CREATE TABLE task_000001_merge(merge_column_0 int)',
'CREATE TABLE task_000001 (a) AS SELECT sum(merge_column_0) FROM task_000001_merge'
);
-- Finally, merge partitioned files using valid arguments
SELECT worker_merge_files_into_table(:JobId, :TaskId,