Mercurial > hgsubversion
comparison tests/test_push_command.py @ 1507:debba0fa822e
test_push_command: bias towards IPv4 to work around gremlins on macOS
| author | Augie Fackler <raf@durin42.com> |
|---|---|
| date | Mon, 29 May 2017 12:50:15 -0400 |
| parents | 6e3f48d8002f |
| children | 5441a9d1fd50 |
comparison
equal
deleted
inserted
replaced
| 1506:332e803044e5 | 1507:debba0fa822e |
|---|---|
| 144 # function, which always returns an IPv4 address, even on hosts that | 144 # function, which always returns an IPv4 address, even on hosts that |
| 145 # support and expect IPv6. As a workaround, resolve the hostname | 145 # support and expect IPv6. As a workaround, resolve the hostname |
| 146 # within the test harness with `getaddrinfo(3)` to ensure that the | 146 # within the test harness with `getaddrinfo(3)` to ensure that the |
| 147 # client and server both use the same IPv4 or IPv6 address. | 147 # client and server both use the same IPv4 or IPv6 address. |
| 148 addrinfo = socket.getaddrinfo(self.host, self.port) | 148 addrinfo = socket.getaddrinfo(self.host, self.port) |
| 149 self.host = addrinfo[0][4][0] | 149 # On macOS svn seems to have issues with IPv6 at least some of |
| 150 # the time, so try and bias towards IPv4. This works because | |
| 151 # AF_INET is less than AF_INET6 on all platforms I've | |
| 152 # checked. Hopefully any platform where that's not true will | |
| 153 # be fine with IPv6 all the time. :) | |
| 154 selected = sorted(addrinfo)[0] | |
| 155 self.host = selected[4][0] | |
| 150 | 156 |
| 151 # If we're connecting via IPv6 the need to put brackets around the | 157 # If we're connecting via IPv6 the need to put brackets around the |
| 152 # hostname in the URL. | 158 # hostname in the URL. |
| 153 ipv6 = addrinfo[0][0] == socket.AF_INET6 | 159 ipv6 = selected[0] == socket.AF_INET6 |
| 154 urlfmt = 'svn://[%s]:%d/%s' if ipv6 else 'svn://%s:%d/%s' | 160 urlfmt = 'svn://[%s]:%d/%s' if ipv6 else 'svn://%s:%d/%s' |
| 155 | 161 |
| 156 args = ['svnserve', '--daemon', '--foreground', | 162 args = ['svnserve', '--daemon', '--foreground', |
| 157 '--listen-port=%d' % self.port, | 163 '--listen-port=%d' % self.port, |
| 158 '--listen-host=%s' % self.host, | 164 '--listen-host=%s' % self.host, |
