diff --git a/lib/katello/tasks/refresh_repos.rake b/lib/katello/tasks/refresh_repos.rake new file mode 100644 index 00000000000..32ec4c8a00c --- /dev/null +++ b/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 diff --git a/test/lib/tasks/refresh_repos_test.rb b/test/lib/tasks/refresh_repos_test.rb new file mode 100644 index 00000000000..3d8b254aed5 --- /dev/null +++ b/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