Skip to content
Snippets Groups Projects
Commit cf1b6740 authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-340: Remove queue parameter from TCPReplicator

parent 45b2f370
No related branches found
No related tags found
1 merge request!117create TCPReplicator for StatisticsClient
......@@ -31,8 +31,6 @@ class TestTCPReplicator(base.TestCase):
def setUp(self):
super(TestTCPReplicator, self).setUp()
self.m_queue = mock.Mock()
self.m_server = mock.Mock()
self.m_server.wait_closed.return_value = self.dummy_task()
......@@ -71,7 +69,7 @@ class TestTCPReplicator(base.TestCase):
"tcp_bind": '0.0.0.0', # I should get set
}
replicator = self.m_tcp_replicator(self.m_queue, test_options)
replicator = self.m_tcp_replicator(options=test_options)
self.assertTrue(replicator.is_alive())
# Ensure replicator initialization does not modify static variable
......@@ -89,7 +87,7 @@ class TestTCPReplicator(base.TestCase):
m_client = mock.Mock()
# Create both a TCPReplicator and TCPServerProtocol separately
replicator = self.m_tcp_replicator(self.m_queue)
replicator = self.m_tcp_replicator()
self.assertTrue(replicator.is_alive())
protocol = TCPReplicator.TCPServerProtocol(
replicator._options, replicator._connected_clients)
......@@ -103,7 +101,7 @@ class TestTCPReplicator(base.TestCase):
def test_start_stop(self):
"""Verify threading behavior, being able to start and stop the thread"""
replicator = self.m_tcp_replicator(self.m_queue)
replicator = self.m_tcp_replicator()
self.assertTrue(replicator.is_alive())
# Give the thread 5 seconds to stop
......@@ -129,7 +127,7 @@ class TestTCPReplicator(base.TestCase):
run_patcher.new_event_loop.return_value = m_loop
# Constructor should raise an exception if the thread dies early
self.assertRaises(RuntimeError, self.m_tcp_replicator, self.m_queue)
self.assertRaises(RuntimeError, self.m_tcp_replicator)
@timeout_decorator.timeout(5)
def test_start_except_server(self):
......@@ -139,13 +137,13 @@ class TestTCPReplicator(base.TestCase):
RuntimeError("Test Error")
# Constructor should raise an exception if the thread dies early
self.assertRaises(RuntimeError, self.m_tcp_replicator, self.m_queue)
self.assertRaises(RuntimeError, self.m_tcp_replicator)
@timeout_decorator.timeout(5)
def test_start_stop_delete(self):
"""Verify that deleting the TCPReplicator object safely halts thread"""
replicator = self.m_tcp_replicator(self.m_queue)
replicator = self.m_tcp_replicator()
self.assertTrue(replicator.is_alive())
del replicator
......@@ -157,7 +155,7 @@ class TestTCPReplicator(base.TestCase):
m_client = mock.Mock()
replicator = self.m_tcp_replicator(self.m_queue)
replicator = self.m_tcp_replicator()
self.assertTrue(replicator.is_alive())
replicator._connected_clients.append(m_client)
......@@ -176,7 +174,7 @@ class TestTCPReplicator(base.TestCase):
m_client.transport.write.assert_called_once_with(m_data)
def test_queue_start(self):
replicator = self.m_tcp_replicator(self.m_queue)
replicator = self.m_tcp_replicator()
self.m_process_queue.assert_called_once_with(replicator)
......@@ -185,9 +183,7 @@ class TestTCPReplicator(base.TestCase):
m_client = mock.Mock()
t_queue = Queue()
replicator = self.m_tcp_replicator(t_queue)
replicator = self.m_tcp_replicator()
self.assertTrue(replicator.is_alive())
# Patch _process_queue back into object and jump start it
......@@ -197,7 +193,7 @@ class TestTCPReplicator(base.TestCase):
replicator._connected_clients.append(m_client)
t_queue.put(m_data)
replicator.put(m_data)
# TODO(Corne): Find suitable primitive to synchronize async task update
# with main thread.
......@@ -213,7 +209,7 @@ class TestTCPReplicator(base.TestCase):
def test_disconnect(self,):
m_client = mock.Mock()
replicator = self.m_tcp_replicator(self.m_queue)
replicator = self.m_tcp_replicator()
self.assertTrue(replicator.is_alive())
replicator._connected_clients.append(m_client)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment