Skip to content

Commit

Permalink
Refs #29246 - handle hammer setup based on service change
Browse files Browse the repository at this point in the history
With this commit, renamed feature puma to foreman_service and
modified the hammer setup tests.
  • Loading branch information
kgaikwad committed Mar 5, 2020
1 parent 7d69769 commit 35cafd5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
8 changes: 5 additions & 3 deletions definitions/features/foreman_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ class ForemanServer < ForemanMaintain::Feature
end

def services
[
system_service('httpd', 30)
]
if feature(:foreman_service)
[feature(:foreman_service).service]
else
[system_service('httpd', 30)]
end
end

def plugins
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
module ForemanMaintain
module Features
class Puma < ForemanMaintain::Feature
class ForemanService < ForemanMaintain::Feature
metadata do
label :puma
confine do
package_manager.installed?(['foreman-service']) && check_min_version('foreman', '2.1')
end
end

def services
[
system_service('foreman', 30)
]
def service
system_service('foreman', 30)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion definitions/procedures/hammer_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Procedures::HammerSetup < ForemanMaintain::Procedure
end

def run
if feature(:foreman_server) && ForemanMaintain::Utils.system_service('httpd', 30).running?
if feature(:foreman_server) && feature(:foreman_server).services.first.running?
puts 'Configuring Hammer CLI...'
result = feature(:hammer).setup_admin_access
logger.info 'Hammer was configured successfully.' if result
Expand Down
2 changes: 2 additions & 0 deletions test/definitions/procedures/hammer_setup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def store_config_file(path)
context 'there is a default configuration with valid credentials' do
it 'uses the default config and sets the feature' do
assume_feature_present(:foreman_server)
assume_feature_absent(:foreman_service)
assume_service_running('httpd')
hammer_ins.stubs(:_check_connection).returns(true)
result = run_procedure(subject)
Expand All @@ -46,6 +47,7 @@ def store_config_file(path)
context 'there is a configuration with invalid credentials' do
it 'calls setup_admin_access and sets the feature' do
assume_feature_present(:foreman_server)
assume_feature_absent(:foreman_service)
assume_service_running('httpd')
hammer_ins.stubs(:_check_connection).returns(false)
hammer_ins.expects(:setup_admin_access).returns(true)
Expand Down

0 comments on commit 35cafd5

Please sign in to comment.