Skip to content

Commit

Permalink
Fix twopence_init after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
cbosdo committed Aug 31, 2023
1 parent e37f19b commit dcdb41c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion testsuite/features/step_definitions/command_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@
# cert-manager takes some time to generate the secret, wait for it before continuing
repeat_until_timeout(timeout: 600, message: "Kubernetes uyuni-proxy-cert secret has not been defined") do
_result, code = $server.run_local("kubectl get secret uyuni-proxy-cert", check_errors: false)
break if code.zero?
break if code.zero?
sleep 1
end
_out, return_code = $server.run_local("kubectl get secret uyuni-proxy-cert -o jsonpath='{.data.tls\\.crt}' | base64 -d >/tmp/proxy.crt")
Expand Down
9 changes: 4 additions & 5 deletions testsuite/features/support/lavanda.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ def run(cmd, separated_results: false, check_errors: true, timeout: DEFAULT_TIME
cmd_prefixed = cmd
if @in_has_uyunictl
cmd_prefixed = "uyunictl exec -i '#{cmd.gsub(/'/, '\'"\'"\'')}'"
print "#{cmd_prefixed}\n"
end
run_local(cmd_prefixed, separated_results: separated_results, check_errors: check_errors, timeout: timeout, user: user, successcodes: successcodes, buffer_size: buffer_size, verbose: verbose)
end
Expand Down Expand Up @@ -263,8 +262,8 @@ def extract(remote_file, local_file, user = "root", dots = true)

def file_exists(file)
if @in_has_uyunictl
_out, code = run_local("uyunictl exec -- 'test -f #{file}'", check_errors: false)
exists = code.zero?
_out, code = run_local("uyunictl exec -- 'test -f #{file}'", check_errors: false)
exists = code.zero?
else
_out, local, _remote, code = test_and_store_results_together("test -f #{file}", 'root', 500)
exists = code.zero? && local.zero?
Expand All @@ -274,8 +273,8 @@ def file_exists(file)

def folder_exists(file)
if @in_has_uyunictl
_out, code = run_local("uyunictl exec -- 'test -d #{file}'", check_errors: false)
exists = code.zero?
_out, code = run_local("uyunictl exec -- 'test -d #{file}'", check_errors: false)
exists = code.zero?
else
_out, local, _remote, code = test_and_store_results_together("test -d #{file}", 'root', 500)
exists = code.zero? && local.zero?
Expand Down
27 changes: 17 additions & 10 deletions testsuite/features/support/twopence_init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Licensed under the terms of the MIT license.

require 'twopence'
require_relative 'lavanda'

# Retrieve and set OS Family and Version of a node
def process_os_family_and_version(host, fqdn, hostname, node)
Expand Down Expand Up @@ -59,24 +60,29 @@ def twopence_init(host)
# Lavanda library module extension
# Look at support/lavanda.rb for more details
node.extend(LavandaBasic)
if host == $server

if host == 'server'
_out, code = node.run('which uyunictl', check_errors: false)
if code.zero?
node.init_has_uyunictl
end
end
if node == $server

fqdn, code = node.run('sed -n \'s/^java.hostname *= *\(.\+\)$/\1/p\' /etc/rhn/rhn.conf')
raise "Cannot connect to get FQDN for '#{$named_nodes[node.hash]}'. Response code: #{code}, local: #{local}, remote: #{remote}" if code.nonzero?
raise "No FQDN for '#{$named_nodes[node.hash]}'. Response code: #{code}" if fqdn.empty?
node.init_full_hostname(fqdn)
node.init_hostname(fqdn.split(".")[0])
node.init_hostname(fqdn.split('.')[0])

node = process_os_family_and_version(host, fqdn, node.hostname, node)
node = process_private_and_public_ip(host, node)
else
# Initialize hostname
hostname, local, remote, code = node.test_and_store_results_together('hostname', 'root', 500)

# special handling for nested VMs since they will only be crated later in the test suite
# we to a late hostname initialization in a special step for those

unless hostname.empty? || node == $salt_migration_minion
unless hostname.empty? || host == 'salt_migration_minion'
raise "Cannot connect to get hostname for '#{$named_nodes[node.hash]}'. Response code: #{code}, local: #{local}, remote: #{remote}" if code.nonzero? || remote.nonzero? || local.nonzero?
raise "No hostname for '#{$named_nodes[node.hash]}'. Response code: #{code}" if hostname.empty?
node.init_hostname(hostname)
Expand All @@ -85,12 +91,13 @@ def twopence_init(host)
raise "Cannot connect to get FQDN for '#{$named_nodes[node.hash]}'. Response code: #{code}, local: #{local}, remote: #{remote}" if code.nonzero? || remote.nonzero? || local.nonzero?
raise "No FQDN for '#{$named_nodes[node.hash]}'. Response code: #{code}" if fqdn.empty?
node.init_full_hostname(fqdn)

node = process_os_family_and_version(host, fqdn, hostname, node)
node = process_private_and_public_ip(host, node)
end
end

STDOUT.puts "Host '#{$named_nodes[node.hash]}' is alive with determined hostname #{node.hostname} and FQDN #{node.full_hostname}" unless $build_validation
os_version, os_family = get_os_version(node)
node.init_os_family(os_family)
node.init_os_version(os_version)
$node_by_host[host] = node
$host_by_node[node] = host
node
end

0 comments on commit dcdb41c

Please sign in to comment.