Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Commits
cf1b6740
Commit
cf1b6740
authored
3 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
L2SS-340
: Remove queue parameter from TCPReplicator
parent
45b2f370
No related branches found
No related tags found
1 merge request
!117
create TCPReplicator for StatisticsClient
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
devices/test/clients/test_tcp_replicator.py
+11
-15
11 additions, 15 deletions
devices/test/clients/test_tcp_replicator.py
with
11 additions
and
15 deletions
devices/test/clients/test_tcp_replicator.py
+
11
−
15
View file @
cf1b6740
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment