Skip to content

Commit

Permalink
confine pulpcore cli checks for setups where the cli is available
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Aug 26, 2024
1 parent 138cd96 commit cf26f56
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions definitions/checks/pulpcore/no_running_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions definitions/features/pulpcore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
19 changes: 19 additions & 0 deletions test/definitions/features/pulpcore_test.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cf26f56

Please sign in to comment.