Fix astute specs

This commit is contained in:
Dmitry Pyzhov 2013-04-10 17:19:28 +04:00
parent 1c98c40791
commit bdd6c5cfb4
10 changed files with 39 additions and 39 deletions

View File

@ -8,17 +8,17 @@ task_uuid: deployment_task
attributes:
# `deployment_mode' shows what type of installation you choose.
# Can be:
# `singlenode_compute' - means only one node will be deployed. It will
# `singlenode' - means only one node will be deployed. It will
# contain Controller and Compute components of OpenStack.
# `multinode_compute' - means one Controller node and some Compute nodes
# `multinode' - means one Controller node and some Compute nodes
# will be deployed.
# `ha_compute' - means at least three Controller nodes and some Compute
# `ha' - means at least three Controller nodes and some Compute
# nodes will be deployed in High Availability mode of Controller
# components.
# In last two cases Astute first of all deployes Contoller components,
# after that it deployes Compute components and finaly deployes other
# components if they exist.
deployment_mode: multinode_compute
deployment_mode: multinode
# `deployment_engine' - shows how you will handle attributes for Puppet
# manifests.
# `simplepuppet' - means you should manualy set up all necessary attributes

View File

@ -8,6 +8,6 @@ nodes:
role: compute
uid: devnailgun.mirantis.com
attributes:
deployment_mode: multinode_compute
deployment_mode: multinode
deployment_engine: simplepuppet
task_uuid: deployment_task

View File

@ -59,7 +59,7 @@ nodes:
uid: devnailgun.mirantis.com
mac: 52:54:00:50:91:DD
attributes:
deployment_mode: multinode_compute
deployment_mode: multinode
deployment_engine: nailyfact
glance:
db_password: glance

View File

@ -12,7 +12,7 @@ module Astute
def deploy(nodes, attrs)
# See implementation in subclasses, this may be everriden
attrs['deployment_mode'] ||= 'multinode_compute' # simple multinode deployment is the default
attrs['deployment_mode'] ||= 'multinode' # simple multinode deployment is the default
attrs['use_cinder'] ||= nodes.any?{|n| n['role'] == 'cinder'}
@ctx.deploy_log_parser.deploy_type = attrs['deployment_mode']
Astute.logger.info "Deployment mode #{attrs['deployment_mode']}"
@ -39,7 +39,7 @@ module Astute
end
# we mix all attrs and prepare them for Puppet
# Works for multinode_compute deployment mode
# Works for multinode deployment mode
def attrs_multinode(nodes, attrs)
ctrl_nodes = nodes.select {|n| n['role'] == 'controller'}
# TODO(mihgen): we should report error back if there are not enough metadata passed

View File

@ -2,7 +2,7 @@ module Astute
module LogParser
class ParseDeployLogs <ParseNodeLogs
attr_reader :deploy_type
def initialize(deploy_type='multinode_compute')
def initialize(deploy_type='multinode')
@deploy_type = deploy_type
pattern_spec = Patterns::get_default_pattern(
"puppet-log-components-list-#{@deploy_type}-controller")
@ -153,4 +153,4 @@ module Astute
end
end
end
end
end

View File

@ -56,7 +56,7 @@ module Astute
'filename' => 'install/anaconda.log'
},
'puppet-log-components-list-ha_compute-controller' => # key for default HA deploy pattern
'puppet-log-components-list-ha-controller' => # key for default HA deploy pattern
{'type' => 'components-list',
'endlog_patterns' => [{'pattern' => /Finished catalog run in [0-9]+\.[0-9]* seconds\n/, 'progress' => 1.0}],
'chunk_size' => 40000,
@ -220,7 +220,7 @@ module Astute
]
},
'puppet-log-components-list-ha_compute-compute' =>
'puppet-log-components-list-ha-compute' =>
{'type' => 'components-list',
'endlog_patterns' => [{'pattern' => /Finished catalog run in [0-9]+\.[0-9]* seconds\n/, 'progress' => 1.0}],
'chunk_size' => 40000,
@ -272,7 +272,7 @@ module Astute
]
},
'puppet-log-components-list-singlenode_compute-controller' =>
'puppet-log-components-list-singlenode-controller' =>
{'type' => 'components-list',
'endlog_patterns' => [{'pattern' => /Finished catalog run in [0-9]+\.[0-9]* seconds\n/, 'progress' => 1.0}],
'chunk_size' => 40000,
@ -358,7 +358,7 @@ module Astute
]
},
'puppet-log-components-list-multinode_compute-controller' =>
'puppet-log-components-list-multinode-controller' =>
{'type' => 'components-list',
'endlog_patterns' => [{'pattern' => /Finished catalog run in [0-9]+\.[0-9]* seconds\n/, 'progress' => 1.0}],
'chunk_size' => 40000,
@ -444,7 +444,7 @@ module Astute
]
},
'puppet-log-components-list-multinode_compute-compute' =>
'puppet-log-components-list-multinode-compute' =>
{'type' => 'components-list',
'endlog_patterns' => [{'pattern' => /Finished catalog run in [0-9]+\.[0-9]* seconds\n/, 'progress' => 1.0}],
'chunk_size' => 40000,
@ -498,4 +498,4 @@ module Astute
}
end
end
end
end

View File

@ -234,7 +234,7 @@ describe LogParser do
{'uid' => '2', 'ip' => '1.0.0.2', 'fqdn' => 'slave-2.domain.tld', 'role' => 'compute', 'src_filename' => 'puppet-agent.log.ha.compute'},
]
calculated_nodes = deployment_parser_wrapper('ha_compute', nodes)
calculated_nodes = deployment_parser_wrapper('ha', nodes)
calculated_nodes.each {|node| node['statistics']['pcc'].should > 0.85}
# For debug purposes.
@ -249,7 +249,7 @@ describe LogParser do
{'uid' => '1', 'ip' => '1.0.0.1', 'fqdn' => 'slave-1.domain.tld', 'role' => 'controller', 'src_filename' => 'puppet-agent.log.singlenode'},
]
calculated_nodes = deployment_parser_wrapper('singlenode_compute', nodes)
calculated_nodes = deployment_parser_wrapper('singlenode', nodes)
calculated_nodes.each {|node| node['statistics']['pcc'].should > 0.97}
end
@ -259,7 +259,7 @@ describe LogParser do
{'uid' => '2', 'ip' => '1.0.0.2', 'fqdn' => 'slave-2.domain.tld', 'role' => 'compute', 'src_filename' => 'puppet-agent.log.multi.compute'},
]
calculated_nodes = deployment_parser_wrapper('multinode_compute', nodes)
calculated_nodes = deployment_parser_wrapper('multinode', nodes)
calculated_nodes.each {|node| node['statistics']['pcc'].should > 0.94}
end

View File

@ -114,7 +114,7 @@ describe "NailyFact DeploymentEngine" do
"role" => "controller"}]
@data_ha = Marshal.load(Marshal.dump(@data))
@data_ha['args']['nodes'] = ha_nodes
@data_ha['args']['attributes']['deployment_mode'] = "ha_compute"
@data_ha['args']['attributes']['deployment_mode'] = "ha"
# VIPs are required for HA mode and should be passed from Nailgun (only in HA)
@data_ha['args']['attributes']['management_vip'] = "192.168.0.111"
@data_ha['args']['attributes']['public_vip'] = "240.0.1.111"
@ -122,11 +122,11 @@ describe "NailyFact DeploymentEngine" do
it "it should call valid method depends on attrs" do
nodes = [{'uid' => 1}]
attrs = {'deployment_mode' => 'ha_compute'}
attrs = {'deployment_mode' => 'ha'}
attrs_modified = attrs.merge({'some' => 'somea'})
@deploy_engine.expects(:attrs_ha_compute).with(nodes, attrs).returns(attrs_modified)
@deploy_engine.expects(:deploy_ha_compute).with(nodes, attrs_modified)
@deploy_engine.expects(:attrs_ha).with(nodes, attrs).returns(attrs_modified)
@deploy_engine.expects(:deploy_ha).with(nodes, attrs_modified)
# All implementations of deploy_piece go to subclasses
@deploy_engine.respond_to?(:deploy_piece).should be_true
@deploy_engine.deploy(nodes, attrs)
@ -138,8 +138,8 @@ describe "NailyFact DeploymentEngine" do
expect {@deploy_engine.deploy(nodes, attrs)}.to raise_exception(/Method attrs_unknown is not implemented/)
end
it "multinode_compute deploy should not raise any exception" do
@data['args']['attributes']['deployment_mode'] = "multinode_compute"
it "multinode deploy should not raise any exception" do
@data['args']['attributes']['deployment_mode'] = "multinode"
Astute::Metadata.expects(:publish_facts).times(@data['args']['nodes'].size)
# we got two calls, one for controller, and another for all computes
controller_nodes = @data['args']['nodes'].select{|n| n['role'] == 'controller'}
@ -149,7 +149,7 @@ describe "NailyFact DeploymentEngine" do
@deploy_engine.deploy(@data['args']['nodes'], @data['args']['attributes'])
end
it "ha_compute deploy should not raise any exception" do
it "ha deploy should not raise any exception" do
Astute::Metadata.expects(:publish_facts).at_least_once
controller_nodes = @data_ha['args']['nodes'].select{|n| n['role'] == 'controller'}
compute_nodes = @data_ha['args']['nodes'].select{|n| n['role'] == 'compute'}
@ -164,15 +164,15 @@ describe "NailyFact DeploymentEngine" do
@deploy_engine.deploy(@data_ha['args']['nodes'], @data_ha['args']['attributes'])
end
it "ha_compute deploy should not raise any exception if there are only one controller" do
it "ha deploy should not raise any exception if there are only one controller" do
Astute::Metadata.expects(:publish_facts).at_least_once
Astute::PuppetdDeployer.expects(:deploy).times(5)
ctrl = @data_ha['args']['nodes'].select {|n| n['role'] == 'controller'}[0]
@deploy_engine.deploy([ctrl], @data_ha['args']['attributes'])
end
it "singlenode_compute deploy should not raise any exception" do
@data['args']['attributes']['deployment_mode'] = "singlenode_compute"
it "singlenode deploy should not raise any exception" do
@data['args']['attributes']['deployment_mode'] = "singlenode"
@data['args']['nodes'] = [@data['args']['nodes'][0]] # We have only one node in singlenode
Astute::Metadata.expects(:publish_facts).times(@data['args']['nodes'].size)
Astute::PuppetdDeployer.expects(:deploy).with(@ctx, @data['args']['nodes'], instance_of(Fixnum), true).once

View File

@ -16,9 +16,9 @@ describe "SimplePuppet DeploymentEngine" do
it "it should call valid method depends on attrs" do
nodes = [{'uid' => 1}]
attrs = {'deployment_mode' => 'ha_compute'}
@deploy_engine.expects(:attrs_ha_compute).never # It is not supported in SimplePuppet
@deploy_engine.expects(:deploy_ha_compute).with(nodes, attrs)
attrs = {'deployment_mode' => 'ha'}
@deploy_engine.expects(:attrs_ha).never # It is not supported in SimplePuppet
@deploy_engine.expects(:deploy_ha).with(nodes, attrs)
# All implementations of deploy_piece go to subclasses
@deploy_engine.respond_to?(:deploy_piece).should be_true
@deploy_engine.deploy(nodes, attrs)
@ -31,23 +31,23 @@ describe "SimplePuppet DeploymentEngine" do
/Method deploy_unknown is not implemented/)
end
it "multinode_compute deploy should not raise any exception" do
@env['attributes']['deployment_mode'] = "multinode_compute"
it "multinode deploy should not raise any exception" do
@env['attributes']['deployment_mode'] = "multinode"
Astute::Metadata.expects(:publish_facts).never # It is not supported in SimplePuppet
# we got two calls, one for controller, and another for all computes
Astute::PuppetdDeployer.expects(:deploy).twice
@deploy_engine.deploy(@env['nodes'], @env['attributes'])
end
it "ha_compute deploy should not raise any exception" do
@env['attributes']['deployment_mode'] = "ha_compute"
it "ha deploy should not raise any exception" do
@env['attributes']['deployment_mode'] = "ha"
Astute::Metadata.expects(:publish_facts).never
Astute::PuppetdDeployer.expects(:deploy).times(6)
@deploy_engine.deploy(@env['nodes'], @env['attributes'])
end
it "singlenode_compute deploy should not raise any exception" do
@env['attributes']['deployment_mode'] = "singlenode_compute"
it "singlenode deploy should not raise any exception" do
@env['attributes']['deployment_mode'] = "singlenode"
@env['nodes'] = [@env['nodes'][0]] # We have only one node in singlenode
Astute::Metadata.expects(:publish_facts).never
Astute::PuppetdDeployer.expects(:deploy).once # one call for one node

View File

@ -28,7 +28,7 @@ class TestHandlers(BaseHandlers):
)
cluster_db = self.env.clusters[0]
cluster_depl_mode = 'ha_compute'
cluster_depl_mode = 'ha'
nailgun.task.task.Cobbler = Mock()
supertask = self.env.launch_deployment()