Stabilize test helper sql files

multi_test_helpers is run in parallel with others, so need to stabilize
other test helpers too to make multi_test_helpers runnable multiple
times.
pull/7032/head
Onur Tirtir 2023-07-03 15:59:36 +03:00
parent 001437bdfe
commit d4789a2c3a
6 changed files with 24 additions and 91 deletions

View File

@ -1,3 +1,6 @@
SET client_min_messages TO WARNING;
DROP SCHEMA IF EXISTS columnar_test_helpers CASCADE;
RESET client_min_messages;
CREATE SCHEMA columnar_test_helpers;
SET search_path TO columnar_test_helpers;
CREATE OR REPLACE FUNCTION columnar_storage_info(

View File

@ -11,7 +11,7 @@ SELECT pg_reload_conf();
(1 row)
-- Add some helper functions for sending commands to mitmproxy
CREATE FUNCTION citus.mitmproxy(text) RETURNS TABLE(result text) AS $$
CREATE OR REPLACE FUNCTION citus.mitmproxy(text) RETURNS TABLE(result text) AS $$
DECLARE
command ALIAS FOR $1;
BEGIN
@ -26,52 +26,13 @@ BEGIN
RETURN QUERY SELECT * FROM mitmproxy_result;
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION citus.clear_network_traffic() RETURNS void AS $$
CREATE OR REPLACE FUNCTION citus.clear_network_traffic() RETURNS void AS $$
BEGIN
PERFORM citus.mitmproxy('recorder.reset()');
RETURN; -- return void
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION citus.dump_network_traffic()
RETURNS TABLE(conn int, source text, message text) AS $$
BEGIN
CREATE TEMPORARY TABLE mitmproxy_command (command text) ON COMMIT DROP;
CREATE TEMPORARY TABLE mitmproxy_result (
conn int, source text, message text
) ON COMMIT DROP;
INSERT INTO mitmproxy_command VALUES ('recorder.dump()');
EXECUTE format('COPY mitmproxy_command TO %L', current_setting('citus.mitmfifo'));
EXECUTE format('COPY mitmproxy_result FROM %L', current_setting('citus.mitmfifo'));
RETURN QUERY SELECT * FROM mitmproxy_result;
END;
$$ LANGUAGE plpgsql;
\c - - - :worker_2_port
-- Add some helper functions for sending commands to mitmproxy
CREATE FUNCTION citus.mitmproxy(text) RETURNS TABLE(result text) AS $$
DECLARE
command ALIAS FOR $1;
BEGIN
CREATE TEMPORARY TABLE mitmproxy_command (command text) ON COMMIT DROP;
CREATE TEMPORARY TABLE mitmproxy_result (res text) ON COMMIT DROP;
INSERT INTO mitmproxy_command VALUES (command);
EXECUTE format('COPY mitmproxy_command TO %L', current_setting('citus.mitmfifo'));
EXECUTE format('COPY mitmproxy_result FROM %L', current_setting('citus.mitmfifo'));
RETURN QUERY SELECT * FROM mitmproxy_result;
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION citus.clear_network_traffic() RETURNS void AS $$
BEGIN
PERFORM citus.mitmproxy('recorder.reset()');
RETURN; -- return void
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION citus.dump_network_traffic()
CREATE OR REPLACE FUNCTION citus.dump_network_traffic()
RETURNS TABLE(conn int, source text, message text) AS $$
BEGIN
CREATE TEMPORARY TABLE mitmproxy_command (command text) ON COMMIT DROP;

View File

@ -3,7 +3,11 @@ SET citus.next_shard_id TO 390000;
-- get ready for the foreign data wrapper tests
-- ===================================================================
-- create fake fdw for use in tests
CREATE FUNCTION fake_fdw_handler()
SET client_min_messages TO WARNING;
DROP SERVER IF EXISTS fake_fdw_server CASCADE;
DROP FOREIGN DATA WRAPPER IF EXISTS fake_fdw CASCADE;
RESET client_min_messages;
CREATE OR REPLACE FUNCTION fake_fdw_handler()
RETURNS fdw_handler
AS 'citus'
LANGUAGE C STRICT;

View File

@ -1,3 +1,7 @@
SET client_min_messages TO WARNING;
DROP SCHEMA IF EXISTS columnar_test_helpers CASCADE;
RESET client_min_messages;
CREATE SCHEMA columnar_test_helpers;
SET search_path TO columnar_test_helpers;

View File

@ -8,7 +8,7 @@ SELECT pg_reload_conf();
-- Add some helper functions for sending commands to mitmproxy
CREATE FUNCTION citus.mitmproxy(text) RETURNS TABLE(result text) AS $$
CREATE OR REPLACE FUNCTION citus.mitmproxy(text) RETURNS TABLE(result text) AS $$
DECLARE
command ALIAS FOR $1;
BEGIN
@ -24,58 +24,14 @@ BEGIN
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION citus.clear_network_traffic() RETURNS void AS $$
CREATE OR REPLACE FUNCTION citus.clear_network_traffic() RETURNS void AS $$
BEGIN
PERFORM citus.mitmproxy('recorder.reset()');
RETURN; -- return void
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION citus.dump_network_traffic()
RETURNS TABLE(conn int, source text, message text) AS $$
BEGIN
CREATE TEMPORARY TABLE mitmproxy_command (command text) ON COMMIT DROP;
CREATE TEMPORARY TABLE mitmproxy_result (
conn int, source text, message text
) ON COMMIT DROP;
INSERT INTO mitmproxy_command VALUES ('recorder.dump()');
EXECUTE format('COPY mitmproxy_command TO %L', current_setting('citus.mitmfifo'));
EXECUTE format('COPY mitmproxy_result FROM %L', current_setting('citus.mitmfifo'));
RETURN QUERY SELECT * FROM mitmproxy_result;
END;
$$ LANGUAGE plpgsql;
\c - - - :worker_2_port
-- Add some helper functions for sending commands to mitmproxy
CREATE FUNCTION citus.mitmproxy(text) RETURNS TABLE(result text) AS $$
DECLARE
command ALIAS FOR $1;
BEGIN
CREATE TEMPORARY TABLE mitmproxy_command (command text) ON COMMIT DROP;
CREATE TEMPORARY TABLE mitmproxy_result (res text) ON COMMIT DROP;
INSERT INTO mitmproxy_command VALUES (command);
EXECUTE format('COPY mitmproxy_command TO %L', current_setting('citus.mitmfifo'));
EXECUTE format('COPY mitmproxy_result FROM %L', current_setting('citus.mitmfifo'));
RETURN QUERY SELECT * FROM mitmproxy_result;
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION citus.clear_network_traffic() RETURNS void AS $$
BEGIN
PERFORM citus.mitmproxy('recorder.reset()');
RETURN; -- return void
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION citus.dump_network_traffic()
CREATE OR REPLACE FUNCTION citus.dump_network_traffic()
RETURNS TABLE(conn int, source text, message text) AS $$
BEGIN
CREATE TEMPORARY TABLE mitmproxy_command (command text) ON COMMIT DROP;

View File

@ -7,7 +7,12 @@ SET citus.next_shard_id TO 390000;
-- ===================================================================
-- create fake fdw for use in tests
CREATE FUNCTION fake_fdw_handler()
SET client_min_messages TO WARNING;
DROP SERVER IF EXISTS fake_fdw_server CASCADE;
DROP FOREIGN DATA WRAPPER IF EXISTS fake_fdw CASCADE;
RESET client_min_messages;
CREATE OR REPLACE FUNCTION fake_fdw_handler()
RETURNS fdw_handler
AS 'citus'
LANGUAGE C STRICT;