2013-03-19 14:34:35 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
describe 'nova::compute::libvirt' do
|
|
|
|
|
|
|
|
let :pre_condition do
|
2013-03-20 12:59:19 -07:00
|
|
|
"include nova\ninclude nova::compute"
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
describe 'on debian platforms' do
|
|
|
|
let :facts do
|
|
|
|
{ :osfamily => 'Debian' }
|
|
|
|
end
|
2013-03-19 14:34:35 -04:00
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
describe 'with default parameters' do
|
|
|
|
|
|
|
|
it { should contain_class('nova::params')}
|
|
|
|
|
|
|
|
it { should contain_package('nova-compute-kvm').with(
|
|
|
|
:ensure => 'present',
|
2014-11-13 11:55:04 -05:00
|
|
|
:before => 'Package[nova-compute]',
|
|
|
|
:tag => ['openstack', 'nova']
|
2013-12-25 02:10:52 +01:00
|
|
|
) }
|
|
|
|
|
|
|
|
it { should contain_package('libvirt').with(
|
|
|
|
:name => 'libvirt-bin',
|
|
|
|
:ensure => 'present'
|
|
|
|
) }
|
|
|
|
|
|
|
|
it { should contain_service('libvirt').with(
|
|
|
|
:name => 'libvirt-bin',
|
2014-02-24 15:17:16 +01:00
|
|
|
:enable => true,
|
2013-12-25 02:10:52 +01:00
|
|
|
:ensure => 'running',
|
|
|
|
:provider => 'upstart',
|
|
|
|
:require => 'Package[libvirt]',
|
|
|
|
:before => 'Service[nova-compute]'
|
|
|
|
)}
|
|
|
|
|
|
|
|
it { should contain_nova_config('DEFAULT/compute_driver').with_value('libvirt.LibvirtDriver')}
|
|
|
|
it { should contain_nova_config('libvirt/virt_type').with_value('kvm')}
|
2014-02-23 22:38:41 -05:00
|
|
|
it { should contain_nova_config('libvirt/cpu_mode').with_value('host-model')}
|
2014-02-25 01:05:29 -05:00
|
|
|
it { should contain_nova_config('libvirt/disk_cachemodes').with_ensure('absent')}
|
2013-12-25 02:10:52 +01:00
|
|
|
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('127.0.0.1')}
|
2014-03-04 14:48:08 +01:00
|
|
|
it { should contain_nova_config('DEFAULT/remove_unused_base_images').with_ensure('absent')}
|
|
|
|
it { should contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_ensure('absent')}
|
|
|
|
it { should contain_nova_config('libvirt/remove_unused_kernels').with_ensure('absent')}
|
|
|
|
it { should contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_ensure('absent')}
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
describe 'with params' do
|
2013-03-19 14:34:35 -04:00
|
|
|
let :params do
|
2014-03-04 14:48:08 +01:00
|
|
|
{ :libvirt_virt_type => 'qemu',
|
|
|
|
:vncserver_listen => '0.0.0.0',
|
|
|
|
:libvirt_cpu_mode => 'host-passthrough',
|
|
|
|
:libvirt_disk_cachemodes => ['file=directsync','block=none'],
|
|
|
|
:remove_unused_base_images => true,
|
|
|
|
:remove_unused_kernels => true,
|
|
|
|
:remove_unused_resized_minimum_age_seconds => 3600,
|
2014-09-29 12:30:34 +02:00
|
|
|
:remove_unused_original_minimum_age_seconds => 3600,
|
|
|
|
:libvirt_service_name => 'custom_service'
|
2013-12-25 02:10:52 +01:00
|
|
|
}
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
it { should contain_nova_config('libvirt/virt_type').with_value('qemu')}
|
2014-02-23 22:38:41 -05:00
|
|
|
it { should contain_nova_config('libvirt/cpu_mode').with_value('host-passthrough')}
|
2014-02-25 01:05:29 -05:00
|
|
|
it { should contain_nova_config('libvirt/disk_cachemodes').with_value('file=directsync,block=none')}
|
2013-12-25 02:10:52 +01:00
|
|
|
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('0.0.0.0')}
|
2014-03-04 14:48:08 +01:00
|
|
|
it { should contain_nova_config('DEFAULT/remove_unused_base_images').with_value(true)}
|
|
|
|
it { should contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_value(3600)}
|
|
|
|
it { should contain_nova_config('libvirt/remove_unused_kernels').with_value(true)}
|
|
|
|
it { should contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_value(3600)}
|
2014-09-29 12:30:34 +02:00
|
|
|
it { should contain_service('libvirt').with(
|
|
|
|
:name => 'custom_service',
|
|
|
|
:enable => true,
|
|
|
|
:ensure => 'running',
|
|
|
|
:require => 'Package[libvirt]',
|
|
|
|
:before => 'Service[nova-compute]'
|
|
|
|
)}
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
describe 'with migration_support enabled' do
|
|
|
|
|
2013-03-19 14:34:35 -04:00
|
|
|
context 'with vncserver_listen set to 0.0.0.0' do
|
2013-12-25 02:10:52 +01:00
|
|
|
let :params do
|
2014-02-24 15:17:16 +01:00
|
|
|
{ :vncserver_listen => '0.0.0.0',
|
2013-12-25 02:10:52 +01:00
|
|
|
:migration_support => true }
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
it { should contain_class('nova::migration::libvirt')}
|
|
|
|
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('0.0.0.0')}
|
2014-10-14 14:34:37 -04:00
|
|
|
it { should contain_file_line('/etc/default/libvirt-bin libvirtd opts').with(:line => 'libvirtd_opts="-d -l"') }
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with vncserver_listen not set to 0.0.0.0' do
|
2013-12-25 02:10:52 +01:00
|
|
|
let :params do
|
2014-02-24 15:17:16 +01:00
|
|
|
{ :vncserver_listen => '127.0.0.1',
|
2013-12-25 02:10:52 +01:00
|
|
|
:migration_support => true }
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
it { expect { should contain_class('nova::compute::libvirt') }.to \
|
|
|
|
raise_error(Puppet::Error, /For migration support to work, you MUST set vncserver_listen to '0.0.0.0'/) }
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
2014-10-14 14:34:37 -04:00
|
|
|
|
|
|
|
context 'with custom libvirt service name on Debian plateforms' do
|
|
|
|
let :params do
|
|
|
|
{ :libvirt_service_name => 'libvirtd',
|
|
|
|
:vncserver_listen => '0.0.0.0',
|
|
|
|
:migration_support => true }
|
|
|
|
end
|
|
|
|
it { should contain_file_line('/etc/default/libvirtd libvirtd opts').with(:line => 'libvirtd_opts="-d -l"') }
|
|
|
|
|
|
|
|
end
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
|
|
|
|
describe 'on rhel platforms' do
|
2013-03-19 14:34:35 -04:00
|
|
|
let :facts do
|
2014-04-22 15:16:04 -04:00
|
|
|
{ :operatingsystem => 'RedHat', :osfamily => 'RedHat',
|
|
|
|
:operatingsystemrelease => 6.5 }
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
describe 'with default parameters' do
|
2013-03-19 14:34:35 -04:00
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
it { should contain_class('nova::params')}
|
2013-03-19 14:34:35 -04:00
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
it { should contain_package('libvirt').with(
|
|
|
|
:name => 'libvirt',
|
|
|
|
:ensure => 'present'
|
|
|
|
) }
|
|
|
|
|
|
|
|
it { should contain_service('libvirt').with(
|
|
|
|
:name => 'libvirtd',
|
2014-02-24 15:17:16 +01:00
|
|
|
:enable => true,
|
2013-12-25 02:10:52 +01:00
|
|
|
:ensure => 'running',
|
2014-04-25 18:05:02 +02:00
|
|
|
:provider => nil,
|
2013-12-25 02:10:52 +01:00
|
|
|
:require => 'Package[libvirt]',
|
|
|
|
:before => 'Service[nova-compute]'
|
|
|
|
)}
|
|
|
|
it { should contain_service('messagebus').with(
|
|
|
|
:ensure => 'running',
|
|
|
|
:enable => true,
|
|
|
|
:before => 'Service[libvirt]',
|
2014-04-25 18:05:02 +02:00
|
|
|
:provider => nil
|
2013-12-25 02:10:52 +01:00
|
|
|
) }
|
2013-03-19 14:34:35 -04:00
|
|
|
|
2014-04-22 15:16:04 -04:00
|
|
|
describe 'on rhel 7' do
|
|
|
|
let :facts do
|
|
|
|
super().merge(:operatingsystemrelease => 7.0)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should contain_service('libvirt').with(
|
|
|
|
:provider => nil
|
|
|
|
)}
|
|
|
|
|
|
|
|
it { should contain_service('messagebus').with(
|
|
|
|
:provider => nil
|
|
|
|
)}
|
|
|
|
end
|
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
it { should contain_nova_config('DEFAULT/compute_driver').with_value('libvirt.LibvirtDriver')}
|
|
|
|
it { should contain_nova_config('libvirt/virt_type').with_value('kvm')}
|
|
|
|
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('127.0.0.1')}
|
2014-03-04 14:48:08 +01:00
|
|
|
it { should contain_nova_config('DEFAULT/remove_unused_base_images').with_ensure('absent')}
|
|
|
|
it { should contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_ensure('absent')}
|
|
|
|
it { should contain_nova_config('libvirt/remove_unused_kernels').with_ensure('absent')}
|
|
|
|
it { should contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_ensure('absent')}
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
describe 'with params' do
|
|
|
|
let :params do
|
2014-03-04 14:48:08 +01:00
|
|
|
{ :libvirt_virt_type => 'qemu',
|
|
|
|
:vncserver_listen => '0.0.0.0',
|
|
|
|
:remove_unused_base_images => true,
|
|
|
|
:remove_unused_kernels => true,
|
|
|
|
:remove_unused_resized_minimum_age_seconds => 3600,
|
|
|
|
:remove_unused_original_minimum_age_seconds => 3600
|
2013-12-25 02:10:52 +01:00
|
|
|
}
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
it { should contain_nova_config('libvirt/virt_type').with_value('qemu')}
|
|
|
|
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('0.0.0.0')}
|
2014-03-04 14:48:08 +01:00
|
|
|
it { should contain_nova_config('DEFAULT/remove_unused_base_images').with_value(true)}
|
|
|
|
it { should contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_value(3600)}
|
|
|
|
it { should contain_nova_config('libvirt/remove_unused_kernels').with_value(true)}
|
|
|
|
it { should contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_value(3600)}
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
describe 'with migration_support enabled' do
|
|
|
|
|
|
|
|
context 'with vncserver_listen set to 0.0.0.0' do
|
|
|
|
let :params do
|
2014-02-24 15:17:16 +01:00
|
|
|
{ :vncserver_listen => '0.0.0.0',
|
2013-12-25 02:10:52 +01:00
|
|
|
:migration_support => true }
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should contain_class('nova::migration::libvirt')}
|
|
|
|
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('0.0.0.0')}
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
context 'with vncserver_listen not set to 0.0.0.0' do
|
|
|
|
let :params do
|
2014-02-24 15:17:16 +01:00
|
|
|
{ :vncserver_listen => '127.0.0.1',
|
2013-12-25 02:10:52 +01:00
|
|
|
:migration_support => true }
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect { should contain_class('nova::compute::libvirt') }.to \
|
|
|
|
raise_error(Puppet::Error, /For migration support to work, you MUST set vncserver_listen to '0.0.0.0'/) }
|
|
|
|
end
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
2013-04-05 10:48:35 -04:00
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
describe 'with default parameters on Fedora' do
|
|
|
|
let :facts do
|
|
|
|
{ :operatingsystem => 'Fedora', :osfamily => 'RedHat' }
|
2013-04-05 10:48:35 -04:00
|
|
|
end
|
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
it { should contain_class('nova::params')}
|
2013-04-05 10:48:35 -04:00
|
|
|
|
2013-12-25 02:10:52 +01:00
|
|
|
it { should contain_package('libvirt').with(
|
|
|
|
:name => 'libvirt',
|
|
|
|
:ensure => 'present'
|
2014-01-30 17:09:21 -05:00
|
|
|
) }
|
2013-12-25 02:10:52 +01:00
|
|
|
|
|
|
|
it { should contain_service('libvirt').with(
|
|
|
|
:name => 'libvirtd',
|
2014-02-24 15:17:16 +01:00
|
|
|
:enable => true,
|
2013-12-25 02:10:52 +01:00
|
|
|
:ensure => 'running',
|
|
|
|
:provider => nil,
|
|
|
|
:require => 'Package[libvirt]',
|
|
|
|
:before => 'Service[nova-compute]'
|
|
|
|
)}
|
|
|
|
|
|
|
|
it { should contain_nova_config('DEFAULT/compute_driver').with_value('libvirt.LibvirtDriver')}
|
|
|
|
it { should contain_nova_config('libvirt/virt_type').with_value('kvm')}
|
|
|
|
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('127.0.0.1')}
|
2013-04-05 10:48:35 -04:00
|
|
|
end
|
2013-12-25 02:10:52 +01:00
|
|
|
|
2013-03-19 14:34:35 -04:00
|
|
|
end
|
|
|
|
end
|