summaryrefslogtreecommitdiff
path: root/spec/unit/chef_fs
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2014-05-17 22:41:15 -0700
committerJohn Keiser <jkeiser@opscode.com>2014-05-17 22:41:15 -0700
commit31b553dcbcc9623eb75a8faa11c01e627851bd37 (patch)
tree55e5c699b0917d709cb033d055469114f9c8ef4e /spec/unit/chef_fs
parentede39a9532b56f24a77efe34086d0e8e13082cc2 (diff)
downloadchef-31b553dcbcc9623eb75a8faa11c01e627851bd37.tar.gz
Add each_with_exceptions to allow all results to be known
Diffstat (limited to 'spec/unit/chef_fs')
-rw-r--r--spec/unit/chef_fs/parallelizer.rb28
1 files changed, 19 insertions, 9 deletions
diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb
index 7823c307f9..5821721703 100644
--- a/spec/unit/chef_fs/parallelizer.rb
+++ b/spec/unit/chef_fs/parallelizer.rb
@@ -105,14 +105,16 @@ describe Chef::ChefFS::Parallelizer do
it "Exceptions with :stop_on_exception are raised after all processing is done" do
processed = 0
parallelized = parallelize([0.3,0.3,'x',0.3,0.3,0.3,0.3,0.3], :ordered => false, :stop_on_exception => true) do |x|
- raise 'hi' if x == 'x'
+ if x == 'x'
+ sleep(0.1)
+ raise 'hi'
+ end
sleep(x)
processed += 1
x
end
expect { parallelized.to_a }.to raise_error 'hi'
- processed.should <= 5
- processed.should >= 2
+ processed.should == 4
end
end
@@ -154,16 +156,22 @@ describe Chef::ChefFS::Parallelizer do
elapsed_time.should < 0.7
end
- it "Exceptions in output are raised in the correct sequence but do NOT stop processing" do
+ it "Exceptions in output are raised in the correct sequence and running processes do NOT stop processing" do
processed = 0
enum = parallelize([0.2,0.1,'x',0.3]) do |x|
+ if x == 'x'
+ while processed < 3
+ sleep(0.05)
+ end
+ raise 'hi'
+ end
sleep(x)
processed += 1
x
end.enum_for(:each)
enum.next.should == 0.2
enum.next.should == 0.1
- expect { enum.next }.to raise_error
+ expect { enum.next }.to raise_error 'hi'
elapsed_time.should > 0.25
elapsed_time.should < 0.55
processed.should == 3
@@ -171,15 +179,17 @@ describe Chef::ChefFS::Parallelizer do
it "Exceptions with :stop_on_exception are raised after all processing is done" do
processed = 0
- parallelized = parallelize([0.3,0.3,'x',0.3,0.3,0.3,0.3,0.3], :stop_on_exception => true) do |x|
- raise 'hi' if x == 'x'
+ parallelized = parallelize([0.3,0.3,'x',0.3,0.3,0.3,0.3,0.3], :ordered => false, :stop_on_exception => true) do |x|
+ if x == 'x'
+ sleep(0.1)
+ raise 'hi'
+ end
sleep(x)
processed += 1
x
end
expect { parallelized.to_a }.to raise_error 'hi'
- processed.should <= 5
- processed.should >= 2
+ processed.should == 4
end
end
end