qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Conway <acon...@redhat.com>
Subject Re: Allocating ports in tests
Date Wed, 01 Aug 2012 19:04:17 GMT
On Tue, 2012-07-31 at 13:12 -0400, Justin Ross wrote:
> I recommend "reserving" a port, chosen at random, in the dynamic port 
> range:
> 
>    * 0 - 1023 Well Known Ports
>    * 1024 - 49151 Registered Ports
>    * 49152 - 65535 Dynamic and/or Private Ports
>    (from http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html)
> 
How do you avoid clashing with non-qpid processes using the dynamic
range?

> Then, make it persistent: store the port with an appropriate key under 
> /var/tmp (or your os equivalent), and look for it again at the start of 
> subsequent test runs.

How do you protect that file from concurrent access? 

> I tend to think using --port 0 is less good than having the port selection 
> logic *outside* the daemon.  That way you don't have to do any hard work 
> to discover what the daemon actually chose.

If that is the only factor to choose between two approaches then I
absolutely agree. For the majority of our tests however (those that
don't attempt to restart a broker on the same port) I don't see an
out-of-broker solution that is nearly as simple or reliable as bind(0). 

For the tests that do restart brokers on the same port the clashes are
pretty rare. I've only seen them in overnight test where 1000s of broker
restarts give 1 or 2 clashes. Still not 0 though :(

> 
> Justin
> 
> On Tue, 31 Jul 2012, Alan Conway wrote:
> 
> > I'm looking for ideas about how to allocate ports for tests.
> >
> > Our test suite generally runs brokers with --port 0 in order to pick an
> > available port. That works well in most cases.
> >
> > The problem case I have is the new HA code. Brokers and clients of a
> > cluster expect the cluster to have fixed addresses & ports. If I kill
> > and restart a broker during a test it needs to come up on the same port.
> >
> > Currently the HA tests use --port 0 and hope for the best, which works
> > almost all the time. It does however give some spurious test failures,
> > because some other process grabs the port in the time between stopping
> > qpidd and restarting it.
> >
> > Does anyone know a good, simple scheme to allocate ports like this? It
> > needs to allow multiple test runs on the same host without collisions.
> >
> > Cheers,
> > Alan.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
> > For additional commands, e-mail: dev-help@qpid.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
> For additional commands, e-mail: dev-help@qpid.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


Mime
View raw message