Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refs #36801: Set Redis as the default cache on upgrade #888

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if answers['foreman'].is_a?(Hash) && answers.dig('foreman', 'rails_cache_store', 'type') == 'file'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about dig, but didn't suggest it because I wasn't 100% sure if rails_cache_store was always a hash or nil. Now that I think more about it, I think that's all good.

answers['foreman']['rails_cache_store'] = { 'type' => 'redis' }
end
3 changes: 3 additions & 0 deletions config/katello.migrations/231005004311-redis-default-cache.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if answers['foreman'].is_a?(Hash) && answers.dig('foreman', 'rails_cache_store', 'type') == 'file'
answers['foreman']['rails_cache_store'] = { 'type' => 'redis' }
end
18 changes: 18 additions & 0 deletions spec/migration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,21 @@
end
end
end

migration '20231005004305_redis_default_cache' do
scenarios %w[foreman katello] do
context 'changes default cache to Redis' do
let(:answers) do
{
'foreman' => {
'rails_cache_store' => { 'type' => 'file' },
},
}
end

it 'changes the default to Redis' do
expect(migrated_answers['foreman']['rails_cache_store']).to eq({ 'type' => 'redis' })
end
end
end
end