Skip to content

Commit

Permalink
QE: Fix server hostname rename test
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Gedon <dominik.gedon@suse.com>
  • Loading branch information
nodeg committed Oct 19, 2023
1 parent 77c90b6 commit 0cd3a6d
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 11 deletions.
1 change: 1 addition & 0 deletions testsuite/.rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ Style/AndOr:
- 'features/step_definitions/common_steps.rb'
- 'features/step_definitions/file_management_steps.rb'
- 'features/step_definitions/retail_steps.rb'
- 'features/step_definitions/salt_steps.rb'
- 'features/step_definitions/setup_steps.rb'

# Offense count: 1
Expand Down
84 changes: 84 additions & 0 deletions testsuite/features/secondary/srv_rename_hostname.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,48 @@ Feature: Reconfigure the server's hostname
When I change the server's short hostname from hosts and hostname files
And I run spacewalk-hostname-rename command on the server

@proxy
Scenario: Copy the new server keys and configure the proxy
When I copy server's keys to the proxy
And I configure the proxy
Then I should see "proxy" via spacecmd
And I restart the "salt-minion" service on "proxy"
Then service "salt-minion" is active on "proxy"
And I restart the "salt-broker" service on "proxy"
Then service "salt-broker" is active on "proxy"

@proxy
Scenario: Apply high state on the proxy to populate new server CA
When I apply highstate on "proxy"

@sle_minion
Scenario: Apply high state on the SUSE Minion to populate new server CA
When I apply highstate on "sle_minion"

@ssh_minion
Scenario: Apply high state on the SUSE SSH Minion to populate new server CA
When I apply highstate on "ssh_minion"

@rhlike_minion
Scenario: Apply high state on the Red Hat-like Minion to populate new server CA
When I apply highstate on "rhlike_minion"

@deblike_minion
Scenario: Apply high state on the Debian-like Minion to populate new server CA
When I apply highstate on "deblike_minion"

@buildhost
Scenario: Apply high state on the build host to populate new server CA
When I apply highstate on "build_host"

@virthost_kvm
Scenario: Apply high state on the virthost to populate new server CA
When I apply highstate on "kvm_server"

@pxeboot_minion
Scenario: Apply high state on the PXE boot minion to populate new server CA
When I apply highstate on "pxeboot_minion"

Scenario: Do some minimal smoke test on the renamed server
Given I am on the Systems overview page of this "sle_minion"
When I follow "Details" in the content area
Expand All @@ -40,3 +82,45 @@ Feature: Reconfigure the server's hostname
Scenario: Change hostname back and reboot server
When I change back the server's hostname
And I run spacewalk-hostname-rename command on the server

@proxy
Scenario: Copy the new server keys and configure the proxy
When I copy server's keys to the proxy
And I configure the proxy
Then I should see "proxy" via spacecmd
And I restart the "salt-minion" service on "proxy"
Then service "salt-minion" is active on "proxy"
And I restart the "salt-broker" service on "proxy"
Then service "salt-broker" is active on "proxy"

@proxy
Scenario: Apply high state on the proxy to populate new server CA
When I apply highstate on "proxy"

@sle_minion
Scenario: Apply high state on the SUSE Minion to populate new server CA
When I apply highstate on "sle_minion"

@ssh_minion
Scenario: Apply high state on the SUSE SSH Minion to populate new server CA
When I apply highstate on "ssh_minion"

@rhlike_minion
Scenario: Apply high state on the Red Hat-like Minion to populate new server CA
When I apply highstate on "rhlike_minion"

@deblike_minion
Scenario: Apply high state on the Debian-like Minion to populate new server CA
When I apply highstate on "deblike_minion"

@buildhost
Scenario: Apply high state on the build host to populate new server CA
When I apply highstate on "build_host"

@virthost_kvm
Scenario: Apply high state on the virthost to populate new server CA
When I apply highstate on "kvm_server"

@pxeboot_minion
Scenario: Apply high state on the PXE boot minion to populate new server CA
When I apply highstate on "pxeboot_minion"
15 changes: 4 additions & 11 deletions testsuite/features/step_definitions/command_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,6 @@
raise 'Vendor change option not found in logs' unless return_code.zero?
end

When(/^I apply highstate on "([^"]*)"$/) do |host|
system_name = get_system_name(host)
if host.include? 'ssh_minion'
cmd = 'mgr-salt-ssh'
elsif host.include? 'minion' or host.include? 'build'
cmd = 'salt'
end
get_target('server').run_until_ok("#{cmd} #{system_name} state.highstate")
end

When(/^I wait until "([^"]*)" service is active on "([^"]*)"$/) do |service, host|
node = get_target(host)
cmd = "systemctl is-active #{service}"
Expand Down Expand Up @@ -1515,6 +1505,10 @@
echo '#{server_node.public_ip} #{server_node.full_hostname} #{old_hostname}' >> /etc/hosts &&
echo '#{server_node.public_ip} #{new_hostname}#{server_node.full_hostname.delete_prefix(server_node.hostname)} #{new_hostname}' >> /etc/hosts")
get_target('server', refresh: true) # This will refresh the attributes of this node
hostname, _result = get_target('server').run("hostname")
hostname.strip!

raise "Wrong hostname after changing it. Is: #{hostname}, should be: #{new_hostname}" if hostname != new_hostname

# Add the new hostname on controller's /etc/hosts to resolve in smoke tests
`echo '#{server_node.public_ip} #{new_hostname}#{server_node.full_hostname.delete_prefix(server_node.hostname)} #{new_hostname}' >> /etc/hosts`
Expand Down Expand Up @@ -1544,7 +1538,6 @@

# Update the server CA certificate since it changed, otherwise all API and browser uses will fail
update_ca('controller')
update_ca('proxy')

# Reset the API client to take the new CA into account
reset_api_client
Expand Down
11 changes: 11 additions & 0 deletions testsuite/features/step_definitions/salt_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -578,3 +578,14 @@ def pillar_get(key, minion)
cleanup = %(salt #{system_name} state.apply util.mgr_switch_to_venv_minion pillar='{"mgr_purge_non_venv_salt_files": True, "mgr_purge_non_venv_salt": True}')
get_target('server').run(cleanup, check_errors: true, verbose: true)
end

When(/^I apply highstate on "([^"]*)"$/) do |host|
system_name = get_system_name(host)
if host.include? 'ssh_minion'
cmd = 'mgr-salt-ssh'
elsif host.include? 'minion' or host.include? 'build' or host.include? 'proxy'
cmd = 'salt'
end
log "#{cmd} #{system_name} state.highstate"
get_target('server').run_until_ok("#{cmd} #{system_name} state.highstate")
end

0 comments on commit 0cd3a6d

Please sign in to comment.