From c6b931c6fdf32a8b6152f74bede41153b5095dcd Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sun, 29 Aug 2021 08:54:57 +0900 Subject: [PATCH] cache: support etcd3gw backend This change introduces support to use ectd3gw backend as oslo.cache backend, and makes the required backend package installed. The same backend is already supported for coordination and this change leverage the existing definitions added for coordination. Change-Id: Id0eec018a68ab4a510307f150aa2a6ee017fa651 --- manifests/cache.pp | 6 ++++ spec/defines/oslo_cache_spec.rb | 51 +++++++++++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/manifests/cache.pp b/manifests/cache.pp index a546631..afc0b77 100644 --- a/manifests/cache.pp +++ b/manifests/cache.pp @@ -202,6 +202,12 @@ define oslo::cache( name => $::oslo::params::python_memcache_package_name, tag => ['openstack'], }) + } elsif ($backend =~ /\.etcd3gw/ ) { + ensure_packages('python-etcd3gw', { + name => $::oslo::params::python_etcd3gw_package_name, + ensure => $package_ensure, + tag => 'openstack', + }) } } diff --git a/spec/defines/oslo_cache_spec.rb b/spec/defines/oslo_cache_spec.rb index 4704565..cb067e2 100644 --- a/spec/defines/oslo_cache_spec.rb +++ b/spec/defines/oslo_cache_spec.rb @@ -165,6 +165,51 @@ describe 'oslo::cache' do end end + context 'with etcd3gw backend' do + let :params do + { + :backend => 'oslo_cache.etcd3gw', + } + end + + it 'configures cache backend' do + is_expected.to contain_keystone_config('cache/backend').with_value('oslo_cache.etcd3gw') + is_expected.to contain_package('python-etcd3gw').with( + :ensure => 'present', + :name => platform_params[:python_etcd3gw_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-etcd3gw').with( + :ensure => 'latest', + :name => platform_params[:python_etcd3gw_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-etcd3gw') + end + end + end + context 'with string in list parameters' do let :params do { @@ -194,10 +239,12 @@ describe 'oslo::cache' do case facts[:osfamily] when 'Debian' { :pylibmc_package_name => 'python3-pylibmc', - :python_memcache_package_name => 'python3-memcache' } + :python_memcache_package_name => 'python3-memcache', + :python_etcd3gw_package_name => 'python3-etcd3gw' } when 'RedHat' { :pylibmc_package_name => 'python3-pylibmc', - :python_memcache_package_name => 'python3-memcached' } + :python_memcache_package_name => 'python3-memcached', + :python_etcd3gw_package_name => 'python3-etcd3gw' } end end