Skip to content

Commit

Permalink
QE: Fix Ruby stile (#7444)
Browse files Browse the repository at this point in the history
  • Loading branch information
srbarrios authored Aug 24, 2023
1 parent e0c55ef commit d17c127
Show file tree
Hide file tree
Showing 22 changed files with 230 additions and 231 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Feature: Register and test a Containerized Proxy
And the system ID for "sle15sp4_minion" should be correct
And the system name for "sle15sp4_minion" should be correct
And the uptime for "sle15sp4_minion" should be correct
And I should see several text fields for "sle15sp4_minion"
And I should see several text fields

Scenario: Install a patch on the Salt minion
When I follow "Software" in the content area
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Feature: Smoke tests for <client>
And the IPv6 address for "<client>" should be correct
And the system ID for "<client>" should be correct
And the system name for "<client>" should be correct
And I should see several text fields for "<client>"
And I should see several text fields

# TODO: remove the "skip" tags when Rocky and Alma have patches available.
@skip_for_rocky9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Feature: The system details of each minion and client provides an overview of th
And the system ID for "sle_minion" should be correct
And the system name for "sle_minion" should be correct
And the uptime for "sle_minion" should be correct
And I should see several text fields for "sle_minion"
And I should see several text fields

@rhlike_minion
Scenario: Red Hat-like minion hardware refresh
Expand All @@ -48,7 +48,7 @@ Feature: The system details of each minion and client provides an overview of th
And the system ID for "rhlike_minion" should be correct
And the system name for "rhlike_minion" should be correct
And the uptime for "rhlike_minion" should be correct
And I should see several text fields for "rhlike_minion"
And I should see several text fields

@deblike_minion
Scenario: Debian-like minion hardware refresh
Expand All @@ -70,7 +70,7 @@ Feature: The system details of each minion and client provides an overview of th
And the system ID for "deblike_minion" should be correct
And the system name for "deblike_minion" should be correct
And the uptime for "deblike_minion" should be correct
And I should see several text fields for "deblike_minion"
And I should see several text fields

@ssh_minion
Scenario: SSH-managed minion hardware refresh
Expand All @@ -91,4 +91,4 @@ Feature: The system details of each minion and client provides an overview of th
And the system ID for "ssh_minion" should be correct
And the system name for "ssh_minion" should be correct
And the uptime for "ssh_minion" should be correct
And I should see several text fields for "ssh_minion"
And I should see several text fields
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Feature: Register and test a Containerized Proxy
And the system ID for "sle_minion" should be correct
And the system name for "sle_minion" should be correct
And the uptime for "sle_minion" should be correct
And I should see several text fields for "sle_minion"
And I should see several text fields

Scenario: Install a patch on the Salt minion
When I follow "Software" in the content area
Expand Down
13 changes: 6 additions & 7 deletions testsuite/features/step_definitions/api_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
refute_nil($client_id, "Could not find system with hostname #{system_name}")
end

When(/^I call system\.bootstrap\(\) on host "([^"]*)" and salt\-ssh "([^"]*)"$/) do |host, salt_ssh_enabled|
When(/^I call system\.bootstrap\(\) on host "([^"]*)" and salt-ssh "([^"]*)"$/) do |host, salt_ssh_enabled|
system_name = get_system_name(host)
salt_ssh = (salt_ssh_enabled == 'enabled')
akey = salt_ssh ? '1-SUSE-SSH-KEY-x86_64' : '1-SUSE-KEY-x86_64'
Expand All @@ -45,8 +45,7 @@
assert(exception_thrown, 'Exception must be thrown for non-existing host.')
end

When(/^I call system\.bootstrap\(\) on a Salt minion with saltSSH = true, \
but with activation key with default contact method, I should get an API fault$/) do
When(/^I call system\.bootstrap\(\) on a Salt minion with saltSSH = true, but with activation key with default contact method, I should get an API fault$/) do
exception_thrown = false
begin
$api_test.system.bootstrap_system(get_target('sle_minion').full_hostname, '1-SUSE-KEY-x86_64', true)
Expand Down Expand Up @@ -480,18 +479,18 @@ def wait_action_complete(actionid, timeout: DEFAULT_TIMEOUT)

## audit namespace

When(/^I call audit\.list_systems_by_patch_status\(\) with CVE identifier "([^\"]*)"$/) do |cve_identifier|
When(/^I call audit\.list_systems_by_patch_status\(\) with CVE identifier "([^"]*)"$/) do |cve_identifier|
@result_list = $api_test.audit.list_systems_by_patch_status(cve_identifier) || []
end

Then(/^I should get status "([^\"]+)" for system "([0-9]+)"$/) do |status, system|
Then(/^I should get status "([^"]+)" for system "([0-9]+)"$/) do |status, system|
@result = @result_list.select { |item| item['system_id'] == system.to_i }
refute_empty(@result)
@result = @result[0]
assert_equal(status, @result['patch_status'])
end

Then(/^I should get status "([^\"]+)" for "([^\"]+)"$/) do |status, host|
Then(/^I should get status "([^"]+)" for "([^"]+)"$/) do |status, host|
node = get_target(host)
step %(I should get status "#{status}" for system "#{get_system_id(node)}")
end
Expand Down Expand Up @@ -548,7 +547,7 @@ def wait_action_complete(actionid, timeout: DEFAULT_TIMEOUT)
@get_file_revision_result = $api_test.configchannel.get_file_revision(channel, file_path, revision.to_i)
end

Then(/^I should get file contents "([^\"]*)"$/) do |contents|
Then(/^I should get file contents "([^"]*)"$/) do |contents|
assert_equal(contents, @get_file_revision_result['contents'])
end

Expand Down
9 changes: 4 additions & 5 deletions testsuite/features/step_definitions/cobbler_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
end

When(/^I remove kickstart profiles and distros$/) do
host = get_target('server').full_hostname
# -------------------------------
# Cleanup kickstart distros and their profiles, if any.

Expand Down Expand Up @@ -140,7 +139,7 @@
result_cobbler, code = get_target('server').run("cobbler profile list | grep -o #{profile}", verbose: true)
cobbler_profiles.push(result_cobbler) if code.zero?
# get all profiles from isolinux.cfg
result_isolinux, code = get_target('server').run("cat #{tmp_dir}/isolinux/isolinux.cfg | grep -o #{profile} | cut -c -6 | head -n 1")
result_isolinux, _code = get_target('server').run("cat #{tmp_dir}/isolinux/isolinux.cfg | grep -o #{profile} | cut -c -6 | head -n 1")
unless result_isolinux.empty?
isolinux_profiles.push(result_isolinux)
end
Expand Down Expand Up @@ -186,7 +185,7 @@
UEFI
EOF")
xorriso = "xorriso -indev #{tmp_dir}/#{name}.iso -report_el_torito 2>/dev/null"
iso_filter = "awk '/^El Torito boot img[[:space:]]+:[[:space:]]+[0-9]+[[:space:]]+[a-zA-Z]+[[:space:]]+y/{print $7}'"
iso_filter = 'awk \'/^El Torito boot img[[:space:]]+:[[:space:]]+[0-9]+[[:space:]]+[a-zA-Z]+[[:space:]]+y/{print $7}\''
iso_file = "#{tmp_dir}/xorriso_#{name}"
out, code = get_target('server').run("#{xorriso} | #{iso_filter} >> #{iso_file}")
raise "error while executing xorriso.\nLogs:\n#{out}" if code.nonzero?
Expand Down Expand Up @@ -241,7 +240,7 @@
result, code = get_target('server').run('systemctl restart apache && systemctl restart cobblerd')
raise "Error while restarting cobblerd.\nLogs:\n#{result}" if code.nonzero?

step %(I wait until "cobblerd" service is active on "server")
step 'I wait until "cobblerd" service is active on "server"'
end

# cobbler commands
Expand Down Expand Up @@ -307,7 +306,7 @@
return_code = file_extract(get_target('server'), cobbler_log_file, local_file)
raise 'File extraction failed' unless return_code.zero?

file_data = File.read(local_file).gsub!("\n", ',').chop.gsub('"', " ' ").gsub("\\''", '"')
file_data = File.read(local_file).gsub!("\n", ',').chop.gsub('"', ' \' ').gsub('\\\'\'', '"')
file_data = "[#{file_data}]"
data_hash = JSON.parse(file_data)
output = data_hash.select { |key, _hash| key['levelname'] == 'ERROR' }
Expand Down
Loading

0 comments on commit d17c127

Please sign in to comment.