Files
puppet-nova/spec/defines/nova_compute_libvirt_secret_ceph_spec.rb
Takashi Kajinami c034b19b52 Sort dictionary values
... to make provider.yaml content predictable.

Also replace verify_contents, because this utility is provided by
puppetlabs_spec_helper which we aim to replace by voxpupuli-test.
More strict assertion allows us to detect wrong orders.

Change-Id: Id9c834b822ba4897b92b43733c6ad557ec586a93
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
2025-09-15 02:39:44 +09:00

84 lines
2.8 KiB
Ruby

require 'spec_helper'
describe 'nova::compute::libvirt::secret_ceph' do
shared_examples 'nova::compute::libvirt::secret_ceph' do
describe 'with required parameters' do
let :pre_condition do
"include nova"
end
let :params do
{
:uuid => '4f515eff-47e4-425c-b24d-9c6adc56401c',
:value => 'AQBHCbtT6APDHhAA5W00cBchwkQjh3dkKsyPjw==',
:secret_name => 'client.openstack',
:secret_path => '/tmp',
}
end
let :title do
'random'
end
it { is_expected.to contain_file('/tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.xml').with(
:ensure => 'file',
:owner => 'root',
:group => 'root',
:mode => '0600',
:require => 'Anchor[nova::config::begin]',
:content => <<EOS
<secret ephemeral='no' private='no'>
<usage type='ceph'>
<name>client.openstack</name>
</usage>
<uuid>4f515eff-47e4-425c-b24d-9c6adc56401c</uuid>
</secret>
EOS
)}
it { is_expected.to contain_file('/tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.secret').with(
:ensure => 'file',
:owner => 'root',
:group => 'root',
:mode => '0600',
:show_diff => false,
:require => 'Anchor[nova::config::begin]',
:content => 'AQBHCbtT6APDHhAA5W00cBchwkQjh3dkKsyPjw==',
)}
it { is_expected.to contain_exec('get-or-set virsh secret 4f515eff-47e4-425c-b24d-9c6adc56401c').with(
:command => [
'/usr/bin/virsh', 'secret-define', '--file', '/tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.xml',
],
:unless => "/usr/bin/virsh secret-list | grep -i 4f515eff-47e4-425c-b24d-9c6adc56401c",
:require => 'File[/tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.xml]',
)}
it { is_expected.to contain_exec('set-secret-value virsh secret 4f515eff-47e4-425c-b24d-9c6adc56401c').with(
:command => [
'/usr/bin/virsh', 'secret-set-value', '--secret', '4f515eff-47e4-425c-b24d-9c6adc56401c',
'--file', '/tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.secret',
],
:unless => "/usr/bin/virsh secret-get-value 4f515eff-47e4-425c-b24d-9c6adc56401c | grep -f /tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.secret",
:logoutput => false,
:require => [
'File[/tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.secret]',
'Exec[get-or-set virsh secret 4f515eff-47e4-425c-b24d-9c6adc56401c]',
],
)}
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_behaves_like 'nova::compute::libvirt::secret_ceph'
end
end
end