Commit 4d7b5cf9 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[test][worker] Get random port rather than using a fixed number

This will allow to run several tests in parallel.
parent b0b6f040
Pipeline #20716 passed with stages
in 57 minutes and 28 seconds
...@@ -46,15 +46,16 @@ from time import sleep ...@@ -46,15 +46,16 @@ from time import sleep
from ..scripts import worker from ..scripts import worker
from ..worker import WorkerController from ..worker import WorkerController
from ..database import Database from ..database import Database
from ..utils import find_free_port
from . import prefix, tmp_prefix from . import prefix, tmp_prefix
#---------------------------------------------------------- #----------------------------------------------------------
WORKER1 = b'worker1' WORKER1 = b'worker1'
WORKER2 = b'worker2' WORKER2 = b'worker2'
PORT = find_free_port()
#---------------------------------------------------------- #----------------------------------------------------------
...@@ -151,7 +152,7 @@ class ControllerProcess(multiprocessing.Process): ...@@ -151,7 +152,7 @@ class ControllerProcess(multiprocessing.Process):
self.controller = WorkerController( self.controller = WorkerController(
'127.0.0.1', '127.0.0.1',
port=50999, port=PORT,
callbacks=dict( callbacks=dict(
onWorkerReady = onWorkerReady, onWorkerReady = onWorkerReady,
onWorkerGone = onWorkerGone, onWorkerGone = onWorkerGone,
...@@ -347,10 +348,10 @@ class TestConnection(TestWorkerBase): ...@@ -347,10 +348,10 @@ class TestConnection(TestWorkerBase):
def test_scheduler_last(self): def test_scheduler_last(self):
self.start_worker(WORKER1, address='tcp://127.0.0.1:50999') self.start_worker(WORKER1, address='tcp://127.0.0.1:%i' % PORT)
sleep(1) sleep(1)
self.start_controller(port=50999) self.start_controller(port=PORT)
self.wait_for_worker_connection(WORKER1) self.wait_for_worker_connection(WORKER1)
...@@ -362,7 +363,7 @@ class TestConnection(TestWorkerBase): ...@@ -362,7 +363,7 @@ class TestConnection(TestWorkerBase):
message = controller.queue.get() message = controller.queue.get()
self.assertEqual(message, 'STARTED') self.assertEqual(message, 'STARTED')
self.start_worker(WORKER1, 'tcp://127.0.0.1:50999') self.start_worker(WORKER1, 'tcp://127.0.0.1:%i' % PORT)
message = controller.queue.get() message = controller.queue.get()
self.assertEqual(message, 'READY ' + WORKER1.decode()) self.assertEqual(message, 'READY ' + WORKER1.decode())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment