Skip to content

Commit

Permalink
Refs #32917 - Don't deploy or configure Redis with new tasking system
Browse files Browse the repository at this point in the history
  • Loading branch information
wbclark committed Jul 8, 2021
1 parent 3998b57 commit 0933244
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 8 deletions.
4 changes: 3 additions & 1 deletion manifests/database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
require => Pulpcore::Admin['migrate --noinput'],
}

include redis
if $pulpcore::uses_redis {
include redis
}

}
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@
) {
$settings_file = "${config_dir}/settings.py"

$uses_redis = $use_rq_tasking_system or $cache_enabled

contain pulpcore::install
contain pulpcore::database
contain pulpcore::config
Expand Down
21 changes: 18 additions & 3 deletions spec/acceptance/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,19 @@ class { 'pulpcore':
its(:exit_status) { is_expected.to eq 0 }
end

describe service('rh-redis5-redis'), if: %w[centos redhat].include?(os[:family]) && os[:release].to_i == 7 do
it { is_expected.not_to be_running }
it { is_expected.not_to be_enabled }
end

describe service('redis'), unless: %w[centos redhat].include?(os[:family]) && os[:release].to_i == 7 do
it { is_expected.not_to be_running }
it { is_expected.not_to be_enabled }
end

describe command("DJANGO_SETTINGS_MODULE=pulpcore.app.settings PULP_SETTINGS=/etc/pulp/settings.py rq info -c pulpcore.rqconfig") do
its(:stdout) { is_expected.to match(/^0 workers, /) }
its(:stdout) { is_expected.not_to match(/^resource-manager /) }
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.not_to match(/Connection refused/) }
its(:exit_status) { is_expected.to eq 1 }
end
end

Expand Down Expand Up @@ -174,6 +183,12 @@ class { 'pulpcore':
it { is_expected.to be_enabled }
end

describe command("DJANGO_SETTINGS_MODULE=pulpcore.app.settings PULP_SETTINGS=/etc/pulp/settings.py rq info -c pulpcore.rqconfig") do
its(:stdout) { is_expected.to match(/^0 workers, /) }
its(:stdout) { is_expected.not_to match(/^resource-manager /) }
its(:exit_status) { is_expected.to eq 0 }
end

describe curl_command("https://#{host_inventory['fqdn']}/pulp/api/v3/status/", cacert: "#{certdir}/ca-cert.pem") do
its(:response_code) { is_expected.to eq(200) }
its(:exit_status) { is_expected.to eq 0 }
Expand Down
65 changes: 61 additions & 4 deletions spec/classes/pulpcore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
is_expected.to contain_exec('pulpcore-manager collectstatic --noinput')
end

it 'configures the database' do
it 'configures the PostgreSQL database' do
is_expected.to contain_class('pulpcore::database')
is_expected.to contain_class('postgresql::server')
is_expected.to contain_postgresql__server__db('pulpcore')
Expand All @@ -51,6 +51,29 @@
is_expected.to contain_exec('pulpcore-manager reset-admin-password --random')
end

it 'does not install 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_POST/)
.without_content(/REDIS_DB/)
end

it 'does not configure content caching' do
is_expected.to contain_concat__fragment('base')
.without_content(/CACHE_ENABLED = True/)
.without_content(%r{CACHE_SETTINGS = \{\n 'EXPIRES_TTL': 60,\n\}})
end

it 'configures pulpcore to use PostgreSQL tasking system' do
is_expected.to contain_concat__fragment('base')
.with_content(/USE_NEW_WORKER_TYPE = True/)
is_expected.to contain_systemd__unit_file('pulpcore-resource-manager.service').with_ensure('absent')
end

it 'configures apache' do
is_expected.to contain_class('pulpcore::apache')
is_expected.to contain_apache__vhost('pulpcore')
Expand Down Expand Up @@ -128,7 +151,6 @@
is_expected.to contain_systemd__unit_file('pulpcore-content.socket')
is_expected.to contain_systemd__unit_file('pulpcore-content.service')
is_expected.to contain_file('/etc/systemd/system/pulpcore-content.socket').that_comes_before('Service[pulpcore-content.service]')
is_expected.to contain_systemd__unit_file('pulpcore-resource-manager.service').with_ensure('absent')
is_expected.to contain_systemd__unit_file('[email protected]')
is_expected.to contain_service("[email protected]").with_ensure(true)
is_expected.not_to contain_service("[email protected]")
Expand Down Expand Up @@ -491,11 +513,46 @@
}
end

it do
it 'configures content caching' do
is_expected.to contain_concat__fragment('base')
.with_content(%r{CACHE_ENABLED = True})
.with_content(/CACHE_ENABLED = True/)
.with_content(%r{CACHE_SETTINGS = \{\n 'EXPIRES_TTL': 60,\n\}})
end

it 'installs 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 'can enable RQ tasking system' do
let :params do
{
use_rq_tasking_system: true,
}
end

it 'configures RQ tasking system' do
is_expected.to contain_concat__fragment('base')
.with_content(/USE_NEW_WORKER_TYPE = False/)
end

it 'installs 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
Expand Down
3 changes: 3 additions & 0 deletions templates/settings.py.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ DATABASES = {
<% end -%>
},
}

<% if scope['pulpcore::uses_redis'] -%>
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" %>

MEDIA_ROOT = "<%= scope['pulpcore::media_root'] %>"
Expand Down

0 comments on commit 0933244

Please sign in to comment.