Merge "Update oslo::cache define"

This commit is contained in:
Jenkins 2016-03-31 17:57:58 +00:00 committed by Gerrit Code Review
commit 415e4ba734
2 changed files with 139 additions and 39 deletions

View File

@ -40,74 +40,78 @@
# (Optional) Prefix for building the configuration dictionary for # (Optional) Prefix for building the configuration dictionary for
# the cache region. This should not need to be changed unless there # the cache region. This should not need to be changed unless there
# is another dogpile.cache region with the same configuration name. # is another dogpile.cache region with the same configuration name.
# Defaults to 'cache.oslo'. # (string value)
# Defaults to $::os_service_default
# #
# [*expiration_time*] # [*expiration_time*]
# (Optional) Default TTL, in seconds, for any cached item in the # (Optional) Default TTL, in seconds, for any cached item in the
# dogpile.cache region. This applies to any cached method that # dogpile.cache region. This applies to any cached method that
# doesn't have an explicit cache expiration time defined for it. # doesn't have an explicit cache expiration time defined for it.
# Defaults to 600. # (integer value)
# Defaults to $::os_service_default
# #
# [*backend*] # [*backend*]
# (Optional) Dogpile.cache backend module. It is recommended that # (Optional) Dogpile.cache backend module. It is recommended that
# Memcache with pooling (oslo_cache.memcache_pool) or Redis # Memcache with pooling (oslo_cache.memcache_pool) or Redis
# (dogpile.cache.redis) be used in production deployments. # (dogpile.cache.redis) be used in production deployments. (string value)
# Defaults to 'dogpile.cache.null'. # Defaults to $::os_service_default
# #
# [*backend_argument*] # [*backend_argument*]
# (Optional) Arguments supplied to the backend module. Specify this option # (Optional) Arguments supplied to the backend module. Specify this option
# once per argument to be passed to the dogpile.cache backend. # once per argument to be passed to the dogpile.cache backend.
# Example format: "<argname>:<value>". # Example format: "<argname>:<value>". (string value)
# Defaults to []. # Defaults to $::os_service_default
# #
# [*proxies*] # [*proxies*]
# (Optional) Proxy classes to import that will affect the way the # (Optional) Proxy classes to import that will affect the way the
# dogpile.cache backend functions. See the dogpile.cache documentation on # dogpile.cache backend functions. See the dogpile.cache documentation on
# changing-backend-behavior. # changing-backend-behavior. (list value)
# Defaults to []. # Defaults to $::os_service_default
# #
# [*enabled*] # [*enabled*]
# (Optional) Global toggle for caching. # (Optional) Global toggle for caching. (boolean value)
# Defaults to false. # Defaults to $::os_service_default
# #
# [*debug_cache_backend*] # [*debug_cache_backend*]
# (Optional) Extra debugging from the cache backend (cache keys, # (Optional) Extra debugging from the cache backend (cache keys,
# get/set/delete/etc calls). This is only really useful if you need # 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. # to see the specific cache-backend get/set/delete calls with the keys/values.
# Typically this should be left set to false. # Typically this should be left set to false. (boolean value)
# Defaults to false. # Defaults to $::os_service_default
# #
# [*memcache_servers*] # [*memcache_servers*]
# (Optional) Memcache servers in the format of "host:port". # (Optional) Memcache servers in the format of "host:port".
# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only). # (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
# Defaults to ['localhost::11211']. # (list value)
# Defaults to $::os_service_default
# #
# [*memcache_dead_retry*] # [*memcache_dead_retry*]
# (Optional) Number of seconds memcached server is considered dead before # (Optional) Number of seconds memcached server is considered dead before
# it is tried again. # it is tried again. (dogpile.cache.memcache and oslo_cache.memcache_pool
# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only). # backends only). (integer value)
# Defaults to '300'. # Defaults to $::os_service_default
# #
# [*memcache_socket_timeout*] # [*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). # (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
# Defaults to '3'. # (integer value)
# Defaults to $::os_service_default
# #
# [*memcache_pool_maxsize*] # [*memcache_pool_maxsize*]
# (Optional) Timeout in seconds for every call to a server.' # Max total number of open connections to every memcached server.
# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only). # (oslo_cache.memcache_pool backend only). (integer value)
# Defaults to '10'. # Defaults to $::os_service_default
# #
# [*memcache_pool_unused_timeout*] # [*memcache_pool_unused_timeout*]
# (Optional) Number of seconds a connection to memcached is held unused # (Optional) Number of seconds a connection to memcached is held unused
# in the pool before it is closed. # in the pool before it is closed. (oslo_cache.memcache_pool backend only)
# (oslo_cache.memcache_pool backend only) # (integer value)
# Defaults to '60'. # Defaults to $::os_service_default
# #
# [*memcache_pool_connection_get_timeout*] # [*memcache_pool_connection_get_timeout*]
# (Optional) Number of seconds that an operation will wait to get a memcache # (Optional) Number of seconds that an operation will wait to get a memcache
# client connection. # client connection. (integer value)
# Defaults to '10'. # Defaults to $::os_service_default
# #
define oslo::cache( define oslo::cache(
$config_prefix = $::os_service_default, $config_prefix = $::os_service_default,
@ -124,17 +128,34 @@ define oslo::cache(
$memcache_pool_unused_timeout = $::os_service_default, $memcache_pool_unused_timeout = $::os_service_default,
$memcache_pool_connection_get_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 }}) if !is_service_default($memcache_servers) and is_array($memcache_servers) {
create_resources($name, {'cache/backend' => { value => $backend }}) $memcache_servers_orig = join($memcache_servers, ',')
create_resources($name, {'cache/backend_argument' => { value => $backend_argument }}) } else {
create_resources($name, {'cache/proxies' => { value => $proxies }}) $memcache_servers_orig = $memcache_servers
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 }}) if !is_service_default($proxies) and is_array($proxies) {
create_resources($name, {'cache/memcache_dead_retry' => { value => $memcache_dead_retry }}) $proxies_orig = join($proxies, ',')
create_resources($name, {'cache/memcache_socket_timeout' => { value => $memcache_socket_timeout }}) } else {
create_resources($name, {'cache/memcache_pool_maxsize' => { value => $memcache_pool_maxsize }}) $proxies_orig = $proxies
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 }})
$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)
} }

View 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