From 8d55754b4dcf91109b8bf3d9be1c02a851a5cfb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?mehmet=20furkan=20=C5=9Fahin?= Date: Wed, 15 Nov 2017 15:16:27 +0300 Subject: [PATCH] the tests are separated and some more added --- .../isolation_create_distributed_table.out | 102 ++++++++++++++++ .../isolation_master_append_table.out | 115 +----------------- .../isolation_master_apply_delete.out | 109 +++++++++++++++++ src/test/regress/isolation_schedule | 2 +- .../isolation_create_distributed_table.spec | 63 ++++++++++ .../specs/isolation_master_append_table.spec | 37 +----- .../specs/isolation_master_apply_delete.spec | 63 ++++++++++ 7 files changed, 342 insertions(+), 149 deletions(-) create mode 100644 src/test/regress/expected/isolation_create_distributed_table.out create mode 100644 src/test/regress/expected/isolation_master_apply_delete.out create mode 100644 src/test/regress/specs/isolation_create_distributed_table.spec create mode 100644 src/test/regress/specs/isolation_master_apply_delete.spec diff --git a/src/test/regress/expected/isolation_create_distributed_table.out b/src/test/regress/expected/isolation_create_distributed_table.out new file mode 100644 index 000000000..bef65be94 --- /dev/null +++ b/src/test/regress/expected/isolation_create_distributed_table.out @@ -0,0 +1,102 @@ +Parsed test spec with 2 sessions + +starting permutation: s1-begin s2-begin s1-create_distributed_table s2-create_distributed_table s1-commit s2-commit +step s1-begin: + BEGIN; + +step s2-begin: + BEGIN; + +step s1-create_distributed_table: + SELECT create_distributed_table('table_to_distribute', 'id'); + +create_distributed_table + + +step s2-create_distributed_table: + SELECT create_distributed_table('table_to_distribute', 'id'); + +step s1-commit: + COMMIT; + +step s2-create_distributed_table: <... completed> +error in steps s1-commit s2-create_distributed_table: ERROR: table "table_to_distribute" is already distributed +step s2-commit: + COMMIT; + + +starting permutation: s1-begin s2-begin s1-create_distributed_table s2-copy_to_local_table s1-commit s2-commit +step s1-begin: + BEGIN; + +step s2-begin: + BEGIN; + +step s1-create_distributed_table: + SELECT create_distributed_table('table_to_distribute', 'id'); + +create_distributed_table + + +step s2-copy_to_local_table: + COPY table_to_distribute FROM PROGRAM 'echo "0\n1\n2\n3\n4\n5\n6\n7\n8"'; + +step s1-commit: + COMMIT; + +step s2-copy_to_local_table: <... completed> +step s2-commit: + COMMIT; + + +starting permutation: s1-begin s2-begin s2-copy_to_local_table s1-create_distributed_table s2-commit s1-commit +step s1-begin: + BEGIN; + +step s2-begin: + BEGIN; + +step s2-copy_to_local_table: + COPY table_to_distribute FROM PROGRAM 'echo "0\n1\n2\n3\n4\n5\n6\n7\n8"'; + +step s1-create_distributed_table: + SELECT create_distributed_table('table_to_distribute', 'id'); + +step s2-commit: + COMMIT; + +step s1-create_distributed_table: <... completed> +create_distributed_table + + +step s1-commit: + COMMIT; + + +starting permutation: s1-copy_to_local_table s1-begin s2-begin s1-create_distributed_table s2-create_distributed_table s1-commit s2-commit +step s1-copy_to_local_table: + COPY table_to_distribute FROM PROGRAM 'echo "0\n1\n2\n3\n4\n5\n6\n7\n8"'; + +step s1-begin: + BEGIN; + +step s2-begin: + BEGIN; + +step s1-create_distributed_table: + SELECT create_distributed_table('table_to_distribute', 'id'); + +create_distributed_table + + +step s2-create_distributed_table: + SELECT create_distributed_table('table_to_distribute', 'id'); + +step s1-commit: + COMMIT; + +step s2-create_distributed_table: <... completed> +error in steps s1-commit s2-create_distributed_table: ERROR: table "table_to_distribute" is already distributed +step s2-commit: + COMMIT; + diff --git a/src/test/regress/expected/isolation_master_append_table.out b/src/test/regress/expected/isolation_master_append_table.out index 2e31b69d7..40070bd32 100644 --- a/src/test/regress/expected/isolation_master_append_table.out +++ b/src/test/regress/expected/isolation_master_append_table.out @@ -17,7 +17,7 @@ step s1-master_append_table_to_shard: master_append_table_to_shard -0.0266667 +0.213333 step s2-master_append_table_to_shard: SELECT @@ -33,118 +33,7 @@ step s1-commit: step s2-master_append_table_to_shard: <... completed> master_append_table_to_shard -0.0266667 -step s2-commit: - COMMIT; - - -starting permutation: s1-begin s2-begin s1-create_distributed_table s2-create_distributed_table s1-commit s2-commit -step s1-begin: - BEGIN; - -step s2-begin: - BEGIN; - -step s1-create_distributed_table: - SELECT create_distributed_table('table_to_distribute', 'id'); - -create_distributed_table - - -step s2-create_distributed_table: - SELECT create_distributed_table('table_to_distribute', 'id'); - -step s1-commit: - COMMIT; - -step s2-create_distributed_table: <... completed> -error in steps s1-commit s2-create_distributed_table: ERROR: table "table_to_distribute" is already distributed -step s2-commit: - COMMIT; - - -starting permutation: s1-begin s2-begin s1-master_append_table_to_shard s2-master_apply_delete_command s1-commit s2-commit -step s1-begin: - BEGIN; - -step s2-begin: - BEGIN; - -step s1-master_append_table_to_shard: - SELECT - master_append_table_to_shard(shardid, 'table_to_be_appended', 'localhost', 57636) - FROM - pg_dist_shard - WHERE - 'table_to_append'::regclass::oid = logicalrelid; - -master_append_table_to_shard - -0.0266667 -step s2-master_apply_delete_command: - SELECT master_apply_delete_command($$DELETE FROM table_to_append WHERE id >= 0$$); - -ERROR: canceling statement due to user request -step s1-commit: - COMMIT; - -step s2-commit: - COMMIT; - - -starting permutation: s1-begin s2-begin s1-master_apply_delete_command s2-master_append_table_to_shard s1-commit s2-commit -step s1-begin: - BEGIN; - -step s2-begin: - BEGIN; - -step s1-master_apply_delete_command: - SELECT master_apply_delete_command($$DELETE FROM table_to_append WHERE id >= 0$$); - -master_apply_delete_command - -1 -step s2-master_append_table_to_shard: - - SELECT - master_append_table_to_shard(shardid, 'table_to_be_appended', 'localhost', 57636) - FROM - pg_dist_shard - WHERE - 'table_to_append'::regclass::oid = logicalrelid; - -ERROR: canceling statement due to user request -step s1-commit: - COMMIT; - -step s2-commit: - COMMIT; - - -starting permutation: s1-begin s2-begin s1-master_apply_delete_command s2-master_apply_delete_command s1-commit s2-commit -step s1-begin: - BEGIN; - -step s2-begin: - BEGIN; - -step s1-master_apply_delete_command: - SELECT master_apply_delete_command($$DELETE FROM table_to_append WHERE id >= 0$$); - -master_apply_delete_command - -1 -step s2-master_apply_delete_command: - SELECT master_apply_delete_command($$DELETE FROM table_to_append WHERE id >= 0$$); - -step s1-commit: - COMMIT; - -step s2-master_apply_delete_command: <... completed> -master_apply_delete_command - -0 +0.32 step s2-commit: COMMIT; diff --git a/src/test/regress/expected/isolation_master_apply_delete.out b/src/test/regress/expected/isolation_master_apply_delete.out new file mode 100644 index 000000000..fe596eef3 --- /dev/null +++ b/src/test/regress/expected/isolation_master_apply_delete.out @@ -0,0 +1,109 @@ +Parsed test spec with 2 sessions + +starting permutation: s1-begin s2-begin s1-master_apply_delete_command_all_shard s2-master_apply_delete_command_all_shard s1-commit s2-commit +step s1-begin: + BEGIN; + +step s2-begin: + BEGIN; + +step s1-master_apply_delete_command_all_shard: + SELECT master_apply_delete_command($$DELETE FROM table_to_delete_from WHERE id >= 0$$); + +master_apply_delete_command + +1 +step s2-master_apply_delete_command_all_shard: + SELECT master_apply_delete_command($$DELETE FROM table_to_delete_from WHERE id >= 0$$); + +step s1-commit: + COMMIT; + +step s2-master_apply_delete_command_all_shard: <... completed> +master_apply_delete_command + +0 +step s2-commit: + COMMIT; + + +starting permutation: s1-begin s2-begin s1-master_apply_delete_command_all_shard s2-master_apply_delete_command_row s1-commit s2-commit +step s1-begin: + BEGIN; + +step s2-begin: + BEGIN; + +step s1-master_apply_delete_command_all_shard: + SELECT master_apply_delete_command($$DELETE FROM table_to_delete_from WHERE id >= 0$$); + +master_apply_delete_command + +1 +step s2-master_apply_delete_command_row: + SELECT master_apply_delete_command($$DELETE FROM table_to_delete_from WHERE id >= 0 and id < 3$$); + +step s1-commit: + COMMIT; + +step s2-master_apply_delete_command_row: <... completed> +master_apply_delete_command + +0 +step s2-commit: + COMMIT; + + +starting permutation: s1-begin s2-begin s1-master_apply_delete_command_row s2-master_apply_delete_command_all_shard s1-commit s2-commit +step s1-begin: + BEGIN; + +step s2-begin: + BEGIN; + +step s1-master_apply_delete_command_row: + SELECT master_apply_delete_command($$DELETE FROM table_to_delete_from WHERE id >= 0 and id < 3$$); + +master_apply_delete_command + +0 +step s2-master_apply_delete_command_all_shard: + SELECT master_apply_delete_command($$DELETE FROM table_to_delete_from WHERE id >= 0$$); + +step s1-commit: + COMMIT; + +step s2-master_apply_delete_command_all_shard: <... completed> +master_apply_delete_command + +1 +step s2-commit: + COMMIT; + + +starting permutation: s1-begin s2-begin s1-master_apply_delete_command_row s2-master_apply_delete_command_row s1-commit s2-commit +step s1-begin: + BEGIN; + +step s2-begin: + BEGIN; + +step s1-master_apply_delete_command_row: + SELECT master_apply_delete_command($$DELETE FROM table_to_delete_from WHERE id >= 0 and id < 3$$); + +master_apply_delete_command + +0 +step s2-master_apply_delete_command_row: + SELECT master_apply_delete_command($$DELETE FROM table_to_delete_from WHERE id >= 0 and id < 3$$); + +step s1-commit: + COMMIT; + +step s2-master_apply_delete_command_row: <... completed> +master_apply_delete_command + +0 +step s2-commit: + COMMIT; + diff --git a/src/test/regress/isolation_schedule b/src/test/regress/isolation_schedule index 595f9e1a8..220f24db6 100644 --- a/src/test/regress/isolation_schedule +++ b/src/test/regress/isolation_schedule @@ -23,7 +23,7 @@ test: isolation_distributed_deadlock_detection # writes, run this test serially. test: isolation_create_restore_point -test: isolation_master_append_table +test: isolation_create_distributed_table isolation_master_append_table isolation_master_apply_delete test: isolation_multi_shard_modify_vs_all test: isolation_hash_copy_vs_all test: isolation_append_copy_vs_all diff --git a/src/test/regress/specs/isolation_create_distributed_table.spec b/src/test/regress/specs/isolation_create_distributed_table.spec new file mode 100644 index 000000000..3b5fa3b6a --- /dev/null +++ b/src/test/regress/specs/isolation_create_distributed_table.spec @@ -0,0 +1,63 @@ +setup +{ + CREATE TABLE table_to_distribute(id int); +} + +teardown +{ + DROP TABLE table_to_distribute CASCADE; +} + +session "s1" + +step "s1-begin" +{ + BEGIN; +} + +step "s1-create_distributed_table" +{ + SELECT create_distributed_table('table_to_distribute', 'id'); +} + +step "s1-copy_to_local_table" +{ + COPY table_to_distribute FROM PROGRAM 'echo "0\n1\n2\n3\n4\n5\n6\n7\n8"'; +} + +step "s1-commit" +{ + COMMIT; +} + +session "s2" + +step "s2-begin" +{ + BEGIN; +} + +step "s2-create_distributed_table" +{ + SELECT create_distributed_table('table_to_distribute', 'id'); +} + +step "s2-copy_to_local_table" +{ + COPY table_to_distribute FROM PROGRAM 'echo "0\n1\n2\n3\n4\n5\n6\n7\n8"'; +} + +step "s2-commit" +{ + COMMIT; +} + +#concurrent create_distributed_table on empty table +permutation "s1-begin" "s2-begin" "s1-create_distributed_table" "s2-create_distributed_table" "s1-commit" "s2-commit" + +#concurrent create_distributed_table vs. copy to table +permutation "s1-begin" "s2-begin" "s1-create_distributed_table" "s2-copy_to_local_table" "s1-commit" "s2-commit" +permutation "s1-begin" "s2-begin" "s2-copy_to_local_table" "s1-create_distributed_table" "s2-commit" "s1-commit" + +#concurrent create_distributed_table on non-empty table +permutation "s1-copy_to_local_table" "s1-begin" "s2-begin" "s1-create_distributed_table" "s2-create_distributed_table" "s1-commit" "s2-commit" diff --git a/src/test/regress/specs/isolation_master_append_table.spec b/src/test/regress/specs/isolation_master_append_table.spec index e85c2dbc1..fcbc8696a 100644 --- a/src/test/regress/specs/isolation_master_append_table.spec +++ b/src/test/regress/specs/isolation_master_append_table.spec @@ -2,20 +2,17 @@ setup { CREATE TABLE table_to_append(id int); CREATE TABLE table_to_be_appended(id int); - CREATE TABLE table_to_distribute(id int); SELECT create_distributed_table('table_to_append', 'id', 'append'); - INSERT INTO table_to_be_appended VALUES(1),(2),(3),(4),(5),(6); - INSERT INTO table_to_distribute SELECT generate_series(1,100); + INSERT INTO table_to_be_appended SELECT generate_series(1,1000); - COPY table_to_append FROM PROGRAM 'echo "0\n7\n8\n9\n10"'; + COPY table_to_append FROM PROGRAM 'echo "0\n7\n8\n9\n10000"'; } teardown { DROP TABLE table_to_append CASCADE; DROP TABLE table_to_be_appended CASCADE; - DROP TABLE table_to_distribute CASCADE; } session "s1" @@ -25,11 +22,6 @@ step "s1-begin" BEGIN; } -step "s1-create_distributed_table" -{ - SELECT create_distributed_table('table_to_distribute', 'id'); -} - step "s1-master_append_table_to_shard" { SELECT @@ -40,11 +32,6 @@ step "s1-master_append_table_to_shard" 'table_to_append'::regclass::oid = logicalrelid; } -step "s1-master_apply_delete_command" -{ - SELECT master_apply_delete_command($$DELETE FROM table_to_append WHERE id >= 0$$); -} - step "s1-commit" { COMMIT; @@ -57,11 +44,6 @@ step "s2-begin" BEGIN; } -step "s2-create_distributed_table" -{ - SELECT create_distributed_table('table_to_distribute', 'id'); -} - step "s2-master_append_table_to_shard" { @@ -73,11 +55,6 @@ step "s2-master_append_table_to_shard" 'table_to_append'::regclass::oid = logicalrelid; } -step "s2-master_apply_delete_command" -{ - SELECT master_apply_delete_command($$DELETE FROM table_to_append WHERE id >= 0$$); -} - step "s2-commit" { COMMIT; @@ -85,13 +62,3 @@ step "s2-commit" # concurrent master_append_table_to_shard tests permutation "s1-begin" "s2-begin" "s1-master_append_table_to_shard" "s2-master_append_table_to_shard" "s1-commit" "s2-commit" - -#concurrent create_distributed_table -permutation "s1-begin" "s2-begin" "s1-create_distributed_table" "s2-create_distributed_table" "s1-commit" "s2-commit" - -# concurrent master_append_table_to_shard vs master_apply_delete_command tests -permutation "s1-begin" "s2-begin" "s1-master_append_table_to_shard" "s2-master_apply_delete_command" "s1-commit" "s2-commit" -permutation "s1-begin" "s2-begin" "s1-master_apply_delete_command" "s2-master_append_table_to_shard" "s1-commit" "s2-commit" - -#concurrent master_apply_delete_command vs master_apply_delete_command -permutation "s1-begin" "s2-begin" "s1-master_apply_delete_command" "s2-master_apply_delete_command" "s1-commit" "s2-commit" \ No newline at end of file diff --git a/src/test/regress/specs/isolation_master_apply_delete.spec b/src/test/regress/specs/isolation_master_apply_delete.spec new file mode 100644 index 000000000..632e2874f --- /dev/null +++ b/src/test/regress/specs/isolation_master_apply_delete.spec @@ -0,0 +1,63 @@ +setup +{ + CREATE TABLE table_to_delete_from(id int); + + SELECT create_distributed_table('table_to_delete_from', 'id', 'append'); + + COPY table_to_delete_from FROM PROGRAM 'echo "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10"'; +} + +teardown +{ + DROP TABLE table_to_delete_from CASCADE; +} + +session "s1" + +step "s1-begin" +{ + BEGIN; +} + +step "s1-master_apply_delete_command_all_shard" +{ + SELECT master_apply_delete_command($$DELETE FROM table_to_delete_from WHERE id >= 0$$); +} + +step "s1-master_apply_delete_command_row" +{ + SELECT master_apply_delete_command($$DELETE FROM table_to_delete_from WHERE id >= 0 and id < 3$$); +} + +step "s1-commit" +{ + COMMIT; +} + +session "s2" + +step "s2-begin" +{ + BEGIN; +} + +step "s2-master_apply_delete_command_all_shard" +{ + SELECT master_apply_delete_command($$DELETE FROM table_to_delete_from WHERE id >= 0$$); +} + +step "s2-master_apply_delete_command_row" +{ + SELECT master_apply_delete_command($$DELETE FROM table_to_delete_from WHERE id >= 0 and id < 3$$); +} + +step "s2-commit" +{ + COMMIT; +} + +#concurrent master_apply_delete_command vs master_apply_delete_command +permutation "s1-begin" "s2-begin" "s1-master_apply_delete_command_all_shard" "s2-master_apply_delete_command_all_shard" "s1-commit" "s2-commit" +permutation "s1-begin" "s2-begin" "s1-master_apply_delete_command_all_shard" "s2-master_apply_delete_command_row" "s1-commit" "s2-commit" +permutation "s1-begin" "s2-begin" "s1-master_apply_delete_command_row" "s2-master_apply_delete_command_all_shard" "s1-commit" "s2-commit" +permutation "s1-begin" "s2-begin" "s1-master_apply_delete_command_row" "s2-master_apply_delete_command_row" "s1-commit" "s2-commit"