diff --git a/plugins/people_block/test/unit/friends_block_test.rb b/plugins/people_block/test/unit/friends_block_test.rb index 004360a..fa0baa9 100644 --- a/plugins/people_block/test/unit/friends_block_test.rb +++ b/plugins/people_block/test/unit/friends_block_test.rb @@ -154,22 +154,6 @@ class FriendsBlockViewTest < ActionView::TestCase assert_tag_in_string render_block_footer(block), tag: 'a', attributes: {class: 'view-all', href: '/profile/mytestperson/friends' } end - FACTOR = 1.8 - - # Testing blog page display. It should not present a linear increase in time - # needed to display a blog page with the increase in number of posts. - # - # GOOD BAD - # - # ^ ^ / - # | | / - # | _____ | / - # | / | / - # | / | / - # |/ |/ - # +---------> +---------> - # 0 50 100 0 50 100 - # should 'not have a linear increase in time to display friends block' do owner = fast_create(Person) owner.boxes<< Box.new @@ -205,7 +189,7 @@ class FriendsBlockViewTest < ActionView::TestCase # the inclination of the second segment. a1 = (time1.total - time0.total)/50.0 a2 = (time2.total - time1.total)/50.0 - assert a1 > a2*FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{FACTOR}" + assert a1 > a2*NON_LINEAR_FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{NON_LINEAR_FACTOR}" end end diff --git a/plugins/people_block/test/unit/members_block_test.rb b/plugins/people_block/test/unit/members_block_test.rb index ad3cc5f..882a259 100644 --- a/plugins/people_block/test/unit/members_block_test.rb +++ b/plugins/people_block/test/unit/members_block_test.rb @@ -307,22 +307,6 @@ class MembersBlockViewTest < ActionView::TestCase end end - FACTOR = 1.8 - - # Testing blog page display. It should not present a linear increase in time - # needed to display a blog page with the increase in number of posts. - # - # GOOD BAD - # - # ^ ^ / - # | | / - # | _____ | / - # | / | / - # | / | / - # |/ |/ - # +---------> +---------> - # 0 50 100 0 50 100 - # should 'not have a linear increase in time to display members block' do owner = fast_create(Community) owner.boxes<< Box.new @@ -359,7 +343,7 @@ class MembersBlockViewTest < ActionView::TestCase # the inclination of the second segment. a1 = (time1.total - time0.total)/50.0 a2 = (time2.total - time1.total)/50.0 - assert a1 > a2*FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{FACTOR}" + assert a1 > a2*NON_LINEAR_FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{NON_LINEAR_FACTOR}" end end diff --git a/plugins/people_block/test/unit/people_block_test.rb b/plugins/people_block/test/unit/people_block_test.rb index 4de9470..74a6a45 100644 --- a/plugins/people_block/test/unit/people_block_test.rb +++ b/plugins/people_block/test/unit/people_block_test.rb @@ -146,22 +146,6 @@ class PeopleBlockViewTest < ActionView::TestCase end end - FACTOR = 1.8 - - # Testing blog page display. It should not present a linear increase in time - # needed to display a blog page with the increase in number of posts. - # - # GOOD BAD - # - # ^ ^ / - # | | / - # | _____ | / - # | / | / - # | / | / - # |/ |/ - # +---------> +---------> - # 0 50 100 0 50 100 - # should 'not have a linear increase in time to display people block' do owner = fast_create(Environment) owner.boxes<< Box.new @@ -195,7 +179,7 @@ class PeopleBlockViewTest < ActionView::TestCase # the inclination of the second segment. a1 = (time1.total - time0.total)/50.0 a2 = (time2.total - time1.total)/50.0 - assert a1 > a2*FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{FACTOR}" + assert a1 > a2*NON_LINEAR_FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{NON_LINEAR_FACTOR}" end end diff --git a/test/integration/performance_test.rb b/test/integration/performance_test.rb index 7e9f910..f09dc8d 100644 --- a/test/integration/performance_test.rb +++ b/test/integration/performance_test.rb @@ -5,22 +5,6 @@ class PerformanceTest < ActionDispatch::IntegrationTest all_fixtures - FACTOR = 1.8 - - # Testing blog page display. It should not present a linear increase in time - # needed to display a blog page with the increase in number of posts. - # - # GOOD BAD - # - # ^ ^ / - # | | / - # | _____ | / - # | / | / - # | / | / - # |/ |/ - # +---------> +---------> - # 0 50 100 0 50 100 - # should 'not have a linear increase in time to display a blog page' do person = create_profile('clueless') @@ -50,7 +34,7 @@ class PerformanceTest < ActionDispatch::IntegrationTest # the inclination of the second segment. a1 = (time1.total - time0.total)/50.0 a2 = (time2.total - time1.total)/50.0 - assert a1 > a2*FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{FACTOR}" + assert a1 > a2*NON_LINEAR_FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{NON_LINEAR_FACTOR}" end protected diff --git a/test/support/performance_helper.rb b/test/support/performance_helper.rb new file mode 100644 index 0000000..b4856de --- /dev/null +++ b/test/support/performance_helper.rb @@ -0,0 +1,23 @@ +module PerformanceHelper + + # Testing blog page display. It should not present a linear increase in time + # needed to display a blog page with the increase in number of posts. + # + # GOOD BAD + # + # ^ ^ / + # | | / + # | _____ | / + # | / | / + # | / | / + # |/ |/ + # +---------> +---------> + # 0 50 100 0 50 100 + # + # On the travis/gitlab CI this can vary with servers' IO load, so + # we soften to avoid failures + # + NON_LINEAR_FACTOR = unless ENV['CI'] then 1.8 else 1.0 end + +end + diff --git a/test/test_helper.rb b/test/test_helper.rb index 3495ef3..b963dca 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -19,6 +19,7 @@ require_relative 'support/controller_test_case' require_relative 'support/authenticated_test_helper' require_relative 'support/action_tracker_test_helper' require_relative 'support/noosfero_doc_test' +require_relative 'support/performance_helper' require_relative 'support/noosfero_test_helper' FileUtils.rm_rf(Rails.root.join('index', 'test')) @@ -60,6 +61,8 @@ class ActiveSupport::TestCase include AuthenticatedTestHelper + include PerformanceHelper + extend Test::Should fixtures :environments, :roles -- libgit2 0.21.2