Add support for cache options in specific module

This patch introduces several parameters in heat::cache class, so that
we can configure caching parameters for specific module.

Change-Id: I752c31825ec3f3f23df01a4d24a633b2453bff19
This commit is contained in:
Takashi Kajinami 2020-03-28 08:05:18 +09:00
parent 5a6838f7cd
commit 3cbb922235
3 changed files with 100 additions and 28 deletions

View File

@ -82,24 +82,57 @@
# Defaults to $::os_service_default
#
# [*manage_backend_package*]
# (Optional) (Optional) Whether to install the backend package for the cache.
# (Optional) Whether to install the backend package for the cache.
# Defaults to true
#
# [*constraint_validation_caching*]
# (Optional) Enable caching in constraint validation. Global caching should
# be also enabled to enable this.
# Defaults to $::os_service_default
#
# [*constraint_validation_expiration_time*]
# (Optional) TTL, in seconds, for caching in constraint validation.
# Defaults to $::os_service_default
#
# [*service_extension_caching*]
# (Optional) Enable caching in service extension. Global caching should
# be also enabled to enable this.
# Defaults to $::os_service_default
#
# [*service_extension_expiration_time*]
# (Optional) TTL, in seconds, for caching in service extention.
# Defaults to $::os_service_default
#
# [*resource_finder_caching*]
# (Optional) Enable caching in resource finder. Global caching should
# be also enabled to enable this.
# Defaults to $::os_service_default
#
# [*resource_finder_expiration_time*]
# (Optional) TTL, in seconds, for caching in resource finder.
# Defaults to $::os_service_default
#
class heat::cache (
$config_prefix = $::os_service_default,
$expiration_time = $::os_service_default,
$backend = $::os_service_default,
$backend_argument = $::os_service_default,
$proxies = $::os_service_default,
$enabled = $::os_service_default,
$debug_cache_backend = $::os_service_default,
$memcache_servers = $::os_service_default,
$memcache_dead_retry = $::os_service_default,
$memcache_socket_timeout = $::os_service_default,
$memcache_pool_maxsize = $::os_service_default,
$memcache_pool_unused_timeout = $::os_service_default,
$memcache_pool_connection_get_timeout = $::os_service_default,
$manage_backend_package = true,
$config_prefix = $::os_service_default,
$expiration_time = $::os_service_default,
$backend = $::os_service_default,
$backend_argument = $::os_service_default,
$proxies = $::os_service_default,
$enabled = $::os_service_default,
$debug_cache_backend = $::os_service_default,
$memcache_servers = $::os_service_default,
$memcache_dead_retry = $::os_service_default,
$memcache_socket_timeout = $::os_service_default,
$memcache_pool_maxsize = $::os_service_default,
$memcache_pool_unused_timeout = $::os_service_default,
$memcache_pool_connection_get_timeout = $::os_service_default,
$manage_backend_package = true,
$constraint_validation_caching = $::os_service_default,
$constraint_validation_expiration_time = $::os_service_default,
$service_extension_caching = $::os_service_default,
$service_extension_expiration_time = $::os_service_default,
$resource_finder_caching = $::os_service_default,
$resource_finder_expiration_time = $::os_service_default,
) {
include heat::deps
@ -120,4 +153,13 @@ class heat::cache (
memcache_pool_connection_get_timeout => $memcache_pool_connection_get_timeout,
manage_backend_package => $manage_backend_package,
}
heat_config {
'constraint_validation_cache/caching': value => $constraint_validation_caching;
'constraint_validation_cache/expiration_time': value => $constraint_validation_expiration_time;
'service_extension_cache/caching': value => $service_extension_caching;
'service_extension_cache/expiration_time': value => $service_extension_expiration_time;
'resource_finder_cache/caching': value => $resource_finder_caching;
'resource_finder_cache/expiration_time': value => $resource_finder_expiration_time;
}
}

View File

@ -0,0 +1,12 @@
---
features:
- |
The following parameters are added in ``heat::cache`` to configure chaching
in specific module.
- ``constraint_validation_caching``
- ``constraint_validation_expiration_time``
- ``service_extension_caching``
- ``service_extension_expiration_time``
- ``resource_finder_caching``
- ``resource_finder_expiration_time``

View File

@ -24,25 +24,37 @@ describe 'heat::cache' do
is_expected.to contain_heat_config('cache/memcache_pool_unused_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_heat_config('cache/memcache_pool_connection_get_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_oslo__cache('heat_config').with_manage_backend_package(true)
is_expected.to contain_heat_config('constraint_validation_cache/caching').with_value('<SERVICE DEFAULT>')
is_expected.to contain_heat_config('constraint_validation_cache/expiration_time').with_value('<SERVICE DEFAULT>')
is_expected.to contain_heat_config('service_extension_cache/caching').with_value('<SERVICE DEFAULT>')
is_expected.to contain_heat_config('service_extension_cache/expiration_time').with_value('<SERVICE DEFAULT>')
is_expected.to contain_heat_config('resource_finder_cache/caching').with_value('<SERVICE DEFAULT>')
is_expected.to contain_heat_config('resource_finder_cache/expiration_time').with_value('<SERVICE DEFAULT>')
end
end
context 'with overridden parameters' do
let :params do
{
:config_prefix => 'prefix',
:expiration_time => '3600',
:backend => 'oslo_cache.memcache_pool',
:proxies => ['proxy01:8888', 'proxy02:8888'],
:enabled => true,
:debug_cache_backend => false,
:memcache_servers => ['memcached01:11211', 'memcached02:11211'],
:memcache_dead_retry => '60',
:memcache_socket_timeout => '300.0',
:memcache_pool_maxsize => '10',
:memcache_pool_unused_timeout => '120',
:memcache_pool_connection_get_timeout => '360',
:manage_backend_package => false,
:config_prefix => 'prefix',
:expiration_time => '3600',
:backend => 'oslo_cache.memcache_pool',
:proxies => ['proxy01:8888', 'proxy02:8888'],
:enabled => true,
:debug_cache_backend => false,
:memcache_servers => ['memcached01:11211', 'memcached02:11211'],
:memcache_dead_retry => '60',
:memcache_socket_timeout => '300.0',
:memcache_pool_maxsize => '10',
:memcache_pool_unused_timeout => '120',
:memcache_pool_connection_get_timeout => '360',
:manage_backend_package => false,
:constraint_validation_caching => true,
:constraint_validation_expiration_time => '3600',
:service_extension_caching => true,
:service_extension_expiration_time => '3600',
:resource_finder_caching => true,
:resource_finder_expiration_time => '3600',
}
end
@ -61,6 +73,12 @@ describe 'heat::cache' do
is_expected.to contain_heat_config('cache/memcache_pool_unused_timeout').with_value('120')
is_expected.to contain_heat_config('cache/memcache_pool_connection_get_timeout').with_value('360')
is_expected.to contain_oslo__cache('heat_config').with_manage_backend_package(false)
is_expected.to contain_heat_config('constraint_validation_cache/caching').with_value('true')
is_expected.to contain_heat_config('constraint_validation_cache/expiration_time').with_value('3600')
is_expected.to contain_heat_config('service_extension_cache/caching').with_value('true')
is_expected.to contain_heat_config('service_extension_cache/expiration_time').with_value('3600')
is_expected.to contain_heat_config('resource_finder_cache/caching').with_value('true')
is_expected.to contain_heat_config('resource_finder_cache/expiration_time').with_value('3600')
end
end
end