Improved session tests.
This commit is contained in:
parent
fa454abf3a
commit
90047729d4
5 changed files with 31 additions and 8 deletions
|
@ -448,11 +448,21 @@ returns
|
|||
end
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
remove all session and spool messages
|
||||
|
||||
Sessions.cleanup
|
||||
|
||||
=end
|
||||
|
||||
def self.cleanup
|
||||
path = "#{@path}/spool/"
|
||||
FileUtils.rm_rf path
|
||||
path = "#{@path}/tmp/"
|
||||
FileUtils.rm_rf path
|
||||
Dir.foreach(@path) do |entry|
|
||||
next if entry == '.'
|
||||
next if entry == '..'
|
||||
FileUtils.rm_rf entry
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
def self.spool_create(data)
|
||||
|
|
|
@ -42,6 +42,9 @@ class ActiveSupport::TestCase
|
|||
# clear cache
|
||||
Cache.clear
|
||||
|
||||
# remove all session messages
|
||||
Sessions.cleanup
|
||||
|
||||
# remove background jobs
|
||||
Delayed::Job.destroy_all
|
||||
Trigger.destroy_all
|
||||
|
|
|
@ -70,8 +70,11 @@ class SessionBasicTicketTest < ActiveSupport::TestCase
|
|||
Sessions::Backend::TicketOverviewList.reset(user.id)
|
||||
result1 = client1.push
|
||||
assert(result1, 'check ticket_overview_index - recall 7')
|
||||
|
||||
travel 10.seconds
|
||||
Sessions.destroy_idle_sessions(3)
|
||||
|
||||
travel_back
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -130,6 +130,10 @@ class SessionCollectionsTest < ActiveSupport::TestCase
|
|||
assert(result2.empty?, 'check collections - recall')
|
||||
result3 = collection_client3.push
|
||||
assert(result3.empty?, 'check collections - recall')
|
||||
|
||||
travel 10.seconds
|
||||
Sessions.destroy_idle_sessions(3)
|
||||
|
||||
travel_back
|
||||
end
|
||||
|
||||
|
@ -175,9 +179,9 @@ class SessionCollectionsTest < ActiveSupport::TestCase
|
|||
|
||||
UserInfo.current_user_id = 2
|
||||
agent1 = User.create_or_update(
|
||||
login: 'sessions-assets-1',
|
||||
login: "sessions-assets-1-#{rand(99_999)}",
|
||||
firstname: 'Session',
|
||||
lastname: "activity stream #{rand(99_999)}",
|
||||
lastname: "sessions assets #{rand(99_999)}",
|
||||
email: 'sessions-assets1@example.com',
|
||||
password: 'agentpw',
|
||||
active: true,
|
||||
|
@ -204,6 +208,9 @@ class SessionCollectionsTest < ActiveSupport::TestCase
|
|||
assert(data[:collection][:Group][groups.first.id])
|
||||
assert_nil(data[:assets][:Group])
|
||||
|
||||
travel 10.seconds
|
||||
Sessions.destroy_idle_sessions(3)
|
||||
|
||||
travel_back
|
||||
end
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
|||
|
||||
# check if session still exists after idle cleanup
|
||||
sleep 4
|
||||
client_ids = Sessions.destroy_idle_sessions(3)
|
||||
client_ids = Sessions.destroy_idle_sessions(2)
|
||||
|
||||
# check client sessions
|
||||
assert(!Sessions.session_exists?(client_id1), 'check if session is removed')
|
||||
|
|
Loading…
Reference in a new issue