public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v4 1/3] Move TAP log-searching feature to common modules
3+ messages / 3 participants
[nested] [flat]

* [PATCH v4 1/3] Move TAP log-searching feature to common modules
@ 2021-01-05 04:34  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Kyotaro Horiguchi @ 2021-01-05 04:34 UTC (permalink / raw)

Some private functions in 019_repslot_limit.pl will be used in other
tests. Move them to common modules so that they are available to the
new tests.
---
 src/test/perl/PostgresNode.pm             | 36 ++++++++++++++++++++++
 src/test/recovery/t/019_replslot_limit.pl | 37 ++++-------------------
 2 files changed, 42 insertions(+), 31 deletions(-)

diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm
index 9667f7667e..d78e9f93fb 100644
--- a/src/test/perl/PostgresNode.pm
+++ b/src/test/perl/PostgresNode.pm
@@ -2223,6 +2223,42 @@ sub pg_recvlogical_upto
 
 =pod
 
+=item $node->current_log_position()
+
+Return the current position of server log.
+
+=cut
+
+sub current_log_position
+{
+	my $self = shift;
+
+	return (stat $self->logfile)[7];
+}
+
+=pod
+
+=item $node->find_in_log($pattern, $startpos)
+
+Returns whether the $pattern occurs after $startpos in the server log.
+
+=cut
+
+sub find_in_log
+{
+	my ($self, $pattern, $startpos) = @_;
+
+	$startpos = 0 unless defined $startpos;
+	my $log = TestLib::slurp_file($self->logfile);
+	return 0 if (length($log) <= $startpos);
+
+	$log = substr($log, $startpos);
+
+	return $log =~ m/$pattern/;
+}
+
+=pod
+
 =back
 
 =cut
diff --git a/src/test/recovery/t/019_replslot_limit.pl b/src/test/recovery/t/019_replslot_limit.pl
index 20f4a1bbc3..b298d9992f 100644
--- a/src/test/recovery/t/019_replslot_limit.pl
+++ b/src/test/recovery/t/019_replslot_limit.pl
@@ -165,19 +165,17 @@ $node_primary->wait_for_catchup($node_standby, 'replay', $start_lsn);
 
 $node_standby->stop;
 
-ok( !find_in_log(
-		$node_standby,
-		"requested WAL segment [0-9A-F]+ has already been removed"),
+ok( !$node_standby->find_in_log(
+		 "requested WAL segment [0-9A-F]+ has already been removed"),
 	'check that required WAL segments are still available');
 
 # Advance WAL again, the slot loses the oldest segment.
-my $logstart = get_log_size($node_primary);
+my $logstart = $node_primary->current_log_position();
 advance_wal($node_primary, 7);
 $node_primary->safe_psql('postgres', "CHECKPOINT;");
 
 # WARNING should be issued
-ok( find_in_log(
-		$node_primary,
+ok( $node_primary->find_in_log(
 		"invalidating slot \"rep1\" because its restart_lsn [0-9A-F/]+ exceeds max_slot_wal_keep_size",
 		$logstart),
 	'check that the warning is logged');
@@ -190,14 +188,13 @@ is($result, "rep1|f|t|lost|",
 	'check that the slot became inactive and the state "lost" persists');
 
 # The standby no longer can connect to the primary
-$logstart = get_log_size($node_standby);
+$logstart = $node_standby->current_log_position();
 $node_standby->start;
 
 my $failed = 0;
 for (my $i = 0; $i < 10000; $i++)
 {
-	if (find_in_log(
-			$node_standby,
+	if ($node_standby->find_in_log(
 			"requested WAL segment [0-9A-F]+ has already been removed",
 			$logstart))
 	{
@@ -264,25 +261,3 @@ sub advance_wal
 	}
 	return;
 }
-
-# return the size of logfile of $node in bytes
-sub get_log_size
-{
-	my ($node) = @_;
-
-	return (stat $node->logfile)[7];
-}
-
-# find $pat in logfile of $node after $off-th byte
-sub find_in_log
-{
-	my ($node, $pat, $off) = @_;
-
-	$off = 0 unless defined $off;
-	my $log = TestLib::slurp_file($node->logfile);
-	return 0 if (length($log) <= $off);
-
-	$log = substr($log, $off);
-
-	return $log =~ m/$pat/;
-}
-- 
2.27.0


----Next_Part(Thu_Jan__7_16_32_36_2021_122)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="v4-0002-New-test-for-timeline-tracking-of-walsender.patch"



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* convert libpq uri-regress tests to tap test
@ 2022-02-23 20:30  Andres Freund <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Andres Freund @ 2022-02-23 20:30 UTC (permalink / raw)
  To: pgsql-hackers

Hi,

When verifying that the meson port actually runs all perl based tests I came
across src/interfaces/libpq/test/regress.pl.  Instead of running tests yet
another way, it seems better to convert it to a tap test.

I hope others agree?

Where would we want that test to live? Right now we have the slightly odd
convention that some tap tests live in src/test/{misc,modules,...}. But
e.g. frontend binary ones are below src/bin/.

For now I've left it in src/interfaces/libpq/test, with the test in
t/001_uri.pl. But we should at least get rid of the test/...

Perhaps we should just rename src/test/modules/libpq_pipeline to
src/test/modules/libpq and move uri-regress in there as well?


The tap test needs a bit more polish, mostly posted this to get some feedback
before wasting more time :)

Greetings,

Andres Freund


Attachments:

  [text/x-diff] v1-0001-Convert-src-interfaces-libpq-test-to-a-tap-test.patch (18.3K, ../../[email protected]/2-v1-0001-Convert-src-interfaces-libpq-test-to-a-tap-test.patch)
  download | inline diff:
From 77b3666c9a7f17f98120cfc9c2a8e99f7d4ab491 Mon Sep 17 00:00:00 2001
From: Andres Freund <[email protected]>
Date: Wed, 23 Feb 2022 12:22:56 -0800
Subject: [PATCH v1] Convert src/interfaces/libpq/test to a tap test.

---
 src/interfaces/libpq/Makefile          |   2 +-
 src/interfaces/libpq/test/Makefile     |  10 +-
 src/interfaces/libpq/test/README       |   7 -
 src/interfaces/libpq/test/expected.out | 171 ----------------
 src/interfaces/libpq/test/regress.in   |  57 ------
 src/interfaces/libpq/test/regress.pl   |  65 ------
 src/interfaces/libpq/test/t/001_uri.pl | 266 +++++++++++++++++++++++++
 7 files changed, 274 insertions(+), 304 deletions(-)
 delete mode 100644 src/interfaces/libpq/test/README
 delete mode 100644 src/interfaces/libpq/test/expected.out
 delete mode 100644 src/interfaces/libpq/test/regress.in
 delete mode 100644 src/interfaces/libpq/test/regress.pl
 create mode 100644 src/interfaces/libpq/test/t/001_uri.pl

diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index 844c95d47de..8920f7e6365 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -137,7 +137,7 @@ install: all installdirs install-lib
 	$(INSTALL_DATA) $(srcdir)/pqexpbuffer.h '$(DESTDIR)$(includedir_internal)'
 	$(INSTALL_DATA) $(srcdir)/pg_service.conf.sample '$(DESTDIR)$(datadir)/pg_service.conf.sample'
 
-installcheck:
+installcheck check:
 	$(MAKE) -C test $@
 
 installdirs: installdirs-lib
diff --git a/src/interfaces/libpq/test/Makefile b/src/interfaces/libpq/test/Makefile
index 4832fab9d23..5dbfe5d09ae 100644
--- a/src/interfaces/libpq/test/Makefile
+++ b/src/interfaces/libpq/test/Makefile
@@ -1,3 +1,5 @@
+# src/interfaces/libpq/test/Makefile
+
 subdir = src/interfaces/libpq/test
 top_builddir = ../../../..
 include $(top_builddir)/src/Makefile.global
@@ -13,10 +15,12 @@ PROGS = uri-regress
 
 all: $(PROGS)
 
+check: all
+	$(prove_check)
+
 installcheck: all
-	SRCDIR='$(top_srcdir)' SUBDIR='$(subdir)' \
-		   $(PERL) $(top_srcdir)/$(subdir)/regress.pl
+	$(prove_installcheck)
 
 clean distclean maintainer-clean:
 	rm -f $(PROGS) *.o
-	rm -f regress.out regress.diff
+	rm -rf tmp_check
diff --git a/src/interfaces/libpq/test/README b/src/interfaces/libpq/test/README
deleted file mode 100644
index a05eb6bb3bc..00000000000
--- a/src/interfaces/libpq/test/README
+++ /dev/null
@@ -1,7 +0,0 @@
-This is a testsuite for testing libpq URI connection string syntax.
-
-To run the suite, use 'make installcheck' command.  It works by
-running 'regress.pl' from this directory with appropriate environment
-set up, which in turn feeds up lines from 'regress.in' to
-'uri-regress' test program and compares the output against the correct
-one in 'expected.out' file.
diff --git a/src/interfaces/libpq/test/expected.out b/src/interfaces/libpq/test/expected.out
deleted file mode 100644
index d375e82b4ac..00000000000
--- a/src/interfaces/libpq/test/expected.out
+++ /dev/null
@@ -1,171 +0,0 @@
-trying postgresql://uri-user:secret@host:12345/db
-user='uri-user' password='secret' dbname='db' host='host' port='12345' (inet)
-
-trying postgresql://uri-user@host:12345/db
-user='uri-user' dbname='db' host='host' port='12345' (inet)
-
-trying postgresql://uri-user@host/db
-user='uri-user' dbname='db' host='host' (inet)
-
-trying postgresql://host:12345/db
-dbname='db' host='host' port='12345' (inet)
-
-trying postgresql://host/db
-dbname='db' host='host' (inet)
-
-trying postgresql://uri-user@host:12345/
-user='uri-user' host='host' port='12345' (inet)
-
-trying postgresql://uri-user@host/
-user='uri-user' host='host' (inet)
-
-trying postgresql://uri-user@
-user='uri-user' (local)
-
-trying postgresql://host:12345/
-host='host' port='12345' (inet)
-
-trying postgresql://host:12345
-host='host' port='12345' (inet)
-
-trying postgresql://host/db
-dbname='db' host='host' (inet)
-
-trying postgresql://host/
-host='host' (inet)
-
-trying postgresql://host
-host='host' (inet)
-
-trying postgresql://
-(local)
-
-trying postgresql://?hostaddr=127.0.0.1
-hostaddr='127.0.0.1' (inet)
-
-trying postgresql://example.com?hostaddr=63.1.2.4
-host='example.com' hostaddr='63.1.2.4' (inet)
-
-trying postgresql://%68ost/
-host='host' (inet)
-
-trying postgresql://host/db?user=uri-user
-user='uri-user' dbname='db' host='host' (inet)
-
-trying postgresql://host/db?user=uri-user&port=12345
-user='uri-user' dbname='db' host='host' port='12345' (inet)
-
-trying postgresql://host/db?u%73er=someotheruser&port=12345
-user='someotheruser' dbname='db' host='host' port='12345' (inet)
-
-trying postgresql://host/db?u%7aer=someotheruser&port=12345
-uri-regress: invalid URI query parameter: "uzer"
-
-trying postgresql://host:12345?user=uri-user
-user='uri-user' host='host' port='12345' (inet)
-
-trying postgresql://host?user=uri-user
-user='uri-user' host='host' (inet)
-
-trying postgresql://host?
-host='host' (inet)
-
-trying postgresql://[::1]:12345/db
-dbname='db' host='::1' port='12345' (inet)
-
-trying postgresql://[::1]/db
-dbname='db' host='::1' (inet)
-
-trying postgresql://[2001:db8::1234]/
-host='2001:db8::1234' (inet)
-
-trying postgresql://[200z:db8::1234]/
-host='200z:db8::1234' (inet)
-
-trying postgresql://[::1]
-host='::1' (inet)
-
-trying postgres://
-(local)
-
-trying postgres:///
-(local)
-
-trying postgres:///db
-dbname='db' (local)
-
-trying postgres://uri-user@/db
-user='uri-user' dbname='db' (local)
-
-trying postgres://?host=/path/to/socket/dir
-host='/path/to/socket/dir' (local)
-
-trying postgresql://host?uzer=
-uri-regress: invalid URI query parameter: "uzer"
-
-trying postgre://
-uri-regress: missing "=" after "postgre://" in connection info string
-
-trying postgres://[::1
-uri-regress: end of string reached when looking for matching "]" in IPv6 host address in URI: "postgres://[::1"
-
-trying postgres://[]
-uri-regress: IPv6 host address may not be empty in URI: "postgres://[]"
-
-trying postgres://[::1]z
-uri-regress: unexpected character "z" at position 17 in URI (expected ":" or "/"): "postgres://[::1]z"
-
-trying postgresql://host?zzz
-uri-regress: missing key/value separator "=" in URI query parameter: "zzz"
-
-trying postgresql://host?value1&value2
-uri-regress: missing key/value separator "=" in URI query parameter: "value1"
-
-trying postgresql://host?key=key=value
-uri-regress: extra key/value separator "=" in URI query parameter: "key"
-
-trying postgres://host?dbname=%XXfoo
-uri-regress: invalid percent-encoded token: "%XXfoo"
-
-trying postgresql://a%00b
-uri-regress: forbidden value %00 in percent-encoded value: "a%00b"
-
-trying postgresql://%zz
-uri-regress: invalid percent-encoded token: "%zz"
-
-trying postgresql://%1
-uri-regress: invalid percent-encoded token: "%1"
-
-trying postgresql://%
-uri-regress: invalid percent-encoded token: "%"
-
-trying postgres://@host
-host='host' (inet)
-
-trying postgres://host:/
-host='host' (inet)
-
-trying postgres://:12345/
-port='12345' (local)
-
-trying postgres://otheruser@?host=/no/such/directory
-user='otheruser' host='/no/such/directory' (local)
-
-trying postgres://otheruser@/?host=/no/such/directory
-user='otheruser' host='/no/such/directory' (local)
-
-trying postgres://otheruser@:12345?host=/no/such/socket/path
-user='otheruser' host='/no/such/socket/path' port='12345' (local)
-
-trying postgres://otheruser@:12345/db?host=/path/to/socket
-user='otheruser' dbname='db' host='/path/to/socket' port='12345' (local)
-
-trying postgres://:12345/db?host=/path/to/socket
-dbname='db' host='/path/to/socket' port='12345' (local)
-
-trying postgres://:12345?host=/path/to/socket
-host='/path/to/socket' port='12345' (local)
-
-trying postgres://%2Fvar%2Flib%2Fpostgresql/dbname
-dbname='dbname' host='/var/lib/postgresql' (local)
-
diff --git a/src/interfaces/libpq/test/regress.in b/src/interfaces/libpq/test/regress.in
deleted file mode 100644
index de034f39141..00000000000
--- a/src/interfaces/libpq/test/regress.in
+++ /dev/null
@@ -1,57 +0,0 @@
-postgresql://uri-user:secret@host:12345/db
-postgresql://uri-user@host:12345/db
-postgresql://uri-user@host/db
-postgresql://host:12345/db
-postgresql://host/db
-postgresql://uri-user@host:12345/
-postgresql://uri-user@host/
-postgresql://uri-user@
-postgresql://host:12345/
-postgresql://host:12345
-postgresql://host/db
-postgresql://host/
-postgresql://host
-postgresql://
-postgresql://?hostaddr=127.0.0.1
-postgresql://example.com?hostaddr=63.1.2.4
-postgresql://%68ost/
-postgresql://host/db?user=uri-user
-postgresql://host/db?user=uri-user&port=12345
-postgresql://host/db?u%73er=someotheruser&port=12345
-postgresql://host/db?u%7aer=someotheruser&port=12345
-postgresql://host:12345?user=uri-user
-postgresql://host?user=uri-user
-postgresql://host?
-postgresql://[::1]:12345/db
-postgresql://[::1]/db
-postgresql://[2001:db8::1234]/
-postgresql://[200z:db8::1234]/
-postgresql://[::1]
-postgres://
-postgres:///
-postgres:///db
-postgres://uri-user@/db
-postgres://?host=/path/to/socket/dir
-postgresql://host?uzer=
-postgre://
-postgres://[::1
-postgres://[]
-postgres://[::1]z
-postgresql://host?zzz
-postgresql://host?value1&value2
-postgresql://host?key=key=value
-postgres://host?dbname=%XXfoo
-postgresql://a%00b
-postgresql://%zz
-postgresql://%1
-postgresql://%
-postgres://@host
-postgres://host:/
-postgres://:12345/
-postgres://otheruser@?host=/no/such/directory
-postgres://otheruser@/?host=/no/such/directory
-postgres://otheruser@:12345?host=/no/such/socket/path
-postgres://otheruser@:12345/db?host=/path/to/socket
-postgres://:12345/db?host=/path/to/socket
-postgres://:12345?host=/path/to/socket
-postgres://%2Fvar%2Flib%2Fpostgresql/dbname
diff --git a/src/interfaces/libpq/test/regress.pl b/src/interfaces/libpq/test/regress.pl
deleted file mode 100644
index 70691dabe68..00000000000
--- a/src/interfaces/libpq/test/regress.pl
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (c) 2021-2022, PostgreSQL Global Development Group
-
-use strict;
-use warnings;
-
-# use of SRCDIR/SUBDIR is required for supporting VPath builds
-my $srcdir = $ENV{'SRCDIR'} or die 'SRCDIR environment variable is not set';
-my $subdir = $ENV{'SUBDIR'} or die 'SUBDIR environment variable is not set';
-
-my $regress_in   = "$srcdir/$subdir/regress.in";
-my $expected_out = "$srcdir/$subdir/expected.out";
-
-# the output file should land in the build_dir of VPath, or just in
-# the current dir, if VPath isn't used
-my $regress_out = "regress.out";
-
-# open input file first, so possible error isn't sent to redirected STDERR
-open(my $regress_in_fh, "<", $regress_in)
-  or die "can't open $regress_in for reading: $!";
-
-# save STDOUT/ERR and redirect both to regress.out
-open(my $oldout_fh, ">&", \*STDOUT) or die "can't dup STDOUT: $!";
-open(my $olderr_fh, ">&", \*STDERR) or die "can't dup STDERR: $!";
-
-open(STDOUT, ">", $regress_out)
-  or die "can't open $regress_out for writing: $!";
-open(STDERR, ">&", \*STDOUT) or die "can't dup STDOUT: $!";
-
-# read lines from regress.in and run uri-regress on them
-while (<$regress_in_fh>)
-{
-	chomp;
-	print "trying $_\n";
-	system("./uri-regress \"$_\"");
-	print "\n";
-}
-
-# restore STDOUT/ERR so we can print the outcome to the user
-open(STDERR, ">&", $olderr_fh)
-  or die;    # can't complain as STDERR is still duped
-open(STDOUT, ">&", $oldout_fh) or die "can't restore STDOUT: $!";
-
-# just in case
-close $regress_in_fh;
-
-my $diff_status = system(
-	"diff -c \"$srcdir/$subdir/expected.out\" regress.out >regress.diff");
-
-print "=" x 70, "\n";
-if ($diff_status == 0)
-{
-	print "All tests passed\n";
-	exit 0;
-}
-else
-{
-	print <<EOF;
-FAILED: the test result differs from the expected output
-
-Review the difference in "$subdir/regress.diff"
-EOF
-	exit 1;
-}
diff --git a/src/interfaces/libpq/test/t/001_uri.pl b/src/interfaces/libpq/test/t/001_uri.pl
new file mode 100644
index 00000000000..a75cc06444d
--- /dev/null
+++ b/src/interfaces/libpq/test/t/001_uri.pl
@@ -0,0 +1,266 @@
+# Copyright (c) 2021-2022, PostgreSQL Global Development Group
+use strict;
+use warnings;
+
+use PostgreSQL::Test::Utils;
+use Test::More;
+use IPC::Run;
+
+my @tests = (
+	[q{postgresql://uri-user:secret@host:12345/db},
+	 q{user='uri-user' password='secret' dbname='db' host='host' port='12345' (inet)},
+     q{},
+    ],
+	[q{postgresql://uri-user@host:12345/db},
+	 q{user='uri-user' dbname='db' host='host' port='12345' (inet)},
+     q{},
+    ],
+	[q{postgresql://uri-user@host/db},
+	 q{user='uri-user' dbname='db' host='host' (inet)},
+     q{},
+    ],
+	[q{postgresql://host:12345/db},
+	 q{dbname='db' host='host' port='12345' (inet)},
+     q{},
+    ],
+	[q{postgresql://host/db},
+	 q{dbname='db' host='host' (inet)},
+     q{},
+    ],
+	[q{postgresql://uri-user@host:12345/},
+	 q{user='uri-user' host='host' port='12345' (inet)},
+     q{},
+    ],
+	[q{postgresql://uri-user@host/},
+	 q{user='uri-user' host='host' (inet)},
+     q{},
+    ],
+	[q{postgresql://uri-user@},
+	 q{user='uri-user' (local)},
+     q{},
+    ],
+	[q{postgresql://host:12345/},
+	 q{host='host' port='12345' (inet)},
+     q{},
+    ],
+	[q{postgresql://host:12345},
+	 q{host='host' port='12345' (inet)},
+     q{},
+    ],
+	[q{postgresql://host/db},
+	 q{dbname='db' host='host' (inet)},
+     q{},
+    ],
+	[q{postgresql://host/},
+	 q{host='host' (inet)},
+     q{},
+    ],
+	[q{postgresql://host},
+	 q{host='host' (inet)},
+     q{},
+    ],
+	[q{postgresql://},
+	 q{(local)},
+     q{},
+    ],
+	[q{postgresql://?hostaddr=127.0.0.1},
+	 q{hostaddr='127.0.0.1' (inet)},
+     q{},
+    ],
+	[q{postgresql://example.com?hostaddr=63.1.2.4},
+	 q{host='example.com' hostaddr='63.1.2.4' (inet)},
+     q{},
+    ],
+	[q{postgresql://%68ost/},
+	 q{host='host' (inet)},
+     q{},
+    ],
+	[q{postgresql://host/db?user=uri-user},
+	 q{user='uri-user' dbname='db' host='host' (inet)},
+     q{},
+    ],
+	[q{postgresql://host/db?user=uri-user&port=12345},
+	 q{user='uri-user' dbname='db' host='host' port='12345' (inet)},
+     q{},
+    ],
+	[q{postgresql://host/db?u%73er=someotheruser&port=12345},
+	 q{user='someotheruser' dbname='db' host='host' port='12345' (inet)},
+     q{},
+    ],
+	[q{postgresql://host/db?u%7aer=someotheruser&port=12345},
+     q{},
+	 q{uri-regress: invalid URI query parameter: "uzer"},
+    ],
+	[q{postgresql://host:12345?user=uri-user},
+	 q{user='uri-user' host='host' port='12345' (inet)},
+     q{},
+    ],
+	[q{postgresql://host?user=uri-user},
+	 q{user='uri-user' host='host' (inet)},
+     q{},
+    ],
+	[q{postgresql://host?},
+	 q{host='host' (inet)},
+     q{},
+    ],
+	[q{postgresql://[::1]:12345/db},
+	 q{dbname='db' host='::1' port='12345' (inet)},
+     q{},
+    ],
+	[q{postgresql://[::1]/db},
+	 q{dbname='db' host='::1' (inet)},
+     q{},
+    ],
+	[q{postgresql://[2001:db8::1234]/},
+	 q{host='2001:db8::1234' (inet)},
+     q{},
+    ],
+	[q{postgresql://[200z:db8::1234]/},
+	 q{host='200z:db8::1234' (inet)},
+     q{},
+    ],
+	[q{postgresql://[::1]},
+	 q{host='::1' (inet)},
+     q{},
+    ],
+	[q{postgres://},
+	 q{(local)},
+     q{},
+    ],
+	[q{postgres:///},
+	 q{(local)},
+     q{},
+    ],
+	[q{postgres:///db},
+	 q{dbname='db' (local)},
+     q{},
+    ],
+	[q{postgres://uri-user@/db},
+	 q{user='uri-user' dbname='db' (local)},
+     q{},
+    ],
+	[q{postgres://?host=/path/to/socket/dir},
+	 q{host='/path/to/socket/dir' (local)},
+     q{},
+    ],
+	[q{postgresql://host?uzer=},
+     q{},
+	 q{uri-regress: invalid URI query parameter: "uzer"},
+    ],
+	[q{postgre://},
+     q{},
+	 q{uri-regress: missing "=" after "postgre://" in connection info string},
+    ],
+	[q{postgres://[::1},
+     q{},
+	 q{uri-regress: end of string reached when looking for matching "]" in IPv6 host address in URI: "postgres://[::1"},
+    ],
+	[q{postgres://[]},
+     q{},
+	 q{uri-regress: IPv6 host address may not be empty in URI: "postgres://[]"},
+    ],
+	[q{postgres://[::1]z},
+     q{},
+	 q{uri-regress: unexpected character "z" at position 17 in URI (expected ":" or "/"): "postgres://[::1]z"},
+    ],
+	[q{postgresql://host?zzz},
+     q{},
+	 q{uri-regress: missing key/value separator "=" in URI query parameter: "zzz"},
+    ],
+	[q{postgresql://host?value1&value2},
+     q{},
+	 q{uri-regress: missing key/value separator "=" in URI query parameter: "value1"},
+    ],
+	[q{postgresql://host?key=key=value},
+     q{},
+	 q{uri-regress: extra key/value separator "=" in URI query parameter: "key"},
+    ],
+	[q{postgres://host?dbname=%XXfoo},
+     q{},
+	 q{uri-regress: invalid percent-encoded token: "%XXfoo"},
+    ],
+	[q{postgresql://a%00b},
+     q{},
+	 q{uri-regress: forbidden value %00 in percent-encoded value: "a%00b"},
+    ],
+	[q{postgresql://%zz},
+     q{},
+	 q{uri-regress: invalid percent-encoded token: "%zz"},
+    ],
+	[q{postgresql://%1},
+     q{},
+	 q{uri-regress: invalid percent-encoded token: "%1"},
+    ],
+	[q{postgresql://%},
+     q{},
+	 q{uri-regress: invalid percent-encoded token: "%"},
+    ],
+	[q{postgres://@host},
+	 q{host='host' (inet)},
+     q{},
+    ],
+	[q{postgres://host:/},
+	 q{host='host' (inet)},
+     q{},
+    ],
+	[q{postgres://:12345/},
+	 q{port='12345' (local)},
+     q{},
+    ],
+	[q{postgres://otheruser@?host=/no/such/directory},
+	 q{user='otheruser' host='/no/such/directory' (local)},
+     q{},
+    ],
+	[q{postgres://otheruser@/?host=/no/such/directory},
+	 q{user='otheruser' host='/no/such/directory' (local)},
+     q{},
+    ],
+	[q{postgres://otheruser@:12345?host=/no/such/socket/path},
+	 q{user='otheruser' host='/no/such/socket/path' port='12345' (local)},
+     q{},
+    ],
+	[q{postgres://otheruser@:12345/db?host=/path/to/socket},
+	 q{user='otheruser' dbname='db' host='/path/to/socket' port='12345' (local)},
+     q{},
+    ],
+	[q{postgres://:12345/db?host=/path/to/socket},
+	 q{dbname='db' host='/path/to/socket' port='12345' (local)},
+     q{},
+    ],
+	[q{postgres://:12345?host=/path/to/socket},
+	 q{host='/path/to/socket' port='12345' (local)},
+     q{},
+    ],
+	[q{postgres://%2Fvar%2Flib%2Fpostgresql/dbname},
+	 q{dbname='dbname' host='/var/lib/postgresql' (local)},
+	 q{},
+	]
+  );
+
+sub test_uri
+{
+	local $Test::Builder::Level = $Test::Builder::Level + 1;
+	my ($uri, $expect_stdout, $expect_stderr) = @$_;
+
+	my $stdout;
+	my $stderr;
+	my $result;
+
+	$result = IPC::Run::run ['uri-regress', $uri], '>', \$stdout, '2>', \$stderr;
+	chomp($stdout);
+	chomp($stderr);
+	is_deeply([$result, $stdout, $stderr],
+			  [$expect_stderr eq '', $expect_stdout, $expect_stderr],
+			  $uri);
+}
+
+foreach (@tests)
+{
+	my $in  =$_;
+	my $uri = @$in[0];
+
+	test_uri $in;
+	#subtest $uri => \&test_uri, $in;
+}
+
+done_testing();
-- 
2.34.0



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: convert libpq uri-regress tests to tap test
@ 2022-02-23 20:40  Daniel Gustafsson <[email protected]>
  parent: Andres Freund <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Daniel Gustafsson @ 2022-02-23 20:40 UTC (permalink / raw)
  To: Andres Freund <[email protected]>; +Cc: pgsql-hackers

> On 23 Feb 2022, at 21:30, Andres Freund <[email protected]> wrote:

> When verifying that the meson port actually runs all perl based tests I came
> across src/interfaces/libpq/test/regress.pl.  Instead of running tests yet
> another way, it seems better to convert it to a tap test.
> 
> I hope others agree?

Many +1's on that.

> The tap test needs a bit more polish, mostly posted this to get some feedback
> before wasting more time :)

Skimming the new test it seems structurally fine to me.

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







^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-02-23 20:40 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05 04:34 [PATCH v4 1/3] Move TAP log-searching feature to common modules Kyotaro Horiguchi <[email protected]>
2022-02-23 20:30 convert libpq uri-regress tests to tap test Andres Freund <[email protected]>
2022-02-23 20:40 ` Re: convert libpq uri-regress tests to tap test Daniel Gustafsson <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox