old_snapshot: add test for coverage
Hi hackers,
I wrote a test of the old_snapshot extension for coverage.
I hope that this is written correctly.
before:
0%
after:
100%
---
regards,
Lee Dong Wook.
Attachments:
v1_add_test_oldsnapshot.patchapplication/octet-stream; name=v1_add_test_oldsnapshot.patchDownload
From eac23ebbacc00dedc7176c269c46dd0a74ef6039 Mon Sep 17 00:00:00 2001
From: Lee Dong Wook <sh95119@gmail.com>
Date: Mon, 8 Aug 2022 12:09:27 +0900
Subject: [PATCH] old_snapshot: add test for coverage
---
contrib/old_snapshot/.gitignore | 4 ++++
contrib/old_snapshot/Makefile | 3 +++
contrib/old_snapshot/expected/old_snapshot.out | 6 ++++++
contrib/old_snapshot/old_snapshot.conf | 1 +
contrib/old_snapshot/sql/old_snapshot.sql | 4 ++++
5 files changed, 18 insertions(+)
create mode 100644 contrib/old_snapshot/.gitignore
create mode 100644 contrib/old_snapshot/expected/old_snapshot.out
create mode 100644 contrib/old_snapshot/old_snapshot.conf
create mode 100644 contrib/old_snapshot/sql/old_snapshot.sql
diff --git a/contrib/old_snapshot/.gitignore b/contrib/old_snapshot/.gitignore
new file mode 100644
index 000000000000..5dcb3ff97235
--- /dev/null
+++ b/contrib/old_snapshot/.gitignore
@@ -0,0 +1,4 @@
+# Generated subdirectories
+/log/
+/results/
+/tmp_check/
diff --git a/contrib/old_snapshot/Makefile b/contrib/old_snapshot/Makefile
index adb557532fc1..6265c6df0b7f 100644
--- a/contrib/old_snapshot/Makefile
+++ b/contrib/old_snapshot/Makefile
@@ -9,6 +9,9 @@ EXTENSION = old_snapshot
DATA = old_snapshot--1.0.sql
PGFILEDESC = "old_snapshot - utilities in support of old_snapshot_threshold"
+REGRESS = old_snapshot
+REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/old_snapshot/old_snapshot.conf
+
ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
diff --git a/contrib/old_snapshot/expected/old_snapshot.out b/contrib/old_snapshot/expected/old_snapshot.out
new file mode 100644
index 000000000000..a1341b5046f1
--- /dev/null
+++ b/contrib/old_snapshot/expected/old_snapshot.out
@@ -0,0 +1,6 @@
+CREATE EXTENSION old_snapshot;
+SELECT * FROM pg_old_snapshot_time_mapping() LIMIT 0;
+ array_offset | end_timestamp | newest_xmin
+--------------+---------------+-------------
+(0 rows)
+
diff --git a/contrib/old_snapshot/old_snapshot.conf b/contrib/old_snapshot/old_snapshot.conf
new file mode 100644
index 000000000000..d847bb42da16
--- /dev/null
+++ b/contrib/old_snapshot/old_snapshot.conf
@@ -0,0 +1 @@
+old_snapshot_threshold = 1min
diff --git a/contrib/old_snapshot/sql/old_snapshot.sql b/contrib/old_snapshot/sql/old_snapshot.sql
new file mode 100644
index 000000000000..f7056def840d
--- /dev/null
+++ b/contrib/old_snapshot/sql/old_snapshot.sql
@@ -0,0 +1,4 @@
+CREATE EXTENSION old_snapshot;
+
+SELECT * FROM pg_old_snapshot_time_mapping() LIMIT 0;
+
Dong Wook Lee <sh95119@gmail.com> writes:
I wrote a test of the old_snapshot extension for coverage.
Hmm, does this really provide any meaningful coverage? The test
sure looks like it's not doing much.
I spent some time a week or so ago trying to graft testing of
contrib/old_snapshot into src/test/modules/snapshot_too_old.
I didn't come up with anything I liked, but I still think
that that might lead to a more thorough test than a standalone
exercise.
regards, tom lane
On 8 Aug 2022, at 07:37, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Dong Wook Lee <sh95119@gmail.com> writes:
I wrote a test of the old_snapshot extension for coverage.
Hmm, does this really provide any meaningful coverage? The test
sure looks like it's not doing much.
Looking at this I agree, this test doesn't provide enough to be of value and
the LIMIT 0 might even hide bugs under a postive test result. I think we
should mark this entry RwF.
--
Daniel Gustafsson https://vmware.com/
On Mon, Aug 8, 2022 at 2:37 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Dong Wook Lee <sh95119@gmail.com> writes:
I wrote a test of the old_snapshot extension for coverage.
Hmm, does this really provide any meaningful coverage? The test
sure looks like it's not doing much.
Previously written tests were simply test codes to increase coverage.
Therefore, we can make a better test.
I'll think about it by this week. If this work exceeds my ability, I
will let you know by reply.
It's okay that the issue should be closed unless I write a meaningful test.
---
Regards,
DongWook Lee.