provider: Assert the whole yaml file content

Change-Id: If494cecb809f0349f0264b0feb3aee08479f5d6c
This commit is contained in:
Takashi Kajinami 2024-04-26 17:09:15 +09:00
parent ddde8befa8
commit 0108bcac76
1 changed files with 136 additions and 110 deletions

View File

@ -9,21 +9,49 @@ describe 'nova::compute::provider' do
{}
end
shared_examples_for 'nova custom resource providers' do
shared_examples_for 'nova::compute::provider' do
it 'configure nova.conf with default parameters' do
context 'with defaults' do
it 'configure nova.conf with default parameters' do
is_expected.to contain_nova_config('compute/provider_config_location').with_value('/etc/nova/provider_config')
end
it 'creates the config directory' do
is_expected.to contain_file('/etc/nova/provider_config').with(
:ensure => 'directory',
:mode => '0750',
:owner => 'nova',
:group => 'nova',
)
end
it 'does not configure provider.yaml on compute nodes' do
is_expected.to_not contain_file('/etc/nova/provider_config/provider.yaml')
end
end
context 'when overriding default parameters' do
before :each do
params.merge!(
:config_location => '/etc/nova/custom_provider_config',
:config_location => '/etc/nova/custom_provider_config',
)
end
it 'configure nova.conf with overridden parameters' do
is_expected.to contain_nova_config('compute/provider_config_location').with_value('/etc/nova/custom_provider_config')
is_expected.to contain_nova_config('compute/provider_config_location').with_value('/etc/nova/custom_provider_config')
end
it 'creates config directory' do
is_expected.to contain_file('/etc/nova/custom_provider_config').with(
:ensure => 'directory',
:mode => '0750',
:owner => 'nova',
:group => 'nova',
)
end
it 'does not configure provider.yaml on compute nodes' do
is_expected.to_not contain_file('/etc/nova/custom_provider_config/provider.yaml')
end
end
@ -55,30 +83,34 @@ describe 'nova::compute::provider' do
end
it 'configure provider.yaml on compute nodes' do
is_expected.to contain_file('/etc/nova/provider_config/provider.yaml')
verify_contents(catalogue, '/etc/nova/provider_config/provider.yaml', [
"meta:",
" schema_version: \'1.0\'",
"providers:",
" # for details check https://docs.openstack.org/nova/latest/admin/managing-resource-providers.html",
" - identification:",
" uuid: \'$COMPUTE_NODE\'",
" inventories:",
" additional:",
" - CUSTOM_EXAMPLE_RESOURCE_CLASS_1:",
" allocation_ratio: 1.0",
" max_unit: 10",
" min_unit: 1",
" reserved: 0",
" step_size: 1",
" total: 100",
" - CUSTOM_EXAMPLE_RESOURCE_CLASS_2:",
" total: 100",
" traits:",
" additional:",
" - \'CUSTOM_P_STATE_ENABLED\'",
" - \'CUSTOM_C_STATE_ENABLED\'"
])
is_expected.to contain_file('/etc/nova/provider_config/provider.yaml').with(
:ensure => 'file',
:mode => '0640',
:owner => 'nova',
:group => 'nova',
)
is_expected.to contain_file('/etc/nova/provider_config/provider.yaml').with_content(
"meta:
schema_version: '1.0'
providers:,
# for details check https://docs.openstack.org/nova/latest/admin/managing-resource-providers.html
- identification:,
uuid: '$COMPUTE_NODE'
inventories:
additional:
- CUSTOM_EXAMPLE_RESOURCE_CLASS_1:
allocation_ratio: 1.0
max_unit: 10
min_unit: 1
reserved: 0
step_size: 1
total: 100
- CUSTOM_EXAMPLE_RESOURCE_CLASS_2:
total: 100
traits:
additional:
- 'CUSTOM_P_STATE_ENABLED'
- 'CUSTOM_C_STATE_ENABLED'")
end
end
@ -111,30 +143,28 @@ describe 'nova::compute::provider' do
end
it 'configure provider.yaml on compute nodes' do
is_expected.to contain_file('/etc/nova/provider_config/provider.yaml')
verify_contents(catalogue, '/etc/nova/provider_config/provider.yaml', [
"meta:",
" schema_version: \'1.0\'",
"providers:",
" # for details check https://docs.openstack.org/nova/latest/admin/managing-resource-providers.html",
" - identification:",
" uuid: \'5213b75d-9260-42a6-b236-f39b0fd10561\'",
" inventories:",
" additional:",
" - CUSTOM_EXAMPLE_RESOURCE_CLASS_1:",
" allocation_ratio: 1.0",
" max_unit: 10",
" min_unit: 1",
" reserved: 0",
" step_size: 1",
" total: 100",
" - CUSTOM_EXAMPLE_RESOURCE_CLASS_2:",
" total: 100",
" traits:",
" additional:",
" - \'CUSTOM_P_STATE_ENABLED\'",
" - \'CUSTOM_C_STATE_ENABLED\'"
])
is_expected.to contain_file('/etc/nova/provider_config/provider.yaml').with_content(
"meta:
schema_version: '1.0'
providers:
# for details check https://docs.openstack.org/nova/latest/admin/managing-resource-providers.html
- identification:
uuid: '5213b75d-9260-42a6-b236-f39b0fd10561'
inventories:
additional:
- CUSTOM_EXAMPLE_RESOURCE_CLASS_1:
allocation_ratio: 1.0
max_unit: 10
min_unit: 1
reserved: 0
step_size: 1
total: 100
- CUSTOM_EXAMPLE_RESOURCE_CLASS_2:
total: 100
traits:
additional:
- 'CUSTOM_P_STATE_ENABLED'
- 'CUSTOM_C_STATE_ENABLED'")
end
end
@ -167,30 +197,28 @@ describe 'nova::compute::provider' do
end
it 'configure provider.yaml on compute nodes' do
is_expected.to contain_file('/etc/nova/provider_config/provider.yaml')
verify_contents(catalogue, '/etc/nova/provider_config/provider.yaml', [
"meta:",
" schema_version: \'1.0\'",
"providers:",
" # for details check https://docs.openstack.org/nova/latest/admin/managing-resource-providers.html",
" - identification:",
" name: \'EXAMPLE_RESOURCE_PROVIDER\'",
" inventories:",
" additional:",
" - CUSTOM_EXAMPLE_RESOURCE_CLASS_1:",
" allocation_ratio: 1.0",
" max_unit: 10",
" min_unit: 1",
" reserved: 0",
" step_size: 1",
" total: 100",
" - CUSTOM_EXAMPLE_RESOURCE_CLASS_2:",
" total: 100",
" traits:",
" additional:",
" - \'CUSTOM_P_STATE_ENABLED\'",
" - \'CUSTOM_C_STATE_ENABLED\'"
])
is_expected.to contain_file('/etc/nova/provider_config/provider.yaml').with-content(
"meta:
schema_version: '1.0'
providers:
# for details check https://docs.openstack.org/nova/latest/admin/managing-resource-providers.html
- identification:
name: 'EXAMPLE_RESOURCE_PROVIDER'
inventories:
additional:
- CUSTOM_EXAMPLE_RESOURCE_CLASS_1:
allocation_ratio: 1.0
max_unit: 10
min_unit: 1
reserved: 0
step_size: 1
total: 100
- CUSTOM_EXAMPLE_RESOURCE_CLASS_2:
total: 100
traits:
additional:
- 'CUSTOM_P_STATE_ENABLED'
- 'CUSTOM_C_STATE_ENABLED'")
end
end
@ -231,39 +259,37 @@ describe 'nova::compute::provider' do
end
it 'configure provider.yaml on compute nodes' do
is_expected.to contain_file('/etc/nova/provider_config/provider.yaml')
verify_contents(catalogue, '/etc/nova/provider_config/provider.yaml', [
"meta:",
" schema_version: \'1.0\'",
"providers:",
" # for details check https://docs.openstack.org/nova/latest/admin/managing-resource-providers.html",
" - identification:",
" uuid: \'$COMPUTE_NODE\'",
" inventories:",
" additional:",
" - CUSTOM_EXAMPLE_RESOURCE_CLASS_1:",
" allocation_ratio: 1.0",
" max_unit: 10",
" min_unit: 1",
" reserved: 0",
" step_size: 1",
" total: 100",
" - CUSTOM_EXAMPLE_RESOURCE_CLASS_2:",
" total: 100",
" traits:",
" additional:",
" - \'CUSTOM_P_STATE_ENABLED\'",
" - \'CUSTOM_C_STATE_ENABLED\'",
" - identification:",
" name: \'EXAMPLE_RESOURCE_PROVIDER\'",
" inventories:",
" additional:",
" - CUSTOM_EXAMPLE_RESOURCE_CLASS:",
" reserved: 100",
" total: 10000",
" traits:",
" additional:"
])
is_expected.to contain_file('/etc/nova/provider_config/provider.yaml').with_content(
"meta:
schema_version: '1.0'
providers:
# for details check https://docs.openstack.org/nova/latest/admin/managing-resource-providers.html
- identification:
uuid: '$COMPUTE_NODE'
inventories:
additional:
- CUSTOM_EXAMPLE_RESOURCE_CLASS_1:
allocation_ratio: 1.0
max_unit: 10
min_unit: 1
reserved: 0
step_size: 1
total: 100
- CUSTOM_EXAMPLE_RESOURCE_CLASS_2:
total: 100
traits:
additional:
- 'CUSTOM_P_STATE_ENABLED'
- 'CUSTOM_C_STATE_ENABLED'
- identification:
name: 'EXAMPLE_RESOURCE_PROVIDER'
inventories:
additional:
- CUSTOM_EXAMPLE_RESOURCE_CLASS:
reserved: 100
total: 10000
traits:
additional:")
end
end
end
@ -276,7 +302,7 @@ describe 'nova::compute::provider' do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'nova custom resource providers'
it_configures 'nova::compute::provider'
end
end
end