Improved speed of test by switching from min to sec for idle param.

This commit is contained in:
Martin Edenhofer 2015-02-25 23:17:34 +01:00
parent 5d2db33534
commit d81a3722e4
3 changed files with 13 additions and 13 deletions

View file

@ -165,11 +165,11 @@ returns
=end
def self.destory_idle_sessions(idle_time_in_min = 4)
def self.destory_idle_sessions(idle_time_in_sec = 240)
list_of_closed_sessions = []
clients = Sessions.list
clients.each { |client_id, client|
if !client[:meta] || !client[:meta][:last_ping] || ( client[:meta][:last_ping].to_i + ( 60 * idle_time_in_min ) ) < Time.now.to_i
if !client[:meta] || !client[:meta][:last_ping] || ( client[:meta][:last_ping].to_i + idle_time_in_sec ) < Time.now.to_i
list_of_closed_sessions.push client_id
Sessions.destory( client_id )
end

View file

@ -293,11 +293,11 @@ EventMachine.run {
def check_unused_connections
log 'notice', "check unused idle connections..."
idle_time_in_min = 4
idle_time_in_sec = 4 * 60
# close unused web socket sessions
@clients.each { |client_id, client|
if ( client[:last_ping] + ( 60 * idle_time_in_min ) ) < Time.now
if ( client[:last_ping] + idle_time_in_sec ) < Time.now
log 'notice', "closing idle websocket connection", client_id
# remember to not use this connection anymore
@ -313,7 +313,7 @@ EventMachine.run {
}
# close unused ajax long polling sessions
clients = Sessions.destory_idle_sessions(idle_time_in_min)
clients = Sessions.destory_idle_sessions(idle_time_in_sec)
clients.each { |client_id|
log 'notice', "closing idle long polling connection", client_id
}

View file

@ -64,17 +64,17 @@ class SessionEnhancedTest < ActiveSupport::TestCase
# check if session still exists after idle cleanup
sleep 1
Sessions.destory_idle_sessions(1)
Sessions.destory_idle_sessions(5)
assert( Sessions.session_exists?(client_id1), "check if session exists after 1 sec" )
assert( Sessions.session_exists?(client_id2), "check if session exists after 1 sec" )
assert( Sessions.session_exists?(client_id3), "check if session exists after 1 sec" )
# check if session still exists after idle cleanup with touched sessions
sleep 62
sleep 6
Sessions.touch(client_id1)
Sessions.touch(client_id2)
Sessions.touch(client_id3)
Sessions.destory_idle_sessions(1)
Sessions.destory_idle_sessions(5)
assert( Sessions.session_exists?(client_id1), "check if session exists after touch" )
assert( Sessions.session_exists?(client_id2), "check if session exists after touch" )
assert( Sessions.session_exists?(client_id3), "check if session exists after touch" )
@ -155,15 +155,15 @@ class SessionEnhancedTest < ActiveSupport::TestCase
assert( Sessions.thread_client_exists?(client_id3), "check if client is running" )
# check if session still exists after idle cleanup
sleep 62
client_ids = Sessions.destory_idle_sessions(1)
sleep 6
client_ids = Sessions.destory_idle_sessions(5)
# check client sessions
assert( !Sessions.session_exists?(client_id1), "check if session is removed" )
assert( !Sessions.session_exists?(client_id2), "check if session is removed" )
assert( !Sessions.session_exists?(client_id3), "check if session is removed" )
sleep 28
sleep 6
# check client threads
assert( !Sessions.thread_client_exists?(client_id1), "check if client is running" )
@ -279,8 +279,8 @@ class SessionEnhancedTest < ActiveSupport::TestCase
check_if_collection_reset_message_exists(client_id2, collections, 'update')
# check if session still exists after idle cleanup
sleep 62
client_ids = Sessions.destory_idle_sessions(1)
sleep 6
client_ids = Sessions.destory_idle_sessions(5)
# check client sessions
assert( !Sessions.session_exists?(client_id1_0), "check if session is removed" )