Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a7800cf

Browse files
committed
injection_points: Add basic isolation test
This test can act as a template when implementing an isolation test with injection points, and tracks in a much simpler way some of the behaviors implied in the existing isolation test "inplace" that has been added in c35f419. Particularly, a detach does not affect a backend wait; a wait needs to be interrupted by a wakeup. Reviewed-by: Bertrand Drouvot Discussion: https://postgr.es/m/ZxGTONm_ctQz--io@paquier.xyz
1 parent f1c141f commit a7800cf

File tree

4 files changed

+111
-1
lines changed

4 files changed

+111
-1
lines changed

src/test/modules/injection_points/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ PGFILEDESC = "injection_points - facility for injection points"
1313
REGRESS = injection_points reindex_conc
1414
REGRESS_OPTS = --dlpath=$(top_builddir)/src/test/regress
1515

16-
ISOLATION = inplace
16+
ISOLATION = basic inplace
1717

1818
TAP_TESTS = 1
1919

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
Parsed test spec with 2 sessions
2+
3+
starting permutation: wait1 wakeup2 detach2
4+
injection_points_attach
5+
-----------------------
6+
7+
(1 row)
8+
9+
step wait1: SELECT injection_points_run('injection-points-wait'); <waiting ...>
10+
step wakeup2: SELECT injection_points_wakeup('injection-points-wait');
11+
injection_points_wakeup
12+
-----------------------
13+
14+
(1 row)
15+
16+
step wait1: <... completed>
17+
injection_points_run
18+
--------------------
19+
20+
(1 row)
21+
22+
step detach2: SELECT injection_points_detach('injection-points-wait');
23+
injection_points_detach
24+
-----------------------
25+
26+
(1 row)
27+
28+
29+
starting permutation: wait1 detach2 wakeup2
30+
injection_points_attach
31+
-----------------------
32+
33+
(1 row)
34+
35+
step wait1: SELECT injection_points_run('injection-points-wait'); <waiting ...>
36+
step detach2: SELECT injection_points_detach('injection-points-wait');
37+
injection_points_detach
38+
-----------------------
39+
40+
(1 row)
41+
42+
step wakeup2: SELECT injection_points_wakeup('injection-points-wait');
43+
injection_points_wakeup
44+
-----------------------
45+
46+
(1 row)
47+
48+
step wait1: <... completed>
49+
injection_points_run
50+
--------------------
51+
52+
(1 row)
53+
54+
55+
starting permutation: detach2 wait1 wakeup2
56+
injection_points_attach
57+
-----------------------
58+
59+
(1 row)
60+
61+
step detach2: SELECT injection_points_detach('injection-points-wait');
62+
injection_points_detach
63+
-----------------------
64+
65+
(1 row)
66+
67+
step wait1: SELECT injection_points_run('injection-points-wait');
68+
injection_points_run
69+
--------------------
70+
71+
(1 row)
72+
73+
step wakeup2: SELECT injection_points_wakeup('injection-points-wait');
74+
ERROR: could not find injection point injection-points-wait to wake up

src/test/modules/injection_points/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ tests += {
4242
},
4343
'isolation': {
4444
'specs': [
45+
'basic',
4546
'inplace',
4647
],
4748
},
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Basic isolation test for injection points.
2+
#
3+
# This checks the interactions between wakeup, wait and detach.
4+
# Feel free to use it as a template when implementing an isolation
5+
# test with injection points.
6+
7+
setup
8+
{
9+
CREATE EXTENSION injection_points;
10+
}
11+
teardown
12+
{
13+
DROP EXTENSION injection_points;
14+
}
15+
16+
# Wait happens in the first session, wakeup in the second session.
17+
session s1
18+
setup {
19+
SELECT injection_points_set_local();
20+
SELECT injection_points_attach('injection-points-wait', 'wait');
21+
}
22+
step wait1 { SELECT injection_points_run('injection-points-wait'); }
23+
24+
session s2
25+
step wakeup2 { SELECT injection_points_wakeup('injection-points-wait'); }
26+
step detach2 { SELECT injection_points_detach('injection-points-wait'); }
27+
28+
# Detach after wait and wakeup.
29+
permutation wait1 wakeup2 detach2
30+
31+
# Detach before wakeup. s1 waits until wakeup, ignores the detach.
32+
permutation wait1 detach2 wakeup2
33+
34+
# Detach before wait does not cause a wait, wakeup produces an error.
35+
permutation detach2 wait1 wakeup2

0 commit comments

Comments
 (0)