summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier2024-10-21 02:10:51 +0000
committerMichael Paquier2024-10-21 02:10:51 +0000
commita7800cf498a36456bf4bd7a52e3b81cc225c5a65 (patch)
tree2f7c598a7abcb633900e9c31f4ac37ce30b9016a
parentf1c141fe143cc362d6db918db5008c25e2df7a62 (diff)
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 c35f419d6efb. 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/[email protected]
-rw-r--r--src/test/modules/injection_points/Makefile2
-rw-r--r--src/test/modules/injection_points/expected/basic.out74
-rw-r--r--src/test/modules/injection_points/meson.build1
-rw-r--r--src/test/modules/injection_points/specs/basic.spec35
4 files changed, 111 insertions, 1 deletions
diff --git a/src/test/modules/injection_points/Makefile b/src/test/modules/injection_points/Makefile
index 8cb8c498e23..0753a9df58c 100644
--- a/src/test/modules/injection_points/Makefile
+++ b/src/test/modules/injection_points/Makefile
@@ -13,7 +13,7 @@ PGFILEDESC = "injection_points - facility for injection points"
REGRESS = injection_points reindex_conc
REGRESS_OPTS = --dlpath=$(top_builddir)/src/test/regress
-ISOLATION = inplace
+ISOLATION = basic inplace
TAP_TESTS = 1
diff --git a/src/test/modules/injection_points/expected/basic.out b/src/test/modules/injection_points/expected/basic.out
new file mode 100644
index 00000000000..840ce2dac90
--- /dev/null
+++ b/src/test/modules/injection_points/expected/basic.out
@@ -0,0 +1,74 @@
+Parsed test spec with 2 sessions
+
+starting permutation: wait1 wakeup2 detach2
+injection_points_attach
+-----------------------
+
+(1 row)
+
+step wait1: SELECT injection_points_run('injection-points-wait'); <waiting ...>
+step wakeup2: SELECT injection_points_wakeup('injection-points-wait');
+injection_points_wakeup
+-----------------------
+
+(1 row)
+
+step wait1: <... completed>
+injection_points_run
+--------------------
+
+(1 row)
+
+step detach2: SELECT injection_points_detach('injection-points-wait');
+injection_points_detach
+-----------------------
+
+(1 row)
+
+
+starting permutation: wait1 detach2 wakeup2
+injection_points_attach
+-----------------------
+
+(1 row)
+
+step wait1: SELECT injection_points_run('injection-points-wait'); <waiting ...>
+step detach2: SELECT injection_points_detach('injection-points-wait');
+injection_points_detach
+-----------------------
+
+(1 row)
+
+step wakeup2: SELECT injection_points_wakeup('injection-points-wait');
+injection_points_wakeup
+-----------------------
+
+(1 row)
+
+step wait1: <... completed>
+injection_points_run
+--------------------
+
+(1 row)
+
+
+starting permutation: detach2 wait1 wakeup2
+injection_points_attach
+-----------------------
+
+(1 row)
+
+step detach2: SELECT injection_points_detach('injection-points-wait');
+injection_points_detach
+-----------------------
+
+(1 row)
+
+step wait1: SELECT injection_points_run('injection-points-wait');
+injection_points_run
+--------------------
+
+(1 row)
+
+step wakeup2: SELECT injection_points_wakeup('injection-points-wait');
+ERROR: could not find injection point injection-points-wait to wake up
diff --git a/src/test/modules/injection_points/meson.build b/src/test/modules/injection_points/meson.build
index fdb5a25d7b3..58f19001157 100644
--- a/src/test/modules/injection_points/meson.build
+++ b/src/test/modules/injection_points/meson.build
@@ -42,6 +42,7 @@ tests += {
},
'isolation': {
'specs': [
+ 'basic',
'inplace',
],
},
diff --git a/src/test/modules/injection_points/specs/basic.spec b/src/test/modules/injection_points/specs/basic.spec
new file mode 100644
index 00000000000..7c50d85e1f9
--- /dev/null
+++ b/src/test/modules/injection_points/specs/basic.spec
@@ -0,0 +1,35 @@
+# Basic isolation test for injection points.
+#
+# This checks the interactions between wakeup, wait and detach.
+# Feel free to use it as a template when implementing an isolation
+# test with injection points.
+
+setup
+{
+ CREATE EXTENSION injection_points;
+}
+teardown
+{
+ DROP EXTENSION injection_points;
+}
+
+# Wait happens in the first session, wakeup in the second session.
+session s1
+setup {
+ SELECT injection_points_set_local();
+ SELECT injection_points_attach('injection-points-wait', 'wait');
+}
+step wait1 { SELECT injection_points_run('injection-points-wait'); }
+
+session s2
+step wakeup2 { SELECT injection_points_wakeup('injection-points-wait'); }
+step detach2 { SELECT injection_points_detach('injection-points-wait'); }
+
+# Detach after wait and wakeup.
+permutation wait1 wakeup2 detach2
+
+# Detach before wakeup. s1 waits until wakeup, ignores the detach.
+permutation wait1 detach2 wakeup2
+
+# Detach before wait does not cause a wait, wakeup produces an error.
+permutation detach2 wait1 wakeup2