From 760d79577c8b8906a12437e70e59ebbef5a25294 Mon Sep 17 00:00:00 2001 From: William Bradford Clark Date: Thu, 1 Jul 2021 12:31:06 -0400 Subject: [PATCH] Refs #32917 - Don't deploy or configure Redis with new tasking system --- manifests/database.pp | 4 +- spec/classes/redis_spec.rb | 89 ++++++++++++++++++++++++++++++++++++++ templates/settings.py.erb | 3 ++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 spec/classes/redis_spec.rb diff --git a/manifests/database.pp b/manifests/database.pp index 3630d88b..2afc7d1b 100644 --- a/manifests/database.pp +++ b/manifests/database.pp @@ -27,6 +27,8 @@ require => Pulpcore::Admin['migrate --noinput'], } - include redis + if $pulpcore::use_rq_tasking_system or $pulpcore::cache_enabled { + include redis + } } diff --git a/spec/classes/redis_spec.rb b/spec/classes/redis_spec.rb new file mode 100644 index 00000000..90e55b96 --- /dev/null +++ b/spec/classes/redis_spec.rb @@ -0,0 +1,89 @@ +require 'spec_helper' + +describe 'pulpcore' do + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { override_facts(os_facts, os: {selinux: {enabled: true}}) } + + context 'postgresql tasking system and content cache disabled' do + let(:params) do + { + use_rq_tasking_system: false, + cache_enabled: false, + } + end + + it 'does not include redis' do + is_expected.not_to contain_class('redis') + end + + it 'does not configure pulpcore connection to redis' do + is_expected.to contain_concat__fragment('base') + .without_content(/REDIS_HOST/) + .without_content(/REDIS_PORT/) + .without_content(/REDIS_DB/) + end + end + + context 'rq tasking system and content cache disabled' do + let(:params) do + { + use_rq_tasking_system: true, + cache_enabled: false, + } + end + + it 'includes redis' do + is_expected.to contain_class('redis') + end + + it 'configures pulpcore connection to redis' do + is_expected.to contain_concat__fragment('base') + .with_content(/REDIS_HOST/) + .with_content(/REDIS_PORT/) + .with_content(/REDIS_DB/) + end + end + + context 'postgresql tasking system and content cache enabled' do + let(:params) do + { + use_rq_tasking_system: false, + cache_enabled: true, + } + end + + it 'includes redis' do + is_expected.to contain_class('redis') + end + + it 'configures pulpcore connection to redis' do + is_expected.to contain_concat__fragment('base') + .with_content(/REDIS_HOST/) + .with_content(/REDIS_PORT/) + .with_content(/REDIS_DB/) + end + end + + context 'rq tasking system and content cache enabled' do + let(:params) do + { + use_rq_tasking_system: true, + cache_enabled: true, + } + end + + it 'includes redis' do + is_expected.to contain_class('redis') + end + + it 'configures pulpcore connection to redis' do + is_expected.to contain_concat__fragment('base') + .with_content(/REDIS_HOST/) + .with_content(/REDIS_PORT/) + .with_content(/REDIS_DB/) + end + end + end + end +end diff --git a/templates/settings.py.erb b/templates/settings.py.erb index 7207c1d5..19c0a44a 100644 --- a/templates/settings.py.erb +++ b/templates/settings.py.erb @@ -19,9 +19,12 @@ DATABASES = { <% end -%> }, } + +<% if scope['pulpcore::use_rq_tasking_system'] || scope['pulpcore::cache_enabled'] -%> REDIS_HOST = "localhost" REDIS_PORT = "<%= scope['redis::port'] %>" REDIS_DB = <%= scope['pulpcore::redis_db'] %> +<% end -%> USE_NEW_WORKER_TYPE = <%= scope['pulpcore::use_rq_tasking_system'] ? "False" : "True" %>