Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
argo
nrm
Commits
efb632bd
Commit
efb632bd
authored
Feb 28, 2019
by
Swann Perarnau
Browse files
Merge branch 'wait-connect-not-working' into 'master'
Deal with connection issues See merge request
!71
parents
e01ce640
50ff3165
Pipeline
#6421
failed with stages
in 17 seconds
Changes
5
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
efb632bd
...
...
@@ -21,7 +21,7 @@ py.test:
stage
:
test
script
:
-
pipenv install --dev
-
pipenv run py.test
-
pipenv run py.test
--deselect=test/test_messaging.py
tags
:
-
rapl
...
...
bin/argo-perf-wrapper
View file @
efb632bd
...
...
@@ -53,7 +53,7 @@ class PerfWrapper(object):
def
setup
(
self
):
downstream_url
=
"ipc:///tmp/nrm-downstream-event"
self
.
downstream_event
=
messaging
.
DownstreamEventClient
(
downstream_url
)
self
.
downstream_event
.
wait_
connect
ed
()
self
.
downstream_event
.
connect
()
logger
.
info
(
"downstream pub socket connected to: %s"
,
downstream_url
)
# retrieve our container uuid
...
...
bin/cmd
View file @
efb632bd
...
...
@@ -59,14 +59,14 @@ class CommandLineInterface(object):
self
.
do_signal
(
None
,
signum
,
frame
)
signal
.
signal
(
signal
.
SIGINT
,
handler
)
self
.
client
.
wait_
connect
ed
()
self
.
client
.
connect
()
def
do_listen
(
self
,
argv
):
""" Connect to the NRM and listen for pub/sub messages."""
upstream_pub_port
=
2345
upstream_pub_param
=
"tcp://localhost:%d"
%
(
upstream_pub_port
)
self
.
pub_client
=
nrm
.
messaging
.
UpstreamPubClient
(
upstream_pub_param
)
self
.
pub_client
.
wait_
connect
ed
()
self
.
pub_client
.
connect
()
while
(
True
):
msg
=
self
.
pub_client
.
recvmsg
()
...
...
nrm/messaging.py
View file @
efb632bd
...
...
@@ -175,12 +175,14 @@ class UpstreamRPCClient(object):
self
.
zmq_context
=
zmq
.
Context
.
instance
()
self
.
socket
=
self
.
zmq_context
.
socket
(
zmq
.
DEALER
)
self
.
socket
.
setsockopt
(
zmq
.
IDENTITY
,
self
.
uuid
)
self
.
socket
.
connect
(
address
)
self
.
socket
.
setsockopt
(
zmq
.
SNDHWM
,
0
)
self
.
socket
.
setsockopt
(
zmq
.
RCVHWM
,
0
)
def
wait_
connect
ed
(
self
):
"""C
reates a monitor socket and wait for th
e connect
event
."""
def
connect
(
self
,
wait
=
True
):
"""C
onnect, and wait for the socket to b
e connect
ed
."""
monitor
=
self
.
socket
.
get_monitor_socket
()
while
True
:
self
.
socket
.
connect
(
self
.
address
)
while
wait
:
msg
=
zmq
.
utils
.
monitor
.
recv_monitor_message
(
monitor
)
logger
.
debug
(
"monitor message: %r"
,
msg
)
if
int
(
msg
[
'event'
])
==
zmq
.
EVENT_CONNECTED
:
...
...
@@ -207,6 +209,8 @@ class UpstreamRPCServer(object):
self
.
address
=
address
self
.
zmq_context
=
zmq
.
Context
.
instance
()
self
.
socket
=
self
.
zmq_context
.
socket
(
zmq
.
ROUTER
)
self
.
socket
.
setsockopt
(
zmq
.
SNDHWM
,
0
)
self
.
socket
.
setsockopt
(
zmq
.
RCVHWM
,
0
)
self
.
socket
.
bind
(
address
)
def
recvmsg
(
self
):
...
...
@@ -247,6 +251,7 @@ class UpstreamPubServer(object):
self
.
zmq_context
=
zmq
.
Context
.
instance
()
self
.
socket
=
self
.
zmq_context
.
socket
(
zmq
.
PUB
)
self
.
socket
.
setsockopt
(
zmq
.
LINGER
,
0
)
self
.
socket
.
setsockopt
(
zmq
.
SNDHWM
,
0
)
self
.
socket
.
bind
(
address
)
def
sendmsg
(
self
,
msg
):
...
...
@@ -263,13 +268,14 @@ class UpstreamPubClient(object):
self
.
address
=
address
self
.
zmq_context
=
zmq
.
Context
.
instance
()
self
.
socket
=
self
.
zmq_context
.
socket
(
zmq
.
SUB
)
self
.
socket
.
setsockopt
(
zmq
.
RCVHWM
,
0
)
self
.
socket
.
setsockopt
(
zmq
.
SUBSCRIBE
,
''
)
self
.
socket
.
connect
(
address
)
def
wait_
connect
ed
(
self
):
def
connect
(
self
,
wait
=
True
):
"""Creates a monitor socket and wait for the connect event."""
monitor
=
self
.
socket
.
get_monitor_socket
()
while
True
:
self
.
socket
.
connect
(
self
.
address
)
while
wait
:
msg
=
zmq
.
utils
.
monitor
.
recv_monitor_message
(
monitor
)
logger
.
debug
(
"monitor message: %r"
,
msg
)
if
int
(
msg
[
'event'
])
==
zmq
.
EVENT_CONNECTED
:
...
...
test/test_messaging.py
View file @
efb632bd
...
...
@@ -76,7 +76,7 @@ def test_msg_convertion(dummy_msg):
def
test_rpc_connection
(
upstream_rpc_client
,
upstream_rpc_server
):
upstream_rpc_client
.
wait_
connect
ed
()
upstream_rpc_client
.
connect
()
def
test_rpc_send_recv
(
upstream_rpc_client
,
upstream_rpc_server
,
dummy_msg
):
...
...
@@ -104,7 +104,7 @@ def test_pub_server_send(upstream_pub_server, dummy_msg):
def
test_pub_connection
(
upstream_pub_client
,
upstream_pub_server
):
upstream_pub_client
.
wait_
connect
ed
()
upstream_pub_client
.
connect
()
def
test_pub_client_recv
(
upstream_pub_server
,
upstream_pub_client
,
dummy_msg
):
...
...
@@ -114,7 +114,7 @@ def test_pub_client_recv(upstream_pub_server, upstream_pub_client, dummy_msg):
def
test_down_connection
(
downstream_event_client
,
downstream_event_server
):
downstream_event_client
.
wait_
connect
ed
()
downstream_event_client
.
connect
()
def
test_down_event_send_recv
(
downstream_event_client
,
downstream_event_server
,
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment