From c3d7e096d0f9ff5e3e8ac3ad442fbf78ea1019b9 Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Wed, 4 Oct 2023 20:54:42 -0400 Subject: [PATCH] Refs #36801: Set Redis as the default cache on upgrade --- .../20231005004305_redis_default_cache.rb | 3 +++ .../231005004311-redis-default-cache.rb | 3 +++ spec/migration_spec.rb | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 config/foreman.migrations/20231005004305_redis_default_cache.rb create mode 100644 config/katello.migrations/231005004311-redis-default-cache.rb diff --git a/config/foreman.migrations/20231005004305_redis_default_cache.rb b/config/foreman.migrations/20231005004305_redis_default_cache.rb new file mode 100644 index 00000000..6ea76bfe --- /dev/null +++ b/config/foreman.migrations/20231005004305_redis_default_cache.rb @@ -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 diff --git a/config/katello.migrations/231005004311-redis-default-cache.rb b/config/katello.migrations/231005004311-redis-default-cache.rb new file mode 100644 index 00000000..6ea76bfe --- /dev/null +++ b/config/katello.migrations/231005004311-redis-default-cache.rb @@ -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 diff --git a/spec/migration_spec.rb b/spec/migration_spec.rb index ed961924..313e829a 100644 --- a/spec/migration_spec.rb +++ b/spec/migration_spec.rb @@ -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