You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Andreas Stieger <an...@gmx.de> on 2015/06/09 19:10:19 UTC

[patch] Support modern network utilities for finding free ports for tests

Hello,

GNU/Linux distributions are deprecating some legacy IP tools [1], moving
them to a -deprecated package: in this case netstat. Please review the
attached patch adding compatible support for it's functional successor
ss(8).

[[[
Support modern network utilities for finding free ports for tests

* subversion/tests/cmdline/davautocheck.sh:
  Check for presence of ss, netstat and fail if neither is found.
  Prefer ss to find a free port, fall back to netstat.
* subversion/tests/cmdline/svnserveautocheck.sh:
  Same, and augment $PATH to include /usr/{,local/}sbin.

]]]


[1] https://build.opensuse.org/request/show/308848

With kind regards,
Andreas Stieger

Re: [patch] Support modern network utilities for finding free ports for tests

Posted by Philip Martin <ph...@wandisco.com>.
Philip Martin <ph...@wandisco.com> writes:

>>> >  HTTPD_PORT=3691
>>> > -while netstat -an | grep $HTTPD_PORT | grep 'LISTEN' >/dev/null; do
>>> > +while \
>>> > +  (ss -ltn sport = :$HTTP_PORT 2>&1 | grep :$HTTP_PORT > /dev/null ) \
>>> > +  || \
>>> > +  (netstat -an 2>&1 | grep $HTTP_PORT | grep 'LISTEN' > /dev/null ) \
>>> > +  do
>
> Looking at it again I'm more worried about the handling of the exit
> statuses in the pipelines.  Different shells have different behaviours.

I think it is probably OK in that regard.  The ambiguity is what should
be returned when multiple commands in a pipeline return non-zero, but
the code is only looking to distinguish two cases: all commands in a
pipeline return zero, one or more commands return non-zero.

-- 
Philip Martin | Subversion Committer
WANdisco // *Non-Stop Data*

Re: [patch] Support modern network utilities for finding free ports for tests

Posted by Philip Martin <ph...@wandisco.com>.
"Bert Huijben" <be...@qqmail.nl> writes:

>> -----Original Message-----
>> From: Philip Martin [mailto:philip.martin@wandisco.com]
>> Sent: woensdag 10 juni 2015 14:05
>> To: Andreas Stieger
>> Cc: dev@subversion.apache.org
>> Subject: Re: [patch] Support modern network utilities for finding free
> ports for
>> tests
>> 
>> Andreas Stieger <an...@gmx.de> writes:
>> 
>> >  HTTPD_PORT=3691
>> > -while netstat -an | grep $HTTPD_PORT | grep 'LISTEN' >/dev/null; do
>> > +while \
>> > +  (ss -ltn sport = :$HTTP_PORT 2>&1 | grep :$HTTP_PORT > /dev/null ) \
>> > +  || \
>> > +  (netstat -an 2>&1 | grep $HTTP_PORT | grep 'LISTEN' > /dev/null ) \
>> > +  do
>> 
>> You have HTTP_PORT where it should be HTTPD_PORT.  I fixed that and
>> committed r1684649.  Thanks!
>
> Shouldn't the default be the other way around?... Stick to using netstat
> unless it doesn't exist?

I don't think it makes a lot of difference in this case: it tries to run
one and if that doesn't work it runs the other.  I don't see that it
matters which one we prefer unless efficiency of starting processes is a
concern.

Looking at it again I'm more worried about the handling of the exit
statuses in the pipelines.  Different shells have different behaviours.

-- 
Philip Martin | Subversion Committer
WANdisco // *Non-Stop Data*

RE: [patch] Support modern network utilities for finding free ports for tests

Posted by Bert Huijben <be...@qqmail.nl>.

> -----Original Message-----
> From: Philip Martin [mailto:philip.martin@wandisco.com]
> Sent: woensdag 10 juni 2015 14:05
> To: Andreas Stieger
> Cc: dev@subversion.apache.org
> Subject: Re: [patch] Support modern network utilities for finding free
ports for
> tests
> 
> Andreas Stieger <an...@gmx.de> writes:
> 
> >  HTTPD_PORT=3691
> > -while netstat -an | grep $HTTPD_PORT | grep 'LISTEN' >/dev/null; do
> > +while \
> > +  (ss -ltn sport = :$HTTP_PORT 2>&1 | grep :$HTTP_PORT > /dev/null ) \
> > +  || \
> > +  (netstat -an 2>&1 | grep $HTTP_PORT | grep 'LISTEN' > /dev/null ) \
> > +  do
> 
> You have HTTP_PORT where it should be HTTPD_PORT.  I fixed that and
> committed r1684649.  Thanks!

Shouldn't the default be the other way around?... Stick to using netstat
unless it doesn't exist?

I don't think 'ss' is nearly available as widely as netstat. It might even
be Linux specific. Netstat is available on FreeBSD and even on Windows,
while 'ss' is available on neither.

	Bert


Re: [patch] Support modern network utilities for finding free ports for tests

Posted by Philip Martin <ph...@wandisco.com>.
Andreas Stieger <an...@gmx.de> writes:

>  HTTPD_PORT=3691
> -while netstat -an | grep $HTTPD_PORT | grep 'LISTEN' >/dev/null; do
> +while \
> +  (ss -ltn sport = :$HTTP_PORT 2>&1 | grep :$HTTP_PORT > /dev/null ) \
> +  || \
> +  (netstat -an 2>&1 | grep $HTTP_PORT | grep 'LISTEN' > /dev/null ) \
> +  do

You have HTTP_PORT where it should be HTTPD_PORT.  I fixed that and
committed r1684649.  Thanks!

-- 
Philip Martin | Subversion Committer
WANdisco // *Non-Stop Data*