Обсуждение: small regression script improvement

Поиск
Список
Период
Сортировка

small regression script improvement

От
Andrew Dunstan
Дата:
This suggested patch makes sure that the regression script can actually
connect to the database rather than falling through after 60 seconds, as
discussed on -hackers.

cheers

andrew
Index: pg_regress.sh
===================================================================
RCS file: /cvsroot/pgsql/src/test/regress/pg_regress.sh,v
retrieving revision 1.64
diff -c -r1.64 pg_regress.sh
*** pg_regress.sh    5 Jan 2006 03:01:38 -0000    1.64
--- pg_regress.sh    18 Jun 2006 22:19:53 -0000
***************
*** 457,471 ****
          sleep 1
      done

!     if kill -0 $postmaster_pid >/dev/null 2>&1
      then
          echo "running on port $PGPORT with pid $postmaster_pid"
!     else
          echo
          echo "$me: postmaster did not start"
          echo "Examine $LOGDIR/postmaster.log for the reason."
          echo
          (exit 2); exit
      fi

  else # not temp-install
--- 457,482 ----
          sleep 1
      done

!     kill -0 $postmaster_pid >/dev/null 2>&1
!     running=$?
!     if test $running -eq 0 -a $i -lt $max
      then
          echo "running on port $PGPORT with pid $postmaster_pid"
!     elif test $running -neq 0
!     then
!         # postmaster is not running
          echo
          echo "$me: postmaster did not start"
          echo "Examine $LOGDIR/postmaster.log for the reason."
          echo
          (exit 2); exit
+     else
+         # postmaster is running but we can't connect
+         echo
+         echo "$me: postmaster started but did not accept connections after $max seconds"
+         echo
+         kill $postmaster_pid
+         (exit 2); exit
      fi

  else # not temp-install

Re: small regression script improvement

От
Tom Lane
Дата:
Andrew Dunstan <andrew@dunslane.net> writes:
> This suggested patch makes sure that the regression script can actually
> connect to the database rather than falling through after 60 seconds, as
> discussed on -hackers.

Oh, I see what you mean.  But surely that's the hard way.  The script
should just fail where it currently "break"s out of the loop.  It's
not any longer and it permits a more specific error message.

            regards, tom lane

*** src/test/regress/pg_regress.sh.orig    Wed Jan  4 22:01:38 2006
--- src/test/regress/new/pg_regress.sh    Sun Jun 18 18:42:24 2006
***************
*** 446,472 ****
          i=`expr $i + 1`
          if [ $i -ge $max ]
          then
!             break
          fi
          if kill -0 $postmaster_pid >/dev/null 2>&1
          then
              : still starting up
          else
!             break
          fi
          sleep 1
      done

!     if kill -0 $postmaster_pid >/dev/null 2>&1
!     then
!         echo "running on port $PGPORT with pid $postmaster_pid"
!     else
!         echo
!         echo "$me: postmaster did not start"
!         echo "Examine $LOGDIR/postmaster.log for the reason."
!         echo
!         (exit 2); exit
!     fi

  else # not temp-install

--- 446,473 ----
          i=`expr $i + 1`
          if [ $i -ge $max ]
          then
!             : timeout
!             echo
!             echo "$me: postmaster is not accepting connections"
!             echo "Examine $LOGDIR/postmaster.log for the reason."
!             echo
!             (exit 2); exit
          fi
          if kill -0 $postmaster_pid >/dev/null 2>&1
          then
              : still starting up
          else
!             : postmaster failed
!             echo
!             echo "$me: postmaster failed"
!             echo "Examine $LOGDIR/postmaster.log for the reason."
!             echo
!             (exit 2); exit
          fi
          sleep 1
      done

!     echo "running on port $PGPORT with pid $postmaster_pid"

  else # not temp-install


Re: small regression script improvement

От
Andrew Dunstan
Дата:

Tom Lane wrote:

>Andrew Dunstan <andrew@dunslane.net> writes:
>
>
>>This suggested patch makes sure that the regression script can actually
>>connect to the database rather than falling through after 60 seconds, as
>>discussed on -hackers.
>>
>>
>
>Oh, I see what you mean.  But surely that's the hard way.  The script
>should just fail where it currently "break"s out of the loop.  It's
>not any longer and it permits a more specific error message.
>
>
>
>

Good point. I'll do that.

cheers

andrew