Skip to content

Commit

Permalink
Speed up bgw scheduler tests
Browse files Browse the repository at this point in the history
Speed up bgw tests by reducing the amount of time we wait in
pg_sleep.
  • Loading branch information
svenklemm committed Dec 13, 2023
1 parent 0e2ff92 commit 250c6c1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion tsl/test/expected/bgw_db_scheduler_fixed.out
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@ ORDER BY job_id;
-- test ability to switch from one type of schedule to another
CREATE OR REPLACE PROCEDURE job_test(jobid int, config jsonb) language plpgsql as $$
BEGIN
PERFORM pg_sleep(10);
PERFORM pg_sleep(0.5);
END
$$;
SELECT add_job('job_test', '8 min', fixed_schedule => false) AS jobid_drifting_1 \gset
Expand Down
6 changes: 3 additions & 3 deletions tsl/test/expected/job_errors_permissions.out
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CREATE OR REPLACE PROCEDURE custom_proc1(jobid int, config jsonb) LANGUAGE PLPGS
$$
BEGIN
UPDATE my_table SET b = 1 WHERE a = 0;
PERFORM pg_sleep(10);
PERFORM pg_sleep(5);
COMMIT;
END
$$;
Expand All @@ -35,7 +35,7 @@ CREATE OR REPLACE PROCEDURE custom_proc2(jobid int, config jsonb) LANGUAGE PLPGS
$$
BEGIN
UPDATE my_table SET b = 2 WHERE a = 0;
PERFORM pg_sleep(10);
PERFORM pg_sleep(5);
COMMIT;
END
$$;
Expand All @@ -48,7 +48,7 @@ SELECT _timescaledb_functions.start_background_workers();
t
(1 row)

SELECT pg_sleep(20);
SELECT pg_sleep(6);
pg_sleep
----------

Expand Down
6 changes: 3 additions & 3 deletions tsl/test/expected/scheduler_fixed.out
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ DELETE FROM _timescaledb_config.bgw_job;
TRUNCATE _timescaledb_internal.bgw_job_stat;
create or replace procedure job_20(jobid int, config jsonb) language plpgsql as $$
begin
perform pg_sleep(20);
perform pg_sleep(5);
end
$$;
create or replace procedure job_5(jobid int, config jsonb) language plpgsql as $$
begin
perform pg_sleep(5);
perform pg_sleep(1);
end
$$;
select * from _timescaledb_internal.bgw_job_stat;
Expand Down Expand Up @@ -95,7 +95,7 @@ select next_start as next_start_long from timescaledb_information.job_stats wher
select :'next_start_long'::timestamptz - :'initial_start_long'::timestamptz as schedule_diff;
schedule_diff
---------------
@ 30 secs
@ 15 secs
(1 row)

-- test some possible schedule_interval, finish_time, initial_start combinations
Expand Down
2 changes: 1 addition & 1 deletion tsl/test/sql/bgw_db_scheduler_fixed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ ORDER BY job_id;
-- test ability to switch from one type of schedule to another
CREATE OR REPLACE PROCEDURE job_test(jobid int, config jsonb) language plpgsql as $$
BEGIN
PERFORM pg_sleep(10);
PERFORM pg_sleep(0.5);
END
$$;

Expand Down
6 changes: 3 additions & 3 deletions tsl/test/sql/job_errors_permissions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CREATE OR REPLACE PROCEDURE custom_proc1(jobid int, config jsonb) LANGUAGE PLPGS
$$
BEGIN
UPDATE my_table SET b = 1 WHERE a = 0;
PERFORM pg_sleep(10);
PERFORM pg_sleep(5);
COMMIT;
END
$$;
Expand All @@ -39,7 +39,7 @@ CREATE OR REPLACE PROCEDURE custom_proc2(jobid int, config jsonb) LANGUAGE PLPGS
$$
BEGIN
UPDATE my_table SET b = 2 WHERE a = 0;
PERFORM pg_sleep(10);
PERFORM pg_sleep(5);
COMMIT;
END
$$;
Expand All @@ -49,7 +49,7 @@ select add_job('custom_proc2', '2 min', initial_start => now() + interval '5 sec

SET ROLE :ROLE_SUPERUSER;
SELECT _timescaledb_functions.start_background_workers();
SELECT pg_sleep(20);
SELECT pg_sleep(6);

\d timescaledb_information.job_errors

Expand Down
4 changes: 2 additions & 2 deletions tsl/test/sql/scheduler_fixed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ TRUNCATE _timescaledb_internal.bgw_job_stat;

create or replace procedure job_20(jobid int, config jsonb) language plpgsql as $$
begin
perform pg_sleep(20);
perform pg_sleep(5);
end
$$;

create or replace procedure job_5(jobid int, config jsonb) language plpgsql as $$
begin
perform pg_sleep(5);
perform pg_sleep(1);
end
$$;

Expand Down

0 comments on commit 250c6c1

Please sign in to comment.