Delay RPC sending and subject resubscription until we have an open channel on the client side, to try to work around prod appengine disappearing messages. Add a test for channel reconnection and re-subscription.

This commit is contained in:
Ian Gulliver
2014-05-19 15:21:21 +03:00
parent 640da84124
commit c361d41fcf
2 changed files with 97 additions and 24 deletions

View File

@@ -351,6 +351,29 @@ asyncTest('Message ordering', function() {
sendNextMessage();
});
asyncTest('Reconnect channel', function() {
expect(2);
var subject = randstring();
var message = randstring();
var callbacks = {
'onMessage': function(msg) {
equal(msg['subject']['name'], subject, 'subject matches');
equal(msg['message'], message, 'message matches');
cosmo.shutdown();
start();
},
};
var cosmo = new Cosmopolite(callbacks, null, randstring());
cosmo.subscribe(subject, 0).then(function() {
// Reach inside to forcefully close the socket
cosmo.socket_.close();
cosmo.sendMessage(subject, message);
});
});
module('dev_appserver only');