Skip to content

Commit

Permalink
Merge pull request #1589 from wallner/fix_doctests
Browse files Browse the repository at this point in the history
Let doctests use an IPv4 address
  • Loading branch information
mfelsche committed Jan 28, 2015
2 parents c7029c5 + 49eb3bc commit d76b41d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions docs/src/crate/ports.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import socket

def public_ip():
def public_ipv4():
"""
take first public interface
sorted by getaddrinfo - see RFC 3484
should have the real public ip as first
should have the real public IPv4 address as first address.
At the moment the test layer is not able to handle v6 addresses
"""
for addrinfo in socket.getaddrinfo(socket.gethostname(), None):
if addrinfo[1] in (socket.SOCK_STREAM, socket.SOCK_DGRAM):
if addrinfo[1] in (socket.SOCK_STREAM, socket.SOCK_DGRAM) and addrinfo[0] == socket.AF_INET:
return addrinfo[4][0]


Expand Down
4 changes: 2 additions & 2 deletions docs/src/crate/process_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from crate.testing.layer import CrateLayer
from crate.client.http import Client
from .paths import crate_path
from .ports import public_ip, random_available_port
from .ports import public_ipv4, random_available_port
from lovely.testlayers.layer import CascadedLayer


Expand Down Expand Up @@ -37,7 +37,7 @@ def __init__(self, *args, **kwargs):
for i in range(num_servers):
layer = GracefulStopCrateLayer(self.node_name(i),
crate_path(),
host=public_ip(),
host=public_ipv4(),
port=random_available_port(),
transport_port=random_available_port(),
multicast=True,
Expand Down

0 comments on commit d76b41d

Please sign in to comment.