Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix passing of API options to the actual deployment resource

  • Loading branch information...
commit 54dff14b1085c122413de32992d3d8d14ffb31b1 1 parent 3ba802f
@priteau authored
View
6 lib/gosen/deployment.rb
@@ -30,8 +30,10 @@ def initialize(site, environment, nodes, options = {})
raise Gosen::Error if @max_deploy_runs < 1
if options[:ssh_public_key]
- @api_options[:key] = @ssh_public_key = options[:ssh_public_key]
+ @ssh_public_key = options[:ssh_public_key]
end
+
+ @api_options = options
end
def good_nodes
@@ -46,7 +48,7 @@ def bad_nodes
def join
@max_deploy_runs.times do |i|
- @deployment_resource = Gosen::DeploymentRun.new(@site, @environment, @bad_nodes)
+ @deployment_resource = Gosen::DeploymentRun.new(@site, @environment, @bad_nodes, @api_options)
@logger.info("Kadeploy run #{i + 1} with #{@bad_nodes.length} nodes (#{@good_nodes.length} already deployed, need #{@min_deployed_nodes - @good_nodes.length} more)")
@deployment_resource.wait_for_completion
@deployment_resource.update_nodes
View
7 test/gosen/test_deployment.rb
@@ -153,6 +153,7 @@ class TestDeployment < Test::Unit::TestCase
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()
@deployment_resource2 = mock()
@deployment_resource1.stubs(:reload)
@@ -170,8 +171,8 @@ class TestDeployment < Test::Unit::TestCase
@deployment_resource1.expects(:[]).with('result').returns(@deployment_result1)
@deployment_resource2.expects(:[]).with('result').returns(@deployment_result2)
@min_deployed_nodes = 2
- @site_deployments.expects(:submit).with({ :environment => @environment, :nodes => @nodes }).returns(@deployment_resource1)
- @site_deployments.expects(:submit).with({ :environment => @environment, :nodes => [ 'paramount-2.rennes.grid5000.fr'] }).returns(@deployment_resource2)
+ @site_deployments.expects(:submit).with({ :environment => @environment, :nodes => @nodes, :key => @ssh_public_key }).returns(@deployment_resource1)
+ @site_deployments.expects(:submit).with({ :environment => @environment, :nodes => [ 'paramount-2.rennes.grid5000.fr'], :key => @ssh_public_key }).returns(@deployment_resource2)
@logger.expects(:info).with("Kadeploy run 1 with 2 nodes (0 already deployed, need 2 more)")
@logger.expects(:info).with("Nodes deployed: paramount-1.rennes.grid5000.fr")
@logger.expects(:info).with("Nodes which failed: paramount-2.rennes.grid5000.fr")
@@ -179,7 +180,7 @@ class TestDeployment < Test::Unit::TestCase
@logger.expects(:info).with("Nodes deployed: paramount-2.rennes.grid5000.fr")
@logger.expects(:info).with("Had to run 2 kadeploy runs, deployed 2 nodes")
- @deployment = Gosen::Deployment.new(@site, @environment, @nodes, { :logger => @logger, :min_deployed_nodes => @min_deployed_nodes, :max_deploy_runs => 2 })
+ @deployment = Gosen::Deployment.new(@site, @environment, @nodes, { :logger => @logger, :min_deployed_nodes => @min_deployed_nodes, :max_deploy_runs => 2, :ssh_public_key => @ssh_public_key })
@deployment.join
assert_equal(@nodes, @deployment.good_nodes)
assert_equal([], @deployment.bad_nodes)
View
9 test/gosen/test_deployment_run.rb
@@ -58,6 +58,7 @@ class TestDeploymentRun < Test::Unit::TestCase
context 'A deployment run instance' do
setup do
+ @ssh_public_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvwM1XBJCIMtAyQlweE7BVRtvgyKdwGTeYCI4AFlsTtti4y0Ipe5Hsygx3p7S0BHFiJsVZWDANMRwZ4tcjp8YnjnMkG2yp1jB1qgUf34t/MmEQL0KkoOk8tIIb28o7nTFYKO15mXJm9yBVS1JY8ozEfnA7s5hkrdnvM6h9Jv6VScp8C1XTKmpEy3sWOeUlmCkYftYSr1fLM/7qk9S2TnljA/CGiK9dq2mhJMjnDtulVrdpc1hbh+0oCzL6m2BfXX3v4q1ORml8o04oFeEYDN5qzZneL+FzK+YfJIidvsjZ9ziVTv+7Oy5ms4wvoKiUGNapP0v/meXXBU1KvFRof3VZQ== priteau@parallelogram.local'
@result = {
'paramount-1.rennes.grid5000.fr' => {
'last_cmd_stderr' => '',
@@ -72,12 +73,12 @@ class TestDeploymentRun < Test::Unit::TestCase
@resource.expects(:reload).twice
Kernel.expects(:sleep).with(Gosen::DeploymentRun::POLLING_TIME).twice
- @deployments = mock()
- @deployments.expects(:submit).returns(@resource)
- @site = stub(:deployments => @deployments)
@environment = 'lenny-x64-base'
@nodes = [ 'paramount-1.rennes.grid5000.fr' ]
- @deployment = Gosen::DeploymentRun.new(@site, @environment, @nodes)
+ @deployments = mock()
+ @deployments.expects(:submit).with({ :environment => @environment, :nodes => @nodes, :key => @ssh_public_key}).returns(@resource)
+ @site = stub(:deployments => @deployments)
+ @deployment = Gosen::DeploymentRun.new(@site, @environment, @nodes, { :ssh_public_key => @ssh_public_key })
end
should 'wait for deployment completion and give access to the results' do
Please sign in to comment.
Something went wrong with that request. Please try again.