Skip to content

Commit 6b25b8d

Browse files
committed
%postgresql_tests*: macros use random server port
* share/postgresql-setup/postgresql_pkg_tests.sh.in (try_random_port): New function which tries to portably generate random port between 32000 and 32000 + 32767, as a fallback - port 54321 port is returned.
1 parent 14e8e42 commit 6b25b8d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

NEWS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22

3+
New in 8.2 version:
4+
5+
* %postgresql_tests_* macros now use random port for the test PostgreSQL
6+
server. This helps in Koji build system where multiple builds of the
7+
same package can happen concurrently on one host and using the same
8+
port would make random build failures.
9+
10+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11+
312
New in 8.1 version:
413

514
* Split testing RPM macros into two files; one is related to build-time

share/postgresql-setup/postgresql_pkg_tests.sh.in

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,23 @@
44

55
# This file is to be sourced.
66

7+
try_random_port ()
8+
{
9+
_port=$RANDOM
10+
if test -n "$_port" && eval '_port=$(( $_port + 32000 ))' 2>/dev/null; then
11+
echo "$_port"
12+
elif test -x /usr/bin/shuf; then
13+
/usr/bin/shuf -r -n 1 -i 32000-64767
14+
else
15+
echo 54321
16+
fi
17+
}
18+
719
: ${PGTESTS_DATADIR=`pwd`/datadir}
820
: ${PGTESTS_ADMIN=`id -u -n`}
921
: ${PGTESTS_ADMINDB=$PGTESTS_ADMIN}
1022
: ${PGTESTS_ADMINPASS=$PGTESTS_ADMIN}
11-
: ${PGTESTS_PORT=54321}
23+
: ${PGTESTS_PORT=`try_random_port`}
1224
: ${PGTESTS_SOCKETDIR=/tmp}
1325
: ${PGTESTS_USERS=test:test}
1426
: ${PGTESTS_DATABASES=test:test}

0 commit comments

Comments
 (0)