Permalink
Browse files

Allow to pass API options such as reformat_tmp to Gosen::Deployment.n…

…ew()
  • Loading branch information...
1 parent 43b9656 commit b149e02f3e92d19e265323ba925eefe14bf7b4d5 @priteau committed Oct 20, 2010
Showing with 17 additions and 6 deletions.
  1. +2 −2 lib/gosen/deployment.rb
  2. +3 −3 lib/gosen/deployment_run.rb
  3. +12 −1 test/gosen/test_deployment.rb
View
@@ -23,10 +23,10 @@ def initialize(site, environment, nodes, options = {})
@api_options = {}
@logger = options.delete(:logger) || NullLogger.new
- @min_deployed_nodes = options[:min_deployed_nodes] || 1
+ @min_deployed_nodes = options.delete(:min_deployed_nodes) || 1
raise Gosen::Error if @min_deployed_nodes > @nodes.length || @min_deployed_nodes < 0
- @max_deploy_runs = options[:max_deploy_runs] || 1
+ @max_deploy_runs = options.delete(:max_deploy_runs) || 1
raise Gosen::Error if @max_deploy_runs < 1
if options[:ssh_public_key]
@@ -16,10 +16,10 @@ def initialize(site, environment, nodes, options = {})
@nodes = nodes
@good_nodes = []
@bad_nodes = Array.new(@nodes)
- @api_options = {}
+ @api_options = options
- if options[:ssh_public_key]
- @api_options[:key] = @ssh_public_key = options[:ssh_public_key]
+ if @api_options[:ssh_public_key]
+ @api_options[:key] = @ssh_public_key = @api_options.delete(:ssh_public_key)
end
submit_deployment
end
@@ -129,7 +129,7 @@ class TestDeployment < Test::Unit::TestCase
@site_deployments.expects(:submit).with({ :environment => @environment, :nodes => @nodes }).returns(@deployment_resource)
@min_deployed_nodes = 2
@logger.expects(:info).with("Kadeploy run 1 with #{@nodes.length} nodes (0 already deployed, need #{@min_deployed_nodes} more)")
- @logger.expects(:info).with("Nodes deployed: paramount-1.rennes.grid5000.fr paramount-2.rennes.grid5000.fr")
+ @logger.expects(:info).with("Nodes deployed: paramount-1.rennes.grid5000.fr paramount-2.rennes.grid5000.fr")
@logger.expects(:info).with("Had to run 1 kadeploy runs, deployed #{@deployment_result.length} nodes")
@deployment = Gosen::Deployment.new(@site, @environment, @nodes, { :logger => @logger, :min_deployed_nodes => @min_deployed_nodes })
@@ -152,6 +152,17 @@ class TestDeployment < Test::Unit::TestCase
}
end
+ should 'pass extra API options to the deployment resource' do
+ @deployment_result = {
+ 'paramount-1.rennes.grid5000.fr' => { 'state' => 'OK' },
+ 'paramount-2.rennes.grid5000.fr' => { 'state' => 'OK' }
+ }
+ @deployment_resource.expects(:[]).with('result').returns(@deployment_result)
+ @site_deployments.expects(:submit).with({ :environment => @environment, :nodes => @nodes, :reformat_tmp => 'ext3' }).returns(@deployment_resource)
+ @deployment = Gosen::Deployment.new(@site, @environment, @nodes, { :reformat_tmp => 'ext3' })
+ @deployment.join
+ end
+
should 'submit new deployment runs when needed' do
@ssh_public_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvwM1XBJCIMtAyQlweE7BVRtvgyKdwGTeYCI4AFlsTtti4y0Ipe5Hsygx3p7S0BHFiJsVZWDANMRwZ4tcjp8YnjnMkG2yp1jB1qgUf34t/MmEQL0KkoOk8tIIb28o7nTFYKO15mXJm9yBVS1JY8ozEfnA7s5hkrdnvM6h9Jv6VScp8C1XTKmpEy3sWOeUlmCkYftYSr1fLM/7qk9S2TnljA/CGiK9dq2mhJMjnDtulVrdpc1hbh+0oCzL6m2BfXX3v4q1ORml8o04oFeEYDN5qzZneL+FzK+YfJIidvsjZ9ziVTv+7Oy5ms4wvoKiUGNapP0v/meXXBU1KvFRof3VZQ== priteau@parallelogram.local'
@deployment_resource1 = mock()

0 comments on commit b149e02

Please sign in to comment.