Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed hanging testcases on fast Linux machines

  • Loading branch information...
commit 89376d5459a00f1e71ef27bad918408aeeb8fba5 1 parent 335e307
@jeremybarnes jeremybarnes authored
Showing with 35 additions and 9 deletions.
  1. +16 −4 test/test.socket.pub-sub.filter.js
  2. +19 −5 test/test.socket.pub-sub.js
View
20 test/test.socket.pub-sub.filter.js
@@ -26,8 +26,20 @@ sub.on('message', function(msg){
sub.bind('inproc://stuff', function(){
pub.connect('inproc://stuff');
- pub.send('js is cool');
- pub.send('ruby is meh');
- pub.send('py is pretty cool');
- pub.send('luna is cool too');
+
+ // The connect is asynchronous, and messages published to a non-
+ // connected socket are silently dropped. That means that there is
+ // a race between connecting and sending the first message which
+ // causes this test to hang, especially when running on Linux. Even an
+ // inproc:// socket seems to be asynchronous. So instead of
+ // sending straight away, we wait 100ms for the connection to be
+ // established before we start the send. This fixes the observed
+ // hang.
+
+ setTimeout(function() {
+ pub.send('js is cool');
+ pub.send('ruby is meh');
+ pub.send('py is pretty cool');
+ pub.send('luna is cool too');
+ }, 100.0);
});
View
24 test/test.socket.pub-sub.js
@@ -25,9 +25,23 @@ sub.on('message', function(msg){
}
});
-sub.bind('inproc://stuff', function(){
- pub.connect('inproc://stuff');
- pub.send('foo');
- pub.send('bar');
- pub.send('baz');
+var addr = "inproc://stuff";
+
+sub.bind(addr, function(){
+ pub.connect(addr);
+
+ // The connect is asynchronous, and messages published to a non-
+ // connected socket are silently dropped. That means that there is
+ // a race between connecting and sending the first message which
+ // causes this test to hang, especially when running on Linux. Even an
+ // inproc:// socket seems to be asynchronous. So instead of
+ // sending straight away, we wait 100ms for the connection to be
+ // established before we start the send. This fixes the observed
+ // hang.
+
+ setTimeout(function() {
+ pub.send('foo');
+ pub.send('bar');
+ pub.send('baz');
+ }, 100.0);
});
Please sign in to comment.
Something went wrong with that request. Please try again.