From 06047e249b5b3667ec391d4e0c7087e49d77436f Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 10 May 2015 17:24:10 +0200 Subject: [PATCH] Added logging to find race condition. --- app/models/application_model.rb | 1 + test/unit/session_basic_ticket_test.rb | 56 ++++++++++++-------------- 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/app/models/application_model.rb b/app/models/application_model.rb index 470f5c2c7..86b187062 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -497,6 +497,7 @@ returns # if we do not have it cached, do lookup if !updated_at o = select(:updated_at).order(updated_at: :desc).limit(1).first + logger.debug "result latest_change #{o.inspect}" if o updated_at = o.updated_at latest_change_set(updated_at) diff --git a/test/unit/session_basic_ticket_test.rb b/test/unit/session_basic_ticket_test.rb index 42c31cb60..5bbf0ceef 100644 --- a/test/unit/session_basic_ticket_test.rb +++ b/test/unit/session_basic_ticket_test.rb @@ -3,24 +3,30 @@ require 'test_helper' class SessionBasicTicketTest < ActiveSupport::TestCase - test 'b ticket_overview_index' do + UserInfo.current_user_id = 1 + # create users + roles = Role.where( name: [ 'Agent' ] ) + groups = Group.all + + agent1 = User.create_or_update( + login: 'session-basic-ticket-agent-1', + firstname: 'Session', + lastname: 'session basic ' + rand(99_999).to_s, + email: 'session-basic-ticket-agent-1@example.com', + password: 'agentpw', + active: true, + roles: roles, + groups: groups, + ) + + # create ticket + ticket = Ticket.create( title: 'default overview test', group_id: 1, priority_id: 1, state_id: 1, customer_id: 1 ) + sleep 6 + + test 'b ticket_overview_index' do UserInfo.current_user_id = 1 - # create users - roles = Role.where( name: [ 'Agent' ] ) - groups = Group.all - - agent1 = User.create_or_update( - login: 'session-basic-ticket-agent-1', - firstname: 'Session', - lastname: 'session basic ' + rand(99_999).to_s, - email: 'session-basic-ticket-agent-1@example.com', - password: 'agentpw', - active: true, - roles: roles, - groups: groups, - ) agent1.roles = roles assert( agent1.save, 'create/update agent1' ) @@ -30,7 +36,7 @@ class SessionBasicTicketTest < ActiveSupport::TestCase # get as stream result1 = client1.push if !result1 - Rails.logger.debug "FAILD Sessions::Backend::TicketOverviewIndex push" + Rails.logger.error "FAILD Sessions::Backend::TicketOverviewIndex push" end assert( result1, 'check ticket_overview_index' ) @@ -53,23 +59,8 @@ class SessionBasicTicketTest < ActiveSupport::TestCase end test 'b ticket_overview_list' do - UserInfo.current_user_id = 1 - # create users - roles = Role.where( name: [ 'Agent' ] ) - groups = Group.all - - agent1 = User.create_or_update( - login: 'session-basic-ticket-agent-1', - firstname: 'Session', - lastname: 'session basic ' + rand(99_999).to_s, - email: 'session-basic-ticket-agent-1@example.com', - password: 'agentpw', - active: true, - roles: roles, - groups: groups, - ) agent1.roles = roles assert( agent1.save, 'create/update agent1' ) @@ -79,6 +70,9 @@ class SessionBasicTicketTest < ActiveSupport::TestCase # get as stream result1 = client1.push + if !result1 + Rails.logger.error "FAILD Sessions::Backend::TicketOverviewList push" + end assert( result1, 'check ticket_overview_list' ) # next check should be empty / no changes