Improved timings.

This commit is contained in:
Martin Edenhofer 2016-05-21 18:19:34 +02:00
parent 927cc759d3
commit 34c4b7bd1b
6 changed files with 101 additions and 101 deletions

View file

@ -9,7 +9,7 @@ class SessionBasicTest < ActiveSupport::TestCase
user.save
test 'a cache' do
Sessions::CacheIn.set('last_run_test', true, { expires_in: 2.seconds })
Sessions::CacheIn.set('last_run_test', true, { expires_in: 1.second })
result = Sessions::CacheIn.get('last_run_test')
assert_equal(true, result, 'check 1')
@ -18,7 +18,7 @@ class SessionBasicTest < ActiveSupport::TestCase
assert_equal(false, result, 'check 1 - expired')
# should be expired
sleep 3
sleep 2
result = Sessions::CacheIn.expired('last_run_test')
assert_equal(true, result, 'check 1 - expired')
@ -31,7 +31,7 @@ class SessionBasicTest < ActiveSupport::TestCase
assert_equal(false, result, 'check 1 - expired')
# ignore expired
sleep 3
sleep 2
result = Sessions::CacheIn.get('last_run_test', ignore_expire: true)
assert_equal(true, result, 'check 1 - ignore_expire')
@ -109,8 +109,8 @@ class SessionBasicTest < ActiveSupport::TestCase
UserInfo.current_user_id = 2
user = User.lookup(id: 1)
collection_client1 = Sessions::Backend::Collections::Group.new(user, {}, false, '123-1', 3)
collection_client2 = Sessions::Backend::Collections::Group.new(user, {}, false, '234-2', 3)
collection_client1 = Sessions::Backend::Collections::Group.new(user, {}, false, '123-1', 2)
collection_client2 = Sessions::Backend::Collections::Group.new(user, {}, false, '234-2', 2)
# get whole collections
result1 = collection_client1.push
@ -130,7 +130,7 @@ class SessionBasicTest < ActiveSupport::TestCase
# change collection
group = Group.first
group.touch
sleep 4
sleep 3
# get whole collections
result1 = collection_client1.push
@ -148,7 +148,7 @@ class SessionBasicTest < ActiveSupport::TestCase
# change collection
group = Group.create(name: 'SomeGroup::' + rand(999_999).to_s, active: true)
sleep 4
sleep 3
# get whole collections
result1 = collection_client1.push
@ -158,7 +158,7 @@ class SessionBasicTest < ActiveSupport::TestCase
assert_equal(result1, result2, 'check collections')
# check again after create
sleep 4
sleep 3
result1 = collection_client1.push
assert(!result1, 'check collections - after create - recall')
result2 = collection_client2.push
@ -167,7 +167,7 @@ class SessionBasicTest < ActiveSupport::TestCase
# change collection
group.destroy
sleep 4
sleep 3
# get whole collections
result1 = collection_client1.push
@ -177,7 +177,7 @@ class SessionBasicTest < ActiveSupport::TestCase
assert_equal(result1, result2, 'check collections')
# check again after destroy
sleep 4
sleep 3
result1 = collection_client1.push
assert(!result1, 'check collections - after destroy - recall')
result2 = collection_client2.push
@ -193,7 +193,7 @@ class SessionBasicTest < ActiveSupport::TestCase
result1 = collection_client1.push
#puts "RSS1: #{result1.inspect}"
assert(!result1.empty?, 'check rss')
sleep 1
sleep 0.5
# next check should be empty
result1 = collection_client1.push
@ -221,7 +221,7 @@ class SessionBasicTest < ActiveSupport::TestCase
agent1.roles = roles
assert(agent1.save, 'create/update agent1')
as_client1 = Sessions::Backend::ActivityStream.new(agent1, {}, false, '123-1', 3)
as_client1 = Sessions::Backend::ActivityStream.new(agent1, {}, false, '123-1', 2)
# get as stream
result1 = as_client1.push
@ -233,14 +233,14 @@ class SessionBasicTest < ActiveSupport::TestCase
assert(!result1, 'check as agent1 - recall')
# next check should be empty
sleep 4
sleep 3
result1 = as_client1.push
assert(!result1, 'check as agent1 - recall 2')
agent1.update_attribute(:email, 'activity-stream-agent11@example.com')
ticket = Ticket.create(title: '12323', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1)
sleep 4
sleep 3
# get as stream
result1 = as_client1.push
@ -251,7 +251,7 @@ class SessionBasicTest < ActiveSupport::TestCase
UserInfo.current_user_id = 2
user = User.lookup(id: 1)
ticket_create_client1 = Sessions::Backend::TicketCreate.new(user, {}, false, '123-1', 3)
ticket_create_client1 = Sessions::Backend::TicketCreate.new(user, {}, false, '123-1', 2)
# get as stream
result1 = ticket_create_client1.push
@ -269,7 +269,7 @@ class SessionBasicTest < ActiveSupport::TestCase
Group.create(name: 'SomeTicketCreateGroup::' + rand(999_999).to_s, active: true)
sleep 4
sleep 3
# get as stream
result1 = ticket_create_client1.push

View file

@ -28,7 +28,7 @@ class SessionBasicTicketTest < ActiveSupport::TestCase
Ticket.create(title: 'default overview test', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1)
user = User.lookup(id: agent1.id)
client1 = Sessions::Backend::TicketOverviewList.new(user, {}, false, '123-1', 5)
client1 = Sessions::Backend::TicketOverviewList.new(user, {}, false, '123-1', 2)
result1 = client1.push
assert(result1, 'check ticket_overview_List')
@ -38,17 +38,17 @@ class SessionBasicTicketTest < ActiveSupport::TestCase
assert(!result1, 'check ticket_overview_index - recall')
# next check should be empty / no changes
sleep 6
sleep 3
result1 = client1.push
assert(!result1, 'check ticket_overview_index - recall 2')
# create ticket
ticket = Ticket.create(title: '12323', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1)
sleep 6
sleep 3
result1 = client1.push
assert(result1, 'check ticket_overview_index - recall 3')
sleep 6
sleep 3
# chnage overview
overviews = Ticket::Overviews.all(

View file

@ -56,9 +56,9 @@ class SessionCollectionsTest < ActiveSupport::TestCase
customer1.roles = roles
customer1.save
collection_client1 = Sessions::Backend::Collections.new(agent1, {}, nil, 'aaa-1', 3)
collection_client2 = Sessions::Backend::Collections.new(agent2, {}, nil, 'bbb-2', 3)
collection_client3 = Sessions::Backend::Collections.new(customer1, {}, nil, 'ccc-2', 3)
collection_client1 = Sessions::Backend::Collections.new(agent1, {}, nil, 'aaa-1', 2)
collection_client2 = Sessions::Backend::Collections.new(agent2, {}, nil, 'bbb-2', 2)
collection_client2 = Sessions::Backend::Collections.new(customer1, {}, nil, 'ccc-2', 2)
# get whole collections
result1 = collection_client1.push
@ -95,7 +95,7 @@ class SessionCollectionsTest < ActiveSupport::TestCase
# change collection
group = Group.first
group.touch
sleep 4
sleep 3
# get whole collections
result1 = collection_client1.push
@ -110,7 +110,7 @@ class SessionCollectionsTest < ActiveSupport::TestCase
assert(check_if_collection_exists(result3, :Group), 'check collections - after touch')
# next check should be empty
sleep 1
sleep 0.5
result1 = collection_client1.push
assert(result1.empty?, 'check collections - recall')
result2 = collection_client2.push

View file

@ -64,17 +64,17 @@ class SessionEnhancedTest < ActiveSupport::TestCase
# check if session still exists after idle cleanup
sleep 1
Sessions.destory_idle_sessions(5)
Sessions.destory_idle_sessions(3)
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 6
sleep 4
Sessions.touch(client_id1)
Sessions.touch(client_id2)
Sessions.touch(client_id3)
Sessions.destory_idle_sessions(5)
Sessions.destory_idle_sessions(3)
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')
@ -145,7 +145,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
jobs = Thread.new {
Sessions.jobs
}
sleep 5
sleep 3
#jobs.join
# check client threads
@ -154,15 +154,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 8
client_ids = Sessions.destory_idle_sessions(5)
sleep 4
client_ids = Sessions.destory_idle_sessions(3)
# 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 10
sleep 6
# check client threads
assert(!Sessions.thread_client_exists?(client_id1), 'check if client is running')
@ -235,7 +235,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
assert(Sessions.session_exists?(client_id1_0), 'check if session exists')
assert(Sessions.session_exists?(client_id1_1), 'check if session exists')
assert(Sessions.session_exists?(client_id2), 'check if session exists')
sleep 11
sleep 8
# check collections
collections = {
@ -254,7 +254,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
check_if_collection_reset_message_exists(client_id1_1, collections, 'init2')
check_if_collection_reset_message_exists(client_id2, collections, 'init2')
sleep 11
sleep 8
collections = {
'Group' => nil,
@ -268,7 +268,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
group = Group.first
group.touch
sleep 11
sleep 8
# check collections
collections = {
@ -280,8 +280,8 @@ class SessionEnhancedTest < ActiveSupport::TestCase
check_if_collection_reset_message_exists(client_id2, collections, 'update')
# check if session still exists after idle cleanup
sleep 6
client_ids = Sessions.destory_idle_sessions(5)
sleep 4
client_ids = Sessions.destory_idle_sessions(3)
# check client sessions
assert(!Sessions.session_exists?(client_id1_0), 'check if session is removed')

View file

@ -57,51 +57,51 @@ class TicketRefObjectTouchTest < ActiveSupport::TestCase
ticket = Ticket.create(
title: "some title1\n äöüß",
group: Group.lookup( name: 'Users'),
group: Group.lookup(name: 'Users'),
customer_id: customer1.id,
owner_id: agent1.id,
state: Ticket::State.lookup( name: 'new' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
assert( ticket, 'ticket created' )
assert_equal( ticket.customer.id, customer1.id )
assert_equal( ticket.organization.id, organization1.id )
assert(ticket, 'ticket created')
assert_equal(ticket.customer.id, customer1.id )
assert_equal(ticket.organization.id, organization1.id )
# check if customer and organization has been touched
customer1 = User.find(customer1.id)
if customer1.updated_at > 4.seconds.ago
assert( true, 'customer1.updated_at has been updated' )
if customer1.updated_at > 3.seconds.ago
assert(true, 'customer1.updated_at has been updated')
else
assert( false, 'customer1.updated_at has not been updated' )
assert(false, 'customer1.updated_at has not been updated')
end
organization1 = Organization.find(organization1.id)
if organization1.updated_at > 4.seconds.ago
assert( true, 'organization1.updated_at has been updated' )
if organization1.updated_at > 3.seconds.ago
assert(true, 'organization1.updated_at has been updated')
else
assert( false, 'organization1.updated_at has not been updated' )
assert(false, 'organization1.updated_at has not been updated')
end
sleep 6
sleep 4
delete = ticket.destroy
assert( delete, 'ticket destroy' )
assert(delete, 'ticket destroy')
# check if customer and organization has been touched
customer1 = User.find(customer1.id)
if customer1.updated_at > 4.seconds.ago
assert( true, 'customer1.updated_at has been updated' )
if customer1.updated_at > 3.seconds.ago
assert(true, 'customer1.updated_at has been updated')
else
assert( false, 'customer1.updated_at has not been updated' )
assert(false, 'customer1.updated_at has not been updated')
end
organization1 = Organization.find(organization1.id)
if organization1.updated_at > 4.seconds.ago
assert( true, 'organization1.updated_at has been updated' )
if organization1.updated_at > 3.seconds.ago
assert(true, 'organization1.updated_at has been updated')
else
assert( false, 'organization1.updated_at has not been updated' )
assert(false, 'organization1.updated_at has not been updated')
end
end
@ -110,51 +110,51 @@ class TicketRefObjectTouchTest < ActiveSupport::TestCase
sleep 6
ticket = Ticket.create(
title: "some title2\n äöüß",
group: Group.lookup( name: 'Users'),
group: Group.lookup(name: 'Users'),
customer_id: customer2.id,
owner_id: agent1.id,
state: Ticket::State.lookup( name: 'new' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
assert( ticket, 'ticket created' )
assert_equal( ticket.customer.id, customer2.id )
assert_equal( ticket.organization, nil )
assert(ticket, 'ticket created')
assert_equal(ticket.customer.id, customer2.id)
assert_equal(ticket.organization, nil)
# check if customer and organization has been touched
customer2 = User.find(customer2.id)
if customer2.updated_at > 4.seconds.ago
assert( true, 'customer2.updated_at has been updated' )
if customer2.updated_at > 3.seconds.ago
assert(true, 'customer2.updated_at has been updated')
else
assert( false, 'customer2.updated_at has not been updated' )
assert(false, 'customer2.updated_at has not been updated')
end
organization1 = Organization.find(organization1.id)
if organization1.updated_at > 4.seconds.ago
assert( false, 'organization1.updated_at has been updated' )
if organization1.updated_at > 3.seconds.ago
assert(false, 'organization1.updated_at has been updated')
else
assert( true, 'organization1.updated_at has not been updated' )
assert(true, 'organization1.updated_at has not been updated')
end
sleep 6
sleep 4
delete = ticket.destroy
assert( delete, 'ticket destroy' )
assert(delete, 'ticket destroy')
# check if customer and organization has been touched
customer2 = User.find(customer2.id)
if customer2.updated_at > 4.seconds.ago
assert( true, 'customer2.updated_at has been updated' )
if customer2.updated_at > 3.seconds.ago
assert(true, 'customer2.updated_at has been updated')
else
assert( false, 'customer2.updated_at has not been updated' )
assert(false, 'customer2.updated_at has not been updated')
end
organization1 = Organization.find(organization1.id)
if organization1.updated_at > 4.seconds.ago
assert( false, 'organization1.updated_at has been updated' )
if organization1.updated_at > 3.seconds.ago
assert(false, 'organization1.updated_at has been updated')
else
assert( true, 'organization1.updated_at has not been updated' )
assert(true, 'organization1.updated_at has not been updated')
end
end

View file

@ -4,8 +4,8 @@ require 'test_helper'
class UserRefObjectTouchTest < ActiveSupport::TestCase
# create base
groups = Group.where( name: 'Users' )
roles = Role.where( name: 'Agent' )
groups = Group.where(name: 'Users')
roles = Role.where(name: 'Agent')
agent1 = User.create_or_update(
login: 'user-ref-object-update-agent1@example.com',
firstname: 'Notification',
@ -19,7 +19,7 @@ class UserRefObjectTouchTest < ActiveSupport::TestCase
updated_by_id: 1,
created_by_id: 1,
)
roles = Role.where( name: 'Customer' )
roles = Role.where(name: 'Customer')
organization1 = Organization.create_if_not_exists(
name: 'Ref Object Update Org',
updated_at: '2015-02-05 16:37:00',
@ -57,59 +57,59 @@ class UserRefObjectTouchTest < ActiveSupport::TestCase
ticket = Ticket.create(
title: "some title1\n äöüß",
group: Group.lookup( name: 'Users'),
group: Group.lookup(name: 'Users'),
customer_id: customer1.id,
owner_id: agent1.id,
state: Ticket::State.lookup( name: 'new' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
assert( ticket, 'ticket created' )
assert_equal( ticket.customer.id, customer1.id )
assert_equal( ticket.organization.id, organization1.id )
assert(ticket, 'ticket created')
assert_equal(ticket.customer.id, customer1.id)
assert_equal(ticket.organization.id, organization1.id)
sleep 6
sleep 4
customer1.firstname = 'firstname customer1'
customer1.save
# check if organization has been touched
organization1 = Organization.find(organization1.id)
if organization1.updated_at > 4.seconds.ago
assert( true, 'organization1.updated_at has been updated' )
if organization1.updated_at > 3.seconds.ago
assert(true, 'organization1.updated_at has been updated')
else
assert( false, 'organization1.updated_at has not been updated' )
assert(false, 'organization1.updated_at has not been updated')
end
sleep 6
sleep 4
ticket.customer_id = customer2.id
ticket.save
# check if customer1, customer2 and organization has been touched
customer1 = User.find(customer1.id)
if customer1.updated_at > 4.seconds.ago
assert( true, 'customer1.updated_at has been updated' )
if customer1.updated_at > 3.seconds.ago
assert(true, 'customer1.updated_at has been updated')
else
assert( false, 'customer1.updated_at has not been updated' )
assert(false, 'customer1.updated_at has not been updated')
end
customer2 = User.find(customer2.id)
if customer2.updated_at > 4.seconds.ago
assert( true, 'customer2.updated_at has been updated' )
if customer2.updated_at > 3.seconds.ago
assert(true, 'customer2.updated_at has been updated')
else
assert( false, 'customer2.updated_at has not been updated' )
assert(false, 'customer2.updated_at has not been updated')
end
organization1 = Organization.find(organization1.id)
if organization1.updated_at > 4.seconds.ago
assert( true, 'organization1.updated_at has been updated' )
if organization1.updated_at > 3.seconds.ago
assert(true, 'organization1.updated_at has been updated')
else
assert( false, 'organization1.updated_at has not been updated' )
assert(false, 'organization1.updated_at has not been updated')
end
delete = ticket.destroy
assert( delete, 'ticket destroy' )
assert(delete, 'ticket destroy')
end
end