Even more speed improvements.

This commit is contained in:
Martin Edenhofer 2015-02-25 23:35:00 +01:00
parent d81a3722e4
commit d003cb0253
2 changed files with 50 additions and 58 deletions

View file

@ -50,13 +50,13 @@ class SessionBasicTest < ActiveSupport::TestCase
UserInfo.current_user_id = 2 UserInfo.current_user_id = 2
user = User.lookup(:id => 1) user = User.lookup(:id => 1)
collection_client1 = Sessions::Backend::Collections::Group.new(user, false, '123-1', 5) collection_client1 = Sessions::Backend::Collections::Group.new(user, false, '123-1', 3)
collection_client2 = Sessions::Backend::Collections::Group.new(user, false, '234-2', 5) collection_client2 = Sessions::Backend::Collections::Group.new(user, false, '234-2', 3)
# get whole collections # get whole collections
result1 = collection_client1.push result1 = collection_client1.push
assert( !result1.empty?, "check collections" ) assert( !result1.empty?, "check collections" )
sleep 1 sleep 0.6
result2 = collection_client2.push result2 = collection_client2.push
assert( !result2.empty?, "check collections" ) assert( !result2.empty?, "check collections" )
assert_equal( result1, result2, "check collections" ) assert_equal( result1, result2, "check collections" )
@ -71,12 +71,11 @@ class SessionBasicTest < ActiveSupport::TestCase
# change collection # change collection
group = Group.first group = Group.first
group.touch group.touch
sleep 6 sleep 4
# get whole collections # get whole collections
result1 = collection_client1.push result1 = collection_client1.push
assert( !result1.empty?, "check collections - after touch" ) assert( !result1.empty?, "check collections - after touch" )
sleep 1
result2 = collection_client2.push result2 = collection_client2.push
assert( !result2.empty?, "check collections - after touch" ) assert( !result2.empty?, "check collections - after touch" )
assert_equal( result1, result2, "check collections" ) assert_equal( result1, result2, "check collections" )
@ -84,49 +83,44 @@ class SessionBasicTest < ActiveSupport::TestCase
# check again after touch # check again after touch
result1 = collection_client1.push result1 = collection_client1.push
assert( !result1, "check collections - after touch - recall" ) assert( !result1, "check collections - after touch - recall" )
sleep 1
result2 = collection_client2.push result2 = collection_client2.push
assert( !result2, "check collections - after touch - recall" ) assert( !result2, "check collections - after touch - recall" )
assert_equal( result1, result2, "check collections" ) assert_equal( result1, result2, "check collections" )
# change collection # change collection
group = Group.create( :name => 'SomeGroup::' + rand(999999).to_s, :active => true ) group = Group.create( :name => 'SomeGroup::' + rand(999999).to_s, :active => true )
sleep 6 sleep 4
# get whole collections # get whole collections
result1 = collection_client1.push result1 = collection_client1.push
assert( !result1.empty?, "check collections - after create" ) assert( !result1.empty?, "check collections - after create" )
sleep 1
result2 = collection_client2.push result2 = collection_client2.push
assert( !result2.empty?, "check collections - after create" ) assert( !result2.empty?, "check collections - after create" )
assert_equal( result1, result2, "check collections" ) assert_equal( result1, result2, "check collections" )
# check again after create # check again after create
sleep 6 sleep 4
result1 = collection_client1.push result1 = collection_client1.push
assert( !result1, "check collections - after create - recall" ) assert( !result1, "check collections - after create - recall" )
sleep 1
result2 = collection_client2.push result2 = collection_client2.push
assert( !result2, "check collections - after create - recall" ) assert( !result2, "check collections - after create - recall" )
assert_equal( result1, result2, "check collections" ) assert_equal( result1, result2, "check collections" )
# change collection # change collection
group.destroy group.destroy
sleep 6 sleep 4
# get whole collections # get whole collections
result1 = collection_client1.push result1 = collection_client1.push
assert( !result1.empty?, "check collections - after destroy" ) assert( !result1.empty?, "check collections - after destroy" )
sleep 1
result2 = collection_client2.push result2 = collection_client2.push
assert( !result2.empty?, "check collections - after destroy" ) assert( !result2.empty?, "check collections - after destroy" )
assert_equal( result1, result2, "check collections" ) assert_equal( result1, result2, "check collections" )
# check again after destroy # check again after destroy
sleep 6 sleep 4
result1 = collection_client1.push result1 = collection_client1.push
assert( !result1, "check collections - after destroy - recall" ) assert( !result1, "check collections - after destroy - recall" )
sleep 1
result2 = collection_client2.push result2 = collection_client2.push
assert( !result2, "check collections - after destroy - recall" ) assert( !result2, "check collections - after destroy - recall" )
assert_equal( result1, result2, "check collections" ) assert_equal( result1, result2, "check collections" )
@ -143,13 +137,12 @@ class SessionBasicTest < ActiveSupport::TestCase
user = User.lookup(:id => 1) user = User.lookup(:id => 1)
org = Organization.create( :name => 'SomeOrg1::' + rand(999999).to_s, :active => true ) org = Organization.create( :name => 'SomeOrg1::' + rand(999999).to_s, :active => true )
collection_client1 = Sessions::Backend::Collections::Organization.new(user, false, '123-1', 5) collection_client1 = Sessions::Backend::Collections::Organization.new(user, false, '123-1', 3)
collection_client2 = Sessions::Backend::Collections::Organization.new(user, false, '234-2', 5) collection_client2 = Sessions::Backend::Collections::Organization.new(user, false, '234-2', 3)
# get whole collections - should be nil, no org exists! # get whole collections - should be nil, no org exists!
result1 = collection_client1.push result1 = collection_client1.push
assert( !result1.empty?, "check collections" ) assert( !result1.empty?, "check collections" )
sleep 1
result2 = collection_client2.push result2 = collection_client2.push
assert( !result2.empty?, "check collections" ) assert( !result2.empty?, "check collections" )
assert_equal( result1, result2, "check collections" ) assert_equal( result1, result2, "check collections" )
@ -157,23 +150,22 @@ class SessionBasicTest < ActiveSupport::TestCase
# next check - should still be nil, no org exists! # next check - should still be nil, no org exists!
result1 = collection_client1.push result1 = collection_client1.push
assert( !result1, "check collections - recall" ) assert( !result1, "check collections - recall" )
sleep 1 sleep 0.6
result2 = collection_client2.push result2 = collection_client2.push
assert( !result2, "check collections - recall" ) assert( !result2, "check collections - recall" )
# change collection # change collection
org = Organization.create( :name => 'SomeOrg2::' + rand(999999).to_s, :active => true ) org = Organization.create( :name => 'SomeOrg2::' + rand(999999).to_s, :active => true )
sleep 6 sleep 4
# get whole collections # get whole collections
result1 = collection_client1.push result1 = collection_client1.push
assert( !result1.empty?, "check collections - after create" ) assert( !result1.empty?, "check collections - after create" )
sleep 1
result2 = collection_client2.push result2 = collection_client2.push
assert( !result2.empty?, "check collections - after create" ) assert( !result2.empty?, "check collections - after create" )
assert_equal( result1, result2, "check collections" ) assert_equal( result1, result2, "check collections" )
sleep 6 sleep 4
# next check should be empty # next check should be empty
result1 = collection_client1.push result1 = collection_client1.push
@ -183,7 +175,7 @@ class SessionBasicTest < ActiveSupport::TestCase
organization = Organization.first organization = Organization.first
organization.touch organization.touch
sleep 12 sleep 4
# get whole collections # get whole collections
result1 = collection_client1.push result1 = collection_client1.push
@ -229,7 +221,7 @@ class SessionBasicTest < ActiveSupport::TestCase
agent1.roles = roles agent1.roles = roles
assert( agent1.save, "create/update agent1" ) assert( agent1.save, "create/update agent1" )
as_client1 = Sessions::Backend::ActivityStream.new(agent1, false, '123-1', 5) as_client1 = Sessions::Backend::ActivityStream.new(agent1, false, '123-1', 3)
# get as stream # get as stream
result1 = as_client1.push result1 = as_client1.push
@ -241,14 +233,14 @@ class SessionBasicTest < ActiveSupport::TestCase
assert( !result1, "check as agent1 - recall" ) assert( !result1, "check as agent1 - recall" )
# next check should be empty # next check should be empty
sleep 6 sleep 4
result1 = as_client1.push result1 = as_client1.push
assert( !result1, "check as agent1 - recall 2" ) assert( !result1, "check as agent1 - recall 2" )
agent1.update_attribute( :email, 'activity-stream-agent11@example.com' ) 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 ) ticket = Ticket.create(:title => '12323', :group_id => 1, :priority_id => 1, :state_id => 1, :customer_id => 1 )
sleep 6 sleep 4
# get as stream # get as stream
result1 = as_client1.push result1 = as_client1.push
@ -259,25 +251,25 @@ class SessionBasicTest < ActiveSupport::TestCase
UserInfo.current_user_id = 2 UserInfo.current_user_id = 2
user = User.lookup(:id => 1) user = User.lookup(:id => 1)
ticket_create_client1 = Sessions::Backend::TicketCreate.new(user, false, '123-1', 5) ticket_create_client1 = Sessions::Backend::TicketCreate.new(user, false, '123-1', 3)
# get as stream # get as stream
result1 = ticket_create_client1.push result1 = ticket_create_client1.push
assert( result1, "check ticket_create" ) assert( result1, "check ticket_create" )
sleep 1 sleep 0.6
# next check should be empty # next check should be empty
result1 = ticket_create_client1.push result1 = ticket_create_client1.push
assert( !result1, "check ticket_create - recall" ) assert( !result1, "check ticket_create - recall" )
# next check should be empty # next check should be empty
sleep 2 sleep 0.6
result1 = ticket_create_client1.push result1 = ticket_create_client1.push
assert( !result1, "check ticket_create - recall 2" ) assert( !result1, "check ticket_create - recall 2" )
Group.create( :name => 'SomeTicketCreateGroup::' + rand(999999).to_s, :active => true ) Group.create( :name => 'SomeTicketCreateGroup::' + rand(999999).to_s, :active => true )
sleep 6 sleep 4
# get as stream # get as stream
result1 = ticket_create_client1.push result1 = ticket_create_client1.push

View file

@ -12,14 +12,14 @@ class SessionCollectionsTest < ActiveSupport::TestCase
groups = Group.all groups = Group.all
agent1 = User.create_or_update( agent1 = User.create_or_update(
:login => 'session-collections-agent-1', :login => 'session-collections-agent-1',
:firstname => 'Session', :firstname => 'Session',
:lastname => 'collections 1', :lastname => 'collections 1',
:email => 'session-collections-agent-1@example.com', :email => 'session-collections-agent-1@example.com',
:password => 'agentpw', :password => 'agentpw',
:active => true, :active => true,
:roles => roles, :roles => roles,
:groups => groups, :groups => groups,
) )
agent1.roles = roles agent1.roles = roles
agent1.save agent1.save
@ -28,34 +28,34 @@ class SessionCollectionsTest < ActiveSupport::TestCase
groups = Group.all groups = Group.all
agent2 = User.create_or_update( agent2 = User.create_or_update(
:login => 'session-collections-agent-2', :login => 'session-collections-agent-2',
:firstname => 'Session', :firstname => 'Session',
:lastname => 'collections 2', :lastname => 'collections 2',
:email => 'session-collections-agent-2@example.com', :email => 'session-collections-agent-2@example.com',
:password => 'agentpw', :password => 'agentpw',
:active => true, :active => true,
:roles => roles, :roles => roles,
:groups => groups, :groups => groups,
) )
agent2.roles = roles agent2.roles = roles
agent2.save agent2.save
roles = Role.where( :name => [ 'Customer'] ) roles = Role.where( :name => [ 'Customer'] )
customer1 = User.create_or_update( customer1 = User.create_or_update(
:login => 'session-collections-customer-1', :login => 'session-collections-customer-1',
:firstname => 'Session', :firstname => 'Session',
:lastname => 'collections 2', :lastname => 'collections 2',
:email => 'session-collections-customer-1@example.com', :email => 'session-collections-customer-1@example.com',
:password => 'customerpw', :password => 'customerpw',
:active => true, :active => true,
:roles => roles, :roles => roles,
) )
customer1.roles = roles customer1.roles = roles
customer1.save customer1.save
collection_client1 = Sessions::Backend::Collections.new(agent1, nil, 'aaa-1') collection_client1 = Sessions::Backend::Collections.new(agent1, nil, 'aaa-1', 5)
collection_client2 = Sessions::Backend::Collections.new(agent2, nil, 'bbb-2') collection_client2 = Sessions::Backend::Collections.new(agent2, nil, 'bbb-2', 5)
collection_client3 = Sessions::Backend::Collections.new(customer1, nil, 'bbb-2') collection_client3 = Sessions::Backend::Collections.new(customer1, nil, 'bbb-2', 5)
# get whole collections # get whole collections
result1 = collection_client1.push result1 = collection_client1.push
@ -92,7 +92,7 @@ class SessionCollectionsTest < ActiveSupport::TestCase
# change collection # change collection
group = Group.first group = Group.first
group.touch group.touch
sleep 11 sleep 6
# get whole collections # get whole collections
result1 = collection_client1.push result1 = collection_client1.push
@ -108,7 +108,7 @@ class SessionCollectionsTest < ActiveSupport::TestCase
# change collection # change collection
org = Organization.create( :name => 'SomeOrg::' + rand(999999).to_s, :active => true, :member_ids => [customer1.id] ) org = Organization.create( :name => 'SomeOrg::' + rand(999999).to_s, :active => true, :member_ids => [customer1.id] )
sleep 11 sleep 6
# get whole collections # get whole collections
result1 = collection_client1.push result1 = collection_client1.push
@ -123,7 +123,7 @@ class SessionCollectionsTest < ActiveSupport::TestCase
assert( check_if_collection_exists(result3, :Organization), "check collections - after create" ) assert( check_if_collection_exists(result3, :Organization), "check collections - after create" )
# next check should be empty # next check should be empty
sleep 11 sleep 6
result1 = collection_client1.push result1 = collection_client1.push
assert( result1.empty?, "check collections - recall" ) assert( result1.empty?, "check collections - recall" )
sleep 1 sleep 1