puppet-nova/spec/classes/nova_compute_vgpu_spec.rb
Takashi Kajinami 851dc512e1 Cleanup device addresses of vgpu type when empty
This change makes sure that device_addresses parameter is unset when
empty list of device addresses is associated with a vgpu type, so that
unmanaged parameter is not left.

Change-Id: Id6a354401b3233d3a17081d97a1a0e25f24d3219
2020-09-17 23:38:17 +09:00

75 lines
2.3 KiB
Ruby

require 'spec_helper'
describe 'nova::compute::vgpu' do
shared_examples_for 'nova-compute-vgpu' do
context 'with default parameters' do
it 'clears vgpu devices' do
is_expected.to contain_nova_config('devices/enabled_vgpu_types').with_ensure('absent')
end
end
context 'with vgpu device' do
let :params do
{
:enabled_vgpu_types => "nvidia-35",
}
end
it 'configures nova vgpu device entries' do
is_expected.to contain_nova_config('devices/enabled_vgpu_types').with(
'value' => 'nvidia-35'
)
end
end
context 'with vgpu types and device addresses mapping' do
let :params do
{
:vgpu_types_device_addresses_mapping => { "nvidia-35" => [] },
}
end
it { is_expected.to contain_nova_config('devices/enabled_vgpu_types').with_value('nvidia-35') }
it { is_expected.to contain_nova_config('vgpu_nvidia-35/device_addresses').with_ensure('absent') }
end
context 'with multiple vgpu devices' do
let :params do
{
:enabled_vgpu_types => ["nvidia-35","nvidia-36"]
}
end
it 'configures nova vgpu device entries' do
is_expected.to contain_nova_config('devices/enabled_vgpu_types').with(
'value' => "nvidia-35,nvidia-36"
)
end
end
context 'with multiple vgpu types and corresponding device addresses mapping' do
let :params do
{
:vgpu_types_device_addresses_mapping => { "nvidia-35" => ['0000:84:00.0', '0000:85:00.0'],
"nvidia-36" => ['0000:86:00.0'] }
}
end
it { is_expected.to contain_nova_config('devices/enabled_vgpu_types').with_value('nvidia-35,nvidia-36') }
it { is_expected.to contain_nova_config('vgpu_nvidia-35/device_addresses').with_value('0000:84:00.0,0000:85:00.0') }
it { is_expected.to contain_nova_config('vgpu_nvidia-36/device_addresses').with_value('0000:86:00.0') }
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'nova-compute-vgpu'
end
end
end