Skip to content

Commit

Permalink
Fixes #35382 - Add rake task to refresh repos on all pulp proxies (Ka…
Browse files Browse the repository at this point in the history
…tello#10242)

Co-authored-by: Joniel Pasqualetto jpasqual@redhat.com
(cherry picked from commit 21107ca)
  • Loading branch information
chris1984 authored and sjha4 committed Aug 29, 2022
1 parent d43df9c commit e4935e7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/katello/tasks/refresh_repos.rake
@@ -0,0 +1,8 @@
namespace :katello do
desc 'Refresh all repositories in all smart proxies and main server'
task :refresh_repos => ["environment", "dynflow:client"] do
User.current = User.anonymous_api_admin
::ForemanTasks.async_task(::Actions::BulkAction, ::Actions::Pulp3::Orchestration::Repository::RefreshRepos, SmartProxy.all)
puts _("Repos are being refreshed in the background.")
end
end
18 changes: 18 additions & 0 deletions test/lib/tasks/refresh_repos_test.rb
@@ -0,0 +1,18 @@
require 'katello_test_helper'
require 'rake'

module Katello
class RefreshReposTest < ActiveSupport::TestCase
def setup
Rake.application.rake_require 'katello/tasks/refresh_repos'
Rake::Task['katello:refresh_repos'].reenable
Rake::Task.define_task(:environment)
Rake::Task.define_task('dynflow:client')
end

def test_refresh_repos_on_smart_proxies
::ForemanTasks.expects(:async_task).with(::Actions::BulkAction, ::Actions::Pulp3::Orchestration::Repository::RefreshRepos, SmartProxy.all)
Rake.application.invoke_task('katello:refresh_repos')
end
end
end

0 comments on commit e4935e7

Please sign in to comment.