Skip to content

Commit

Permalink
Improve the Twopence lazy initzialition refactor (#7457)
Browse files Browse the repository at this point in the history
* QE: Fix the request of targets not defined

* QE: Fix a incorrect call to get a target
  • Loading branch information
srbarrios authored Aug 24, 2023
1 parent 86ecd9c commit e0c55ef
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
9 changes: 7 additions & 2 deletions testsuite/.rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,18 @@ Lint/UselessAssignment:
# Offense count: 9
# Configuration parameters: IgnoredMethods.
Metrics/AbcSize:
Max: 46
Enabled: false

# Offense count: 6
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 67
Max: 74

# Offense count: 4
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Enabled: false

# Offense count: 21
# Configuration parameters: CountComments, ExcludedMethods.
Expand Down
3 changes: 1 addition & 2 deletions testsuite/features/step_definitions/cobbler_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@
# cobbler reports
When(/^I trigger cobbler system record on the "([^"]*)"$/) do |host|
space = 'spacecmd -u admin -p admin'
system_name = get_system_name(host)
get_target('server').run("#{space} clear_caches")
out, _code = get_target('server').run("#{space} system_details #{system_name}")
out, _code = get_target('server').run("#{space} system_details #{get_target(host).full_hostname}")
unless out.include? 'ssh-push-tunnel'
steps %(
Given I am authorized as "testing" with password "testing"
Expand Down
3 changes: 2 additions & 1 deletion testsuite/features/support/commonlib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,9 @@ def get_system_name(host)
begin
node = get_target(host)
system_name = node.full_hostname
rescue RuntimeError
rescue NotImplementedError => e
# If the node for that host is not defined, just return the host parameter as system_name
warn e.message
system_name = host
end
end
Expand Down
7 changes: 7 additions & 0 deletions testsuite/features/support/twopence_init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ def process_private_and_public_ip(host, node)
# Initialize a Twopence node through its host (additionally it will setup some handy maps)
def twopence_init(host)
puts "Initializing a twopence node for '#{host}'."
raise(NotImplementedError, "Host #{host} is not defined as a valid host in the Test Framework.") unless ENV_VAR_BY_HOST.key? host

unless ENV.key? ENV_VAR_BY_HOST[host]
warn "Host #{host} is not defined as environment variable."
return
end

target = "ssh:#{ENV[ENV_VAR_BY_HOST[host]]}"
node = Twopence.init(target)
raise "Twopence node #{host} initialization has failed." if node.nil?
Expand Down

0 comments on commit e0c55ef

Please sign in to comment.