diff --git a/definitions/checks/pulpcore/no_running_tasks.rb b/definitions/checks/pulpcore/no_running_tasks.rb index a807b05f3..3f112c241 100644 --- a/definitions/checks/pulpcore/no_running_tasks.rb +++ b/definitions/checks/pulpcore/no_running_tasks.rb @@ -2,6 +2,9 @@ module Checks::Pulpcore class NoRunningTasks < ForemanMaintain::Check metadata do for_feature :pulpcore + confine do + feature(:pulpcore)&.cli_available? + end description 'Check for running pulpcore tasks' tags :pre_upgrade param :wait_for_tasks, diff --git a/definitions/features/pulpcore.rb b/definitions/features/pulpcore.rb index 5ecba87e3..04360ff43 100644 --- a/definitions/features/pulpcore.rb +++ b/definitions/features/pulpcore.rb @@ -6,6 +6,7 @@ class Features::Pulpcore < ForemanMaintain::Feature TIMEOUT_FOR_TASKS_STATUS = 300 RETRY_INTERVAL_FOR_TASKS_STATE = 10 PULP_SETTINGS = '/etc/pulp/settings.py'.freeze + PULP_CLI_SETTINGS = '/etc/pulp/cli.toml'.freeze metadata do label :pulpcore @@ -15,6 +16,10 @@ class Features::Pulpcore < ForemanMaintain::Feature end end + def cli_available? + File.exist?(PULP_CLI_SETTINGS) + end + def cli(args) parse_json(execute("pulp --format json #{args}")) end diff --git a/test/definitions/features/pulpcore_test.rb b/test/definitions/features/pulpcore_test.rb new file mode 100644 index 000000000..9c241a42c --- /dev/null +++ b/test/definitions/features/pulpcore_test.rb @@ -0,0 +1,19 @@ +require 'test_helper' + +describe Features::Pulpcore do + include DefinitionsTestHelper + + subject { Features::Pulpcore.new } + + describe '.cli_available?' do + it 'recognizes server with CLI' do + File.expects(:exist?).with('/etc/pulp/cli.toml').returns(true) + assert subject.cli_available? + end + + it 'recognizes proxy without CLI' do + File.expects(:exist?).with('/etc/pulp/cli.toml').returns(false) + refute subject.cli_available? + end + end +end