Added missing tests and checked existing ones

Partial-Bug: #1328999
Implements: blueprint add-template-tests

Change-Id: I19e49bde3d8dd9c195a0aee7f671c07428cce1a2
This commit is contained in:
Federico Gimenez Nieto 2014-07-23 19:20:36 +02:00
parent ced678f875
commit cedf3540cf
5 changed files with 97 additions and 54 deletions

View File

@ -42,6 +42,10 @@ describe 'openstack-network::dhcp_agent' do
mode: 0644
)
end
it_behaves_like 'dhcp agent template configurator' do
let(:file_name) { file.name }
end
end
describe '/etc/neutron/dnsmasq.conf' do
@ -54,6 +58,10 @@ describe 'openstack-network::dhcp_agent' do
mode: 0644
)
end
it_behaves_like 'dnsmasq template configurator' do
let(:file_name) { file.name }
end
end
end
end

View File

@ -73,35 +73,8 @@ describe 'openstack-network::dhcp_agent' do
)
end
it 'uses ovs driver' do
expect(chef_run).to render_file(file.name).with_content(
'interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver')
end
it 'uses namespaces' do
expect(chef_run).to render_file(file.name).with_content('use_namespaces = True')
end
it 'disables ovs_use_veth' do
expect(chef_run).to render_file(file.name).with_content('ovs_use_veth = False')
end
it 'checks dhcp domain' do
expect(chef_run).to render_file(file.name).with_content(/^dhcp_domain = openstacklocal$/)
end
it 'has default dnsmasq_lease_max setting' do
expect(chef_run).to render_file(file.name).with_content(/^dnsmasq_lease_max = 16777216$/)
end
it 'has default dhcp_delete_namespaces setting' do
expect(chef_run).to render_file(file.name).with_content(/^dhcp_delete_namespaces = False$/)
end
it 'has configurable dnsmasq_lease_max setting' do
node.set['openstack']['network']['dhcp']['dnsmasq_lease_max'] = 16777215
expect(chef_run).to render_file(file.name).with_content(/^dnsmasq_lease_max = 16777215$/)
it_behaves_like 'dhcp agent template configurator' do
let(:file_name) { file.name }
end
it 'notifies the dhcp agent service' do
@ -120,13 +93,8 @@ describe 'openstack-network::dhcp_agent' do
)
end
it 'overrides dhcp options' do
expect(chef_run).to render_file(file.name).with_content('dhcp-option=26,1454')
end
it 'checks upstream resolvers' do
expect(chef_run).to render_file(file.name).with_content(/^server=209.244.0.3$/)
expect(chef_run).to render_file(file.name).with_content(/^server=8.8.8.8$/)
it_behaves_like 'dnsmasq template configurator' do
let(:file_name) { file.name }
end
it 'notifies the dhcp agent service' do

View File

@ -44,32 +44,39 @@ describe 'openstack-network::l3_agent' do
)
end
it 'it has ovs driver' do
expect(chef_run).to render_file(file.name).with_content(
'interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver')
end
context 'template contents' do
it_behaves_like 'custom template banner displayer' do
let(:file_name) { file.name }
end
it 'sets fuzzy delay to default' do
expect(chef_run).to render_file(file.name).with_content(
'periodic_fuzzy_delay = 5')
end
it_behaves_like 'common network attributes displayer' do
let(:file_name) { file.name }
end
it 'it does not set a nil router_id' do
expect(chef_run).not_to render_file(file.name).with_content(/^router_id =/)
end
%w[handle_internal_only_routers external_network_bridge metadata_port send_arp_for_ha
periodic_interval periodic_fuzzy_delay router_delete_namespaces].each do |attr|
it "displays the #{attr} l3 attribute" do
node.set['openstack']['network']['l3'][attr] = "network_l3_#{attr}_value"
expect(chef_run).to render_file(file.name).with_content(/^#{attr} = network_l3_#{attr}_value$/)
end
end
it 'it does not set a nil router_id' do
expect(chef_run).not_to render_file(file.name).with_content(
/^gateway_external_network_id =/)
%w[router_id gateway_external_network_id].each do |conditional_attr|
it "displays the #{conditional_attr} attribute when present" do
node.set['openstack']['network']['l3'][conditional_attr] = "network_l3_#{conditional_attr}_value"
expect(chef_run).to render_file(file.name).with_content(/^#{conditional_attr} = network_l3_#{conditional_attr}_value$/)
end
it "does not display the #{conditional_attr} attribute if not set" do
node.set['openstack']['network']['l3'][conditional_attr] = nil
expect(chef_run).not_to render_file(file.name).with_content(/^#{conditional_attr} = /)
end
end
end
it 'notifies the l3 agent service' do
expect(file).to notify('service[neutron-l3-agent]').to(:restart).immediately
end
it 'has default router_delete_namespaces setting' do
expect(chef_run).to render_file(file.name).with_content(/^router_delete_namespaces = False$/)
end
end
describe 'create ovs bridges' do

View File

@ -75,6 +75,10 @@ describe 'openstack-network::server' do
mode: 0640
)
end
it_behaves_like 'custom template banner displayer' do
let(:file_name) { file.name }
end
end
describe 'neutron-ha-tool.py' do

View File

@ -91,3 +91,59 @@ shared_context 'neutron-stubs' do
stub_command('ip link show eth1').and_return(false)
end
end
shared_examples 'custom template banner displayer' do
it 'shows the custom banner' do
node.set['openstack']['network']['custom_template_banner'] = 'custom_template_banner_value'
expect(chef_run).to render_file(file_name).with_content(/^custom_template_banner_value$/)
end
end
shared_examples 'common network attributes displayer' do
%w[debug interface_driver use_namespaces].each do |attr|
it "displays the #{attr} common attribute" do
node.set['openstack']['network'][attr] = "network_#{attr}_value"
expect(chef_run).to render_file(file_name).with_content(/^#{attr} = network_#{attr}_value$/)
end
end
end
shared_examples 'dhcp agent template configurator' do
it_behaves_like 'custom template banner displayer'
it_behaves_like 'common network attributes displayer'
it 'displays the dhcp driver attribute' do
node.set['openstack']['network']['dhcp_driver'] = 'network_dhcp_driver_value'
expect(chef_run).to render_file(file_name).with_content(/^dhcp_driver = network_dhcp_driver_value$/)
end
%w[resync_interval ovs_use_veth enable_isolated_metadata
enable_metadata_network dnsmasq_lease_max dhcp_delete_namespaces].each do |attr|
it "displays the #{attr} dhcp attribute" do
node.set['openstack']['network']['dhcp'][attr] = "network_dhcp_#{attr}_value"
expect(chef_run).to render_file(file_name).with_content(/^#{attr} = network_dhcp_#{attr}_value$/)
end
end
it 'displays the dhcp_domain attribute' do
node.set['openstack']['network']['dhcp']['default_domain'] = 'network_dhcp_domain_value'
expect(chef_run).to render_file(file_name).with_content(/^dhcp_domain = network_dhcp_domain_value$/)
end
end
shared_examples 'dnsmasq template configurator' do
it_behaves_like 'custom template banner displayer'
it 'displays the dhcp-option attribute' do
node.set['openstack']['network']['dhcp']['dhcp-option'] = 'dhcp-option_value'
expect(chef_run).to render_file(file_name).with_content(/^dhcp-option=dhcp-option_value$/)
end
it 'displays the upstream dns servers setting' do
node.set['openstack']['network']['dhcp']['upstream_dns_servers'] = %w[server0 server1]
node['openstack']['network']['dhcp']['upstream_dns_servers'].each do |dns_server|
expect(chef_run).to render_file(file_name).with_content(/^server=#{dns_server}$/)
end
end
end