Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
[CC] Raise the right error when staging
  Updated StagingTaskLog to raise StagingTimeoutError when timed out
from fetching redis value.
  Unit tests have also been added to exercise the errback code path.

Change-Id: Id2b04acc43eb08fe616ddee3f86cb4b23aa40b83
  • Loading branch information
d committed Feb 17, 2012
1 parent 3a4c4fd commit 33f357a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cloud_controller/app/models/staging_task_log.rb
Expand Up @@ -17,7 +17,7 @@ def fetch_fibered(app_id, redis=nil, timeout=5)
get_def = redis.get(key)
get_def.timeout(timeout)
get_def.errback do |e|
e = VCAP::Stager::TaskResultTimeoutError.new("Timed out fetching result") if e == nil
e = VCAP::Stager::StagingTimeoutError.new("Timed out fetching result") if e == nil
logger.error("Failed fetching result for key '#{key}': #{e}")
logger.error(e)
f.resume([false, e])
Expand Down
18 changes: 18 additions & 0 deletions cloud_controller/spec/models/staging_task_log_spec.rb
Expand Up @@ -53,6 +53,24 @@
end.resume
@deferrable_mock.succeed(nil)
end

it 'should raise TimeoutError when timed out fetching result' do
Fiber.new do
expect do
res = StagingTaskLog.fetch_fibered(@task_id, @redis_mock)
end.to raise_error(VCAP::Stager::TaskError)
end.resume
@deferrable_mock.fail(nil)
end

it 'should raise error when redis fetching fails' do
Fiber.new do
expect do
res = StagingTaskLog.fetch_fibered(@task_id, @redis_mock)
end.to raise_error
end.resume
@deferrable_mock.fail(RuntimeError.new("Mock Runtime Error from EM::Hiredis"))
end
end

end

0 comments on commit 33f357a

Please sign in to comment.