Merge "Update oslo::cache define"
This commit is contained in:
commit
415e4ba734
@ -40,74 +40,78 @@
|
||||
# (Optional) Prefix for building the configuration dictionary for
|
||||
# the cache region. This should not need to be changed unless there
|
||||
# is another dogpile.cache region with the same configuration name.
|
||||
# Defaults to 'cache.oslo'.
|
||||
# (string value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*expiration_time*]
|
||||
# (Optional) Default TTL, in seconds, for any cached item in the
|
||||
# dogpile.cache region. This applies to any cached method that
|
||||
# doesn't have an explicit cache expiration time defined for it.
|
||||
# Defaults to 600.
|
||||
# (integer value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*backend*]
|
||||
# (Optional) Dogpile.cache backend module. It is recommended that
|
||||
# Memcache with pooling (oslo_cache.memcache_pool) or Redis
|
||||
# (dogpile.cache.redis) be used in production deployments.
|
||||
# Defaults to 'dogpile.cache.null'.
|
||||
# (dogpile.cache.redis) be used in production deployments. (string value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*backend_argument*]
|
||||
# (Optional) Arguments supplied to the backend module. Specify this option
|
||||
# once per argument to be passed to the dogpile.cache backend.
|
||||
# Example format: "<argname>:<value>".
|
||||
# Defaults to [].
|
||||
# Example format: "<argname>:<value>". (string value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*proxies*]
|
||||
# (Optional) Proxy classes to import that will affect the way the
|
||||
# dogpile.cache backend functions. See the dogpile.cache documentation on
|
||||
# changing-backend-behavior.
|
||||
# Defaults to [].
|
||||
# changing-backend-behavior. (list value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*enabled*]
|
||||
# (Optional) Global toggle for caching.
|
||||
# Defaults to false.
|
||||
# (Optional) Global toggle for caching. (boolean value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*debug_cache_backend*]
|
||||
# (Optional) Extra debugging from the cache backend (cache keys,
|
||||
# get/set/delete/etc calls). This is only really useful if you need
|
||||
# to see the specific cache-backend get/set/delete calls with the keys/values.
|
||||
# Typically this should be left set to false.
|
||||
# Defaults to false.
|
||||
# Typically this should be left set to false. (boolean value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*memcache_servers*]
|
||||
# (Optional) Memcache servers in the format of "host:port".
|
||||
# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
|
||||
# Defaults to ['localhost::11211'].
|
||||
# (list value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*memcache_dead_retry*]
|
||||
# (Optional) Number of seconds memcached server is considered dead before
|
||||
# it is tried again.
|
||||
# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
|
||||
# Defaults to '300'.
|
||||
# it is tried again. (dogpile.cache.memcache and oslo_cache.memcache_pool
|
||||
# backends only). (integer value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*memcache_socket_timeout*]
|
||||
# (Optional) Timeout in seconds for every call to a server.'
|
||||
# (Optional) Timeout in seconds for every call to a server.
|
||||
# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
|
||||
# Defaults to '3'.
|
||||
# (integer value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*memcache_pool_maxsize*]
|
||||
# (Optional) Timeout in seconds for every call to a server.'
|
||||
# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
|
||||
# Defaults to '10'.
|
||||
# Max total number of open connections to every memcached server.
|
||||
# (oslo_cache.memcache_pool backend only). (integer value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*memcache_pool_unused_timeout*]
|
||||
# (Optional) Number of seconds a connection to memcached is held unused
|
||||
# in the pool before it is closed.
|
||||
# (oslo_cache.memcache_pool backend only)
|
||||
# Defaults to '60'.
|
||||
# in the pool before it is closed. (oslo_cache.memcache_pool backend only)
|
||||
# (integer value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*memcache_pool_connection_get_timeout*]
|
||||
# (Optional) Number of seconds that an operation will wait to get a memcache
|
||||
# client connection.
|
||||
# Defaults to '10'.
|
||||
# client connection. (integer value)
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
define oslo::cache(
|
||||
$config_prefix = $::os_service_default,
|
||||
@ -124,17 +128,34 @@ define oslo::cache(
|
||||
$memcache_pool_unused_timeout = $::os_service_default,
|
||||
$memcache_pool_connection_get_timeout = $::os_service_default,
|
||||
){
|
||||
create_resources($name, {'cache/config_prefix' => { value => $config_prefix }})
|
||||
create_resources($name, {'cache/expiration_time' => { value => $expiration_time }})
|
||||
create_resources($name, {'cache/backend' => { value => $backend }})
|
||||
create_resources($name, {'cache/backend_argument' => { value => $backend_argument }})
|
||||
create_resources($name, {'cache/proxies' => { value => $proxies }})
|
||||
create_resources($name, {'cache/enabled' => { value => $enabled }})
|
||||
create_resources($name, {'cache/debug_cache_backend' => { value => $debug_cache_backend }})
|
||||
create_resources($name, {'cache/memcache_servers' => { value => $memcache_servers }})
|
||||
create_resources($name, {'cache/memcache_dead_retry' => { value => $memcache_dead_retry }})
|
||||
create_resources($name, {'cache/memcache_socket_timeout' => { value => $memcache_socket_timeout }})
|
||||
create_resources($name, {'cache/memcache_pool_maxsize' => { value => $memcache_pool_maxsize }})
|
||||
create_resources($name, {'cache/memcache_pool_unused_timeout' => { value => $memcache_pool_unused_timeout }})
|
||||
create_resources($name, {'cache/memcache_pool_connection_get_timeout' => { value => $memcache_pool_connection_get_timeout }})
|
||||
|
||||
if !is_service_default($memcache_servers) and is_array($memcache_servers) {
|
||||
$memcache_servers_orig = join($memcache_servers, ',')
|
||||
} else {
|
||||
$memcache_servers_orig = $memcache_servers
|
||||
}
|
||||
|
||||
if !is_service_default($proxies) and is_array($proxies) {
|
||||
$proxies_orig = join($proxies, ',')
|
||||
} else {
|
||||
$proxies_orig = $proxies
|
||||
}
|
||||
|
||||
$cache_options = {
|
||||
'cache/config_prefix' => { value => $config_prefix },
|
||||
'cache/expiration_time' => { value => $expiration_time },
|
||||
'cache/backend' => { value => $backend },
|
||||
'cache/backend_argument' => { value => $backend_argument },
|
||||
'cache/proxies' => { value => $proxies_orig },
|
||||
'cache/enabled' => { value => $enabled },
|
||||
'cache/debug_cache_backend' => { value => $debug_cache_backend },
|
||||
'cache/memcache_servers' => { value => $memcache_servers_orig },
|
||||
'cache/memcache_dead_retry' => { value => $memcache_dead_retry },
|
||||
'cache/memcache_socket_timeout' => { value => $memcache_socket_timeout },
|
||||
'cache/memcache_pool_maxsize' => { value => $memcache_pool_maxsize },
|
||||
'cache/memcache_pool_unused_timeout' => { value => $memcache_pool_unused_timeout },
|
||||
'cache/memcache_pool_connection_get_timeout' => { value => $memcache_pool_connection_get_timeout },
|
||||
}
|
||||
|
||||
create_resources($name, $cache_options)
|
||||
}
|
||||
|
79
spec/defines/oslo_cache_spec.rb
Normal file
79
spec/defines/oslo_cache_spec.rb
Normal file
@ -0,0 +1,79 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'oslo::cache' do
|
||||
|
||||
let (:title) { 'keystone_config' }
|
||||
|
||||
shared_examples 'shared examples' do
|
||||
|
||||
context 'with default parameters' do
|
||||
it 'configure oslo_cache default params' do
|
||||
is_expected.to contain_keystone_config('cache/config_prefix').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('cache/expiration_time').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('cache/backend').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('cache/backend_argument').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('cache/proxies').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('cache/enabled').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('cache/debug_cache_backend').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('cache/memcache_servers').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('cache/memcache_dead_retry').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('cache/memcache_socket_timeout').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('cache/memcache_pool_maxsize').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('cache/memcache_pool_unused_timeout').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('cache/memcache_pool_connection_get_timeout').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with overridden parameters' do
|
||||
let :params do
|
||||
{
|
||||
:config_prefix => 'cache.oslo',
|
||||
:expiration_time => '600',
|
||||
:backend => 'dogpile.cache.null',
|
||||
:backend_argument => 'foo:bar',
|
||||
:proxies => ['proxy1', 'proxy2'],
|
||||
:enabled => true,
|
||||
:debug_cache_backend => true,
|
||||
:memcache_servers => ['host1:11211', 'host2:11211'],
|
||||
:memcache_dead_retry => '300',
|
||||
:memcache_socket_timeout => '3',
|
||||
:memcache_pool_maxsize => '10',
|
||||
:memcache_pool_unused_timeout => '60',
|
||||
:memcache_pool_connection_get_timeout => '10',
|
||||
}
|
||||
end
|
||||
|
||||
it 'configures cache setion' do
|
||||
is_expected.to contain_keystone_config('cache/config_prefix').with_value('cache.oslo')
|
||||
is_expected.to contain_keystone_config('cache/expiration_time').with_value('600')
|
||||
is_expected.to contain_keystone_config('cache/backend').with_value('dogpile.cache.null')
|
||||
is_expected.to contain_keystone_config('cache/backend_argument').with_value('foo:bar')
|
||||
is_expected.to contain_keystone_config('cache/proxies').with_value('proxy1,proxy2')
|
||||
is_expected.to contain_keystone_config('cache/enabled').with_value('true')
|
||||
is_expected.to contain_keystone_config('cache/debug_cache_backend').with_value('true')
|
||||
is_expected.to contain_keystone_config('cache/memcache_servers').with_value('host1:11211,host2:11211')
|
||||
is_expected.to contain_keystone_config('cache/memcache_dead_retry').with_value('300')
|
||||
is_expected.to contain_keystone_config('cache/memcache_socket_timeout').with_value('3')
|
||||
is_expected.to contain_keystone_config('cache/memcache_pool_maxsize').with_value('10')
|
||||
is_expected.to contain_keystone_config('cache/memcache_pool_unused_timeout').with_value('60')
|
||||
is_expected.to contain_keystone_config('cache/memcache_pool_connection_get_timeout').with_value('10')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'on a Debian osfamily' do
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => "Debian" })
|
||||
end
|
||||
|
||||
include_examples 'shared examples'
|
||||
end
|
||||
|
||||
context 'on a RedHat osfamily' do
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => 'RedHat' })
|
||||
end
|
||||
|
||||
include_examples 'shared examples'
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user