Feedback fixes:

* remove .DS_Store from local ignore;
* remove TODO;
* add 1 test and doubles test speed;
* small refactoring of /bin/astute;
* remove require of rubygems.
This commit is contained in:
Vladmir Sharhsov(warpc) 2013-07-15 10:17:12 +04:00
parent 862d96aed1
commit 833b0eae55
6 changed files with 27 additions and 23 deletions

1
.gitignore vendored
View File

@ -1,3 +1,2 @@
.idea
*.gem
.DS_Store

View File

@ -71,14 +71,16 @@ case environment['attributes']['deployment_engine']
deploy_engine = nil # Orchestrator will use it's default
end
if [:deploy, :fast_provision, :provision].include? opts[:command]
orchestrator = Astute::Orchestrator.new(deploy_engine, log_parsing=false)
end
case opts[:command]
when :deploy
orchestrator = Astute::Orchestrator.new(deploy_engine, log_parsing=false)
orchestrator.deploy(reporter, environment['task_uuid'], environment['nodes'], environment['attributes'])
when :fast_provision
orchestrator = Astute::Orchestrator.new(deploy_engine, log_parsing=false)
orchestrator.fast_provision(reporter, environment['engine'], environment['nodes'])
when :provision
orchestrator = Astute::Orchestrator.new(deploy_engine, log_parsing=false)
orchestrator.provision(reporter, environment['task_uuid'], environment['nodes'])
end

View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
require "rubygems"
require 'astute/ruby_removed_functions'
require 'json'

View File

@ -19,7 +19,6 @@ module Astute
@log_parser = log_parsing ? LogParser::ParseDeployLogs.new : LogParser::NoParsing.new
end
# TODO(waprc): does this method should be private?
def node_type(reporter, task_id, nodes, timeout=nil)
context = Context.new(task_id, reporter)
uids = nodes.map {|n| n['uid']}

View File

@ -29,6 +29,7 @@ Astute.config.PUPPET_DEPLOY_INTERVAL = 0
Astute.config.PUPPET_FADE_INTERVAL = 0
Astute.config.MC_RETRY_INTERVAL = 0
Astute.config.PROVISIONING_TIMEOUT = 0
Astute.config.REBOOT_TIMEOUT = 0
Astute.logger = Logger.new(STDERR)
RSpec.configure do |c|

View File

@ -359,6 +359,13 @@ describe Astute::Orchestrator do
describe '#provision' do
before(:each) do
# Disable sleeping in test env (doubles the test speed)
def @orchestrator.sleep_not_greater_than(time, &block)
block.call
end
end
it "raises error if nodes list is empty" do
expect {@orchestrator.provision(@reporter, @data['task_uuid'], {})}.
to raise_error(/Nodes to provision are not provided!/)
@ -369,7 +376,7 @@ describe Astute::Orchestrator do
expects(:prepare).with(@data['nodes']).once
end
@orchestrator.stubs(:report_about_progress).returns()
@orchestrator.stubs(:node_type).returns([{'uid' => 1, 'node_type' => 'target' }])
@orchestrator.stubs(:node_type).returns([{'uid' => '1', 'node_type' => 'target' }])
@orchestrator.provision(@reporter, @data['task_uuid'], @data['nodes'])
end
@ -380,37 +387,34 @@ describe Astute::Orchestrator do
end
@orchestrator.stubs(:report_about_progress).returns()
@orchestrator.stubs(:node_type).returns([{'uid' => 1, 'node_type' => 'target' }])
@orchestrator.stubs(:node_type).returns([{'uid' => '1', 'node_type' => 'target' }])
@orchestrator.provision(@reporter, @data['task_uuid'], @data['nodes'])
end
it 'provision nodes using mclient' do
@orchestrator.stubs(:report_about_progress).returns()
@orchestrator.expects(:node_type).returns([{'uid' => 1, 'node_type' => 'target' }])
@orchestrator.expects(:node_type).returns([{'uid' => '1', 'node_type' => 'target' }])
@orchestrator.provision(@reporter, @data['task_uuid'], @data['nodes'])
end
xit "fail if timeout of provisioning is exceeded" do
it "fail if timeout of provisioning is exceeded" do
Astute::LogParser::ParseProvisionLogs.any_instance do
stubs(:prepare).returns()
end
@orchestrator.stubs(:node_type).returns([{'uid' => 1, 'node_type' => 'target' }])
Timeout.stubs(:timeout).raises(Timeout::Error)
msg = 'Timeout of provisioning is exceeded'
Astute.logger.expects(:error).with(msg)
# error_mgs = {'status' => 'error', 'error' => msg, 'nodes' => [{ 'uid' => 1,
# 'status' => 'error',
# 'error_msg' => msg,
# 'progress' => 100,
# 'error_type' => 'provision'}]}
#
#@reporter.expects(:report).with(error_mgs)
msg = 'Timeout of provisioning is exceeded.'
error_mgs = {'status' => 'error', 'error' => msg, 'nodes' => [{ 'uid' => '1',
'status' => 'error',
'error_msg' => msg,
'progress' => 100,
'error_type' => 'provision'}]}
@reporter.expects(:report).with(error_mgs).once
@orchestrator.provision(@reporter, @data['task_uuid'], @data['nodes'])
end
end