summaryrefslogtreecommitdiff
path: root/spec/unit/chef_fs/parallelizer.rb
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2014-05-18 19:18:38 -0700
committerJohn Keiser <jkeiser@opscode.com>2014-05-18 19:18:38 -0700
commitc28654606f6c2ef3211d0cc0cf8d02c29e9571b8 (patch)
tree04d5cf7bff3fe8e2d61a57631c47f718b75bb3f3 /spec/unit/chef_fs/parallelizer.rb
parenta32736de04df3c40fb21ec57db00128cf33e1f7d (diff)
downloadchef-c28654606f6c2ef3211d0cc0cf8d02c29e9571b8.tar.gz
Make it possible to resize and gently stop the parallelizer
Diffstat (limited to 'spec/unit/chef_fs/parallelizer.rb')
-rw-r--r--spec/unit/chef_fs/parallelizer.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb
index 5c9f38a8eb..c474a4774d 100644
--- a/spec/unit/chef_fs/parallelizer.rb
+++ b/spec/unit/chef_fs/parallelizer.rb
@@ -227,10 +227,12 @@ describe Chef::ChefFS::Parallelizer do
before :each do
parallelizer
started = false
+ @occupying_job_finished = occupying_job_finished = [ false ]
@thread = Thread.new do
parallelizer.parallelize([0], :main_thread_processing => false) do |x|
started = true
sleep(0.3)
+ occupying_job_finished[0] = true
end.wait
end
while !started
@@ -257,6 +259,28 @@ describe Chef::ChefFS::Parallelizer do
end.to_a.should == [ 2 ]
elapsed_time.should > 0.3
end
+
+ it "resizing the Parallelizer to 0 waits for the job to stop" do
+ elapsed_time.should < 0.2
+ parallelizer.resize(0)
+ elapsed_time.should > 0.25
+ @occupying_job_finished.should == [ true ]
+ end
+
+ it "stopping the Parallelizer waits for the job to finish" do
+ elapsed_time.should < 0.2
+ parallelizer.stop
+ elapsed_time.should > 0.25
+ @occupying_job_finished.should == [ true ]
+ end
+
+ it "resizing the Parallelizer to 2 does not stop the job" do
+ elapsed_time.should < 0.2
+ parallelizer.resize(2)
+ elapsed_time.should < 0.2
+ sleep(0.3)
+ @occupying_job_finished.should == [ true ]
+ end
end
end