* adding tests for VRFS-2221

This commit is contained in:
Seth Call 2014-09-17 10:21:42 -05:00
parent 6b96bdcd05
commit 0db38e17d6
3 changed files with 45 additions and 1 deletions

View File

@ -104,14 +104,56 @@ describe ConnectionManager, no_transaction: true do
cc.ip_address.should eql("1.1.1.1")
cc.addr.should == 0x01010101
cc.locidispid.should == 17192000002
cc.udp_reachable.should == true
@connman.reconnect(cc, channel_id, nil, "33.1.2.3", STALE_TIME, EXPIRE_TIME, REACHABLE)
@connman.reconnect(cc, channel_id, nil, "33.1.2.3", STALE_TIME, EXPIRE_TIME, false)
cc = Connection.find_by_client_id!(client_id)
cc.connected?.should be_true
cc.ip_address.should eql("33.1.2.3")
cc.addr.should == 0x21010203
cc.locidispid.should == 30350000003
cc.udp_reachable.should == false
count = @connman.delete_connection(client_id)
count.should == 0
@conn.exec("SELECT count(*) FROM connections where user_id = $1", [user.id]) do |result|
result.getvalue(0, 0).to_i.should == 0
end
end
it "create connection, reconnect via heartbeat" do
client_id = "client_id3"
#user_id = create_user("test", "user2", "user2@jamkazam.com")
user = FactoryGirl.create(:user)
count = @connman.create_connection(user.id, client_id, channel_id, "1.1.1.1", 'client', STALE_TIME, EXPIRE_TIME, false)
count.should == 1
# make sure the connection is seen
@conn.exec("SELECT count(*) FROM connections where user_id = $1", [user.id]) do |result|
result.getvalue(0, 0).to_i.should == 1
end
cc = Connection.find_by_client_id!(client_id)
cc.connected?.should be_true
cc.ip_address.should eql("1.1.1.1")
cc.addr.should == 0x01010101
cc.locidispid.should == 17192000002
cc.udp_reachable.should == false
@connman.reconnect(cc, channel_id, nil, "33.1.2.3", STALE_TIME, EXPIRE_TIME, nil) # heartbeat passes nil in for udp_reachable
cc = Connection.find_by_client_id!(client_id)
cc.connected?.should be_true
cc.ip_address.should eql("33.1.2.3")
cc.addr.should == 0x21010203
cc.locidispid.should == 30350000003
cc.udp_reachable.should == false
count = @connman.delete_connection(client_id)
count.should == 0

View File

@ -222,6 +222,7 @@
heartbeatMS = payload.heartbeat_interval * 1000;
connection_expire_time = payload.connection_expire_time * 1000;
logger.info("loggedIn(): clientId=" + app.clientId + " heartbeat=" + payload.heartbeat_interval + "s expire_time=" + payload.connection_expire_time + 's');
heartbeatMS = 40 * 1000;
heartbeatInterval = context.setInterval(_heartbeat, heartbeatMS);
heartbeatAckCheckInterval = context.setInterval(_heartbeatAckCheck, 1000);
lastHeartbeatAckTime = new Date(new Date().getTime() + heartbeatMS); // add a little forgiveness to server for initial heartbeat

View File

@ -737,6 +737,7 @@ module JamWebsockets
if connection.stale?
ConnectionManager.active_record_transaction do |connection_manager|
heartbeat_interval, connection_stale_time, connection_expire_time = determine_connection_times(context.user, context.client_type)
puts "RECONNECETETETETETETETET"
connection_manager.reconnect(connection, connection.music_session_id, nil, connection_stale_time, connection_expire_time, nil)
end
end