Re: [PATCH 1 of 4] runtests: add a function to test if IPv6 is available
On Wed, Feb 15, 2017 at 06:57:37PM -0800, Jun Wu wrote: > Excerpts from Augie Fackler's message of 2017-02-15 21:32:38 -0500: > > On Wed, Feb 15, 2017 at 06:26:11PM -0800, Jun Wu wrote: > > > Excerpts from Augie Fackler's message of 2017-02-15 21:23:37 -0500: > > > > I'm not overjoyed at the static default. Is there a reason to use the > > > > static default instead of checking HGPORT, so that multiple users on a > > > > single box (such as the big compile farm machine several of us favor) > > > > can run the tests without risk of stomping each other? > > > > > > That's just a random default which must > 1024. If multiple users run this > > > in parallel - it'd be fine - one of them will get the error EADDRINUSE, > > > and > > > that's considered "IPv6 is available". > > > > Oh, I misunderstood. This function is *only* for checking that IPv6 is > > available, not also for checking if a specific port is available with > > IPv6. Is that (revised) understanding correct on my part? > > Correct. run-tests.py will first decide whether to use IPv6 or not globally > by calling this function. If IPv6 is available, then all port checks will > be IPv6-only. Otherwise, they will be IPv4-only. Okay, sure. Queued. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 1 of 4] runtests: add a function to test if IPv6 is available
Excerpts from Augie Fackler's message of 2017-02-15 21:32:38 -0500: > On Wed, Feb 15, 2017 at 06:26:11PM -0800, Jun Wu wrote: > > Excerpts from Augie Fackler's message of 2017-02-15 21:23:37 -0500: > > > I'm not overjoyed at the static default. Is there a reason to use the > > > static default instead of checking HGPORT, so that multiple users on a > > > single box (such as the big compile farm machine several of us favor) > > > can run the tests without risk of stomping each other? > > > > That's just a random default which must > 1024. If multiple users run this > > in parallel - it'd be fine - one of them will get the error EADDRINUSE, and > > that's considered "IPv6 is available". > > Oh, I misunderstood. This function is *only* for checking that IPv6 is > available, not also for checking if a specific port is available with > IPv6. Is that (revised) understanding correct on my part? Correct. run-tests.py will first decide whether to use IPv6 or not globally by calling this function. If IPv6 is available, then all port checks will be IPv6-only. Otherwise, they will be IPv4-only. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 1 of 4] runtests: add a function to test if IPv6 is available
On Wed, Feb 15, 2017 at 06:26:11PM -0800, Jun Wu wrote: > Excerpts from Augie Fackler's message of 2017-02-15 21:23:37 -0500: > > I'm not overjoyed at the static default. Is there a reason to use the > > static default instead of checking HGPORT, so that multiple users on a > > single box (such as the big compile farm machine several of us favor) > > can run the tests without risk of stomping each other? > > That's just a random default which must > 1024. If multiple users run this > in parallel - it'd be fine - one of them will get the error EADDRINUSE, and > that's considered "IPv6 is available". Oh, I misunderstood. This function is *only* for checking that IPv6 is available, not also for checking if a specific port is available with IPv6. Is that (revised) understanding correct on my part? ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 1 of 4] runtests: add a function to test if IPv6 is available
Excerpts from Augie Fackler's message of 2017-02-15 21:23:37 -0500: > I'm not overjoyed at the static default. Is there a reason to use the > static default instead of checking HGPORT, so that multiple users on a > single box (such as the big compile farm machine several of us favor) > can run the tests without risk of stomping each other? That's just a random default which must > 1024. If multiple users run this in parallel - it'd be fine - one of them will get the error EADDRINUSE, and that's considered "IPv6 is available". ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 1 of 4] runtests: add a function to test if IPv6 is available
On Wed, Feb 15, 2017 at 04:50:14PM -0800, Jun Wu wrote: > # HG changeset patch > # User Jun Wu> # Date 1487204311 28800 > # Wed Feb 15 16:18:31 2017 -0800 > # Node ID a70fa1e0fcdb11980338d72dde33dfe047bda7c2 > # Parent e5363cb96233861fc99f7e9b85d7884d3121558c > # Available At https://bitbucket.org/quark-zju/hg-draft > # hg pull https://bitbucket.org/quark-zju/hg-draft -r > a70fa1e0fcdb > runtests: add a function to test if IPv6 is available > > Previously, checkportisavailable returns True if the port is free either on > IPv4 or IPv6, but the hg server only uses IPv4 by default. That leads to > issues when IPv4 port is not free but the IPv6 one is. > > To address that, run-tests should stick with either IPv4 or IPv6. This patch > adds a function similar to checkportisavailable to test if IPv6 is > available, and assigns the result to a variable. > > The new function was tested in a Linux system script with the following > steps: > > 1. Run "ip addr del ::1/128 dev lo" to delete lo's IPv6 address, > Confirm checkipv6available() returns False. > 2. Run "ip addr add ::1/128 dev lo" to add back lo's IPv6 address. > Confirm checkipv6available() returns True. > 3. Start a web server taking the 8000 port. > Confirm checkipv6available(8000) is still True. > > diff --git a/tests/run-tests.py b/tests/run-tests.py > --- a/tests/run-tests.py > +++ b/tests/run-tests.py > @@ -113,4 +113,27 @@ else: > wifexited = getattr(os, "WIFEXITED", lambda x: False) > > +# Whether to use IPv6 > +def checkipv6available(port=20058): > +"""return true if we can listen on localhost's IPv6 ports""" > +family = getattr(socket, 'AF_INET6', None) > +if family is None: > +return False > +try: > +s = socket.socket(family, socket.SOCK_STREAM) > +s.bind(('localhost', port)) > +s.close() > +return True > +except socket.error as exc: > +if exc.errno == errno.EADDRINUSE: > +return True > +elif exc.errno in (errno.EADDRNOTAVAIL, errno.EPROTONOSUPPORT): > +return False > +else: > +raise > +else: > +return False > + > +useipv6 = checkipv6available() I'm not overjoyed at the static default. Is there a reason to use the static default instead of checking HGPORT, so that multiple users on a single box (such as the big compile farm machine several of us favor) can run the tests without risk of stomping each other? > + > def checkportisavailable(port): > """return true if a port seems free to bind on localhost""" > ___ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel