Fix streaming test ports
Change ID I032f15eef15a26287d0d912d6ef105cf5beae200 introduced a test using the same port (9000) being used in another test. This is going to cause random test flaps. Use random ports. Change-Id: I209ca0923cfd05038ef9f4bc14523af8cc9f2dd4
This commit is contained in:
parent
03e52eab3b
commit
1eca5e3cb3
|
@ -169,9 +169,9 @@ class TestStreaming(tests.base.AnsibleZuulTestCase):
|
|||
self.log.debug("\n\nStreamed: %s\n\n", self.streaming_data)
|
||||
self.assertEqual(file_contents, self.streaming_data)
|
||||
|
||||
def runWSClient(self, build_uuid, event):
|
||||
def runWSClient(self, port, build_uuid, event):
|
||||
async def client(loop, build_uuid, event):
|
||||
uri = 'http://[::1]:9000/api/tenant/tenant-one/console-stream'
|
||||
uri = 'http://[::1]:%s/api/tenant/tenant-one/console-stream' % port
|
||||
try:
|
||||
session = aiohttp.ClientSession(loop=loop)
|
||||
async with session.ws_connect(uri) as ws:
|
||||
|
@ -280,7 +280,7 @@ class TestStreaming(tests.base.AnsibleZuulTestCase):
|
|||
|
||||
# Start the web server
|
||||
web_server = zuul.web.ZuulWeb(
|
||||
listen_address='::', listen_port=9000,
|
||||
listen_address='::', listen_port=0,
|
||||
gear_server='127.0.0.1', gear_port=self.gearman_server.port,
|
||||
static_path=tempfile.gettempdir())
|
||||
loop = asyncio.new_event_loop()
|
||||
|
@ -293,8 +293,12 @@ class TestStreaming(tests.base.AnsibleZuulTestCase):
|
|||
|
||||
# Wait until web server is started
|
||||
while True:
|
||||
if web_server.server is None:
|
||||
time.sleep(0.1)
|
||||
continue
|
||||
port = web_server.server.sockets[0].getsockname()[1]
|
||||
try:
|
||||
with socket.create_connection((self.host, 9000)):
|
||||
with socket.create_connection((self.host, port)):
|
||||
break
|
||||
except ConnectionRefusedError:
|
||||
time.sleep(0.1)
|
||||
|
@ -303,7 +307,7 @@ class TestStreaming(tests.base.AnsibleZuulTestCase):
|
|||
ws_client_event = threading.Event()
|
||||
self.ws_client_results = ''
|
||||
ws_client_thread = threading.Thread(
|
||||
target=self.runWSClient, args=(build.uuid, ws_client_event)
|
||||
target=self.runWSClient, args=(port, build.uuid, ws_client_event)
|
||||
)
|
||||
ws_client_thread.start()
|
||||
ws_client_event.wait()
|
||||
|
@ -366,7 +370,7 @@ class TestStreaming(tests.base.AnsibleZuulTestCase):
|
|||
|
||||
# Start the web server
|
||||
web_server = zuul.web.ZuulWeb(
|
||||
listen_address='::', listen_port=9000,
|
||||
listen_address='::', listen_port=0,
|
||||
gear_server='127.0.0.1', gear_port=self.gearman_server.port,
|
||||
static_path=tempfile.gettempdir())
|
||||
loop = asyncio.new_event_loop()
|
||||
|
@ -379,8 +383,12 @@ class TestStreaming(tests.base.AnsibleZuulTestCase):
|
|||
|
||||
# Wait until web server is started
|
||||
while True:
|
||||
if web_server.server is None:
|
||||
time.sleep(0.1)
|
||||
continue
|
||||
port = web_server.server.sockets[0].getsockname()[1]
|
||||
try:
|
||||
with socket.create_connection((self.host, 9000)):
|
||||
with socket.create_connection((self.host, port)):
|
||||
break
|
||||
except ConnectionRefusedError:
|
||||
time.sleep(0.1)
|
||||
|
@ -389,7 +397,7 @@ class TestStreaming(tests.base.AnsibleZuulTestCase):
|
|||
ws_client_event = threading.Event()
|
||||
self.ws_client_results = ''
|
||||
ws_client_thread = threading.Thread(
|
||||
target=self.runWSClient, args=(build.uuid, ws_client_event)
|
||||
target=self.runWSClient, args=(port, build.uuid, ws_client_event)
|
||||
)
|
||||
ws_client_thread.start()
|
||||
ws_client_event.wait()
|
||||
|
|
Loading…
Reference in New Issue