Merge "CentOS: Skip redundant compress/cache clear"

This commit is contained in:
Zuul 2023-09-15 14:06:14 +00:00 committed by Gerrit Code Review
commit c4af4b3d35
2 changed files with 21 additions and 48 deletions

View File

@ -718,22 +718,14 @@ class horizon(
require => Anchor['horizon::config::begin'],
}
exec { 'refresh_horizon_django_cache':
command => "${::horizon::params::manage_py} collectstatic --noinput --clear",
refreshonly => true,
tag => ['horizon-compress'],
}
exec { 'refresh_horizon_django_compress':
command => "${::horizon::params::manage_py} compress --force",
refreshonly => true,
tag => ['horizon-compress'],
}
if $compress_offline {
Concat<| tag == 'django-config' |> ~> Exec['refresh_horizon_django_compress']
if $facts['os']['family'] == 'RedHat' {
Concat<| tag == 'django-config' |> ~> Exec['refresh_horizon_django_cache'] -> Exec['refresh_horizon_django_compress']
if $facts['os']['family'] == 'Debian' {
exec { 'refresh_horizon_django_compress':
command => "${::horizon::params::manage_py} compress --force",
refreshonly => true,
tag => ['horizon-compress'],
}
Concat<| tag == 'django-config' |> ~> Exec['refresh_horizon_django_compress']
}
}

View File

@ -23,23 +23,8 @@ describe 'horizon' do
:tag => ['openstack', 'horizon-package'],
)
}
it { is_expected.to contain_exec('refresh_horizon_django_cache').with({
:command => '/usr/share/openstack-dashboard/manage.py collectstatic --noinput --clear',
:refreshonly => true,
})}
it { is_expected.to contain_exec('refresh_horizon_django_compress').with({
:command => '/usr/share/openstack-dashboard/manage.py compress --force',
:refreshonly => true,
})}
it {
if facts[:os]['family'] == 'RedHat'
is_expected.to contain_concat(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]')
is_expected.to contain_concat(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_compress]')
else
is_expected.to_not contain_concat(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]')
is_expected.to contain_concat(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_compress]')
end
it {
is_expected.to contain_concat(platforms_params[:config_file]).with(
:mode => '0640',
:owner => platforms_params[:wsgi_user],
@ -231,8 +216,7 @@ describe 'horizon' do
end
it { is_expected.to contain_file(platforms_params[:conf_d_dir]).with_ensure('directory') }
it { is_expected.not_to contain_file(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]') }
it { is_expected.not_to contain_file(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_compress]') }
it { is_expected.to_not contain_exec('refresh_horizon_django_compress') }
it { is_expected.to contain_file(params[:file_upload_temp_dir]) }
end
@ -249,9 +233,6 @@ describe 'horizon' do
" 'LOCATION': [ '10.0.0.1:11211','10.0.0.2:11211', ],",
])
end
it { is_expected.to contain_exec('refresh_horizon_django_cache') }
it { is_expected.to contain_exec('refresh_horizon_django_compress') }
end
context 'with overridden parameters, IPv6 cache_server_ip array and MemcachedCache' do
@ -268,9 +249,6 @@ describe 'horizon' do
" 'LOCATION': [ 'inet6:[fd12:3456:789a:1::1]:11211','inet6:[fd12:3456:789a:1::2]:11211', ],",
])
end
it { is_expected.to contain_exec('refresh_horizon_django_cache') }
it { is_expected.to contain_exec('refresh_horizon_django_compress') }
end
context 'with overridden parameters, IPv6 cache_server_ip array and PyMemcacheCache' do
@ -287,9 +265,6 @@ describe 'horizon' do
" 'LOCATION': [ '[fd12:3456:789a:1::1]:11211','[fd12:3456:789a:1::2]:11211', ],",
])
end
it { is_expected.to contain_exec('refresh_horizon_django_cache') }
it { is_expected.to contain_exec('refresh_horizon_django_compress') }
end
context 'with overridden parameters and cache_server_url (string)' do
@ -304,9 +279,6 @@ describe 'horizon' do
" 'LOCATION': 'redis://:password@10.0.0.1:6379/1',",
])
end
it { is_expected.to contain_exec('refresh_horizon_django_cache') }
it { is_expected.to contain_exec('refresh_horizon_django_compress') }
end
context 'with overridden parameters and cache_server_url (array)' do
@ -321,9 +293,6 @@ describe 'horizon' do
" 'LOCATION': ['192.0.2.1:11211','192.0.2.2:11211'],",
])
end
it { is_expected.to contain_exec('refresh_horizon_django_cache') }
it { is_expected.to contain_exec('refresh_horizon_django_compress') }
end
context 'installs python memcache library when cache_backend is set to memcache' do
@ -748,6 +717,10 @@ describe 'horizon' do
end
shared_examples_for 'horizon on RedHat' do
it 'skips refreshing horizon django cache' do
is_expected.to_not contain_exec('refresh_horizon_django_compress')
end
it 'sets WEBROOT in local_settings.py' do
verify_concat_fragment_contents(catalogue, 'local_settings.py', [
"WEBROOT = '/dashboard/'",
@ -756,6 +729,14 @@ describe 'horizon' do
end
shared_examples_for 'horizon on Debian' do
it 'refreshes horizon django cache' do
is_expected.to contain_exec('refresh_horizon_django_compress').with({
:command => '/usr/share/openstack-dashboard/manage.py compress --force',
:refreshonly => true,
})
is_expected.to contain_concat(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_compress]')
end
it 'sets WEBROOT in local_settings.py' do
verify_concat_fragment_contents(catalogue, 'local_settings.py', [
"WEBROOT = '/horizon/'",