Skip to content

Commit

Permalink
Improve the client.sql regression test script. Share the data context…
Browse files Browse the repository at this point in the history
… setting for both rollback monitor clients.
  • Loading branch information
beaud76 committed Mar 24, 2023
1 parent a9160cd commit b6ce864
Show file tree
Hide file tree
Showing 8 changed files with 413 additions and 822 deletions.
219 changes: 74 additions & 145 deletions test/11/expected/client.out

Large diffs are not rendered by default.

219 changes: 74 additions & 145 deletions test/12/expected/client.out

Large diffs are not rendered by default.

219 changes: 74 additions & 145 deletions test/13/expected/client.out

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions test/14/expected/after_restore.out
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,6 @@ select mark_group, regexp_replace(mark_name,E'\\d\\d\.\\d\\d\\.\\d\\d\\.\\d\\d\\
select time_id, time_last_emaj_gid, time_event from emaj.emaj_time_stamp order by time_id;
time_id | time_last_emaj_gid | time_event
---------+--------------------+------------
-8 | |
-7 | |
-6 | |
-5 | |
-4 | |
-3 | |
-2 | |
Expand Down Expand Up @@ -992,7 +988,7 @@ select time_id, time_last_emaj_gid, time_event from emaj.emaj_time_stamp order b
20203 | 20000272 | R
20204 | 20000291 | M
20205 | 20000291 | R
(506 rows)
(502 rows)

select sequ_schema, sequ_name, sequ_time_id, sequ_last_val, sequ_is_called from emaj.emaj_sequence order by sequ_time_id, sequ_schema, sequ_name;
sequ_schema | sequ_name | sequ_time_id | sequ_last_val | sequ_is_called
Expand Down
219 changes: 74 additions & 145 deletions test/14/expected/client.out

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions test/14/expected/restore.out
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ SET
SET
SET
ALTER TABLE
COPY 504
COPY 500
ALTER TABLE
ALTER TABLE
COPY 3
Expand Down Expand Up @@ -405,16 +405,16 @@ ALTER TABLE
COPY 130
ALTER TABLE
ALTER TABLE
COPY 81
COPY 78
ALTER TABLE
ALTER TABLE
COPY 362
COPY 353
ALTER TABLE
ALTER TABLE
COPY 42
ALTER TABLE
ALTER TABLE
COPY 289
COPY 268
ALTER TABLE
ALTER TABLE
COPY 12
Expand Down
219 changes: 74 additions & 145 deletions test/15/expected/client.out

Large diffs are not rendered by default.

126 changes: 38 additions & 88 deletions test/sql/client.sql
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
-- client.sql: Test client tools

--------------------------------------------------------------
-- PHP SCRIPTS
--
-- Test emajParallelRollback.php and emajRollbackMonitor.php
-- Parallel Rollback clients
--
--------------------------------------------------------------

--------------------------------------------
-- Prepare data for emajParallelRollback.php
--------------------------------------------
-- set sequence restart value
truncate emaj.emaj_hist;
select public.handle_emaj_sequences(20000);

--------------------------------------------
-- Prepare data for emajParallelRollback.php
--------------------------------------------
delete from mySchema1.myTbl4;
delete from mySchema1.myTbl1;
delete from mySchema1.myTbl2;
Expand Down Expand Up @@ -46,76 +46,14 @@ select emaj.emaj_modify_table('myschema1', 'mytbl1', '{"priority": 2}'::jsonb);
\! ${EMAJ_DIR}/client/emajParallelRollback.php -h localhost -d regression -g myGroup1 -m Multi-1 -s 1 -a

--------------------------------------------
-- Prepare data for emajRollbackMonitor.php
--------------------------------------------

-- 1st rollback, in EXECUTING state
insert into emaj.emaj_time_stamp (time_id, time_tx_timestamp) overriding system value
values (-1, now()-'110.1 seconds'::interval);
insert into emaj.emaj_time_stamp (time_id, time_clock_timestamp) overriding system value
values (-2, '2000-01-01 01:00:00');
insert into emaj.emaj_rlbk (rlbk_id, rlbk_groups, rlbk_mark, rlbk_mark_time_id, rlbk_time_id, rlbk_is_logged, rlbk_is_alter_group_allowed, rlbk_nb_session,
rlbk_nb_table, rlbk_nb_sequence, rlbk_eff_nb_table, rlbk_eff_nb_sequence, rlbk_status)
values (20101,array['group20101'],'mark20101',-2,-1,true,false,1,
5,4,3,1,'EXECUTING');
insert into emaj.emaj_rlbk_plan (rlbp_rlbk_id, rlbp_step, rlbp_schema, rlbp_table, rlbp_object,
rlbp_estimated_duration, rlbp_start_datetime, rlbp_duration)
values (20101, 'RLBK_TABLE','schema','t1','','50 seconds'::interval,null,null),
(20101, 'RLBK_TABLE','schema','t2','','30 seconds'::interval,null,null),
(20101, 'RLBK_TABLE','schema','t3','','20 seconds'::interval,null,null);
-- the first RLBK_TABLE is completed, and the step duration < the estimated duration
update emaj.emaj_rlbk_plan set rlbp_start_datetime = now() - '45 seconds'::interval,
rlbp_duration = '45 seconds'::interval
where rlbp_rlbk_id = 20101 and rlbp_table = 't1';
-- the second RLBK_TABLE is completed, and the step duration > the estimated duration
update emaj.emaj_rlbk_plan set rlbp_start_datetime = now() - '65 seconds'::interval,
rlbp_duration = '65 seconds'::interval
where rlbp_rlbk_id = 20101 and rlbp_table = 't2';

-- 2nd rollback, in LOCKING state with RLBK_TABLE steps
insert into emaj.emaj_time_stamp (time_id, time_tx_timestamp) overriding system value
values (-3, now()-'2 minutes'::interval);
insert into emaj.emaj_rlbk (rlbk_id, rlbk_groups, rlbk_mark, rlbk_mark_time_id, rlbk_time_id, rlbk_is_logged, rlbk_is_alter_group_allowed, rlbk_nb_session,
rlbk_nb_table, rlbk_nb_sequence, rlbk_eff_nb_table, rlbk_eff_nb_sequence, rlbk_status)
values (20102,array['group20102'],'mark20102',-2,-3,true,false,1,
5,4,3,NULL,'LOCKING');
insert into emaj.emaj_rlbk_plan (rlbp_rlbk_id, rlbp_step, rlbp_schema, rlbp_table, rlbp_object,
rlbp_estimated_duration, rlbp_start_datetime, rlbp_duration)
values (20102, 'LOCK_TABLE','schema','t1','',null,null,null),
(20102, 'LOCK_TABLE','schema','t2','',null,null,null),
(20102, 'LOCK_TABLE','schema','t3','',null,null,null),
(20102, 'RLBK_TABLE','schema','t1','','0:20:00'::interval,null,null),
(20102, 'RLBK_TABLE','schema','t2','','0:02:00'::interval,null,null),
(20102, 'RLBK_TABLE','schema','t3','','0:00:20'::interval,null,null);

-- 3rd rollback, in PLANNING state
insert into emaj.emaj_time_stamp (time_id, time_tx_timestamp) overriding system value
values (-4, now()-'1 minute'::interval);
insert into emaj.emaj_rlbk (rlbk_id, rlbk_groups, rlbk_mark, rlbk_mark_time_id, rlbk_time_id, rlbk_is_logged, rlbk_is_alter_group_allowed, rlbk_nb_session,
rlbk_nb_table, rlbk_nb_sequence, rlbk_eff_nb_table, rlbk_eff_nb_sequence, rlbk_status)
values (20103,array['group20103'],'mark20103',-2,-4,true,false,1,
5,4,3,NULL,'PLANNING');

--------------------------------------------
-- call emajRollbackMonitor.php using an emaj_viewer role
-- Prepare data for emajParallelRollback.pl
--------------------------------------------
\! ${EMAJ_DIR}/client/emajRollbackMonitor.php -h localhost -d regression -U emaj_regression_tests_viewer_user -i 0.1 -n 2 -l 2 -a 12 -vr

--------------------------------------------------------------
-- PERL SCRIPTS
--
-- Test emajParallelRollback.pl and emajRollbackMonitor.pl
--------------------------------------------------------------

-- set sequence restart value
truncate emaj.emaj_hist;
alter sequence emaj.emaj_hist_hist_id_seq restart 20200;
alter sequence emaj.emaj_time_stamp_time_id_seq restart 20200;
alter sequence emaj.emaj_rlbk_rlbk_id_seq restart 20200;

--------------------------------------------
-- Prepare data for emajParallelRollback.pl
--------------------------------------------
delete from mySchema1.myTbl4;
delete from mySchema1.myTbl1;
delete from mySchema1.myTbl2;
Expand Down Expand Up @@ -148,58 +86,70 @@ select emaj.emaj_modify_table('myschema1', 'mytbl1', '{"priority": 1}'::jsonb);
-- logged rollback for a single group and a single session
\! ${EMAJ_DIR}/client/emajParallelRollback.pl -h localhost -d regression -g myGroup1 -m Multi-1 -s 1 -a

--------------------------------------------------------------
--
-- Rollback monitor clients
--
--------------------------------------------------------------

--------------------------------------------
-- Prepare data for emajRollbackMonitor.pl
-- Prepare data for both emajRollbackMonitor.php and emajRollbackMonitor.pl
--------------------------------------------

-- 1st rollback, in EXECUTING state
insert into emaj.emaj_time_stamp (time_id, time_tx_timestamp) overriding system value
values (-5, now()-'110.1 seconds'::interval);
values (-1, now()-'110.1 seconds'::interval);
insert into emaj.emaj_time_stamp (time_id, time_clock_timestamp) overriding system value
values (-6, '2000-01-01 01:00:00');
values (-2, '2000-01-01 01:00:00');
insert into emaj.emaj_rlbk (rlbk_id, rlbk_groups, rlbk_mark, rlbk_mark_time_id, rlbk_time_id, rlbk_is_logged, rlbk_is_alter_group_allowed, rlbk_nb_session,
rlbk_nb_table, rlbk_nb_sequence, rlbk_eff_nb_table, rlbk_eff_nb_sequence, rlbk_status)
values (20301,array['group20301'],'mark20301',-2,-1,true,false,1,
values (20101,array['group20101'],'mark20101',-2,-1,true,false,1,
5,4,3,1,'EXECUTING');
insert into emaj.emaj_rlbk_plan (rlbp_rlbk_id, rlbp_step, rlbp_schema, rlbp_table, rlbp_object,
rlbp_estimated_duration, rlbp_start_datetime, rlbp_duration)
values (20301, 'RLBK_TABLE','schema','t1','','50 seconds'::interval,null,null),
(20301, 'RLBK_TABLE','schema','t2','','30 seconds'::interval,null,null),
(20301, 'RLBK_TABLE','schema','t3','','20 seconds'::interval,null,null);
values (20101, 'RLBK_TABLE','schema','t1','','50 seconds'::interval,null,null),
(20101, 'RLBK_TABLE','schema','t2','','30 seconds'::interval,null,null),
(20101, 'RLBK_TABLE','schema','t3','','20 seconds'::interval,null,null);
-- the first RLBK_TABLE is completed, and the step duration < the estimated duration
update emaj.emaj_rlbk_plan set rlbp_start_datetime = now() - '45 seconds'::interval,
rlbp_duration = '45 seconds'::interval
where rlbp_rlbk_id = 20301 and rlbp_table = 't1';
where rlbp_rlbk_id = 20101 and rlbp_table = 't1';
-- the second RLBK_TABLE is completed, and the step duration > the estimated duration
update emaj.emaj_rlbk_plan set rlbp_start_datetime = now() - '65 seconds'::interval,
rlbp_duration = '65 seconds'::interval
where rlbp_rlbk_id = 20301 and rlbp_table = 't2';
where rlbp_rlbk_id = 20101 and rlbp_table = 't2';

-- 2nd rollback, in LOCKING state with RLBK_TABLE steps
insert into emaj.emaj_time_stamp (time_id, time_tx_timestamp) overriding system value
values (-7, now()-'2 minutes'::interval);
values (-3, now()-'2 minutes'::interval);
insert into emaj.emaj_rlbk (rlbk_id, rlbk_groups, rlbk_mark, rlbk_mark_time_id, rlbk_time_id, rlbk_is_logged, rlbk_is_alter_group_allowed, rlbk_nb_session,
rlbk_nb_table, rlbk_nb_sequence, rlbk_eff_nb_table, rlbk_eff_nb_sequence, rlbk_status)
values (20302,array['group20302'],'mark20302',-2,-3,true,false,1,
values (20102,array['group20102'],'mark20102',-2,-3,true,false,1,
5,4,3,NULL,'LOCKING');
insert into emaj.emaj_rlbk_plan (rlbp_rlbk_id, rlbp_step, rlbp_schema, rlbp_table, rlbp_object,
rlbp_estimated_duration, rlbp_start_datetime, rlbp_duration)
values (20302, 'LOCK_TABLE','schema','t1','',null,null,null),
(20302, 'LOCK_TABLE','schema','t2','',null,null,null),
(20302, 'LOCK_TABLE','schema','t3','',null,null,null),
(20302, 'RLBK_TABLE','schema','t1','','0:20:00'::interval,null,null),
(20302, 'RLBK_TABLE','schema','t2','','0:02:00'::interval,null,null),
(20302, 'RLBK_TABLE','schema','t3','','0:00:20'::interval,null,null);
values (20102, 'LOCK_TABLE','schema','t1','',null,null,null),
(20102, 'LOCK_TABLE','schema','t2','',null,null,null),
(20102, 'LOCK_TABLE','schema','t3','',null,null,null),
(20102, 'RLBK_TABLE','schema','t1','','0:20:00'::interval,null,null),
(20102, 'RLBK_TABLE','schema','t2','','0:02:00'::interval,null,null),
(20102, 'RLBK_TABLE','schema','t3','','0:00:20'::interval,null,null);

-- 3rd rollback, in PLANNING state
insert into emaj.emaj_time_stamp (time_id, time_tx_timestamp) overriding system value
values (-8, now()-'1 minute'::interval);
insert into emaj.emaj_rlbk (rlbk_id, rlbk_groups, rlbk_mark, rlbk_mark_time_id, rlbk_time_id, rlbk_is_logged, rlbk_is_alter_group_allowed, rlbk_nb_session,
values (-4, now()-'1 minute'::interval);
insert into emaj.emaj_rlbk (rlbk_id, rlbk_groups, rlbk_mark, rlbk_mark_time_id, rlbk_time_id, rlbk_is_logged, rlbk_is_alter_group_allowed, rlbk_nb_session,
rlbk_nb_table, rlbk_nb_sequence, rlbk_eff_nb_table, rlbk_eff_nb_sequence, rlbk_status)
values (20303,array['group20303'],'mark20303',-2,-4,true,false,1,
values (20103,array['group20103'],'mark20103',-2,-4,true,false,1,
5,4,3,NULL,'PLANNING');

--------------------------------------------
-- call emajRollbackMonitor.php using an emaj_viewer role
--------------------------------------------
\! ${EMAJ_DIR}/client/emajRollbackMonitor.php -h localhost -d regression -U emaj_regression_tests_viewer_user -i 0.1 -n 2 -l 2 -a 12 -v -r

--------------------------------------------
-- call emajRollbackMonitor.pl using an emaj_viewer role
--------------------------------------------
\! ${EMAJ_DIR}/client/emajRollbackMonitor.pl -h localhost -d regression -U emaj_regression_tests_viewer_user -i 0.1 -n 2 -l 2 -a 12 -v -r

0 comments on commit b6ce864

Please sign in to comment.