cache: Ensure pymemcache library is installed

The pymemcache library should be installed when pymemcache backend is
used but this library is not required by the oslo.cache library or
its dependencies and should be installed additionally.

Closes-Bug: #1988205
Change-Id: I9422af416e74c53e09f6216bcbeab234337ccbae
This commit is contained in:
Takashi Kajinami 2022-08-31 02:36:10 +09:00
parent c47f5dbc4f
commit fc72a83bcc
3 changed files with 66 additions and 6 deletions

View File

@ -269,6 +269,12 @@ define oslo::cache(
name => $::oslo::params::python_memcache_package_name,
tag => ['openstack'],
})
} elsif ($backend =~ /\.pymemcache/ ) {
ensure_packages('python-pymemcache', {
ensure => $package_ensure,
name => $::oslo::params::python_pymemcache_package_name,
tag => ['openstack'],
})
} elsif ($backend =~ /\.etcd3gw/ ) {
ensure_packages('python-etcd3gw', {
name => $::oslo::params::python_etcd3gw_package_name,

View File

@ -0,0 +1,5 @@
---
features:
- |
Now the ``oslo::cache`` defined resource type installs
the pymemcache library when pymemcache backend is used.

View File

@ -197,6 +197,53 @@ describe 'oslo::cache' do
end
end
context 'with pymemcache backend' do
let :params do
{
:backend => 'dogpile.cache.pymemcache',
:memcache_servers => ['host1:11211', 'host2:11211','[fd12:3456:789a:1::1]:11211'],
}
end
it 'configures cache backend' do
is_expected.to contain_keystone_config('cache/backend').with_value('dogpile.cache.pymemcache')
is_expected.to contain_keystone_config('cache/memcache_servers').with_value('host1:11211,host2:11211,[fd12:3456:789a:1::1]:11211')
is_expected.to contain_package('python-pymemcache').with(
:ensure => 'installed',
:name => platform_params[:python_pymemcache_package_name],
:tag => ['openstack'],
)
end
context 'with package_ensure set' do
before do
params.merge!({
:package_ensure => 'latest'
})
end
it 'ensures status of the package' do
is_expected.to contain_package('python-pymemcache').with(
:ensure => 'latest',
:name => platform_params[:python_pymemcache_package_name],
:tag => ['openstack'],
)
end
end
context 'with backend package management disabled' do
before do
params.merge!({
:manage_backend_package => false,
})
end
it 'does not install backend package' do
is_expected.not_to contain_package('python-pymemcache')
end
end
end
context 'with etcd3gw backend' do
let :params do
{
@ -270,13 +317,15 @@ describe 'oslo::cache' do
let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :pylibmc_package_name => 'python3-pylibmc',
:python_memcache_package_name => 'python3-memcache',
:python_etcd3gw_package_name => 'python3-etcd3gw' }
{ :pylibmc_package_name => 'python3-pylibmc',
:python_memcache_package_name => 'python3-memcache',
:python_etcd3gw_package_name => 'python3-etcd3gw',
:python_pymemcache_package_name => 'python3-pymemcache' }
when 'RedHat'
{ :pylibmc_package_name => 'python3-pylibmc',
:python_memcache_package_name => 'python3-memcached',
:python_etcd3gw_package_name => 'python3-etcd3gw' }
{ :pylibmc_package_name => 'python3-pylibmc',
:python_memcache_package_name => 'python3-memcached',
:python_etcd3gw_package_name => 'python3-etcd3gw',
:python_pymemcache_package_name => 'python3-pymemcache' }
end
end