Fix noops tests for the new network variables

* Refactor old noop tests to support flexible network data
* Repair puppet function helper
* Script to remove old external modules before updating them
* network_config_prepared function to check if network
  scheme is already loaded

Change-Id: Ie2e7e2a8a7fbfa32a4172e018acba6e955973425
Closes-Bug: 1486048
Fuel-CI: disable
This commit is contained in:
Dmitry Ilyin 2015-08-24 20:36:44 +03:00
parent 3864463078
commit 63eb7faf69
7 changed files with 516 additions and 357 deletions

View File

@ -5,40 +5,69 @@ manifest = 'horizon/horizon.pp'
describe manifest do
shared_examples 'catalog' do
bind_address = Noop.node_hash['internal_address'] # TODO: smakar change AFTER https://bugs.launchpad.net/fuel/+bug/1486048
nova_quota = Noop.hiera 'nova_quota'
management_vip = Noop.hiera('management_vip')
keystone_url = "http://#{management_vip}:5000/v2.0"
cache_options = nil
cache_options = {'SOCKET_TIMEOUT' => 1,'SERVER_RETRIES' => 1,'DEAD_RETRY' => 1}
neutron_advanced_config = Noop.hiera_structure 'neutron_advanced_configuration'
let(:network_scheme) do
Noop.hiera_hash 'network_scheme'
end
let(:service_endpoint) do
Noop.hiera 'service_endpoint'
end
let(:prepare) do
Noop.puppet_function 'prepare_network_config', network_scheme
end
let(:bind_address) do
prepare
Noop.puppet_function 'get_network_role_property', 'horizon', 'ipaddr'
end
let(:nova_quota) do
Noop.hiera 'nova_quota'
end
let(:keystone_url) do
"http://#{service_endpoint}:5000/v2.0"
end
let(:cache_options) do
{
'SOCKET_TIMEOUT' => 1,
'SERVER_RETRIES' => 1,
'DEAD_RETRY' => 1,
}
end
###########################################################################
# Horizon
it 'should declare openstack::horizon class' do
should contain_class('openstack::horizon').with(
'nova_quota' => nova_quota,
'bind_address' => bind_address,
)
'nova_quota' => nova_quota,
'bind_address' => bind_address
)
end
it 'should declare openstack::horizon class with keystone_url' do
should contain_class('openstack::horizon').with('keystone_url' => keystone_url)
should contain_class('openstack::horizon').with(
'keystone_url' => keystone_url
)
end
it 'should declare horizon class with cache_backend,cache_options,log_handler' do
should contain_class('horizon').with(
'cache_backend' => 'horizon.backends.memcached.HorizonMemcached',
'cache_options' => cache_options,
'log_handler' => 'file',
)
should contain_class('horizon').with(
'cache_backend' => 'horizon.backends.memcached.HorizonMemcached',
'cache_options' => cache_options,
'log_handler' => 'file'
)
end
if neutron_advanced_config && neutron_advanced_config.has_key?('neutron_dvr')
dvr = neutron_advanced_config['neutron_dvr']
context 'with Neutron DVR', :if => Noop.hiera_structure('neutron_advanced_configuration/neutron_dvr') do
it 'should configure horizon for neutron DVR' do
should contain_class('openstack::horizon').with(
'neutron_options' => {'enable_distributed_router' => dvr},
)
should contain_class('openstack::horizon').with(
'neutron_options' => {
'enable_distributed_router' => Noop.hiera_structure('neutron_advanced_configuration/neutron_dvr')
}
)
end
end
@ -62,6 +91,7 @@ describe manifest do
}
end
test_ubuntu_and_centos manifest
end

View File

@ -4,24 +4,26 @@ manifest = 'murano/keystone.pp'
describe manifest do
shared_examples 'catalog' do
public_ip = Noop.hiera('public_vip')
internal_address = Noop.hiera('management_vip', public_ip)
service_endpoint = Noop.hiera('service_endpoint', internal_address)
public_ssl = Noop.hiera_structure('public_ssl/services')
api_bind_port = '8082'
if public_ssl
public_protocol = 'https'
public_address = Noop.hiera_structure('public_ssl/hostname')
else
public_protocol = 'http'
public_address = public_ip
end
murano_password = Noop.hiera_structure('murano_hash/user_password')
tenant = Noop.hiera_structure('murano_hash/tenant', 'services')
region = Noop.hiera('region', 'RegionOne')
public_url = "#{public_protocol}://#{public_address}:#{api_bind_port}"
admin_url = "http://#{service_endpoint}:#{api_bind_port}"
let(:service_endpoint) { Noop.hiera 'service_endpoint' }
let(:network_scheme) { Noop.hiera_hash 'network_scheme' }
let(:public_vip) { Noop.hiera 'public_vip' }
let(:public_ssl) { Noop.hiera_structure('public_ssl/services') }
let(:public_ssl_hostname) { Noop.hiera_structure('public_ssl/hostname') }
let(:api_bind_port) { '8082' }
let(:admin_url) { "http://#{service_endpoint}:#{api_bind_port}" }
let(:public_url) { "#{public_protocol}://#{public_address}:#{api_bind_port}" }
let(:public_protocol) { public_ssl ? 'https' : 'http' }
let(:public_address) { public_ssl ? public_ssl_hostname : public_vip }
let(:region) { Noop.hiera('region', 'RegionOne') }
let(:tenant) { Noop.hiera_structure('murano_hash/tenant', 'services') }
let(:murano_password) { Noop.hiera_structure('murano_hash/user_password') }
##########################################################################
it 'should declare murano::keystone::auth class correctly' do
should contain_class('murano::keystone::auth').with(
@ -31,9 +33,10 @@ describe manifest do
'tenant' => tenant,
'public_url' => public_url,
'admin_url' => admin_url,
'internal_url' => admin_url,
'internal_url' => admin_url
)
end
end
test_ubuntu_and_centos manifest
end

View File

@ -5,73 +5,86 @@ manifest = 'murano/murano.pp'
describe manifest do
shared_examples 'catalog' do
murano_user = Noop.hiera_structure('murano_hash/user', 'murano')
murano_password = Noop.hiera_structure('murano_hash/user_password')
murano_enabled = Noop.hiera_structure('murano_hash/enabled')
tenant = Noop.hiera_structure('murano_hash/tenant', 'services')
rabbit_os_user = Noop.hiera_structure('rabbit_hash/user')
rabbit_os_password = Noop.hiera_structure('rabbit_hash/password')
rabbit_own_password = Noop.hiera_structure('heat_hash/rabbit_password')
node_role = Noop.hiera('node_role')
public_ip = Noop.hiera('public_vip')
management_ip = Noop.hiera('management_vip')
bind_address = Noop.hiera('internal_address') # TODO: smakar change AFTER https://bugs.launchpad.net/fuel/+bug/1486048
region = Noop.hiera('region', 'RegionOne')
use_neutron = Noop.hiera('use_neutron', false)
service_endpoint = Noop.hiera('service_endpoint', management_ip)
syslog_log_facility_murano = Noop.hiera('syslog_log_facility_murano')
debug = Noop.hiera('debug', false)
verbose = Noop.hiera('verbose', true)
use_syslog = Noop.hiera('use_syslog', true)
rabbit_ha_queues = Noop.hiera('rabbit_ha_queues')
amqp_port = Noop.hiera('amqp_port')
amqp_hosts = Noop.hiera('amqp_hosts')
public_ssl = Noop.hiera_structure('public_ssl/services')
let(:murano_user) { Noop.hiera_structure('murano/user', 'murano') }
let(:murano_password) { Noop.hiera_structure('murano/user_password') }
let(:tenant) { Noop.hiera_structure('murano/tenant', 'services') }
let(:rabbit_os_user) { Noop.hiera_structure('rabbit/user', 'nova') }
let(:rabbit_os_password) { Noop.hiera_structure('rabbit/password') }
let(:rabbit_own_password) { Noop.hiera_structure('heat/rabbit_password') }
db_user = Noop.hiera_structure('murano_hash/db_user', 'murano')
db_name = Noop.hiera_structure('murano_hash/db_name', 'murano')
db_host = Noop.hiera_structure('murano_hash/db_host', management_ip)
db_password = Noop.hiera_structure('murano_hash/db_password')
let(:network_scheme) do
Noop.hiera_hash 'network_scheme'
end
predefined_networks = Noop.hiera_structure('neutron_config/predefined_networks')
repository_url = Noop.hiera_structure('murano_settings/murano_repo_url')
let(:prepare) do
Noop.puppet_function 'prepare_network_config', network_scheme
end
if murano_enabled
api_bind_port = '8082'
api_bind_host = bind_address
let(:public_ip) do
Noop.hiera 'public_vip'
end
internal_url = "http://#{api_bind_host}:#{api_bind_port}"
let(:bind_address) do
prepare
Noop.puppet_function 'get_network_role_property', 'murano/api', 'ipaddr'
end
read_timeout = '60'
sql_connection = "mysql://#{db_user}:#{db_password}@#{db_host}/#{db_name}?read_timeout=#{read_timeout}"
let(:region) { Noop.hiera('region', 'RegionOne') }
let(:use_neutron) { Noop.hiera('use_neutron', false) }
let(:service_endpoint) { Noop.hiera('service_endpoint') }
let(:syslog_log_facility_murano) { Noop.hiera('syslog_log_facility_murano') }
let(:debug) { Noop.hiera('debug', false) }
let(:verbose) { Noop.hiera('verbose', true) }
let(:use_syslog) { Noop.hiera('use_syslog', true) }
let(:rabbit_ha_queues) { Noop.hiera('rabbit_ha_queues') }
let(:amqp_port) { Noop.hiera('amqp_port') }
let(:amqp_hosts) { Noop.hiera('amqp_hosts') }
let(:public_ssl) { Noop.hiera_structure('public_ssl/services') }
if public_ssl
public_protocol = 'https'
public_address = Noop.hiera_structure('public_ssl/hostname')
else
public_protocol = 'http'
public_address = public_ip
end
let(:db_user) { Noop.hiera_structure('murano/db_user', 'murano') }
let(:db_name) { Noop.hiera_structure('murano/db_name', 'murano') }
let(:db_host) { Noop.hiera_structure('murano/db_host', service_endpoint) }
let(:db_password) { Noop.hiera_structure('murano/db_password') }
let(:predefined_networks) { Noop.hiera_structure('neutron_config/predefined_networks') }
let(:default_repository_url) { 'http://storage.apps.openstack.org' }
let(:repository_url) { Noop.hiera_structure('murano_settings/murano_repo_url', default_repository_url) }
let(:api_bind_port) { '8082' }
let(:internal_url) { "http://#{bind_address}:#{api_bind_port}" }
let(:sql_connection) do
read_timeout = '60'
"mysql://#{db_user}:#{db_password}@#{db_host}/#{db_name}?read_timeout=#{read_timeout}"
end
let(:public_ssl_hostname) do
Noop.hiera_structure('public_ssl/hostname')
end
let(:public_protocol) { public_ssl ? 'https' : 'http' }
let(:public_address) { public_ssl ? public_ssl_hostname : public_ip }
let(:external_network) do
if use_neutron
external_network = Noop.puppet_function 'get_ext_net_name', predefined_networks
Noop.puppet_function 'get_ext_net_name', predefined_networks
else
external_network = nil
nil
end
end
if repository_url
apps_repository = repository_url
else
apps_repository = 'http://storage.apps.openstack.org'
end
#############################################################################
enable = Noop.hiera_structure('murano/enabled')
context 'if murano is enabled', :if => enable do
it 'should declare murano class correctly' do
should contain_class('murano').with(
'verbose' => verbose,
'debug' => debug,
'use_syslog' => use_syslog,
'use_stderr' => 'false',
'log_facility' => syslog_log_facility_murano,
'verbose' => verbose,
'debug' => debug,
'use_syslog' => use_syslog,
'use_stderr' => 'false',
'log_facility' => syslog_log_facility_murano,
'database_connection' => sql_connection,
'keystone_uri' => "#{public_protocol}://#{public_address}:5000/v2.0/",
'keystone_username' => murano_user,
@ -88,16 +101,16 @@ describe manifest do
'rabbit_own_port' => '55572',
'rabbit_own_user' => 'murano',
'rabbit_own_password' => rabbit_own_password,
'service_host' => api_bind_host,
'service_port' => api_bind_port,
'external_network' => external_network,
'service_host' => bind_address,
'service_port' => api_bind_port,
'external_network' => external_network
)
end
it 'should declare murano::api class correctly' do
should contain_class('murano::api').with(
'host' => api_bind_host,
'port' => api_bind_port,
'host' => bind_address,
'port' => api_bind_port
)
end
@ -111,36 +124,47 @@ describe manifest do
it 'should declare murano::dashboard class correctly' do
should contain_class('murano::dashboard').with(
'api_url' => internal_url,
'repo_url' => apps_repository,
'api_url' => internal_url,
'repo_url' => repository_url
)
end
it 'should declare murano::rabbitmq class correctly' do
should contain_class('murano::rabbitmq').with(
'rabbit_user' => 'murano',
'rabbit_user' => 'murano',
'rabbit_password' => rabbit_own_password,
'rabbit_port' => '55572',
'rabbit_port' => '55572'
)
end
if node_role == 'primary-controller'
enable = (Noop.hiera_structure('murano/enabled') and Noop.hiera('node_role') == 'primary-controller')
context 'on primary controller', :if => enable do
it 'should declare murano::application resource correctly' do
should contain_murano__application('io.murano').with(
'os_tenant_name' => tenant,
'os_username' => murano_user,
'os_password' => murano_password,
'os_auth_url' => "#{public_protocol}://#{public_address}:5000/v2.0/",
'os_region' => region,
'mandatory' => true,
'os_username' => murano_user,
'os_password' => murano_password,
'os_auth_url' => "#{public_protocol}://#{public_address}:5000/v2.0/",
'os_region' => region,
'mandatory' => true
)
end
it { should contain_haproxy_backend_status('keystone-public').that_comes_before('Haproxy_backend_status[murano-api]') }
it { should contain_haproxy_backend_status('keystone-admin').that_comes_before('Haproxy_backend_status[murano-api]') }
it { should contain_haproxy_backend_status('murano-api').that_comes_before('Murano::Application[io.murano]') }
it {
should contain_haproxy_backend_status('keystone-public').that_comes_before('Haproxy_backend_status[murano-api]')
}
it {
should contain_haproxy_backend_status('keystone-admin').that_comes_before('Haproxy_backend_status[murano-api]')
}
it {
should contain_haproxy_backend_status('murano-api').that_comes_before('Murano::Application[io.murano]')
}
end
end
end
test_ubuntu_and_centos manifest
end

View File

@ -3,17 +3,64 @@ require 'shared-examples'
manifest = 'openstack-network/openstack-network-compute.pp'
describe manifest do
shared_examples 'catalog' do
# TODO All this stuff should be moved to shared examples controller* tests.
let(:network_scheme) do
Noop.hiera_hash 'network_scheme'
end
metadata_host = Noop.node_hash['internal_address'] # TODO: smakar change AFTER https://bugs.launchpad.net/fuel/+bug/1486048
use_neutron = Noop.hiera 'use_neutron'
let(:prepare) do
Noop.puppet_function 'prepare_network_config', network_scheme
end
let(:metadata_host) do
prepare
Noop.puppet_function 'get_network_role_property', 'mgmt/vip', 'ipaddr'
end
let(:neutron_dvr) do
Noop.hiera_structure 'neutron_advanced_configuration/neutron_dvr'
end
let(:neutron_l2_pop) do
Noop.hiera_structure 'neutron_advanced_configuration/neutron_l2_pop'
end
let(:segmentation_type) do
Noop.hiera_structure 'neutron_config/L2/segmentation_type'
end
let(:use_gre_for_tun) do
Noop.hiera_structure 'neutron_config/L2/use_gre_for_tun'
end
let(:tunnel_id_ranges) do
Noop.hiera_structure 'neutron_config/L2/tunnel_id_ranges'
end
let(:tunnel_types) do
if use_gre_for_tun
['gre']
else
['vxlan']
end
end
let(:tenant_network_types) do
if use_gre_for_tun
%w(flat vlan gre)
else
%w(flat vlan vxlan)
end
end
############################################################################
it 'should declare openstack::network with use_stderr disabled' do
should contain_class('openstack::network').with(
'use_stderr' => 'false',
)
'use_stderr' => 'false'
)
end
it 'should apply kernel tweaks for connections' do
@ -22,18 +69,19 @@ describe manifest do
should contain_sysctl__value('net.ipv4.neigh.default.gc_thresh3').with_value('4096')
end
# Network
if use_neutron
enable = Noop.hiera('use_neutron')
context 'with Neutron', :if => enable do
it 'should declare openstack::network with neutron_server parameter set to false' do
should contain_class('openstack::network').with(
'neutron_server' => 'false',
)
'neutron_server' => 'false'
)
end
it 'should pass auth region to openstack::network' do
should contain_class('openstack::network').with(
'region' => 'RegionOne',
)
'region' => 'RegionOne'
)
end
it 'should configure report_interval for neutron' do
@ -44,167 +92,168 @@ describe manifest do
it 'should configure auth region for neutron-agents' do
should contain_class('openstack::network::neutron_agents').with(
'auth_region' => 'RegionOne',
)
'auth_region' => 'RegionOne'
)
end
it 'should declare neutron::agents::ml2::ovs with drop_flows_on_start disabled' do
should contain_class('neutron::agents::ml2::ovs').with(
'drop_flows_on_start' => 'false',
)
end
else
it 'should declare openstack::network with neutron_server parameter set to false' do
should contain_class('openstack::network').with(
'neutron_server' => 'false',
)
end
end
if use_neutron
it 'should wait for integration bridge' do
should contain_exec('wait-for-int-br').with(
'command' => 'ovs-vsctl br-exists br-int',
)
'command' => 'ovs-vsctl br-exists br-int'
)
end
it { should contain_class('openstack::network').that_comes_before('Exec[wait-for-int-br]') }
it { should contain_exec('wait-for-int-br').that_comes_before('Service[nova-compute]') }
it {
should contain_class('openstack::network').that_comes_before('Exec[wait-for-int-br]')
}
it {
should contain_exec('wait-for-int-br').that_comes_before('Service[nova-compute]')
}
it 'should remove default libvirt network' do
should contain_exec('destroy_libvirt_default_network').with(
'command' => 'virsh net-destroy default',
'onlyif' => 'virsh net-info default | grep -qE "Active:.* yes"',
'path' => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin' ],
'tries' => 3,
'require' => 'Service[libvirt]',
)
'command' => 'virsh net-destroy default',
'onlyif' => 'virsh net-info default | grep -qE "Active:.* yes"',
'path' => ['/bin', '/sbin', '/usr/bin', '/usr/sbin'],
'tries' => 3,
'require' => 'Service[libvirt]'
)
should contain_exec('undefine_libvirt_default_network').with(
'command' => 'virsh net-undefine default',
'onlyif' => 'virsh net-info default 2>&1 > /dev/null',
'path' => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin' ],
'tries' => 3,
'require' => 'Exec[destroy_libvirt_default_network]',
)
'command' => 'virsh net-undefine default',
'onlyif' => 'virsh net-info default 2>&1 > /dev/null',
'path' => ['/bin', '/sbin', '/usr/bin', '/usr/sbin'],
'tries' => 3,
'require' => 'Exec[destroy_libvirt_default_network]'
)
should contain_service('libvirt').that_notifies('Exec[destroy_libvirt_default_network]')
end
it 'should configure libvirt for qemu' do
should contain_file_line('clear_emulator_capabilities').with(
'path' => '/etc/libvirt/qemu.conf',
'line' => 'clear_emulator_capabilities = 0',
)
'path' => '/etc/libvirt/qemu.conf',
'line' => 'clear_emulator_capabilities = 0'
)
should contain_file_line('no_qemu_selinux').with(
'path' => '/etc/libvirt/qemu.conf',
'line' => 'security_driver = "none"',
)
'path' => '/etc/libvirt/qemu.conf',
'line' => 'security_driver = "none"'
)
end
it 'should configure linuxnet_interface_driver and linuxnet_ovs_integration_bridge' do
should contain_nova_config('DEFAULT/linuxnet_interface_driver').with(
'value' => 'nova.network.linux_net.LinuxOVSInterfaceDriver',
)
'value' => 'nova.network.linux_net.LinuxOVSInterfaceDriver'
)
should contain_nova_config('DEFAULT/linuxnet_ovs_integration_bridge').with(
'value' => 'br-int',
)
'value' => 'br-int'
)
end
it 'should configure net.bridge.bridge* keys that come before libvirt service' do
should contain_augeas('sysctl-net.bridge.bridge-nf-call-arptables').with(
'context' => '/files/etc/sysctl.conf',
'changes' => "set net.bridge.bridge-nf-call-arptables '1'",
).that_comes_before('Service[libvirt]')
'context' => '/files/etc/sysctl.conf',
'changes' => "set net.bridge.bridge-nf-call-arptables '1'"
).that_comes_before('Service[libvirt]')
should contain_augeas('sysctl-net.bridge.bridge-nf-call-iptables').with(
'context' => '/files/etc/sysctl.conf',
'changes' => "set net.bridge.bridge-nf-call-iptables '1'",
).that_comes_before('Service[libvirt]')
'context' => '/files/etc/sysctl.conf',
'changes' => "set net.bridge.bridge-nf-call-iptables '1'"
).that_comes_before('Service[libvirt]')
should contain_augeas('sysctl-net.bridge.bridge-nf-call-ip6tables').with(
'context' => '/files/etc/sysctl.conf',
'changes' => "set net.bridge.bridge-nf-call-ip6tables '1'",
).that_comes_before('Service[libvirt]')
'context' => '/files/etc/sysctl.conf',
'changes' => "set net.bridge.bridge-nf-call-ip6tables '1'"
).that_comes_before('Service[libvirt]')
end
neutron_config = Noop.hiera_structure 'quantum_settings'
neutron_advanced_config = Noop.hiera_structure 'neutron_advanced_configuration'
enable = Noop.hiera_structure('neutron_advanced_configuration/neutron_dvr')
context 'with neutron_dvr', :if => enable do
if neutron_advanced_config && neutron_advanced_config.has_key?('neutron_dvr')
dvr = neutron_advanced_config['neutron_dvr']
it 'should configure neutron DVR' do
should contain_class('openstack::network').with(
'dvr' => dvr,
)
should contain_class('openstack::network').with(
'dvr' => neutron_dvr
)
end
if dvr
it 'should set dvr mode for neutron l3 agent' do
should contain_class('openstack::network::neutron_agents').with(
'agent_mode' => 'dvr',
)
end
it 'should set dvr mode for neutron l3 agent' do
should contain_class('openstack::network::neutron_agents').with(
'agent_mode' => 'dvr'
)
end
end
if neutron_advanced_config && neutron_advanced_config.has_key?('neutron_l2_pop')
l2_pop = neutron_advanced_config['neutron_l2_pop']
it 'should configure neutron L2 population' do
should contain_class('openstack::network').with(
'l2_population' => l2_pop,
)
end
end
if neutron_config && neutron_config.has_key?('L2') && neutron_config['L2']['segmentation_type'] != 'vlan'
tunnel_id_ranges = [neutron_config['L2']['tunnel_id_ranges']]
if neutron_config['L2']['segmentation_type'] == 'gre'
tenant_network_types = ['flat', 'vlan', 'gre']
tunnel_types = ['gre']
else
tenant_network_types = ['flat', 'vlan', 'vxlan']
tunnel_types = ['vxlan']
end
it 'should configure tunnel_types for neutron and set net_mtu' do
should contain_class('openstack::network').with(
'tunnel_types' => tunnel_types,
'tunnel_id_ranges' => tunnel_id_ranges,
'vni_ranges' => tunnel_id_ranges,
'tenant_network_types' => tenant_network_types,
'net_mtu' => 1500,
'network_device_mtu' => 1450,
)
should contain_class('neutron::plugins::ml2').with(
'tunnel_id_ranges' => tunnel_id_ranges,
'vni_ranges' => tunnel_id_ranges,
'tenant_network_types' => tenant_network_types,
)
should contain_class('neutron::agents::ml2::ovs').with(
'tunnel_types' => tunnel_types ? tunnel_types.join(",") : "",
)
end
else
it 'should declare openstack::network with tunnel_types set to [] and set net_mtu' do
should contain_class('openstack::network').with(
'tunnel_types' => [],
'net_mtu' => 1500,
'network_device_mtu' => 1500,
)
end
end
else
it 'should configure multi_host, send_arp_for_ha, metadata_host in nova.conf for nova-network' do
should contain_nova_config('DEFAULT/multi_host').with(
'value' => 'True',
)
should contain_nova_config('DEFAULT/send_arp_for_ha').with(
'value' => 'True',
)
should contain_nova_config('DEFAULT/metadata_host').with(
'value' => metadata_host,
)
end
it 'should declare openstack::network with neutron disabled' do
enable = Noop.hiera_structure('neutron_advanced_configuration/neutron_l2_pop')
it 'should configure neutron L2 population', :if => enable do
should contain_class('openstack::network').with(
'neutron_server' => 'false',
)
'l2_population' => neutron_l2_pop
)
end
enable = Noop.hiera_structure('neutron_config/L2/segmentation_type') == 'gre'
context 'segmentation_type = GRE', :if => enable do
it 'should configure tunnel_types for neutron and set net_mtu' do
should contain_class('openstack::network').with(
'tunnel_types' => tunnel_types,
'tunnel_id_ranges' => tunnel_id_ranges,
'vni_ranges' => tunnel_id_ranges,
'tenant_network_types' => tenant_network_types,
'net_mtu' => 1500,
'network_device_mtu' => 1450
)
should contain_class('neutron::plugins::ml2').with(
'tunnel_id_ranges' => tunnel_id_ranges,
'vni_ranges' => tunnel_id_ranges,
'tenant_network_types' => tenant_network_types
)
should contain_class('neutron::agents::ml2::ovs').with(
'tunnel_types' => tunnel_types ? tunnel_types.join(",") : ""
)
end
end
end
end # end of shared_examples
enable = Noop.hiera('use_neutron')
context 'with Nova-Network', :unless => enable do
it 'should declare openstack::network with neutron_server parameter set to false' do
should contain_class('openstack::network').with(
'neutron_server' => 'false'
)
end
it 'should configure multi_host, send_arp_for_ha, metadata_host in nova.conf for nova-network' do
should contain_nova_config('DEFAULT/multi_host').with(
'value' => 'True'
)
should contain_nova_config('DEFAULT/send_arp_for_ha').with(
'value' => 'True'
)
should contain_nova_config('DEFAULT/metadata_host').with(
'value' => metadata_host
)
end
it 'should declare openstack::network with neutron disabled' do
should contain_class('openstack::network').with(
'neutron_server' => 'false'
)
end
enable = Noop.hiera_structure('neutron_config/L2/segmentation_type') == 'vlan'
context 'segmentation_type = VLAN', :if => enable do
it 'should declare openstack::network with tunnel_types set to [] and set net_mtu' do
should contain_class('openstack::network').with(
'tunnel_types' => [],
'net_mtu' => 1500,
'network_device_mtu' => 1500
)
end
end
end
end
test_ubuntu_and_centos manifest
end

View File

@ -4,38 +4,35 @@ manifest = 'sahara/keystone.pp'
describe manifest do
shared_examples 'catalog' do
public_vip = Noop.hiera('public_vip')
admin_address = Noop.hiera('management_vip')
public_ssl = Noop.hiera_structure('public_ssl/services')
let(:public_vip) { Noop.hiera('public_vip') }
let(:admin_address) { Noop.hiera('management_vip') }
let(:public_ssl) { Noop.hiera_structure('public_ssl/services') }
let(:public_ssl_hostname) { Noop.hiera_structure('public_ssl/hostname') }
api_bind_port = '8386'
if public_ssl
public_address = Noop.hiera_structure('public_ssl/hostname')
public_protocol = 'https'
else
public_address = public_vip
public_protocol = 'http'
end
sahara_user = Noop.hiera_structure('sahara_hash/user', 'sahara')
sahara_password = Noop.hiera_structure('sahara_hash/user_password')
tenant = Noop.hiera_structure('sahara_hash/tenant', 'services')
region = Noop.hiera_structure('sahara_hash/region', 'RegionOne')
service_name = Noop.hiera_structure('sahara_hash/service_name', 'sahara')
public_url = "#{public_protocol}://#{public_address}:#{api_bind_port}/v1.1/%(tenant_id)s"
admin_url = "http://#{admin_address}:#{api_bind_port}/v1.1/%(tenant_id)s"
let(:api_bind_port) { '8386' }
let(:public_protocol) { public_ssl ? 'https' : 'http' }
let(:public_address) { public_ssl ? public_ssl_hostname : public_vip }
let(:sahara_user) { Noop.hiera_structure('sahara_hash/user', 'sahara') }
let(:sahara_password) { Noop.hiera_structure('sahara_hash/user_password') }
let(:tenant) { Noop.hiera_structure('sahara_hash/tenant', 'services') }
let(:region) { Noop.hiera_structure('sahara_hash/region', 'RegionOne') }
let(:service_name) { Noop.hiera_structure('sahara_hash/service_name', 'sahara') }
let(:public_url) { "#{public_protocol}://#{public_address}:#{api_bind_port}/v1.1/%(tenant_id)s" }
let(:admin_url) { "http://#{admin_address}:#{api_bind_port}/v1.1/%(tenant_id)s" }
it 'should declare sahara::keystone::auth class correctly' do
should contain_class('sahara::keystone::auth').with(
'auth_name' => sahara_user,
'password' => sahara_password,
'service_type' => 'data_processing',
'service_name' => service_name,
'region' => region,
'tenant' => tenant,
'public_url' => public_url,
'admin_url' => admin_url,
'internal_url' => admin_url,
)
'auth_name' => sahara_user,
'password' => sahara_password,
'service_type' => 'data_processing',
'service_name' => service_name,
'region' => region,
'tenant' => tenant,
'public_url' => public_url,
'admin_url' => admin_url,
'internal_url' => admin_url
)
end
end
test_ubuntu_and_centos manifest

View File

@ -5,81 +5,96 @@ manifest = 'sahara/sahara.pp'
describe manifest do
shared_examples 'catalog' do
use_neutron = Noop.hiera 'use_neutron'
rabbit_user = Noop.hiera_structure 'rabbit_hash/user'
rabbit_password = Noop.hiera_structure 'rabbit_hash/password'
sahara_enabled = Noop.hiera_structure 'sahara_hash/enabled'
ceilometer_enabled = Noop.hiera_structure 'ceilometer_hash/enabled'
auth_user = Noop.hiera_structure 'access_hash/user'
auth_password = Noop.hiera_structure 'access_hash/password'
auth_tenant = Noop.hiera_structure 'access_hash/tenant'
primary_controller = Noop.hiera('primary_controller')
service_endpoint = Noop.hiera('service_endpoint')
public_vip = Noop.hiera('public_vip')
bind_address = Noop.hiera('internal_address') # TODO: smakar change AFTER https://bugs.launchpad.net/fuel/+bug/1486048
database_vip = Noop.hiera('database_vip', bind_address)
amqp_port = Noop.hiera('amqp_port')
amqp_hosts = Noop.hiera('amqp_hosts')
debug = Noop.hiera('debug', false)
verbose = Noop.hiera('verbose', true)
use_syslog = Noop.hiera('use_syslog', true)
log_facility_sahara = Noop.hiera('syslog_log_facility_sahara')
rabbit_ha_queues = Noop.hiera('rabbit_ha_queues')
public_ssl = Noop.hiera_structure('public_ssl/services')
let(:use_neutron) { Noop.hiera 'use_neutron' }
let(:rabbit_user) { Noop.hiera_structure 'rabbit/user', 'nova' }
let(:rabbit_password) { Noop.hiera_structure 'rabbit/password' }
let(:auth_user) { Noop.hiera_structure 'access/user' }
let(:auth_password) { Noop.hiera_structure 'access/password' }
let(:auth_tenant) { Noop.hiera_structure 'access/tenant' }
let(:service_endpoint) { Noop.hiera('service_endpoint') }
let(:public_vip) { Noop.hiera('public_vip') }
if sahara_enabled
firewall_rule = '201 sahara-api'
api_bind_port = '8386'
api_bind_host = bind_address
sahara_plugins = [ 'ambari', 'cdh', 'mapr', 'spark', 'vanilla' ]
if public_ssl
public_address = Noop.hiera_structure('public_ssl/hostname')
public_protocol = 'https'
else
public_address = public_vip
public_protocol = 'http'
end
sahara_user = Noop.hiera_structure('sahara_hash/user', 'sahara')
sahara_password = Noop.hiera_structure('sahara_hash/user_password')
tenant = Noop.hiera_structure('sahara_hash/tenant', 'services')
db_user = Noop.hiera_structure('sahara_hash/db_user', 'sahara')
db_name = Noop.hiera_structure('sahara_hash/db_name', 'sahara')
db_password = Noop.hiera_structure('sahara_hash/db_password')
db_host = Noop.hiera_structure('sahara_hash/db_host', database_vip)
read_timeout = '60'
sql_connection = "mysql://#{db_user}:#{db_password}@#{db_host}/#{db_name}?read_timeout=#{read_timeout}"
let(:network_scheme) do
Noop.hiera_hash 'network_scheme'
end
let(:prepare) do
Noop.puppet_function 'prepare_network_config', network_scheme
end
let(:bind_address) do
prepare
Noop.puppet_function 'get_network_role_property', 'sahara/api', 'ipaddr'
end
let(:public_ip) do
Noop.hiera 'public_vip'
end
let(:public_ssl_hostname) do
Noop.hiera_structure('public_ssl/hostname')
end
let(:database_vip) { Noop.hiera('database_vip', bind_address) }
let(:amqp_port) { Noop.hiera('amqp_port') }
let(:amqp_hosts) { Noop.hiera('amqp_hosts') }
let(:debug) { Noop.hiera('debug', false) }
let(:verbose) { Noop.hiera('verbose', true) }
let(:use_syslog) { Noop.hiera('use_syslog', true) }
let(:log_facility_sahara) { Noop.hiera('syslog_log_facility_sahara') }
let(:rabbit_ha_queues) { Noop.hiera('rabbit_ha_queues') }
let(:public_ssl) { Noop.hiera_structure('public_ssl/services') }
let(:public_protocol) { public_ssl ? 'https' : 'http' }
let(:public_address) { public_ssl ? public_ssl_hostname : public_ip }
############################################################################
enable = Noop.hiera_structure('sahara/enabled')
context 'if sahara is enabled', :if => enable do
it 'should declare sahara class correctly' do
sahara_plugins = %w(ambari cdh mapr spark vanilla)
sahara_user = Noop.hiera_structure('sahara_hash/user', 'sahara')
sahara_password = Noop.hiera_structure('sahara_hash/user_password')
tenant = Noop.hiera_structure('sahara_hash/tenant', 'services')
db_user = Noop.hiera_structure('sahara_hash/db_user', 'sahara')
db_name = Noop.hiera_structure('sahara_hash/db_name', 'sahara')
db_password = Noop.hiera_structure('sahara_hash/db_password')
db_host = Noop.hiera_structure('sahara_hash/db_host', database_vip)
read_timeout = '60'
sql_connection = "mysql://#{db_user}:#{db_password}@#{db_host}/#{db_name}?read_timeout=#{read_timeout}"
should contain_class('sahara').with(
'auth_uri' => "http://#{service_endpoint}:5000/v2.0/",
'identity_uri' => "http://#{service_endpoint}:35357/",
'plugins' => sahara_plugins,
'rpc_backend' => 'rabbit',
'use_neutron' => use_neutron,
'admin_user' => sahara_user,
'verbose' => verbose,
'debug' => debug,
'use_syslog' => use_syslog,
'use_stderr' => 'false',
'log_facility' => log_facility_sahara,
'database_connection' => sql_connection,
'admin_password' => sahara_password,
'admin_tenant_name' => tenant,
'rabbit_userid' => rabbit_user,
'rabbit_password' => rabbit_password,
'rabbit_ha_queues' => rabbit_ha_queues,
'rabbit_port' => amqp_port,
'rabbit_hosts' => amqp_hosts.split(","),
)
'auth_uri' => "http://#{service_endpoint}:5000/v2.0/",
'identity_uri' => "http://#{service_endpoint}:35357/",
'plugins' => sahara_plugins,
'rpc_backend' => 'rabbit',
'use_neutron' => use_neutron,
'admin_user' => sahara_user,
'verbose' => verbose,
'debug' => debug,
'use_syslog' => use_syslog,
'use_stderr' => 'false',
'log_facility' => log_facility_sahara,
'database_connection' => sql_connection,
'admin_password' => sahara_password,
'admin_tenant_name' => tenant,
'rabbit_userid' => rabbit_user,
'rabbit_password' => rabbit_password,
'rabbit_ha_queues' => rabbit_ha_queues,
'rabbit_port' => amqp_port,
'rabbit_hosts' => amqp_hosts.split(",")
)
end
if public_ssl
enable = (Noop.hiera_structure('sahara/enabled') and Noop.hiera_structure('public_ssl/services'))
context 'with public_ssl enabled', :if => enable do
it { should contain_file('/etc/pki/tls/certs').with(
'mode' => 755,
'mode' => 755
)}
it { should contain_file('/etc/pki/tls/certs/public_haproxy.pem').with(
'mode' => 644,
'mode' => 644
)}
it { is_expected.to contain_sahara_config('object_store_access/public_identity_ca_file').with_value('/etc/pki/tls/certs/public_haproxy.pem') }
@ -87,10 +102,11 @@ describe manifest do
end
it 'should declare sahara::api class correctly' do
api_bind_port = '8386'
should contain_class('sahara::api').with(
'host' => api_bind_host,
'port' => api_bind_port,
)
'host' => bind_address,
'port' => api_bind_port
)
end
it 'should declare sahara::engine class correctly' do
@ -101,30 +117,42 @@ describe manifest do
should contain_class('sahara::client')
end
if ceilometer_enabled
enable = (Noop.hiera_structure('sahara/enabled') and Noop.hiera_structure('ceilometer/enabled'))
context 'with ceilometer', :if => enable do
it 'should declare sahara::notify class correctly' do
should contain_class('sahara::notify').with(
'enable_notifications' => true,
)
'enable_notifications' => true
)
end
end
if primary_controller
enable = (Noop.hiera_structure('sahara/enabled') and Noop.hiera('node_role') == 'primary-controller')
context 'on primary-controller', :if => enable do
it 'should declare sahara_templates class correctly' do
should contain_class('sahara_templates::create_templates').with(
'use_neutron' => use_neutron,
'auth_uri' => "#{public_protocol}://#{public_address}:5000/v2.0/",
'auth_password' => auth_password,
'auth_user' => auth_user,
'auth_tenant' => auth_tenant,
)
'use_neutron' => use_neutron,
'auth_uri' => "#{public_protocol}://#{public_address}:5000/v2.0/",
'auth_password' => auth_password,
'auth_user' => auth_user,
'auth_tenant' => auth_tenant
)
end
it { should contain_haproxy_backend_status('keystone-public').that_comes_before('Haproxy_backend_status[sahara]') }
it { should contain_haproxy_backend_status('keystone-admin').that_comes_before('Haproxy_backend_status[sahara]') }
it { should contain_haproxy_backend_status('sahara').that_comes_before('Class[sahara_templates::create_templates]') }
it {
should contain_haproxy_backend_status('keystone-public').that_comes_before('Haproxy_backend_status[sahara]')
}
it {
should contain_haproxy_backend_status('keystone-admin').that_comes_before('Haproxy_backend_status[sahara]')
}
it {
should contain_haproxy_backend_status('sahara').that_comes_before('Class[sahara_templates::create_templates]')
}
end
end
end
test_ubuntu_and_centos manifest
end

View File

@ -147,6 +147,8 @@ module Noop
# return @hiera[astute_yaml_name]
return @hiera_object if @hiera_object
@hiera_object = Hiera.new(:config => hiera_config)
Hiera.logger = hiera_config[:logger]
@hiera_object
end
def self.hiera(key, default = nil, resolution_type = :priority)
@ -213,9 +215,22 @@ module Noop
Puppet::Util::Log.newdestination(:console)
end
def self.puppet_resource_scope_override
Puppet::Parser::Resource.module_eval do
def initialize(*args)
raise ArgumentError, "Resources require a hash as last argument" unless args.last.is_a? Hash
raise ArgumentError, "Resources require a scope" unless args.last[:scope]
super
Noop.puppet_scope = scope
@source ||= scope.source
end
end
end
def self.setup_overrides
hiera_puppet_override
puppet_debug_override if ENV['SPEC_PUPPET_DEBUG']
puppet_resource_scope_override
end
## Facts ##
@ -396,6 +411,16 @@ module Noop
resource[parameter.to_sym]
end
# save the current puppet scope
def self.puppet_scope=(value)
@puppet_scope = value
end
def self.puppet_scope
fail "Puppet scope is not saved in the Noop module!" unless @puppet_scope
@puppet_scope
end
# load a puppet function if it's not alreay loaded
def self.puppet_function_load(name)
name = name.to_sym unless name.is_a? Symbol
@ -405,12 +430,15 @@ module Noop
# call a puppet function and return it's value
def self.puppet_function(name, *args)
name = name.to_sym unless name.is_a? Symbol
puppet_scope = PuppetlabsSpec::PuppetInternals.scope
puppet_function_load name
fail "Could not load Puppet function '#{name}'!" unless puppet_scope.respond_to? "function_#{name}".to_sym
puppet_scope.send "function_#{name}".to_sym, args
end
def self.lookupvar(name)
puppet_scope.lookupvar name
end
def self.debug(msg)
puts msg if ENV['SPEC_PUPPET_DEBUG']
end