Commit 16414139ef0d6c4840dc0451d55c0689501ca0a3

Authored by Braulio Bhavamitra
1 parent 41474777

Share non linear performance factor and avoid CI failures

plugins/people_block/test/unit/friends_block_test.rb
@@ -154,22 +154,6 @@ class FriendsBlockViewTest < ActionView::TestCase @@ -154,22 +154,6 @@ class FriendsBlockViewTest < ActionView::TestCase
154 assert_tag_in_string render_block_footer(block), tag: 'a', attributes: {class: 'view-all', href: '/profile/mytestperson/friends' } 154 assert_tag_in_string render_block_footer(block), tag: 'a', attributes: {class: 'view-all', href: '/profile/mytestperson/friends' }
155 end 155 end
156 156
157 - FACTOR = 1.8  
158 -  
159 - # Testing blog page display. It should not present a linear increase in time  
160 - # needed to display a blog page with the increase in number of posts.  
161 - #  
162 - # GOOD BAD  
163 - #  
164 - # ^ ^ /  
165 - # | | /  
166 - # | _____ | /  
167 - # | / | /  
168 - # | / | /  
169 - # |/ |/  
170 - # +---------> +--------->  
171 - # 0 50 100 0 50 100  
172 - #  
173 should 'not have a linear increase in time to display friends block' do 157 should 'not have a linear increase in time to display friends block' do
174 owner = fast_create(Person) 158 owner = fast_create(Person)
175 owner.boxes<< Box.new 159 owner.boxes<< Box.new
@@ -205,7 +189,7 @@ class FriendsBlockViewTest &lt; ActionView::TestCase @@ -205,7 +189,7 @@ class FriendsBlockViewTest &lt; ActionView::TestCase
205 # the inclination of the second segment. 189 # the inclination of the second segment.
206 a1 = (time1.total - time0.total)/50.0 190 a1 = (time1.total - time0.total)/50.0
207 a2 = (time2.total - time1.total)/50.0 191 a2 = (time2.total - time1.total)/50.0
208 - assert a1 > a2*FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{FACTOR}" 192 + assert a1 > a2*NON_LINEAR_FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{NON_LINEAR_FACTOR}"
209 end 193 end
210 194
211 end 195 end
plugins/people_block/test/unit/members_block_test.rb
@@ -307,22 +307,6 @@ class MembersBlockViewTest &lt; ActionView::TestCase @@ -307,22 +307,6 @@ class MembersBlockViewTest &lt; ActionView::TestCase
307 end 307 end
308 end 308 end
309 309
310 - FACTOR = 1.8  
311 -  
312 - # Testing blog page display. It should not present a linear increase in time  
313 - # needed to display a blog page with the increase in number of posts.  
314 - #  
315 - # GOOD BAD  
316 - #  
317 - # ^ ^ /  
318 - # | | /  
319 - # | _____ | /  
320 - # | / | /  
321 - # | / | /  
322 - # |/ |/  
323 - # +---------> +--------->  
324 - # 0 50 100 0 50 100  
325 - #  
326 should 'not have a linear increase in time to display members block' do 310 should 'not have a linear increase in time to display members block' do
327 owner = fast_create(Community) 311 owner = fast_create(Community)
328 owner.boxes<< Box.new 312 owner.boxes<< Box.new
@@ -359,7 +343,7 @@ class MembersBlockViewTest &lt; ActionView::TestCase @@ -359,7 +343,7 @@ class MembersBlockViewTest &lt; ActionView::TestCase
359 # the inclination of the second segment. 343 # the inclination of the second segment.
360 a1 = (time1.total - time0.total)/50.0 344 a1 = (time1.total - time0.total)/50.0
361 a2 = (time2.total - time1.total)/50.0 345 a2 = (time2.total - time1.total)/50.0
362 - assert a1 > a2*FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{FACTOR}" 346 + assert a1 > a2*NON_LINEAR_FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{NON_LINEAR_FACTOR}"
363 end 347 end
364 348
365 end 349 end
plugins/people_block/test/unit/people_block_test.rb
@@ -146,22 +146,6 @@ class PeopleBlockViewTest &lt; ActionView::TestCase @@ -146,22 +146,6 @@ class PeopleBlockViewTest &lt; ActionView::TestCase
146 end 146 end
147 end 147 end
148 148
149 - FACTOR = 1.8  
150 -  
151 - # Testing blog page display. It should not present a linear increase in time  
152 - # needed to display a blog page with the increase in number of posts.  
153 - #  
154 - # GOOD BAD  
155 - #  
156 - # ^ ^ /  
157 - # | | /  
158 - # | _____ | /  
159 - # | / | /  
160 - # | / | /  
161 - # |/ |/  
162 - # +---------> +--------->  
163 - # 0 50 100 0 50 100  
164 - #  
165 should 'not have a linear increase in time to display people block' do 149 should 'not have a linear increase in time to display people block' do
166 owner = fast_create(Environment) 150 owner = fast_create(Environment)
167 owner.boxes<< Box.new 151 owner.boxes<< Box.new
@@ -195,7 +179,7 @@ class PeopleBlockViewTest &lt; ActionView::TestCase @@ -195,7 +179,7 @@ class PeopleBlockViewTest &lt; ActionView::TestCase
195 # the inclination of the second segment. 179 # the inclination of the second segment.
196 a1 = (time1.total - time0.total)/50.0 180 a1 = (time1.total - time0.total)/50.0
197 a2 = (time2.total - time1.total)/50.0 181 a2 = (time2.total - time1.total)/50.0
198 - assert a1 > a2*FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{FACTOR}" 182 + assert a1 > a2*NON_LINEAR_FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{NON_LINEAR_FACTOR}"
199 end 183 end
200 184
201 end 185 end
test/integration/performance_test.rb
@@ -5,22 +5,6 @@ class PerformanceTest &lt; ActionDispatch::IntegrationTest @@ -5,22 +5,6 @@ class PerformanceTest &lt; ActionDispatch::IntegrationTest
5 5
6 all_fixtures 6 all_fixtures
7 7
8 - FACTOR = 1.8  
9 -  
10 - # Testing blog page display. It should not present a linear increase in time  
11 - # needed to display a blog page with the increase in number of posts.  
12 - #  
13 - # GOOD BAD  
14 - #  
15 - # ^ ^ /  
16 - # | | /  
17 - # | _____ | /  
18 - # | / | /  
19 - # | / | /  
20 - # |/ |/  
21 - # +---------> +--------->  
22 - # 0 50 100 0 50 100  
23 - #  
24 should 'not have a linear increase in time to display a blog page' do 8 should 'not have a linear increase in time to display a blog page' do
25 person = create_profile('clueless') 9 person = create_profile('clueless')
26 10
@@ -50,7 +34,7 @@ class PerformanceTest &lt; ActionDispatch::IntegrationTest @@ -50,7 +34,7 @@ class PerformanceTest &lt; ActionDispatch::IntegrationTest
50 # the inclination of the second segment. 34 # the inclination of the second segment.
51 a1 = (time1.total - time0.total)/50.0 35 a1 = (time1.total - time0.total)/50.0
52 a2 = (time2.total - time1.total)/50.0 36 a2 = (time2.total - time1.total)/50.0
53 - assert a1 > a2*FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{FACTOR}" 37 + assert a1 > a2*NON_LINEAR_FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{NON_LINEAR_FACTOR}"
54 end 38 end
55 protected 39 protected
56 40
test/support/performance_helper.rb 0 → 100644
@@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
  1 +module PerformanceHelper
  2 +
  3 + # Testing blog page display. It should not present a linear increase in time
  4 + # needed to display a blog page with the increase in number of posts.
  5 + #
  6 + # GOOD BAD
  7 + #
  8 + # ^ ^ /
  9 + # | | /
  10 + # | _____ | /
  11 + # | / | /
  12 + # | / | /
  13 + # |/ |/
  14 + # +---------> +--------->
  15 + # 0 50 100 0 50 100
  16 + #
  17 + # On the travis/gitlab CI this can vary with servers' IO load, so
  18 + # we soften to avoid failures
  19 + #
  20 + NON_LINEAR_FACTOR = unless ENV['CI'] then 1.8 else 1.0 end
  21 +
  22 +end
  23 +
test/test_helper.rb
@@ -19,6 +19,7 @@ require_relative &#39;support/controller_test_case&#39; @@ -19,6 +19,7 @@ require_relative &#39;support/controller_test_case&#39;
19 require_relative 'support/authenticated_test_helper' 19 require_relative 'support/authenticated_test_helper'
20 require_relative 'support/action_tracker_test_helper' 20 require_relative 'support/action_tracker_test_helper'
21 require_relative 'support/noosfero_doc_test' 21 require_relative 'support/noosfero_doc_test'
  22 +require_relative 'support/performance_helper'
22 require_relative 'support/noosfero_test_helper' 23 require_relative 'support/noosfero_test_helper'
23 24
24 FileUtils.rm_rf(Rails.root.join('index', 'test')) 25 FileUtils.rm_rf(Rails.root.join('index', 'test'))
@@ -60,6 +61,8 @@ class ActiveSupport::TestCase @@ -60,6 +61,8 @@ class ActiveSupport::TestCase
60 61
61 include AuthenticatedTestHelper 62 include AuthenticatedTestHelper
62 63
  64 + include PerformanceHelper
  65 +
63 extend Test::Should 66 extend Test::Should
64 67
65 fixtures :environments, :roles 68 fixtures :environments, :roles