Skip to content

Commit

Permalink
refresh collation version when pulp_ansible is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni authored and ekohl committed Jun 5, 2024
1 parent f6a4160 commit c6e7c2d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions definitions/procedures/restore/reindex_databases.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Procedures::Restore
class ReindexDatabases < ForemanMaintain::Procedure
include ForemanMaintain::Concerns::SystemService
include ForemanMaintain::Concerns::SystemHelpers

metadata do
description 'REINDEX databases'
Expand All @@ -16,6 +17,11 @@ def run

spinner.update('Reindexing the databases')
execute!('runuser - postgres -c "reindexdb -a"')
if check_min_version('python3.11-pulp-ansible', '0.20.0')
execute!('runuser -c '\
'\'echo "ALTER COLLATION pulp_ansible_semver REFRESH VERSION;"'\
'| psql pulpcore\' postgres')
end
end
end
end
Expand Down
13 changes: 13 additions & 0 deletions test/definitions/procedures/restore/reindex_databases_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
reindex_command = 'runuser - postgres -c "reindexdb -a"'

subject.stubs(:'execute!').with(reindex_command).returns(0)
subject.stubs(:check_min_version).returns(false)
result = run_procedure(subject)
assert result.success?, 'the procedure was expected to succeed'
end

it 'reindexes all DBs if DB is local and pulp-ansible is present' do
reindex_command = 'runuser - postgres -c "reindexdb -a"'
collate_command = 'runuser -c \'echo "ALTER COLLATION pulp_ansible_semver REFRESH VERSION;"'\
'| psql pulpcore\' postgres'

subject.stubs(:'execute!').with(reindex_command).returns(0)
subject.stubs(:check_min_version).with('python3.11-pulp-ansible', '0.20.0').returns(true)
subject.stubs(:'execute!').with(collate_command).returns(0)
result = run_procedure(subject)
assert result.success?, 'the procedure was expected to succeed'
end
Expand Down

0 comments on commit c6e7c2d

Please sign in to comment.