Skip to content

Random port #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

New in 8.2 version:

* %postgresql_tests_* macros now use random port for the test PostgreSQL
server. This helps in Koji build system where multiple builds of the
same package can happen concurrently on one host and using the same
port would make random build failures.

* If the testing server fails, the %postgresql_tests_* macros print the
error log out for easier debugging.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

New in 8.1 version:

* Split testing RPM macros into two files; one is related to build-time
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use the MAJ.MIN[~SUFF]. Note that X.X > X.X~SUFF!
AC_INIT([postgresql-setup], [8.1], [[email protected]])
AC_INIT([postgresql-setup], [8.2], [[email protected]])
AC_CONFIG_AUX_DIR(auxdir)
config_aux_dir=auxdir
AC_SUBST([config_aux_dir])
Expand Down
26 changes: 22 additions & 4 deletions share/postgresql-setup/postgresql_pkg_tests.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@

# This file is to be sourced.

try_random_port ()
{
_port=$RANDOM
if test -n "$_port" && eval '_port=$(( $_port + 32000 ))' 2>/dev/null; then
echo "$_port"
elif test -x /usr/bin/shuf; then
/usr/bin/shuf -r -n 1 -i 32000-64767
else
echo 54321
fi
}

: ${PGTESTS_DATADIR=`pwd`/datadir}
: ${PGTESTS_ADMIN=`id -u -n`}
: ${PGTESTS_ADMINDB=$PGTESTS_ADMIN}
: ${PGTESTS_ADMINPASS=$PGTESTS_ADMIN}
: ${PGTESTS_PORT=54321}
: ${PGTESTS_PORT=`try_random_port`}
: ${PGTESTS_SOCKETDIR=/tmp}
: ${PGTESTS_USERS=test:test}
: ${PGTESTS_DATABASES=test:test}
Expand Down Expand Up @@ -54,7 +66,11 @@ __pgtests_initdb ()

__pgtests_start ()
{
pg_ctl -D "$PGTESTS_DATADIR" -l "$PGTESTS_DATADIR"/start.log start -o "-k $PGTESTS_SOCKETDIR -p $PGTESTS_PORT" -w
pg_ctl -D "$PGTESTS_DATADIR" -l "$PGTESTS_DATADIR"/start.log start \
-o "-k $PGTESTS_SOCKETDIR -p $PGTESTS_PORT" -w || {
cat >&2 "$PGTESTS_DATADIR"/start.log
false
}
}


Expand Down Expand Up @@ -91,8 +107,10 @@ pgtests_start ()
fi
fi

__pgtests_initdb && __TRAP_ACTIONS="pgtests_cleanup $__TRAP_ACTIONS"
__pgtests_start && __TRAP_ACTIONS="pgtests_stop $__TRAP_ACTIONS"
__pgtests_initdb
__TRAP_ACTIONS="pgtests_cleanup $__TRAP_ACTIONS"
__pgtests_start
__TRAP_ACTIONS="pgtests_stop $__TRAP_ACTIONS"
__pgtests_create_admins_db

__pgtests_passwd "$PGTESTS_ADMIN" "$PGTESTS_ADMINPASS"
Expand Down