Skip to content

Commit 1ba6ee2

Browse files
committed
removed debug puts. Also, can travis work with a longer setup time, but a shorter time between runs?
1 parent 65c80b2 commit 1ba6ee2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

spec/parallel_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,25 @@
1010
describe "threadhot" do
1111

1212
before :each do
13+
ActiveRecord::Base.connection.reconnect!
1314
TagHierarchy.delete_all
1415
Tag.delete_all
1516
@iterations = 5
1617
@workers = 6 # Travis CI workers can't reliably handle larger numbers
1718
@parent = nil
19+
@time_between_runs = 1
1820
end
1921

2022
def find_or_create_at_even_second(run_at)
2123
sleep(run_at - Time.now.to_f)
2224
ActiveRecord::Base.connection.reconnect!
23-
(@parent || Tag).find_or_create_by_path([run_at.to_s, :a, :b, :c].compact)
25+
(@parent || Tag).find_or_create_by_path([run_at.to_s, :a, :b, :c])
2426
end
2527

2628
def run_workers
27-
start_time = Time.now.to_i + 2
28-
@times = @iterations.times.collect { |ea| start_time + (ea * 2) }
29+
expected_thread_setup_time = 4
30+
start_time = Time.now.to_i + expected_thread_setup_time
31+
@times = @iterations.times.collect { |ea| start_time + (ea * @time_between_runs) }
2932
@names = @times.collect { |ea| ea.to_s }
3033
@threads = @workers.times.collect do
3134
Thread.new do
@@ -78,12 +81,10 @@ def run_workers
7881
target.find_or_create_by_path(name)
7982
children_to_delete << name
8083
added_children << name
81-
puts "+ #{name}"
8284
end
8385
end while !children_to_add.empty?
8486
end
8587
end
86-
sleep 0.5
8788
run_destruction = true
8889
destroyer_threads = @workers.times.map do
8990
Thread.new do
@@ -93,9 +94,8 @@ def run_workers
9394
if victim
9495
target.children.where(:name => victim).first.destroy
9596
deleted_children << victim
96-
puts "- #{victim}"
9797
else
98-
sleep 0.1
98+
sleep rand # wait for moar victims
9999
end
100100
end while run_destruction || !children_to_delete.empty?
101101
end

0 commit comments

Comments
 (0)