tests: add tests for statement_timeout
The new tests verify that: - statement_timeout on the authenticator role works to cancel slow statements - changes to statement_timeout take effect on SIGUSR1 This reuses the old "limited_authenticator" role and adds some plumbing to allow reliably changing the statement timeout even if the current role is not functional due to a low statement timeout, and to make tests that modify the role independent from each other. - introduce module-wide metapostgrest fixture to have an out-of-band way to manipulate the database, without having to spin up extra postgrest instances per test - reset statement_timeout at the start of the respective tests
This commit is contained in:
+10
-5
@@ -59,10 +59,15 @@ ALTER ROLE other_authenticator SET pgrst.db_extra_search_path = 'public, extensi
|
||||
ALTER ROLE other_authenticator SET pgrst.openapi_mode = 'disabled';
|
||||
ALTER ROLE other_authenticator SET pgrst.openapi_security_active = 'false';
|
||||
|
||||
-- limited authenticator used for failed schema cache loads
|
||||
CREATE ROLE limited_authenticator LOGIN NOINHERIT;
|
||||
-- authenticator used for tests that manipulate statement timeout
|
||||
CREATE ROLE timeout_authenticator LOGIN NOINHERIT;
|
||||
|
||||
create or replace function no_schema_cache_for_limited_authenticator() returns void as $_$
|
||||
create function set_statement_timeout(role text, milliseconds int) returns void as $_$
|
||||
begin
|
||||
ALTER ROLE limited_authenticator SET statement_timeout to 1;
|
||||
end $_$ volatile security definer language plpgsql ;
|
||||
execute format($$
|
||||
alter role %I set statement_timeout to %L;
|
||||
$$, role, milliseconds);
|
||||
end $_$ volatile security definer language plpgsql;
|
||||
|
||||
-- authenticator used for test-independent database manipulation
|
||||
CREATE ROLE meta_authenticator LOGIN NOINHERIT;
|
||||
|
||||
Reference in New Issue
Block a user