Fixes unit tests

test_branch
gindibay 2023-07-28 20:34:42 +03:00
parent 4ed78f148e
commit 24380f80b9
2 changed files with 34 additions and 11 deletions

View File

@ -4,14 +4,35 @@ starting permutation: s1-begin s1-pause-node s2-begin s2-insert s2-end s1-end
step s1-begin: step s1-begin:
BEGIN; BEGIN;
s1: NOTICE:
step s1-pause-node: step s1-pause-node:
SELECT pg_catalog.citus_pause_node(2); SET client_min_messages = 'notice';
DO $$
citus_pause_node DECLARE
--------------------------------------------------------------------- v_shard_id int;
v_node_id int;
(1 row) v_node_name text;
v_node_port int;
BEGIN
--The first message in the block is being printed on the top of the code block. So adding a dummy message
--to make sure that the first message is printed in correct place.
raise notice '';
-- Get the shard id for the distribution column
SELECT get_shard_id_for_distribution_column('employee', 3) into v_shard_id;
--Get the node id for the shard id
SELECT nodename,nodeport into v_node_name,v_node_port FROM citus_shards WHERE shardid = v_shard_id limit 1;
raise notice 'node name is %',v_node_name;
raise notice 'node port is %',v_node_port;
-- Get the node id for the shard id
SELECT nodeid into v_node_id FROM pg_dist_node WHERE nodename = v_node_name and nodeport = v_node_port limit 1;
-- Pause the node
perform pg_catalog.citus_pause_node(v_node_id) ;
END;
$$
LANGUAGE plpgsql;
s1: NOTICE: node name is localhost
s1: NOTICE: node port is 57638
step s2-begin: step s2-begin:
BEGIN; BEGIN;
@ -22,13 +43,13 @@ step s2-insert:
-- Variable to track if the INSERT statement was successful -- Variable to track if the INSERT statement was successful
DO $$ DO $$
DECLARE DECLARE
insert_successful BOOLEAN := FALSE; v_insert_successful BOOLEAN := FALSE;
BEGIN BEGIN
-- Execute the INSERT statement -- Execute the INSERT statement
insert into employee values(11,'e11',3); insert into employee values(11,'e11',3);
-- If we reach this point, the INSERT statement was successful -- If we reach this point, the INSERT statement was successful
insert_successful := TRUE; v_insert_successful := TRUE;
IF insert_successful THEN IF v_insert_successful THEN
RAISE NOTICE 'INSERT statement completed successfully. This means that citus_pause_node could not get the lock.'; RAISE NOTICE 'INSERT statement completed successfully. This means that citus_pause_node could not get the lock.';
END IF; END IF;
-- You can add additional processing here if needed -- You can add additional processing here if needed

View File

@ -52,7 +52,10 @@ step "s1-pause-node"
v_node_name text; v_node_name text;
v_node_port int; v_node_port int;
BEGIN BEGIN
-- Get the shard id for the distribution column --The first message in the block is being printed on the top of the code block. So adding a dummy message
--to make sure that the first message is printed in correct place.
raise notice '';
-- Get the shard id for the distribution column
SELECT get_shard_id_for_distribution_column('employee', 3) into v_shard_id; SELECT get_shard_id_for_distribution_column('employee', 3) into v_shard_id;
--Get the node id for the shard id --Get the node id for the shard id
@ -62,7 +65,6 @@ step "s1-pause-node"
-- Get the node id for the shard id -- Get the node id for the shard id
SELECT nodeid into v_node_id FROM pg_dist_node WHERE nodename = v_node_name and nodeport = v_node_port limit 1; SELECT nodeid into v_node_id FROM pg_dist_node WHERE nodename = v_node_name and nodeport = v_node_port limit 1;
raise notice 'node id is %',v_node_id;
-- Pause the node -- Pause the node