vacuumlo: add test to vacuumlo for test coverage

Started by Dong Wook Leeover 3 years ago5 messages
#1Dong Wook Lee
sh95119@gmail.com
1 attachment(s)

Hi hackers,
I write a tiny patch about vacuumlo to improve test coverage.
I hope my work is meaningful.

---
Regards,
DongWook Lee.

Attachments:

v1_add_test_to_vacuumlo.patchapplication/octet-stream; name=v1_add_test_to_vacuumlo.patchDownload
From e0d1a9a04c3dab1f37d9772588f45a62c586d9a9 Mon Sep 17 00:00:00 2001
From: Lee Dong Wook <sh95119@gmail.com>
Date: Tue, 9 Aug 2022 11:13:49 +0900
Subject: [PATCH] vacuumlo: add test for coverage

---
 contrib/vacuumlo/t/002_vacuumlo.pl | 31 ++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 contrib/vacuumlo/t/002_vacuumlo.pl

diff --git a/contrib/vacuumlo/t/002_vacuumlo.pl b/contrib/vacuumlo/t/002_vacuumlo.pl
new file mode 100644
index 000000000000..e661b08f25ce
--- /dev/null
+++ b/contrib/vacuumlo/t/002_vacuumlo.pl
@@ -0,0 +1,31 @@
+
+# Copyright (c) 2021-2022, PostgreSQL Global Development Group
+
+use strict;
+use warnings;
+
+use PostgreSQL::Test::Cluster;
+use Test::More;
+use IPC::Run;
+
+my ($node, $port, $stdout, $stderr);
+
+$node = PostgreSQL::Test::Cluster->new('main');
+$node->init;
+$node->start;
+
+$node->safe_psql('postgres',
+    'CREATE TABLE test(loid oid);'
+    . 'INSERT INTO test(loid)
+       SELECT lo_creat(27);'
+    . 'DROP TABLE test;'
+    . 'CREATE TABLE test(loid oid);'
+    . 'INSERT INTO test(loid)
+       SELECT lo_creat(27);');
+
+$port = $node->port;
+IPC::Run::run [ 'vacuumlo', '-v', '-n', '-p', $port, 'postgres' ], '>', \$stdout;
+
+like($stdout, qr/Removing lo  \d+/, 'remove lo successfully');
+
+done_testing();
#2Daniel Gustafsson
daniel@yesql.se
In reply to: Dong Wook Lee (#1)
Re: vacuumlo: add test to vacuumlo for test coverage

On 3 Sep 2022, at 10:27, Dong Wook Lee <sh95119@gmail.com> wrote:

I write a tiny patch about vacuumlo to improve test coverage.

If we are paying for setting up a cluster we might as well test more scenarios
than just the one. Perhaps some other low-hanging fruit like calling vacuumlo
on a non-existing databsase, on one where no LO have been made etc?

One thing about the patch:

+IPC::Run::run [ 'vacuumlo', '-v', '-n', '-p', $port, 'postgres' ], '>', \$stdout;

This should use run_command() which provides facilities for running commands
and capturing STDOUT. With this the test can be rewritten something like:

my ($out, $err) = run_command(['vacuumlo', .. ]);
like($out, ..);

run_command() is defined in PostgreSQL::Test::Utils.

--
Daniel Gustafsson https://vmware.com/

#3Ian Lawrence Barwick
barwick@gmail.com
In reply to: Dong Wook Lee (#1)
Re: vacuumlo: add test to vacuumlo for test coverage

2022年9月3日(土) 17:28 Dong Wook Lee <sh95119@gmail.com>:

Hi hackers,
I write a tiny patch about vacuumlo to improve test coverage.
I hope my work is meaningful.

Hi

While reviewing the patch backlog, we have determined that this patch adds
one or more TAP tests but has not added the test to the "meson.build" file.

To do this, locate the relevant "meson.build" file for each test and add it
in the 'tests' dictionary, which will look something like this:

'tap': {
'tests': [
't/001_basic.pl',
],
},

For some additional details please see this Wiki article:

https://wiki.postgresql.org/wiki/Meson_for_patch_authors

For more information on the meson build system for PostgreSQL see:

https://wiki.postgresql.org/wiki/Meson

Regards

Ian Barwick

#4vignesh C
vignesh21@gmail.com
In reply to: Ian Lawrence Barwick (#3)
Re: vacuumlo: add test to vacuumlo for test coverage

On Wed, 16 Nov 2022 at 10:18, Ian Lawrence Barwick <barwick@gmail.com> wrote:

2022年9月3日(土) 17:28 Dong Wook Lee <sh95119@gmail.com>:

Hi hackers,
I write a tiny patch about vacuumlo to improve test coverage.
I hope my work is meaningful.

Hi

While reviewing the patch backlog, we have determined that this patch adds
one or more TAP tests but has not added the test to the "meson.build" file.

To do this, locate the relevant "meson.build" file for each test and add it
in the 'tests' dictionary, which will look something like this:

'tap': {
'tests': [
't/001_basic.pl',
],
},

For some additional details please see this Wiki article:

https://wiki.postgresql.org/wiki/Meson_for_patch_authors

For more information on the meson build system for PostgreSQL see:

https://wiki.postgresql.org/wiki/Meson

Hi DongWook Lee,

Please plan to work on the comment and provide a patch. As CommitFest
2023-01 is currently underway, this would be an excellent time to
update the patch and get the patch in a better shape.

Regards,
Vignesh

#5vignesh C
vignesh21@gmail.com
In reply to: vignesh C (#4)
Re: vacuumlo: add test to vacuumlo for test coverage

On Tue, 17 Jan 2023 at 17:10, vignesh C <vignesh21@gmail.com> wrote:

On Wed, 16 Nov 2022 at 10:18, Ian Lawrence Barwick <barwick@gmail.com> wrote:

2022年9月3日(土) 17:28 Dong Wook Lee <sh95119@gmail.com>:

Hi hackers,
I write a tiny patch about vacuumlo to improve test coverage.
I hope my work is meaningful.

Hi

While reviewing the patch backlog, we have determined that this patch adds
one or more TAP tests but has not added the test to the "meson.build" file.

To do this, locate the relevant "meson.build" file for each test and add it
in the 'tests' dictionary, which will look something like this:

'tap': {
'tests': [
't/001_basic.pl',
],
},

For some additional details please see this Wiki article:

https://wiki.postgresql.org/wiki/Meson_for_patch_authors

For more information on the meson build system for PostgreSQL see:

https://wiki.postgresql.org/wiki/Meson

Hi DongWook Lee,

Please plan to work on the comment and provide a patch. As CommitFest
2023-01 is currently underway, this would be an excellent time to
update the patch and get the patch in a better shape.

There has been no updates on this thread for some time, so this has
been switched as Returned with Feedback. Feel free to open it in the
next commitfest if you plan to continue on this.

Regards,
Vignesh