Update tests to use AF_INET6
zuul_console now properly uses AF_INET6, but some of our tests were still using AF_INET. There are some sporadic failures with the streaming test that show some connection errors. It's possible AF_INET6 is a red herring, but it's also not incorrect to set it, so let's go ahead and update it. While we're at it - use the create_connection form like we do in zuul_stream rather than the s = socket.socket ; s.connect form. Change-Id: I278efb939cb6540b5fe2fb1a06495d9be5a7f997
This commit is contained in:
parent
b286f16dd0
commit
211883d09a
|
@ -1195,7 +1195,7 @@ class FakeStatsd(threading.Thread):
|
|||
def __init__(self):
|
||||
threading.Thread.__init__(self)
|
||||
self.daemon = True
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
self.sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
|
||||
self.sock.bind(('', 0))
|
||||
self.port = self.sock.getsockname()[1]
|
||||
self.wake_read, self.wake_write = os.pipe()
|
||||
|
|
|
@ -22,6 +22,7 @@ import os
|
|||
import os.path
|
||||
import socket
|
||||
import tempfile
|
||||
import testtools
|
||||
import threading
|
||||
import time
|
||||
|
||||
|
@ -46,16 +47,13 @@ class TestLogStreamer(tests.base.BaseTestCase):
|
|||
streamer = self.startStreamer(port)
|
||||
self.addCleanup(streamer.stop)
|
||||
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.addCleanup(s.close)
|
||||
self.assertEqual(0, s.connect_ex((self.host, port)))
|
||||
s = socket.create_connection((self.host, port))
|
||||
s.close()
|
||||
|
||||
streamer.stop()
|
||||
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.addCleanup(s.close)
|
||||
self.assertNotEqual(0, s.connect_ex((self.host, port)))
|
||||
with testtools.ExpectedException(ConnectionRefusedError):
|
||||
s = socket.create_connection((self.host, port))
|
||||
s.close()
|
||||
|
||||
|
||||
|
@ -80,8 +78,7 @@ class TestStreaming(tests.base.AnsibleZuulTestCase):
|
|||
root = tempfile.gettempdir()
|
||||
self.streamer = zuul.lib.log_streamer.LogStreamer(None, self.host,
|
||||
port, root)
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.connect((self.host, port))
|
||||
s = socket.create_connection((self.host, port))
|
||||
self.addCleanup(s.close)
|
||||
|
||||
req = '%s\n' % build_uuid
|
||||
|
@ -237,8 +234,11 @@ class TestStreaming(tests.base.AnsibleZuulTestCase):
|
|||
self.addCleanup(web_server.stop)
|
||||
|
||||
# Wait until web server is started
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
while s.connect_ex((self.host, 9000)):
|
||||
while True:
|
||||
try:
|
||||
with socket.create_connection((self.host, 9000)):
|
||||
break
|
||||
except ConnectionRefusedError:
|
||||
time.sleep(0.1)
|
||||
|
||||
# Start a thread with the websocket client
|
||||
|
|
Loading…
Reference in New Issue